/* Ozon Bonus Hunter — feed-страница: filter UI + product grid.
 * Совместим с двумя проектами:
 *   - bot_Ozon: загружается ПОСЛЕ ozon-shell.css (тот переопределяет токены)
 *   - bot_Bonus: загружается одиночно (этот файл сам всё определяет)
 *
 * Layout v3 (2026-05-13): фильтры в боковом sidebar (а не inline в main).
 * Совместимость: классы .filters / .search / .cs / .slider-block / .histogram
 * / .dual-range / .grid / .card сохраняют семантику для legacy-кода.
 */

:root {
  /* Brand + базовые токены (дубль ozon-shell.css для standalone-режима) */
  --brand: #005BFF;
  --brand-hover: #1F75FF;
  --brand-press: #003ECC;
  --brand-soft: rgba(0, 91, 255, .10);
  --brand-softer: rgba(0, 91, 255, .04);
  --brand-glow: 0 0 0 3px rgba(0, 91, 255, .14);

  --accent-warm: #F91155;
  --accent-warm-hover: #FF2E6E;
  --accent-warm-soft: rgba(249, 17, 85, .10);

  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #F4F5F8;
  --surface-3: #ECEEF2;
  --surface-inset: #E8EAEF;
  --surface-hover: #F0F2F6;

  --border: #E8EAEF;
  --border-strong: #D6D9DF;

  --text: #0B1117;
  --text-secondary: #475063;
  --text-tertiary: #818A9A;

  --success: #00B36B;
  --success-bg: rgba(0, 179, 107, .10);
  --warning: #B26900;
  --warning-bg: rgba(255, 153, 0, .10);
  --danger: #DC3545;
  --danger-bg: rgba(220, 53, 69, .10);

  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-pill: 999px;

  --shadow-sm:  0 1px 2px rgba(11, 18, 32, .04);
  --shadow-md:  0 4px 16px rgba(11, 18, 32, .06);
  --shadow-lg:  0 12px 32px rgba(11, 18, 32, .10);
  --shadow-xl:  0 24px 56px rgba(11, 18, 32, .14);

  --font-sans: "Onest", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Consolas, monospace;
  --font-display: var(--font-sans);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --t-fast: 140ms var(--ease-out);
  --t-med:  220ms var(--ease-out);

  --ozon-primary: var(--brand);
  --ozon-primary-dark: var(--brand-press);
  --ozon-primary-soft: var(--brand-soft);
  --ozon-primary-softer: var(--brand-softer);
  --ozon-secondary: var(--accent-warm);
  --success-soft: var(--success-bg);
  --warning-soft: var(--warning-bg);
  --danger-soft: var(--danger-bg);
  --shadow: var(--shadow-sm);
  --shadow-card: var(--shadow-sm);
  --radius: var(--r-md);
  --radius-sm: var(--r-sm);
  --radius-md: var(--r-md);
  --radius-lg: var(--r-lg);
  --radius-pill: var(--r-pill);

  /* Dual-range / histogram геометрия — handle 22, track inset = handle/2 */
  --handle-size: 22px;
  --track-h: 6px;
  --track-radius: 999px;

  /* CSS-var для расчёта alignment: bar count устанавливается JS-ом в
     paintHistogram() как el.style.setProperty('--hist-n', n).
     Используется в padding histogram. */

  --hist-bar: rgba(0, 91, 255, .35);
  --hist-bar-dim: rgba(138, 147, 166, .22);

  --bonus-bg: linear-gradient(135deg, #5B51DE 0%, #7B5BFF 100%);
  --bonus-text: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07090E;
    --surface: #0F141C;
    --surface-2: #141A24;
    --surface-3: #1B222F;
    --surface-inset: #080B11;
    --surface-hover: #181F2B;

    --border: #1B222F;
    --border-strong: #2A3142;

    --text: #F0F2F7;
    --text-secondary: #A7B0C2;
    --text-tertiary: #6E7689;

    --brand-soft: rgba(0, 91, 255, .14);
    --brand-softer: rgba(0, 91, 255, .06);
    --brand-glow: 0 0 0 3px rgba(0, 91, 255, .22);
    --brand-hover: #3284FF;

    --accent-warm-soft: rgba(249, 17, 85, .14);

    --success-bg: rgba(0, 179, 107, .14);
    --warning-bg: rgba(255, 153, 0, .14);
    --danger-bg: rgba(220, 53, 69, .14);

    --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
    --shadow-md: 0 8px 24px rgba(0,0,0,.4);
    --shadow-lg: 0 16px 40px rgba(0,0,0,.5);
    --shadow-xl: 0 32px 64px rgba(0,0,0,.55);

    --hist-bar: rgba(60, 142, 255, .55);
    --hist-bar-dim: rgba(138, 147, 166, .14);
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--tg-theme-bg-color, var(--bg));
  color: var(--tg-theme-text-color, var(--text));
  font-family: "Onest", -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  font-size: 14px; line-height: 1.5;
  font-feature-settings: "cv11", "ss01";
  letter-spacing: -.006em;
  -webkit-font-smoothing: antialiased;
}
body {
  padding-bottom: env(safe-area-inset-bottom, 0);
  overscroll-behavior-y: none;
  overflow-x: hidden;
  overflow-x: clip;
  max-width: 100vw;
}

