/* =============================================================================
   ui.css — дизайн-система панели «Мафия Балаган». Единственный файл стилей.

   Заменил app.css (3331 строка, 54 % наслоений) + modal.css + toast.css.
   Правило одно: селектор объявляется ОДИН раз. Проверяет scripts/check_css.py —
   дубли, !important вне [hidden], необъявленные переменные. Не чини каскад
   дописыванием в конец: найди объявление и поправь его.

   Содержание
     1. Токены (тёмная тема — по умолчанию, светлая — [data-theme="light"])
     2. Шрифты и база
     3. Каркас: сайдбар, шапка, контент, три ступени адаптива
     4. Заголовок страницы, панели, KPI-ряд
     5. Кнопки
     6. Таблицы
     7. Статусы, метки, типы игр
     8. Формы, фильтры, поиск
     9. Баннер, алерты, пустое состояние, пагинация
    10. Воронка, столбики
    11. Настройки: действует / выключено
    12. Детали под строкой
    13. Модалка, тосты
    14. Утилиты
    15. Печать и reduced-motion
   ============================================================================= */

@import url("fonts/fonts.css");

/* ============================== 1. ТОКЕНЫ ================================== */
:root {
  color-scheme: dark;

  /* Хвойная палитра — выбор владельца из восьми вариантов (07.09.2026) */
  --bg: #14181A;
  --panel: #1A1F22;
  --panel-2: #212829;
  --raise: #272F30;
  --line: #2A3336;
  --line-soft: #222A2C;

  --ink: #EDF2F0;
  --dim: #A3B5B0;
  --faint: #7A908A;

  /* Кирпичный акцент. В тёмной теме им красятся и заливки, и главные числа;
     в светлой — только заливки (число фонда чёрным): яркий оранжевый текст
     на белом грязнит. Отсюда отдельный --accent-ink. */
  --accent: #D4573C;
  --accent-hover: #C04B31;
  --on-accent: #FFFFFF;
  --accent-ink: var(--accent);
  --accent-soft: color-mix(in oklab, var(--accent), transparent 86%);

  /* Цвета смысла — не акцент. Каждый значит одно и то же на всех страницах. */
  --good: #4FBF8B;
  --bad: #FF6B6B;
  --warn: #E8B84B;
  --info: #5B9DC4;
  --good-soft: color-mix(in oklab, var(--good), transparent 86%);
  --bad-soft: color-mix(in oklab, var(--bad), transparent 86%);
  --warn-soft: color-mix(in oklab, var(--warn), transparent 86%);
  --info-soft: color-mix(in oklab, var(--info), transparent 86%);

  /* Типы игр: чтобы столбец читался по цвету, не по тексту */
  --gt-main: var(--accent);
  --gt-battle: var(--info);
  --gt-kids: var(--warn);
  --gt-corporate: #9B8BC4;
  --gt-other: var(--faint);

  --f-display: "Sofia Sans Extra Condensed", "Arial Narrow", "Segoe UI", Arial, sans-serif;
  --f-body: "Golos Text", "Segoe UI", Arial, sans-serif;
  --f-mono: "JetBrains Mono", Consolas, "Courier New", monospace;

  --sidebar-w: 198px;
  --sidebar-c: 52px;
  --topbar-h: 48px;
  --pad: 14px;
  --radius-pill: 20px;

  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #F4F5F4;
  --panel: #FFFFFF;
  --panel-2: #EAEDEC;
  --raise: #DFE4E2;
  --line: #D6DCDA;
  --line-soft: #E6EAE8;
  --ink: #15191B;
  --dim: #4B5754;
  --faint: #7E8A87;
  --accent-ink: var(--ink);
  --good: #2E8B5F;
  --bad: #C1442C;
  --warn: #A8791A;
  --info: #2E6F94;
  --gt-corporate: #6F5FA6;
  --shadow: 0 12px 32px rgba(20, 25, 27, .16);
}

/* ============================ 2. ШРИФТЫ И БАЗА ============================= */
*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

/* :is() — чтобы общий стиль и размер каждого уровня не были двумя
   объявлениями одного селектора: страж считает это дублем, и по делу */
:is(h1, h2, h3, h4) {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
  line-height: 1.05;
}
h1 { font-size: 26px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; letter-spacing: .05em; }
h4 { font-size: 14px; letter-spacing: .06em; color: var(--dim); }

