/* Админка v2 MIKHEEFF Queue.
 *
 * Рабочий экран владельца: цифры и действия важнее украшений. Один акцент —
 * синий из проверенной палитры графиков (он же первая серия данных), статусы —
 * только вместе с иконкой и словом. Шрифт IBM Plex Sans (свой файл, без CDN:
 * в России CDN бывают недоступны), цифры табличные — колонки чисел не пляшут.
 * Анимируются только transform и opacity; палитра поиска открывается мгновенно
 * (её зовут десятки раз в день), карточка справа выезжает за 240 мс.
 */

/* Шрифты (@font-face) — в fonts.css: встроены base64, чтобы выкладка текстом их не портила. */

:root {
  color-scheme: light;
  --canvas: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --raised: #ffffff;
  --hover: #f1f3f6;
  --line: #e3e6eb;
  --line-strong: #cfd4dc;
  --ink: #15171c;
  --ink-2: #4f5562;
  --ink-3: #6b7280;
  --accent: #256abf;
  --accent-ink: #1d5aa6;
  --accent-soft: #e8f0fb;
  --on-accent: #ffffff;
  /* Заливка кнопок с белым текстом: в обеих темах ≥ 4.5:1 (у #3987e5 было 3.6:1). */
  --accent-fill: #256abf;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --grid: #e9ebef;
  --axis: #c3c8d0;
  --good: #0f7a2f;
  --good-soft: #e5f4ea;
  --warn: #8a5a00;
  --warn-dot: #e2a100;
  --warn-soft: #fbf1dc;
  --bad: #c0352f;
  --bad-soft: #fbe9e8;
  --seq-0: #edf4fd;
  --seq-1: #cde2fb;
  --seq-2: #9ec5f4;
  --seq-3: #6da7ec;
  --seq-4: #3987e5;
  --seq-5: #256abf;
  --seq-6: #184f95;
  --shadow-pop: 0 8px 28px rgba(16, 24, 40, 0.14), 0 2px 6px rgba(16, 24, 40, 0.08);
  --shadow-drawer: -12px 0 40px rgba(16, 24, 40, 0.12);
  --scrim: rgba(15, 18, 24, 0.32);
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --font: 'Plex', -apple-system, 'Segoe UI', Roboto, system-ui, sans-serif;
  --mono: 'Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

/* Тёмная: свои шаги тех же цветов, проверенные на тёмной подложке — не инверсия. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;
    --canvas: #0e1014;
    --surface: #15181d;
    --surface-2: #121519;
    --raised: #1b1f25;
    --hover: #1f242b;
    --line: #262b33;
    --line-strong: #353b45;
    --ink: #eceef2;
    --ink-2: #b4bac5;
    --ink-3: #8c93a0;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-soft: #16263b;
    --on-accent: #ffffff;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --grid: #22272e;
    --axis: #3a414c;
    --good: #3fbf6a;
    --good-soft: #13281b;
    --warn: #f0b33b;
    --warn-dot: #f0b33b;
    --warn-soft: #2c2310;
    --bad: #f07a76;
    --bad-soft: #321717;
    --seq-0: #141d29;
    --seq-1: #102c4f;
    --seq-2: #184f95;
    --seq-3: #1c5cab;
    --seq-4: #2a78d6;
    --seq-5: #5598e7;
    --seq-6: #9ec5f4;
    --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-drawer: -16px 0 48px rgba(0, 0, 0, 0.5);
    --scrim: rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --canvas: #0e1014;
  --surface: #15181d;
  --surface-2: #121519;
  --raised: #1b1f25;
  --hover: #1f242b;
  --line: #262b33;
  --line-strong: #353b45;
  --ink: #eceef2;
  --ink-2: #b4bac5;
  --ink-3: #8c93a0;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --accent-soft: #16263b;
  --on-accent: #ffffff;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --grid: #22272e;
  --axis: #3a414c;
  --good: #3fbf6a;
  --good-soft: #13281b;
  --warn: #f0b33b;
  --warn-dot: #f0b33b;
  --warn-soft: #2c2310;
  --bad: #f07a76;
  --bad-soft: #321717;
  --seq-0: #141d29;
  --seq-1: #102c4f;
  --seq-2: #184f95;
  --seq-3: #1c5cab;
  --seq-4: #2a78d6;
  --seq-5: #5598e7;
  --seq-6: #9ec5f4;
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-drawer: -16px 0 48px rgba(0, 0, 0, 0.5);
  --scrim: rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
/* scroll-padding: при переходе по Tab липкая шапка не закрывает поле. */
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
button, a, .chip, summary, tr.clickable { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.skip { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 12px; border-radius: var(--r-sm); background: var(--accent-fill); color: #fff; text-decoration: none; }
.skip:focus { top: 12px; }
html, body { margin: 0; background: var(--canvas); color: var(--ink); }
body {
  font: 400 14px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
::selection { background: color-mix(in srgb, var(--accent) 28%, transparent); }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; flex-shrink: 0; }
.mono { font-family: var(--mono); font-weight: 500; font-size: 12.5px; letter-spacing: 0.01em; white-space: nowrap; }
.muted { color: var(--ink-3); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }

/* --- Каркас: навигация слева, работа справа ------------------------------ */

.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  padding: 16px 12px; background: var(--surface-2); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 28px; height: 28px; border-radius: 7px; }
.brand b { display: block; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.brand span { display: block; font-size: 12px; color: var(--ink-3); }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--r-sm);
  color: var(--ink-2); text-decoration: none; font-weight: 500;
  transition: background-color 120ms ease, color 120ms ease;
}
.nav-item svg { color: var(--ink-3); }
.nav-item .count { margin-left: auto; font-size: 12px; color: var(--ink-3); }
.nav-item .count.alert { color: var(--bad); font-weight: 600; }
@media (hover: hover) and (pointer: fine) { .nav-item:hover { background: var(--hover); color: var(--ink); } }
.nav-item[aria-current='page'] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line); }
.nav-item[aria-current='page'] svg { color: var(--accent); }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 10px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 32px; background: color-mix(in srgb, var(--canvas) 92%, transparent);
  border-bottom: 1px solid transparent; backdrop-filter: saturate(1.4) blur(8px);
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar-title { display: none; font-weight: 600; }
.topbar-spacer { flex: 1; }
.btn.menu-btn { display: none; }
.updated { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

.view { padding: 8px 32px 64px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 8px 0 20px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 600; letter-spacing: -0.015em; text-wrap: balance; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* --- Панели и сетки ------------------------------------------------------- */

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px 20px 0; flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.panel-head .sub { color: var(--ink-3); font-size: 12.5px; }
.panel-body { padding: 14px 20px 18px; }
.panel-body.flush { padding: 8px 0 0; }
.section-gap { height: 16px; }

/* --- KPI одной полосой: ячейки через тонкие разделители, без карточек ---- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.kpi { padding: 16px 20px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.kpi:nth-child(4n) { border-right: 0; }
.kpi:nth-last-child(-n + 4) { border-bottom: 0; }
.kpi-label { color: var(--ink-2); font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.kpi-value { font-size: 28px; line-height: 1.15; font-weight: 600; letter-spacing: -0.02em; white-space: nowrap; }
.kpi-sub { font-size: 12px; color: var(--ink-3); min-height: 18px; }
.kpi-spark { height: 28px; margin-top: 2px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.delta.up { color: var(--good); }
.delta.down { color: var(--bad); }
.delta.flat { color: var(--ink-3); font-weight: 500; }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.figure { background: var(--surface); padding: 14px 18px; min-width: 0; }
.figure .k { font-size: 12.5px; color: var(--ink-2); }
.figure .v { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; margin-top: 2px; white-space: nowrap; }
.figure .s { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* --- Очередь «Что сделать сегодня» --------------------------------------- */

.queue { list-style: none; margin: 0; padding: 0; }
.queue li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 12px 20px; border-top: 1px solid var(--line); }
.queue li:first-child { border-top: 0; }
.q-pos { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--hover); margin-top: 1px; }
.queue li.sev-critical .q-pos { background: var(--bad-soft); color: var(--bad); }
.queue li.sev-warn .q-pos { background: var(--warn-soft); color: var(--warn); }
.q-title { font-weight: 600; }
.q-sub { color: var(--ink-2); font-size: 13px; overflow-wrap: anywhere; }
.q-sub a { color: inherit; }
.q-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.q-empty { padding: 28px 20px; color: var(--ink-2); }
.q-empty b { display: block; color: var(--ink); margin-bottom: 2px; }

