/* =============================================================================
 *  app.css — Apple-inspired dashboard.
 *  Эстетика: мягкие пастельные цвета, крупные радиусы, нежные тени,
 *  щедрая типографика. Светлая тема по умолчанию + dark toggle + tint skins.
 * ============================================================================= */

/* ============================================================ TOKENS ====== */

:root, :root[data-theme="light"] {
  /* surfaces — премиальный тёплый холст, белые карточки */
  --bg:           #ECEAE3;
  --bg-elev:      #F2F0E9;
  --surface:      #FFFFFF;
  --surface-2:    #F7F5F0;
  --surface-3:    #EFECE4;
  --surface-hi:   #E5E2D9;

  /* ink — тёплый графит, высокий контраст */
  --ink-1:        #161410;
  --ink-2:        #423E37;
  --ink-3:        #4A463E;
  --ink-4:        #6B655A;

  /* lines */
  --line:         #E6E2D8;
  --line-2:       #D8D2C6;
  --line-strong:  #C3BCAF;

  /* chart palette — утончённая, гармоничная */
  --c-blue:       rgba(108,148,196,.82);  --c-blue-soft:    #E4E9F1;
  --c-mint:       rgba(98,176,156,.82);   --c-mint-soft:    #DFEDE8;
  --c-coral:      rgba(216,134,118,.82);  --c-coral-soft:   #F5E4DD;
  --c-amber:      rgba(212,166,114,.82);  --c-amber-soft:   #F3E9D9;
  --c-violet:     rgba(158,140,198,.82);  --c-violet-soft:  #E9E3F0;
  --c-rose:       rgba(206,138,164,.82);  --c-rose-soft:    #F4E5EC;
  --c-sky:        rgba(122,178,206,.82);  --c-sky-soft:     #E3EDF2;
  --c-sage:       rgba(148,182,140,.82);  --c-sage-soft:    #E7EEDF;

  /* states (semantic) — утончённые, чёткие (warn — глина, не горчица) */
  --pos:          rgba(72,158,108,.92);   --pos-bg:        #E3EFE7;
  --neg:          rgba(212,104,92,.92);   --neg-bg:        #F5E2DC;
  --warn:         rgba(206,148,94,.92);   --warn-bg:       #F4E8D7;
  --info:         rgba(102,148,198,.92);  --info-bg:       #E4E9F1;

  /* marketplaces — в общей гамме, чёткие */
  --wb:           rgba(166,126,186,.88);  --wb-tint:       #ECE3F0;
  --ozon:         rgba(108,148,198,.88);  --ozon-tint:     #E4E9F1;

  /* shape */
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-2xl: 32px;

  --shadow-sm:  0 1px 2px rgba(60,50,30,.04), 0 0 0 1px rgba(60,50,30,.03);
  --shadow-md:  0 1px 2px rgba(60,50,30,.04), 0 6px 16px rgba(60,50,30,.06);
  --shadow-lg:  0 2px 4px rgba(60,50,30,.06), 0 16px 48px rgba(60,50,30,.12);
  --shadow-xl:  0 30px 80px rgba(60,50,30,.18), 0 4px 12px rgba(60,50,30,.08);

  --topbar-bg:   rgba(244,241,234,.80);
  --code-bg:     #211F1B;
  --code-ink:    #EDE8E0;

  /* accent (по умолчанию: розовая пудра, чёткий) */
  --accent:       rgba(198,126,150,.95);
  --accent-soft:  #F1E2E8;
  --accent-ink:   #FFFFFF;
}