p { margin: 0 0 .75em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12px; }
code, kbd { font-family: var(--f-mono); font-size: .92em; }
strong, b { font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line-soft); margin: 16px 0; }
img { max-width: 100%; }
svg { display: inline-block; vertical-align: middle; }

:focus-visible { outline: none; box-shadow: var(--focus); }

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

/* ============================== 3. КАРКАС ================================== */
.skip-link {
  position: absolute;
  left: 8px;
  top: -48px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.skip-link:focus { top: 8px; }

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}
html[data-nav="collapsed"] .layout { grid-template-columns: var(--sidebar-c) minmax(0, 1fr); }
.layout-plain { grid-template-columns: minmax(0, 1fr); }

/* --- сайдбар --- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 12px 0;
  overflow: hidden;
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 14px 12px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  min-height: 42px;
  white-space: nowrap;
}
.sidebar-brand:hover { text-decoration: none; }
.brand-mark {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 16px;
}
.brand-name { font-family: var(--f-display); font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; line-height: 1.1; }
.brand-sub { font-family: var(--f-mono); font-size: 8.5px; color: var(--faint); letter-spacing: .16em; text-transform: uppercase; }

.sidebar-nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; }
.sidebar-group { padding: 0 7px; margin-bottom: 8px; }
.sidebar-group-title {
  font-family: var(--f-mono);
  font-size: 8.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 0 7px 4px;
  white-space: nowrap;
}

.sidebar-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 7px;
  color: var(--dim);
  font-size: 12.5px;
  white-space: nowrap;
  border-radius: 0;
}
.sidebar-link:hover { color: var(--ink); background: var(--panel-2); text-decoration: none; }
.sidebar-link.active, .sidebar-link[aria-current="page"] { color: var(--ink); background: var(--panel-2); font-weight: 600; }
.sidebar-link.active::before, .sidebar-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--accent);
}
.sidebar-icon { flex: 0 0 auto; width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-label { overflow: hidden; text-overflow: ellipsis; }
.sidebar-count { margin-left: auto; font-family: var(--f-mono); font-size: 9.5px; color: var(--faint); }

.sidebar-footer {
  margin-top: auto;
  padding: 8px 7px 0;
  border-top: 1px solid var(--line-soft);
  display: grid;
  gap: 2px;
}
.sidebar-footer .sidebar-link { font-size: 11.5px; color: var(--faint); }

/* свёрнутое состояние — только ярлычки */
html[data-nav="collapsed"] .sidebar-brand { padding-left: 0; padding-right: 0; justify-content: center; }
html[data-nav="collapsed"] .brand-text,
html[data-nav="collapsed"] .sidebar-label,
html[data-nav="collapsed"] .sidebar-count { display: none; }
html[data-nav="collapsed"] .sidebar-group { padding: 0 5px; }
html[data-nav="collapsed"] .sidebar-group-title { height: 1px; padding: 0; margin: 3px 4px 7px; background: var(--line-soft); font-size: 0; }
html[data-nav="collapsed"] .sidebar-link { justify-content: center; padding: 7px 0; }
html[data-nav="collapsed"] .sidebar-link.active::before,
html[data-nav="collapsed"] .sidebar-link[aria-current="page"]::before { left: -5px; }

/* --- шапка (только на телефоне) и контент --- */
.layout-main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-h);
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar-title { font-family: var(--f-display); font-weight: 800; font-size: 18px; text-transform: uppercase; letter-spacing: .04em; }
.menu-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--ink);
  cursor: pointer;
  background: var(--panel-2);
}
.menu-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }

.main { flex: 1 1 auto; padding: 16px 20px 28px; min-width: 0; }
.layout-plain .main { max-width: 480px; margin: 0 auto; padding-top: 10vh; }

.sidebar-overlay { display: none; }

/* --- три ступени адаптива: одна точка правды --- */
/* планшет: 641–1023 — меню всегда свёрнуто, кнопка сворачивания спрятана */
@media (max-width: 1023px) {
  .layout { grid-template-columns: var(--sidebar-c) minmax(0, 1fr); }
  .sidebar-brand { padding-left: 0; padding-right: 0; justify-content: center; }
  .brand-text, .sidebar-label, .sidebar-count { display: none; }
  .sidebar-group { padding: 0 5px; }
  .sidebar-group-title { height: 1px; padding: 0; margin: 3px 4px 7px; background: var(--line-soft); font-size: 0; }
  .sidebar-link { justify-content: center; padding: 7px 0; }
  .sidebar-link.active::before, .sidebar-link[aria-current="page"]::before { left: -5px; }
  [data-action="toggle-nav"] { display: none; }
}

