/* «Ozon Hub Аналитика» — дизайн-система.
   Идея: «управленческая ведомость» — холодная бумага, чернильный текст,
   цифры моноширинные по ширине (tabular-nums), цвет только на смысле:
   синий — действие, зелёный/красный — направление изменения.
   Все цвета — токены; тёмная тема переопределяет только токены. */

:root {
  color-scheme: light;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef1f5;
  --line: #e4e7ec;
  --line-strong: #d3d8e0;
  --ink: #141821;
  --ink-2: #4a5262;
  --ink-3: #7b8494;
  --accent: #3348d4;
  --accent-ink: #ffffff;
  --accent-hover: #283bb8;
  --accent-soft: #eceffd;
  --good: #17784c;
  --good-soft: #e3f3ea;
  --good-tile: #f0f8f3;
  --good-rule: #3aa874;
  --bad: #c0352e;
  --bad-soft: #fbe7e5;
  --bad-tile: #fcf2f1;
  --bad-rule: #e0655c;
  --flat-tile: #ffffff;
  --flat-rule: #c9cfd8;
  --warn: #9a6200;
  --warn-soft: #fff4dc;
  --info-soft: #eef2fe;
  --ico-digit: #5468e0; --ico-fin: #1c9a83; --ico-goods: #c98a12; --ico-ads: #d0527a;
  --shadow-sm: 0 1px 2px rgba(20, 24, 33, .05);
  --shadow-md: 0 1px 2px rgba(20, 24, 33, .05), 0 6px 20px rgba(20, 24, 33, .07);
  --shadow-pop: 0 2px 6px rgba(20, 24, 33, .08), 0 18px 48px rgba(20, 24, 33, .16);
  --skel: #e9ecf1;
  --skel-hi: #f5f7fa;
  --focus: 0 0 0 3px rgba(51, 72, 212, .28);
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --topbar-h: 64px;
  --nav-w: 240px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1016;
  --surface: #151922;
  --surface-2: #1a1f29;
  --surface-3: #212734;
  --line: #252b37;
  --line-strong: #343c4b;
  --ink: #e8ebf1;
  --ink-2: #aab2c0;
  --ink-3: #788292;
  --accent: #8297ff;
  --accent-ink: #0d1016;
  --accent-hover: #9cadff;
  --accent-soft: rgba(130, 151, 255, .14);
  --good: #52c690;
  --good-soft: rgba(82, 198, 144, .15);
  --good-tile: #142019;
  --good-rule: #3fa878;
  --bad: #ff8178;
  --bad-soft: rgba(255, 129, 120, .15);
  --bad-tile: #22161a;
  --bad-rule: #d9625a;
  --flat-tile: #151922;
  --flat-rule: #3a4252;
  --warn: #f0b545;
  --warn-soft: rgba(240, 181, 69, .12);
  --info-soft: rgba(130, 151, 255, .10);
  --ico-digit: #7b8cf0; --ico-fin: #3cc0a6; --ico-goods: #e0a83a; --ico-ads: #ea7398;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  --shadow-pop: 0 2px 8px rgba(0, 0, 0, .45), 0 18px 48px rgba(0, 0, 0, .5);
  --skel: #1e2430;
  --skel-hi: #262d3a;
  --focus: 0 0 0 3px rgba(130, 151, 255, .35);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.45 var(--font);
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; }
svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.num, .tbl, .kpi-val, .kpi-prev, .delta, .dr-txt, .pnl { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }

.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip:focus { left: 8px; }

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

/* ---------------- кнопки ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid transparent; background: none; cursor: pointer;
  font-weight: 500; font-size: 13.5px; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; height: 42px; }
.btn.is-busy { position: relative; color: transparent; }
.btn.is-busy::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--accent-ink); border-right-color: transparent; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.iconbtn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  border: 0; background: none; cursor: pointer; color: var(--ink-2);
}
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn:hover { background: var(--surface-3); color: var(--ink); }
.iconbtn:disabled { opacity: .35; cursor: default; background: none; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 13px; font-weight: 500; }
.linkbtn:hover { text-decoration: underline; }

/* ---------------- шапка ---------------- */