/* ============== TINT SKINS — утончённые, чёткие ====== */
:root[data-tint="rose"]    { --accent: rgba(198,126,150,.95); --accent-soft: #F1E2E8; }
:root[data-tint="sky"]     { --accent: rgba(108,162,200,.92); --accent-soft: #E2ECF2; }
:root[data-tint="sage"]    { --accent: rgba(96,170,140,.92);  --accent-soft: #DFEDE6; }
:root[data-tint="amber"]   { --accent: rgba(206,158,98,.92);  --accent-soft: #F3E7D5; }
:root[data-tint="violet"]  { --accent: rgba(150,128,196,.92); --accent-soft: #E8E2F1; }
:root[data-tint="coral"]   { --accent: rgba(214,116,98,.92);  --accent-soft: #F5E1DA; }
:root[data-tint="graphite"]{ --accent: rgba(82,80,90,.92);    --accent-soft: #E5E2DB; }

/* ============== DARK THEME ============== */
:root[data-theme="dark"] {
  --bg:           #0E0E10;
  --bg-elev:      #16161A;
  --surface:      #1A1A1E;
  --surface-2:    #202024;
  --surface-3:    #28282C;
  --surface-hi:   #2E2E32;

  --ink-1:        #F7F7FA;
  --ink-2:        #C3C3CA;
  --ink-3:        #AEAEB6;
  --ink-4:        #82828A;

  --line:         #28282C;
  --line-2:       #36363B;
  --line-strong:  #45454B;

  --c-blue:       #6FB5EF;  --c-blue-soft:    rgba(111,181,239,.16);
  --c-mint:       #5FD7BA;  --c-mint-soft:    rgba(95,215,186,.16);
  --c-coral:      #FA9A88;  --c-coral-soft:   rgba(250,154,136,.16);
  --c-amber:      #F4C46B;  --c-amber-soft:   rgba(244,196,107,.16);
  --c-violet:     #BCA1E5;  --c-violet-soft:  rgba(188,161,229,.16);
  --c-rose:       #F1A3BC;  --c-rose-soft:    rgba(241,163,188,.16);
  --c-sky:        #92D3F0;  --c-sky-soft:     rgba(146,211,240,.16);
  --c-sage:       #A8D49E;  --c-sage-soft:    rgba(168,212,158,.16);

  --pos:          #4DC97F;   --pos-bg:        rgba(77,201,127,.12);
  --neg:          #F08772;   --neg-bg:        rgba(240,135,114,.12);
  --warn:         #EDB04A;   --warn-bg:       rgba(237,176,74,.12);
  --info:         #6FB5EF;   --info-bg:       rgba(111,181,239,.12);

  --wb:           #D49DE4;   --wb-tint:       rgba(212,157,228,.14);
  --ozon:         #6FB5EF;   --ozon-tint:     rgba(111,181,239,.14);

  --shadow-sm:   0 1px 2px rgba(0,0,0,.4);
  --shadow-md:   0 4px 12px rgba(0,0,0,.45);
  --shadow-lg:   0 16px 48px rgba(0,0,0,.55);
  --shadow-xl:   0 30px 80px rgba(0,0,0,.7);

  --topbar-bg:   rgba(14,14,16,.78);
  --code-bg:     #08080A;
}

/* =========================================================== RESET ======== */

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink-1);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Geist',
               'Inter', system-ui, sans-serif;
  font-feature-settings: 'ss01', 'cv11', 'tnum';
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

.num, .mono, .tab { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.mono { font-family: 'Geist Mono', 'SF Mono', ui-monospace, monospace; letter-spacing: -0.005em; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.10); border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.20); }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.10); }

::selection { background: var(--accent-soft); color: var(--accent); }

button { font-family: inherit; }

@keyframes skel {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@keyframes ping {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(2.4); }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes overlayIn {
  from { opacity: 0; backdrop-filter: blur(0); }
  to   { opacity: 1; backdrop-filter: blur(20px); }
}
@keyframes drawLine {
  from { stroke-dashoffset: var(--len, 1000); }
  to   { stroke-dashoffset: 0; }
}
@keyframes growBar {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

/* ====================================================== APP SHELL ========= */

.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* ---- left rail ---- */
.rail {
  position: sticky; top: 0;
  height: 100vh;
  background: var(--bg-elev);
  border-right: 1px solid var(--line);
  padding: 22px 14px 18px 18px;
  display: flex; flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  font-size: 13px;
}
.rail .brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 6px 22px 6px;
}
.rail .brand .mark {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--c-violet));
  color: #FFFFFF;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; letter-spacing: -0.04em;
  box-shadow: var(--shadow-sm);
}
.rail .brand .name { font-size: 14px; font-weight: 600; letter-spacing: -0.018em; }
.rail .brand .sub  { font-size: 11px; color: var(--ink-3); margin-top: -1px; }

.rail .section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--ink-3); padding: 14px 8px 6px 8px;
  font-weight: 600;
}

.rail a {
  position: relative;
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13px;
  transition: color .15s, background .15s;
  cursor: pointer;
}
.rail a:hover { color: var(--ink-1); background: var(--surface); }
.rail a.active {
  color: var(--ink-1);
  background: var(--surface);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.rail a .ic {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: var(--ink-2);
}
.rail a.active .ic { color: var(--accent); }
.rail a.active {
  color: var(--ink-1);
  background: var(--surface);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}
.rail a:hover .ic { color: var(--ink-1); }
.rail a .num { display: none; }
.rail a .badge {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.rail .foot {
  margin-top: auto;
  padding: 14px 8px 4px 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--ink-3);
  display: flex; flex-direction: column; gap: 6px;
}
.rail .foot .live { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.rail .foot .live .ping {
  position: relative;
  width: 7px; height: 7px; border-radius: 99px;
  background: var(--pos);
}
.rail .foot .live .ping::after {
  content: ''; position: absolute; inset: 0;
  border-radius: 99px; background: var(--pos);
  animation: ping 2s ease-out infinite;
}

/* ====================================================== MAIN PANE ========= */

.main {
  min-width: 0;
  display: flex; flex-direction: column;
}

/* ---- topbar ---- */
.topbar {
  position: sticky; top: 14px; z-index: 10;
  margin: 14px 14px 0 14px;
  background: var(--topbar-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  padding: 12px 22px;
  display: flex; align-items: center; gap: 14px;
}
.topbar .doc-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.topbar .doc-sub {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 0;
}
.topbar .spacer { flex: 1; }

/* tint switcher (Apple-style color skins) */
.tint-pick {
  display: flex; gap: 4px;
  padding: 3px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
}
.tint-pick button {
  width: 18px; height: 18px;
  border-radius: 99px;
  border: 0;
  cursor: pointer;
  padding: 0;
  transition: transform .15s;
}
.tint-pick button:hover { transform: scale(1.15); }
.tint-pick button.active {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink-1);
}

.period-picker {
  display: flex; align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 2px;
  font-size: 12px;
  box-shadow: var(--shadow-sm);
}
.period-picker button {
  font: inherit; border: 0; background: transparent;
  padding: 5px 12px; border-radius: 99px;
  color: var(--ink-2); cursor: pointer;
  font-weight: 500;
  transition: all .15s;
}
.period-picker button.active {
  background: var(--ink-1); color: var(--bg);
  font-weight: 600;
}
.period-picker button:hover:not(.active) { color: var(--ink-1); }

.btn {
  font: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-1);
  font-size: 12px;
  font-weight: 500;
  transition: all .15s;
}
.btn:hover { border-color: var(--line-2); background: var(--surface-2); }
.btn.primary {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink); font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink-1); background: var(--surface); }
.btn .icon { width: 13px; height: 13px; }

