/* Панель отчётов — data-dense dashboard.
   Без сборщика и без внешних CDN: шрифты системные, иконки — инлайн-SVG Lucide. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  color-scheme: light;
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --surface-2: #f8fafc;
  --ink:       #0f172a;
  --ink-2:     #334155;
  --muted:     #5a6875;   /* 5.22 на --bg, 5.72 на белом (было 4.34 — не проходило) */
  --line:      #e2e8f0;
  --line-2:    #cbd5e1;

  --brand:     #1e40af;
  --brand-2:   #3b82f6;
  --brand-sub: #dbeafe;
  --accent:    #b45309;   /* текст-акцент на светлом */
  --accent-sub:#fef3c7;
  --ch-sent:   #2563eb;   /* ΔE 31 к ошибкам при дальтонизме, >3:1 к фону */
  --ch-err:    #b91c1c;
  --btn-pri-bg: #1e40af;  --btn-pri-ink: #ffffff;   /* 8.72 */
  --btn-acc-bg: #b45309;  --btn-acc-ink: #ffffff;   /* 5.02 */

  --ok:        #15803d;
  --ok-sub:    #dcfce7;
  --warn:      #b45309;
  --warn-sub:  #fef3c7;
  --err:       #b91c1c;
  --err-sub:   #fee2e2;

  --deep:      #0f2540;
  --shadow:    0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.05);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.18);
  --r:  10px;
  --r-lg: 14px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --z-modal: 50; --z-toast: 60;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0b1220;
  --surface:   #131c2e;
  --surface-2: #18233a;
  --ink:       #e8eefb;
  --ink-2:     #c2cfe4;
  --muted:     #8b9bb4;
  --line:      #24314c;
  --line-2:    #33415f;

  --brand:     #60a5fa;
  --brand-2:   #3b82f6;
  --brand-sub: #1c2d4d;
  --accent:    #fbbf24;
  --accent-sub:#3a2e12;
  /* В тёмной теме заливка кнопок светлая, поэтому текст на ней — тёмный. */
  --ch-sent:   #3b82f6;   /* своя пара под тёмный фон, не автоинверсия светлой */
  --ch-err:    #ef4444;
  --btn-pri-bg: #2563eb;  --btn-pri-ink: #ffffff;   /* 5.17 */
  --btn-acc-bg: #fbbf24;  --btn-acc-ink: #0b1220;   /* 11.22 */

  --ok:        #4ade80;  --ok-sub:   #12301f;
  --warn:      #fbbf24;  --warn-sub: #3a2e12;
  --err:       #f87171;  --err-sub:  #3b1717;

  --deep:      #0a1120;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  --shadow-lg: 0 12px 44px rgba(0,0,0,.55);
}

/* Тема не выбрана явно — идём за системной настройкой. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  color-scheme: dark;
  --bg:        #0b1220;
  --surface:   #131c2e;
  --surface-2: #18233a;
  --ink:       #e8eefb;
  --ink-2:     #c2cfe4;
  --muted:     #8b9bb4;
  --line:      #24314c;
  --line-2:    #33415f;

  --brand:     #60a5fa;
  --brand-2:   #3b82f6;
  --brand-sub: #1c2d4d;
  --accent:    #fbbf24;
  --accent-sub:#3a2e12;
  /* В тёмной теме заливка кнопок светлая, поэтому текст на ней — тёмный. */
  --ch-sent:   #3b82f6;   /* своя пара под тёмный фон, не автоинверсия светлой */
  --ch-err:    #ef4444;
  --btn-pri-bg: #2563eb;  --btn-pri-ink: #ffffff;   /* 5.17 */
  --btn-acc-bg: #fbbf24;  --btn-acc-ink: #0b1220;   /* 11.22 */

  --ok:        #4ade80;  --ok-sub:   #12301f;
  --warn:      #fbbf24;  --warn-sub: #3a2e12;
  --err:       #f87171;  --err-sub:  #3b1717;

  --deep:      #0a1120;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  --shadow-lg: 0 12px 44px rgba(0,0,0,.55);
}
}

