/*
  Дизайн-система дашборда.

  ТЁМНАЯ ТЕМА — ОСНОВНАЯ (пожелание Мадины 27.08.2026: «более красивый
  интерфейс и тёмный фон, на контрасте цифры»). Светлая осталась как выбор
  в переключателе, но палитра теперь строится от тёмной, а не выворачивается
  из светлой — поэтому у тёмной своя глубина, а не серый фон с белым текстом.

  Главное правило подачи: на тёмном экране цифра должна быть самым ярким
  пятном. Поэтому значения показателей — почти белые и крупные, подписи
  приглушены, а линии и рамки едва заметны. Цвет у цифры появляется только
  тогда, когда он что-то значит (светофор из методики).

  Ничего не грузится из интернета: шрифты системные, графики рисуются SVG
  на сервере. Дашборд полностью работает офлайн.
*/

:root {
  color-scheme: dark;

  /* Поверхности: три уровня глубины, разница мягкая */
  --bg: #080b14;
  --surface: #111725;
  --surface-2: #171e2f;
  --surface-hover: #1d2538;
  --border: #222b3f;
  --border-strong: #2f3a52;

  /* Текст: значения почти белые, подписи заметно тише — так цифра выступает */
  --text: #f2f5ff;
  --text-muted: #8e9cb8;
  --text-faint: #5d6a85;

  --accent: #7c8cff;
  --accent-hover: #9aa7ff;
  --accent-soft: #171d33;
  --accent-text: #ffffff;

  /* Светофоры — те же уровни, что заливают Excel (spec.md §1.4),
     но подобраны так, чтобы читаться на тёмном фоне */
  --ok: #34d399;
  --ok-soft: #0e2a22;
  --warn: #fbbf24;
  --warn-soft: #2b2110;
  --alert: #fb923c;
  --alert-soft: #2d1c10;
  --bad: #f87171;
  --bad-soft: #2e1418;
  --neutral: #8e9cb8;
  --neutral-soft: #1a2131;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / .4);
  --shadow-md: 0 4px 12px rgb(0 0 0 / .45), 0 1px 3px rgb(0 0 0 / .3);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / .5);

  /* Тонкая светлая линия по верхней кромке карточки — даёт объём,
     без неё тёмные плашки сливаются с фоном */
  --edge: inset 0 1px 0 rgb(255 255 255 / .04);

  /* Высота верхней панели — на неё опирается липкая шапка таблиц */
  --topbar-h: 64px;

  --radius: 16px;
  --radius-sm: 10px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI",
          Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: "Segoe UI Variable Display", "SF Pro Display", var(--font);
  --font-mono: "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
}

/* Светлая тема — только по явному выбору в переключателе */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f5f7fc;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --surface-hover: #f1f4fa;
  --border: #e3e8f2;
  --border-strong: #c9d2e3;

  --text: #0e1729;
  --text-muted: #5b6880;
  --text-faint: #8c98ae;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef1ff;
  --accent-text: #ffffff;

  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #a16207;
  --warn-soft: #fef9c3;
  --alert: #c2410c;
  --alert-soft: #ffedd5;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --neutral: #5b6880;
  --neutral-soft: #eef1f7;

  --shadow-sm: 0 1px 2px rgb(15 23 42 / .06);
  --shadow-md: 0 2px 6px rgb(15 23 42 / .07), 0 8px 24px rgb(15 23 42 / .06);
  --shadow-lg: 0 12px 32px rgb(15 23 42 / .1);
  --edge: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;

  /* Два мягких пятна света сверху — экран перестаёт быть плоским чёрным */
  background:
    radial-gradient(1100px 520px at 12% -8%, rgb(124 140 255 / .10), transparent 60%),
    radial-gradient(900px 460px at 88% -4%, rgb(52 211 153 / .06), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

:root[data-theme="light"] body {
  background:
    radial-gradient(1000px 480px at 15% -10%, rgb(79 70 229 / .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }

/* ---------- Каркас ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 26px;
  height: 64px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 640;
  font-size: 15px;
  color: var(--text);
  letter-spacing: -.012em;
  white-space: nowrap;
}
.brand:hover { color: var(--text); }
.brand-mark {
  display: grid;
  place-items: center;
  width: 31px; height: 31px;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--accent), #22d3ee);
  color: #0b0f1a;
  font-size: 15px;
  font-weight: 800;
  box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}

.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 7px 14px;
  border-radius: 9px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 520;
  white-space: nowrap;
  transition: background .16s, color .16s;
}
.nav a:hover { background: var(--surface-hover); color: var(--text); }
.nav a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 620;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.icon-btn {
  display: grid; place-items: center;
  width: 35px; height: 35px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 15px;
  transition: background .16s, color .16s, border-color .16s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }

.page { max-width: 1400px; margin: 0 auto; padding: 30px 26px 90px; }

.page-head { margin-bottom: 26px; }
.page-head h1 {
  margin: 0 0 7px;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -.028em;
}
.page-head .sub { color: var(--text-muted); font-size: 14px; }

.section { margin-top: 40px; }
.section > h2 {
  margin: 0 0 5px;
  font-size: 18px;
  font-weight: 660;
  letter-spacing: -.018em;
}
.section > .section-note {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13.5px;
  max-width: 92ch;
}

/* ---------- Карточки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), var(--edge);
}
.card-pad { padding: 20px 22px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Карточка показателя — главный носитель цифры */
.kpi {
  position: relative;
  padding: 18px 20px 19px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), var(--edge);
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
}
/* Цветная полоска слева — цвет светофора, если он есть */
.kpi::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--neutral);
  opacity: .5;
}
.kpi.tone-ok::before    { background: var(--ok);    opacity: .9; }
.kpi.tone-warn::before  { background: var(--warn);  opacity: .9; }
.kpi.tone-alert::before { background: var(--alert); opacity: .9; }
.kpi.tone-bad::before   { background: var(--bad);   opacity: .9; }