/* ============================================================
 * MOBILE FALLBACK TOPBAR (для случая когда .shell не используется)
 * ============================================================ */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: max(14px, env(safe-area-inset-top, 0px) + 10px) 16px 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}
.brand { display: flex; align-items: center; gap: 8px; justify-content: center; }
.logo-img {
  height: 22px; width: auto; display: block;
  user-select: none; -webkit-user-drag: none; pointer-events: none;
}
@media (prefers-color-scheme: dark) {
  .logo-img { filter: brightness(0) invert(1); }
}
.icon-btn {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  color: transparent; opacity: 0;
  border-radius: 50%; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ============================================================
 * FILTERS — теперь в sidebar (не в card). Каждый блок отдельный.
 * ============================================================ */
.filters {
  display: flex; flex-direction: column;
  gap: 22px;
  /* Без background/border — раздел внутри sidebar */
}

/* Group label для каждого фильтра в sidebar — micro-uppercase mono */
.filter-group {
  display: flex; flex-direction: column;
  gap: 10px;
}
.filter-group-label {
  display: flex; align-items: center;
  font: 600 10.5px/1 "JetBrains Mono", ui-monospace, monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}
.filter-group-label::after {
  content: "";
  flex: 1;
  height: 1px;
  margin-left: 10px;
  background: var(--border);
}

/* ============================================================
 * SEARCH
 * ============================================================ */
.search { position: relative; display: block; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-tertiary); pointer-events: none;
  display: inline-flex;
  transition: color var(--t-fast);
}
.search input {
  width: 100%; height: 40px;
  padding: 0 36px 0 36px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font: 500 13.5px var(--font-sans);
  letter-spacing: -.005em;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--text-tertiary); }
.search input:hover { background: var(--surface-3); }
.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration { -webkit-appearance: none; }
.search input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--brand-glow);
}
.search input:focus ~ .search-icon { color: var(--brand); }

.search-clear {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: var(--r-sm);
  background: var(--surface-3); color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.search-clear:hover {
  background: var(--danger-bg); color: var(--danger);
}
.search-clear[hidden] { display: none; }

/* ============================================================
 * PRESETS (если используются на bot_Bonus)
 * ============================================================ */
.presets {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 2px 0 4px;
  margin: 0 -2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.presets::-webkit-scrollbar { display: none; }
.chip-preset {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-secondary);
  font: 600 12px var(--font-sans);
  letter-spacing: -.005em;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.chip-preset:hover {
  border-color: var(--brand);
  color: var(--text);
}
.chip-preset.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

/* ============================================================
 * ROW — в sidebar layout-е делаем колонку, не grid 2col
 * ============================================================ */
.row {
  display: flex; flex-direction: column; gap: 10px;
}

/* На bot_Bonus где filter inline (не в sidebar) — оставляем 2 col */
body:not(.shell) .row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px;
}

/* ============================================================
 * CUSTOM SELECT (cs)
 * ============================================================ */
.cs { position: relative; min-width: 0; }
.cs-btn {
  width: 100%; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  height: 52px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.cs-btn:hover {
  background: var(--surface-3);
  border-color: var(--border-strong);
}
.cs-btn:focus-visible {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--brand-glow);
  outline: none;
}
.cs[data-open] .cs-btn {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--brand-glow);
}

