/* Signalyst — общая дизайн-система (docs/05_backend/ui_design.md §3, §4, §8.4).
   Стиль «спокойный аналитический»: светлая и тёмная темы, один синий акцент, системный шрифт, без внешних запросов.
   Постраничные стили — run.css (.run-*), signal.css (.sig-*, .method-*). */

/* ============================================================ 1. Токены (§3.1, механика тем §3.4) */
:root {
  color-scheme: light;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --surface-2: #F0F3F7;
  --ink: #16223A;
  --ink-2: #56617A;
  --line: #DCE1E8;
  --line-strong: #858FA1;          /* рамки полей и контур «ниже порога»: ≥ 3:1 к --surface (WCAG 1.4.11) */
  --accent: #1F4FBF;
  --accent-ink: #FFFFFF;
  --accent-soft: #E7EDFB;
  --ok: #23734D;   --ok-soft: #E4F2EA;
  --warn: #8F5608; --warn-soft: #FBF0DC;
  --bad: #B3261E;  --bad-soft: #FBE6E4;
  --focus: rgba(31, 79, 191, 0.40);
  --tip-bg: #16223A;  --tip-ink: #FFFFFF;

  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Roboto,
          "Noto Sans", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --r-ctl: 6px;    /* кнопки, поля, бейджи */
  --r-panel: 10px; /* панели */
  --header-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0E131A;
    --surface: #151B24;
    --surface-2: #1B2330;
    --ink: #E4E9F0;
    --ink-2: #9BA6B7;
    --line: #29323F;
    --line-strong: #627085;
    --accent: #7EA4FF;
    --accent-ink: #0E131A;
    --accent-soft: #1C2944;
    --ok: #5DC28E;   --ok-soft: #14281E;
    --warn: #E3A857; --warn-soft: #2D2314;
    --bad: #F2857C;  --bad-soft: #321A19;
    --focus: rgba(126, 164, 255, 0.50);
    --tip-bg: #E4E9F0;  --tip-ink: #0E131A;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0E131A;
  --surface: #151B24;
  --surface-2: #1B2330;
  --ink: #E4E9F0;
  --ink-2: #9BA6B7;
  --line: #29323F;
  --line-strong: #627085;
  --accent: #7EA4FF;
  --accent-ink: #0E131A;
  --accent-soft: #1C2944;
  --ok: #5DC28E;   --ok-soft: #14281E;
  --warn: #E3A857; --warn-soft: #2D2314;
  --bad: #F2857C;  --bad-soft: #321A19;
  --focus: rgba(126, 164, 255, 0.50);
  --tip-bg: #E4E9F0;  --tip-ink: #0E131A;
}

/* ============================================================ 2. База и типографика (§3.2) */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
}

h1, h2, h3, h4 { margin: 0; color: var(--ink); font-weight: 600; }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 20px; line-height: 1.3; }
h3 { font-size: 16px; line-height: 1.4; }
h4 { font-size: 15px; line-height: 1.4; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0 0 12px; padding-left: 20px; }
li + li { margin-top: 4px; }
small, .small { font-size: 13px; line-height: 1.45; }
strong, b { font-weight: 600; }

a { color: var(--accent); text-decoration: none; text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; }
svg { flex-shrink: 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }

code, kbd, samp { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
pre {
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--r-ctl);
  padding: 12px 14px; margin: 0 0 12px; overflow: auto; max-height: 320px;
  white-space: pre-wrap;
}
pre code { background: none; padding: 0; }

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

/* Фокус (§4 «Кнопки»): видимое кольцо 3 px цвета --focus */
:focus { outline: none; }
/* без border-radius: он менял бы форму чипов, кнопок и вкладок при фокусе — кольцо и так повторяет их скругление */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ============================================================ 3. Каркас (§3.3) */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 50;
  background: var(--surface); color: var(--accent); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: var(--r-ctl);
}
.skip-link:focus { top: 8px; }