.kpi-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
}
.kpi-value {
  font-family: var(--font-num);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.kpi-value .unit {
  font-size: 15px;
  font-weight: 550;
  color: var(--text-muted);
  margin-left: 3px;
  letter-spacing: 0;
}
.kpi-hint { font-size: 12.5px; color: var(--text-muted); line-height: 1.45; }

/* Цвет у цифры — только когда он что-то означает */
.kpi.tone-ok    .kpi-value { color: var(--ok); }
.kpi.tone-warn  .kpi-value { color: var(--warn); }
.kpi.tone-alert .kpi-value { color: var(--alert); }
.kpi.tone-bad   .kpi-value { color: var(--bad); }

/* Карточка агента на обзоре */
.agent-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding: 21px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm), var(--edge);
  color: var(--text);
  overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.agent-card:hover {
  color: var(--text);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg), var(--edge);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}
.agent-card-head { display: flex; align-items: flex-start; gap: 13px; }
.agent-num {
  display: grid; place-items: center;
  flex: none;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}
.agent-card h3 { margin: 0; font-size: 15.5px; font-weight: 650; letter-spacing: -.015em; }
.agent-card .agent-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.agent-card-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 14px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}
.agent-stat-value {
  font-family: var(--font-num);
  font-size: 22px;
  font-weight: 690;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.agent-stat-label { font-size: 11.5px; color: var(--text-muted); line-height: 1.35; margin-top: 3px; }

.agent-card.compact { padding: 18px; gap: 13px; }
.agent-card.compact h3 { font-size: 14px; }
.agent-card.compact .agent-num { width: 35px; height: 35px; border-radius: 11px; font-size: 13px; }
.agent-card.compact .agent-stat-value { font-size: 19px; }

/* ---------- Кольца-прогресс ---------- */

.ring-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-around; }
.ring-item { text-align: center; flex: 1 1 135px; min-width: 135px; }
.ring-item svg { margin-inline: auto; }
.ring-caption { margin-top: 6px; font-size: 12.5px; line-height: 1.45; }

/* ---------- Плитки «Требует внимания» ---------- */

.attention {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 17px 19px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--neutral);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  box-shadow: var(--shadow-sm), var(--edge);
  color: var(--text);
  transition: transform .18s ease, box-shadow .18s ease;
}
.attention:hover { color: var(--text); transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.attention.tone-bad   { border-left-color: var(--bad); }
.attention.tone-alert { border-left-color: var(--alert); }
.attention.tone-warn  { border-left-color: var(--warn); }
.attention-title { font-size: 14.5px; font-weight: 660; line-height: 1.4; letter-spacing: -.01em; }
.attention.tone-bad   .attention-title { color: var(--bad); }
.attention.tone-alert .attention-title { color: var(--alert); }
.attention.tone-warn  .attention-title { color: var(--warn); }
.attention-text { font-size: 13px; color: var(--text-muted); line-height: 1.55; }
.attention-link { margin-top: auto; padding-top: 6px; font-size: 12.5px; font-weight: 580; color: var(--accent); }

/* ---------- Полоса прогресса ---------- */

.bar {
  position: relative;
  height: 7px;
  border-radius: 99px;
  background: var(--neutral-soft);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .03);
}
.bar > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
}
.bar.tone-ok    > span { background: var(--ok); }
.bar.tone-warn  > span { background: var(--warn); }
.bar.tone-alert > span { background: var(--alert); }
.bar.tone-bad   > span { background: var(--bad); }