/* телефон: ≤640 — сайдбар уезжает за край, открывается бургером (без JS) */
@media (max-width: 640px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .topbar { display: flex; }
  .main { padding: 12px 12px 24px; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: none;
    z-index: 40;
  }
  #menu-switch:checked ~ .layout .sidebar { transform: translateX(0); box-shadow: var(--shadow); }
  #menu-switch:checked ~ .layout .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .55);
    z-index: 35;
  }
  /* в drawer меню всегда развёрнуто — это и есть смысл выдвижной панели */
  .sidebar-brand { padding-left: 14px; padding-right: 14px; justify-content: flex-start; }
  .brand-text, .sidebar-label { display: block; }
  .sidebar-count { display: inline; }
  .sidebar-group { padding: 0 7px; }
  .sidebar-group-title { height: auto; padding: 0 7px 4px; margin: 0; background: none; font-size: 8.5px; }
  .sidebar-link { justify-content: flex-start; padding: 8px 7px; }
  .sidebar-link.active::before, .sidebar-link[aria-current="page"]::before { left: 0; }
}

/* ====================== 4. ЗАГОЛОВОК, ПАНЕЛИ, KPI ========================== */
.page-head, .section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
}
.page-title, .section-title { font-family: var(--f-display); font-weight: 800; font-size: 24px; text-transform: uppercase; letter-spacing: .03em; margin: 0; }
.page-meta, .section-meta, .section-caption { font-family: var(--f-mono); font-size: 10.5px; color: var(--faint); }
.page-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.panel, .table-panel, .card {
  background: var(--panel);
  margin-bottom: 12px;
  min-width: 0;
}
.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 9px;
  padding: 10px var(--pad);
  border-bottom: 1px solid var(--line-soft);
}
.panel-title { font-family: var(--f-display); font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; }
.panel-subtitle { font-family: var(--f-mono); font-size: 10px; color: var(--faint); }
.panel-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; }
.panel-body, .card-body { padding: 12px var(--pad); }
.panel-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 9px var(--pad);
  border-top: 1px solid var(--line-soft);
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--faint);
}
.panel-footer b { color: var(--ink); font-weight: 500; }
.panel--warning { border-left: 3px solid var(--warn); }

/* раскрывающаяся панель: <details class="panel"><summary class="panel-header"> */
details.panel > summary { list-style: none; cursor: pointer; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel:not([open]) > summary { border-bottom: 0; }
details.panel[open] > summary .set-caret { display: inline-block; transform: rotate(90deg); }

.panel-grid, .grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.panel-grid > .panel, .grid-2 > .panel, .grid-3 > .panel { margin-bottom: 0; }
.col-span-2 { grid-column: span 2; }

/* KPI-ряд: одна панель, ячейки через тонкие линии — как на утверждённом макете */
.kpis, .stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--panel); margin-bottom: 12px; }
.kpis--3, .stat-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi, .stat { padding: 13px var(--pad); border-right: 1px solid var(--line-soft); min-width: 0; display: flex; flex-direction: column; }
.kpi:last-child, .stat:last-child { border-right: 0; }
.kpi-label, .stat-label { font-family: var(--f-mono); font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); margin-bottom: 7px; }
.kpi-value, .stat-value { font-family: var(--f-display); font-weight: 800; font-size: 32px; line-height: 1; font-variant-numeric: tabular-nums; letter-spacing: .005em; }
.kpi-value.is-accent { color: var(--accent-ink); font-size: 38px; }
.kpi-value.is-muted { color: var(--faint); }
.kpi-sub, .stat-link { font-size: 11px; color: var(--faint); margin-top: 6px; }
.kpi-row { display: flex; align-items: flex-end; gap: 12px; }

@media (max-width: 900px) {
  .kpis, .stat-row, .kpis--3, .stat-row--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(2n), .stat:nth-child(2n) { border-right: 0; }
  .kpi:nth-child(-n+2), .stat:nth-child(-n+2) { border-bottom: 1px solid var(--line-soft); }
  .panel-grid, .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .col-span-2 { grid-column: auto; }
}