/* Шапка (§1а, §4): 56 px, --surface, нижняя рамка */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.site-header__inner { display: flex; align-items: center; gap: 32px; min-height: var(--header-h); }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand__mark { width: 20px; height: 20px; color: var(--accent); }
.brand__name { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.brand__tag { font-size: 13px; color: var(--ink-2); padding-left: 10px; border-left: 1px solid var(--line); line-height: 1.2; }

.site-nav { display: flex; align-items: stretch; gap: 4px; align-self: stretch; margin-right: auto; }
.site-nav a {
  display: inline-flex; align-items: center; padding: 0 10px;
  color: var(--ink-2); font-size: 14px; font-weight: 500; text-decoration: none;
  border-bottom: 2px solid transparent; border-top: 2px solid transparent; white-space: nowrap;
}
.site-nav a:hover { color: var(--ink); }
.site-nav a:focus-visible { outline-offset: -4px; border-radius: var(--r-ctl); }
.site-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; margin-left: auto;
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--r-ctl); cursor: pointer;
}
.theme-toggle:hover { color: var(--ink); background: var(--surface-2); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
html:not(.js) .theme-toggle { visibility: hidden; }

.site-main { flex: 1 0 auto; padding-bottom: 64px; }
.site-main:focus { outline: none; }

.site-footer { border-top: 1px solid var(--line); color: var(--ink-2); font-size: 13px; }
.site-footer__inner { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; padding-top: 16px; padding-bottom: 20px; }
.site-footer a { color: var(--ink-2); text-decoration: underline; }
.site-footer__links { display: inline-flex; flex-wrap: wrap; gap: 4px 16px; }
.site-footer a:hover { color: var(--ink); }

/* Заголовок страницы */
.page-head { padding: 32px 0 24px; }
.page-head > * + * { margin-top: 8px; }
.page-title { font-size: 28px; line-height: 1.2; font-weight: 600; letter-spacing: -0.01em; }
.page-sub { color: var(--ink-2); max-width: 72ch; font-size: 15px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-head--split { display: flex; flex-wrap: wrap; gap: 16px 24px; align-items: flex-start; justify-content: space-between; }
.page-head--split > * + * { margin-top: 0; }
.page-head__main { min-width: 0; flex: 1 1 480px; }
.page-head__main > * + * { margin-top: 8px; }

.section { margin-top: 48px; }
.section:first-child { margin-top: 0; }
.page-head + .section { margin-top: 8px; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 16px; }
.section-head p { margin: 0; color: var(--ink-2); font-size: 13px; }

.layout-aside { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 48px; align-items: start; }
.aside { position: sticky; top: 16px; display: grid; gap: 16px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 20px 24px; }

.prose { max-width: 72ch; }
.prose p, .prose ul, .prose ol { margin-bottom: 12px; }
.prose a { text-decoration: underline; }
.prose h2, .prose h3 { margin: 24px 0 8px; }
.prose > :first-child { margin-top: 0; }

.muted { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ============================================================ 4. Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  font: inherit; font-size: 15px; font-weight: 600; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--r-ctl);
  background: transparent; color: var(--accent);
  cursor: pointer; text-decoration: none; user-select: none;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); border-color: color-mix(in srgb, var(--accent) 86%, var(--ink)); }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); font-weight: 500; }
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--accent); font-weight: 500; padding: 0 10px; }
.btn-ghost:hover { background: var(--surface-2); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-ghost.btn-sm { padding: 0 8px; }

/* ============================================================ 5. Бейджи, термины, точки */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap;
  border-radius: var(--r-ctl);
  background: var(--surface-2); color: var(--ink-2);
  vertical-align: middle;
}
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--warn { background: var(--warn-soft); color: var(--warn); }
.badge--bad { background: var(--bad-soft); color: var(--bad); }
.badge[title] { cursor: help; }
.badges { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.term {
  position: relative;
  border-bottom: 1px dotted currentColor;
  cursor: help;
  text-decoration: none;
}
abbr.term { text-decoration: none; }
/* Подсказка при фокусе с клавиатуры (при наведении мышью — родной title) */
.term:focus-visible { outline-offset: 1px; }
.term:focus-visible::after {
  content: attr(title);
  position: absolute; left: 0; top: calc(100% + 8px); z-index: 20;
  width: max-content; max-width: min(320px, 80vw);
  padding: 8px 10px; border-radius: var(--r-ctl);
  background: var(--tip-bg); color: var(--tip-ink);
  font-size: 13px; font-weight: 400; line-height: 1.45; white-space: normal; text-align: left;
  box-shadow: 0 6px 20px rgba(10, 20, 40, 0.18);
}

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ink-2); flex-shrink: 0; vertical-align: middle; }
.dot--ok { background: var(--ok); }
.dot--warn { background: var(--warn); }
.dot--bad { background: var(--bad); }