.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; gap: 12px; padding: 0 20px 0 14px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 7px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; align-self: center; margin-right: 3px; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: -.02em; }
.brand-sub { font-weight: 500; font-size: 17px; letter-spacing: -.02em; color: var(--ink-3); }
.topbar-sep { width: 1px; height: 22px; background: var(--line-strong); margin: 0 6px; }
.topbar-ws { color: var(--ink-2); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.topbar-sep:has(+ .topbar-ws:empty) { display: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.usermenu { position: relative; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line-strong);
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 13px; cursor: pointer;
}
.avatar:hover { border-color: var(--accent); }
.user-pop { right: 0; top: calc(100% + 8px); min-width: 240px; padding: 6px; }
.user-head { padding: 10px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.user-name { font-weight: 600; }
.user-mail { color: var(--ink-3); font-size: 12.5px; word-break: break-all; }
.menu-item {
  display: block; width: 100%; text-align: left; padding: 9px 10px; border-radius: 8px;
  border: 0; background: none; cursor: pointer; color: var(--ink); font-size: 13.5px;
}
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item.danger { color: var(--bad); }

/* ---------------- меню ---------------- */

.sidenav {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--nav-w); z-index: 20;
  overflow-y: auto; padding: 14px 10px 20px;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
  transition: transform .22s ease;
}
.nav-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 8px; border: 0; background: none; border-radius: 10px; cursor: pointer;
  font-weight: 600; font-size: 14px; color: var(--ink); text-align: left;
}
.nav-head:hover { background: var(--surface-3); }
.nav-ico { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; flex: none; }
.nav-ico svg { width: 14px; height: 14px; }
.ico-digit { background: color-mix(in srgb, var(--ico-digit) 16%, transparent); color: var(--ico-digit); }
.ico-fin { background: color-mix(in srgb, var(--ico-fin) 16%, transparent); color: var(--ico-fin); }
.ico-goods { background: color-mix(in srgb, var(--ico-goods) 18%, transparent); color: var(--ico-goods); }
.ico-ads { background: color-mix(in srgb, var(--ico-ads) 16%, transparent); color: var(--ico-ads); }
.ico-digit svg { fill: currentColor; }
.ico-fin svg, .ico-goods svg, .ico-ads svg { stroke: currentColor; }
.nav-title { flex: 1; }
.nav-chev { width: 12px; height: 12px; color: var(--ink-3); transition: transform .18s; }
.nav-group.collapsed .nav-chev { transform: rotate(-90deg); }
.nav-items { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 8px 19px; padding-left: 14px; border-left: 1px solid var(--line); }
.nav-group.collapsed .nav-items { display: none; }
.nav-link {
  position: relative; display: block; padding: 7px 10px; border-radius: 8px;
  color: var(--ink-2); font-size: 13.5px;
}
.nav-link:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link.active::before {
  content: ''; position: absolute; left: -15.5px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--accent);
}
.nav-foot { margin-top: auto; padding: 16px 10px 0; color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.nav-backdrop { position: fixed; inset: 0; z-index: 19; background: rgba(10, 13, 20, .42); }

/* ---------------- основная колонка ---------------- */

.main {
  margin-left: var(--nav-w); padding: calc(var(--topbar-h) + 18px) 28px 48px;
  min-height: 100vh; outline: none; transition: margin-left .22s ease;
}
body.nav-collapsed .sidenav { transform: translateX(-100%); }
body.nav-collapsed .main { margin-left: 0; }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--ink-3); margin-bottom: 14px; font-size: 13.5px; }
.crumb-home { color: var(--ink-3); display: grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; }
.crumb-home:hover { color: var(--ink); background: var(--surface-3); }
.crumb-home svg { width: 16px; height: 16px; }
.crumb-sep { width: 12px; height: 12px; }
.crumb-cur { color: var(--ink); font-weight: 600; }
.screen-in { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -.025em; }
.page-head .spacer { flex: 1; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

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

.fbar { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; }
.fbar-extra { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.fbtn {
  display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface);
  cursor: pointer; text-align: left; max-width: 320px; transition: border-color .15s, background .15s;
}
.fbtn:hover { border-color: var(--ink-3); }
.open > .fbtn { border-color: var(--accent); box-shadow: var(--focus); }
.fbtn .chev { width: 12px; height: 12px; color: var(--ink-3); flex: none; margin-left: 2px; transition: transform .15s; }
.open > .fbtn .chev { transform: rotate(180deg); }
.fbtn-label { display: flex; flex-direction: column; font-size: 11px; color: var(--ink-3); line-height: 1.1; }
.fbtn { flex-direction: row; }
.ms .fbtn { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; column-gap: 8px; align-content: center; height: 44px; min-width: 150px; }
.ms .fbtn-label { grid-column: 1; grid-row: 1; }
.ms .fbtn-val { grid-column: 1; grid-row: 2; font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms .fbtn .chev { grid-column: 2; grid-row: 1 / 3; align-self: center; }
.fbtn-val.is-set { color: var(--accent); }
.ms, .dr { position: relative; }

.pop {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-pop);
  animation: popin .14s ease-out;
}
@keyframes popin { from { opacity: 0; transform: translateY(-4px); } }

/* мультиселект */
.ms-pop { width: 340px; display: flex; flex-direction: column; max-height: min(520px, 70vh); }
.ms-wide .ms-pop { width: 420px; }
.ms-search-wrap { padding: 10px 10px 6px; }
.ms-search { width: 100%; height: 36px; border: 1px solid var(--line-strong); border-radius: 8px; padding: 0 10px; background: var(--surface-2); }
.ms-search:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.ms-bar { display: flex; align-items: center; gap: 14px; padding: 4px 12px 8px; border-bottom: 1px solid var(--line); }
.ms-count { margin-left: auto; color: var(--ink-3); font-size: 12px; }
.ms-list { overflow-y: auto; padding: 4px; flex: 1; }
.ms-opt { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.ms-opt:hover { background: var(--surface-3); }
.ms-opt input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; margin: 0; }
.ms-img { width: 27px; height: 36px; border-radius: 5px; object-fit: cover; flex: none; background: var(--surface-3); }
.ms-txt { display: flex; flex-direction: column; min-width: 0; }
.ms-l { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-sub { color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-empty { padding: 18px 12px; color: var(--ink-3); text-align: center; font-size: 13px; }
.ms-foot { padding: 8px 10px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }

/* датапикер */
.dr-btn { min-width: 230px; }
.dr-ico { width: 16px; height: 16px; color: var(--ink-3); flex: none; }
.dr-txt { display: flex; flex-direction: column; line-height: 1.15; }
.dr-main-l { font-weight: 600; font-size: 14px; }
.dr-cmp { color: var(--ink-3); font-size: 11.5px; margin-top: 2px; }
.dr-pop { display: flex; padding: 0; }
.dr-presets { display: flex; flex-direction: column; gap: 1px; padding: 10px; border-right: 1px solid var(--line); min-width: 150px; }
.dr-preset { text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.dr-preset:hover { background: var(--surface-3); color: var(--ink); }
.dr-preset.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.dr-main { padding: 10px 14px 12px; position: relative; }
.dr-nav { position: absolute; left: 8px; right: 8px; top: 8px; display: flex; justify-content: space-between; pointer-events: none; }
.dr-nav .iconbtn { pointer-events: auto; width: 32px; height: 32px; }
.dr-months { display: flex; gap: 22px; }
.dr-month { width: 252px; }
.dr-mtitle { text-align: center; font-weight: 600; height: 32px; line-height: 32px; margin-bottom: 4px; }
.dr-grid { display: grid; grid-template-columns: repeat(7, 36px); row-gap: 2px; }
.dr-dow { text-align: center; color: var(--ink-3); font-size: 11.5px; height: 26px; line-height: 26px; }
.dr-day {
  height: 34px; border: 0; background: none; cursor: pointer; font-size: 13px;
  font-variant-numeric: tabular-nums; border-radius: 0; position: relative; color: var(--ink);
}
.dr-day:hover:not(:disabled) { background: var(--surface-3); border-radius: 8px; }
.dr-day.in { background: var(--accent-soft); }
.dr-day.edge { background: var(--accent); color: var(--accent-ink); font-weight: 600; border-radius: 8px; }
.dr-day.in.lo:not(.hi) { border-radius: 8px 0 0 8px; }
.dr-day.in.hi:not(.lo) { border-radius: 0 8px 8px 0; }
.dr-day.today:not(.edge)::after { content: ''; position: absolute; left: 50%; bottom: 4px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--accent); }
.dr-day:disabled { color: var(--ink-3); opacity: .45; cursor: default; }
.dr-hint { color: var(--ink-3); font-size: 12px; margin-top: 8px; text-align: center; }

/* select */
.sel-wrap { position: relative; display: inline-flex; flex-direction: column; justify-content: center; height: 44px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); padding: 0 30px 0 12px; min-width: 140px; cursor: pointer; }
.sel-wrap:hover { border-color: var(--ink-3); }
.sel-wrap:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.sel-label { font-size: 11px; color: var(--ink-3); line-height: 1.1; }
.sel { appearance: none; -webkit-appearance: none; border: 0; background: none; padding: 0; font-weight: 500; font-size: 13.5px; cursor: pointer; outline: none; }
.sel-wrap:not(:has(.sel-label)) .sel { height: 100%; }
.sel-wrap .chev { position: absolute; right: 11px; top: 50%; width: 12px; height: 12px; margin-top: -6px; color: var(--ink-3); pointer-events: none; }
.sel option { background: var(--surface); color: var(--ink); }

/* тумблер */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 38px; height: 22px; border-radius: 11px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch-track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }

/* ---------------- карточки, алерты, состояния ---------------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 0; flex-wrap: wrap; }
.card-title { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.card-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 16px 18px 18px; }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); font-size: 13.5px; line-height: 1.5; }
.alert-ico { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert-ico svg { width: 18px; height: 18px; }
.alert-error { background: var(--bad-soft); color: var(--bad); }
.alert-error b { font-weight: 600; }
.alert-info { background: var(--info-soft); color: var(--ink-2); border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); }
.alert-info .alert-ico { color: var(--accent); }
.alert-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 3px; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 72px 20px; gap: 6px; }
.empty-art { width: 64px; height: 64px; color: var(--line-strong); margin-bottom: 10px; }
.empty-art svg { width: 64px; height: 64px; }
.empty-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.empty-text { margin: 0 0 14px; color: var(--ink-2); max-width: 440px; }
.empty-action { display: inline-block; border-radius: 10px; }

.skel { display: flex; flex-direction: column; gap: 12px; }
.sk { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--skel) 0, var(--skel-hi) 50%, var(--skel) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skel-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.skel-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; display: flex; flex-direction: column; gap: 14px; height: 132px; }
.sk-sm { width: 45%; } .sk-lg { width: 70%; height: 24px; } .sk-md { width: 55%; }
.skel-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.skel-row { display: flex; gap: 18px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.skel-row:last-child { border-bottom: 0; }

/* хинт (i) и тултип */
.hint-i {
  display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-3); font: 600 10px/1 var(--font); font-style: normal;
  cursor: help; flex: none; vertical-align: 1px; margin-left: 5px; border: 1px solid var(--line-strong);
}
.hint-i:hover { color: var(--accent); border-color: var(--accent); }
.an-tip {
  position: fixed; z-index: 90; left: 0; top: 0; pointer-events: none; opacity: 0;
  background: var(--ink); color: var(--bg); padding: 8px 11px; border-radius: 8px;
  font-size: 12.5px; line-height: 1.45; white-space: pre-line; box-shadow: var(--shadow-pop);
  transition: opacity .12s;
}
.an-tip.show { opacity: 1; }