.cs-icon {
  flex-shrink: 0; display: inline-flex;
  width: 20px; height: 20px;
  color: var(--brand);
}
.cs-icon svg { width: 100%; height: 100%; stroke-width: 1.75; }

.cs-content {
  display: flex; flex-direction: column;
  flex: 1 1 0; min-width: 0;
  line-height: 1.2;
}
.cs-meta {
  font: 600 9.5px/1 var(--font-mono);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .14em;
  margin-bottom: 4px;
}
.cs-value {
  font: 600 13px var(--font-sans);
  color: var(--text);
  letter-spacing: -.008em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cs-chev {
  flex-shrink: 0;
  width: 11px; height: 7px;
  color: var(--text-tertiary);
  transition: transform var(--t-fast), color var(--t-fast);
}
.cs[data-open] .cs-chev { transform: rotate(180deg); color: var(--brand); }

.cs-panel {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  max-height: min(360px, 60vh);
  display: flex; flex-direction: column; overflow: hidden;
  transform-origin: top center;
  transform: scale(0.96) translateY(-6px);
  opacity: 0;
  transition: transform var(--t-fast), opacity 120ms ease;
  pointer-events: none;
}
.cs[data-open] .cs-panel {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.cs-panel[hidden] { display: none; }

.cs-search {
  position: relative; flex-shrink: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-tertiary);
}
.cs-search svg { width: 16px; height: 16px; flex-shrink: 0; }
.cs-search input {
  flex: 1; min-width: 0;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text);
  font: 500 13px var(--font-sans);
  outline: none;
  padding: 0;
}

.cs-list {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px;
}

.cs-opt {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  min-height: 36px;
  border: none;
  background: transparent;
  color: var(--text);
  font: 500 13px var(--font-sans);
  letter-spacing: -.005em;
  text-align: left;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: background var(--t-fast), color var(--t-fast);
}
.cs-opt:hover, .cs-opt:focus-visible {
  background: var(--brand-softer);
  outline: none;
}
.cs-opt[aria-selected="true"] {
  color: var(--brand);
  font-weight: 600;
  background: var(--brand-soft);
}
.cs-opt[aria-selected="true"] .cs-opt-check { opacity: 1; }