/* circular ghost button (icon-only) */
.btn.icon-only {
  width: 32px; height: 32px;
  padding: 0; justify-content: center;
  border-radius: 99px;
}

/* ====================================================== CONTENT =========== */

.content {
  padding: 24px 14px 80px 14px;
  max-width: 1680px;
  width: 100%;
  display: flex; flex-direction: column;
  gap: 24px;
}

/* ===================================================== SECTION ============ */

.sec { scroll-margin-top: 70px; }

.sec-head {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 18px;
  align-items: end;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.sec-head .num {
  font-family: 'Geist Mono', monospace;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  padding-bottom: 8px;
  font-weight: 500;
}
.sec-head h2 {
  margin: 0;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1.05;
}
.sec-head .ttl-sub {
  display: block;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink-3);
  margin-top: 6px;
  letter-spacing: 0;
}
.sec-head .actions { display: flex; gap: 8px; align-items: center; }

/* ====================================================== CARDS ============= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.card-pad { padding: 20px 22px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.card-head .title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.012em;
}
.card-head .sub { font-size: 12px; color: var(--ink-3); font-weight: 400; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px 20px; }

.grid { display: grid; gap: 14px; }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
.g-12 { grid-template-columns: repeat(12, minmax(0,1fr)); }
.span-9 { grid-column: span 9; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
.span-12 { grid-column: span 12; }

/* ======================================================= KPI v2 ========== */

.kpi {
  position: relative;
  padding: 18px 20px 16px 20px;
  display: flex; flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  min-height: 130px;
  cursor: pointer;
  transition: all .18s ease;
  overflow: hidden;
}
.kpi:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--line-2);
}
.kpi .kpi-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: var(--accent);
}
.kpi .kpi-icon svg { width: 16px; height: 16px; }

.kpi .label {
  font-size: 13px;
  color: var(--ink-2);
  font-weight: 500;
  letter-spacing: -0.005em;
  display: flex; align-items: center; gap: 8px;
}
.kpi .value {
  font-size: 31px;
  font-weight: 600;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 4px;
  line-height: 1.05;
  color: var(--ink-1);
}
.kpi .unit { font-size: 13px; color: var(--ink-3); font-weight: 500; }
.kpi .delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  padding: 2px 8px; border-radius: 99px;
  font-variant-numeric: tabular-nums;
}
.kpi .delta.up   { background: var(--pos-bg); color: var(--pos); }
.kpi .delta.down { background: var(--neg-bg); color: var(--neg); }
.kpi .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi .spark { margin-top: auto; height: 28px; width: 100%; }

/* tint variations for kpi icon */
.tint-blue   .kpi-icon { background: var(--c-blue-soft);   color: var(--c-blue); }
.tint-mint   .kpi-icon { background: var(--c-mint-soft);   color: var(--c-mint); }
.tint-coral  .kpi-icon { background: var(--c-coral-soft);  color: var(--c-coral); }
.tint-amber  .kpi-icon { background: var(--c-amber-soft);  color: var(--c-amber); }
.tint-violet .kpi-icon { background: var(--c-violet-soft); color: var(--c-violet); }
.tint-rose   .kpi-icon { background: var(--c-rose-soft);   color: var(--c-rose); }
.tint-sky    .kpi-icon { background: var(--c-sky-soft);    color: var(--c-sky); }
.tint-sage   .kpi-icon { background: var(--c-sage-soft);   color: var(--c-sage); }

/* drillable KPI — кнопка раскрытия в правом нижнем углу, появляется на hover */
.kpi.drillable .kpi-expand-hint {
  position: absolute;
  right: 12px; bottom: 12px;
  width: 22px; height: 22px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  color: var(--ink-3);
  opacity: 0;
  transform: scale(0.85);
  transition: all .18s ease;
  pointer-events: none;
}
.kpi.drillable:hover .kpi-expand-hint {
  opacity: 1;
  transform: scale(1);
  color: var(--accent);
  border-color: var(--accent-soft);
  background: var(--surface);
}
.kpi.drillable:hover { border-color: var(--accent-soft); }

/* ======================================================= PILLS ============ */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px; font-weight: 500;
  background: var(--surface-3); color: var(--ink-2);
  border: 1px solid transparent;
}
.pill .dot { width: 6px; height: 6px; border-radius: 99px; }
.pill.wb   { background: var(--wb-tint);   color: var(--wb); }
.pill.ozon { background: var(--ozon-tint); color: var(--ozon); }
.pill.pos  { background: var(--pos-bg);    color: var(--pos); }
.pill.neg  { background: var(--neg-bg);    color: var(--neg); }
.pill.warn { background: var(--warn-bg);   color: var(--warn); }
.pill.info { background: var(--info-bg);   color: var(--info); }

/* ======================================================= TABLE =========== */

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl thead th {
  text-align: left;
  font-weight: 500;
  color: var(--ink-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0;
}
.tbl tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .sku-cell .title { font-weight: 500; }
.tbl .sku-cell .meta { font-size: 11px; color: var(--ink-3); }

.minibar {
  position: relative; height: 6px; background: var(--surface-3);
  border-radius: 99px; overflow: hidden; min-width: 60px;
}
.minibar .fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: 99px; }