/* дельта */
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.delta-good { color: var(--good); }
.delta-bad { color: var(--bad); }
.delta-flat { color: var(--ink-3); }
.dl-pct { opacity: .85; font-weight: 400; }
.dl-arrow { display: inline-grid; width: 12px; height: 12px; }
.dl-arrow svg { width: 12px; height: 12px; }

/* товар */
.pc { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pc-img { width: 33px; height: 44px; border-radius: 6px; object-fit: cover; flex: none; background: var(--surface-3); }
.pc-ph { display: block; background: repeating-linear-gradient(135deg, var(--surface-3) 0 6px, var(--surface-2) 6px 12px); }
.pc-txt { min-width: 0; }
.pc-art { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-name { color: var(--ink-3); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }

/* ---------------- таблица ---------------- */

.dt { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.dt-tools { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.dt-scroll { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.dt-scroll:focus-visible { border-radius: var(--r); }
/* ОПиУ — ~25 строк, итоговые (EBITDA, чистая прибыль) внизу: без внутренней прокрутки по высоте */
.dt-scroll:has(> table.pnl) { max-height: none; }
.tbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
.tbl th, .tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.tbl th {
  position: sticky; top: 0; z-index: 2; background: var(--surface-2);
  font-size: 12px; font-weight: 500; color: var(--ink-2); vertical-align: bottom; white-space: normal; min-width: 128px;
}
.tbl th.is-sticky, .tbl td.is-sticky { position: sticky; z-index: 1; box-shadow: inset -1px 0 0 var(--line); }
.tbl th.is-sticky { z-index: 3; }
.tbl tr:last-child td { border-bottom: 0; }
.th-in { display: inline-flex; align-items: flex-end; gap: 2px; }
.al-r .th-in { justify-content: flex-end; }
.th-name { line-height: 1.3; }
.al-r { text-align: right; }
.al-l { text-align: left; }
.is-sortable { cursor: pointer; user-select: none; }
.is-sortable:hover { color: var(--ink); }
.th-sort { display: inline-grid; width: 10px; height: 12px; margin-left: 4px; flex: none; }
.th-sort svg { width: 10px; height: 12px; fill: var(--line-strong); }
.th-sort.on.asc .s-up, .th-sort.on.desc .s-dn { fill: var(--accent); }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tr.is-total td { background: var(--accent-soft); font-weight: 600; }
html[data-theme="dark"] .tbl tr.is-total td { background: #1a2036; }
.tbl tr.is-total td.is-sticky { background: var(--accent-soft); }
html[data-theme="dark"] .tbl tr.is-total td.is-sticky { background: #1a2036; }
.c-v { line-height: 1.3; }
.c-d { margin-top: 2px; line-height: 1.2; }
.c-d .delta { font-size: 11.5px; }
.dt-empty { color: var(--ink-3); text-align: center; padding: 22px; background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--r); }

/* настройка колонок */
.cs-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 52vh; overflow-y: auto; }
.cs-item { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 8px; border-radius: 8px; }
.cs-item:hover { background: var(--surface-3); }
.cs-lab { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; min-width: 0; }
.cs-lab input { width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.cs-mv { display: flex; }
.cs-mv .iconbtn { width: 30px; height: 30px; }
.cs-mv svg { width: 12px; height: 12px; }

/* модалка */
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(10, 13, 20, .45); display: grid; place-items: center; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); border: 1px solid var(--line); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 14px 0 20px; }
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 650; }
.modal-body { padding: 10px 20px; overflow-y: auto; }
.modal-body p { margin: 0; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }

/* ---------------- дашборд: KPI ---------------- */

.dash-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi {
  position: relative; background: var(--flat-tile); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 15px 16px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--flat-rule); }
.kpi.t-good { background: var(--good-tile); border-color: color-mix(in srgb, var(--good-rule) 22%, var(--line)); }
.kpi.t-good::before { background: var(--good-rule); }
.kpi.t-bad { background: var(--bad-tile); border-color: color-mix(in srgb, var(--bad-rule) 22%, var(--line)); }
.kpi.t-bad::before { background: var(--bad-rule); }
.kpi-title { display: flex; align-items: center; font-size: 13px; color: var(--ink-2); font-weight: 500; min-width: 0; }
.kpi-title > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi { container-type: inline-size; }
.kpi-val { font-size: clamp(18px, 8.4cqi, 26px); font-weight: 650; letter-spacing: -.025em; line-height: 1.2; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 0; }
.kpi-val .vp { white-space: nowrap; }
.kpi-val .u { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-left: 2px; letter-spacing: 0; }
.kpi-val .sl { color: var(--ink-3); font-weight: 400; margin: 0 6px; }
.kpi-val .nd { color: var(--ink-3); }
.kpi-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 24px; }
.kpi-prev { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.kpi-chip { display: inline-flex; align-items: center; border-radius: 6px; padding: 2px 7px; background: var(--surface-3); }
.t-good .kpi-chip { background: var(--good-soft); }
.t-bad .kpi-chip { background: var(--bad-soft); }
.kpi-chip .delta { font-size: 12px; }
.kpi-note { font-size: 12px; color: var(--ink-3); }
.kpi-sub { font-size: 12px; color: var(--ink-3); }
/* кликабельные плитки статей → «Детализация расходов» */
.kpi-click { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.kpi-click:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.kpi-click:focus-visible { outline: none; box-shadow: var(--focus); }
.kpi-zoom { margin-left: auto; padding-left: 6px; display: inline-flex; color: var(--ink-3); flex: none; }
.kpi-zoom svg { width: 15px; height: 15px; }
.kpi-click:hover .kpi-zoom, .kpi-click:focus-visible .kpi-zoom { color: var(--accent); }
.kpi-parts { display: grid; gap: 2px; font-size: 12.5px; color: var(--ink-2); margin-top: -2px; }
.kp-row { display: flex; justify-content: space-between; gap: 8px; min-width: 0; }
.kp-l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kp-l i { font-style: normal; color: var(--ink-3); margin-right: 2px; }
.kp-v { white-space: nowrap; font-weight: 600; color: var(--ink); }
/* модалка детализации */
.bd { display: grid; gap: 2px; }
.bd-head, .bd-row { display: grid; grid-template-columns: minmax(0, 1fr) auto 64px; gap: 12px; align-items: baseline; }
.bd-head { padding: 0 0 6px; border-bottom: 1px solid var(--line); }
.bd-head span:not(:first-child) { text-align: right; }
.bd-row { padding: 7px 0; font-size: 14px; border-bottom: 1px solid var(--line); }
.bd-row:last-child { border-bottom: 0; }
.bd-name { min-width: 0; overflow-wrap: anywhere; }
.bd-amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bd-pct { text-align: right; white-space: nowrap; color: var(--ink-3); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.bd-total { font-weight: 650; font-size: 15px; background: var(--surface-2); border-radius: var(--r-sm); padding: 9px 10px; margin: 6px 0 4px; border-bottom: 0; }
.bd-list { display: grid; }
.bd-list .bd-row:not(.bd-sub) { padding-left: 10px; color: var(--ink-2); }
.bd-sub { font-weight: 600; margin-top: 6px; color: var(--ink); }
.bd-ref { opacity: .72; font-style: italic; }
.bd-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; font-size: 11px; font-style: normal; line-height: 18px; color: var(--accent); background: var(--accent-soft); vertical-align: 1px; }
.bd-note { font-size: 12px; color: var(--ink-3); padding: 12px 0 2px; }
.bd-empty { font-size: 13px; color: var(--ink-3); padding: 7px 10px; border-bottom: 1px solid var(--line); }
.bd-foot { margin: 10px 0 2px !important; }
@media (max-width: 640px) {
  .bd-head, .bd-row { grid-template-columns: minmax(0, 1fr) auto; }
  .bd-pct, .bd-head span:last-child { display: none; }
}

/* виджеты: список в модалке */
.wg-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 56vh; overflow-y: auto; }

/* ---------------- сводный / ОПиУ / удержания ---------------- */

.row-label { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--ink-3); font-size: 11.5px; }

.pnl th.per { text-align: center; text-transform: uppercase; letter-spacing: .05em; font-size: 11px; font-weight: 600; }
.pnl th.per-sub { font-size: 11px; color: var(--ink-3); text-transform: none; letter-spacing: 0; top: 37px; font-weight: 500; padding-top: 6px; padding-bottom: 6px; }
.pnl td.amt { text-align: right; }
.pnl td.pct { text-align: right; color: var(--ink-3); font-size: 12.5px; padding-left: 4px; }
.pnl td.amt.first, .pnl th.per-l { border-left: 1px solid var(--line); }
.pnl tr.lvl0 td { font-weight: 500; }
.pnl tr.is-bold td { font-weight: 700; background: var(--surface-2); }
.pnl tr.is-bold td.is-sticky { background: var(--surface-2); }
.pnl tr.is-final td { background: var(--accent-soft); }
.pnl tr.is-final td.is-sticky { background: var(--accent-soft); }
html[data-theme="dark"] .pnl tr.is-final td { background: #1a2036; }
.pnl .art { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pnl .art-name { overflow: hidden; text-overflow: ellipsis; }
.tree-tg {
  width: 22px; height: 22px; border-radius: 6px; border: 0; background: none; cursor: pointer; color: var(--ink-3);
  display: grid; place-items: center; flex: none; margin-left: -4px;
}
.tree-tg:hover { background: var(--surface-3); color: var(--ink); }
.tree-tg svg { width: 12px; height: 12px; transition: transform .15s; }
.tree-tg[aria-expanded="true"] svg { transform: rotate(90deg); }
.tree-sp { width: 22px; flex: none; margin-left: -4px; }
.neg { color: var(--bad); }

.oh-group { display: inline-block; padding: 1px 7px; border-radius: 6px; background: var(--surface-3); color: var(--ink-2); font-size: 11.5px; }

/* ---------------- вход ---------------- */

.auth-body { min-height: 100vh; background:
  radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 60%),
  var(--bg); }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-theme { position: fixed; top: 14px; right: 14px; }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 30px 28px 24px; box-shadow: var(--shadow-md); }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.auth-brand img { border-radius: 10px; }
.auth-brand .brand-name, .auth-brand .brand-sub { font-size: 16px; line-height: 1.2; display: block; }
.auth-title { margin: 0 0 6px; font-size: 22px; font-weight: 700; letter-spacing: -.025em; }
.auth-lead { margin: 0 0 22px; color: var(--ink-2); font-size: 13.5px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field-label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.input { height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; padding: 0 12px; background: var(--surface); width: 100%; font-size: 15px; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input-code { font-size: 20px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { padding-right: 44px; }
.pw-eye { position: absolute; right: 4px; top: 4px; width: 34px; height: 34px; border: 0; background: none; color: var(--ink-3); cursor: pointer; display: grid; place-items: center; border-radius: 8px; }
.pw-eye:hover { color: var(--ink); background: var(--surface-3); }
.pw-eye svg { width: 18px; height: 18px; }
.auth-err { background: var(--bad-soft); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
#stepTotp .linkbtn { margin: -4px 0 14px; }
.auth-foot { margin: 18px 0 0; color: var(--ink-3); font-size: 12.5px; text-align: center; }

/* ---------------- адаптив ---------------- */


@media (max-width: 1100px) {
  .kpi-grid, .skel-tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dr-month + .dr-month { display: none; }
}

@media (max-width: 900px) {
  :root { --topbar-h: 56px; }
  .topbar { padding: 0 12px 0 6px; gap: 8px; }
  .brand-name, .brand-sub { font-size: 15.5px; }
  .topbar-sep, .topbar-ws { display: none; }
  .sidenav { transform: translateX(-100%); width: min(300px, 86vw); z-index: 35; box-shadow: var(--shadow-pop); }
  body.nav-open .sidenav { transform: none; }
  body.nav-collapsed .sidenav { transform: translateX(-100%); }
  body.nav-collapsed.nav-open .sidenav { transform: none; }
  .nav-backdrop { z-index: 34; }
  .main, body.nav-collapsed .main { margin-left: 0; padding: calc(var(--topbar-h) + 12px) 16px 40px; }
  .kpi-grid, .skel-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 13px 12px; }
  .kpi-val .u { font-size: 13px; }
  .fbar { gap: 6px; }
  .fbar > .dr, .fbar > .ms, .fbar > .sel-wrap { flex: 1 1 calc(50% - 6px); min-width: 0; }
  .fbar > .dr { flex-basis: 100%; }
  .fbtn, .ms .fbtn { width: 100%; max-width: none; min-width: 0; }
  .fbar-extra { margin-left: 0; width: 100%; }
  .dt-scroll { max-height: 70vh; }
  .page-title { font-size: 19px; }
  /* поповеры — нижним листом */
  .pop.ms-pop, .pop.dr-pop {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; max-height: 82vh;
    border-radius: 18px 18px 0 0; padding-bottom: env(safe-area-inset-bottom);
    animation: sheet .2s ease-out;
  }
  .ms.open::before, .dr.open::before { content: ''; position: fixed; inset: 0; z-index: 39; background: rgba(10, 13, 20, .42); }
  .dr-pop { flex-direction: column; overflow-y: auto; }
  .dr-presets { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); min-width: 0; }
  .dr-preset { border: 1px solid var(--line-strong); border-radius: 999px; }
  .dr-main { display: flex; flex-direction: column; align-items: center; }
  .dr-month { width: auto; }
  .dr-grid { grid-template-columns: repeat(7, minmax(38px, 44px)); }
  .dr-day { height: 40px; }
  .ms-search { font-size: 16px; }
  .user-pop { position: fixed; right: 8px; top: calc(var(--topbar-h) + 4px); }
}
@keyframes sheet { from { transform: translateY(30px); opacity: 0; } }

@media (max-width: 560px) {
  .kpi-grid, .skel-tiles { grid-template-columns: minmax(0, 1fr); }
  .fbar > .sel-wrap { flex-basis: 100%; }
  .dt-tools { justify-content: flex-start; }
  /* узкий экран: первая липкая колонка ужимается, текст переносится */
  .tbl th.is-sticky:first-child, .tbl td.is-sticky:first-child { min-width: 132px !important; max-width: 150px !important; white-space: normal; }
  .tbl td.is-sticky:first-child .row-label, .tbl td.is-sticky:first-child .pc-name { white-space: normal; }
  .pnl td.is-sticky:first-child { max-width: 180px !important; min-width: 160px !important; }
  .tbl th, .tbl td { padding: 9px 10px; }
  .card-body { padding: 14px; }
  .card-head { padding: 14px 14px 0; }
}

/* ДДС */
.dds-bal-wrap { display: inline-flex; align-items: baseline; gap: 8px; margin-left: 6px; }
.dds-bal { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
