/* ═══════════════════════════════════════════════════════════════
   instafox — направление: «patisserie editorial»
   тёплый дорогой люкс для школы кондитеров. Fraunces + Manrope,
   кремовые фоны, карамель/эспрессо, персиковый бренд как акцент.
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* — светлая тема (крем-патиссери) — */
  --bg:            #f4ece0;   /* тёплый кремовый холст */
  --bg-tint:       #efe4d4;   /* чуть глубже для полос */
  --surface:       #fbf6ef;   /* карточка */
  --surface-2:     #f6efe4;   /* вложенная поверхность */
  --surface-hover: #fdfaf5;
  --ink:           #2a1d12;   /* эспрессо — основной текст */
  --ink-soft:      #6f5c48;   /* какао с молоком */
  --ink-muted:     #a2907c;   /* карамельно-серый */
  --line:          #e6d8c6;   /* тёплая линия */
  --line-strong:   #d8c6ae;

  /* бренд + акценты */
  --peach:         #f9d3b6;   /* фирменный персик */
  --peach-deep:    #f3b98a;
  --caramel:       #c8791f;   /* карамель — действия/акцент */
  --caramel-ink:   #a4610f;
  --berry:         #b23a48;   /* ягодный — тревога/промахи */
  --pistachio:     #7e8b52;   /* фисташка — успех */
  --gold:          #c9a24a;

  /* заливки статусов (мягкие) */
  --peach-wash:    #fbe4d0;
  --berry-wash:    #f4dcd8;
  --pist-wash:     #e6ead0;

  /* типографика */
  --display: 'Fraunces', 'Georgia', serif;
  --body:    'Manrope', 'Geometria', system-ui, sans-serif;

  /* радиусы */
  --r-xs: 8px;  --r-sm: 12px;  --r-md: 16px;  --r-lg: 22px;  --r-pill: 999px;

  /* тёплые тени (коричневатый оттенок, не серый) */
  --sh-sm: 0 1px 2px rgba(74,49,26,.06), 0 2px 6px rgba(74,49,26,.05);
  --sh-md: 0 2px 6px rgba(74,49,26,.06), 0 10px 24px rgba(74,49,26,.09);
  --sh-lg: 0 8px 20px rgba(74,49,26,.10), 0 24px 60px rgba(74,49,26,.14);
  --sh-glow: 0 0 0 1px rgba(200,121,31,.14), 0 8px 26px rgba(200,121,31,.20);

  /* движение */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-soft: cubic-bezier(.4, 0, .2, 1);
  --dur: .22s;

  --sidebar-w: 244px;
  --maxw: 1240px;
}

:root[data-theme="dark"] {
  --bg:            #1a130d;   /* тёмный какао */
  --bg-tint:       #211811;
  --surface:       #241a12;
  --surface-2:     #2c211829;
  --surface-hover: #2e2318;
  --ink:           #f4e9db;
  --ink-soft:      #cbb6a0;
  --ink-muted:     #97836e;
  --line:          #38291d;
  --line-strong:   #4a3524;

  --peach:         #f6c79f;
  --peach-deep:    #f0ad76;
  --caramel:       #eeae5e;
  --caramel-ink:   #f2bd77;
  --berry:         #e07884;
  --pistachio:     #a7b573;
  --gold:          #d9b968;

  --peach-wash:    #3a281a;
  --berry-wash:    #3c2622;
  --pist-wash:     #2b311d;

  --sh-sm: 0 1px 2px rgba(0,0,0,.34);
  --sh-md: 0 2px 8px rgba(0,0,0,.36), 0 12px 30px rgba(0,0,0,.4);
  --sh-lg: 0 10px 30px rgba(0,0,0,.5), 0 30px 70px rgba(0,0,0,.55);
  --sh-glow: 0 0 0 1px rgba(238,174,94,.24), 0 8px 30px rgba(238,174,94,.22);
}