/* ======================================================= SQL TIP ========== */

.sql-tag {
  display: inline-flex; align-items: center;
  font-family: 'Geist Mono', monospace;
  font-size: 10px;
  color: var(--ink-3);
  padding: 2px 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: help;
  letter-spacing: 0.04em;
}
.sql-tag:hover { color: var(--ink-2); border-color: var(--line-2); }

/* ===================================================== ALERTS ============= */

.alert {
  display: flex; gap: 12px; padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
}
.alert .marker { width: 3px; border-radius: 99px; align-self: stretch; flex: 0 0 3px; }
.alert.high   .marker { background: var(--neg); }
.alert.medium .marker { background: var(--warn); }
.alert.low    .marker { background: var(--info); }
.alert .body { flex: 1; }
.alert .ttl  { font-size: 13px; font-weight: 600; }
.alert .desc { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

/* ===================================================== UTILITY =========== */

.row { display: flex; }
.col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-14 { gap: 14px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; } .gap-24 { gap: 24px; }
.center { align-items: center; } .between { justify-content: space-between; } .end { justify-content: flex-end; }
.muted { color: var(--ink-2); } .dim { color: var(--ink-3); }
.h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.028em; }
.h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; }
.h3 { font-size: 13px; font-weight: 600; }
.h4 { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 600; }
.txt-sm { font-size: 11px; } .txt-md { font-size: 13px; } .txt-lg { font-size: 16px; }
.up { color: var(--pos); } .down { color: var(--neg); }
.right { text-align: right; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.spacer { flex: 1; }

.mrow { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 0; align-items: baseline; }
.mrow + .mrow { border-top: 1px solid var(--line); }
.mrow .k { font-size: 13px; color: var(--ink-2); }
.mrow .v { font-size: 13px; font-variant-numeric: tabular-nums; font-weight: 500; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 11px; color: var(--ink-2); }
.legend .item { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

.tabs { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 99px; border: 1px solid var(--line); }
.tabs button {
  font: inherit; border: 0; background: transparent;
  padding: 4px 12px; border-radius: 99px;
  color: var(--ink-2); cursor: pointer; font-size: 11px;
  font-weight: 500;
}
.tabs button.active { background: var(--surface); color: var(--ink-1); box-shadow: var(--shadow-sm); }

.prog { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.prog > .fill { height: 100%; border-radius: 99px; background: var(--accent); }

/* ============================================== INVARIANT PRIMITIVES ====== */

.skel {
  display: inline-block;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease infinite;
  border-radius: 6px;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 44px 20px;
  text-align: center;
}
.empty-state .ic {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink-3);
  display: grid; place-items: center;
}
.empty-state .ttl { font-size: 14px; font-weight: 500; color: var(--ink-1); }

.pending-banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--warn-bg);
  border: 1px dashed var(--warn);
  color: var(--warn);
}
.pending-banner .icon { color: var(--warn); margin-top: 1px; flex-shrink: 0; }
.pending-banner .col span { color: var(--ink-1); font-size: 13px; }
.pending-banner .col .dim { color: var(--ink-2); }

.mock-badge {
  position: absolute; top: 10px; right: 12px;
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9px;
  font-family: 'Geist Mono', monospace;
  letter-spacing: 0.14em;
  color: var(--warn);
  background: var(--warn-bg);
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid transparent;
  font-weight: 600;
  z-index: 1;
}
.mock-badge .dot { width: 4px; height: 4px; border-radius: 99px; background: var(--warn); }

.src {
  display: inline-flex;
  font-size: 10px;
  font-family: 'Geist Mono', monospace;
  letter-spacing: 0.04em;
  padding: 1px 7px;
  border-radius: 4px;
  text-transform: lowercase;
  font-weight: 500;
}
.src.manual { background: var(--info-bg); color: var(--info); }
.src.auto   { background: var(--pos-bg);  color: var(--pos); }
.src.mixed  { background: var(--warn-bg); color: var(--warn); }

/* ---- Balance table ---- */
.balance-table {
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.balance-table .bt-head {
  display: grid; grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--line);
}
.balance-table .bt-head .bt-col { padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; }
.balance-table .bt-head .bt-col + .bt-col { border-left: 1px solid var(--line); }
.balance-table .bt-body { display: grid; grid-template-columns: 1fr 1fr; }
.balance-table .bt-body .bt-side { padding: 6px 0; display: flex; flex-direction: column; }
.balance-table .bt-body .bt-side + .bt-side { border-left: 1px solid var(--line); }
.balance-table .brow {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  padding: 12px 20px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
}
.balance-table .brow:last-child { border-bottom: 0; }
.balance-table .brow .lbl { font-size: 13px; font-weight: 500; display: block; margin-bottom: 4px; }
.balance-table .brow .val { text-align: right; }
.balance-table .bt-foot {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.balance-table .bt-foot .bt-col { padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; }
.balance-table .bt-foot .bt-col + .bt-col { border-left: 1px solid var(--line); }
.balance-table .bt-foot .bt-equity { background: linear-gradient(180deg, var(--accent-soft), var(--surface-2)); }

/* ---- Manual field ---- */
.manual-field {
  display: flex; flex-direction: column; gap: 8px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  position: relative;
  box-shadow: var(--shadow-sm);
}
.manual-field .label { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.manual-field .value-row { display: flex; align-items: baseline; gap: 8px; min-height: 30px; }
.manual-field .manual-input {
  font: inherit;
  font-family: 'Geist Mono', monospace;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-1);
  width: 100%;
}
.manual-field .manual-input:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ============================================== HERO ===================== */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  padding: 8px 0 28px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 32px;
}
.hero .stat .lbl {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin-bottom: 10px;
}
.hero .stat .big {
  font-size: 60px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 8px;
  color: var(--ink-1);
}
.hero .stat .big .u { font-size: 20px; color: var(--ink-3); font-weight: 500; }
.hero .stat .sub {
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-2);
  display: flex; align-items: center; gap: 12px;
}