/* ============================================================ 6. «Подпись сигнала»: полоска критериев и мини-график */
.crit { display: inline-flex; align-items: stretch; gap: 2px; vertical-align: middle; line-height: 0; }
.crit__cell {
  display: block; width: 6px; height: 14px; border-radius: 1px;
  background: transparent;
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.crit__cell.is-pass { background: var(--accent); box-shadow: none; }
.crit__cell.is-fail { background: var(--surface); }
.crit__cell.is-na {
  box-shadow: inset 0 0 0 1px var(--line);
  background: repeating-linear-gradient(135deg, var(--line-strong) 0 1px, transparent 1px 3px);
}
.crit--s .crit__cell { width: 6px; height: 14px; }
.crit--l { gap: 3px; }
.crit--l .crit__cell { width: 14px; height: 24px; border-radius: 2px; }
.crit--l .crit__cell.is-na { background: repeating-linear-gradient(135deg, var(--line-strong) 0 1px, transparent 1px 4px); }
.crit--l .crit__cell[title] { cursor: help; }
.crit--l .crit__cell:hover { outline: 2px solid var(--focus); outline-offset: 1px; }

/* Легенда полоски (главная, «Методика») */
.crit-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; font-size: 13px; color: var(--ink-2); list-style: none; padding: 0; margin: 0; }
.crit-legend li { display: inline-flex; align-items: center; gap: 8px; margin: 0; }

.spark { display: inline-block; color: var(--accent); vertical-align: middle; line-height: 0; }
.spark svg { display: block; overflow: visible; }
.spark--s { width: 96px; }                      /* «ряд не измерен» занимает место графика — полоски в строках ТОП на одной вертикали */
.spark--s .spark__none { display: block; white-space: nowrap; }
.spark--l { display: block; margin: 0; }
.spark--l svg { width: 100%; max-width: 100%; height: auto; }
.spark__years { display: flex; justify-content: space-between; margin-top: 4px; font-size: 12px; line-height: 1.4; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.spark__legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: 12px; line-height: 1.4; color: var(--ink-2); }
.spark__key { display: inline-flex; align-items: center; gap: 6px; }
.spark__key::before { content: ""; width: 14px; height: 0; border-top: 2px solid var(--accent); }
.spark__key--pre::before { border-top: 1.5px solid var(--ink-2); opacity: 0.6; }   /* как линия .spark__pre: тонкая, вторичная */
.spark__none { font-size: 12px; line-height: 24px; color: var(--ink-2); }
/* Элементы SVG мини-графика (view.sparkline_svg): цвет — currentColor; работы — акцент, препринты — вторичный */
.spark .spark__pre { color: var(--ink-2); }
.spark .spark__base { color: var(--ink-2); }
.spark .spark__hit { cursor: default; }
.spark .spark__hit:hover { fill: var(--accent); fill-opacity: 0.08; }