/* ─── reset ─── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv11", "ss01";
  transition: background var(--dur) var(--ease-soft), color var(--dur) var(--ease-soft);
}

/* тонкое зерно бумаги поверх фона */
body::before {
  content: "";
  position: fixed; inset: 0;
  z-index: 0; pointer-events: none;
  opacity: .5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.045'/%3E%3C/svg%3E");
}
:root[data-theme="dark"] body::before { opacity: .7; }

/* тёплое сияние в углу холста */
body::after {
  content: "";
  position: fixed; inset: 0;
  z-index: 0; pointer-events: none;
  background:
    radial-gradient(60% 50% at 100% 0%, rgba(249,211,182,.28), transparent 60%),
    radial-gradient(50% 40% at 0% 100%, rgba(200,121,31,.10), transparent 55%);
}
:root[data-theme="dark"] body::after {
  background:
    radial-gradient(60% 50% at 100% 0%, rgba(238,174,94,.10), transparent 60%),
    radial-gradient(50% 40% at 0% 100%, rgba(160,90,20,.12), transparent 55%);
}

h1, h2, h3 { font-family: var(--display); font-weight: 560; letter-spacing: -.01em; margin: 0; }
a { color: inherit; text-decoration: none; }

/* ─── каркас: sidebar + main ─── */
.shell { position: relative; z-index: 1; display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px;
  padding: 26px 16px;
  background: linear-gradient(180deg, var(--bg-tint), var(--bg));
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 22px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-size: 20px;
  background: linear-gradient(140deg, var(--peach), var(--peach-deep));
  box-shadow: var(--sh-glow);
}
.brand-name { font-family: var(--display); font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.brand-name b { color: var(--caramel); font-weight: 600; }
.brand-sub { font-size: 11px; color: var(--ink-muted); letter-spacing: .08em; text-transform: uppercase; margin-top: -2px; }

.nav-group { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); padding: 18px 12px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--r-sm);
  color: var(--ink-soft); font-weight: 550; font-size: 14px;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.nav-item .ico { width: 18px; height: 18px; opacity: .8; flex: none; }
.nav-item:hover { background: var(--surface); color: var(--ink); transform: translateX(2px); }
.nav-item.active {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--sh-sm);
  position: relative;
}
.nav-item.active::before {
  content: ""; position: absolute; left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0;
  background: linear-gradient(var(--caramel), var(--peach-deep));
}
.sidebar-foot { margin-top: auto; padding: 12px; display: flex; gap: 8px; }

.main { padding: 26px clamp(18px, 4vw, 44px) 60px; max-width: var(--maxw); width: 100%; }

/* ─── топбар страницы ─── */
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 26px; }
.page-title { font-size: clamp(26px, 3.4vw, 38px); line-height: 1.05; }
.page-kicker { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--caramel); font-family: var(--body); font-weight: 700; margin-bottom: 8px; }
.page-sub { color: var(--ink-soft); font-size: 14px; margin-top: 6px; }
.topbar-tools { display: flex; align-items: center; gap: 10px; }

/* сегментированный переключатель периода */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px; }
.segmented button {
  border: 0; background: transparent; cursor: pointer;
  font-family: var(--body); font-weight: 600; font-size: 13px; color: var(--ink-soft);
  padding: 6px 14px; border-radius: var(--r-pill); transition: all var(--dur) var(--ease);
}
.segmented button.active { background: var(--surface); color: var(--ink); box-shadow: var(--sh-sm); }
.segmented button:hover:not(.active) { color: var(--ink); }

/* диапазон дат */
.date-range { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); }
.date-lbl { font-size: 12px; color: var(--ink-muted); font-weight: 600; }
.date-input { font-family: var(--body); font-size: 13px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 5px 8px; cursor: pointer; transition: border-color var(--dur) var(--ease); }
.date-input:hover { border-color: var(--caramel); }
.date-input:focus { outline: none; border-color: var(--caramel); box-shadow: var(--sh-glow); }
:root[data-theme="dark"] .date-input::-webkit-calendar-picker-indicator { filter: invert(.8); }