.cs-opt-icon {
  flex-shrink: 0;
  width: 16px; height: 16px;
  color: var(--text-tertiary);
}
.cs-opt[aria-selected="true"] .cs-opt-icon { color: var(--brand); }
.cs-opt-text {
  flex: 1 1 auto; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cs-opt-count {
  flex-shrink: 0;
  font: 600 11px var(--font-mono);
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.cs-opt-check {
  flex-shrink: 0; width: 14px; height: 14px;
  color: var(--brand);
  opacity: 0;
  transition: opacity var(--t-fast);
}
.cs-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
}

/* ============================================================
 * SLIDER BLOCK
 * ============================================================ */
.slider-block {
  display: flex; flex-direction: column;
  gap: 4px;
}

.slider-block.is-loading .histogram .bar {
  background: linear-gradient(110deg,
    var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
.slider-block.is-loading .dual-range .handle {
  background: var(--surface-3);
  border-color: var(--border-strong);
  box-shadow: none;
}
.slider-block.is-loading .dual-range .track-fill {
  background: linear-gradient(110deg,
    var(--surface-3) 0%, var(--surface-2) 40%, var(--surface-3) 80%);
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
}
.slider-block.is-loading .num,
.slider-block.is-loading .slider-hint,
.slider-block.is-loading .hist-axis { opacity: 0.5; }
.slider-block.is-loading .num,
.slider-block.is-loading .dual-range .handle { pointer-events: none; }

.slider-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.slider-label {
  font: 600 12px/1 var(--font-mono);
  color: var(--text);
  letter-spacing: .04em;
  text-transform: uppercase;
}
.slider-hint {
  font: 500 11px var(--font-mono);
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

/* ============================================================
 * HISTOGRAM — фикс alignment со слайдером.
 *
 * Цель: центр первого/последнего бара должен совпадать с leftmost/rightmost
 * центром thumb-а. Thumb traversal: [11px, container.width - 11px] (где 11 =
 * half handle size).
 *
 * Решение: histogram использует grid layout с N равными колонками, каждый
 * bar занимает свою колонку и центрируется внутри (margin: 0 auto + узкая
 * ширина). Track слайдера тоже инсетим симметрично: каждый край = column/2.
 *
 * JS устанавливает CSS-var `--hist-n` = количество бинов на .slider-block.
 * Тогда:
 *   - histogram: grid-template-columns: repeat(var(--hist-n), 1fr)
 *   - track inset: calc(50% / var(--hist-n))
 * И bar i центр = (i + 0.5) * (100% / N) = thumb position для value i.
 * Симметрично — переход thumb 0..1 проходит через все bar центры точно.
 * ============================================================ */
.slider-block {
  --hist-n: 24;  /* fallback — JS установит реальное */
}

.histogram {
  display: grid;
  grid-template-columns: repeat(var(--hist-n), 1fr);
  gap: 0;
  padding: 0;
  height: 32px;
  align-items: end;
}
.histogram .bar {
  width: calc(100% - 2px);  /* 1px margin с каждой стороны = визуальный gap */
  margin: 0 auto;
  background: var(--hist-bar-dim);
  border-radius: 2px 2px 0 0;
  transition: background var(--t-med), height 280ms var(--ease-out);
  min-height: 2px;
}
.histogram .bar.in-range {
  background: linear-gradient(180deg, var(--brand) 0%, rgba(0, 91, 255, .55) 100%);
}

.hist-axis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin: 6px 0 2px;
  font: 500 10px var(--font-mono);
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  pointer-events: none;
}
.hist-axis > :first-child { justify-self: start; }
.hist-axis > :last-child { justify-self: end; }

/* ============================================================
 * DUAL RANGE — track inset аналогично гистограмме (column/2)
 * ============================================================ */
.dual-range {
  position: relative;
  height: var(--handle-size);
  margin: 2px 0 12px;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
}
.dual-range .track {
  position: absolute;
  /* Inset = half column width (когда есть N bars). Это выравнивает thumb
     position с bar центрами: thumb on 0% = bar[0] center, thumb 100% =
     bar[N-1] center. `--hist-n` задаётся в paintHistogram на .slider-block
     (родитель), наследуется сюда через CSS-cascade. */
  left: calc(50% / var(--hist-n, 24));
  right: calc(50% / var(--hist-n, 24));
  top: 50%; transform: translateY(-50%);
  height: var(--track-h);
  background: var(--surface-inset);
  border-radius: var(--track-radius);
  border: 1px solid var(--border);
}
.dual-range .track-fill {
  position: absolute;
  left: 0; right: 0;
  top: -1px; bottom: -1px;
  background: linear-gradient(90deg, var(--brand) 0%, var(--brand-hover) 100%);
  border-radius: var(--track-radius);
  pointer-events: none;
  z-index: 1;
  box-shadow: 0 0 12px rgba(0, 91, 255, .25);
}
.dual-range .handle {
  position: absolute;
  left: 0; top: 50%;
  width: var(--handle-size); height: var(--handle-size);
  margin-left: calc(var(--handle-size) / -2);
  margin-top: calc(var(--handle-size) / -2);
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--brand);
  box-shadow: 0 2px 6px rgba(0, 91, 255, .25), 0 0 0 1px rgba(0, 91, 255, .1);
  cursor: grab;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
  z-index: 2;
}
.dual-range .handle:hover { transform: scale(1.08); }
.dual-range .handle:active,
.dual-range .handle.dragging {
  cursor: grabbing;
  transform: scale(1.15);
  box-shadow: 0 4px 16px rgba(0, 91, 255, .4), 0 0 0 6px var(--brand-softer);
  z-index: 3;
}
.dual-range .handle:focus-visible {
  box-shadow: 0 2px 6px rgba(0, 91, 255, .25), 0 0 0 4px var(--brand-softer);
}

.dual-range.single .handle-min { display: none; }
.dual-range.single .track-fill { left: 0; }

/* ============================================================
 * NUMERIC INPUTS
 * ============================================================ */
.num-pair {
  display: flex; align-items: center; gap: 6px;
}
.num {
  flex: 1 1 0; min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--text);
  font: 600 13px var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  outline: none;
  text-align: center;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  -moz-appearance: textfield;
}
.num::-webkit-outer-spin-button,
.num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num::placeholder { color: var(--text-tertiary); font-weight: 500; }
.num:hover { background: var(--surface-3); }
.num:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: var(--brand-glow);
}
.num-sep { color: var(--text-tertiary); font-size: 13px; }
.num-suffix {
  font: 600 10.5px var(--font-mono);
  color: var(--text-tertiary);
  flex-shrink: 0;
  min-width: 36px;
  text-align: right;
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* ============================================================
 * ACTIVE CHIPS
 * ============================================================ */
.active-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 0 0;
  margin-top: 4px;
  border-top: 1px dashed var(--border);
}
.active-chips[hidden] { display: none; }
.chip-active {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 4px 0 10px;
  background: var(--brand-soft);
  color: var(--brand);
  border: none;
  border-radius: var(--r-pill);
  font: 600 11.5px var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.005em;
  cursor: pointer;
  transition: background var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.chip-active:hover { background: rgba(0, 91, 255, .18); }
.chip-active .x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
}