/* ============================================================ 7. Счётчики R-33 (одна полоса) */
/* Разделители — рамками ячеек, без overflow: hidden: иначе обрезаются подсказки терминов и кольцо фокуса */
.stats {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  margin: 0;
}
.stat { padding: 16px 20px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat:first-child { border-radius: calc(var(--r-panel) - 1px) 0 0 calc(var(--r-panel) - 1px); }
.stat:last-child { border-radius: 0 calc(var(--r-panel) - 1px) calc(var(--r-panel) - 1px) 0; }
.stat:only-child { border-radius: calc(var(--r-panel) - 1px); }
a.stat:focus-visible { outline-offset: -3px; }
.stat__value { font-size: 26px; line-height: 1.15; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink); letter-spacing: -0.01em; }
.stat__label { font-size: 13px; line-height: 1.4; color: var(--ink); }
.stat__note { font-size: 12px; line-height: 1.4; color: var(--ink-2); }
a.stat { color: inherit; text-decoration: none; }
a.stat:hover { background: var(--surface-2); text-decoration: none; }
a.stat:hover .stat__label { text-decoration: underline; color: var(--accent); }
a.stat .stat__value { color: var(--accent); }

/* ============================================================ 8. Вкладки */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 14px; margin-bottom: -1px;
  font-size: 15px; font-weight: 500; color: var(--ink-2); white-space: nowrap;
  border-bottom: 2px solid transparent; border-radius: var(--r-ctl) var(--r-ctl) 0 0;
  text-decoration: none; cursor: pointer;
}
.tab:hover { color: var(--ink); background: var(--surface-2); text-decoration: none; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab:focus-visible { outline-offset: -3px; }
.tab__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--surface); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line);  /* вкладки лежат на --bg */
  font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.tab[aria-selected="true"] .tab__count { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.tab-panel { padding-top: 24px; }
.tab-panel[hidden] { display: none; }
html:not(.js) .tab-panel + .tab-panel { margin-top: 32px; border-top: 1px solid var(--line); }
html:not(.js) .tab[aria-selected="true"] { color: var(--ink-2); border-bottom-color: transparent; }
html:not(.js) .tab[aria-selected="true"] .tab__count { background: var(--surface); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }

/* ============================================================ 9. Этапы прогона */
.stepper { list-style: none; margin: 0; padding: 0; }
.step { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: 14px; padding-bottom: 20px; margin: 0; }
.step:last-child { padding-bottom: 0; }
.step:not(:last-child)::before {
  content: ""; position: absolute; left: 13px; top: 32px; bottom: 4px; width: 2px;
  background: var(--line); border-radius: 1px;
}
.step.is-done:not(:last-child)::before { background: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.step__marker {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--surface); color: var(--ink-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
  position: relative;
}
.step__marker svg { width: 14px; height: 14px; }
.step__body { min-width: 0; padding-top: 3px; }
.step__title { font-size: 15px; line-height: 1.45; color: var(--ink); }
.step.is-todo .step__title { color: var(--ink-2); }
.step.is-current .step__title { font-weight: 600; }
.step__msg { margin-top: 2px; font-size: 13px; color: var(--ink-2); }
.step__progress { display: flex; align-items: center; gap: 12px; margin-top: 8px; max-width: 420px; font-size: 13px; color: var(--ink-2); }
.bar { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.bar__fill { display: block; height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }

.step.is-done .step__marker { background: var(--ok-soft); color: var(--ok); box-shadow: none; }
.step.is-current .step__marker { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.step.is-current .step__marker::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--accent); opacity: 0;
  animation: step-pulse 1.8s ease-out infinite;
}
.step.is-failed .step__marker { background: var(--bad-soft); color: var(--bad); box-shadow: none; }
.step.is-failed .step__title { color: var(--bad); font-weight: 600; }
.step__dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
@keyframes step-pulse {
  0% { transform: scale(0.85); opacity: 0.55; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* ============================================================ 10. Выноска и раскрывашка */
.callout {
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
  border-radius: 0 var(--r-ctl) var(--r-ctl) 0;
  padding: 12px 16px;
  font-size: 14px; line-height: 1.5; color: var(--ink);
  max-width: calc(72ch * 15 / 14);   /* правый край — как у прозы (72ch при 15 px; у выноски 14 px) */
}
.callout--info { border-left-color: var(--accent); background: var(--accent-soft); }
.callout--bad { border-left-color: var(--bad); background: var(--bad-soft); }
.callout__title { font-weight: 600; margin-bottom: 4px; }
.callout--warn .callout__title { color: var(--warn); }
.callout--info .callout__title { color: var(--accent); }
.callout--bad .callout__title { color: var(--bad); }
.callout > :last-child { margin-bottom: 0; }
.callout + .callout { margin-top: 8px; }

details { margin: 0; }
details > summary {
  display: flex; align-items: center; gap: 8px;
  list-style: none; cursor: pointer;
  font-weight: 500; color: var(--ink);
  padding: 6px 0; width: fit-content; max-width: 100%;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::marker { content: ""; }
details > summary::before {
  content: ""; flex-shrink: 0;
  width: 7px; height: 7px; margin: 0 3px 0 1px;
  border-right: 1.5px solid var(--ink-2); border-bottom: 1.5px solid var(--ink-2);
  transform: rotate(-45deg); transition: transform 0.15s ease;
}
details[open] > summary::before { transform: rotate(45deg); margin-top: -3px; }
details > summary:hover { color: var(--accent); }
details > summary .muted, details > summary .small { font-weight: 400; }
.details-body { padding: 8px 0 4px 20px; }

/* ============================================================ 11. Таблицы и списки */
.table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel);
  font-size: 14px;
}
/* углы — радиусом крайних ячеек, а не overflow: hidden (он обрезал бы подсказки терминов в ячейках) */
.table > :first-child > tr:first-child > :first-child { border-top-left-radius: calc(var(--r-panel) - 1px); }
.table > :first-child > tr:first-child > :last-child { border-top-right-radius: calc(var(--r-panel) - 1px); }
.table > :last-child > tr:last-child > :first-child { border-bottom-left-radius: calc(var(--r-panel) - 1px); }
.table > :last-child > tr:last-child > :last-child { border-bottom-right-radius: calc(var(--r-panel) - 1px); }
.table th, .table td { padding: 10px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table tbody tr:last-child > * { border-bottom: 0; }
.table th { background: var(--surface-2); color: var(--ink-2); font-size: 12px; font-weight: 500; line-height: 1.4; white-space: nowrap; }
.table .num, .table th.num { text-align: right; }
.table tbody tr:hover > td { background: color-mix(in srgb, var(--surface-2) 60%, var(--surface)); }
.table td.table__main { font-weight: 500; }
.table-wrap { overflow-x: auto; border-radius: var(--r-panel); }
.flow-only { display: none; }
/* .table--flow: на узком экране строка — заголовок и одна строка фактов в поток (без столбца подписей).
   Подпись факта — короткая data-short («в ТОП», «найдено»); без data-short значение говорит само за себя. */

.list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.list > li { margin: 0; }
.list-row { position: relative; display: block; padding: 16px 20px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.list > .list-row:first-child, .list > li:first-child > .list-row, .list > :first-child.list-row { border-top: 0; }
.list-row:hover { background: var(--surface-2); text-decoration: none; }
a.list-row:hover, a.list-row:focus-visible { text-decoration: none; }
a.list-row:focus-visible { outline-offset: -3px; border-radius: 0; }
/* растянутая ссылка: вся строка кликабельна, остальные ссылки и кнопки в строке — поверх */
.list-row__link { color: var(--ink); font-weight: 600; }
.list-row__link::after { content: ""; position: absolute; inset: 0; }
.list-row__link:focus-visible { outline: none; }
.list-row:has(.list-row__link:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }
.list-row a:not(.list-row__link), .list-row button, .list-row .term, .list-row [title] { position: relative; z-index: 1; }

/* ============================================================ 12. Формы, чипы, фильтры */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label, .field > label { font-size: 13px; font-weight: 500; color: var(--ink); }
.field__hint { font-size: 12px; line-height: 1.4; color: var(--ink-2); }

.input {
  width: 100%; height: 40px; padding: 0 12px;
  font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  appearance: none;
}
.input::placeholder { color: var(--ink-2); opacity: 1; }   /* с прозрачностью светлая тема падала ниже 4,5:1 */
.input:hover { border-color: color-mix(in srgb, var(--line-strong) 60%, var(--ink-2)); }
.input:focus-visible, .input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 35%, transparent); }
input[type="date"].input { width: auto; min-width: 180px; padding-right: 8px; }
.input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.7; }
/* значок календаря в тёмной теме светлый сам — через color-scheme: dark (без filter: invert, иначе он гаснет) */

.check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; line-height: 1.45; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.check__hint { display: block; font-size: 12px; color: var(--ink-2); }

.form-error { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 0; color: var(--bad); font-size: 13px; font-weight: 500; }
.form-error svg { width: 16px; height: 16px; margin-top: 1px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 32px; padding: 6px 14px; max-width: 100%;
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1.3; text-align: left;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 999px;
  cursor: pointer; text-decoration: none;
}
.chip:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip__count { font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 400; }
.chip[aria-pressed="true"] .chip__count { color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
html:not(.js) button[data-filter], html:not(.js) [data-print] { display: none; }
[data-filter-empty][hidden] { display: none; }
.is-filtered-out { display: none !important; }

/* ============================================================ 13. Пустое состояние, факты */
.empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 24px; }
.empty__title { font-size: 16px; font-weight: 600; line-height: 1.4; margin-bottom: 4px; }
.empty__text { color: var(--ink-2); max-width: 72ch; margin-bottom: 0; }
.empty__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 24px; margin: 0; }
.facts__item { min-width: 0; }
.facts dt { font-size: 12px; font-weight: 500; line-height: 1.4; color: var(--ink-2); }
.facts dd { margin: 1px 0 0; font-size: 14px; line-height: 1.45; color: var(--ink); }
.facts--inline { display: flex; flex-wrap: wrap; gap: 4px 20px; }
.facts--inline .facts__item { display: flex; gap: 6px; align-items: baseline; }
.facts--inline dd { margin: 0; }

/* ============================================================ 14. Главная (index.html, префикс .home-) */
.home-hero { padding: 40px 0 8px; }

.home-hero .page-sub { margin-top: 12px; font-size: 16px; }
.home-form { margin-top: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 20px 24px 16px; }
.home-search { display: flex; gap: 12px; align-items: stretch; }
.home-search .input { height: 48px; font-size: 16px; padding: 0 16px; }
.home-search .btn { height: 48px; padding: 0 24px; font-size: 16px; }
.home-examples { margin-top: 16px; }
.home-examples__label { font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.home-params { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
.home-params summary .muted { margin-left: 4px; }
.home-params__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 32px; padding: 12px 0 8px 20px; align-items: start; }

.home-steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px 32px; counter-reset: hs; }
.home-steps li { margin: 0; counter-increment: hs; position: relative; padding-top: 14px; border-top: 2px solid var(--line); }
.home-steps h3 { display: flex; gap: 8px; align-items: baseline; font-size: 15px; }
.home-steps h3::before { content: counter(hs); color: var(--accent); font-variant-numeric: tabular-nums; font-weight: 600; }
.home-steps p { margin-top: 6px; font-size: 14px; color: var(--ink-2); }
.home-steps__more { margin-top: 16px; font-size: 14px; }
.home-signature { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; margin-top: 20px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); font-size: 13px; color: var(--ink-2); }
.home-signature__sample { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); }