/* ---------- Значки ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 620;
  white-space: nowrap;
  letter-spacing: -.005em;
}
.badge.ok      { background: var(--ok-soft);      color: var(--ok); }
.badge.warn    { background: var(--warn-soft);    color: var(--warn); }
.badge.alert   { background: var(--alert-soft);   color: var(--alert); }
.badge.bad     { background: var(--bad-soft);     color: var(--bad); }
.badge.neutral { background: var(--neutral-soft); color: var(--text-muted); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

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

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm), var(--edge);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  /* Шапка остаётся на месте, а список прокручивается под ней (пожелание
     Мадины 31.08.2026: «чтобы шапочка оставалась»).

     Прилипает к верху САМОЙ ТАБЛИЦЫ, а не страницы. Иначе не работает:
     у таблиц включена горизонтальная прокрутка (overflow-x), а по правилам
     браузера это делает контейнер своим окном прокрутки — отсчёт идёт от
     его верха, а не от верха страницы. При отступе в высоту панели шапка
     съезжала вниз, и первые строки списка оказывались НАД ней. Ровно это
     Мадина и увидела 31.08.2026. */
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 12px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-size: 11.5px;
  font-weight: 640;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
thead th:first-child, tbody td:first-child { text-align: left; }
thead th.c-text, tbody td.c-text { text-align: left; }
thead th[data-sort] { cursor: pointer; user-select: none; transition: color .15s; }
thead th[data-sort]:hover { color: var(--text); }
thead th[data-sort]::after { content: " ⇅"; opacity: .3; font-size: 10px; }
thead th[data-sort].asc::after  { content: " ↑"; opacity: 1; color: var(--accent); }
thead th[data-sort].desc::after { content: " ↓"; opacity: 1; color: var(--accent); }

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
tbody td.c-text { white-space: normal; min-width: 230px; color: var(--text-muted); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-hover); }
tbody tr:hover td.c-text { color: var(--text); }
tbody tr.is-total td { font-weight: 680; background: var(--surface-2); color: var(--text); }
tbody tr.is-total:hover td { background: var(--surface-2); }

/* Цветные ячейки — те же уровни, что заливают Excel */
td.cell-ok    { background: var(--ok-soft);    color: var(--ok);    font-weight: 640; }
td.cell-warn  { background: var(--warn-soft);  color: var(--warn);  font-weight: 640; }
td.cell-alert { background: var(--alert-soft); color: var(--alert); font-weight: 640; }
td.cell-bad   { background: var(--bad-soft);   color: var(--bad);   font-weight: 640; }

/* Высота таблицы ограничена, чтобы список прокручивался внутри неё, а не
   уводил вниз всю страницу — тогда шапка и остаётся видимой.
   Короткие таблицы это ограничение просто не задевает. */
.table-wrap { max-height: 74vh; }
/* Очень длинные перечни (тысячи строк) — чуть компактнее, чтобы после
   таблицы на экране оставалось видно, что идёт дальше. */
.table-wrap.scrolls { max-height: 68vh; }

.rank { color: var(--text-faint); font-size: 12px; }

/* ---------- Панель управления таблицей ---------- */

.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 13px; }
.search {
  flex: 1 1 250px;
  max-width: 400px;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.search::placeholder { color: var(--text-faint); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  transition: all .16s;
}
.chip:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-strong); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 30%, transparent);
}

.row-count { margin-left: auto; color: var(--text-faint); font-size: 12.5px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 17px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 580;
  cursor: pointer;
  transition: background .16s, border-color .16s, transform .12s;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 32%, transparent);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-text); }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Плашки ---------- */