.icon-btn {
  width: 40px; height: 40px; border-radius: var(--r-sm); flex: none;
  display: grid; place-items: center; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-soft);
  transition: all var(--dur) var(--ease);
}
.icon-btn:hover { color: var(--ink); box-shadow: var(--sh-md); transform: translateY(-1px); }

/* ─── карточки ─── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  padding: 22px;
}
.card-lg { border-radius: var(--r-lg); padding: 26px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-family: var(--body); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); }

/* ─── KPI-плитки ─── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 20px 20px 18px;
  box-shadow: var(--sh-sm);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); border-color: var(--line-strong); }
.kpi::after {
  content: ""; position: absolute; right: -30px; top: -30px; width: 90px; height: 90px; border-radius: 50%;
  background: radial-gradient(circle, var(--peach-wash), transparent 70%); opacity: .8;
}
.kpi-ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; margin-bottom: 14px;
  background: var(--peach-wash); color: var(--caramel-ink); position: relative; z-index: 1; }
.kpi-val { font-family: var(--display); font-size: 38px; font-weight: 580; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.kpi-label { font-size: 13px; color: var(--ink-soft); margin-top: 7px; position: relative; z-index: 1; }
.kpi-delta { font-size: 12px; font-weight: 700; margin-top: 4px; }
.kpi-delta.up { color: var(--pistachio); }
.kpi-delta.down { color: var(--berry); }

/* ─── таблицы ─── */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-weight: 700; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-muted); padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background var(--dur) var(--ease); cursor: default; }
.table tbody tr:hover td { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.num { font-variant-numeric: tabular-nums; }
.t-strong { font-weight: 650; }

/* мини-бар прогресса в ячейке (доля matched/CR) */
.meter { height: 6px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; min-width: 60px; }
.meter > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--peach-deep), var(--caramel)); }

/* ─── бейджи / чипы ─── */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: var(--r-pill); }
.badge.ig { background: var(--peach-wash); color: var(--caramel-ink); }
.badge.vk { background: var(--pist-wash); color: var(--pistachio); }
.badge.miss { background: var(--berry-wash); color: var(--berry); }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; padding: 4px 11px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft); }
.tag-word { font-weight: 650; color: var(--ink); }

/* чип-ссылка на исходный пост */
.chip-link { text-decoration: none; color: var(--caramel-ink); border-color: var(--line-strong); cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease; }
.chip-link:hover { color: #fff; background: var(--caramel); border-color: var(--caramel); }
.chip-link .ico-ext { width: 13px; height: 13px; flex: none; }
.chip-link-icon { padding: 4px 7px; }                 /* только иконка — компактнее */
/* иконка-ссылка прямо в строке таблицы постов */
.post-cell { display: inline-flex; align-items: center; gap: 8px; }
.row-ext { width: 26px; height: 26px; justify-content: center; padding: 0; opacity: .55; }
tr:hover .row-ext { opacity: 1; }

/* встройка-превью исходного поста (Instagram embed) */
.post-preview { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden; background: #fff; box-shadow: var(--shadow-sm, 0 1px 2px rgb(0 0 0 / .05)); }
.post-preview iframe { display: block; width: 100%; height: 540px; border: 0; }
@media (max-width: 600px) { .post-preview iframe { height: 480px; } }

/* VK: богатая карточка-ссылка (картинку поста без токена не достать) */
.vk-card { display: block; margin-top: 16px; text-decoration: none; color: inherit;
  border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease; }
.vk-card:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: 0 6px 18px rgb(0 0 0 / .07); }
.vk-cover { height: 116px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--surface-2), var(--peach-deep)); color: var(--caramel); }
.vk-cover svg { width: 54px; height: 54px; opacity: .92; }
.vk-card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 3px; }
.vk-card-title { font-weight: 700; color: var(--ink); }
.vk-card-sub { font-size: 13px; color: var(--ink-soft); }
.vk-card-cta { margin-top: 9px; display: inline-flex; align-items: center; gap: 6px;
  color: var(--caramel-ink); font-weight: 650; font-size: 13px; }
.vk-card-cta .ico-ext { width: 14px; height: 14px; }
.vk-card:hover .vk-card-cta { text-decoration: underline; }