.home-recent td.home-recent__query { width: 40%; }
.home-recent__query a { font-weight: 500; }
.home-recent__query a.home-recent__garbled { font-style: italic; font-weight: 400; color: var(--ink-2); }
.home-recent__when { font-variant-numeric: tabular-nums; white-space: nowrap; }
.home-recent__meta { display: none; }

/* ============================================================ 15. Источники (health.html, префикс .health-) */
.health-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-panel); }
.health-summary__main { display: flex; align-items: baseline; gap: 4px 12px; flex-wrap: wrap; }
.health-summary__value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.15; }
.health-summary__main .badge { align-self: center; }
.health-summary .btn { margin-left: auto; }
.health-status { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-weight: 500; }
.health-status--ok { color: var(--ok); }
.health-status--bad { color: var(--bad); }
.health-list { margin-top: 24px; }
.health-name { font-weight: 600; }
@media (min-width: 961px) { .health-table td.table__main { min-width: 15em; } }   /* сообщение о сбое не сжимает названия */
.health-id { display: block; font-size: 12px; color: var(--ink-2); font-weight: 400; }
.health-msg { color: var(--ink-2); font-size: 13px; max-width: 60ch; }
.health-msg--bad { color: var(--ink); }

/* ============================================================ 16. Ошибка (error.html) */
.error-page { padding: 64px 0 32px; max-width: 640px; }
.error-page__code { font-size: 13px; font-weight: 500; color: var(--ink-2); font-variant-numeric: tabular-nums; margin-bottom: 8px; }
.error-page .page-sub { margin-top: 12px; }
.error-page__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }

/* ============================================================ 17. Адаптивность (§3.3: 960 / 600)
   Только для экрана: лист печати уже 960 px, и без «screen» таблицы и факты печатались бы как на телефоне. */
@media screen and (max-width: 960px) {
  .layout-aside { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .aside { position: static; }
  .home-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-params__grid { grid-template-columns: minmax(0, 1fr); }
  .brand__tag { display: none; }

  /* таблицы → списки: строка — блок, ячейка — пара «подпись: значение» (подпись из data-label) */
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table tr { border-bottom: 1px solid var(--line); padding: 12px 16px; }
  .table tbody tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 2px 0; text-align: left; }
  .table .num { text-align: left; }
  /* пара «подпись: значение» — сеткой: перенос значения не уходит под подпись (висячий отступ) */
  .table:not(.table--flow) td[data-label] { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); column-gap: 12px;
    align-items: baseline; }
  .table td[data-label]::before {
    content: attr(data-label); display: block; min-width: 0; margin: 0;
    font-size: 12px; font-weight: 500; color: var(--ink-2);
  }
  .table td.table__main { font-size: 15px; padding-bottom: 6px; width: auto; }
  .home-recent td.home-recent__query { width: auto; }
  .table td:empty { display: none; }
  .table tbody tr:hover > td { background: transparent; }

  .table--flow tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
  .table--flow td { width: auto; padding: 0; font-size: 14px; }
  .table--flow td.table__main { flex: 1 1 100%; padding-bottom: 2px; }
  .table--flow td[data-label]::before { content: none; }
  .table--flow td[data-short]::before { content: attr(data-short); display: inline; min-width: 0; margin-right: 5px; font-size: 13px; font-weight: 400; }
  .table--flow td.is-empty, .table--flow .flow-hide { display: none; }
  .table--flow .flow-only { display: inline; }
  .table--flow td.flow-wide { flex-basis: 100%; }
  /* «готово за 26 с» — статус и длительность рядом, дальше ТОП, срез, время запуска */
  .home-recent .table td { order: 2; }
  .home-recent .table td.home-recent__query { order: 0; }
  .home-recent .table td.home-recent__status, .home-recent .table td.home-recent__dur { order: 1; }
  .home-recent .table td.home-recent__dur { margin-left: -10px; }
  .home-recent .table td.home-recent__when { color: var(--ink-2); }
}

