:root {
  color-scheme: dark;
  --bg: #101113;
  --panel: #191b1f;
  --panel-2: #22252b;
  --line: #30343b;
  --text: #f5f7fa;
  --muted: #9da7b3;
  --accent: #30d158;
  --accent-2: #ffd23f;
  --danger: #ff5c5c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

button,
.offer {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--accent);
  color: #071008;
  cursor: pointer;
  font-weight: 700;
  padding: 10px 14px;
}

button.ghost,
.admin-link {
  background: transparent;
  color: var(--text);
}

button.danger {
  background: var(--danger);
  color: #180000;
}

.topbar {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 24px;
}

.brand {
  font-size: 20px;
  font-weight: 900;
}

.catalog,
.admin {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px 20px 56px;
}

.intro {
  align-items: end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 28px;
}

.intro p {
  color: var(--muted);
  font-size: 18px;
  margin: 0;
}

.site-search {
  margin-top: 12px;
  width: min(420px, 100%);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filters button {
  background: var(--panel);
  color: var(--text);
  padding: 8px 12px;
}

.filters button.active {
  background: var(--accent-2);
  color: #151200;
}

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.product-card,
.admin-card,
.login-panel,
dialog {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.product-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.image-wrap {
  align-items: center;
  aspect-ratio: 16 / 10;
  background: #252932;
  color: var(--muted);
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.image-wrap img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.product-body {
  padding: 16px;
}

.product-meta,
.muted {
  color: var(--muted);
}

.product-body h2 {
  font-size: 20px;
  line-height: 1.2;
  margin: 6px 0 8px;
}

.product-body p {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

.offers {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 16px;
}

.offer {
  align-items: center;
  background: var(--panel-2);
  color: var(--text);
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr auto;
}

.offer small {
  color: var(--muted);
  display: block;
  font-weight: 500;
}

.clicks {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.offer em,
.badge {
  background: var(--accent-2);
  border-radius: 999px;
  color: #151200;
  font-size: 12px;
  font-style: normal;
  padding: 3px 7px;
  width: fit-content;
}

.price {
  color: var(--accent);
  font-weight: 900;
}

.login-panel {
  margin: 10vh auto 0;
  max-width: 380px;
  padding: 24px;
}

.login-panel form,
.admin-grid,
.row-actions,
.admin-card-head,
.dialog-actions {
  display: flex;
  gap: 10px;
}

.login-panel form {
  flex-direction: column;
}

input,
textarea,
select {
  background: #0f1012;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  min-width: 0;
  padding: 10px 12px;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

.admin-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
}

.head-actions {
  display: flex;
  gap: 10px;
}

.admin-toolbar {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(220px, 1fr) 160px auto auto;
  margin-bottom: 8px;
}

.admin-count {
  margin: 0 0 12px;
}

.admin-list {
  display: grid;
  gap: 8px;
  max-height: calc(100vh - 240px);
  overflow: auto;
}

.admin-workspace {
  align-items: start;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
}

.product-list-row {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  display: grid;
  gap: 10px;
  grid-template-columns: 54px minmax(0, 1fr) 82px;
  padding: 8px;
  text-align: left;
}

.product-list-row.selected {
  border-color: var(--accent);
}

.product-list-row strong,
.product-list-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-list-row small,
.product-list-row em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.product-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 16px;
  position: sticky;
  top: 16px;
}

.editor-head {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.editor-head h2 {
  font-size: 20px;
  margin: 0 0 4px;
}

.admin-card {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.admin-card.compact {
  padding: 10px;
}

.admin-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 42px 54px minmax(180px, 1fr) 180px 96px 128px 82px 76px;
}

.expand-btn {
  height: 36px;
  padding: 0;
  width: 36px;
}

.thumb {
  align-items: center;
  background: #252932;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  height: 42px;
  justify-content: center;
  overflow: hidden;
  width: 54px;
}

.thumb img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.offer-count,
.publish-toggle {
  color: var(--muted);
  font-size: 13px;
}

.admin-details {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  padding-top: 10px;
}

.admin-card-head {
  align-items: center;
}

.admin-card-head input[name="name"] {
  flex: 1;
  font-weight: 800;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
}

.offer-edit {
  display: grid;
  gap: 8px;
  grid-template-columns: 150px 100px 100px 80px 1fr 1fr 80px;
  margin-bottom: 8px;
}

dialog {
  color: var(--text);
  max-width: 760px;
  padding: 0;
  width: min(calc(100vw - 28px), 760px);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.dialog-head,
.dialog-actions {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
}

.dialog-actions {
  border-bottom: 0;
  border-top: 1px solid var(--line);
}

.icon {
  background: transparent;
  color: var(--text);
  font-size: 24px;
  padding: 4px 10px;
}

.import-content {
  max-height: 60vh;
  overflow: auto;
  padding: 16px;
}

.summary {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, auto 1fr);
}

.product-page {
  max-width: 980px;
}

.product-hero {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  margin-bottom: 24px;
}

.product-hero-image {
  align-items: center;
  aspect-ratio: 16 / 10;
  background: #252932;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

.product-hero-image img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.product-hero-copy h1 {
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1;
  margin: 8px 0 14px;
}

.product-hero-copy p {
  color: var(--muted);
  line-height: 1.55;
}

.special-discount {
  background: var(--accent-2);
  border-radius: 8px;
  color: #151200;
  font-weight: 900;
  margin-top: 16px;
  padding: 12px 14px;
}

.product-offers {
  display: grid;
  gap: 12px;
}

.detail-offer {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.errors {
  color: var(--danger);
}

@media (max-width: 820px) {
  .intro,
  .admin-head,
  .admin-card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-grid,
  .offer-edit,
  .admin-toolbar,
  .admin-row,
  .admin-workspace,
  .product-hero {
    grid-template-columns: 1fr;
  }

  .product-editor {
    position: static;
  }

  .thumb {
    display: none;
  }
}