/* ============================================== CHARTS ==================== */

.chart-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.chart-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px 10px 20px;
}
.chart-head .title { font-size: 14px; font-weight: 600; letter-spacing: -0.012em; }
.chart-head .sub { font-size: 12px; color: var(--ink-3); }
.chart-head .spacer { flex: 1; }

.chart-stage {
  position: relative;
  padding: 6px 14px 14px 14px;
}
.chart-stage svg { display: block; }

.chart-tooltip {
  position: absolute;
  background: var(--ink-1);
  color: var(--bg);
  padding: 10px 12px;
  border-radius: var(--r-sm);
  font-size: 11px;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  z-index: 50;
  min-width: 130px;
  animation: fadeIn .12s ease;
}
.chart-tooltip .tt-date { font-family: 'Geist Mono', monospace; font-size: 10px; opacity: 0.7; margin-bottom: 4px; }
.chart-tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; }
.chart-tooltip .tt-row .lbl { display: inline-flex; align-items: center; gap: 6px; }
.chart-tooltip .tt-row .swatch { width: 8px; height: 8px; border-radius: 2px; }
.chart-tooltip .tt-row .val { font-variant-numeric: tabular-nums; font-weight: 600; font-family: 'Geist Mono', monospace; }

.chart-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  padding: 0 20px 14px 20px;
  font-size: 12px; color: var(--ink-2);
}
.chart-legend .item {
  display: inline-flex; align-items: center; gap: 7px;
  cursor: pointer; user-select: none;
  padding: 3px 9px; border-radius: 99px;
  background: var(--surface-2);
  transition: opacity .15s;
}
.chart-legend .item.off { opacity: 0.35; }
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; }

.chart-expand {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, transform .15s;
  z-index: 4;
}
.chart-card:hover .chart-expand { opacity: 1; }
.chart-expand:hover { transform: scale(1.08); }
.chart-expand svg { width: 13px; height: 13px; color: var(--ink-2); }

/* ============================================== CHART MODAL ============== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20,20,30,0.30);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  z-index: 100;
  display: grid; place-items: center;
  padding: 32px;
  animation: overlayIn .25s ease;
}
:root[data-theme="dark"] .modal-overlay { background: rgba(0,0,0,.55); }

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 1320px;
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modalIn .28s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-head {
  display: flex; align-items: center; gap: 16px;
  padding: 20px 26px;
  border-bottom: 1px solid var(--line);
}
.modal-head .t { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; }
.modal-head .s { font-size: 13px; color: var(--ink-3); }
.modal-head .spacer { flex: 1; }
.modal-body {
  padding: 22px 26px 26px 26px;
  display: flex; flex-direction: column; gap: 16px;
  overflow: auto;
}

.modal-controls {
  display: flex; flex-wrap: wrap; gap: 12px;
  align-items: center;
}
.modal-controls .ctrl-label {
  font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
  margin-right: 4px;
}

.metric-pick {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 99px;
  border: 1px solid var(--line);
}
.metric-pick button {
  font: inherit; border: 0; background: transparent;
  padding: 5px 11px; border-radius: 99px;
  color: var(--ink-2); cursor: pointer; font-size: 11px; font-weight: 500;
  transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
}
.metric-pick button.active {
  background: var(--surface); color: var(--ink-1);
  box-shadow: var(--shadow-sm); font-weight: 600;
}
.metric-pick button .swatch { width: 8px; height: 8px; border-radius: 2px; }

.modal-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding-top: 6px;
}
.modal-stats .stat {
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
}
.modal-stats .stat .lbl { font-size: 11px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.modal-stats .stat .val { font-size: 18px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; font-family: 'Geist Mono', monospace; }
.modal-stats .stat .sub { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

/* ============================================== FUNNEL =================== */

.funnel {
  display: flex; flex-direction: column;
  gap: 6px;
}

.funnel-arrow {
  display: flex; align-items: center; gap: 12px;
  padding: 0 0 0 56px;
  height: 28px;
  font-size: 11px; color: var(--ink-3);
}
.funnel-arrow .conv {
  display: inline-flex; align-items: center; gap: 5px;
  font-weight: 500;
  font-family: 'Geist Mono', monospace;
}
.funnel-arrow .drop {
  font-family: 'Geist Mono', monospace;
  color: var(--neg);
  font-weight: 500;
}

.funnel-row {
  display: grid;
  grid-template-rows: auto 8px;
  gap: 6px;
  padding: 12px 16px 14px 16px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  transition: transform .15s;
}
.funnel-row:hover { transform: translateY(-1px); }