.chip-adjusted {
  background: var(--warning-bg);
  color: var(--warning);
  order: -1;
}
.chip-adjusted .x { background: var(--warning); }
.chip-adjusted:hover { background: rgba(255, 153, 0, .22); }

/* ============================================================
 * RESET button — smart с counter
 * ============================================================ */
.reset {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-secondary);
  font: 600 13px var(--font-sans);
  letter-spacing: -.005em;
  cursor: pointer;
  transition: all var(--t-fast);
  margin-top: 4px;
}
.reset svg { stroke-width: 2; transition: transform var(--t-med); }
.reset:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-softer);
}
.reset:hover svg { transform: rotate(-60deg); }
.reset:active { transform: scale(0.99); }

.reset--active {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}
.reset--active:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.reset--active .reset-count {
  background: var(--brand);
  color: #fff;
}
.reset--active:hover .reset-count {
  background: rgba(255, 255, 255, .25);
  color: #fff;
}
.reset-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-secondary);
  font: 700 11px var(--font-mono);
  font-variant-numeric: tabular-nums;
  transition: background var(--t-fast), color var(--t-fast);
}

/* ============================================================
 * FAB — scroll to top
 * ============================================================ */
.fab-top {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-md);
  z-index: 50;
  transition: transform var(--t-med),
              background var(--t-fast),
              color var(--t-fast),
              border-color var(--t-fast),
              opacity var(--t-med);
}
.fab-top:hover {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 12px 28px rgba(0, 91, 255, .3);
}
.fab-top:active { transform: translateY(0) scale(0.96); }
.fab-top[hidden] {
  display: inline-flex !important;
  opacity: 0;
  pointer-events: none;
  transform: translateY(16px) scale(0.9);
}

/* ============================================================
 * RESULTS / GRID
 * ============================================================ */