@media screen and (max-width: 600px) {
  .container { padding: 0 16px; }
  .site-header__inner { flex-wrap: wrap; gap: 0 12px; min-height: 0; padding-top: 10px; }
  .brand { order: 1; }
  .theme-toggle { order: 2; margin-left: auto; width: 34px; height: 34px; }
  .site-nav { order: 3; flex-basis: 100%; margin: 6px -10px 0; overflow-x: auto; scrollbar-width: none; min-height: 40px; }
  .site-nav::-webkit-scrollbar { display: none; }

  h1, .page-title { font-size: 24px; }
  .page-head { padding: 24px 0 20px; }
  .section { margin-top: 40px; }

  .stats { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 14px 16px; border-radius: 0; }
  .stat + .stat { border-left: 0; }
  .stat:nth-child(even) { border-left: 1px solid var(--line); }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stat:first-child { border-radius: calc(var(--r-panel) - 1px) 0 0 0; }
  .stat:last-child:nth-child(odd) { grid-column: span 2; }
  .stat__value { font-size: 24px; }

  .home-hero { padding-top: 28px; }
  .home-form { padding: 16px; }
  .home-search { flex-direction: column; }
  .home-search .btn { width: 100%; }
  .home-steps { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .home-params__grid { padding-left: 0; }
  /* готовые направления на телефоне — одна прокручиваемая строка вместо десяти строк чипов */
  .home-examples .chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: none; }
  .home-examples .chips::-webkit-scrollbar { display: none; }
  .home-examples .chip { white-space: nowrap; flex-shrink: 0; max-width: none; }
  .home-params summary { flex-wrap: wrap; row-gap: 0; }
  .home-params summary .muted { flex-basis: 100%; margin-left: 20px; }

  .list-row { padding: 14px 16px; }
  .tabs { gap: 0; margin: 0 -16px; padding: 0 16px; }
  .tab { padding: 0 10px; font-size: 14px; }
  .panel { padding: 16px; }
  .health-summary .btn { margin-left: 0; }
  .table:not(.table--flow) td[data-label] { grid-template-columns: 6.5rem minmax(0, 1fr); }
  .error-page { padding-top: 40px; }
  /* длинные подписи кнопок («Группа «Нет документов в источниках» в выдаче») переносятся, а не вылезают за экран */
  .btn { height: auto; min-height: 40px; padding-top: 8px; padding-bottom: 8px; white-space: normal; line-height: 1.3; text-align: center; }
  .btn-sm { min-height: 32px; padding-top: 6px; padding-bottom: 6px; }
}