.funnel-info {
  display: flex; align-items: center; gap: 14px;
}
.funnel-label {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
}
.funnel-label .lbl { font-size: 13px; font-weight: 600; }
.funnel-value {
  font-size: 17px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.funnel-bar {
  height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden;
}
.funnel-bar-fill {
  height: 100%; border-radius: 99px;
  transition: width .5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ============================================== SEARCH ANALYTICS ========= */

.search-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 16px;
}

.search-filters {
  display: flex; flex-direction: column; gap: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
  height: fit-content;
  position: sticky; top: 80px;
}
.search-filters .fg-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  font-weight: 600;
  margin-bottom: 4px;
}
.search-filters .fg-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 13px;
}
.search-filters .fg-item:hover { background: var(--surface-2); }
.search-filters .fg-item.active {
  background: var(--accent-soft); color: var(--accent);
  font-weight: 500;
}
.search-filters .fg-item .count {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  color: var(--ink-3);
}
.search-filters .fg-item.active .count { color: var(--accent); }

.search-q {
  font-family: 'Geist Mono', monospace;
  font-size: 13px;
}
.search-q .qtext { font-weight: 500; color: var(--ink-1); }
.search-q .meta { font-size: 10px; color: var(--ink-3); margin-top: 2px; }

.trend-arrow {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 600;
  padding: 2px 7px; border-radius: 99px;
  font-variant-numeric: tabular-nums;
}
.trend-arrow.up    { background: var(--pos-bg); color: var(--pos); }
.trend-arrow.down  { background: var(--neg-bg); color: var(--neg); }
.trend-arrow.new   { background: var(--c-violet-soft); color: var(--c-violet); }
.trend-arrow.flat  { background: var(--surface-3); color: var(--ink-3); }

.position-cell {
  display: inline-flex; align-items: center; gap: 6px;
}
.position-cell .pos-num {
  display: inline-grid; place-items: center;
  min-width: 28px; height: 22px; padding: 0 7px;
  border-radius: 6px;
  font-family: 'Geist Mono', monospace;
  font-weight: 600;
  font-size: 11px;
}
.position-cell .pos-num.top    { background: var(--pos-bg); color: var(--pos); }
.position-cell .pos-num.mid    { background: var(--warn-bg); color: var(--warn); }
.position-cell .pos-num.low    { background: var(--neg-bg); color: var(--neg); }
.position-cell .pos-num.none   { background: var(--surface-3); color: var(--ink-3); }

@media (max-width: 1100px) {
  .search-grid { grid-template-columns: 1fr; }
  .search-filters { position: static; }
}

/* responsive */
@media (max-width: 1100px) {
  .app { grid-template-columns: 64px 1fr; }
  .rail .brand .col, .rail a .ttl, .rail .section-label, .rail .foot { display: none; }
  .rail { padding: 18px 10px; align-items: center; }
  .rail a { grid-template-columns: 1fr; justify-items: center; }
  .hero { grid-template-columns: 1fr; gap: 24px; }
  .modal-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================ COLLAPSING RAIL ===
   (удалено для trade-lens — используется полноширинный sticky-rail из tl.css) */



/* ============================================================ HELP HINT ====== */
.help {
  position: relative;
  display: inline-flex;
  margin-left: 6px;
  vertical-align: middle;
}
.help-btn {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-family: inherit;
  transition: all .12s;
}
.help-btn:hover {
  background: var(--info-bg);
  color: var(--info);
  border-color: var(--info);
  transform: scale(1.1);
}
.help-pop {
  z-index: 200;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px 16px;
  animation: hint-in .16s ease both;
  text-align: left;
  font-weight: 400;
  white-space: normal;
}
@keyframes hint-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}
.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.help-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-1);
  letter-spacing: -0.01em;
}
.help-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  color: var(--ink-3);
  padding: 0 4px;
}
.help-close:hover { color: var(--ink-1); }
.help-sec { margin-top: 10px; }
.help-sec:first-of-type { margin-top: 0; }
.help-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 5px;
}
.help-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-1);
}
.help-formula {
  font-family: 'Geist Mono', monospace;
  font-size: 11px;
  line-height: 1.5;
  background: var(--surface-2);
  padding: 9px 11px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  white-space: pre-wrap;
  color: var(--ink-1);
}
.help-actions {
  margin: 4px 0 0 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink-2);
}
.help-actions li { margin-bottom: 3px; }

