/* =====================================================================
   WB Аналитика — интерфейс по концепту C «Понятно продавцу».
   Тёплая палитра, крупные понятные подписи, цветные семейства колонок.
   Правила стабильности: текст не мельче 13 px, контраст AA в обеих темах,
   все размеры, зависящие от данных, зарезервированы заранее (ничего не прыгает).
   ===================================================================== */

:root {
  color-scheme: light;
  --font: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, Arial, sans-serif;

  --bg: #f6f3ee;
  --glow-1: rgba(118, 88, 255, .11);
  --glow-2: rgba(255, 146, 70, .11);
  --surface: #ffffff;
  --surface-2: #fbf9f6;
  --surface-3: #f4f0ea;
  --hover: #f8f5f0;
  --line: #eee9e1;
  --line-2: #e4ded4;
  --line-strong: #d5cdc0;
  --text: #1f1b16;
  --text-2: #5d564c;
  --text-3: #675f54;          /* captions: ≥ 5:1 on every surface */
  --zero: #736b60;            /* zeros and «—»: dimmer than numbers, still ≥ 4.5:1 */
  --sk: #ece6dd;              /* skeleton blocks */

  --accent: #6a4cf5;
  --accent-2: #8f6bff;
  --accent-ink: #4c32cc;
  --accent-soft: #f1edff;
  --accent-line: #dcd3ff;
  --on-accent: #ffffff;

  --pos: #137a46; --pos-dot: #1d9a5b; --pos-soft: #e5f6ec;
  --neg: #c22a33; --neg-soft: #fdecec;
  --warn: #8f5600; --warn-dot: #e09200; --warn-soft: #fff5e3; --warn-line: #f4dcaf;
  --info: #2f5bc4; --info-soft: #eef3ff; --info-line: #d6e1fb;

  /* column families */
  --prod: #6f675c;   --prod-tint: #f2eee8;   --prod-soft: #f8f6f2;
  --stock: #0e9384;  --stock-ink: #0a7266;   --stock-tint: #dcf3ef;  --stock-soft: #f0faf8;
  --orders: #6a4cf5; --orders-ink: #4c32cc;  --orders-tint: #ebe6ff; --orders-soft: #f7f5ff;
  --sales: #1d9a5b;  --sales-ink: #15733f;   --sales-tint: #dcf2e4;  --sales-soft: #f1faf4;
  --conv: #e7720b;   --conv-ink: #9a4a00;    --conv-tint: #ffead2;   --conv-soft: #fff8ef;
  --fc: #1f7fd6;     --fc-ink: #145ea6;      --fc-tint: #e0eefb;     --fc-soft: #f2f8fe;
  --cost: #c03a76;   --cost-ink: #9c2560;    --cost-tint: #fbe3ee;   --cost-soft: #fdf3f7;
  --ret: #e0444c;    --ret-tint: #fde4e4;
  --hl: rgba(106, 76, 245, .045);

  --card-row: #faf7f2;
  --tot-row: #f3efe8;

  --shadow-sm: 0 1px 2px rgba(45, 32, 18, .05);
  --shadow: 0 1px 2px rgba(45, 32, 18, .04), 0 8px 24px -14px rgba(45, 32, 18, .18);
  --shadow-lg: 0 28px 70px -20px rgba(45, 32, 18, .32), 0 4px 14px rgba(45, 32, 18, .08);
  --ring: 0 0 0 3px rgba(106, 76, 245, .22);

  --r-xl: 22px;
  --r-lg: 16px;
  --r: 12px;
  --r-sm: 9px;

  --pad-x: 20px;              /* page side padding */
  --top-h: 64px;
  --kpi-h: 186px;             /* KPI cards (height tiers below make them shorter on short screens) */
  --strip-h: 48px;            /* «Свернуть итоги»: the KPI cards as one line */
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121110;
  --glow-1: rgba(128, 102, 255, .16);
  --glow-2: rgba(255, 140, 60, .07);
  --surface: #1b1917;
  --surface-2: #1f1d1a;
  --surface-3: #262320;
  --hover: #23201d;
  --line: #2b2824;
  --line-2: #34302b;
  --line-strong: #443e37;
  --text: #f4efe8;
  --text-2: #c3baad;
  --text-3: #a39a8c;
  --zero: #9a9184;
  --sk: #2a2622;

  --accent: #8d75ff;
  --accent-2: #a892ff;
  --accent-ink: #bcafff;
  --accent-soft: #25203d;
  --accent-line: #3b3268;
  --on-accent: #ffffff;

  --pos: #52d08e; --pos-dot: #52d08e; --pos-soft: #15291e;
  --neg: #ff7a7f; --neg-soft: #34191b;
  --warn: #f2b24e; --warn-dot: #f2b24e; --warn-soft: #2c2414; --warn-line: #574220;
  --info: #8fb0ff; --info-soft: #1a2133; --info-line: #2b3858;

  --prod: #a89f92;   --prod-tint: #25221f;   --prod-soft: #1f1d1a;
  --stock: #2cc6b2;  --stock-ink: #66dccb;   --stock-tint: #12302a;  --stock-soft: #182320;
  --orders: #8d75ff; --orders-ink: #b8a9ff;  --orders-tint: #262046; --orders-soft: #1f1c2b;
  --sales: #52d08e;  --sales-ink: #85e2b0;   --sales-tint: #163120;  --sales-soft: #1a231d;
  --conv: #ff9d45;   --conv-ink: #ffbd7e;    --conv-tint: #36250f;   --conv-soft: #261e15;
  --fc: #4ea6ff;     --fc-ink: #94c8ff;      --fc-tint: #13283d;     --fc-soft: #172029;
  --cost: #f0659f;   --cost-ink: #f7a3c6;    --cost-tint: #3a1828;   --cost-soft: #261820;
  --ret: #ff6d72;    --ret-tint: #3a1d1f;
  --hl: rgba(141, 117, 255, .07);

  --card-row: #211e1b;
  --tot-row: #29251f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px -16px rgba(0, 0, 0, .6);
  --shadow-lg: 0 28px 70px -20px rgba(0, 0, 0, .75), 0 4px 14px rgba(0, 0, 0, .4);
  --ring: 0 0 0 3px rgba(141, 117, 255, .35);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.45 var(--font);
  color: var(--text);
  background:
    radial-gradient(1100px 420px at 8% -120px, var(--glow-1), transparent 70%),
    radial-gradient(900px 380px at 96% -140px, var(--glow-2), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; font-feature-settings: "tnum" 1; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; }
.skip:focus { left: 8px; z-index: 100; background: var(--surface); padding: 6px 10px; border-radius: 8px; }
.measure { position: absolute; left: -10000px; top: 0; visibility: hidden; white-space: nowrap; pointer-events: none; contain: layout style; }
.measure span { display: inline-block; height: auto; }
.measure .m-vb { font-size: 14px; font-weight: 700; }
.measure .m-fn { font-size: 14px; font-weight: 700; }
.measure .m-fh { font-size: 13px; font-weight: 500; }
.measure .m-star { font-size: 13px; font-weight: 800; }
.measure .m-ts { font-size: 13px; font-weight: 500; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.i-sm { width: 14px; height: 14px; }
.i-xs { width: 12px; height: 12px; stroke-width: 2.2; }
.muted { color: var(--text-3); }
.spacer { flex: 1 1 auto; }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: 11px;
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--hover); border-color: var(--line-strong); }
.btn:disabled { color: var(--text-3); background: var(--surface-2); box-shadow: none; }
.btn-primary:disabled { color: rgba(255,255,255,.92); background: linear-gradient(135deg, #8a72f0, #6f58e0); }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; gap: 7px; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-soft { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); box-shadow: none; }
.btn-soft:hover { background: var(--accent-line); border-color: var(--accent-line); }
.btn-primary {
  position: relative;
  border: 0; color: var(--on-accent);
  background: linear-gradient(135deg, #7d5cff, #5f41ea 55%, #4f31dc);
  box-shadow: 0 1px 0 rgba(255,255,255,.25) inset, 0 8px 20px -8px rgba(106, 76, 245, .65);
}
.btn-primary:hover { background: linear-gradient(135deg, #7656ff, #5a3be6 45%, #4a2cd4); border: 0; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 16px; border-radius: 14px; gap: 10px; }
.btn .spinner { width: 14px; height: 14px; }
.btn-primary.is-dirty::after {
  content: ""; position: absolute; top: -4px; right: -4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--warn-dot); box-shadow: 0 0 0 2px var(--surface);
}
.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 11px; padding: 0;
  border: 1px solid transparent; background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.is-hidden { visibility: hidden; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--accent-ink); font-size: 13.5px; font-weight: 600; }
.linkbtn:hover { text-decoration: underline; text-underline-offset: 2px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 13px 0 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface);
  font-size: 13.5px; color: var(--text-2); white-space: nowrap;
}
.pill:hover { border-color: var(--line-strong); background: var(--hover); }
.pill b { color: var(--text); font-weight: 600; }
.pill-txt { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pos-dot); flex: none; box-shadow: 0 0 0 3px var(--pos-soft); }
.dot-idle { background: var(--line-strong); box-shadow: 0 0 0 3px var(--surface-3); }
.dot.aging { background: var(--warn-dot); box-shadow: 0 0 0 3px var(--warn-soft); }
.dot.stale { background: var(--ret); box-shadow: 0 0 0 3px var(--neg-soft); }
.dot.syncing { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); animation: pulse 1.6s ease-in-out infinite; }
.dot.live { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px var(--pos-soft); } 50% { box-shadow: 0 0 0 6px var(--pos-soft); } }

.spinner {
  display: inline-block; width: 16px; height: 16px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; opacity: .8;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* segmented control */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-3); border-radius: 12px; border: 1px solid var(--line);
}
.seg button {
  display: inline-flex; align-items: center; gap: 6px;
  border: 0; background: transparent; color: var(--text-2);
  height: 32px; padding: 0 12px; border-radius: 9px; font-weight: 600; font-size: 13.5px; white-space: nowrap;
}
.seg button[aria-pressed="true"] {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(45, 32, 18, .1), 0 0 0 1px var(--line);
}
.seg button:disabled { opacity: .5; }
.seg-sm button { height: 28px; padding: 0 10px; font-size: 13px; }
.seg small { font-weight: 500; color: var(--text-3); font-size: 13px; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--text-2); user-select: none; position: relative; }
.switch input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.switch .track { width: 34px; height: 20px; border-radius: 99px; background: var(--line-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 2px; left: 2px; 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 + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(14px); }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* chips & badges */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 30px; padding: 0 4px 0 9px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line-2);
  font-size: 13.5px; font-weight: 600; color: var(--text); white-space: nowrap;
}
.chip button { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--surface-3); color: var(--text-2); padding: 0; }
.chip button:hover { background: var(--neg-soft); color: var(--neg); }
.chip.same { background: var(--orders-soft); border-color: var(--accent-line); color: var(--orders-ink); padding-right: 9px; gap: 4px; }
.chip.same small { font-weight: 500; color: var(--text-3); font-size: 13px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 7px; border-radius: 6px;
  font-size: 13px; font-weight: 600; white-space: nowrap; line-height: 1;
  background: var(--surface-3); color: var(--text-2);
}
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.live, .badge.ok { background: var(--pos-soft); color: var(--pos); }
.badge.err { background: var(--neg-soft); color: var(--neg); }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); }

/* inputs */
.input {
  height: 36px; padding: 0 11px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text);
  font-size: 14px; min-width: 0;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input.is-invalid { border-color: var(--neg); }
select.input { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f877a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; background-size: 16px; }
input[type="date"].input { font-variant-numeric: tabular-nums; }
:root[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(.8); }

/* ------------------------------------------------------------------ top bar (fixed sizes: nothing in it changes width) */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: 1840px; margin: 0 auto; height: var(--top-h); padding: 0 var(--pad-x);
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, #8f6bff 0%, #6a4cf5 48%, #ff8a4c 120%);
  box-shadow: 0 6px 16px -6px rgba(106, 76, 245, .6);
}
.logo svg { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 0 1 auto; }
.brand-name { font: 700 16px/1.25 var(--font-display); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-seller { font-size: 13px; line-height: 18px; height: 18px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-seller b { color: var(--text-2); font-weight: 600; }
.share-slot { display: flex; min-width: 0; flex: none; }
.pill-share { height: 34px; }
.pill-share .i { color: var(--accent); }

.tabs {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 14px;
}
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 16px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-2); font-weight: 650; font-size: 14px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 2px rgba(45, 32, 18, .1), 0 0 0 1px var(--line);
}
.tab[aria-selected="true"] .i { color: var(--accent); }
.tab small { font-weight: 500; font-size: 13px; color: var(--text-3); }

.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; min-width: 0; }
.anchor { position: relative; }
.sync-anchor { display: flex; align-items: center; gap: 6px; }
.pill-fresh { width: 200px; }
.btn-sync { width: 172px; justify-content: center; }
.btn-sync .ico { display: inline-grid; place-items: center; width: 16px; height: 16px; }

/* ------------------------------------------------------------------ popovers / tooltip / toasts */
.popover {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 14px; text-align: left;
}
.pop-sync { width: 400px; padding: 0; overflow: hidden; }
.pop-head { padding: 14px 16px 10px; }
.pop-title { font: 700 15px/1.3 var(--font-display); margin-bottom: 2px; display: flex; align-items: center; gap: 8px; }
.pop-title .i { color: var(--pos); }
.pop-sub { color: var(--text-3); font-size: 13px; }
.pop-body { padding: 0 12px 12px; display: grid; gap: 10px; max-height: min(60vh, 520px); overflow: auto; }
.pop-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--surface-2); }
.bar { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 8px; transition: width .4s; }
.lanes { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.lanes.cols { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 14px; }
.lane { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 8px; font-size: 13.5px; min-height: 32px; }
.lane-icon { display: grid; place-items: center; color: var(--text-3); }
.lane-icon .spinner { width: 14px; height: 14px; color: var(--accent); }
.lane.ok .lane-icon, .lane.skipped .lane-icon { color: var(--pos); }
.lane.error .lane-icon { color: var(--neg); }
.lane.waiting .lane-icon, .lane.queued .lane-icon { color: var(--warn); }
.lane-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane-msg { color: var(--text-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 210px; text-align: right; }
.lane.error .lane-msg { color: var(--neg); }
.lane .wait { color: var(--warn); display: inline-flex; align-items: center; gap: 4px; }
.sync-log summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); padding: 4px; }
.sync-log ol { margin: 4px 0 0; padding: 8px 10px; list-style: none; font-size: 13px; color: var(--text-2); background: var(--surface-2); border-radius: 10px; max-height: 180px; overflow: auto; display: grid; gap: 3px; }
.sync-log li.warn { color: var(--warn); }
.sync-log li.error { color: var(--neg); }

