/* Product Radar — стили. Токены темы объявлены на :root, тёмная тема
   переопределяет только значения (data-theme ставится скриптом в <head>). */

:root {
  color-scheme: light;

  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f2ef;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #6f6d67;
  --border: rgba(11, 11, 11, 0.10);
  --grid: #e1e0d9;
  --axis: #c3c2b7;

  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --good: #0ca30c;
  --sale: #d03b3b;
  --star: #eda100;

  /* Категориальные слоты графиков (палитра dataviz, светлый режим) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;

  --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 8px 24px rgba(11, 11, 11, .06);
  --radius: 14px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --border: rgba(255, 255, 255, 0.12);
  --grid: #2c2c2a;
  --axis: #383835;

  --accent: #3987e5;
  --accent-ink: #0d0d0d;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --good: #0ca30c;
  --sale: #e66767;
  --star: #c98500;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;

  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 24px rgba(0, 0, 0, .45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--page);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- Шапка ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 20px;
  height: 62px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.logo:hover { text-decoration: none; }
.logo-mark { font-size: 1.25rem; }

.site-nav { display: flex; gap: 4px; margin-left: auto; }
.site-nav a {
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--text-2);
  font-weight: 500;
  font-size: .95rem;
}
.site-nav a:hover { background: var(--surface-2); text-decoration: none; }
.site-nav a.active { background: var(--accent-soft); color: var(--accent); }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease;
}
.icon-btn:hover { background: var(--surface-2); transform: rotate(-12deg); }

/* ---------- Заголовок страницы ---------- */

.hero { padding: 36px 0 20px; }
.hero h1 {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 4vw, 2.3rem);
  letter-spacing: -0.02em;
}
.hero-sub { margin: 0; color: var(--text-2); max-width: 60ch; }

/* ---------- Панель фильтров ---------- */

.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.search-wrap { position: relative; }
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  opacity: .55;
  pointer-events: none;
}
#searchInput {
  width: 100%;
  padding: 12px 14px 12px 42px;
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
}
#searchInput:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font: inherit;
  font-size: .9rem;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chip .chip-count { opacity: .7; font-size: .85em; margin-left: 4px; }