/* ============================================================ TOOLTIP (hover) === */
.tt-wrap {
  position: relative;
  display: inline-flex;
}
.tt {
  position: absolute;
  padding: 5px 9px;
  background: var(--ink-1);
  color: var(--bg);
  font-size: 11px;
  font-weight: 500;
  border-radius: var(--r-xs);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .14s, transform .14s;
  z-index: 60;
  box-shadow: var(--shadow-md);
}
.tt-top    { bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(2px); }
.tt-bottom { top:    calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(-2px); }
.tt-top::after, .tt-bottom::after {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
}
.tt-top::after    { top: 100%;    border-top-color:    var(--ink-1); }
.tt-bottom::after { bottom: 100%; border-bottom-color: var(--ink-1); }
.tt-wrap:hover .tt {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================ ABC×XYZ ANALYTICS === */
.abc-matrix {
  display: grid;
  grid-template-columns: 80px repeat(3, 1fr);
  gap: 8px;
}
.abc-matrix .abc-th {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: grid;
  place-items: center;
  padding: 8px;
}
.abc-matrix .abc-cell {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 90px;
  transition: transform .15s, box-shadow .15s;
  cursor: default;
}
.abc-matrix .abc-cell:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.abc-matrix .abc-cell .ttl   { font-size: 11px; font-weight: 600; color: var(--ink-3); }
.abc-matrix .abc-cell .qty   { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.abc-matrix .abc-cell .gmv   { font-size: 11px; color: var(--ink-2); }
.abc-matrix .abc-cell.t-best  { background: var(--pos-bg); border-color: var(--pos); }
.abc-matrix .abc-cell.t-good  { background: var(--info-bg); border-color: var(--info); }
.abc-matrix .abc-cell.t-watch { background: var(--warn-bg); border-color: var(--warn); }
.abc-matrix .abc-cell.t-cut   { background: var(--neg-bg);  border-color: var(--neg); }
.abc-row-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  display: grid;
  place-items: center;
  background: var(--surface-3);
  border-radius: var(--r-md);
}
.abc-legend {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-size: 11px; color: var(--ink-2);
}
.abc-legend .sw {
  width: 12px; height: 12px;
  border-radius: 3px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}
.bcg-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 10px;
  min-height: 320px;
}
.bcg-cell {
  position: relative;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bcg-cell .bcg-ttl {
  font-size: 13px; font-weight: 600; color: var(--ink-1);
}
.bcg-cell .bcg-sub { font-size: 11px; color: var(--ink-3); }
.bcg-cell.star  { background: var(--info-bg); }
.bcg-cell.cash  { background: var(--pos-bg); }
.bcg-cell.quest { background: var(--warn-bg); }
.bcg-cell.dog   { background: var(--neg-bg); }
.bcg-cell ul   { margin: 4px 0 0 0; padding-left: 16px; font-size: 11px; line-height: 1.6; }

/* Pareto */
.pareto-row {
  display: grid;
  grid-template-columns: 28px 1fr 80px 90px 60px;
  gap: 8px;
  align-items: center;
  padding: 4px 6px;
  font-size: 12px;
  border-radius: 6px;
}
.pareto-row:hover { background: var(--surface-2); }
.pareto-row .rk { font-family: 'Geist Mono', monospace; color: var(--ink-3); font-size: 11px; }
.pareto-row .bar { background: var(--surface-3); height: 6px; border-radius: 99px; overflow: hidden; }
.pareto-row .bar .fill { height: 100%; }

/* Раскрывающийся под-блок «Подключения» в Введите вручную */
.subsection {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 2px dashed var(--line-2);
}
.subsection .sub-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.subsection .sub-head .badge-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface);
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px;
}
.subsection .sub-head .h2 {
  font-size: 18px; font-weight: 600; letter-spacing: -0.015em;
}
.subsection .sub-head .h2-sub {
  font-size: 13px; color: var(--ink-3);
}

/* Кликабельная строка таблицы */
.tbl tr.clickable { cursor: pointer; transition: background .12s; }
.tbl tr.clickable:hover { background: var(--surface-2); }
.tbl tr.clickable.selected { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }

/* #8 Инвентаризация — дельта: излишек синий, недостача красная, ноль = зелёная ✓ */
.delta-cell.plus  { color: var(--pos); font-weight: 600; }
.delta-cell.minus { color: var(--neg);  font-weight: 600; }
.delta-cell.zero  { color: var(--pos); }
.delta-cell.zero .icon { vertical-align: middle; }

/* Юнит-экономика — цена до СПП: зелёная (отчёт) / красная (override) + ↻ сброс */
.ue-price .ue-price-val { font-weight: 600; }
.ue-price--market .ue-price-val { color: var(--pos); }
.ue-price--override .ue-price-val { color: var(--neg); }
.ue-reset { border: 0; background: none; cursor: pointer; color: var(--neg); font-size: 13px; margin-left: 6px; padding: 0 2px; line-height: 1; }
.ue-reset:hover { color: var(--ink-1); }
.ue-avg-row > td { background: var(--surface-2); }
.ue-period { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink-3); margin-bottom: 14px; }
.ue-period .icon { color: var(--ink-4); }
.ue-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin: 0 2px; }
.ue-dot.market { background: var(--pos); }
.ue-dot.auto { background: var(--pos); }
.ue-dot.override { background: var(--neg); }
/* Ревизия 03.06 — цветовая маркировка влияющих ячеек UE (зелёный авто / красный ручной / нет данных) */
.ue-c { cursor: pointer; position: relative; }
.ue-c--auto    { background: color-mix(in srgb, var(--pos) 12%, transparent); color: var(--ink-1); }
.ue-c--override{ background: color-mix(in srgb, var(--neg) 14%, transparent); color: var(--neg); font-weight: 600; }
.ue-c--missing { color: var(--ink-3); background: repeating-linear-gradient(45deg, transparent, transparent 4px, color-mix(in srgb, var(--ink-3) 6%, transparent) 4px, color-mix(in srgb, var(--ink-3) 6%, transparent) 8px); }
.ue-c.editing  { background: var(--bg-1); }
.ue-c .ue-reset { border: 0; background: none; cursor: pointer; color: var(--neg); font-size: 13px; margin-left: 6px; padding: 0 2px; line-height: 1; }
/* фото позиции в заявке ФБО (URL Ozon CDN) */
.so-photo { width: 40px; height: 40px; border-radius: var(--r-sm); object-fit: cover; display: block; background: var(--surface-2); }