.note {
  display: flex;
  gap: 12px;
  padding: 14px 17px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-muted);
}
.note .note-icon { flex: none; font-size: 15px; line-height: 1.4; }
.note strong { font-weight: 640; color: var(--text); }
.note.warn  { background: var(--warn-soft);  border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.note.alert { background: var(--alert-soft); border-color: color-mix(in srgb, var(--alert) 28%, transparent); }
.note.bad   { background: var(--bad-soft);   border-color: color-mix(in srgb, var(--bad) 28%, transparent); }
.note.privacy { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.note + .note { margin-top: 9px; }

/* Выводы Claude */
.insight {
  padding: 19px 22px;
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: var(--radius);
  background:
    radial-gradient(600px 200px at 0% 0%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    var(--surface);
  box-shadow: var(--shadow-sm), var(--edge);
}
.insight-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 11px;
  font-size: 11.5px; font-weight: 660;
  color: var(--accent);
  text-transform: uppercase; letter-spacing: .07em;
}
.insight-body { font-size: 14px; line-height: 1.65; color: var(--text); }
.insight-body ul { margin: 8px 0; padding-left: 20px; }
.insight-body li { margin-bottom: 7px; }
.insight-body li::marker { color: var(--accent); }
.insight-body p { margin: 0 0 9px; }
.insight-body p:last-child, .insight-body ul:last-child { margin-bottom: 0; }
.insight-foot { margin-top: 13px; font-size: 11.5px; color: var(--text-faint); }

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

.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; max-width: 100%; height: auto; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 15px;
  margin-top: 13px;
  font-size: 12.5px; color: var(--text-muted);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Пустое состояние ---------- */

.empty {
  padding: 52px 26px;
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.empty-icon { font-size: 32px; opacity: .45; display: block; margin-bottom: 12px; }
.empty h3 { margin: 0 0 7px; font-size: 16px; font-weight: 650; color: var(--text); }
.empty p { margin: 0 auto; font-size: 13.5px; max-width: 48ch; }

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

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 390px;
  padding: 36px 34px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg), var(--edge);
}
.login-card .brand-mark { width: 46px; height: 46px; border-radius: 14px; font-size: 21px; margin-bottom: 18px; }
.login-card h1 { margin: 0 0 6px; font-size: 21px; font-weight: 680; letter-spacing: -.025em; }
.login-card .sub { margin: 0 0 24px; color: var(--text-muted); font-size: 13.5px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 580; }
.field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.form-error {
  margin-bottom: 16px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 13px;
  font-weight: 550;
}

/* ---------- Мелочи ---------- */

.t-ok { color: var(--ok); }
.t-warn { color: var(--warn); }
.t-alert { color: var(--alert); }
.t-bad { color: var(--bad); }
.t-neutral { color: var(--text); }

.muted { color: var(--text-muted); }
.mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* Полосы прокрутки — чтобы не выбивались светлым на тёмном */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-faint); background-clip: content-box; }

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 10px; padding: 11px 16px; }
  .topbar-right { width: 100%; margin-left: 0; }
  .nav { order: 3; width: 100%; }
  .page { padding: 20px 14px 64px; }
  .page-head h1 { font-size: 22px; }
  .kpi-value { font-size: 28px; }
  tbody td.c-text { min-width: 170px; }
}

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

@media print {
  .topbar, .table-tools, .btn, .icon-btn { display: none !important; }
  .page { max-width: none; padding: 0; }
  .card, .table-wrap, .kpi { break-inside: avoid; box-shadow: none; }
}

/* ---------- Подробности по строке ---------- */

tr[data-details] { cursor: pointer; }
tr[data-details]:hover td { background: var(--surface-hover); }
tr[data-details].expanded td {
  background: var(--accent-soft);
  border-bottom-color: transparent;
}
tr[data-details]::after { content: ""; }

tr.details-row td {
  padding: 0;
  background: var(--surface-2);
  /* Ячейки таблицы запрещают перенос строк (чтобы не рвались даты и числа),
     и карточка это наследовала: длинное название организации и фамилия
     врача вылезали за свою колонку и налезали на соседние значения —
     Мадина увидела это 31.08.2026. Внутри карточки перенос разрешён. */
  white-space: normal;
}
.details-box {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px 22px;
  padding: 16px 20px;
  border-left: 3px solid var(--accent);
}
/* Без min-width: 0 ячейка сетки не может стать уже своего содержимого —
   длинная строка распирает её и выходит за границы соседних. */
.detail-item { min-width: 0; }
.detail-label {
  font-size: 11px;
  font-weight: 620;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 3px;
}
.detail-value {
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.45;
  /* Название организации — одно длинное слово в кавычках; без этого оно
     не переносится даже с white-space: normal. */
  overflow-wrap: anywhere;
}

/* Ячейка, по которой можно «провалиться» к списку */
[data-drill] { cursor: pointer; }
[data-drill]:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Заголовок таблицы с кнопкой выгрузки.
   Мадина 31.08.2026: «возле каждой таблицы нужна выгрузка эксель» —
   кнопка стоит у названия, а не одна на всю страницу внизу. */
.table-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}
.table-head h2 { margin: 0 0 6px; }
.table-head .section-note { margin: 0; max-width: 74ch; }

.table-total {
  margin: 8px 0 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.btn-excel {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-excel:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-hover);
}
.btn-excel span { font-size: 15px; line-height: 1; }

@media (max-width: 720px) {
  .table-head { flex-direction: column; }
}