/* =============================== 5. КНОПКИ ================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font: 600 11.5px/1.3 var(--f-body);
  color: var(--dim);
  background: var(--raise);
  border: 1px solid var(--line);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }
.btn-primary, .btn-accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover, .btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost, .btn-secondary { background: transparent; }
.btn-danger, .btn-error { background: transparent; color: var(--bad); border-color: color-mix(in oklab, var(--bad), transparent 70%); }
.btn-danger:hover, .btn-error:hover { background: var(--bad-soft); color: var(--bad); }
.btn-sm { padding: 4px 9px; font-size: 10.5px; }
.btn-xs { padding: 2px 7px; font-size: 10px; }
.btn-icon { padding: 4px; width: 26px; height: 26px; }
.btn-icon svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; }
.btn-block { width: 100%; }
.btn.is-disabled, .btn:disabled, .btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { position: relative; color: transparent; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-color: var(--dim) var(--dim) transparent transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { border-color: var(--on-accent) var(--on-accent) transparent transparent; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }

@keyframes spin { to { transform: rotate(360deg); } }

/* =============================== 6. ТАБЛИЦЫ ================================ */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  font-family: var(--f-mono);
  font-size: 9px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .11em;
  color: var(--faint);
  text-align: left;
  padding: 7px 12px;
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.table td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in oklab, var(--panel-2), transparent 40%); }
.table tfoot th, .table tfoot td, .table-total td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 600; color: var(--ink); }
.table.compact th { padding: 6px 10px; }
.table.compact td { padding: 6px 10px; }
.table.loose td { padding: 11px 12px; }

.table .t-right, .table .text-right, .table .t-num { text-align: right; }
.table .t-center { text-align: center; }
.t-num, .num, .mono { font-family: var(--f-mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.mono em { font-style: normal; color: var(--faint); }

/* строка вне расчёта (ниже порога, отменена) — приглушаем, не прячем */
.row-muted td, tr.is-muted td { color: var(--faint); }
.row-highlight td { background: var(--warn-soft); }

/* Новички сезона: вечеров на странице несколько, у каждого своя таблица.
   Без table-layout: fixed браузер считает колонки для каждой отдельно,
   и поля разъезжаются по горизонтали от вечера к вечеру. */
.table.newcomers { table-layout: fixed; }
.table.newcomers select {
  width: 100%;
  min-width: 0;          /* иначе длинное имя в списке распирает колонку */
}
.table.newcomers td > form { width: 100%; gap: 6px; }

/* Пометка «показано не то, что просили»: жёлтая, не красная — это не
   ошибка, а расхождение запроса с данными. */
.note-warn {
  padding: 11px 14px;
  margin-bottom: 12px;
  background: var(--warn-soft);
  border-left: 3px solid var(--warn);
  font-size: 13px;
  color: var(--dim);
}
tr.is-open td { background: var(--panel-2); border-bottom: 0; }
tr.is-pair td { background: color-mix(in oklab, var(--panel-2), transparent 50%); }
.table td.is-actions { text-align: right; white-space: nowrap; }

.table thead.is-sticky th { position: sticky; top: 0; background: var(--panel); z-index: 2; }

/* ========================= 7. СТАТУСЫ И МЕТКИ ============================== */
.badge, .status-pill, .chip {
  display: inline-block;
  font-family: var(--f-mono);
  font-size: 9.5px;
  letter-spacing: .04em;
  padding: 2px 7px;
  white-space: nowrap;
  background: var(--raise);
  color: var(--faint);
}
.badge-success, .badge-done, .status-pill.is-done { background: var(--good-soft); color: var(--good); }
.badge-warn, .badge-warning, .status-pill.is-planned { background: var(--warn-soft); color: var(--warn); }
.badge-error, .badge-danger, .badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge-muted, .status-pill.is-canceled { background: var(--raise); color: var(--faint); }
.badge-row { display: flex; flex-wrap: wrap; gap: 4px; }

.status { font-weight: 600; }
.status.ok { color: var(--good); }
.status.bad { color: var(--bad); }
.text-good { color: var(--good); }
.text-bad { color: var(--bad); }
.text-warn { color: var(--warn); }
.text-info { color: var(--info); }
.text-accent { color: var(--accent-ink); }

/* тип игры — точка перед названием */
.gt::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--gt-other);
}
.gt-main::before, .gt-secondary::before { background: var(--gt-main); }
.gt-battle::before { background: var(--gt-battle); }
.gt-kids::before, .gt-kids_corporate::before { background: var(--gt-kids); }
.gt-corporate::before, .gt-offsite::before { background: var(--gt-corporate); }