.tip {
  position: fixed; z-index: 100; max-width: 360px; pointer-events: none;
  background: #221d18; color: #f6f1ea; border-radius: 10px; padding: 8px 11px;
  font-size: 13px; line-height: 1.45; white-space: pre-line;
  box-shadow: 0 10px 30px -8px rgba(0,0,0,.4);
}
:root[data-theme="dark"] .tip { background: #f1ebe2; color: #1f1b16; }
/* a formatted tooltip: the calculation behind «Дефицит» / «Остаток с учётом в пути» (label … number lines) */
.tip.rich { --tt-2: #d9d0c3; --tt-3: #c9bfb1; --tt-line: rgba(255, 255, 255, .16); --tt-warn: #ffc56b; max-width: 460px; white-space: normal; padding: 10px 13px 11px; }
:root[data-theme="dark"] .tip.rich { --tt-2: #4a443c; --tt-3: #5d564c; --tt-line: rgba(0, 0, 0, .14); --tt-warn: #8f5600; }
.tip.rich p { margin: 0; }
.tip.rich .tt-h { font-weight: 600; margin-bottom: 4px; }
.tip.rich .tt-h b { font-weight: 750; }
.tip.rich .tt-h small { font-size: 13px; font-weight: 400; color: var(--tt-3); margin-left: 4px; }
.tip.rich .tt-h2 { margin-top: 9px; padding-top: 8px; border-top: 1px solid var(--tt-line); }
.tip.rich .tt-f { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 18px; }
.tip.rich .tt-f .tt-l { color: var(--tt-2); }
.tip.rich .tt-f b { text-align: right; font-weight: 650; }
.tip.rich .tt-f .tt-sum, .tip.rich .tt-f .tt-sum + b { border-top: 1px solid var(--tt-line); margin-top: 3px; padding-top: 3px; font-weight: 700; color: inherit; }
.tip.rich .tt-n { margin-top: 6px; color: var(--tt-3); line-height: 1.4; }
.tip.rich .tt-w { color: var(--tt-warn); }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: #221d18; color: #f6f1ea; padding: 10px 10px 10px 14px; border-radius: 12px; box-shadow: var(--shadow-lg);
  font-size: 14px; line-height: 1.4; animation: toastIn .2s ease-out; max-width: 560px;
}
.toast .i { margin-top: 1px; }
.toast.ok .i { color: #6fe0a5; } .toast.error .i { color: #ff8f93; } .toast.warn .i { color: #ffc56b; } .toast.info .i { color: #a9c2ff; }
.toast-text { flex: 1; min-width: 0; }
.toast-action { margin-top: 8px; }
.toast-action .btn { height: 30px; font-size: 13.5px; background: #3a332c; color: #fff; border-color: #4a423a; }
.toast .x { width: 26px; height: 26px; border: 0; background: transparent; color: #cfc6ba; border-radius: 8px; display: grid; place-items: center; padding: 0; flex: none; }
.toast .x:hover { background: #3a332c; color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
:root[data-theme="dark"] .toast { background: #f1ebe2; color: #1f1b16; }
:root[data-theme="dark"] .toast.ok .i { color: #137a46; } :root[data-theme="dark"] .toast.error .i { color: #c22a33; }
:root[data-theme="dark"] .toast.warn .i { color: #8f5600; } :root[data-theme="dark"] .toast.info .i { color: #2f5bc4; }
:root[data-theme="dark"] .toast .x { color: #5d564c; }
:root[data-theme="dark"] .toast .x:hover, :root[data-theme="dark"] .toast-action .btn { background: #e2d9cc; color: #1f1b16; border-color: #d5cdc0; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ------------------------------------------------------------------ page */
.page { max-width: 1840px; margin: 0 auto; padding: 16px var(--pad-x) 40px; }
.banners:empty { display: none; }
/* one column that never grows past the page: a one-line (nowrap) note is cut with «…», it does not widen the page */
.banners { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin-bottom: 14px; }
/* the icon, «ещё N» / «свернуть» and «×» sit on the first text line (not in the middle of the note): when the notes
   open and the first one takes two lines, the buttons keep their place. --bn-c = content height of a one-line note */
.banner {
  --bn-c: 28px; --bn-x: 28px; --bn-m: 26px;
  display: flex; align-items: flex-start; gap: 10px; min-height: 40px; min-width: 0;
  padding: 5px 6px 5px 14px; border-radius: 12px;
  background: var(--info-soft); border: 1px solid var(--info-line); color: var(--text-2); font-size: 13.5px;
}
.banner > .i { color: var(--info); margin-top: calc((var(--bn-c) - 14px) / 2); }
.banner.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.banner.warn > .i { color: var(--warn); }
.banner.error { background: var(--neg-soft); border-color: color-mix(in srgb, var(--neg) 30%, transparent); }
.banner.error > .i { color: var(--neg); }
.banner-text { flex: 1; min-width: 0; line-height: 20px; padding: calc((var(--bn-c) - 20px) / 2) 0; }
.banner-text a { margin-left: 8px; font-weight: 600; }
.banner b { color: var(--text); font-weight: 600; }
.banner .x { margin-left: auto; width: var(--bn-x); height: var(--bn-x); margin-top: calc((var(--bn-c) - var(--bn-x)) / 2); }
.banner-more { flex: none; width: 84px; height: var(--bn-m); margin-top: calc((var(--bn-c) - var(--bn-m)) / 2); padding: 0 6px; border-radius: 8px; text-align: center; border: 1px solid var(--info-line); background: var(--surface); color: var(--accent-ink); font-size: 13px; font-weight: 600; white-space: nowrap; }
.banner-more:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.banner.warn .banner-more { border-color: var(--warn-line); }
.banner-more + .x { margin-left: 0; }

.views { display: block; }

/* ------------------------------------------------------------------ setup: collapsed bar (fixed height) */
.setup { margin-bottom: 16px; }
.setup-bar {
  display: flex; align-items: center; gap: 18px; height: 78px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow); padding: 0 14px;
}
.sb-period { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 0 1 auto; }
.cal-ico {
  width: 52px; height: 54px; border-radius: 12px; flex: none; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-2); text-align: center;
  display: flex; flex-direction: column; box-shadow: var(--shadow-sm);
}
.cal-ico span:first-child { background: linear-gradient(135deg, #7d5cff, #5a3be6); color: #fff; font-size: 13px; font-weight: 700; line-height: 19px; letter-spacing: .02em; }
.cal-ico span:last-child { font: 700 20px/33px var(--font-display); color: var(--text); }
.kicker { font-size: 13px; font-weight: 600; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-title { font: 700 21px/1.3 var(--font-display); letter-spacing: -.015em; display: flex; align-items: center; gap: 10px; white-space: nowrap; min-width: 0; }
.sb-title > span:first-child { overflow: hidden; text-overflow: ellipsis; }
.sb-title .badge { font-family: var(--font); letter-spacing: 0; }
.sb-title .t-short { display: none; }
.sb-part .i { display: none; }
.sb-facts { display: flex; align-items: stretch; gap: 0; min-width: 0; flex: 1 1 auto; }
.fact { padding: 2px 16px; border-left: 1px solid var(--line); min-width: 0; flex: none; }
.fact:last-child { flex: 0 1 auto; }
.fact-wh { width: 236px; }
.fact-win { width: 196px; }
.fact-k { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-3); font-weight: 600; white-space: nowrap; height: 19px; }
.fact-v { font-size: 14px; font-weight: 650; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 22px; line-height: 22px; }
.fact-v .muted { font-weight: 500; }
button.fact { background: none; border: 0; border-left: 1px solid var(--line); text-align: left; border-radius: 0; color: inherit; }
button.fact:hover .fact-v { color: var(--accent-ink); }
button.fact .chev { display: inline-block; vertical-align: -3px; color: var(--text-3); transition: transform .15s; }
button.fact[aria-expanded="true"] .chev { transform: rotate(180deg); }
.fact-anchor { position: relative; display: flex; }
.sb-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex: none; }
.sb-progress { flex: 1 1 auto; min-width: 0; display: grid; gap: 6px; padding: 0 8px 0 16px; border-left: 1px solid var(--line); }
.sb-progress .pt { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; white-space: nowrap; overflow: hidden; }
.sb-progress .pt .muted { font-weight: 500; }
.sb-progress .spinner { color: var(--accent); width: 14px; height: 14px; }

/* ------------------------------------------------------------------ setup: expanded steps */
.setup-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  box-shadow: var(--shadow);
}
.setup-head { display: flex; align-items: center; gap: 14px; padding: 18px 22px 4px; }
.setup-head h2 { font-size: 20px; font-weight: 700; }
.setup-head p { color: var(--text-3); font-size: 14px; }
.setup-head .icon-btn { margin-left: auto; }
.steps { display: grid; grid-template-columns: 1.22fr 1fr 1fr 0.96fr; gap: 0; padding: 14px; }
.step { position: relative; padding: 14px 18px 16px; min-width: 0; }
.step + .step::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 1px; background: var(--line); }
.step-h { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.step-n {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: linear-gradient(135deg, #7d5cff, #5a3be6); color: #fff; font-weight: 700; font-size: 14px;
  box-shadow: 0 4px 10px -4px rgba(106, 76, 245, .7);
}
.step-t { font: 700 16px/1.25 var(--font-display); }
.step-d { color: var(--text-3); font-size: 13.5px; margin: 0 0 14px 38px; line-height: 1.4; }
.step-body { display: grid; gap: 12px; }
#st-win .row { gap: 6px; }
/* step 1: when the column is narrow the end-of-period buttons put their hint under the label (no overflow, no jumps) */
#st-period { container-type: inline-size; }
@container (max-width: 404px) {
  #st-period .seg button { flex-direction: column; justify-content: center; align-items: center; gap: 0; height: 44px; line-height: 18px; padding: 0 11px; }
}
.f-label { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; display: block; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 11px; background: var(--surface); overflow: hidden; height: 36px; }
.stepper button { width: 32px; height: 100%; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; padding: 0; }
.stepper button:hover { background: var(--surface-3); }
.stepper input { width: 46px; border: 0; text-align: center; font-weight: 700; font-size: 15px; background: transparent; height: 100%; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; }
.stepper .unit { font-size: 13px; color: var(--text-3); padding-right: 6px; }
.presets { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.preset { height: 30px; min-width: 34px; padding: 0 9px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--surface); font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.preset:hover { border-color: var(--line-strong); color: var(--text); }
.preset[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-ink); }
.range-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; color: var(--text-2); }
.range-row .input { width: 150px; }
.result {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 14px;
}
.result b { color: var(--text); font-weight: 700; }
.result .i { color: var(--accent); }
.result.err { background: var(--neg-soft); color: var(--neg); }
.hint { font-size: 13px; color: var(--text-3); line-height: 1.4; }
.hint.warn { color: var(--warn); }

/* warehouses dropdown */
.dd { position: relative; }
.dd-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 12px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--surface); text-align: left;
  box-shadow: var(--shadow-sm);
}
.dd-btn:hover { border-color: var(--line-strong); }
.dd-btn[aria-expanded="true"] { border-color: var(--accent); box-shadow: var(--ring); }
.dd-btn .wh-ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--stock-tint); color: var(--stock); flex: none; }
.dd-btn .lbl { flex: 1; min-width: 0; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; }
.dd-btn .lbl small { display: block; font-weight: 500; font-size: 13px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.dd-btn .chev { color: var(--text-3); transition: transform .15s; display: grid; }
.dd-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.excluded { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; color: var(--text-3); }
.excluded .chip { height: 28px; font-size: 13px; font-weight: 600; background: var(--neg-soft); border-color: transparent; color: var(--neg); padding-left: 10px; }
.excluded .chip button { background: transparent; color: var(--neg); width: 20px; height: 20px; }
.sw-note { font-size: 13px; color: var(--text-3); margin: 3px 0 0 43px; line-height: 1.4; }
.sw-note.warn { color: var(--warn); }

.dd-panel {
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 50;
  width: 500px; max-width: calc(100vw - 32px); padding: 0; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow-lg);
}
.dd-top { padding: 12px 12px 8px; display: grid; gap: 10px; border-bottom: 1px solid var(--line); }
.dd-search { position: relative; }
.dd-search .i { position: absolute; left: 12px; top: 12px; color: var(--text-3); }
.dd-search input { width: 100%; padding-left: 36px; height: 38px; background: var(--surface-2); }
.dd-actions { display: flex; align-items: center; gap: 4px; font-size: 13.5px; flex-wrap: wrap; }
.dd-actions .btn { height: 30px; padding: 0 9px; font-size: 13.5px; }
.dd-count { margin-left: auto; color: var(--text-3); font-size: 13.5px; white-space: nowrap; }
.dd-count b { color: var(--text); }
.dd-cols { display: grid; grid-template-columns: minmax(0, 1fr) 78px 92px; gap: 8px; padding: 8px 20px 4px 52px; white-space: nowrap; font-size: 13px; color: var(--text-3); font-weight: 600; }
.dd-cols span:not(:first-child) { text-align: right; }
.dd-list { height: 330px; overflow: auto; padding: 2px 6px 6px; overscroll-behavior: contain; }
.wh {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) 78px 92px; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 10px; cursor: pointer; font-size: 14px; min-height: 40px; position: relative;
}
.wh:hover { background: var(--hover); }
.wh input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.cbox {
  width: 20px; height: 20px; border-radius: 6px; border: 1.6px solid var(--line-strong); background: var(--surface);
  display: grid; place-items: center; color: #fff; transition: background .12s, border-color .12s;
}
.cbox .i { opacity: 0; }
.wh input:checked + .cbox { background: var(--accent); border-color: var(--accent); }
.wh input:checked + .cbox .i { opacity: 1; }
.wh input:focus-visible + .cbox { box-shadow: var(--ring); }
.wh-name { min-width: 0; display: flex; align-items: center; gap: 6px; }
.wh-name > .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wh-name mark { background: var(--warn-soft); color: inherit; border-radius: 3px; }
.wh-name .note { color: var(--text-3); display: inline-grid; }
.wh-qty { text-align: right; font-weight: 650; }
.wh-bar { display: block; width: 56px; margin-left: auto; height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 3px; overflow: hidden; }
.wh-bar i { display: block; height: 100%; background: var(--stock); border-radius: 4px; }
.wh-flow { text-align: right; font-size: 13.5px; color: var(--text-3); }
.wh-flow b { color: var(--orders-ink); font-weight: 650; }
.wh.off .wh-name { color: var(--text-3); }
.wh.zero .wh-qty { color: var(--zero); font-weight: 500; }
.wh .badge { height: 20px; font-size: 13px; padding: 0 6px; font-weight: 500; }
.wh-sep { padding: 10px 10px 4px 44px; font-size: 13px; font-weight: 600; color: var(--text-3); }
.dd-empty { padding: 18px; color: var(--text-3); font-size: 14px; }
.dd-foot { border-top: 1px solid var(--line); padding: 10px 14px 12px; display: grid; gap: 9px; background: var(--surface-2); }
.dd-info { display: flex; gap: 8px; font-size: 13px; color: var(--text-3); line-height: 1.4; }
.dd-info .i { color: var(--info); margin-top: 1px; }
.dd-done { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; color: var(--text-3); }

/* run column */
.step-run {
  margin: 0 0 0 10px; padding: 18px; border-radius: 18px;
  background:
    radial-gradient(240px 160px at 100% 0%, rgba(255, 146, 70, .14), transparent 70%),
    linear-gradient(160deg, var(--accent-soft), color-mix(in srgb, var(--accent-soft) 40%, var(--surface)));
  border: 1px solid var(--accent-line);
  display: flex; flex-direction: column; gap: 12px;
}
.step-run::before { display: none; }
.checks { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; font-size: 14px; }
.checks li { display: flex; gap: 9px; align-items: flex-start; color: var(--text-2); line-height: 1.35; }
.checks li b { color: var(--text); font-weight: 650; }
.checks .ck { width: 20px; height: 20px; border-radius: 50%; background: var(--pos-dot); color: #fff; display: grid; place-items: center; flex: none; margin-top: -1px; }
.checks .ck.changed { background: var(--warn-dot); }
.checks .ck.bad { background: var(--ret); }
.step-run .btn-lg { width: 100%; justify-content: center; margin-top: auto; }
.run-note { font-size: 13px; color: var(--text-3); text-align: center; line-height: 1.4; }
.dirty { display: flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--warn); font-weight: 600; min-height: 20px; }
.dirty.ok { color: var(--text-2); font-weight: 500; }
.dirty.ok .i { color: var(--pos); }
.run-progress { display: grid; gap: 8px; }
.run-progress .pt { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; font-weight: 600; font-size: 14px; }
.run-progress .pt .muted { flex-basis: 100%; font-weight: 500; font-size: 13px; padding-left: 22px; }
.run-progress .lane { grid-template-columns: 20px minmax(0, 1fr); row-gap: 0; padding: 4px; }
.run-progress .lane-msg { grid-column: 2; text-align: left; max-width: none; }
.run-progress .spinner { color: var(--accent); width: 14px; height: 14px; }

.setup-extra {
  display: flex; align-items: center; gap: 12px 16px; flex-wrap: wrap;
  padding: 12px 22px 16px; border-top: 1px dashed var(--line-2); margin: 0 14px;
}
.setup-extra .x-title { font-size: 13px; font-weight: 700; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.setup-extra label.inline { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.setup-extra select { height: 34px; width: 230px; }
.setup-extra #fc-days { height: 34px; width: 74px; text-align: right; }

/* ------------------------------------------------------------------ KPI (fixed height: skeleton and data have the same box) */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.42fr); gap: 12px; margin-bottom: 16px; height: var(--kpi-h); }
.kpi, .stockcard {
  position: relative; overflow: hidden; height: var(--kpi-h);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow); min-width: 0;
}
.kpi { padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; container-type: inline-size; }
.kpi-h { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; color: var(--text-2); margin-bottom: 6px; height: 28px; white-space: nowrap; }
.fi { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.fi .i { width: 16px; height: 16px; stroke-width: 2; }
.fi-stock { background: var(--stock-tint); color: var(--stock); }
.fi-orders { background: var(--orders-tint); color: var(--orders); }
.fi-sales { background: var(--sales-tint); color: var(--sales); }
.fi-ret { background: var(--ret-tint); color: var(--ret); }
.fi-conv { background: var(--conv-tint); color: var(--conv); }
.fi-prod { background: var(--prod-tint); color: var(--prod); }
.fi-fc { background: var(--fc-tint); color: var(--fc); }
.fi-cost { background: var(--cost-tint); color: var(--cost); }
.kpi-v { font: 700 30px/36px var(--font-display); letter-spacing: -.02em; white-space: nowrap; height: 36px; overflow: hidden; text-overflow: ellipsis; }
.kpi-v small { font-size: 17px; font-weight: 600; color: var(--text-3); margin-left: 3px; letter-spacing: 0; }
.kpi-v.neg { color: var(--neg); }
.kpi-s { font-size: 13.5px; color: var(--text-2); line-height: 19px; height: 38px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.kpi-s b { color: var(--text); font-weight: 650; }
.kpi-f { margin-top: auto; padding-top: 8px; font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 6px; white-space: nowrap; height: 30px; overflow: hidden; }
.kpi-f b { color: var(--text-2); font-weight: 650; }
.kpi-f > span:not(.meter):not(.badge):not(.kpi-flag) { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.kpi-f .badge { height: 22px; flex: none; }
/* «уточняется»: icon + word on a wide card, the word alone on a medium one, the clock alone on a narrow one */
.imm-badge { padding: 0 5px; }
.imm-badge .bt { display: none; }
@container (min-width: 178px) { .imm-badge .bt { display: inline; } .imm-badge .i { display: none; } .imm-badge { padding: 0 7px; } }
@container (min-width: 198px) { .imm-badge .i { display: inline-block; } }
.meter { flex: 1; height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; display: flex; min-width: 24px; }
.meter i { display: block; height: 100%; background: var(--ret); }
.kpi .ring { position: absolute; right: 14px; top: 14px; }
.kpi-hero {
  border: 0; color: #fff;
  background:
    radial-gradient(180px 120px at 100% 0%, rgba(255,255,255,.22), transparent 70%),
    linear-gradient(150deg, #23a463, #12804f 60%, #0e715b);
  box-shadow: 0 14px 30px -14px rgba(19, 138, 85, .7);
}
:root[data-theme="dark"] .kpi-hero { background: radial-gradient(180px 120px at 100% 0%, rgba(255,255,255,.12), transparent 70%), linear-gradient(150deg, #1f8f57, #156b45 60%, #11594c); }
.kpi-hero .kpi-h, .kpi-hero .kpi-s, .kpi-hero .kpi-f { color: rgba(255,255,255,.92); }
.kpi-hero .kpi-s b, .kpi-hero .kpi-f b { color: #fff; }
.kpi-hero .fi { background: rgba(255,255,255,.2); color: #fff; }
.kpi-hero .kpi-v small { color: rgba(255,255,255,.85); }
.kpi-hero .kpi-v.neg { color: #fff; }
.kpi-flag { margin-left: auto; flex: none; height: 22px; padding: 0 7px; border-radius: 6px; font-size: 13px; font-weight: 600; background: rgba(0,0,0,.18); color: #fff; display: none; align-items: center; gap: 4px; }
.kpis.filtered .kpi-flag { display: inline-flex; margin-left: 0; }
.kpis.filtered .kpi-hero .kpi-f > span:first-child { display: none; }   /* while searching the line says «по найденным» (the exact sum is in the tooltip) */

.stockcard { padding: 12px 14px 8px; display: flex; flex-direction: column; container-type: inline-size; }
.stockcard .v-s { display: none; }
@container (max-width: 262px) { .stockcard .v-l { display: none; } .stockcard .v-s { display: inline; } }
.stockcard-h { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 650; color: var(--text-2); height: 22px; white-space: nowrap; }
.sc-sub { font-size: 13px; color: var(--text-3); height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sc-note { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; color: var(--text-3); white-space: nowrap; }
.srow { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; height: 46px; border-bottom: 1px dashed var(--line); }
.srow:last-child { border-bottom: 0; }
.srow .lbl { min-width: 0; font-size: 14px; color: var(--text); font-weight: 600; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow .lbl small { display: block; font-size: 13px; color: var(--text-3); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.srow .v { font: 700 19px/1 var(--font-display); letter-spacing: -.01em; white-space: nowrap; }
.srow .lbl .l-part { display: none; }
.srow .v small { font-size: 13px; color: var(--text-3); font-weight: 600; margin-left: 2px; }

/* «Свернуть итоги»: the same numbers in one line (the choice is restored before the first paint: theme.js) */
:root[data-kpis="strip"] .kpis, .kpis.is-strip { display: block; height: var(--strip-h); }
.kstrip {
  /* the money item («Чистыми 23,23 млн ₽») gets a little of the room the short ones do not need */
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, .9fr) minmax(0, 1.15fr) minmax(0, .95fr) minmax(0, 1.42fr) auto auto; align-items: center;
  height: var(--strip-h); padding: 0 6px 0 2px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
}
.ks { display: flex; align-items: center; gap: 8px; min-width: 0; height: 28px; padding: 0 12px; border-left: 1px solid var(--line); container-type: inline-size; }
.ks:first-child { border-left: 0; }
.ks .fi { width: 24px; height: 24px; border-radius: 7px; }
.ks .fi .i { width: 14px; height: 14px; }
.ks > .sk { flex: 1; }
.fi-hero { background: linear-gradient(150deg, #23a463, #12804f); color: #fff; }
/* the grey extra after a number drops to the hidden second line when it does not fit: whole words, no «…» */
.ks-t { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; min-width: 0; height: 22px; line-height: 22px; overflow: hidden; }
.ks-m { display: inline-flex; align-items: baseline; gap: 6px; white-space: nowrap; }
.ks-l { font-size: 13.5px; font-weight: 650; color: var(--text-2); }
.ks-m b { font: 700 17px/22px var(--font-display); letter-spacing: -.01em; color: var(--text); }
.ks-m small { font-size: 13px; font-weight: 600; color: var(--text-3); margin-left: -3px; }
.ks-hero .ks-m b { color: var(--sales-ink); }
.ks-hero.neg .ks-m b { color: var(--neg); }
.ks-x { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.ks-x::before { content: "· "; }
.ks-x b { color: var(--text-2); font-weight: 650; }
.ks .v-s { display: none; }
/* priority in a narrow item: label + number first (the grey extra wraps away whole when it does not fit beside
   them), then the short label, then the icon goes; the label is the last thing to go (the tooltip has every figure) */
@container (max-width: 236px) { .ks .v-l { display: none; } .ks .v-s { display: inline; } }
@container (max-width: 110px) { .ks-l { display: none; } }
/* up to 1340 px wide the icons go (all of them, so the row stays even) and the items get a little more room */
@media (min-width: 761px) and (max-width: 1340px) {
  .ks .fi { display: none; }
  .ks { padding: 0 10px; }
  .ks-m { gap: 5px; }
}
.ks-end { width: 34px; height: 34px; border-radius: 10px; }
.ks-end .btn-txt { display: none; }
.ks-flag { display: none; align-items: center; gap: 4px; height: 22px; padding: 0 7px; margin-right: 4px; border-radius: 6px; font-size: 13px; font-weight: 600; background: var(--accent-soft); color: var(--accent-ink); white-space: nowrap; }
.kpis.filtered .ks-flag { display: inline-flex; }
.sb-kpi { justify-content: center; }
:root[data-kpis="strip"] .sb-kpi { display: none; }   /* the strip has its own toggle at its end: one is enough */
@media (max-width: 1500px) {
  .sb-kpi { width: 38px; padding: 0; }
  .sb-kpi .btn-txt { display: none; }
}

/* skeleton */
.sk { display: block; height: 14px; border-radius: 7px; background: var(--sk); position: relative; overflow: hidden; }
.sk::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); animation: shimmer 1.4s infinite; }
:root[data-theme="dark"] .sk::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.06), transparent); }
@keyframes shimmer { to { transform: translateX(100%); } }
.kpi.is-sk { gap: 0; }
.kpi.is-sk .sk-h { width: 55%; height: 16px; margin: 6px 0 16px; }
.kpi.is-sk .sk-v { width: 62%; height: 30px; border-radius: 9px; margin-bottom: 14px; }
.kpi.is-sk .sk-s { width: 88%; margin-bottom: 8px; }
.kpi.is-sk .sk-s2 { width: 64%; }
.kpi.is-sk .sk-f { width: 70%; margin-top: auto; }
.stockcard.is-sk .sk-sh { width: 50%; height: 16px; margin: 4px 0 12px; }
.stockcard.is-sk .sk-sr { width: 90%; height: 26px; margin-bottom: 16px; }
.stockcard.is-sk .sk-sr:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ table card */
.tcard { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); overflow: hidden; }
.tc-head { display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 14px 0 18px; }
.tc-l, .tc-r { display: contents; }   /* groups for the one-row toolbar of short screens */
.tc-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: none; }
.tc-title h2 { font-size: 17px; font-weight: 700; white-space: nowrap; }
.tc-count { color: var(--text-3); font-size: 13.5px; white-space: nowrap; width: 230px; overflow: hidden; text-overflow: ellipsis; }
.search { position: relative; display: block; width: 300px; flex: 0 1 300px; min-width: 160px; }
.search .search-ico { position: absolute; left: 12px; top: 11px; color: var(--text-3); display: flex; }
.search input { width: 100%; height: 36px; padding: 0 12px 0 36px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: 14px; }
.search input:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); background: var(--surface); }
/* always «Свернуть размеры» / «Показать размеры» (a bare «Свернуть» next to «Свернуть итоги» was unclear);
   the width fits both labels, so the button never changes size */
#btn-collapse { width: 194px; justify-content: flex-start; }
#btn-collapse.is-off { visibility: hidden; }
#btn-collapse .i { transition: transform .15s; }
#btn-collapse.all-collapsed .i { transform: rotate(90deg); }

/* info strip: legend on the left, report warnings on the right (fixed height: warnings never push the table) */
.infostrip {
  display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 10px 0 16px;
  border-top: 1px solid var(--line); background: var(--surface-2); font-size: 13px; color: var(--text-3);
}
.legend { display: flex; align-items: center; gap: 6px 15px; min-width: 0; flex: 0 1 auto; overflow: hidden; white-space: nowrap; }
.legend .lg-t { display: inline-grid; place-items: center; width: 26px; height: 26px; border: 0; border-radius: 8px; background: transparent; color: var(--accent); padding: 0; flex: none; }
.legend .lg-t:hover { background: var(--surface-3); }
.lg { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lg b { color: var(--text); font-weight: 650; }
.sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.sw-stock { background: var(--stock); } .sw-orders { background: var(--orders); } .sw-sales { background: var(--sales); } .sw-conv { background: var(--conv); } .sw-fc { background: var(--fc); } .sw-cost { background: var(--cost); }
.lg .star { color: var(--conv-ink); font-weight: 800; font-size: 15px; }
.legend.closed .lg { display: none; }
.legend .lg-ss { display: none; }
.legend.bare .lg-d { display: none; }   /* the descriptions do not fit: the family names only (fitLegend) */
#legend.no-star .lg-star { display: none; }   /* no «*» in the report: no stray asterisk in the toolbar */
/* the legend never changes with the report (warnings take the free space on the right): nothing shifts on load */
.warn-anchor { flex: 1 1 0; min-width: 160px; display: flex; justify-content: flex-end; }
.wh-jump {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 4px; width: 128px; height: 28px; padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--stock) 35%, transparent); border-radius: 8px; background: var(--stock-soft);
  color: var(--stock-ink); font-size: 13px; font-weight: 650; white-space: nowrap;
}
.wh-jump:hover { background: var(--stock-tint); }
/* the chip takes the colour of the family it leads to (data-at: sales / conv / wh / back) */
.wh-jump[data-at="sales"] { border-color: color-mix(in srgb, var(--sales) 35%, transparent); background: var(--sales-soft); color: var(--sales-ink); }
.wh-jump[data-at="sales"]:hover { background: var(--sales-tint); }
.wh-jump[data-at="conv"] { border-color: color-mix(in srgb, var(--conv) 35%, transparent); background: var(--conv-soft); color: var(--conv-ink); }
.wh-jump[data-at="conv"]:hover { background: var(--conv-tint); }
.wh-jump[data-at="cost"] { border-color: color-mix(in srgb, var(--cost) 35%, transparent); background: var(--cost-soft); color: var(--cost-ink); }
.wh-jump[data-at="cost"]:hover { background: var(--cost-tint); }
.wh-jump .flip { transform: rotate(180deg); }
.rwarn {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-width: 0; height: 30px; padding: 0 10px;
  border: 1px solid var(--warn-line); border-radius: 9px; background: var(--warn-soft); color: var(--warn); font-size: 13px; font-weight: 600;
}
.rwarn .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.rwarn .n { flex: none; background: var(--surface); border-radius: 6px; padding: 0 6px; line-height: 20px; }
.rwarn .tm { display: none; white-space: nowrap; }
.rwarn .tm-s { display: none; }
/* a narrow slot: «Предупреждения · N» instead of the first warning cut to a few letters */
.warn-anchor { container-type: inline-size; }
@container (max-width: 250px) { .rwarn .t, .rwarn .n { display: none; } .rwarn .tm { display: inline; } }
@container (max-width: 180px) { .rwarn .tm-l { display: none; } .rwarn .tm-s { display: inline; } }
/* the first warning does not fit whole (app.js fitRwarn): the label form, the full text is in the popover */
.rwarn.short .t, .rwarn.short .n { display: none; }
.rwarn.short .tm { display: inline; }
.pop-warn { width: 460px; max-width: calc(100vw - 32px); }
.pop-warn ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 6px; font-size: 14px; color: var(--text-2); }
.pop-warn .pop-note { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-3); line-height: 1.45; }
.pop-note .star { color: var(--conv-ink); font-weight: 800; font-size: 15px; }

/* table viewport: fixed height, reserved before the data arrives */
.tbl-box { position: relative; border-top: 1px solid var(--line); }
.tbl-scroll {
  position: relative; overflow: auto; height: calc(100vh - 150px); min-height: 420px;
  overscroll-behavior: contain; scrollbar-gutter: stable;
}
.tbl-fade {
  position: absolute; top: 0; bottom: 0; right: 0; width: 44px; pointer-events: none; opacity: 0; transition: opacity .2s;
  background: linear-gradient(to right, transparent, color-mix(in srgb, var(--surface) 92%, transparent));
}
.tbl-box.more-right .tbl-fade { opacity: 1; }
.tbl-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: color-mix(in srgb, var(--surface) 80%, transparent); z-index: 9;
}
.tbl-msg .empty { max-width: 460px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.tbl-msg .empty-ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.tbl-msg h3 { font-size: 18px; }
.tbl-msg p { color: var(--text-2); font-size: 14px; }
.tbl-box.is-loading .tbl-scroll { opacity: .55; pointer-events: none; transition: opacity .2s; }

/* ------------------------------------------------------------------ the grid */
.grid {
  border-collapse: separate; border-spacing: 0; table-layout: fixed;
  font-size: 14px; line-height: 20px;
}
.grid th, .grid td { padding: 0 6px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid thead { position: sticky; top: 0; z-index: 6; }
.grid thead th, .grid thead td { background: var(--surface); }
.grid .n { text-align: right; }

/* family band */
.grid tr.fam th { height: 34px; text-align: left; font-size: 14px; font-weight: 700; padding: 0 10px; border-bottom: 0; }
.fam-in { display: flex; align-items: center; gap: 7px; min-width: 0; overflow: hidden; }
.fam-in > span { white-space: nowrap; }
.fam-in small { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fam-in .i { width: 15px; height: 15px; stroke-width: 2; }
.grid th.f-stock { background: var(--stock-tint); color: var(--stock-ink); box-shadow: inset 0 3px 0 var(--stock); }
.grid th.f-wh { background: var(--stock-tint); color: var(--stock-ink); box-shadow: inset 0 3px 0 var(--stock); }
.grid th.f-orders { background: var(--orders-tint); color: var(--orders-ink); box-shadow: inset 0 3px 0 var(--orders); }
.grid th.f-sales { background: var(--sales-tint); color: var(--sales-ink); box-shadow: inset 0 3px 0 var(--sales); }
.grid th.f-conv { background: var(--conv-tint); color: var(--conv-ink); box-shadow: inset 0 3px 0 var(--conv); }
.grid th.f-fc { background: var(--fc-tint); color: var(--fc-ink); box-shadow: inset 0 3px 0 var(--fc); }
.grid th.f-cost { background: var(--cost-tint); color: var(--cost-ink); box-shadow: inset 0 3px 0 var(--cost); }

/* column headers: a «label» line and a «caption» line, both nowrap; the sort arrow lives in a fixed slot */
.grid tr.lbl { height: 48px; }
.grid tr.unit { height: 26px; }
.grid tr.lbl.solo { height: 74px; }
.grid tr.lbl th, .grid tr.unit th {
  vertical-align: bottom; text-align: right; padding: 0 6px 7px; position: relative;
  user-select: none; overflow: hidden;
}
.th-l { display: block; height: 20px; line-height: 20px; font-size: 13px; font-weight: 650; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.th-c { display: block; height: 18px; line-height: 18px; font-size: 13px; font-weight: 400; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.grid th.sortable { cursor: pointer; }
.grid th.sortable:hover .th-l { color: var(--accent-ink); }
.grid th.sorted .th-l { color: var(--accent-ink); }
.sort-ar { position: absolute; right: 6px; bottom: 46px; width: 12px; height: 12px; display: grid; place-items: center; color: var(--accent); visibility: hidden; }
.sort-ar svg { width: 12px; height: 12px; fill: currentColor; stroke: none; }
.grid th.sorted .sort-ar { visibility: visible; }
.grid th.sorted.asc .sort-ar svg { transform: rotate(180deg); }
.grid tr.unit th { padding-bottom: 5px; }
.grid tr.unit th .sort-ar { right: auto; left: 3px; top: auto; bottom: 9px; }
.grid.tight tr.lbl th, .grid.tight tr.unit th { padding-left: 4.5px; padding-right: 4.5px; }
.grid.tight td.n, .grid.tight tr.tot td, .grid.tight tr.tot-all td { padding-left: 4.5px; padding-right: 4.5px; }
.grid.tight .sort-ar { right: 4px; }
.grid.tight .c-a { padding-left: 10px; padding-right: 8px; }
/* «Товар» below its usual floor (desktop, the last few px): no card photo, a narrower size tree */
.grid.tighter .c-a { padding-left: 8px; padding-right: 6px; }
.grid.tighter .card-a .ph { display: none; }
.grid.tighter .size-a { padding-left: 18px; gap: 6px; }
.grid.tighter .size-a::before, .grid.tighter .size-a::after { left: 10px; }
.grid.tighter .size-a::after { width: 6px; }
.grid.tighter .sz { min-width: 32px; }
.grid.tighter .bc { font-size: 13px; }
.grid.tighter .ca-head .td-x { display: none; }
.grid tr.unit th .th-l { font-size: 13px; color: var(--text-2); }
.grid tr.lbl th.pair { text-align: center; padding-bottom: 3px; border-bottom: 0; cursor: default; }
.grid th .star { color: var(--conv-ink); font-weight: 800; margin-left: 1px; }
/* tight layouts: the «*» of a column is raised above the end of its label and takes no width (1366 px fits) */
.grid.raised tr.lbl th.has-star .th-l .star { position: absolute; right: 1px; bottom: 33px; margin: 0; font-size: 15px; line-height: 1; }
.grid.raised th.has-star .sort-ar { right: 12px; }
.grid th.c-stock, .grid th.c-wh { background: var(--stock-soft); }
.grid th.c-orders { background: var(--orders-soft); }
.grid th.c-sales { background: var(--sales-soft); }
.grid th.c-conv { background: var(--conv-soft); }
.grid th.c-fc { background: var(--fc-soft); }
.grid th.c-cost { background: var(--cost-soft); }
.grid th.hl .th-c { color: var(--orders-ink); }
.grid .fs { border-left: 1px solid var(--line-2); }

/* totals rows (sticky, under the header) */
.grid tr.tot > * { background: var(--tot-row); height: 46px; font-weight: 700; border-bottom: 1px solid var(--line-strong); }
.grid tr.tot-all > * { background: var(--tot-row); height: 30px; font-weight: 500; font-size: 13px; color: var(--text-2); border-bottom: 1px solid var(--line-strong); }
.grid tr.tot-all.whole > * { color: var(--text-3); }
.grid tr.has-all > * { border-bottom-color: var(--line-2); }
.grid thead tr.tot th.c-a, .grid thead tr.tot-all th.c-a { padding: 0 10px 0 12px; vertical-align: middle; cursor: default; }
.tot-a { display: flex; flex-direction: column; line-height: 1.2; padding-left: 4px; min-width: 0; }
.tot-a b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tot-a small { font-weight: 500; color: var(--text-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tot-all-a { padding-left: 4px; font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tot-all-a span { color: var(--text-3); }
.grid tr.tot-all td.z, .grid tr.tot td.z { color: var(--zero); }

/* sticky first column */
.grid .c-a { position: sticky; left: 0; z-index: 2; text-align: left; border-right: 1px solid var(--line-2); padding: 0 10px 0 12px; }
.grid thead .c-a { z-index: 7; }
.grid thead th.c-a { vertical-align: bottom; padding: 8px 12px 9px 14px; background: var(--surface); cursor: pointer; }
.tbl-box.scrolled-x .grid .c-a { box-shadow: 8px 0 10px -8px rgba(45, 32, 18, .28); }
:root[data-theme="dark"] .tbl-box.scrolled-x .grid .c-a { box-shadow: 8px 0 10px -8px rgba(0, 0, 0, .7); }
.ca-head { display: grid; gap: 4px; position: relative; }
.ca-head .fam-in { font-size: 14px; font-weight: 700; color: var(--prod); }
.ca-head .fam-in .i { width: 15px; height: 15px; }
.ca-head .tree-demo { font-size: 13px; color: var(--text-3); font-weight: 400; line-height: 18px; overflow: hidden; text-overflow: ellipsis; }
.ca-head .tree-demo b { color: var(--text); font-weight: 600; }
.ca-head .sort-ar { position: static; display: inline-grid; visibility: hidden; }
.grid th.c-a.sorted .ca-head .sort-ar { visibility: visible; }
.grid th.c-a.sorted .fam-in > span { color: var(--accent-ink); }

/* body rows: constant heights per row type */
.grid tbody td { background: var(--surface); }
.grid tbody tr:hover > td { background: var(--hover); }
.grid tbody td.z, .grid tbody td.na { color: var(--zero); }
.grid td.neg, .grid tr.tot .neg { color: var(--neg); }
.grid td.imm { color: var(--text-3); font-style: italic; }
.grid td.hl, .grid th.hl { box-shadow: inset 0 0 0 9999px var(--hl); }
.pct-s { color: var(--text-3); font-size: 13px; margin-left: 2px; }
/* «Прогноз»: too few days in stock for a reliable forecast (orange, as in the seller's other service), the
   deficit as a chip (red; amber when it rests on such a forecast), a row's own «*» on its days in stock */
.grid tbody tr > td.low { background: var(--warn-soft); color: var(--warn); }
.grid tbody tr:hover > td.low { background: color-mix(in srgb, var(--warn-soft) 80%, var(--warn-line)); }
.grid tr.card > td.low { font-weight: 650; }
.dchip {
  display: inline-block; min-width: 26px; padding: 0 7px; border-radius: 7px; line-height: 22px; text-align: center;
  font-weight: 700; background: var(--neg-soft); color: var(--neg);
}
.dchip.warn { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 1px var(--warn-line); }
.cstar { color: var(--conv-ink); font-weight: 800; margin-left: 1px; }
/* «Дней в наличии»: the number opens «Наличие по дням» (dotted underline = «there is more behind it») */
.grid td.av { cursor: pointer; }
.avb {
  border: 0; background: none; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; line-height: inherit;
  text-decoration: underline dotted; text-decoration-thickness: 1.5px; text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, currentColor 60%, transparent);
}
.grid td.av:hover .avb, .avb[aria-expanded="true"] { color: var(--fc-ink); text-decoration-style: solid; text-decoration-color: currentColor; }
.avb:focus-visible { border-radius: 4px; }
/* «Дефицит» / «Остаток с учётом в пути»: the tooltip holds the whole calculation */
.grid td.calc { cursor: help; }
.grid tr.size > td { height: 34px; }
.grid tr.flat > td { height: 46px; }
.grid tr.spacer > td { padding: 0; border: 0; background: transparent; height: auto; }
.grid tr.empty-row > td { height: 120px; text-align: center; color: var(--text-2); white-space: normal; }

/* card (group) rows */
.grid tr.card > td { height: 56px; background: var(--card-row); font-weight: 650; border-top: 1px solid var(--line-2); }
.grid tr.card:hover > td { background: color-mix(in srgb, var(--card-row) 70%, var(--line)); }
.grid tr.card td.z { font-weight: 500; }
.card-a { display: flex; align-items: center; gap: 9px; min-width: 0; }
.tw { width: 22px; height: 22px; border-radius: 6px; border: 0; padding: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; flex: none; }
.tw:hover { background: var(--surface-3); color: var(--text); }
.tw .i { transition: transform .15s; }
.collapsed .tw .i { transform: rotate(-90deg); }
.ph {
  width: 32px; height: 42px; border-radius: 7px; flex: none; overflow: hidden;
  background: var(--surface-3); display: grid; place-items: center; color: var(--text-3);
  box-shadow: 0 0 0 1px var(--line);
}
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-t { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.card-t .art { font-weight: 700; color: var(--text); display: block; max-width: 100%; min-width: 0; line-height: 17px; }
.card-t .art > span { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; overflow-wrap: anywhere; }
.card-t .art .i { color: var(--accent); margin-left: 4px; vertical-align: -1px; }
.art .nw { white-space: nowrap; }
.card-t a.art:hover { color: var(--accent-ink); text-decoration: none; }
.card-t a.art:hover span { text-decoration: underline; text-underline-offset: 2px; }
.card-t small { font-size: 13px; color: var(--text-3); font-weight: 400; display: flex; align-items: center; gap: 6px; min-width: 0; height: 17px; line-height: 17px; }
.card-t .sub-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-t small .flag { flex: none; margin-left: 0; }
.flag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 5px; font-size: 13px; font-weight: 600; line-height: 18px; background: var(--surface-3); color: var(--text-2); vertical-align: 1px; }
.flag.warn { background: var(--warn-soft); color: var(--warn); }
.flag.ico { display: inline-grid; place-items: center; width: 22px; height: 20px; padding: 0; vertical-align: -4px; }
.grid tr.card.trash td, .grid tr.trash td { color: var(--text-3); }

/* size rows */
.size-a { display: flex; align-items: center; gap: 8px; padding-left: 28px; position: relative; height: 33px; min-width: 0; }
.size-a::before { content: ""; position: absolute; left: 17px; top: -1px; bottom: -1px; width: 1.5px; background: var(--line-2); }
.size-a::after { content: ""; position: absolute; left: 17px; top: 16px; width: 9px; height: 1.5px; background: var(--line-2); }
tr.last .size-a::before { bottom: 16px; }
.sz {
  min-width: 36px; height: 22px; padding: 0 6px; border-radius: 6px;
  background: var(--surface-3); color: var(--text); font-weight: 700; font-size: 13px;
  display: inline-grid; place-items: center; flex: none; max-width: 110px; overflow: hidden; text-overflow: ellipsis;
}
.bc { border: 0; background: none; padding: 0; color: var(--text-2); font-size: 13.5px; letter-spacing: .01em; cursor: copy; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.bc:hover { color: var(--accent-ink); }
.bc.copied { color: var(--pos); }
.bc-more { border: 0; flex: none; font-size: 13px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); border-radius: 5px; padding: 0 5px; line-height: 18px; cursor: copy; }
.flat-a { display: flex; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; }
.fl1, .fl2 { display: flex; align-items: center; gap: 7px; min-width: 0; height: 20px; }
.fl1 .art { font-weight: 650; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 0 1 auto; }
/* Chrome breaks at <wbr> even under nowrap: on desktop a long «артикул/цвет+цвет» ends in «…» (full text in the
   tooltip) instead of a second line that spills out of the row; phones keep the two-line form (media below) */
@media (min-width: 761px) { .fl1 .art wbr { display: none; } }
.fl1 .flag { flex: none; margin-left: 0; }
.fl2 .sz { height: 20px; flex: none; }
.fl2 .bc { font-size: 13px; }
.fl2 .bc-more { flex: none; }

/* columns popover */
.pop-cols { width: 340px; max-height: min(70vh, 560px); overflow: auto; }
.pop-cols .pop-acts { display: flex; gap: 6px; margin: 6px 0 4px; }
.colgrp { padding: 6px 0; }
.colgrp + .colgrp { border-top: 1px solid var(--line); }
.colgrp-h { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700; color: var(--text-2); margin: 2px 0 6px; }
.colgrp-h .fi { width: 22px; height: 22px; border-radius: 7px; }
.colopt { display: flex; align-items: center; gap: 10px; padding: 5px 4px; border-radius: 8px; font-size: 14px; cursor: pointer; }
.colopt:hover { background: var(--hover); }
.colopt input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.colopt small { color: var(--text-3); font-size: 13px; }

/* ------------------------------------------------------------------ DAY VIEW (fixed blocks: skeleton = data size) */
.day-head { display: flex; align-items: flex-end; gap: 18px; margin: 2px 0 12px; height: 92px; }
.day-title-box { min-width: 0; flex: 1 1 auto; }
.day-head h1 { font-size: 30px; line-height: 40px; font-weight: 700; letter-spacing: -.02em; display: flex; align-items: center; gap: 12px; white-space: nowrap; overflow: hidden; }
.day-head h1 .badge { height: 26px; font-size: 13px; padding: 0 10px; border-radius: 8px; font-family: var(--font); letter-spacing: 0; }
.day-sub { color: var(--text-3); font-size: 14px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 20px; }
.day-sub b { color: var(--text-2); font-weight: 600; }
.day-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; padding-bottom: 4px; }
.datebox {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 14px 0 12px; border-radius: 11px;
  background: var(--surface); border: 1px solid var(--line-2); font-weight: 600; font-size: 14px; box-shadow: var(--shadow-sm); cursor: pointer;
}
.datebox:hover { border-color: var(--line-strong); }
.datebox .i { color: var(--accent); }
.date-lbl { display: inline-block; width: 128px; font-weight: 650; color: var(--text); white-space: nowrap; }
.datebox input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.datebox input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: auto; height: auto; margin: 0; padding: 0; cursor: pointer; }
.datebox input:focus { outline: none; }
.datebox:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.nav-btn { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-sm); padding: 0; }
.nav-btn:hover { color: var(--text); border-color: var(--line-strong); }
.nav-btn:disabled { color: var(--line-strong); box-shadow: none; }
/* one line when it fits; a long warning wraps (up to three lines) so its conclusion stays readable */
.day-note {
  display: flex; align-items: flex-start; gap: 10px; min-height: 40px; padding: 9px 14px; border-radius: 12px; margin-bottom: 14px;
  background: var(--info-soft); border: 1px solid var(--info-line); color: var(--text-2); font-size: 13.5px;
}
.day-note > .i { color: var(--info); margin-top: 3px; }
.day-note.warn { background: var(--warn-soft); border-color: var(--warn-line); }
.day-note.warn > .i { color: var(--warn); }
.day-note .t { min-width: 0; flex: 1; line-height: 20px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.day-note .more { flex: none; }

.tiles { display: grid; grid-template-columns: 1.1fr 1.3fr 1fr 1fr 0.85fr 1.15fr; gap: 12px; margin: 0 0 16px; height: 236px; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; height: 236px; overflow: hidden;
}
.tile > * { flex: none; }
.tile-v { font: 700 30px/36px var(--font-display); letter-spacing: -.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 36px; }
.tile-v small { font-size: 15px; font-weight: 650; color: var(--text-3); margin-left: 6px; letter-spacing: 0; }
.tile-v .star { color: var(--conv-ink); font-size: 18px; margin-left: 2px; }
.tile-s { font-size: 13px; color: var(--text-3); line-height: 18px; height: 36px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tile-s b { color: var(--text-2); font-weight: 650; }
.cmp { margin-top: 8px; display: grid; gap: 5px; }
.cmp-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); white-space: nowrap; height: 22px; }
.cmp-row > span:first-child { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.cmp-row .was { margin-left: auto; color: var(--text-2); }
.dl { white-space: nowrap; display: inline-flex; align-items: center; gap: 3px; height: 22px; padding: 0 6px; border-radius: 6px; font-size: 13px; font-weight: 700; flex: none; }
.dl.good { background: var(--pos-soft); color: var(--pos); }
.dl.bad { background: var(--neg-soft); color: var(--neg); }
.dl.flat { background: var(--surface-3); color: var(--text-2); font-weight: 600; }
.events { display: grid; gap: 6px; margin-top: 8px; }
.ev { display: flex; align-items: baseline; gap: 8px; border-radius: 10px; padding: 0 10px; height: 36px; align-items: center; background: var(--surface-2); border: 1px solid var(--line); min-width: 0; }
.ev b { font: 700 20px/1 var(--font-display); }
.ev span { font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev.s b { color: var(--sales-ink); } .ev.r b { color: var(--neg); } .ev.c b { color: var(--conv-ink); }
.split { display: flex; height: 6px; border-radius: 6px; overflow: hidden; background: var(--surface-3); margin-top: 10px; flex: none; }
.split-legend { display: flex; flex-wrap: wrap; gap: 2px 10px; margin-top: 6px; font-size: 13px; color: var(--text-3); height: 18px; overflow: hidden; }
.split-legend span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.split-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.tile.is-sk .sk-h { width: 50%; height: 16px; margin: 6px 0 14px; }
.tile.is-sk .sk-v { width: 60%; height: 30px; border-radius: 9px; margin-bottom: 14px; }
.tile.is-sk .sk-s { width: 85%; margin-bottom: 10px; }

.day-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); min-width: 0; overflow: hidden; display: flex; flex-direction: column; }
.panel-h { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px 8px; height: 66px; flex: none; }
.panel-h > div:first-child { min-width: 0; }
.panel-h h3 { font-size: 16px; font-weight: 700; white-space: nowrap; }
.panel-h p { font-size: 13px; color: var(--text-3); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-mini { margin-left: auto; display: flex; gap: 14px; font-size: 13px; color: var(--text-2); white-space: nowrap; flex: none; }
.legend-mini span { display: inline-flex; align-items: center; gap: 6px; }
.panel-b { padding: 6px 18px 16px; flex: 1 1 auto; min-height: 0; }
/* the regions list shows its header + exactly 10 rows (no half-cut row); more rows scroll */
.panel-chart { height: 410px; }
.panel-regions { height: 410px; }
.panel-regions .panel-b { padding-bottom: 0; margin-bottom: 16px; }
.panel-regions .panel-b, .panel-side .panel-b { overflow: auto; }
.panel-city { height: 326px; }
.panel-side .panel-b { padding-bottom: 0; margin-bottom: 14px; }
.panel-wh { height: 316px; }
.side { display: grid; gap: 16px; align-content: start; }

/* hourly chart */
.hchart { display: grid; grid-template-columns: 30px minmax(0, 1fr); height: 314px; gap: 8px; padding-top: 4px; }
.hc-y { position: relative; font-size: 13px; color: var(--text-3); margin-bottom: 24px; }
.hc-y span { position: absolute; right: 0; transform: translateY(50%); line-height: 1; }
.hc-plot { position: relative; border-bottom: 1px solid var(--line-strong); margin-bottom: 24px; margin-top: 24px; }
.hc-grid { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.hc-cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 5px; align-items: end; }
.hc-col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.hc-bar { width: 100%; max-width: 30px; border-radius: 7px 7px 3px 3px; display: flex; flex-direction: column-reverse; overflow: hidden; background: linear-gradient(180deg, var(--accent-2), var(--accent)); min-height: 2px; }
.hc-bar .c { background: var(--ret); display: block; flex: none; width: 100%; }
.hc-col.peak .hc-bar { background: linear-gradient(180deg, #ffa35c, var(--conv)); }
.hc-col.future .hc-bar { background: transparent; border: 1.5px dashed var(--line-strong); }
.hc-col.now .hc-bar { opacity: .6; }
.hc-col.zero .hc-bar { background: var(--line-2); }
.hc-val { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 3px; line-height: 16px; }
.hc-col.peak .hc-val { color: var(--conv-ink); }
.hc-col.hv .hc-val { visibility: hidden; }
.hc-x { position: absolute; bottom: -22px; font-size: 13px; color: var(--text-3); line-height: 16px; }
.peak-flag { white-space: nowrap; font-size: 13px; font-weight: 700; color: #fff; background: #b65a00; padding: 0 7px; border-radius: 6px; margin-bottom: 4px; line-height: 20px; box-shadow: 0 4px 10px -4px var(--conv); }

/* rank bars */
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
/* a long name («Склад не определён (нет в статистике)») takes a second line instead of ending in «…» */
.rank li { display: grid; grid-template-columns: minmax(0, 1fr) 46px 46px; align-items: center; gap: 10px; min-height: 28px; padding: 3px 0; font-size: 14px; }
.rank .nm { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(40px, 24%); align-items: center; gap: 10px; }
.rank .nm span { display: block; overflow-wrap: anywhere; line-height: 1.3; }
.rank .bar { display: block; height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.rank .bar i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.rank.rank-wh .bar i { background: linear-gradient(90deg, #3ad0bd, var(--stock)); }
.rank.rank-city .bar i { background: linear-gradient(90deg, #ffb27a, var(--conv)); }
.rank .v { font-weight: 700; text-align: right; }
.rank .p { font-size: 13px; color: var(--text-3); text-align: right; }
.rank.rank-out li { grid-template-columns: minmax(0, 1fr) 44px 38px 36px 36px; gap: 8px; }
.rank.rank-out .nm { grid-template-columns: minmax(0, 1fr) minmax(32px, 18%); }
.rank .o { font-size: 14px; color: var(--text-2); text-align: right; }
.rank .o.z { color: var(--zero); }
.rank li.rank-h { height: 20px; min-height: 0; padding: 0; font-size: 13px; font-weight: 500; color: var(--text-3); position: sticky; top: -6px; background: var(--surface); z-index: 1; }
.rank li.rank-h > span { text-align: right; font-weight: 500; font-size: 13px; color: var(--text-3); }
.note { font-size: 13px; color: var(--text-3); margin-top: 10px; display: flex; gap: 7px; line-height: 1.4; }
.note .i { color: var(--info); flex: none; margin-top: 1px; }
.empty-p { color: var(--text-3); font-size: 14px; padding: 8px 0; }

/* day products table */
.panel-prod .panel-h .search { margin-left: auto; width: 270px; flex: 0 1 270px; }
.dtable-wrap { overflow-x: auto; }
.dtable { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 0; font-size: 14px; table-layout: fixed; }
.dtable col.c-prod { width: auto; }
.dtable col.c-n { width: 96px; }
.dtable col.c-m { width: 104px; }
.dtable th { position: sticky; top: 0; background: var(--surface-2); text-align: right; font-size: 13px; font-weight: 650; color: var(--text-2); padding: 0 10px 0 14px; height: 38px; border-bottom: 1px solid var(--line); border-top: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; overflow: hidden; text-overflow: ellipsis; }
.dtable th:first-child { text-align: left; padding-left: 18px; }
.dtable .th-in { position: relative; }
.dtable th .sort-ar { position: absolute; right: calc(100% + 3px); top: 50%; margin-top: -6px; bottom: auto; }
.dtable th.sorted { color: var(--accent-ink); }
.dtable th .l-s { display: none; }   /* short header words for phones */
.dtable th.sorted .sort-ar { visibility: visible; }
.dtable th.sorted.asc .sort-ar svg { transform: rotate(180deg); }
.dtable td { padding: 0 10px; height: 48px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dtable td:first-child { text-align: left; padding-left: 18px; }
.dtable td.z { color: var(--zero); }
.dtable tbody tr:hover td { background: var(--hover); }
.dtable tfoot td { height: 42px; font-weight: 700; background: var(--tot-row); border-bottom: 0; }
.dtable td.empty { text-align: center; color: var(--text-3); height: 96px; }
.panel-foot { display: flex; justify-content: center; padding: 10px; border-top: 1px solid var(--line); height: 56px; align-items: center; flex: none; }
/* «Что заказали» by card: a card row (48 px, as the skeleton) with the sums of its sizes; its sizes below it */
.panel-prod .panel-h > div:first-child { flex: 1 1 auto; }
.panel-prod .panel-h .search { flex: none; }
.panel-prod .panel-h .day-expand { flex: none; width: 156px; justify-content: flex-start; }
.dtable td .l-s { display: none; }
.dtable tr.dcard > td { background: var(--card-row); font-weight: 650; cursor: pointer; }
.dtable tr.dcard.open > td { border-bottom-color: var(--line-2); }
.dtable tbody tr.dcard:hover > td { background: color-mix(in srgb, var(--card-row) 70%, var(--line)); }
.dtable tr.dcard > td.z { font-weight: 500; }
.dcard-a { display: flex; align-items: center; gap: 8px; min-width: 0; margin-left: -6px; }
.dcard-a .ph { width: 28px; height: 37px; border-radius: 6px; }
.dtable tr.dcard:not(.open) .tw .i { transform: rotate(-90deg); }
.dcard-t { min-width: 0; line-height: 1.2; }
.dcard-t .art { font-weight: 700; color: var(--text); display: flex; align-items: center; min-width: 0; max-width: 100%; white-space: nowrap; line-height: 17px; }
.dcard-t .art .nm { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.dcard-t .art .i { color: var(--accent); margin-left: 4px; flex: none; }
.dcard-t a.art:hover { color: var(--accent-ink); text-decoration: none; }
.dcard-t a.art:hover .nm { text-decoration: underline; text-underline-offset: 2px; }
.dcard-t .meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; min-width: 0; height: 17px; }
.dsizes { font-size: 13px; font-weight: 400; color: var(--text-3); line-height: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dcard-t .meta .flag { flex: none; margin-left: 0; }
.dtable tr.dsize > td { height: 40px; font-weight: 400; }
.dsize-a { display: flex; align-items: center; gap: 8px; padding-left: 38px; position: relative; height: 39px; min-width: 0; }
.dsize-a::before { content: ""; position: absolute; left: 11px; top: -1px; bottom: -1px; width: 1.5px; background: var(--line-2); }
.dsize-a::after { content: ""; position: absolute; left: 11px; top: 19px; width: 20px; height: 1.5px; background: var(--line-2); }
.dtable tr.dsize.last .dsize-a::before { bottom: 19px; }
.dsize-a .bcx { font-size: 13.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; user-select: all; }
.dsize-a .bcx b { font-size: 13px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); border-radius: 5px; padding: 0 5px; }
.dsize-a .flag { flex: none; margin-left: 0; }
.day-empty { padding: 60px 20px; text-align: center; display: grid; gap: 8px; justify-items: center; }
.day-empty h3 { font-size: 18px; }
.day-empty p { color: var(--text-2); }

/* token dialog */
.dlg { border: 0; padding: 0; border-radius: 20px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(520px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(20, 16, 12, .45); backdrop-filter: blur(3px); }
.dlg-in { padding: 20px 22px; display: grid; gap: 14px; }
.dlg-h { display: flex; align-items: center; gap: 10px; }
.dlg-h h2 { font-size: 18px; }
.dlg-h .icon-btn { margin-left: auto; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 14px; align-items: center; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 600; min-width: 0; }
.kv code { font-family: ui-monospace, Consolas, monospace; font-size: 14px; background: var(--surface-3); padding: 2px 6px; border-radius: 6px; }
.kv .scopes { display: flex; flex-wrap: wrap; gap: 4px; }
.dlg textarea { width: 100%; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 10px 12px; resize: vertical; font-size: 14px; font-family: ui-monospace, Consolas, monospace; color: var(--text); }
.dlg textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.dlg-note { font-size: 13px; color: var(--text-3); line-height: 1.45; }
.dlg-error { padding: 10px 12px; border-radius: 10px; background: var(--neg-soft); color: var(--neg); font-size: 14px; }
.dlg-f { display: flex; justify-content: flex-end; gap: 8px; }

/* ------------------------------------------------------------------ settings: currency, the cost module */
.setup-extra .cur-pick { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text-2); }
.setup-extra .cur-pick .seg button { min-width: 38px; justify-content: center; font-size: 14px; }
.setup-extra .cost-sw { display: inline-flex; align-items: center; gap: 8px; }

/* ------------------------------------------------------------------ sync popover: the availability archive */
.arch { border-top: 1px solid var(--line); padding: 10px 4px 2px; display: grid; gap: 4px; font-size: 13px; color: var(--text-3); }
.arch-h { display: flex; align-items: center; gap: 7px; color: var(--text-3); white-space: nowrap; }
.arch-h .i { color: var(--fc); }
.arch-h b { color: var(--text); font-weight: 650; font-size: 13.5px; }
.arch-r { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; padding-left: 21px; }
.arch-r b { color: var(--text-2); font-weight: 600; }
.arch-r .badge { height: 20px; }
.arch-hint { display: flex; gap: 7px; margin-top: 4px; padding: 7px 9px; border-radius: 9px; background: var(--info-soft); color: var(--text-2); line-height: 1.4; }
.arch-hint .i { color: var(--info); flex: none; margin-top: 2px; }
.arch-hint code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--surface); padding: 0 4px; border-radius: 5px; white-space: nowrap; }

/* ------------------------------------------------------------------ «Наличие по дням» (floating panel; a bottom sheet on phones) */
.pop-av {
  position: fixed; top: 8px; left: 8px; right: auto; z-index: 70;
  width: max-content; max-width: min(980px, calc(100vw - 16px)); max-height: calc(100vh - 16px);
  padding: 0; display: flex; flex-direction: column; overflow: hidden;
}
.pop-av:focus-visible { box-shadow: var(--shadow-lg), var(--ring); border-radius: var(--r-lg); }
.av-h { display: flex; align-items: center; gap: 10px; padding: 10px 8px 10px 14px; flex: none; border-bottom: 1px solid var(--line); }
.av-h .fi .i { width: 15px; height: 15px; }
.av-ht { min-width: 0; flex: 1 1 auto; }
.av-ht h3 { font-size: 15px; line-height: 20px; white-space: nowrap; }
.av-ht p { font-size: 13px; line-height: 18px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.av-stat { flex: none; font-size: 13px; color: var(--text-2); white-space: nowrap; height: 26px; line-height: 26px; padding: 0 9px; border-radius: 8px; background: var(--fc-soft); }
.av-stat b { color: var(--fc-ink); font-weight: 700; }
.av-scroll { overflow: auto; flex: 0 1 auto; min-height: 0; overscroll-behavior: contain; }
.av-scroll:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0; }
.av-grid { border-collapse: separate; border-spacing: 0; table-layout: fixed; font-size: 13px; line-height: 16px; margin: 0 0 4px; }
.av-col-rh { width: 118px; }
.av-col-d { width: 40px; }
.av-col-n { width: 54px; }
.av-grid th, .av-grid td { height: 30px; padding: 0 2px; text-align: center; white-space: nowrap; overflow: hidden; }
.av-grid thead { position: sticky; top: 0; z-index: 3; }
.av-grid thead th { background: var(--surface); }
.av-mon th { height: 22px; text-align: left; padding: 6px 0 0 6px; font-weight: 600; color: var(--text-3); border-left: 1px solid var(--line); overflow: visible; }
.av-mon th span { position: sticky; left: 124px; }   /* the month of the first visible day stays named while scrolling */
.av-mon th:first-child, .av-mon th:last-child { border-left: 0; }
.av-days th { height: 40px; vertical-align: bottom; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.av-days th b { display: block; font-weight: 650; color: var(--text); }
.av-days th small { display: block; font-size: 13px; font-weight: 400; color: var(--text-3); }
.av-days th.we small { color: var(--accent-ink); }
.av-days th.today b { color: var(--accent-ink); }
.av-grid .av-rh { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; padding: 0 6px 0 12px; font-weight: 600; color: var(--text-2); text-overflow: ellipsis; }
.av-grid thead .av-rh { z-index: 4; vertical-align: bottom; padding-bottom: 5px; font-size: 13px; color: var(--text-3); }
.av-grid .av-cnt { position: sticky; right: 0; z-index: 1; background: var(--surface); font-weight: 700; color: var(--text); border-left: 1px solid var(--line); }
.av-grid thead .av-cnt { z-index: 4; vertical-align: bottom; padding-bottom: 5px; font-weight: 600; color: var(--text-3); }
.av-grid .sz { height: 22px; }
/* a day: green when in stock (the units of the evening check), grey «0» when not, «—» unknown; dashed = provisional */
.av-c { position: relative; font-weight: 650; color: var(--text-2); }
.av-c.in { background: var(--pos-soft); color: var(--pos); font-weight: 700; box-shadow: inset 0 0 0 2px var(--surface); border-radius: 8px; }
.av-c.out { background: var(--surface-3); color: var(--text-2); box-shadow: inset 0 0 0 2px var(--surface); border-radius: 8px; }
.av-c.unk { color: var(--zero); font-weight: 500; }
.av-c.prov::after, .av-k.prov::after { content: ""; position: absolute; inset: 3px; border: 1.5px dashed color-mix(in srgb, currentColor 60%, transparent); border-radius: 6px; pointer-events: none; }
.av-c .i { width: 13px; height: 13px; }
.av-c > .sk { width: 26px; height: 18px; margin: 0 auto; border-radius: 6px; }
.av-sum > * { border-bottom: 1px solid var(--line-2); }
.av-sum .av-rh { color: var(--text); font-weight: 700; }
.av-main .av-rh { color: var(--text); font-weight: 700; }
.av-det .av-rh { font-weight: 500; color: var(--text-3); }
.av-c.av-v { font-weight: 500; color: var(--text-2); }
.av-c.av-v.z { color: var(--zero); }
.av-det:first-of-type > * { border-top: 1px solid var(--line); }
.av-main + .av-det > * { border-top: 1px solid var(--line); }
.av-err { text-align: left !important; padding: 12px 14px !important; height: auto !important; color: var(--neg); white-space: normal !important; }
.av-err .i { margin-right: 6px; }
.av-legend { flex: none; display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 9px 14px 0; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.av-legend > span { display: inline-flex; align-items: center; white-space: nowrap; }
.av-k { position: relative; display: inline-grid; place-items: center; min-width: 26px; height: 22px; padding: 0 5px; margin-right: 6px; border-radius: 6px; font-style: normal; font-weight: 700; font-size: 13px; }
.av-k.in { background: var(--pos-soft); color: var(--pos); }
.av-k.out { background: var(--surface-3); color: var(--text-2); }
.av-k.unk { color: var(--zero); box-shadow: inset 0 0 0 1px var(--line-2); font-weight: 500; }
.av-k.prov::after { inset: 2px; border-radius: 5px; }
.av-note { flex: none; padding: 6px 14px 12px; font-size: 13px; color: var(--text-3); line-height: 1.45; max-width: 640px; }

/* ------------------------------------------------------------------ «Себестоимость» dialog (fixed size: nothing jumps while it fills) */
.dlg-costs { width: min(960px, calc(100vw - 32px)); height: min(800px, calc(100vh - 32px)); max-height: none; overflow: hidden; }
.costs-in { height: 100%; display: flex; flex-direction: column; gap: 12px; padding: 16px 20px 16px; }
.dlg-costs .dlg-h { flex: none; gap: 12px; }
.dlg-costs .dlg-h .icon-btn { margin-left: 0; }
.dlg-costs .dlg-h .fi { width: 34px; height: 34px; border-radius: 11px; }
.costs-ht { min-width: 0; flex: 1 1 auto; }
.costs-ht h2 { font-size: 18px; line-height: 24px; }
.costs-ht p { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.costs-on { flex: none; font-weight: 600; color: var(--text); }
.costs-sub { flex: none; display: flex; gap: 8px; font-size: 13px; color: var(--text-3); line-height: 1.4; }
.costs-sub .i { color: var(--info); flex: none; margin-top: 2px; }
.costs-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.drop {
  flex: none; display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px;
  border: 1.5px dashed var(--line-strong); background: var(--surface-2); transition: background .15s, border-color .15s;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--cost-tint); color: var(--cost); flex: none; }
.drop-t { flex: 1 1 auto; min-width: 0; display: grid; gap: 2px; }
.drop-t b { font-size: 14px; font-weight: 650; }
.drop-t span { font-size: 13px; color: var(--text-3); }
.drop-a { display: flex; gap: 8px; flex: none; }
.costs-tools { flex: none; display: flex; align-items: center; gap: 10px; }
.costs-tools .search { flex: 1 1 240px; width: auto; min-width: 0; }
.costs-tools .seg small { margin-left: 2px; }
.dlg-costs { --cr-cols: 28px minmax(0, 1fr) 112px 140px 78px 150px; }
.costs-head { flex: none; display: grid; grid-template-columns: var(--cr-cols); gap: 10px; padding: 0 11px; font-size: 13px; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.costs-head span:nth-child(3) { text-align: right; }
.costs-head.is-off { visibility: hidden; }   /* no prices yet: the explanation below has no columns (the row keeps its height) */
.costs-list { flex: 1 1 auto; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 12px; overscroll-behavior: contain; }
.ci { border-bottom: 1px solid var(--line); }
.cr { display: grid; grid-template-columns: var(--cr-cols); align-items: center; gap: 10px; min-height: 48px; padding: 4px 10px; }
.cr:hover { background: var(--hover); }
.ci.open { background: var(--surface-2); }
.ci.open > .cr:hover { background: var(--surface-2); }
.cr-tw { width: 26px; height: 26px; }
.ci:not(.open) .cr-tw .i { transform: rotate(-90deg); }
.cr-a { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.cr-a b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-a small { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cr-a .flag { margin-left: 6px; }
.cr-v { text-align: right; font-weight: 700; white-space: nowrap; }
.cr-d { font-size: 13px; color: var(--text-2); white-space: nowrap; }
.cr-h { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.cr-x { display: flex; justify-content: flex-end; }
.cr-x .btn { height: 30px; padding: 0 10px; font-size: 13px; }
.cr-miss { font-weight: 600; color: var(--warn); font-size: 13px; }
.cr-unk { font-weight: 500; color: var(--text-3); font-size: 13px; }
.cr-more { padding: 0 12px 12px 48px; }
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.hist li { display: grid; grid-template-columns: 140px 120px minmax(0, 1fr) auto 32px 32px; align-items: center; gap: 10px; min-height: 36px; font-size: 13.5px; border-bottom: 1px dashed var(--line); }
.hist li:last-child { border-bottom: 0; }
.hist .h-d { color: var(--text-2); white-space: nowrap; }
.hist .h-v { text-align: right; white-space: nowrap; }
.hist li.zero .h-v { color: var(--warn); font-weight: 600; }
.hist li.cur .h-v { color: var(--cost-ink); }
.hist .h-s { font-size: 13px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hist .badge { height: 20px; }
.hist .icon-btn { width: 32px; height: 32px; border-radius: 9px; }
/* values replaced or deleted (the journal): struck-through price, when and how */
.hist-old { list-style: none; margin: 6px 0 0; padding: 6px 0 0; border-top: 1px dashed var(--line); display: grid; gap: 2px; font-size: 13px; line-height: 1.45; color: var(--text-3); }
.hist-old s { color: var(--text-2); text-decoration-thickness: 1px; }
.icon-btn.danger, .icon-btn.danger:hover { background: var(--neg-soft); color: var(--neg); }
.cform { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; margin-top: 8px; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-2); }
.cform label { display: grid; gap: 4px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.cform .input { height: 34px; width: 160px; }
.cform .input:disabled { color: var(--text-2); background: var(--surface-2); }
.cform .btn { height: 34px; }
.cform-n { flex-basis: 100%; font-size: 13px; color: var(--text-3); }
.costs-foot { flex: none; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); min-width: 0; }
.costs-foot .i { flex: none; }
.costs-foot span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.costs-empty { display: grid; justify-items: center; gap: 10px; padding: 48px 16px; color: var(--text-3); text-align: center; font-size: 14px; }
.costs-empty .spinner { color: var(--accent); }
.costs-more { padding: 10px; text-align: center; font-size: 13px; color: var(--text-3); }
.costs-howto { padding: 16px 18px; display: grid; gap: 10px; font-size: 14px; color: var(--text-2); line-height: 1.45; align-content: start; }
.costs-howto h3 { font-size: 16px; color: var(--text); }
.costs-howto ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.costs-howto b { color: var(--text); font-weight: 650; }
.howto { border-collapse: separate; border-spacing: 0; font-size: 13.5px; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; max-width: 620px; }
.howto th { background: var(--cost-soft); color: var(--cost-ink); font-weight: 650; text-align: left; padding: 7px 12px; border-bottom: 1px solid var(--line-2); }
.howto td { padding: 6px 12px; border-bottom: 1px solid var(--line); color: var(--text); }
.howto tr:last-child td { border-bottom: 0; }
/* the preview of an upload: what «Применить» will do */
.pv-head { flex: none; display: flex; align-items: center; gap: 10px; min-width: 0; }
.pv-head > div { min-width: 0; display: grid; }
.pv-head b { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-head span { font-size: 13px; color: var(--text-3); }
.pv-stats { flex: none; display: flex; flex-wrap: wrap; gap: 8px; }
.pv-chip { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px; border-radius: 10px; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.pv-chip b { font: 700 17px/1 var(--font-display); }
.pv-chip.new { background: var(--pos-soft); color: var(--pos); }
.pv-chip.chg { background: var(--warn-soft); color: var(--warn); }
.pv-chip.same { background: var(--surface-3); color: var(--text-2); }
.pv-chip.unk { background: var(--info-soft); color: var(--info); }
.pv-chip.err { background: var(--neg-soft); color: var(--neg); }
.pv-chip.none { background: var(--surface-2); color: var(--text-3); box-shadow: inset 0 0 0 1px var(--line); }
.pv-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: 12px; overscroll-behavior: contain; }
.pv-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; table-layout: fixed; }
.pv-table th:nth-child(1) { width: 76px; }
.pv-table th:nth-child(3) { width: 132px; }
.pv-table th:nth-child(4) { width: 150px; }
.pv-table th:nth-child(5) { width: 150px; }
.pv-table th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: left; font-size: 13px; color: var(--text-2); font-weight: 650; height: 34px; padding: 0 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.pv-table td { height: 34px; padding: 0 10px; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-table .n { text-align: right; }
.pv-table td .clip { display: block; overflow: hidden; text-overflow: ellipsis; }
.pv-st { display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.pv-st.new { background: var(--pos-soft); color: var(--pos); }
.pv-st.chg { background: var(--warn-soft); color: var(--warn); }
.pv-st.same { background: var(--surface-3); color: var(--text-2); }
.pv-st.unk { background: var(--info-soft); color: var(--info); }
.pv-st.err { background: var(--neg-soft); color: var(--neg); }
.pv-more { padding: 8px 10px; font-size: 13px; color: var(--text-3); }
.pv-det { margin: 4px 10px 10px; }
.pv-det summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; padding: 6px 0; }
.pv-det summary .i { color: var(--info); }
.pv-det.err summary, .pv-det.err summary .i { color: var(--neg); }
.pv-det.warn summary .i { color: var(--warn); }
.pv-det ul { margin: 2px 0 0; padding-left: 22px; font-size: 13.5px; color: var(--text-2); display: grid; gap: 3px; }
.pv-det ul b { color: var(--text); font-weight: 600; }
.pv-det p { font-size: 13.5px; color: var(--text-2); line-height: 1.5; padding-left: 22px; overflow-wrap: anywhere; }
.pv-foot { flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.pv-foot .muted { margin-right: auto; font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
.grid th:focus-visible { box-shadow: inset 0 0 0 2px var(--accent); border-radius: 0; outline: none; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1500px) {
  :root { --pad-x: 16px; }
  .rank .nm { grid-template-columns: minmax(0, 1fr) minmax(28px, 15%); }
  .rank.rank-out .nm { grid-template-columns: minmax(0, 1fr) minmax(24px, 12%); }
  .fact-wh { width: 210px; }
  .fact-win { width: 176px; }
  .tc-count { width: 214px; }
  .search { width: 260px; flex-basis: 260px; }
  .dsz-n { display: none; }   /* «Что заказали»: the sizes themselves get the room (the count is in the tooltip) */
}
@media (max-width: 1400px) {
  :root { --pad-x: 12px; }
  .topbar-in { gap: 10px; }
  .tab { padding: 0 13px; }
  .pill-fresh { width: 190px; }
  .btn-sync { width: 166px; }
  .setup-bar { gap: 14px; }
  .fact { padding: 2px 12px; }
  .fact-wh { width: 196px; }
  .fact-win { width: 160px; }
  .setup-extra { column-gap: 14px; }
  .step { padding: 14px 14px 16px; }
  .kpi { padding: 12px 14px; }
  .kpi-v { font-size: 27px; }
  .tc-head { gap: 8px; padding: 0 10px 0 14px; }
  .tc-count { width: 200px; }
  .search { width: 250px; flex-basis: 250px; }
  #btn-collapse { width: 186px; }
  .legend .lg-d { display: none; }
  .tiles { gap: 10px; }
  .tile { padding: 12px 14px; }
  .tile-v { font-size: 27px; }
}
@media (max-width: 1360px) {
  .sb-facts .fact:nth-child(3) { display: none; }
  .steps { grid-template-columns: 1fr 1fr; }
  .step-run { margin: 8px 0 0; }
  .tc-head .btn-txt { display: none; }
  #btn-collapse { width: 162px; }
  .tc-head .btn-ghost { padding: 0 9px; }
}
/* below 1280 the tabs stop being centred: they follow the brand, the actions stay on the right — one row down to phones */
@media (max-width: 1280px) {
  .topbar-in { grid-template-columns: minmax(0, max-content) max-content minmax(max-content, 1fr); }
  .tab small { display: none; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); height: auto; }
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); height: auto; }
  .pill-share .pill-txt { display: none; }
}
@media (max-width: 1100px) {
  .sb-facts { display: none; }
  .day-grid { grid-template-columns: minmax(0, 1fr); }
  .tc-head { height: auto; flex-wrap: wrap; padding: 10px 12px; }
  .tc-count { display: none; }   /* the same counts are in the «Итого» row */
}
@media (max-width: 1010px) {
  .btn-sync { width: 40px; padding: 0; justify-content: center; }
  .btn-sync .btn-txt { display: none; }
}
@media (max-width: 860px) {
  .pill-fresh { width: 46px; padding: 0; justify-content: center; }
  .pill-fresh .pill-txt { display: none; }
}
@media (max-width: 900px) {
  #btn-collapse { width: 34px; padding: 0; justify-content: center; }
  #collapse-label { display: none; }   /* the chevron alone; the tooltip and aria-label say what it does */
}
@media (max-width: 760px) {
  body { font-size: 14px; }
  .topbar-in { grid-template-columns: minmax(0, 1fr) auto; height: auto; row-gap: 8px; }
  .tabs { order: 3; grid-column: 1 / -1; justify-self: start; }
  .topbar-in { padding: 8px 12px 0; gap: 8px; }
  /* no backdrop-filter here: it would make the top bar the containing block of the fixed sync sheet */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg); }
  .brand-seller { display: none; }
  .brand-name { font-size: 15px; }
  .logo { width: 34px; height: 34px; border-radius: 11px; }
  .top-actions { gap: 2px; }
  .sync-anchor { gap: 2px; }
  .pill-fresh { width: 36px; height: 34px; }
  .btn-sync { width: 36px; height: 36px; }
  .icon-btn { width: 34px; height: 34px; }
  .tabs { width: 100%; display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 8px; }
  .tab { justify-content: center; padding: 0 8px; font-size: 14px; height: 36px; }
  .tab small { display: none; }
  .page { padding: 12px 12px 32px; }
  .setup-bar { gap: 10px; padding: 0 10px 0 12px; border-radius: 18px; height: 70px; }
  .sb-run { display: none; }
  .sb-actions .btn { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .sb-actions .btn-txt { display: none; }
  .sb-title { font-size: 17px; }
  .cal-ico { width: 46px; height: 48px; }
  .cal-ico span:last-child { font-size: 17px; line-height: 28px; }
  .kpis { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 12px; margin: 0 -12px 12px; padding: 0 12px 4px; scrollbar-width: none; height: auto; }
  .kpis > * { flex: 0 0 62%; scroll-snap-align: start; height: 176px; }
  .kpis > .kpi-hero { order: -1; }
  .kpis > .stockcard { flex-basis: 86%; }
  .kpi { padding: 12px; border-radius: 14px; }
  .kpi-v { font-size: 24px; }
  .kpi-v small { font-size: 14px; }
  .kpi .ring { display: none; }
  .kpi-f .meter { display: none; }
  .stockcard { padding: 10px 12px; }
  .srow .v { font-size: 17px; }
  .srow { height: 42px; }
  .tcard { border-radius: 18px; }
  .lg-d, .lg-m, .fam-in small { display: none; }
  .ca-head .tree-demo { display: none; }
  .banner { font-size: 13px; }
  .tc-title { flex-direction: column; gap: 0; align-items: flex-start; }
  .tc-count { display: block; width: auto; min-height: 20px; }   /* the count line is reserved before its text comes */
  .tc-title h2 { font-size: 16px; }
  .search { width: 100%; flex: 1 1 100%; order: 5; }
  .tc-head .seg, #btn-collapse { display: none; }
  .tbl-scroll { height: calc(100vh - 120px); }
  .banner-text .bt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .banners.is-open .banner-text .bt { display: block; -webkit-line-clamp: unset; overflow: visible; }   /* «ещё N» opened: the whole text */
  .sb-title .t-long { display: none; }
  .sb-title .t-short { display: inline; }
  /* «неполный день» as a clock (tap: the tooltip): the dates of the period keep their room */
  .sb-part { padding: 0 6px; }
  .sb-part .i { display: inline-block; }
  .sb-part .bt { display: none; }
  .size-a { padding-left: 20px; gap: 6px; }
  .size-a::before, .size-a::after { left: 10px; }
  .size-a::after { width: 7px; }
  .sz { min-width: 30px; padding: 0 5px; }
  .bc { font-size: 13px; }
  .card-a { gap: 6px; }
  .ph { width: 28px; height: 36px; }
  .tw { width: 18px; }
  .cmp-row .was { display: none; }
  .cmp-row .dl { margin-left: auto; }
  .tile { padding: 12px; }
  .tile-v { font-size: 24px; }
  .infostrip { padding: 0 8px 0 10px; gap: 8px; }
  .steps { grid-template-columns: 1fr; padding: 6px; }
  .step + .step::before { left: 18px; right: 18px; top: 0; bottom: auto; width: auto; height: 1px; }
  .step-run { margin: 8px 6px 6px; }
  .setup-extra { padding: 12px 14px 16px; margin: 0 6px; }
  .dd-panel { position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; max-width: none; height: min(82vh, 660px); display: flex; flex-direction: column; }
  .dd-panel .dd-top, .dd-panel .dd-cols, .dd-panel .dd-foot { flex: none; }
  .dd-panel .dd-list { flex: 1 1 auto; height: auto; min-height: 0; }
  .dd-cols { padding: 8px 14px 4px 46px; }
  .tiles { grid-template-columns: 1fr 1fr; }
  .day-head { flex-direction: column; align-items: flex-start; height: auto; }
  .day-title-box { width: 100%; }
  .day-head h1 { font-size: 24px; line-height: 1.3; flex-wrap: wrap; row-gap: 4px; white-space: normal; }
  .day-sub { white-space: normal; height: auto; }
  /* three lines reserved (3 × 20 px + padding): the note never grows when the day's warnings arrive; a longer text is
     cut there and stays whole in its tooltip */
  .day-note { padding: 9px 12px; min-height: 80px; }
  .panel-h { height: auto; flex-wrap: wrap; row-gap: 8px; }
  .panel-h h3, .panel-h p { white-space: normal; }
  .panel-h .legend-mini { order: 3; flex-basis: 100%; margin-left: 0; flex-wrap: wrap; gap: 4px 14px; }
  .panel-chart, .panel-regions, .panel-city, .panel-wh { height: auto; }
  .panel-regions .panel-b, .panel-side .panel-b { overflow: visible; }
  /* the title on its own line; the search and the icon-only «Развернуть все» share the next one */
  .panel-prod .panel-h > div:first-child { flex: 1 1 100%; }
  .panel-prod .panel-h .search { flex: 1 1 0; width: auto; min-width: 0; margin-left: 0; }
  .panel-prod .panel-h .day-expand { order: 6; width: 36px; height: 36px; padding: 0; justify-content: center; }
  .panel-prod .panel-h .day-expand span { display: none; }   /* the icon alone: aria-label and the tooltip say it */
  .dtable { min-width: 600px; }
  .dtable col.c-prod { width: 230px; }
  /* the product column stays put while the numbers scroll sideways inside the panel */
  .dtable th:first-child, .dtable td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: inset -1px 0 0 var(--line); }
  .dtable thead th:first-child { z-index: 3; background: var(--surface-2); }
  .dtable tfoot td:first-child { background: var(--tot-row); }
  .dtable tbody tr:hover td:first-child { background: var(--hover); }
  .dtable tr.dcard > td:first-child { background: var(--card-row); }
  .dtable tbody tr.dcard:hover > td:first-child { background: color-mix(in srgb, var(--card-row) 70%, var(--line)); }
  .dtable col.c-n { width: 66px; }
  .dtable col.c-m { width: 88px; }
  .rank.rank-out li { grid-template-columns: minmax(0, 1fr) 34px 36px 30px 30px; gap: 6px; }
  .rank.rank-out .nm { grid-template-columns: minmax(0, 1fr); }
  .rank.rank-out .bar { display: none; }
  .dtable th { padding: 0 8px 0 14px; }
  .dtable td { padding: 0 8px; }
  .dtable th:first-child, .dtable td:first-child { padding-left: 14px; }
  .day-nav { margin-left: 0; flex-wrap: wrap; }
  .pop-sync { width: calc(100vw - 24px); position: fixed; left: 12px; right: 12px; top: auto; bottom: 12px; }
  .pop-sync, .pop-cols, .pop-warn, .dd-panel { box-shadow: var(--shadow-lg), 0 0 0 100vmax rgba(20, 16, 12, .32); }
  .pop-cols, .pop-warn { position: fixed; left: 12px; right: 12px; width: auto; top: auto; bottom: 12px; }
  .lanes.cols { grid-template-columns: 1fr; }
}

/* =====================================================================
   Height tiers (desktops and laptops, wider than a phone).
   The product table should start on the first screen: the shorter the window, the tighter the blocks above
   it. Chosen by media queries only, so the layout is final at the first paint — nothing moves after load.
     M  ≤ 1100 px high (1920×1080, 1680×1050): one-row toolbar, shorter KPI cards, slimmer settings bar
     S  ≤ 960 px (1440×900, 1536×864, and a browser window on a 1920×1080 screen: ~920–955 px of page)
                                              + slimmer top bar, one-line notes, tighter table header
     XS ≤ 760 px (1366×768, 1280×720):        + each KPI card keeps its two main lines, tightest header
   ===================================================================== */
@media (min-width: 761px) and (max-height: 1100px) {
  :root { --kpi-h: 132px; --strip-h: 44px; }
  .page { padding-top: 12px; }
  .banners { margin-bottom: 10px; gap: 6px; }
  /* collapsed notes take exactly one line (the full text is in the tooltip when it is cut) */
  .banners:not(.is-open) .banner-text { display: flex; align-items: baseline; min-width: 0; }
  .banners:not(.is-open) .banner-text .bt { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .banners:not(.is-open) .banner-text a { flex: none; }
  .setup { margin-bottom: 12px; }
  .setup-bar { height: 64px; padding: 0 12px; border-radius: 20px; }
  .cal-ico { width: 46px; height: 46px; border-radius: 11px; }
  .cal-ico span:first-child { line-height: 17px; }
  .cal-ico span:last-child { font-size: 18px; line-height: 27px; }
  .sb-title { font-size: 19px; line-height: 25px; }

  /* KPI cards: title, number, one sub-line (its tail drops out whole when it does not fit), footer */
  .kpis { margin-bottom: 12px; }
  .kpi { padding: 10px 14px 9px; gap: 0; }
  .kpi-h { height: 26px; margin-bottom: 2px; }
  .kpi-h .fi { width: 26px; height: 26px; border-radius: 8px; }
  .kpi-v { font-size: 28px; line-height: 34px; height: 34px; }
  .kpi-v small { font-size: 16px; }
  .kpi-s { display: flex; flex-wrap: wrap; align-items: baseline; height: 20px; line-height: 20px; }
  .kpi-f { height: 24px; padding-top: 0; }
  .kpi .ring { top: 9px; right: 11px; width: 38px; height: 38px; }
  .kpi.is-sk .sk-h { margin: 4px 0 10px; }
  .kpi.is-sk .sk-v { height: 26px; margin-bottom: 10px; }
  .kpi.is-sk .sk-s2 { display: none; }
  .stockcard { padding: 9px 14px 6px; }
  .stockcard-h { height: 24px; margin-bottom: 2px; }
  .sc-sub, .srow .lbl small { display: none; }
  /* the «19 из 20 складов» line is hidden here: a partial count says so in the label itself */
  .stockcard.is-filtered .srow .lbl .l-full { display: none; }
  .stockcard.is-filtered .srow .lbl .l-part { display: inline; }
  .srow { height: 29px; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 8px; }
  .srow .fi { width: 24px; height: 24px; border-radius: 7px; }
  .srow .fi .i { width: 14px; height: 14px; }
  .srow .v { font-size: 18px; }
  .stockcard.is-sk .sk-sh { margin: 4px 0 10px; }
  .stockcard.is-sk .sk-sr { height: 18px; margin-bottom: 11px; }
}
/* one KPI row also between 1200 and 1280 px wide (the short cards fit) */
@media (min-width: 1201px) and (max-width: 1280px) and (max-height: 1100px) {
  .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.42fr); height: var(--kpi-h); }
  .kpi { padding-left: 12px; padding-right: 12px; }
  .kpi-v { font-size: 25px; }
}
/* one-row toolbar: title + search · «*» legend, warehouses jump, warnings · view and buttons. The coloured legend
   is not repeated here: the column family bands of the table say the same. */
@media (min-width: 1101px) and (max-height: 1100px) {
  .tc-top { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 10px 0 16px; }
  .tc-head { display: contents; }
  .tc-head > .spacer { display: none; }
  .tc-l, .tc-r { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .tc-l { order: 1; flex: 0 1 auto; }
  .tc-r { order: 3; flex: none; gap: 6px; }
  .tc-top .search { flex: 0 1 260px; min-width: 150px; }
  /* a reserved minimum: the search box gives way first, the legend / jump / warnings never slide under the buttons */
  .tc-top .infostrip { order: 2; flex: 1 1 0; min-width: 380px; height: auto; padding: 0; border-top: 0; background: none; gap: 10px; }
  .tc-top .legend { flex: none; }
  .tc-top .legend .lg-t, .tc-top .legend .lg:not(.lg-star) { display: none; }
  .tc-top .legend.closed .lg-star { display: inline-flex; }
  .tc-top #legend.no-star { display: none; }
  .tc-top .warn-anchor { min-width: 110px; }
  /* the table box fills the window under the top bar and the toolbar */
  .tbl-scroll { height: calc(100vh - 124px); }
}
@media (min-width: 1101px) and (max-width: 1699px) and (max-height: 1100px) {
  .tc-top .tc-count { display: none; }   /* the same counts are in the «Итого» row */
}
@media (min-width: 1101px) and (max-width: 1499px) and (max-height: 1100px) {
  .tc-head .btn-txt { display: none; }
  #btn-collapse { width: 162px; }
  .tc-head .btn-ghost { padding: 0 9px; }
}
@media (min-width: 1101px) and (max-width: 1399px) and (max-height: 1100px) {
  .tc-top .lg-star .lg-st { display: none; }   /* «* неполн.»: the short word, the tooltip explains it */
  .tc-top .lg-star .lg-ss { display: inline; }
  .tc-top .infostrip { min-width: 272px; }
}

@media (min-width: 761px) and (max-height: 960px) {
  :root { --top-h: 56px; --kpi-h: 128px; --strip-h: 42px; }
  .topbar .tabs { padding: 3px; border-radius: 13px; }
  .topbar .tab { height: 36px; }
  .logo { width: 34px; height: 34px; border-radius: 11px; }
  .topbar .pill, .topbar .btn { height: 34px; }
  .topbar .icon-btn { width: 34px; height: 34px; }
  .page { padding-top: 10px; }
  .banners { margin-bottom: 8px; }
  .banner { min-height: 34px; padding: 2px 4px 2px 12px; --bn-x: 26px; --bn-m: 24px; }
  .setup { margin-bottom: 10px; }
  .setup-bar { height: 58px; }
  .sb-actions .btn { height: 36px; }
  .cal-ico { width: 42px; height: 42px; }
  .cal-ico span:last-child { font-size: 17px; line-height: 23px; }
  .sb-title { font-size: 18px; line-height: 23px; }
  .kpis { margin-bottom: 10px; }
  .kpi { padding-top: 8px; padding-bottom: 7px; }
  .stockcard { padding-top: 7px; padding-bottom: 5px; }
  .srow { height: 28px; }
  /* table header: same lines, less air */
  .grid tr.fam th { height: 30px; }
  .grid tr.lbl { height: 46px; }
  .grid tr.lbl.solo { height: 70px; }
  .grid tr.lbl th { padding-bottom: 6px; }
  .grid.raised tr.lbl th.has-star .th-l .star { bottom: 32px; }
  .grid tr.unit { height: 24px; }
  .grid tr.unit th { padding-bottom: 4px; }
  .grid tr.unit th .th-l { height: 19px; line-height: 19px; }
  .grid tr.unit th .sort-ar { bottom: 8px; }
  .grid tr.tot > * { height: 42px; }
  .grid tr.tot-all > * { height: 26px; }
  .tot-a { line-height: 1.15; }
}
/* the one-row toolbar exists from 1101 px wide; narrower windows keep the two-row toolbar at its natural height */
@media (min-width: 1101px) and (max-height: 960px) { .tc-top { height: 52px; } .tbl-scroll { height: calc(100vh - 112px); } }

@media (min-width: 761px) and (max-height: 760px) {
  :root { --kpi-h: 104px; --strip-h: 40px; }
  .page { padding-top: 8px; }
  .banner { min-height: 32px; --bn-c: 26px; }
  .setup { margin-bottom: 8px; }
  .setup-bar { height: 52px; border-radius: 18px; }
  .sb-actions .btn { height: 34px; }
  .cal-ico { width: 38px; height: 40px; border-radius: 10px; }
  .cal-ico span:first-child { line-height: 16px; }
  .cal-ico span:last-child { font-size: 16px; line-height: 22px; }
  .sb-title { font-size: 17px; line-height: 22px; }
  .kicker { line-height: 17px; }
  .fact-k { height: 18px; }
  .kpis { margin-bottom: 8px; }
  .kpi { padding: 7px 12px 6px; }
  .kpi-h { height: 24px; margin-bottom: 0; }
  .kpi-h .fi { width: 24px; height: 24px; }
  .kpi-v { font-size: 25px; line-height: 30px; height: 30px; }
  .kpi-v small { font-size: 15px; }
  .kpi-opt { display: none; }
  .kpi-s, .kpi-f { margin-top: auto; }   /* the line each card keeps sits at the bottom, aligned across cards */
  .kpi .ring { top: 8px; right: 10px; width: 32px; height: 32px; }
  .kpi.is-sk .sk-h { margin: 4px 0 8px; }
  .kpi.is-sk .sk-v { height: 22px; margin-bottom: 8px; }
  .kpi.is-sk .sk-s { display: none; }
  .stockcard { padding: 6px 12px 4px; }
  .stockcard-h { height: 22px; margin-bottom: 0; }
  .srow { height: 25px; grid-template-columns: 20px minmax(0, 1fr) auto; }
  .srow .fi { width: 20px; height: 20px; border-radius: 6px; }
  .srow .fi .i { width: 13px; height: 13px; }
  .srow .v { font-size: 16px; }
  .stockcard.is-sk .sk-sh { margin: 3px 0 8px; }
  .stockcard.is-sk .sk-sr { height: 14px; margin-bottom: 10px; }
  .grid tr.fam th { height: 28px; }
  .grid tr.lbl { height: 44px; }
  .grid tr.lbl.solo { height: 68px; }
  .grid tr.lbl th { padding-bottom: 5px; }
  .grid.raised tr.lbl th.has-star .th-l .star { bottom: 31px; }
  .grid tr.tot > * { height: 40px; }
}
@media (min-width: 1101px) and (max-height: 760px) { .tc-top { height: 50px; } .tbl-scroll { height: calc(100vh - 110px); } }

/* phones: day tiles, regions, cities and product names wrap instead of ending in «…» */
@media (max-width: 760px) {
  .hc-col:not(.l3) .hc-val, .hc-col.n2 .hc-val { visibility: hidden; }   /* bars ~8 px wide: labels would collide */
  .tiles { grid-auto-rows: minmax(236px, auto); }
  .tile { height: auto; }
  .tile-v { white-space: normal; height: auto; min-height: 36px; line-height: 32px; }
  .tile-s { display: block; height: auto; -webkit-line-clamp: unset; overflow: visible; }
  .cmp-row { height: auto; min-height: 22px; white-space: normal; }
  .cmp-row > span:first-child { white-space: normal; overflow: visible; }
  .split-legend { height: auto; overflow: visible; }
  .ev span { white-space: normal; overflow: visible; line-height: 1.2; }
  /* flat rows: a long «артикул/цвет+цвет» takes two lines (break chances after «/» and «+»); every flat row has
     the same height (the windowed table measures one row) */
  .grid tr.flat > td { height: 62px; }
  .fl1 { height: auto; max-height: 38px; align-items: flex-start; }
  .fl1 .art { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 19px; }
  .fl1 .flag { margin-top: 1px; }
  .dtable td:first-child { white-space: normal; }
  /* a card row keeps its 48 px: the name stays on one line («…», the tooltip and the WB card have the rest) */
  .dcard-t .art { white-space: nowrap; }
  .dtable tfoot td .l-l { display: none; }
  .dtable tfoot td .l-s { display: inline; }
  .dsize-a { padding-left: 32px; }
  .dsz-n { display: none; }   /* phones: just «50 · 52 · 54» under the name (the count is in the tooltip) */
  .dsize-a::after { width: 15px; }
  .dtable th .l-l { display: none; }
  .dtable th .l-s { display: inline; }
  .dtable th { padding: 0 6px 0 12px; }
  .dtable col.c-n { width: 64px; }
  /* the table strip: «Предупреждения · N» instead of a cut first warning; the «*» note lives in their popover */
  .legend { display: none; }
  .rwarn .t, .rwarn .n { display: none; }
  .rwarn .tm { display: inline; }
  .sb-kpi { display: none; }   /* phones: the KPI cards are already a swipeable row */
  .kpis.is-strip { height: auto; margin: 0 0 12px; }
  .kstrip { display: flex; overflow-x: auto; scrollbar-width: none; }
  .ks { flex: none; }
  .ks-x { display: none; }
}

/* phones: «Наличие по дням» is a bottom sheet (the grid scrolls sideways, the size column stays), the cost
   dialog takes the whole screen and its list keeps the article, the price and the actions */
@media (max-width: 760px) {
  .pop-av { left: 12px; right: 12px; top: auto; bottom: 12px; width: auto; max-width: none; max-height: 80vh; box-shadow: var(--shadow-lg), 0 0 0 100vmax rgba(20, 16, 12, .32); }
  .av-ht p { max-width: none; }
  .av-stat { display: none; }
  .av-col-rh { width: 88px; }
  .av-ll { display: none; }
  .av-mon th span { left: 94px; }   /* «07:00» / «19:00»: the row header keeps the time (the tooltip says morning / evening) */
  .av-legend { gap: 4px 12px; }
  .av-legend > span { white-space: normal; }   /* the long first item wraps inside the sheet instead of running out */
  .dlg-costs { width: calc(100vw - 16px); height: calc(100vh - 16px); --cr-cols: 26px minmax(0, 1fr) auto auto; }
  .costs-in { padding: 12px 12px 12px; gap: 10px; }
  .dlg-costs .dlg-h { flex-wrap: wrap; row-gap: 6px; }
  .costs-ht { flex-basis: calc(100% - 100px); }
  .costs-ht p { white-space: normal; }
  .costs-on { order: 5; }
  /* phones do not drag files: just the two buttons */
  .drop { padding: 10px; border-style: solid; border-width: 1px; }
  .drop-ico, .drop-t { display: none; }
  .drop-a { width: 100%; flex-wrap: wrap; }
  .costs-tools { flex-wrap: wrap; }
  .costs-tools .search { flex-basis: 100%; }
  .costs-tools .seg { overflow-x: auto; max-width: 100%; }
  .costs-head { display: none; }
  .cr-d, .cr-h { display: none; }
  .cr-x .btn span { display: none; }
  .cr-x .btn { width: 32px; padding: 0; justify-content: center; }
  .cr-more { padding: 4px 8px 10px 12px; }
  .hist li { grid-template-columns: minmax(0, 1fr) auto 32px 32px; gap: 6px; }
  .hist .h-s, .hist li > .badge, .hist li > span:empty { display: none; }
  .cform .input { width: 140px; }
  .pv-table th:nth-child(1) { width: 52px; }
  .pv-table th:nth-child(3) { width: 96px; }
  .pv-table th:nth-child(4) { display: none; }
  .pv-table td:nth-child(4) { display: none; }
  .pv-table th:nth-child(5) { width: 104px; }
  .pv-foot .muted { display: none; }
}

/* === кабинеты и вход === (docs/multi_cabinet_design.md §6: the login page, the cabinet switcher, the user menu,
   the «API-ключ» dialog, the first-run cards, «Кабинеты и пользователи»). Text ≥ 13 px, inputs 16 px, every
   message line has its height reserved. */

/* ---- the login page (static/login.html) */
.auth { width: min(400px, calc(100% - 32px)); margin: 0 auto; padding: max(28px, 9vh) 0 40px; display: grid; gap: 18px; }
.auth-brand { display: flex; align-items: center; justify-content: center; gap: 12px; }
.auth-brand .brand-name { font-size: 18px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow); padding: 26px 26px 16px; }
.auth-form { display: grid; gap: 14px; }
.auth-form h1 { font-size: 24px; line-height: 1.25; }
.auth-sub { margin-top: -6px; color: var(--text-2); font-size: 14px; line-height: 1.45; }
.auth-field { display: grid; min-width: 0; }
.auth-in { width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; font-size: 16px; }
.pw-box { position: relative; display: block; }
.pw-box .auth-in { padding-right: 50px; }
.pw-eye { position: absolute; top: 4px; right: 4px; }
.pw-eye.is-on { color: var(--accent); }
.auth-submit { width: 100%; justify-content: center; margin-top: 2px; }
.auth-submit .spinner { width: 18px; height: 18px; }
.auth-hint { margin: -6px 0 0; font-size: 13px; color: var(--text-3); line-height: 1.4; }
.auth-err { min-height: 40px; margin: 0; color: var(--neg); font-size: 14px; line-height: 20px; }
.auth-note { text-align: center; font-size: 13.5px; color: var(--text-2); }
.auth-extra { margin: 0; padding: 10px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; color: var(--text-2); background: var(--info-soft); border: 1px solid var(--info-line); }
.auth-extra.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--text); }

/* ---- shared bits of the new dialogs */
.mc-field { display: grid; min-width: 0; }
.mc-field .input { width: 100%; height: 42px; font-size: 16px; }
.mc-err { min-height: 20px; margin: 0; color: var(--neg); font-size: 14px; line-height: 20px; }
.btn-danger { border: 0; background: #c22a33; color: #fff; box-shadow: 0 8px 20px -10px rgba(194, 42, 51, .7); }
.btn-danger:hover { background: #a9222b; border: 0; }
.btn-danger:disabled { border: 0; background: var(--surface-3); color: var(--text-3); box-shadow: none; }
/* a control that would change a disabled cabinet: the look of a disabled button (no opacity — the text keeps its
   contrast), the tooltip says why */
.btn.is-ro, .btn.is-ro:hover, .icon-btn.is-ro, .icon-btn.is-ro:hover, .seg button.is-ro { border-color: var(--line); background: var(--surface-2); color: var(--text-3); box-shadow: none; cursor: not-allowed; }
.btn-ghost.is-ro, .btn-ghost.is-ro:hover, .icon-btn.is-ro, .icon-btn.is-ro:hover { border-color: transparent; background: transparent; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.chip-sm { height: 24px; padding: 0 8px; gap: 4px; font-size: 13px; }
.menu { display: grid; gap: 2px; padding: 6px; }
.menu-i { display: flex; align-items: center; gap: 10px; width: 100%; height: 38px; padding: 0 10px; border: 0; border-radius: 9px; background: none; color: var(--text); font-size: 14px; text-align: left; white-space: nowrap; }
.menu-i:hover, .menu-i:focus-visible { background: var(--surface-3); }
.menu-i .i { color: var(--text-3); }
.menu-i.danger, .menu-i.danger .i { color: var(--neg); }

/* ---- header: the cabinet switcher (#seller), the key button's dot, the user button */
.brand { position: relative; }
.brand-seller.has-btn { overflow: visible; }
.cab-btn { position: relative; z-index: 0; display: inline-flex; align-items: center; gap: 4px; max-width: 100%; height: 18px; padding: 0; border: 0; border-radius: 6px; background: none; color: inherit; font: inherit; line-height: 18px; text-align: left; }
.cab-btn::before { content: ""; position: absolute; z-index: -1; inset: -6px -8px; border-radius: 9px; }
.cab-btn:hover::before, .cab-btn[aria-expanded="true"]::before { background: var(--surface-3); }
.cab-btn:focus-visible { box-shadow: none; }
.cab-btn:focus-visible::before { box-shadow: var(--ring); }
.cab-cur { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cab-chev { color: var(--text-3); transition: transform .15s; }
.cab-btn[aria-expanded="true"] .cab-chev { transform: rotate(180deg); }
.pop-cab { top: calc(100% + 12px); right: auto; left: 0; width: 380px; padding: 0; overflow: hidden; }
.cab-search { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--text-3); }
.cab-search .input { flex: 1; height: 38px; font-size: 16px; }
.cab-list { display: grid; gap: 2px; max-height: min(430px, 60vh); margin: 0; padding: 6px; overflow: auto; list-style: none; }
.cab-opt { display: grid; grid-template-columns: minmax(0, 1fr) auto 18px; align-items: center; gap: 10px; min-height: 50px; padding: 6px 10px; border-radius: 10px; cursor: pointer; }
.cab-opt:hover { background: var(--surface-3); }
.cab-opt:focus-visible { border-radius: 10px; box-shadow: inset 0 0 0 2px var(--accent); }
.cab-opt.is-cur { background: var(--accent-soft); }
.cab-opt.is-busy { opacity: .6; pointer-events: none; }
.cab-o-t { display: grid; min-width: 0; }
.cab-o-t b { overflow: hidden; font-size: 14px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.cab-o-t small { overflow: hidden; color: var(--text-3); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.cab-o-st { display: flex; align-items: center; gap: 6px; }
.cab-o-ck { display: grid; place-items: center; width: 18px; color: var(--accent); }
.cab-sync { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-ink); font-size: 13px; white-space: nowrap; }
.cab-sync .dot { width: 7px; height: 7px; }
.cab-empty { padding: 14px; color: var(--text-3); font-size: 14px; text-align: center; }
.cab-foot { justify-content: flex-start; }
.key-btn { position: relative; }
.kdot { position: absolute; top: 6px; right: 5px; width: 9px; height: 9px; border-radius: 50%; box-shadow: 0 0 0 2px var(--bg); pointer-events: none; }
.kdot.warn { background: var(--warn-dot); }
.kdot.err { background: var(--ret); }
.user-anchor { display: flex; margin-left: 2px; }
.user-btn { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--accent-line); border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); font-size: 14px; font-weight: 700; line-height: 1; }
.user-btn:hover { border-color: var(--accent); }
.user-btn.is-local { border-color: var(--line-2); background: var(--surface-3); color: var(--text-2); }
.user-btn:focus-visible { border-radius: 50%; }
.user-ini { display: grid; place-items: center; width: 100%; height: 100%; }
.pop-user { width: 300px; padding: 0; overflow: hidden; }
.pop-user .pop-head { border-bottom: 1px solid var(--line); }
.pop-user .pop-title { min-width: 0; }
.pop-user .pop-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-user .pop-title .i { color: var(--text-3); }
.sync-anchor.is-off, .tabs.is-off { visibility: hidden; }   /* a whole-page card: their place is kept */

/* ---- «API-ключ кабинета» */
.dlg-key { margin: max(24px, 7vh) auto auto; width: min(560px, calc(100vw - 32px)); }
.key-kv { align-content: start; }
.key-kv dd .muted { font-weight: 500; }
.key-kv dd .badge { margin: 1px 0; vertical-align: middle; }
.key-kv .kv-seller { border-bottom: 1px dotted var(--line-strong); }
.key-edit { display: grid; }
.key-edit textarea { font-size: 16px; }
.key-edit textarea:disabled { opacity: .6; cursor: not-allowed; }
.key-ro { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-3); color: var(--text-2); font-size: 14px; line-height: 1.45; }
.key-msg { min-height: 44px; font-size: 14px; line-height: 1.45; }
.key-msg.is-err { padding: 10px 12px; border-radius: 10px; background: var(--neg-soft); color: var(--neg); }
.key-msg.is-confirm { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--warn-line); border-radius: 10px; background: var(--warn-soft); color: var(--text); }
.key-msg.is-confirm p { flex: 1; min-width: 0; }
.key-confirm-a { display: flex; flex: none; gap: 6px; }
.key-bad { color: var(--neg); }
.key-save { min-width: 220px; justify-content: center; }
.dlg-pw { width: min(440px, calc(100vw - 32px)); }
.dlg-confirm { width: min(480px, calc(100vw - 32px)); }
.confirm-text { color: var(--text-2); font-size: 14.5px; line-height: 1.5; }

/* ---- whole-page cards (§6.5) */
.gate { display: grid; justify-items: center; padding: 20px 0 40px; }
.gate-card { display: grid; justify-items: start; gap: 14px; width: min(580px, 100%); padding: 28px 28px 24px; border: 1px solid var(--line); border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow); }
.gate-card.is-wide { width: min(780px, 100%); }
.gate-ico { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; background: var(--accent-soft); color: var(--accent); }
.gate-ico .i { width: 24px; height: 24px; }
.gate-ico.is-warn { background: var(--warn-soft); color: var(--warn); }
.gate-card h2 { font-size: 22px; line-height: 1.3; }
.gate-p { color: var(--text-2); font-size: 15px; line-height: 1.5; }
.gate-a { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-height: 52px; }
.gate-note { color: var(--text-2); font-size: 14px; line-height: 1.45; }
.gate-help { color: var(--text-3); font-size: 13.5px; line-height: 1.5; }
.gate-form { display: grid; gap: 12px; width: 100%; }
.gate-form .gate-a { min-height: 0; }
.gate-form textarea, .adm-form textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 12px; background: var(--surface-2); color: var(--text); font: 16px/1.4 ui-monospace, Consolas, monospace; resize: vertical; }
.gate-form textarea:focus, .adm-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.gate-form textarea:disabled, .adm-form textarea:disabled { opacity: .6; cursor: not-allowed; }
.gate-sync { display: grid; gap: 12px; width: 100%; }
.gs-top { display: grid; gap: 8px; }
.gs-t { color: var(--text-2); font-size: 14px; }
.gs-t b { color: var(--text); }

/* ---- «Кабинеты и пользователи» (fixed size: nothing jumps while it fills) */
.dlg-admin { width: min(1120px, calc(100vw - 32px)); height: min(820px, calc(100vh - 32px)); max-width: none; max-height: none; overflow: hidden; }
.adm-in { display: flex; flex-direction: column; gap: 12px; height: 100%; padding: 20px 22px 16px; }
.adm-in > .dlg-h { flex: none; gap: 12px; }
.adm-in > .dlg-h .icon-btn { margin-left: 0; }
.adm-in > .dlg-h .fi { width: 34px; height: 34px; border-radius: 11px; }
.adm-ht { flex: 1; min-width: 0; }
.adm-ht p { overflow: hidden; color: var(--text-3); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.adm-tabs { flex: none; align-self: flex-start; }
.adm-tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(45, 32, 18, .1), 0 0 0 1px var(--line); }
.adm-body { display: flex; flex: 1 1 auto; flex-direction: column; gap: 12px; min-height: 0; padding: 2px; overflow: auto; }
.adm-tools { display: flex; flex: none; align-items: center; gap: 12px; }
.adm-count { color: var(--text-3); font-size: 13.5px; }
.adm-list { flex: none; }
.adm-table { overflow: clip; border: 1px solid var(--line); border-radius: 14px; }
.adm-row { display: grid; align-items: center; gap: 12px; min-height: 58px; padding: 8px 12px 8px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.adm-row:last-child { border-bottom: 0; }
.adm-row > div { min-width: 0; }
.adm-cab { grid-template-columns: minmax(150px, 1.15fr) minmax(150px, 1.25fr) 176px minmax(140px, 1fr) 56px 36px; }
.adm-user { grid-template-columns: minmax(150px, 1fr) 128px minmax(170px, 1.6fr) 130px minmax(150px, 1fr) 36px; }
.adm-row .c-wide { grid-column: span 2; }
.adm-head { position: sticky; top: 0; z-index: 1; min-height: 38px; padding-top: 0; padding-bottom: 0; background: var(--surface-2); color: var(--text-3); font-size: 13px; font-weight: 600; }
.adm-row.is-sk .sk { height: 14px; }
.adm-row.is-off .adm-name b { color: var(--text-2); }
.adm-row.is-gone, .adm-row.is-gone .adm-name b { color: var(--text-3); }
.adm-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.adm-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-2l { display: grid; min-width: 0; }
.adm-2l > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-2l small { color: var(--text-3); font-size: 13px; }
.adm-unav { max-width: 100%; overflow: hidden; }
.adm-unav > span { overflow: hidden; text-overflow: ellipsis; }
.adm-sync, .adm-pend { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13.5px; white-space: nowrap; }
.adm-sync .spinner, .adm-pend .spinner { width: 14px; height: 14px; color: var(--accent); }
.c-data .dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; vertical-align: middle; }
.adm-users { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); }
.adm-more { width: 34px; height: 34px; }
.adm-more[aria-expanded="true"] { background: var(--surface-3); color: var(--text); }
.adm-menu { position: fixed; top: 0; right: auto; left: 0; z-index: 5; width: 270px; padding: 0; }
.adm-inline { display: flex; align-items: center; gap: 6px; }
.adm-inline .input { flex: 1; min-width: 0; height: 36px; font-size: 16px; }
.adm-form { display: grid; flex: none; gap: 12px; padding: 16px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--surface-2); }
.adm-form-h { display: flex; align-items: baseline; gap: 10px; }
.adm-form-h h3 { font-size: 16px; }
.adm-form-h .muted { font-size: 13px; }
.adm-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.adm-form-a { display: flex; justify-content: flex-end; gap: 8px; }
.adm-access { display: grid; gap: 2px; max-height: 232px; min-width: 0; margin: 0; padding: 0; overflow: auto; border: 0; }
.adm-access legend { padding: 0; }
.adm-access > p { font-size: 13.5px; }
.grant { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 2px 8px; border-radius: 9px; }
.grant:hover { background: var(--hover); }
.grant-cb { display: flex; flex: 1; align-items: center; gap: 10px; min-width: 0; cursor: pointer; }
.grant-cb input { flex: none; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.grant-l { display: grid; min-width: 0; font-size: 14px; }
.grant-l > * { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grant-l small { color: var(--text-3); font-size: 13px; }
.grant-sw { flex: none; }
.grant-sw.is-off { color: var(--text-3); }
.grant-sw.is-off .track { opacity: .5; }
.adm-pwmode { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.adm-pwmode .f-label { margin: 0; }
.adm-pwmode .input { width: 260px; height: 40px; font-size: 16px; }
.adm-pw-note { font-size: 13px; }
.adm-adminsw { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.adm-sub { display: grid; gap: 10px; padding: 12px 16px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.adm-result { display: flex; flex: none; align-items: flex-start; gap: 12px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--pos) 30%, transparent); border-radius: 14px; background: var(--pos-soft); }
.adm-result-b { display: grid; flex: 1; gap: 6px; min-width: 0; }
.adm-result p { color: var(--text-2); font-size: 13.5px; line-height: 1.45; }
.adm-pw-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.adm-pw { padding: 6px 10px; border-radius: 8px; background: var(--surface); color: var(--text); font: 600 18px/1.2 ui-monospace, Consolas, monospace; letter-spacing: .02em; user-select: all; }
.adm-filters { display: flex; flex: none; flex-wrap: wrap; gap: 12px; }
.adm-filter { display: grid; min-width: 190px; }
.adm-filter .input { height: 40px; font-size: 16px; }
.aud-list { margin: 0; padding: 0; overflow: clip; border: 1px solid var(--line); border-radius: 14px; list-style: none; }
.aud-i { display: grid; grid-template-columns: 148px minmax(0, 1fr) 128px; align-items: baseline; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; line-height: 1.45; }
.aud-i:last-child { border-bottom: 0; }
.aud-i.is-sk { align-items: center; min-height: 42px; }
.aud-t { color: var(--text-3); font-size: 13px; white-space: nowrap; }
.aud-t b { color: var(--text-2); font-weight: 600; }
.aud-ip { color: var(--text-3); font-size: 13px; text-align: right; }
.aud-more { display: flex; justify-content: center; padding: 10px 0 2px; }
.adm-empty { display: grid; justify-items: center; gap: 8px; padding: 40px 20px; color: var(--text-2); text-align: center; }
.adm-empty .i { color: var(--text-3); }

/* the tables become stacked cards */
@media (max-width: 720px) {
  .adm-head { display: none; }
  .adm-row { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 12px; }
  .adm-row > .c-name { grid-column: 1; grid-row: 1; }
  .adm-row > .c-act { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
  .adm-row > div:not(.c-name):not(.c-act), .adm-row .c-wide { grid-column: 1; }
  .adm-grid2 { grid-template-columns: minmax(0, 1fr); }
  .aud-i { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .aud-ip { text-align: left; }
  .adm-filter { flex: 1 1 100%; }
  .grant { flex-wrap: wrap; row-gap: 0; }
  .grant-sw { margin-left: 28px; }
  .key-msg.is-confirm { flex-direction: column; align-items: stretch; }
  .key-confirm-a { justify-content: flex-end; }
}

/* phones: the cabinet name stays in the header (the seller goes), the menus and the panel are sheets */
@media (max-width: 760px) {
  .brand { gap: 8px; }
  .brand-seller { display: block; }
  .cab-sel { display: none; }
  .user-btn { width: 34px; height: 34px; }
  .pop-cab, .pop-user { position: fixed; top: auto; right: 12px; bottom: 12px; left: 12px; width: auto; box-shadow: var(--shadow-lg), 0 0 0 100vmax rgba(20, 16, 12, .32); }
  .dlg-key { margin-top: 12px; }
  .key-save { min-width: 0; }
  .dlg-admin { width: 100vw; height: 100vh; height: 100dvh; margin: 0; border-radius: 0; }   /* a full-screen sheet (§6.4) */
  .adm-in { padding: 12px; gap: 10px; }
  .adm-tabs { align-self: stretch; }
  .adm-tabs button { flex: 1 1 auto; justify-content: center; padding: 0 6px; }
  .adm-ht p { display: none; }
  .gate { padding-top: 4px; }
  .gate-card { padding: 20px 18px 18px; }
  .gate-card h2 { font-size: 20px; }
  .auth-card { padding: 20px 18px 12px; }
  .auth-err { min-height: 60px; }
}