/* --- Кнопки, поля, чипы ---------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform 160ms var(--ease-out), background-color 120ms ease, border-color 120ms ease;
}
.btn:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .btn:hover { background: var(--hover); } }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--on-accent); }
@media (hover: hover) and (pointer: fine) { .btn.primary:hover { background: color-mix(in srgb, var(--accent-fill) 86%, #000); } }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.danger { color: var(--bad); }
.btn.danger.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 32px; padding: 0; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn .kbd { font-size: 11px; color: var(--ink-3); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; line-height: 16px; }

.seg { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--hover); border: 1px solid var(--line); }
.seg button { height: 28px; padding: 0 12px; border: 0; background: transparent; border-radius: 6px; color: var(--ink-2); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background-color 120ms ease, color 120ms ease; }
.seg button[aria-pressed='true'] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 0 0 1px var(--line); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-weight: 500; font-size: 13px; cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease, transform 160ms var(--ease-out);
}
.chip:active { transform: scale(0.97); }
.chip .n { color: var(--ink-3); font-weight: 500; }
.chip[aria-pressed='true'] { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent-ink); }
.chip[aria-pressed='true'] .n { color: inherit; }

.input, .select, textarea.input {
  height: 32px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); min-width: 0;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
textarea.input { height: auto; padding: 8px 10px; resize: vertical; }
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.search { position: relative; flex: 1; min-width: 180px; max-width: 360px; }
.search svg { position: absolute; left: 10px; top: 9px; color: var(--ink-3); }
.search .input { width: 100%; padding-left: 32px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.field .hint { font-size: 12px; color: var(--ink-3); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.form-foot { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1; }
.toolbar .chips { flex: 1 1 100%; min-width: 0; }
.cols { position: relative; }
.cols > summary { list-style: none; }
.cols > summary::-webkit-details-marker { display: none; }
.cols > div { right: 0; top: calc(100% + 4px); }

/* --- Статусы: точка + слово, никогда только цвет ------------------------- */

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 500; white-space: nowrap; color: var(--ink-2); }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex-shrink: 0; }
.status.good::before { background: var(--good); }
.status.warn::before { background: var(--warn-dot); }
.status.bad::before { background: var(--bad); }
.status.info::before { background: var(--accent); }
.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--hover); color: var(--ink-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag.accent { background: var(--accent-soft); color: var(--accent-ink); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.good { background: var(--good-soft); color: var(--good); }

/* --- Таблицы ---------------------------------------------------------------- */

/* Без своей прокрутки: иначе липкая шапка отсчитывала бы отступ от обёртки и
   наезжала на первую строку. Прокрутка — только на средних ширинах (ниже). */
.table-wrap { min-width: 0; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data th {
  position: sticky; top: 61px; z-index: 2; text-align: left; font-weight: 500; color: var(--ink-3); font-size: 12.5px;
  padding: 9px 12px; background: var(--surface); border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data th.sortable { cursor: pointer; user-select: none; }
@media (hover: hover) and (pointer: fine) { table.data th.sortable:hover { color: var(--ink); } }
table.data th[aria-sort] { color: var(--ink); }
table.data th .arrow { display: inline-block; margin-left: 4px; opacity: 0.8; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td:first-child, table.data th:first-child { padding-left: 20px; }
table.data td:last-child, table.data th:last-child { padding-right: 20px; }
table.data .num { text-align: right; white-space: nowrap; }
table.data tbody tr.clickable { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { table.data tbody tr.clickable:hover td { background: var(--hover); } }
.cell-main { font-weight: 500; }
.cell-sub { color: var(--ink-3); font-size: 12px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12.5px; }
.empty { padding: 36px 20px; text-align: center; color: var(--ink-2); }
.empty b { display: block; color: var(--ink); font-size: 14px; margin-bottom: 4px; }
.empty p { margin: 0 auto; max-width: 52ch; }

.meter { display: inline-flex; align-items: center; gap: 8px; }
.meter i { display: block; width: 48px; height: 4px; border-radius: 2px; background: var(--hover); overflow: hidden; position: relative; }
.meter i b { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 2px; }
.meter.full i b { background: var(--warn-dot); }
.risk-bar { display: inline-flex; align-items: center; gap: 8px; }
.risk-bar i { width: 64px; height: 6px; border-radius: 3px; background: var(--hover); position: relative; overflow: hidden; }
.risk-bar i b { position: absolute; inset: 0 auto 0 0; background: var(--bad); border-radius: 3px; }
.risk-bar.low i b { background: var(--warn-dot); }

/* --- Графики ------------------------------------------------------------------ */

.chart { position: relative; width: 100%; }
.chart svg { width: 100%; height: auto; overflow: visible; }
.chart .axis-label { fill: var(--ink-3); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .crosshair { stroke: var(--line-strong); stroke-width: 1; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 140px; padding: 8px 10px; border-radius: 8px;
  background: var(--raised); border: 1px solid var(--line); box-shadow: var(--shadow-pop); font-size: 12.5px; color: var(--ink); white-space: nowrap;
}
.tip .t { color: var(--ink-3); margin-bottom: 4px; }
.tip .r { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tip .r span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.tip .r i { width: 8px; height: 8px; border-radius: 2px; }
.tip .r b { font-weight: 600; }
.chart-empty { display: grid; place-items: center; height: 160px; color: var(--ink-3); font-size: 13px; border: 1px dashed var(--line); border-radius: var(--r); }

.barlist { display: flex; flex-direction: column; gap: 8px; }
.barlist .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.barlist .row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.barlist .row .val { font-weight: 600; text-align: right; }
.barlist .row .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--hover); position: relative; overflow: hidden; }
.barlist .row .track b { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--series-1); }
.barlist .row.hl .name { color: var(--ink); font-weight: 500; }

.funnel { display: flex; flex-direction: column; }
.f-step { display: grid; grid-template-columns: 210px minmax(0, 1fr) 132px; gap: 16px; align-items: center; padding: 9px 20px; }
.f-step + .f-step { border-top: 1px dashed var(--line); }
.f-name { font-weight: 500; }
.f-bar { height: 22px; background: var(--hover); border-radius: 4px; position: relative; overflow: hidden; }
.f-bar b { position: absolute; inset: 0 auto 0 0; background: var(--series-1); border-radius: 4px; }
.f-num { text-align: right; }
.f-num b { font-weight: 600; font-size: 15px; }
.f-num span { display: block; font-size: 12px; color: var(--ink-3); }
.f-num span.drop { color: var(--bad); }

/* Тепловая карта — компактная: на всю ширину ячейки терялись в широких колонках. */
.heat { width: 100%; max-width: 640px; table-layout: fixed; border-collapse: separate; border-spacing: 3px; font-size: 12.5px; }
.heat th:first-child { width: 132px; }
.heat th:nth-child(2) { width: 84px; }
.heat th { color: var(--ink-3); font-weight: 500; text-align: center; padding: 4px; white-space: nowrap; }
.heat th:first-child, .heat td:first-child { text-align: left; }
.heat td { padding: 0; }
.heat td.lbl { padding: 6px 8px 6px 0; white-space: nowrap; color: var(--ink-2); }
.heat .cell { height: 34px; border-radius: 6px; display: grid; place-items: center; font-weight: 600; font-size: 12.5px; position: relative; }
.heat .cell.partial::after { content: ''; position: absolute; inset: 2px; border: 1px dashed currentColor; border-radius: 4px; opacity: 0.45; }
.heat .cell.none { color: var(--ink-3); font-weight: 400; background: transparent; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 9px 20px; border-top: 1px solid var(--line); font-size: 13px; }
.feed li:first-child { border-top: 0; }
.feed time { color: var(--ink-3); white-space: nowrap; }
.feed .what { overflow-wrap: anywhere; }
.feed .what a { color: inherit; }
.quote { margin: 0; padding: 12px 20px; border-top: 1px solid var(--line); }
.quote:first-child { border-top: 0; }
.quote p { margin: 0 0 4px; }
.quote footer { font-size: 12px; color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; }

.sysline { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: var(--r); border: 1px solid var(--line); background: var(--surface); margin-top: 16px; font-size: 13px; flex-wrap: wrap; }
.sysline.bad { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }

/* --- Карточка справа (клиент, ключ) --------------------------------------- */

.scrim { position: fixed; inset: 0; background: var(--scrim); z-index: 40; opacity: 0; transition: opacity 200ms ease; }
.scrim.open { opacity: 1; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 41; background: var(--surface);
  border-left: 1px solid var(--line); box-shadow: var(--shadow-drawer); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform 180ms var(--ease-out); visibility: hidden;
}
.drawer.open { transform: none; transition: transform 240ms var(--ease-drawer); visibility: visible; }
.drawer-head { display: flex; align-items: flex-start; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head .who { flex: 1; min-width: 0; }
.drawer-head h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.drawer-head .meta { color: var(--ink-3); font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.drawer-body { overflow-y: auto; padding: 4px 0 32px; flex: 1; overscroll-behavior: contain; }
.d-sec { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.d-sec:last-child { border-bottom: 0; }
.d-sec h4 { margin: 0 0 10px; font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.d-sec h4 span { font-weight: 400; color: var(--ink-3); font-size: 12px; }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; }
.facts .k { font-size: 12px; color: var(--ink-3); }
.facts .v { font-weight: 500; overflow-wrap: anywhere; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; }
.dev { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.dev:first-of-type { border-top: 0; }
.dev .t { font-weight: 500; }
.dev .s { color: var(--ink-3); font-size: 12px; }
.inline-form { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface-2); margin-top: 10px; }
.inline-form .btns { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.keybox { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.keybox .mono { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; flex-shrink: 0; }

/* --- Поиск Cmd/Ctrl+K: без анимации — им пользуются десятки раз в день ---- */

.palette { position: fixed; inset: 0; z-index: 60; background: var(--scrim); display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; }
.palette.open { display: flex; }
.palette-box { width: min(620px, 100%); background: var(--raised); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); overflow: hidden; }
.palette-box .search { max-width: none; }
.palette-box .search .input { height: 48px; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding-left: 42px; font-size: 15px; box-shadow: none; }
.palette-box .search svg { left: 16px; top: 16px; }
.palette-list { max-height: 50vh; overflow-y: auto; overscroll-behavior: contain; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.palette-item[aria-selected='true'] { background: var(--accent-soft); }
.palette-item .ti { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .su { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.palette-item .txt { min-width: 0; flex: 1; }
.palette-item svg { color: var(--ink-3); }
.palette-hint { padding: 8px 14px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12px; }

/* --- Уведомления --------------------------------------------------------- */

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  background: var(--ink); color: var(--canvas); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-pop); font-size: 13px; max-width: 420px;
  transition: opacity 200ms ease, transform 200ms var(--ease-out);
}
@starting-style { .toast { opacity: 0; transform: translateY(8px); } }
.toast.bad { background: var(--bad); color: #fff; }
.toast.leaving { opacity: 0; transform: translateY(8px); transition-duration: 150ms; }

/* --- Загрузка: скелет на месте данных, без спиннера посреди экрана ------- */

.sk { background: linear-gradient(90deg, var(--hover) 0%, var(--line) 50%, var(--hover) 100%); background-size: 200% 100%; border-radius: 6px; animation: sk 1.4s ease-in-out infinite; }
@keyframes sk { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.sk-line { height: 12px; margin: 8px 0; }
.sk-block { height: 180px; }
.error-box { padding: 24px 20px; border: 1px solid color-mix(in srgb, var(--bad) 30%, var(--line)); border-radius: var(--r-lg); background: var(--surface); }
.error-box b { color: var(--bad); }

/* --- Вход ------------------------------------------------------------------ */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login form { width: min(360px, 100%); display: grid; gap: 14px; }
.login h1 { margin: 0; font-size: 20px; font-weight: 600; }
.login p { margin: 0; color: var(--ink-2); }
.login .err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* --- Адаптивность: 390 px — телефон, без горизонтальной прокрутки --------- */

@media (max-width: 1180px) {
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .table-wrap { overflow-x: auto; }
  table.data th { position: static; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1023px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { position: fixed; z-index: 50; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); transition: transform 200ms var(--ease-out); box-shadow: var(--shadow-pop); visibility: hidden; }
  .nav.open { transform: none; visibility: visible; transition: transform 240ms var(--ease-drawer); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; gap: 8px; }
  .topbar-title { display: block; }
  .view { padding: 4px 16px 48px; }
  table.data th { top: 53px; }
}
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(4n) { border-right: 1px solid var(--line); }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi:nth-last-child(-n + 4) { border-bottom: 1px solid var(--line); }
  .kpi:nth-last-child(-n + 2) { border-bottom: 0; }
  .kpi { padding: 14px 14px 12px; }
  .kpi-value { font-size: 22px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 21px; }
  .panel-head { padding: 14px 16px 0; }
  .panel-body { padding: 12px 16px 16px; }
  .toolbar { padding: 12px 16px; }
  .queue li { padding: 12px 16px; grid-template-columns: 24px minmax(0, 1fr); }
  .queue .q-actions { grid-column: 2; justify-content: flex-start; }
  .f-step { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 10px 16px; }
  .f-step .f-bar { grid-column: 1 / -1; grid-row: 2; }
  .feed li { grid-template-columns: minmax(0, 1fr); gap: 2px; padding: 10px 16px; }
  .facts { grid-template-columns: minmax(0, 1fr); }
  /* Период на телефоне — своей строкой во всю ширину: в одной строке с кнопками он не помещался. */
  .topbar { flex-wrap: wrap; row-gap: 8px; }
  .period-wrap { order: 10; flex-basis: 100%; }
  .period-wrap .seg { display: flex; width: 100%; }
  .period-wrap .seg button { flex: 1; padding: 0 4px; }
  .updated { display: none; }
  /* Таблица на телефоне — карточки: строка становится блоком, подписи из data-label. */
  table.data.cards thead { display: none; }
  table.data.cards, table.data.cards tbody, table.data.cards tr, table.data.cards td { display: block; width: 100%; }
  table.data.cards tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  table.data.cards tr:last-child { border-bottom: 0; }
  table.data.cards td { border: 0; padding: 3px 0 !important; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.data.cards td::before { content: attr(data-label); color: var(--ink-3); font-size: 12.5px; text-align: left; flex-shrink: 0; }
  table.data.cards td.lead { display: block; text-align: left; padding-bottom: 6px !important; }
  table.data.cards td.lead::before { content: none; }
  table.data.cards .num { text-align: right; }
  .drawer { width: 100vw; }
  .toasts { left: 16px; right: 16px; align-items: stretch; }
}
@media (max-width: 420px) {
  .topbar .btn .label { display: none; }
  .seg button { padding: 0 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .drawer, .drawer.open, .nav, .nav.open { transition: none; }
  .btn:active, .chip:active { transform: none; }
  .sk { animation: none; }
  .toast { transition: opacity 120ms ease; }
}