/* день недели после даты: 09.09 ср */
.weekday-hint { font-style: normal; color: var(--faint); font-size: 11px; margin-left: 2px; }

/* привязка строки рейтинга: список тянулся на всю ширину и выдавливал
   кнопку «Привязать» за край таблицы */
.rating-link-form { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.rating-link-select { flex: 1 1 auto; min-width: 0; max-width: 420px; }

/* пометка рядом с именем: «без Telegram», «не работает с сентября» */
.tag-note { font-family: var(--f-mono); font-size: 9px; color: var(--faint); letter-spacing: .06em; text-transform: uppercase; margin-left: 8px; }
/* Подсказка к возможному дублю: что говорит база — один человек или двое.
   Цвет по силе признака: вместе на вечере — точно двое, опечатка и смена
   номера — повод присмотреться, остальное — справочно. */
.dupe-hint { font-size: 12px; color: var(--dim); margin: 4px 0 6px; max-width: 260px; }
.dupe-hint.is-together { color: var(--bad); }
.dupe-hint.is-typo, .dupe-hint.is-moved { color: var(--warn); }
/* Вечера карточки: по ним владелец и узнаёт человека */
.dupe-evenings { list-style: none; margin: 0; padding: 0; font-family: var(--f-mono); font-size: 11px; line-height: 1.5; white-space: nowrap; }

/* ================================ 8. ФОРМЫ ================================= */
.form-row, .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 12px; align-items: end; }
.form-group, .field, .fg-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-grow { flex: 1 1 auto; }
.form-label, .label, .fg-label { font-family: var(--f-mono); font-size: 9px; letter-spacing: .11em; text-transform: uppercase; color: var(--faint); }
.form-hint { font-size: 11px; color: var(--faint); }
.form-error { font-size: 11.5px; color: var(--bad); }
.form-actions, .fg-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

:is(.form-input, .form-select, .form-textarea, .input,
    input[type="text"], input[type="number"], input[type="date"], input[type="time"],
    input[type="password"], input[type="search"], input[type="file"], select, textarea) {
  width: 100%;
  min-width: 0;
  padding: 6px 9px;
  font: 400 12.5px/1.4 var(--f-body);
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 0;
  outline: none;
}
:is(input[type="number"], input[type="date"], input[type="time"], .form-input-sm) { font-family: var(--f-mono); font-size: 12px; }
:is(.form-input, .form-select, .form-textarea, .input, input, select, textarea):focus-visible { border-color: var(--accent); box-shadow: var(--focus); }
:is(input, textarea)::placeholder { color: var(--faint); }
select { appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--faint) 50%), linear-gradient(135deg, var(--faint) 50%, transparent 50%); background-position: calc(100% - 13px) 55%, calc(100% - 9px) 55%; background-size: 4px 4px; background-repeat: no-repeat; }
textarea { min-height: 72px; resize: vertical; }
input[type="file"] { padding: 5px; font-size: 12px; }
input[type="checkbox"], input[type="radio"] { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); flex: 0 0 auto; }

.checkbox, .radio, .form-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--dim);
  cursor: pointer;
  padding: 4px 0;
}
.checkbox:has(input:checked), .form-check:has(input:checked) { color: var(--ink); }