html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }

/* Размер по умолчанию для любой иконки. Без него SVG без width/height
   разворачивается на 300x150 — правило нужно раньше всех частных. */
svg { width: 16px; height: 16px; flex: 0 0 auto; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }

/* ── шапка ─────────────────────────────────────────────────────────────── */
.top { background: var(--deep); color: #fff; position: sticky; top: 0; z-index: 20;
       box-shadow: 0 1px 0 rgba(255,255,255,.06); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 20px;
          display: flex; align-items: center; gap: 18px; height: 58px; }

/* ── прокрутка ─────────────────────────────────────────────────────────────
   Системный скроллбар в тёмной теме выглядит инородно, а в светлой съедает
   14px и рисуется поверх содержимого. Делаем тонкий, в цветах панели —
   одинаково во всех прокручиваемых местах: таблицы, лента шагов, список
   в выпадашке, тело модалки. */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px;
  border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* Лента шагов тёмная — на ней светлый ползунок читается лучше. */
.steps { scrollbar-color: #4a5f7d transparent; }
.steps::-webkit-scrollbar-thumb { background: #4a5f7d; background-clip: content-box; }
.steps::-webkit-scrollbar-thumb:hover { background: #6b82a3; background-clip: content-box; }

.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto;
        scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 8px;
       color: #9dbde0; text-decoration: none; font-size: 14px; font-weight: 500;
       white-space: nowrap; transition: background .18s, color .18s; cursor: pointer; }
.tab svg { width: 16px; height: 16px; }
.tab:hover { background: rgba(255,255,255,.08); color: #fff; }
.tab.on { background: rgba(255,255,255,.14); color: #fff; }
.tab:focus-visible { outline: 2px solid #7fa8d9; outline-offset: 1px; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 9px; border: 0; cursor: pointer;
  background: rgba(255,255,255,.1); color: #cfe0f5; transition: background .18s; }
.icon-btn:hover { background: rgba(255,255,255,.2); }
.icon-btn svg { width: 17px; height: 17px; }

/* ── каркас ────────────────────────────────────────────────────────────── */
.wrap { max-width: 1240px; margin: 0 auto; padding: 22px 20px 70px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between;
             gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 21px; letter-spacing: -.015em; }
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 3px; }

.card { background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--r-lg); box-shadow: var(--shadow); margin-bottom: 18px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px;
          padding: 15px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h h2 { margin: 0; font-size: 12.5px; font-weight: 700; letter-spacing: .09em;
             text-transform: uppercase; color: var(--muted); }
.card-b { padding: 18px; }
.card-b.flush { padding: 0; }

/* ── KPI ───────────────────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
        gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
       padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--brand-2); }
.kpi.is-err::after { background: var(--err); }
.kpi.is-ok::after  { background: var(--ok); }
.kpi.is-warn::after{ background: var(--accent); }
.kpi-l { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.kpi-l svg { width: 14px; height: 14px; }
.kpi-v { font-size: 30px; font-weight: 700; letter-spacing: -.025em; margin-top: 3px;
         font-variant-numeric: tabular-nums; }
.kpi-v small { font-size: 16px; font-weight: 400; color: var(--muted); }
.kpi-s { font-size: 12px; color: var(--muted); margin-top: 2px; min-height: 17px; }

/* ── таблицы ───────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
           color: var(--muted); font-weight: 600; padding: 11px 14px;
           background: var(--surface-2); border-bottom: 1px solid var(--line); }
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--line); font-size: 14px;
           vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: var(--surface-2); }
.r { text-align: right; }
.c { text-align: center; }
.dom { font-weight: 600; color: var(--ink); }
.sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.tbl-scroll { overflow-x: auto; }

/* ── бейджи и кнопки ───────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600;
        padding: 4px 10px; border-radius: 20px; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; }
.p-ok   { background: var(--ok-sub);   color: var(--ok); }
.p-err  { background: var(--err-sub);  color: var(--err); }
.p-warn { background: var(--warn-sub); color: var(--warn); }
.p-mut  { background: var(--surface-2);color: var(--muted); border: 1px solid var(--line); }
.p-brand{ background: var(--brand-sub);color: var(--brand); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: 600 13.5px/1 -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 9px 15px; min-height: 38px; border-radius: 9px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .18s, border-color .18s, color .18s, opacity .18s; }
.btn svg { width: 15px; height: 15px; }
.btn:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.btn-pri { background: var(--btn-pri-bg); color: var(--btn-pri-ink); }
.btn-pri:hover { filter: brightness(1.12); }
.btn-acc { background: var(--btn-acc-bg); color: var(--btn-acc-ink); }
.btn-acc:hover { filter: brightness(1.1); }
.btn-gho { background: var(--surface); color: var(--ink-2); border-color: var(--line-2); }
.btn-gho:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-dan { background: var(--surface); color: var(--err); border-color: var(--err); }
.btn-dan:hover { background: var(--err-sub); }
.btn-sm { min-height: 32px; padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.loading { position: relative; color: transparent !important; }
.btn.loading::after { content: ""; position: absolute; width: 15px; height: 15px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  animation: spin .7s linear infinite; }
.btn-pri.loading::after { color: var(--btn-pri-ink); }
.btn-acc.loading::after { color: var(--btn-acc-ink); }
.btn-gho.loading::after, .btn-dan.loading::after { color: var(--ink-2); }
@keyframes spin { to { transform: rotate(360deg); } }
/* Действия — в одну строку. Перенос делал из четырёх кнопок два неровных
   ряда; таблица и так умеет прокручиваться вбок, а на узком экране перенос
   возвращается — там он уместен. */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
/* Кнопки действий не переносим и на телефоне: таблица прокручивается
   вбок целиком, а лесенка из кнопок в строке выглядит поломкой. */

/* Примечание к строке — во всю ширину под ней, без верхней границы:
   визуально это продолжение той же строки. */
tr.note-row > td { border-top: 0; padding-top: 0; }
tr.note-row .sub { margin-top: 0; }

/* ── сводка по месяцам ─────────────────────────────────────────────────────
   Цифрами, не столбиками: значение — «сколько из скольких», одно число на
   месяц. Цвет тут подсказка, а не носитель смысла: он продублирован подписью. */
.months { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; }
.mcell { display: flex; flex-direction: column; gap: 1px; padding: 9px 4px 8px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--surface);
  text-decoration: none; color: inherit; text-align: center; min-width: 0;
  transition: border-color .16s, background .16s; position: relative; overflow: hidden; }
.mcell::before { content: ""; position: absolute; inset: auto 0 0 0; height: 3px;
  background: var(--line-2); }
.mcell:hover { border-color: var(--line-2); background: var(--surface-2); }
.mcell:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }

.m-lab { font-size: 11px; color: var(--muted); text-transform: capitalize;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-val { font-size: 18px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.m-val span { font-size: 12.5px; font-weight: 400; color: var(--muted); }

.mcell.is-ok::before   { background: var(--ch-sent); }
.mcell.is-part::before { background: var(--line-2); }
.mcell.is-err::before  { background: var(--ch-err); }
.mcell.is-err .m-note  { color: var(--ch-err); }
.mcell.is-none { background: var(--surface-2); }
.mcell.is-none .m-val { color: var(--line-2); font-weight: 400; }
@media (max-width: 1000px) { .months { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 560px)  { .months { grid-template-columns: repeat(4, 1fr); } }

.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted);
  margin-top: 14px; flex-wrap: wrap; align-items: center; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px;
  margin-right: 6px; vertical-align: -1px; background: var(--line-2); }
.lg-ok { background: var(--ch-sent) !important; }
.lg-err { background: var(--ch-err) !important; }
.lg-part { background: var(--line-2) !important; }

/* ── архив ─────────────────────────────────────────────────────────────── */
.arch { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.arch-c { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
          padding: 15px 16px; box-shadow: var(--shadow); transition: border-color .18s, transform .18s; }
.arch-c:hover { border-color: var(--brand-2); transform: translateY(-1px); }
.arch-c.empty { opacity: .55; border-style: dashed; box-shadow: none; }
.arch-p { font-weight: 700; font-size: 15px; }
.arch-n { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.arch-bar { display: flex; gap: 2px; height: 6px; margin: 11px 0 10px; border-radius: 3px; overflow: hidden; }
.arch-bar span { display: block; }
.arch-links { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── формы ─────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
               margin-bottom: 5px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.45; }
input[type=text], input[type=email], input[type=password], input[type=search],
select, textarea {
  width: 100%; padding: 9px 12px; font: 14px/1.4 inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 9px;
  transition: border-color .18s, box-shadow .18s; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--brand-2);
  box-shadow: 0 0 0 3px var(--brand-sub); }
input[aria-invalid="true"] { border-color: var(--err); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── фильтр над таблицей ───────────────────────────────────────────────────
   Поиск растянут на всю свободную ширину: он тут главный, а статус —
   уточнение. На узком экране строка переносится, таблица не ломается. */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; border-bottom: 1px solid var(--line); }
.search { position: relative; flex: 1 1 220px; min-width: 180px; }
.search > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 34px; min-height: 38px; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.filter-bar .csel { flex: 0 0 auto; }
.filter-bar .csel-btn { min-width: 150px; justify-content: space-between; }
/* Кнопка сброса — той же высоты, что поиск и селект слева: разнобой
   по высоте в одной строке видно сразу. */
.filter-bar .btn { flex: 0 0 auto; min-height: 38px; }

tbody tr[hidden] { display: none; }

/* ── выбор строк и массовые действия ───────────────────────────────────────
   Полоса появляется только когда что-то выбрано: пустая панель с мёртвыми
   кнопками — шум. */
td.pick, th.pick { width: 38px; padding-right: 0; text-align: center; }
td.pick input, th.pick input { width: 17px; height: 17px; cursor: pointer;
  accent-color: var(--brand); }
tr:has(input.rp-pick:checked),
tr:has(input.rp-pick:checked) + tr.note-row { background: var(--brand-sub); }

.bulk { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); }
.bulk[hidden] { display: none; }
.bulk-n { font-size: 13.5px; color: var(--ink-2); }
.bulk-n b { font-variant-numeric: tabular-nums; }

/* Свёрнутая задача — плашка внизу. Свернуть должно означать «не мешай»,
   а не «забудь про неё». */
.chips { position: fixed; left: 18px; bottom: 18px; z-index: 40;
  display: flex; flex-direction: column; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 9px 14px; min-height: 38px; border-radius: 999px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg); font: 600 13px/1 inherit; }
.chip:hover { border-color: var(--muted); }
.chip:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.chip .spinner { width: 14px; height: 14px; }

/* прогресс задачи */
.prog { height: 6px; border-radius: 3px; background: var(--surface-2);
  border: 1px solid var(--line); overflow: hidden; margin: 2px 0 12px; }
.prog i { display: block; height: 100%; background: var(--brand);
  transition: width .25s; }
.prog-t { font-size: 13px; color: var(--muted); margin-bottom: 6px;
  font-variant-numeric: tabular-nums; }

/* ── модалка ───────────────────────────────────────────────────────────── */
.ov[hidden] { display: none; }   /* .ov задаёт display:flex — без этого [hidden] не сработает */
.ov { position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(2px);
      display: flex; align-items: center; justify-content: center; padding: 20px;
      z-index: var(--z-modal); animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
  animation: pop .2s cubic-bezier(.2,.9,.3,1.2); }
.modal.wide { max-width: 820px; }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-h { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-h h3 { margin: 0; font-size: 16px; }
.modal-b { padding: 20px; overflow-y: auto; }
.modal-f { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px;
  border-top: 1px solid var(--line); flex-wrap: wrap; }
.x { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 6px;
     border-radius: 7px; display: inline-flex; }
.x:hover { background: var(--surface-2); color: var(--ink); }
.x svg { width: 18px; height: 18px; }

/* ── тосты ─────────────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column;
          gap: 10px; z-index: var(--z-toast); max-width: min(400px, calc(100vw - 36px)); }
.toast { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--brand-2);
  border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 13px 15px;
  display: flex; gap: 11px; align-items: flex-start; animation: slide .22s ease; }
@keyframes slide { from { transform: translateX(14px); opacity: 0; } }
.toast.ok  { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast svg { width: 17px; height: 17px; flex: 0 0 auto; margin-top: 1px; }
.toast.ok svg { color: var(--ok); } .toast.err svg { color: var(--err); }
.toast-t { font-weight: 600; font-size: 13.5px; }
.toast-m { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.45; word-break: break-word; }

/* ── прогресс задачи ───────────────────────────────────────────────────── */
.steps { background: var(--deep); border-radius: var(--r); padding: 13px 15px;
  font: 12.5px/1.7 var(--mono); color: #cfe0f5; max-height: 240px; overflow-y: auto; }
.steps div { display: flex; gap: 10px; }
.steps .t { color: #6f8bb0; flex: 0 0 auto; }
.spinner { width: 15px; height: 15px; border: 2px solid var(--line-2);
  border-top-color: var(--brand-2); border-radius: 50%; animation: spin .7s linear infinite;
  display: inline-block; vertical-align: -2px; }

/* ── мелочи ────────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; opacity: .35; margin-bottom: 12px; }
.warn-box { background: var(--warn-sub); border: 1px solid var(--accent); border-radius: var(--r);
  padding: 13px 15px; font-size: 13.5px; color: var(--ink-2); margin-bottom: 16px;
  display: flex; gap: 10px; }
.warn-box svg { width: 17px; height: 17px; color: var(--accent); flex: 0 0 auto; margin-top: 1px; }
.err-box { background: var(--err-sub); border: 1px solid var(--err); border-radius: var(--r);
  padding: 13px 15px; margin-bottom: 16px; }
.err-box b { color: var(--err); font-size: 13.5px; }
.err-row { padding: 8px 0; border-top: 1px solid rgba(185,28,28,.25); font-size: 13px; }
.err-row:first-of-type { border-top: 0; }
.danger-zone { border-color: var(--err) !important; }
code, kbd { background: var(--surface-2); border: 1px solid var(--line);
  padding: 2px 6px; border-radius: 5px; font: 12.5px var(--mono); }
.spread { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.gap { flex: 1; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

@media (max-width: 760px) {
  .hide-s { display: none !important; }
  .wrap { padding: 16px 14px 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── свой select (D9) ───────────────────────────────────────────────────────
   Нативный список опций рисует ОС и через CSS он не стилизуется, поэтому
   настоящий <select> прячем (он остаётся источником значения), а рядом —
   свой listbox в теме панели. */
.csel { position: relative; display: inline-block; }
.csel-native { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.csel-btn { display: inline-flex; align-items: center; gap: 9px; min-height: 38px;
  padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); cursor: pointer;
  font: 500 14px/1 -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: border-color .18s, box-shadow .18s; }
.csel-btn:hover { border-color: var(--muted); }
.csel-btn:focus-visible { outline: 0; border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-sub); }
.csel-chev { color: var(--muted); transition: transform .18s; }
.csel-btn[aria-expanded="true"] .csel-chev { transform: rotate(180deg); }
.csel-list { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; min-width: 100%;
  max-height: 290px; overflow-y: auto; margin: 0; padding: 5px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: var(--shadow-lg); }
.csel-opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .13s; }
.csel-opt:hover, .csel-opt.on { background: var(--surface-2); }
.csel-opt[aria-selected="true"] { color: var(--brand); font-weight: 600; }
.csel-tick { width: 15px; display: inline-flex; color: var(--brand); opacity: 0; }
.csel-tick svg { width: 15px; height: 15px; }
.csel-opt[aria-selected="true"] .csel-tick { opacity: 1; }

/* Кнопка отправки в модалке — на всю ширину (D54) */
@media (max-width: 520px) {
  .modal-f { flex-direction: column-reverse; }
  .modal-f .btn { width: 100%; }
}

/* ── узкий экран ───────────────────────────────────────────────────────────
   Правила собраны в одном месте: разъезжаться вёрстке проще всего именно
   на телефоне, и искать причину лучше в одном блоке, а не по всему файлу. */
.nav-select { display: none; flex: 1; }
.nav-select .csel { display: block; }
.nav-select .csel-btn { width: 100%; justify-content: space-between;
  background: rgba(255,255,255,.09); color: #ffffff; border-color: rgba(255,255,255,.20); }
.nav-select .csel-btn:hover { border-color: rgba(255,255,255,.36); }
.nav-select .csel-chev { color: #b9cfea; }
/* Белый цвет кнопки в тёмной шапке наследовался списком — пункты выходили
   белым по белому, виден был только выбранный. Цвет списка задаём явно. */
.nav-select .csel-list { color: var(--ink); }
.nav-select .csel-opt { color: var(--ink); }
.nav-select .csel-opt[aria-selected="true"] { color: var(--brand); }

/* Длинные технические строки — пути, домены, куски конфигов — рвём где угодно:
   иначе они утаскивают всю страницу вбок. */
code, .mono, .hint { overflow-wrap: anywhere; }
.spread { flex-wrap: wrap; }
.spread > * { min-width: 0; }

@media (max-width: 620px) {
  .tabs { display: none; }
  .nav-select { display: block; }
  /* Поиск — на всю первую строку, селект и «Сбросить» делят вторую поровну:
     кнопка вдвое меньше соседа выглядит случайной. */
  .search { flex: 1 1 100%; max-width: none; }
  /* Ровно пополам, без надежды на flex-basis: у кнопки своя минимальная
     ширина по содержимому, и она перетягивала одеяло. */
  .filter-bar .csel, .filter-bar .btn {
    flex: 0 0 calc(50% - 5px) !important; width: calc(50% - 5px) !important;
    min-width: 0 !important; }
  .filter-bar .csel-btn { width: 100%; min-width: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  /* Колонка грида по умолчанию не уже своего самого длинного слова —
     а слова здесь технические: пути, имена файлов, домены. */
  .grid-2 > * { min-width: 0; }
  .wrap { padding-left: 12px; padding-right: 12px; }
  .card-b { padding: 14px; }
}

/* ── страница входа ────────────────────────────────────────────────────────
   Отдельная от панели: до входа человек видит только форму — ни вкладок,
   ни данных. Ширина маленькая, всё по центру, тема наследуется общая. */
.login-page { display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px 16px; }
.login { width: 100%; max-width: 360px; text-align: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 30px 26px 24px; box-shadow: var(--shadow-lg); }
.login img { display: block; margin: 0 auto 14px; border-radius: 12px; }
.login h1 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.login-sub { margin: 6px 0 20px; color: var(--muted); font-size: 13.5px; }
.login-form { text-align: left; }
.login-form .btn { width: 100%; margin-top: 4px; }
.login-remember { display: flex; align-items: center; gap: 9px; cursor: pointer;
  font-size: 13.5px; color: var(--ink-2); margin: 2px 0 16px; }
.login-remember input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.login-err { text-align: left; margin-bottom: 16px; }
.login-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