/* лента комментариев под постом */
.cmt-list { display: flex; flex-direction: column; gap: 6px; }
.cmt-row { display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.cmt-text { flex: 1; min-width: 0; font-size: 13.5px; color: var(--ink); overflow-wrap: anywhere; }
.cmt-badge { flex: none; font-size: 11px; font-weight: 650; padding: 2px 9px; border-radius: var(--r-pill);
  border: 1px solid var(--line); }
.cmt-badge.on { color: var(--caramel-ink); border-color: var(--line-strong); background: var(--surface); }
.cmt-badge.off { color: var(--ink-soft); }

/* ─── кнопки ─── */
.btn { font-family: var(--body); font-weight: 650; font-size: 14px; cursor: pointer;
  padding: 9px 16px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); transition: all var(--dur) var(--ease); }
.btn:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--caramel), var(--caramel-ink)); color: #fff; border-color: transparent; box-shadow: var(--sh-glow); }
.btn-ghost { background: transparent; }

/* ─── переключатель (вкл/выкл правила) ─── */
.switch { position: relative; width: 42px; height: 24px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--line-strong); transition: background var(--dur) var(--ease); }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--sh-sm); transition: transform var(--dur) var(--ease); }
.switch input:checked ~ .track { background: linear-gradient(135deg, var(--pistachio), #63713f); }
.switch input:checked ~ .thumb { transform: translateX(18px); }

/* ─── скелет-загрузка ─── */
.skel { background: linear-gradient(100deg, var(--surface-2) 30%, var(--surface-hover) 50%, var(--surface-2) 70%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--r-xs); color: transparent !important; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── появление (оркестрованный reveal) ─── */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.reveal { animation: rise .6s var(--ease) both; }
.reveal:nth-child(1) { animation-delay: .02s; }
.reveal:nth-child(2) { animation-delay: .08s; }
.reveal:nth-child(3) { animation-delay: .14s; }
.reveal:nth-child(4) { animation-delay: .20s; }
.reveal:nth-child(5) { animation-delay: .26s; }

/* ─── утилиты ─── */
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--ink-muted); }
.soft { color: var(--ink-soft); }
.grow { flex: 1; }
.mt-lg { margin-top: 22px; }
.empty { text-align: center; padding: 60px 20px; color: var(--ink-muted); }
.empty .big { font-size: 34px; margin-bottom: 8px; }

/* ─── поиск / фильтры ─── */
.search { position: relative; }
.search input {
  font-family: var(--body); font-size: 14px; color: var(--ink);
  padding: 10px 14px 10px 38px; width: 240px; max-width: 46vw;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill);
  transition: all var(--dur) var(--ease);
}
.search input:focus { outline: none; border-color: var(--caramel); box-shadow: var(--sh-glow); width: 280px; }
.search .s-ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-muted); pointer-events: none; }

/* ─── чипы кодовых слов ─── */
.kw-list { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-chip { font-weight: 650; font-size: 13px; padding: 3px 11px; border-radius: var(--r-pill);
  background: var(--peach-wash); color: var(--caramel-ink); }
.kw-chip.catch { background: var(--surface-2); color: var(--ink-muted); font-style: italic; }
.kw-more { font-size: 12px; color: var(--ink-muted); align-self: center; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status-dot.on { background: var(--pistachio); box-shadow: 0 0 0 3px var(--pist-wash); }
.status-dot.off { background: var(--ink-muted); }

/* ─── выдвижная карточка (drawer) ─── */
.scrim { position: fixed; inset: 0; z-index: 60; background: rgba(30,18,8,.34); backdrop-filter: blur(3px);
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease); }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; z-index: 61; top: 0; right: 0; height: 100vh; width: min(560px, 94vw);
  background: var(--bg); border-left: 1px solid var(--line); box-shadow: var(--sh-lg);
  transform: translateX(100%); transition: transform .32s var(--ease); overflow-y: auto; }