/* тумблер: включённость режима (Общак, сетка ЗП) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--dim); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 30px; height: 16px; border-radius: var(--radius-pill); background: var(--raise); position: relative; transition: background .15s; flex: 0 0 auto; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--faint); transition: transform .15s, background .15s; }
.switch input:checked + .switch-track { background: var(--good); }
.switch input:checked + .switch-track::after { transform: translateX(14px); background: var(--bg); }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }

.status-select { font-family: var(--f-mono); font-size: 11px; }
.status-select.is-done { color: var(--good); }
.status-select.is-planned { color: var(--info); }
.status-select.is-canceled { color: var(--faint); }

/* фильтры и поиск — строка над таблицей внутри панели */
.filters, .panel-filters, .filters-grid, .filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  padding: 10px var(--pad);
  border-bottom: 1px solid var(--line-soft);
}
.filters .form-group, .panel-filters .form-group { flex-direction: row; align-items: center; gap: 6px; }
.filters input, .filters select, .panel-filters input, .panel-filters select { width: auto; }
.filters .form-label, .panel-filters .form-label { margin-right: 2px; }
.search {
  flex: 1 1 160px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.search:focus-within { border-color: var(--accent); }
.search svg { width: 13px; height: 13px; stroke: var(--faint); fill: none; stroke-width: 2; stroke-linecap: round; flex: 0 0 auto; }
.search input { border: 0; padding: 6px 0; background: transparent; }
.search input:focus-visible { box-shadow: none; }
.quick-ranges { display: flex; flex-wrap: wrap; gap: 4px; }

/* ================== 9. БАННЕР, АЛЕРТЫ, ПУСТОТА, ПАГИНАЦИЯ ================== */
.banner, .alert {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 9px 13px;
  margin-bottom: 12px;
  background: var(--panel);
  border-left: 3px solid var(--faint);
  font-size: 12.5px;
  color: var(--dim);
}
.banner b, .alert b { color: var(--ink); }
.banner .btn, .alert .btn { margin-left: auto; }
.alert-warning, .banner-warning { border-left-color: var(--warn); }
.alert-error, .alert-danger, .banner-error { border-left-color: var(--bad); }
.alert-success, .banner-success { border-left-color: var(--good); }
.alert-info, .banner-info { border-left-color: var(--info); }

.empty-state, .empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--faint);
  font-size: 13px;
}
.empty-state-text, .empty-title { font-family: var(--f-display); font-weight: 800; font-size: 18px; text-transform: uppercase; letter-spacing: .04em; color: var(--dim); margin-bottom: 8px; }
.empty-desc { margin-bottom: 12px; }

.pagination { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 9px var(--pad); border-top: 1px solid var(--line-soft); font-family: var(--f-mono); font-size: 11px; }
.pagination .btn { font-family: var(--f-mono); }
.pagination .is-current { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ========================= 10. ВОРОНКА, СТОЛБИКИ =========================== */
.funnel { padding: 12px var(--pad) 6px; }
.funnel-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 84px;
  gap: 10px;
  align-items: center;
  margin-bottom: 9px;
  font-size: 12px;
  color: var(--dim);
}
.funnel-bar { height: 6px; background: var(--panel-2); border-radius: var(--radius-pill); overflow: hidden; }
.funnel-fill { height: 100%; border-radius: var(--radius-pill); background: var(--faint); }
.funnel-fill.is-accent { background: var(--accent); }
.funnel-fill.is-good { background: var(--good); }
.funnel-fill.is-bad { background: var(--bad); }
.funnel-fill.is-warn { background: var(--warn); }
.funnel-value { text-align: right; font-family: var(--f-mono); font-size: 11px; color: var(--ink); font-variant-numeric: tabular-nums; }
.funnel-note { font-size: 11.5px; color: var(--faint); padding: 9px var(--pad) 12px; border-top: 1px solid var(--line-soft); margin: 4px 0 0; }

/* столбики динамики: маленькие — в KPI, большие — на странице фонда */
.bars { display: flex; align-items: flex-end; gap: 2px; height: 30px; margin-left: auto; }
.bars i { display: block; width: 5px; background: var(--raise); }
.bars i.is-hi { background: var(--accent); }
.bars--lg { height: 110px; gap: 5px; margin: 0; padding: 14px var(--pad) 6px; }
.bars--lg i { flex: 1 1 0; width: auto; min-width: 4px; position: relative; }
.bars--lg i b { position: absolute; top: -16px; left: 0; right: 0; text-align: center; font: 400 9px/1 var(--f-mono); color: var(--faint); }
.bars-caption { display: flex; justify-content: space-between; padding: 0 var(--pad) 12px; font-family: var(--f-mono); font-size: 9.5px; color: var(--faint); }

/* накопительная линия фонда — inline SVG, без библиотек */
.chart-wrap { padding: 12px var(--pad) 4px; }
.chart { display: block; width: 100%; height: 150px; }
.chart-area { fill: var(--accent-soft); stroke: none; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }

/* ======================= 11. НАСТРОЙКИ: ВКЛ / ВЫКЛ ========================= */
.set { border-left: 3px solid var(--good); }
.set.is-off { border-left-color: var(--faint); }
.set.is-off .panel-header { border-bottom: 0; }
.set.is-off .panel-title { color: var(--dim); }
.set-caret { color: var(--faint); font-size: 11px; margin-right: 2px; }
.set-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px;
  gap: 12px;
  align-items: center;
  padding: 8px var(--pad);
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.set-row:last-child { border-bottom: 0; }
.set-row small { display: block; color: var(--faint); font-size: 11px; margin-top: 1px; }
.set-row input, .set-row select { text-align: right; }
.set-row input[type="checkbox"] { justify-self: end; }
details.set > summary { list-style: none; cursor: pointer; }
details.set > summary::-webkit-details-marker { display: none; }
details.set[open] .set-caret { transform: rotate(90deg); display: inline-block; }
details.set[open] .panel-header { border-bottom: 1px solid var(--line-soft); }

/* ========================== 12. ДЕТАЛИ ПОД СТРОКОЙ ========================= */
.details-row > td { padding: 0; background: var(--panel-2); border-top: 1px solid var(--line); }
.details {
  padding: 12px var(--pad) 14px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 14px;
  align-items: end;
}
.details-label { font-family: var(--f-mono); font-size: 9px; letter-spacing: .11em; text-transform: uppercase; color: var(--faint); margin-bottom: 5px; }
.details-loading { padding: 12px var(--pad); color: var(--faint); font-size: 12px; }
@media (max-width: 900px) { .details { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 8px var(--pad);
  background: var(--accent-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
}
.bulk-actions b { color: var(--accent-ink); }
.bulk-actions .btn-group { margin-left: auto; }

/* ========================= 13. МОДАЛКА И ТОСТЫ ============================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .6);
  animation: fadeIn .15s ease-out;
}
.modal-backdrop.is-leaving { animation: fadeOut .2s ease-in forwards; }
.modal {
  position: relative;
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  animation: rise .18s ease-out;
}
.modal.is-leaving { animation: sink .2s ease-in forwards; }
.modal-header { display: flex; align-items: center; gap: 10px; padding: 12px var(--pad); border-bottom: 1px solid var(--line-soft); }
.modal-title { font-family: var(--f-display); font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: .06em; margin: 0; }
.modal-close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { color: var(--ink); background: var(--panel-2); }
.modal-body { padding: 14px var(--pad); font-size: 13px; color: var(--dim); }
.modal-footer { display: flex; justify-content: flex-end; gap: 6px; padding: 10px var(--pad); border-top: 1px solid var(--line-soft); }

.toast-container {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 70;
  display: grid;
  gap: 6px;
  width: min(360px, calc(100vw - 28px));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--info);
  box-shadow: var(--shadow);
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  animation: rise .18s ease-out;
}
.toast-leaving { animation: sink .2s ease-in forwards; }
.toast-success { border-left-color: var(--good); }
.toast-error { border-left-color: var(--bad); }
.toast-info { border-left-color: var(--info); }
.toast-message { flex: 1 1 auto; }
.toast-close { border: 0; background: transparent; color: var(--faint); font-size: 16px; line-height: 1; cursor: pointer; padding: 0; }
.toast-close:hover { color: var(--ink); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes sink { to { opacity: 0; transform: translateY(6px); } }

/* ========================= 13b. «СЕГОДНЯ» — КАРТОЧКИ ======================= */
/* Экран под одну задачу: отметить вечер с телефона одним касанием */
.today-nav { gap: 4px; }
.today-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; align-items: start; }
.today-card { background: var(--panel); }
.today-card.is-done { opacity: .82; }
.today-top { display: flex; align-items: baseline; gap: 9px; padding: 11px 13px 8px; }
.today-time { font-family: var(--f-display); font-weight: 800; font-size: 24px; color: var(--accent-ink); line-height: 1; }
.today-type { font-family: var(--f-display); font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: .05em; }
.today-host { margin-left: auto; font-size: 11.5px; color: var(--dim); text-align: right; }
.today-fields { padding: 0 13px 10px; display: grid; gap: 7px; }
.today-field { display: grid; grid-template-columns: minmax(0, 1fr) 84px; gap: 9px; align-items: center; font-size: 12.5px; color: var(--dim); }
.today-field input[type="number"] { font-size: 15px; text-align: center; padding: 7px 8px; }
.today-actions { display: grid; gap: 6px; padding: 0 13px 12px; }
.btn-big { padding: 11px; font-family: var(--f-display); font-weight: 800; font-size: 16px; text-transform: uppercase; letter-spacing: .08em; }
.today-sum { display: grid; gap: 6px; padding: 10px 13px 12px; font-size: 12.5px; color: var(--dim); }
.today-sum > div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.today-sum b { font-weight: 500; color: var(--ink); }

/* ===================== 13c. ВЫПАДАЮЩЕЕ МЕНЮ И ВХОД ======================== */
/* <details class="dropdown"><summary class="btn">…</summary><div class="dropdown-menu"> — без JS */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 25;
  min-width: 220px;
  display: grid;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.dropdown-menu > a { padding: 8px 12px; color: var(--dim); font-size: 12.5px; border-bottom: 1px solid var(--line-soft); }
.dropdown-menu > a:last-child { border-bottom: 0; }
.dropdown-menu > a:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }

.login { width: min(360px, 100%); margin: 0 auto; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-title { font-family: var(--f-display); font-weight: 800; font-size: 22px; text-transform: uppercase; letter-spacing: .04em; line-height: 1; }

/* =============================== 14. УТИЛИТЫ =============================== */
.muted { color: var(--faint); }
.dim { color: var(--dim); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-meta { font-family: var(--f-mono); font-size: 10.5px; color: var(--faint); }
.nowrap { white-space: nowrap; }
.flex { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.flex-between { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.flex-end { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.flex-nowrap { flex-wrap: nowrap; }
.span-all { grid-column: 1 / -1; }
.t-center { text-align: center; }
.inline { display: inline; }
.ml-auto { margin-left: auto; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.full-width { width: 100%; }
.display { font-family: var(--f-display); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }

/* [hidden] обязан побеждать авторский display — иначе панель «Не сохранено»
   висит на чистой странице. Единственный законный !important в файле. */
[hidden] { display: none !important; }
.hidden { display: none; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ===================== 15. ПЕЧАТЬ И REDUCED-MOTION ========================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media print {
  .sidebar, .topbar, .toast-container, #modal-root, .btn, .filters, .pagination { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  body { background: #fff; color: #000; }
  .panel, .kpis { border: 1px solid #ccc; }
}

/* ===================== 16. ВЕДОМОСТЬ ЗП (экран + печать под акт) ======== */
.rep-printonly { display: none; }
.rep-rules { margin: 8px 0 14px; line-height: 1.5; }
.rep-foot { margin-top: 14px; }
.rep-ref td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.rep-sign { margin: 18px 16px 8px; font-size: 13px; }
@media print {
  /* Поля страницы — ноль: в них Chrome печатает свои колонтитулы (дата,
     заголовок, URL), и они выглядели «лишними ссылками». Своё поле даём
     через padding. Альбомный лист: у таблицы десять колонок. */
  @page { size: A4 landscape; margin: 0; }
  .rep-page { padding: 9mm 11mm; }
  .rep-noprint { display: none; }
  .rep-printonly { display: block; }
  .rep-host { border: 0; break-inside: avoid; }
  /* Разрыв только МЕЖДУ ведущими: после последнего пустой лист не нужен */
  .rep-host + .rep-host { break-before: page; page-break-before: always; }
  .rep-head { margin-bottom: 6px; }
  .rep-rules, .rep-foot { color: #333; font-size: 10px; }
  .rep-page .kpis { grid-template-columns: repeat(3, 1fr); }
  .rep-page .kpi { padding: 6px 10px; }
  .rep-page .kpi-value { font-size: 18px; }
  .rep-page .kpi-sub { font-size: 10px; }
  .rep-page .table-responsive { overflow: visible; }
  .rep-page .table { width: 100%; font-size: 11px; }
  .rep-page .table td, .rep-page .table th { padding: 3px 6px; white-space: nowrap; }
  .rep-page .panel-header { padding: 6px 10px; }
  .rep-sign { break-inside: avoid; margin: 10px 0 0; }
}