/* ====================== GLASS THEME · Apple liquid glass ======================
   Светлая база + полупрозрачные панели с размытием фона. Один цельный «кубик»
   (LEGO): удалить этот блок — стекло исчезнет, светлая/тёмная не тронуты.       */
:root[data-theme="glass"] {
  --bg:          #E9E4DB;
  --surface:     rgba(255,255,255,.58);
  --surface-2:   rgba(255,255,255,.42);
  --surface-3:   rgba(255,255,255,.30);
  --surface-hi:  rgba(255,255,255,.34);
  --line:        rgba(255,255,255,.62);
  --line-2:      rgba(90,80,66,.16);
  --line-strong: rgba(90,80,66,.26);
  --topbar-bg:   rgba(255,255,255,.46);
  --shadow-sm:   0 1px 2px rgba(50,44,34,.06), inset 0 0 0 1px rgba(255,255,255,.45);
  --shadow-md:   0 2px 12px rgba(50,44,34,.10), inset 0 0 0 1px rgba(255,255,255,.45);
  --shadow-lg:   0 10px 44px rgba(50,44,34,.18), inset 0 0 0 1px rgba(255,255,255,.55);
  --shadow-xl:   0 30px 80px rgba(50,44,34,.24), inset 0 0 0 1px rgba(255,255,255,.55);
}
/* мягкая цветная подложка, чтобы стекло «играло» (если пользователь не задал обои) */
:root[data-theme="glass"]:not([data-bg="custom"]) body {
  background:
    radial-gradient(46% 40% at 10% 6%,  rgba(198,126,150,.22), transparent 60%),
    radial-gradient(50% 44% at 90% 96%, rgba(150,128,196,.20), transparent 62%),
    radial-gradient(44% 40% at 84% 4%,  rgba(122,178,206,.18), transparent 58%),
    radial-gradient(50% 50% at 4% 92%,  rgba(148,182,140,.16), transparent 60%),
    linear-gradient(160deg, #F1EDE5, #E4DFD5);
  background-attachment: fixed;
}
/* панели верхнего уровня = матовое стекло (вложенные .cost-group — просто полупрозрачны) */
:root[data-theme="glass"] .block,
:root[data-theme="glass"] .kpi,
:root[data-theme="glass"] .rail,
:root[data-theme="glass"] .topbar,
:root[data-theme="glass"] .tweaks,
:root[data-theme="glass"] .modal,
:root[data-theme="glass"] .help-pop,
:root[data-theme="glass"] .gp-pop {
  -webkit-backdrop-filter: blur(22px) saturate(1.7);
  backdrop-filter: blur(22px) saturate(1.7);
}

/* 2026-06-14: квадратик-бренд вместо гамбургера в topbar — клик открывает левую панель (rail) */
.topbar-brand {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border-radius: var(--r-md, 10px);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-1);
  font-size: 14px; font-weight: 600; letter-spacing: -0.02em;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: filter .14s ease, transform .08s ease;
}
.topbar-brand:hover { filter: brightness(1.06); }
.topbar-brand:active { transform: scale(0.97); }
.topbar-brand img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topbar-brand .topbar-brand-letter { line-height: 1; }

/* строка с логином пользователя в плашке topbar (под подзаголовком) */
.topbar .doc-user {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 1px;
  font-family: 'Geist Mono', ui-monospace, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 2026-06-14: компонент <Brand> в .topbar — компактная вариация + .brand-footer для username */
.topbar .brand { display: flex; align-items: center; gap: 11px; padding: 0; flex-shrink: 0; }
.topbar .brand .mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: var(--r-md, 10px);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-1);
  font-size: 15px; font-weight: 600; letter-spacing: -0.02em;
  cursor: pointer;
  overflow: hidden;
  padding: 0;
  transition: filter .14s ease, transform .08s ease;
}
.topbar .brand .mark:hover { filter: brightness(1.08); }
.topbar .brand .mark:active { transform: scale(0.97); }
.topbar .brand .mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.topbar .brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; gap: 0; }
.topbar .brand-text .name {
  font-size: 15px; font-weight: 600; letter-spacing: -0.02em;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--ink-1);
}
.topbar .brand-text .name .brand-edit { opacity: 0; color: var(--ink-4); transition: opacity .14s; }
.topbar .brand-text .name:hover .brand-edit { opacity: 1; }
.topbar .brand-text .sub { font-size: 11px; color: var(--ink-3); margin-top: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .brand-text .brand-footer {
  font-size: 10px; color: var(--ink-3);
  font-family: 'Geist Mono', ui-monospace, monospace;
  margin-top: 1px; letter-spacing: 0.02em;
}

/* ===========================================================================
 * 2026-06-14: АЛИАСЫ переменных — фикс тёмной темы на Главной
 * home_page.jsx и tl_chart.jsx используют var(--card), var(--ink), var(--accent-weak)
 * которые НЕ существовали — рендерились белыми fallback. Здесь объявляю их
 * как синонимы реальных переменных, автоматически следующих теме.
 * =========================================================================== */
:root, :root[data-theme="light"] {
  --card:         var(--surface);
  --ink:          var(--ink-1);
  --accent-weak:  var(--accent-soft);
}
:root[data-theme="dark"] {
  --card:         var(--surface);
  --ink:          var(--ink-1);
  --accent-weak:  rgba(108,162,200,.20);
}
:root[data-theme="glass"] {
  --card:         var(--surface);
  --ink:          var(--ink-1);
  --accent-weak:  var(--accent-soft);
}