.filters-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.filter-field { display: grid; gap: 4px; font-size: .82rem; color: var(--muted); }
.filter-field input,
.filter-field select {
  font: inherit;
  font-size: .92rem;
  padding: 8px 10px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.filter-field input { width: 110px; }
.filter-field input:focus,
.filter-field select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: .92rem;
  color: var(--text-2);
  cursor: pointer;
  padding-bottom: 8px;
}
.check-field input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn-ghost {
  padding: 8px 14px;
  font: inherit;
  font-size: .92rem;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-ghost:hover { background: var(--surface); border-color: var(--accent); color: var(--accent); }
.btn-ghost[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.pill {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: inherit;
  font-size: .8rem;
  text-align: center;
}
.btn-ghost[aria-pressed="true"] .pill { background: rgba(255, 255, 255, .25); }

.results-meta {
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: .9rem;
}

/* ---------- Сетка товаров ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
  padding-bottom: 40px;
}
.grid-similar { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 32px rgba(0, 0, 0, .14); }

.card-media { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--surface-2); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }

.badges { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; }
.badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  color: #fff;
  background: var(--sale);
}
.badge-out { background: #55534e; }

.fav-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, .88);
  color: #55534e;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform .15s ease;
}
.fav-btn:hover { transform: scale(1.12); }
.fav-btn[aria-pressed="true"] { color: var(--sale); }

.card-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card-meta { display: flex; gap: 8px; font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.card-title { margin: 0; font-size: 1rem; line-height: 1.35; }
.card-title a { color: var(--text); }
.card-desc {
  margin: 0;
  font-size: .87rem;
  color: var(--text-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot { margin-top: auto; display: flex; align-items: end; justify-content: space-between; gap: 10px; }
.price-box { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.price { font-size: 1.16rem; font-weight: 700; }
.price-old { font-size: .87rem; color: var(--muted); text-decoration: line-through; }
.rating { display: inline-flex; align-items: center; gap: 4px; font-size: .87rem; color: var(--text-2); white-space: nowrap; }
.rating .star { color: var(--star); }
.stock { font-size: .8rem; }
.stock-in { color: var(--good); }
.stock-out { color: var(--muted); }

.empty { text-align: center; padding: 60px 20px 80px; color: var(--text-2); }
.empty-icon { font-size: 3rem; }
.empty h2 { margin: 10px 0 6px; }
.loading { color: var(--muted); padding: 30px 0; }

/* ---------- Страница товара ---------- */

.breadcrumbs { padding: 20px 0 10px; font-size: .88rem; color: var(--muted); }

.product-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  padding-bottom: 30px;
}
@media (max-width: 780px) { .product-view { grid-template-columns: 1fr; } }

.product-image {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.product-image img { width: 100%; display: block; aspect-ratio: 4 / 3; object-fit: cover; }

.product-info { display: grid; gap: 14px; }
.product-info h1 { margin: 0; font-size: clamp(1.4rem, 3.4vw, 2rem); letter-spacing: -.02em; }
.product-tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  padding: 4px 11px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: .82rem;
  color: var(--text-2);
}
.product-price-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.product-price { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }
.product-desc { margin: 0; color: var(--text-2); }

.spec-table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.spec-table th,
.spec-table td { text-align: left; padding: 9px 0; border-bottom: 1px solid var(--border); }
.spec-table th { color: var(--muted); font-weight: 500; width: 45%; }

.btn-primary {
  justify-self: start;
  padding: 11px 22px;
  font: inherit;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-primary[aria-pressed="true"] {
  background: var(--surface);
  color: var(--sale);
  border-color: var(--sale);
}

.similar { padding-bottom: 40px; }
.similar h2 { font-size: 1.25rem; margin: 10px 0 16px; }

/* ---------- Аналитика ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  padding-bottom: 8px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.tile-label { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.tile-value { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.tile-note { font-size: .84rem; color: var(--text-2); }

.charts {
  display: grid;
  /* min(...) — чтобы на узких экранах колонка не была шире вьюпорта */
  grid-template-columns: repeat(auto-fit, minmax(min(430px, 100%), 1fr));
  gap: 18px;
  padding: 26px 0 8px;
}
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.chart-card h2 { margin: 0 0 14px; font-size: 1.02rem; }
.chart-card-wide { grid-column: 1 / -1; }
.chart-body { width: 100%; overflow-x: auto; }
.chart-body svg { display: block; width: 100%; }
.chart-bar { transition: opacity .12s ease; cursor: default; }
.chart-bar:hover { opacity: .82; }

.chart-tooltip {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  padding: 7px 11px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
  font-size: .85rem;
  color: var(--text);
  white-space: nowrap;
}

.highlights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  padding: 18px 0 50px;
}
.highlight-card {
  display: flex;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.highlight-card img {
  width: 92px;
  height: 92px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex: none;
}
.highlight-card .hl-label { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.highlight-card .hl-name { font-weight: 600; }
.highlight-card .hl-price { font-size: 1.25rem; font-weight: 700; }

/* ---------- Подвал ---------- */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 22px 0 30px;
  color: var(--muted);
  font-size: .88rem;
}

@media (max-width: 560px) {
  .container { padding: 0 14px; }
  .header-inner { gap: 8px; height: 56px; }
  .logo { font-size: .98rem; }
  .site-nav { gap: 2px; }
  .site-nav a { padding: 6px 9px; font-size: .85rem; }
  .icon-btn { width: 34px; height: 34px; flex: none; font-size: .95rem; }
  .filter-field input { width: 92px; }
}

/* Совсем узкие экраны: в шапке остаётся только знак логотипа —
   иначе логотип, навигация и кнопка темы не влезают в строку. */
@media (max-width: 400px) {
  .logo-text { display: none; }
  .logo-mark { font-size: 1.4rem; }
  .site-nav a { padding: 6px 8px; font-size: .82rem; }
}