.results { padding: 0 0 40px; }
.results-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 0 16px;
  font: 500 13px var(--font-sans);
  color: var(--text-secondary);
}
.results-header strong {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.loading-tag {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--brand); margin-left: 6px;
  font: 600 12px var(--font-mono);
}
.spinner {
  width: 12px; height: 12px;
  border: 2px solid var(--brand-soft);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

/* Product grid — крупные тайлы т.к. main теперь шире (sidebar забрал левую часть) */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 600px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1200px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1500px) { .grid { grid-template-columns: repeat(5, 1fr); } }

/* Product card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: transform var(--t-fast), border-color var(--t-fast), box-shadow var(--t-med);
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-img {
  width: 100%; aspect-ratio: 3/4;
  background: var(--surface-2);
  object-fit: cover;
  display: block;
}
.card-img--empty { background: var(--surface-2); }

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-shimmer {
  background: linear-gradient(110deg,
    var(--surface-2)  0%,
    var(--surface-3) 40%,
    var(--surface-2) 80%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.card.skeleton { pointer-events: none; }
.card.skeleton .card-img {
  animation: shimmer 1.4s linear infinite;
  background: linear-gradient(110deg,
    var(--surface-2)  0%,
    var(--surface-3) 40%,
    var(--surface-2) 80%);
  background-size: 200% 100%;
}
.sk-bar { height: 12px; border-radius: 4px; }
.sk-bar--price { width: 50%; height: 16px; margin-bottom: 4px; }
.sk-bar--name  { width: 92%; }
.sk-bar--name2 { width: 70%; }
.sk-bar--cat   { width: 40%; height: 8px; margin-top: auto; }
@media (prefers-reduced-motion: reduce) {
  .skeleton-shimmer, .card.skeleton .card-img { animation: none; }
}

.card-img-wrap { position: relative; display: block; }

.bonus-badge {
  position: absolute; left: 8px; bottom: 8px;
  background: var(--bonus-bg);
  color: var(--bonus-text);
  border-radius: var(--r-sm);
  padding: 4px 8px;
  font: 700 11px var(--font-mono);
  letter-spacing: -.005em;
  display: inline-flex; align-items: center; gap: 4px;
  box-shadow: 0 4px 12px rgba(91, 81, 222, .35);
}
.bonus-badge::before {
  content: "";
  width: 10px; height: 10px;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23fff'><path d='M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z'/></svg>") center/contain no-repeat;
}

.card-body {
  padding: 10px 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
  flex: 1;
}
.price-row {
  display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap;
}
.price {
  font: 700 17px/1 var(--font-display);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.ratio {
  margin-left: auto;
  font: 700 11px var(--font-mono);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  background: var(--brand-soft);
  color: var(--brand);
}
.name {
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 52px;
}
.cat {
  font: 600 10px var(--font-mono);
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: auto;
}

.more { display: flex; justify-content: center; padding: 18px; }
.more button {
  height: 40px;
  padding: 0 24px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font: 600 13.5px var(--font-sans);
  cursor: pointer;
  transition: all var(--t-fast);
}
.more button:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-softer);
}

.empty {
  text-align: center; padding: 56px 20px;
  color: var(--text-secondary);
  grid-column: 1 / -1;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.empty-icon {
  width: 56px; height: 56px;
  border-radius: 12px;
  background: var(--brand-soft);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--brand);
}
.empty-title {
  font: 700 16px var(--font-display);
  color: var(--text);
  letter-spacing: -.018em;
}
.empty-msg {
  line-height: 1.5;
  max-width: 320px;
  font-size: 13px;
}
.empty-cta {
  margin-top: 4px;
  height: 38px;
  padding: 0 20px;
  border: 1px solid var(--brand);
  border-radius: var(--r-md);
  background: transparent;
  color: var(--brand);
  font: 600 13px var(--font-sans);
  cursor: pointer;
  transition: all var(--t-fast);
}
.empty-cta:hover {
  background: var(--brand); color: #fff;
}

.adjusted {
  font: 700 10px var(--font-mono);
  padding: 2px 6px;
  border-radius: var(--r-xs);
  background: var(--brand-soft);
  color: var(--brand);
  margin-left: 4px;
}

/* ============================================================
 * AUTH OVERLAY (тот же что был)
 * ============================================================ */
.auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 16px;
  overflow-y: auto;
  overflow-x: hidden;
}
.auth-overlay[hidden] { display: none !important; }
@media (max-width: 360px) {
  .auth-overlay { padding: 8px; }
  .auth-card { padding: 18px 14px; }
}

.auth-card {
  width: 100%; max-width: 380px;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px 24px;
  text-align: center;
  box-shadow: var(--shadow-xl);
  overflow-x: hidden;
  position: relative;
}
.auth-card::before {
  content: ""; position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--brand-softer) 0%, transparent 50%);
  pointer-events: none;
}
.auth-card > * { position: relative; }

.auth-spin { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.auth-spin-ring {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: auth-spin 0.9s linear infinite;
}
.auth-spin-text { color: var(--text-secondary); font: 500 13.5px var(--font-sans); }
@keyframes auth-spin { to { transform: rotate(360deg); } }

.auth-h {
  font: 700 20px/1.2 var(--font-display);
  margin: 4px 0 8px;
  color: var(--text);
  letter-spacing: -.022em;
}
.auth-p {
  font: 500 14px/1.55 var(--font-sans);
  color: var(--text-secondary);
  margin: 0 0 18px;
}
.auth-tg-slot { display: flex; justify-content: center; min-height: 40px; margin: 8px 0; }
.auth-or {
  color: var(--text-tertiary);
  font: 700 11px var(--font-mono);
  margin: 14px 0 8px;
  text-transform: uppercase;
  letter-spacing: .14em;
  display: flex; align-items: center; gap: 10px;
}
.auth-or::before, .auth-or::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.auth-link {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  text-decoration: none;
  color: var(--text);
  font: 500 14px var(--font-sans);
  transition: all var(--t-fast);
}
.auth-link:hover { background: var(--surface-3); border-color: var(--brand); }

.auth-icon { font-size: 40px; margin-bottom: 12px; }
.auth-id {
  display: inline-block;
  padding: 8px 14px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  font: 500 13px var(--font-mono);
  color: var(--text);
}

.auth-btn-bot {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  background: linear-gradient(135deg, #229ED9 0%, #1c87b8 100%);
  color: #fff;
  text-decoration: none;
  border-radius: var(--r-md);
  font: 600 14px var(--font-sans);
  margin: 6px 0;
  text-align: center; line-height: 1.25;
  transition: transform var(--t-fast), box-shadow var(--t-fast);
}
.auth-btn-bot:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(34, 158, 217, .35);
}

.auth-code-form { margin-top: 14px; }
.auth-code-input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font: 600 24px var(--font-mono);
  text-align: center;
  letter-spacing: 0.32em;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.auth-code-input:focus {
  border-color: var(--brand);
  box-shadow: var(--brand-glow);
}
.auth-code-input:disabled { opacity: 0.6; }

.auth-code-hint {
  margin-top: 10px;
  text-align: center;
  font: 500 12.5px var(--font-mono);
  color: var(--text-tertiary);
}
.auth-code-msg {
  margin-top: 10px;
  font: 500 13px var(--font-sans);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(220, 53, 69, .25);
  text-align: center;
}

/* ============================================================
 * Delivery / stock badges на product card
 * ============================================================ */
.delivery-badge {
  position: absolute; right: 8px; bottom: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px 8px;
  font: 700 11px var(--font-mono);
  letter-spacing: -.005em;
  display: inline-flex; align-items: center; gap: 4px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(6px);
}
.delivery-badge--fast {
  background: rgba(0, 179, 107, .92);
  color: #fff;
  border-color: transparent;
}
.delivery-badge--slow {
  background: rgba(255, 153, 0, .92);
  color: #fff;
  border-color: transparent;
}

.stock-badge {
  position: absolute; left: 8px; top: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 3px 7px;
  font: 700 10.5px var(--font-mono);
  letter-spacing: -.005em;
  backdrop-filter: blur(6px);
}
.stock-badge--low {
  background: rgba(220, 53, 69, .92);
  color: #fff;
  border-color: transparent;
}