/* ============================================================ 18. Движение */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .step.is-current .step__marker::after { display: none; }
}

/* ============================================================ 19. Печать: всегда светлая, без шапки, вкладки раскрыты */
@media print {
  :root, :root[data-theme], :root:not([data-theme="light"]) {
    color-scheme: light;
    --bg: #FFFFFF; --surface: #FFFFFF; --surface-2: #F0F3F7;
    --ink: #000000; --ink-2: #444C5C; --line: #C9D0DA; --line-strong: #8A94A6;
    --accent: #1F4FBF; --accent-ink: #FFFFFF; --accent-soft: #E7EDFB;
    --ok: #23734D; --ok-soft: #E4F2EA; --warn: #8F5608; --warn-soft: #FBF0DC; --bad: #B3261E; --bad-soft: #FBE6E4;
  }
  @page { margin: 16mm 14mm; }
  html, body { background: #FFFFFF !important; }
  body { font-size: 11pt; display: block; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .term::after, .term:focus-visible::after { display: none !important; }
  .site-header, .site-footer, .skip-link, .theme-toggle, .tabs, [data-print], .no-print, .page-actions .btn, .chips button[data-filter] { display: none !important; }
  .container { max-width: none; padding: 0; }
  .tab-panel, .tab-panel[hidden], .is-filtered-out { display: block !important; }
  .tab-panel + .tab-panel { margin-top: 16pt; border-top: 1px solid var(--line); }
  details > summary::before { display: none; }
  details:not([open]) > *:not(summary) { display: block; }
  .layout-aside { display: block; }
  .aside { position: static; margin-top: 16pt; }
  .list-row, .step, .callout, .stat, .facts__item, .table tr { break-inside: avoid; }
  h1, h2, h3 { break-after: avoid; }
  .site-main a[href^="http"]:not(.btn):not(.list-row__link)::after { content: " (" attr(href) ")"; font-size: 9pt; color: #444C5C; word-break: break-all; }
  .step.is-current .step__marker::after { display: none; }
  .list-row:hover, .table tbody tr:hover > td { background: transparent; }
}