.drawer.open { transform: none; }
.drawer-inner { padding: 26px clamp(20px, 4vw, 32px) 48px; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.drawer h2 { font-size: 28px; line-height: 1.1; }

.step { margin-top: 22px; }
.step-label { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--ink-muted); margin-bottom: 10px; }
.step-num { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px;
  background: var(--caramel); color: #fff; }
.msg-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 15px 17px;
  font-size: 14px; line-height: 1.6; white-space: pre-wrap;
  overflow-wrap: anywhere; }  /* рвём длинные ссылки без пробелов, иначе вылазят за карточку на мобилке */
.msg-block + .msg-block { margin-top: 8px; }
.msg-variant { position: relative; padding-left: 26px; }
.msg-variant::before { content: attr(data-i); position: absolute; left: 0; top: 15px; font-size: 11px; font-weight: 700;
  color: var(--ink-muted); }
.btn-preview { display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: var(--r-pill);
  background: linear-gradient(135deg, var(--peach), var(--peach-deep)); color: var(--caramel-ink); font-weight: 700; box-shadow: var(--sh-sm); }
.link-preview { display: block; font-size: 13px; color: var(--caramel-ink); word-break: break-all; margin-top: 8px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.mini-stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.mini-stat .v { font-family: var(--display); font-size: 24px; font-weight: 560; }
.mini-stat .l { font-size: 11.5px; color: var(--ink-muted); }

/* ─── bento продуктов ─── */
.bento { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.prod-card { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 20px; box-shadow: var(--sh-sm);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.prod-card:hover { transform: translateY(-3px); box-shadow: var(--sh-lg); }
.prod-card::after { content: ""; position: absolute; right: -24px; bottom: -24px; width: 80px; height: 80px; border-radius: 50%;
  background: radial-gradient(circle, var(--peach-wash), transparent 70%); }
.prod-name { font-family: var(--display); font-size: 21px; font-weight: 560; letter-spacing: -.01em; }
.prod-bot { font-size: 12px; color: var(--ink-muted); margin-top: 2px; }
.prod-row { display: flex; gap: 18px; margin-top: 16px; position: relative; z-index: 1; }
.prod-row .v { font-weight: 750; font-variant-numeric: tabular-nums; }
.prod-row .l { font-size: 11px; color: var(--ink-muted); }

/* ─── редактор в drawer ─── */
.drawer-toolbar { display: flex; align-items: center; gap: 10px; margin-top: 18px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }
.toolbar-status { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 14px; }
.edit-field { width: 100%; font-family: var(--body); font-size: 14px; line-height: 1.6; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 12px 14px; resize: vertical; transition: border-color var(--dur) var(--ease); }
.edit-field:focus { outline: none; border-color: var(--caramel); box-shadow: var(--sh-glow); }
textarea.edit-field { min-height: 84px; }
.edit-field + .edit-field { margin-top: 8px; }
.drawer-actions { position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line);
  background: linear-gradient(transparent, var(--bg) 30%); }
/* форма создания/правки правила */
.form-block { margin-top: 22px; }
.quick-input { margin-top: 14px; padding: 14px; border-radius: var(--r-sm);
  background: var(--peach-wash); border: 1px dashed var(--peach-deep); }
.quick-input .field-label { color: var(--caramel-ink); }
.quick-hint { font-size: 12px; color: var(--ink-soft); margin-top: 7px; }
.field-row { margin-top: 12px; }
.field-label { display: block; font-size: 12px; font-weight: 700; letter-spacing: .03em; color: var(--ink-soft); margin-bottom: 6px; }
.greet-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; }
.greet-row textarea { flex: 1; }
.del-variant { width: 38px; height: 38px; flex: none; font-size: 13px; }
.add-variant { margin-top: 6px; width: 100%; border-style: dashed; }

.audit { margin-top: 30px; }
.audit-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.audit-item:last-child { border-bottom: 0; }
.audit-when { color: var(--ink-muted); white-space: nowrap; min-width: 96px; }
.audit-diff b { color: var(--caramel-ink); }
.audit-diff .arrow { color: var(--ink-muted); margin: 0 6px; }
.toast { position: fixed; z-index: 80; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 12px 20px; border-radius: var(--r-pill); font-weight: 650;
  box-shadow: var(--sh-lg); opacity: 0; transition: all .3s var(--ease); pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ─── воронка (этапы) ─── */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 140px 1fr auto; align-items: center; gap: 14px; }
.funnel-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.funnel-bar { height: 34px; border-radius: var(--r-sm); position: relative; overflow: hidden;
  background: var(--surface-2); }
.funnel-bar > i { display: block; height: 100%; border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--peach), var(--peach-deep)); transition: width .7s var(--ease); }
.funnel-row:nth-child(2) .funnel-bar > i { background: linear-gradient(90deg, var(--peach-deep), var(--caramel)); }
.funnel-row:nth-child(3) .funnel-bar > i { background: linear-gradient(90deg, var(--caramel), var(--caramel-ink)); }
.funnel-row:nth-child(4) .funnel-bar > i { background: linear-gradient(90deg, var(--pistachio), #63713f); }
.funnel-val { font-family: var(--display); font-size: 20px; font-weight: 560; font-variant-numeric: tabular-nums;
  min-width: 118px; text-align: right; }
.funnel-val small { font-family: var(--body); font-size: 12px; color: var(--ink-muted); font-weight: 600; margin-left: 6px; }

/* ─── разбивка мессенджеров ─── */
.split { display: flex; flex-direction: column; gap: 16px; }
.split-item .split-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.split-name { font-weight: 700; font-size: 14px; }
.split-meta { font-size: 12px; color: var(--ink-muted); }
.split-track { height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.split-track > i { display: block; height: 100%; border-radius: var(--r-pill); }
.split-track > i.ig { background: linear-gradient(90deg, var(--peach), var(--peach-deep)); }
.split-track > i.vk { background: linear-gradient(90deg, var(--pistachio), #63713f); }

/* ─── топ-листы ─── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.toplist { display: flex; flex-direction: column; }
.top-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.top-row:last-child { border-bottom: 0; }
.top-rank { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex: none;
  font-size: 12px; font-weight: 800; background: var(--peach-wash); color: var(--caramel-ink); }
.top-row:first-child .top-rank { background: linear-gradient(135deg, var(--gold), var(--caramel)); color: #fff; }
.top-main { flex: 1; min-width: 0; overflow: hidden; }
.toplist, .top-row { min-width: 0; max-width: 100%; }
.top-title { font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-sub { font-size: 12px; color: var(--ink-muted); }
.top-metric { font-family: var(--display); font-size: 20px; font-weight: 560; }
.top-metric small { font-family: var(--body); font-size: 11px; color: var(--ink-muted); }

/* ─── категории промахов ─── */
.cat-tabs { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.cat-tab { flex: 1; min-width: 200px; text-align: left; cursor: pointer; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  transition: all var(--dur) var(--ease); }
.cat-tab:hover { box-shadow: var(--sh-md); transform: translateY(-1px); }
.cat-tab.active { border-color: var(--caramel); box-shadow: var(--sh-glow); }
.cat-tab .ct-count { font-family: var(--display); font-size: 26px; font-weight: 560; }
.cat-tab .ct-label { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.cat-tab .ct-hint { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; }

.syn-btn { font-family: var(--body); font-size: 12.5px; font-weight: 650; cursor: pointer; white-space: nowrap;
  padding: 5px 12px; border-radius: var(--r-pill); border: 1px solid var(--pistachio); color: var(--pistachio);
  background: transparent; transition: all var(--dur) var(--ease); }
.syn-btn:hover { background: var(--pist-wash); }
.syn-btn:disabled { opacity: .5; cursor: default; border-color: var(--line); color: var(--ink-muted); }

/* мини-воронка продукта */
.conv-bar { height: 8px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.conv-bar > i { display: block; height: 100%; border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--peach-deep), var(--caramel)); }

:focus-visible { outline: 2px solid var(--caramel); outline-offset: 2px; border-radius: 4px; }

/* ─── адаптив ─── */
/* скрим под мобильное меню */
.nav-scrim { position: fixed; inset: 0; z-index: 35; background: rgba(30,18,8,.34); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease); }
.nav-scrim.open { opacity: 1; pointer-events: auto; }

@media (max-width: 900px) {
  /* z-index:auto убирает stacking-контекст shell — иначе сайдбар (внутри shell) заперт под nav-scrim.
     контент поднимаем отдельно через .main, чтобы фон body::before/::after его не накрыл */
  .shell { grid-template-columns: minmax(0, 1fr); z-index: auto; }  /* minmax(0,..) против grid-blowout */
  .main { min-width: 0; position: relative; z-index: 1; }
  .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform var(--dur) var(--ease); box-shadow: var(--sh-lg); }
  .sidebar.open { transform: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .main { padding-top: 72px; }
  .mobile-bar { display: flex !important; }
  .topbar { flex-direction: column; align-items: stretch; }
  .topbar-tools { flex-wrap: wrap; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .date-range { flex-wrap: wrap; }
  .drawer { width: 100vw; }
  .cat-tab { min-width: 140px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-val { font-size: 30px; }
  .funnel-row { grid-template-columns: 1fr auto; row-gap: 6px; }
  .funnel-bar { grid-column: 1 / -1; order: 3; height: 26px; }
  .funnel-label { font-size: 12px; }
  .funnel-val { min-width: auto; }
  .cat-tabs { flex-direction: column; }
  .cat-tab { min-width: 100%; }
  .search input, .search input:focus { width: 100%; max-width: none; }
  .search { width: 100%; }
  .page-title { font-size: 26px; }
  .date-input { flex: 1; min-width: 0; }
}
.mobile-bar { display: none; position: fixed; z-index: 30; top: 0; left: 0; right: 0; height: 58px;
  align-items: center; gap: 12px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ── страница входа ── */
.login-body { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(60% 48% at 50% 0%, var(--peach-wash), transparent 70%), var(--bg); }
.login-wrap { width: 100%; max-width: 380px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.login-card { width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 34px 30px 30px; box-shadow: var(--sh-lg);
  display: flex; flex-direction: column; align-items: center; text-align: center; }
.login-mark { width: 62px; height: 62px; border-radius: 20px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--peach), var(--peach-deep)); box-shadow: 0 6px 16px rgba(74,49,26,.16); }
.login-brand { margin-top: 16px; font-family: var(--display); font-size: 28px; font-weight: 560; letter-spacing: -.01em; color: var(--ink); }
.login-brand b { color: var(--caramel); font-weight: 600; }
.login-sub { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); margin-top: 4px; }
.login-lbl { align-self: flex-start; margin-top: 26px; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.login-input { width: 100%; font-family: var(--body); font-size: 22px; font-weight: 600; letter-spacing: .3em;
  text-align: center; color: var(--ink); background: var(--surface-2); border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md); padding: 14px 16px; transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.login-input::placeholder { letter-spacing: .3em; color: var(--ink-muted); }
.login-input:focus { outline: none; border-color: var(--caramel); box-shadow: 0 0 0 4px rgba(200,121,31,.14); }
.login-err { align-self: flex-start; margin-top: 9px; font-size: 13px; font-weight: 600; color: var(--berry); }
.login-btn { width: 100%; margin-top: 18px; font-family: var(--body); font-size: 15px; font-weight: 700;
  color: #fff; background: var(--caramel); border: 0; border-radius: var(--r-md); padding: 14px;
  cursor: pointer; transition: background var(--dur) var(--ease), transform var(--dur) var(--ease); }
.login-btn:hover { background: var(--caramel-ink); }
.login-btn:active { transform: translateY(1px); }
.login-btn:disabled { opacity: .6; cursor: default; }
.login-foot { font-size: 12px; color: var(--ink-muted); }
.login-card.shake { animation: login-shake .4s; }
@keyframes login-shake { 0%,100%{transform:translateX(0)} 20%,60%{transform:translateX(-7px)} 40%,80%{transform:translateX(7px)} }
@media (prefers-reduced-motion: reduce) { .login-card.shake { animation: none; } }
