/* ============================================================================
   Flow Control — токены, компоненты и движение.
   Одна тема = один набор переменных на .fc[data-theme]. Всё остальное — общее.
   Файл рассчитан на перенос в панель как есть (Jinja2 + HTMX, без JS-библиотек).
   ========================================================================== */

@property --n { syntax: '<integer>'; inherits: false; initial-value: 0; }

/* ---------- 1. Токены: светлая тема ---------- */
.fc {
  --paper: #F2F1EC;            /* фон страницы */
  --panel: #FFFFFF;            /* панели */
  --raised: #FFFFFF;           /* активный сегмент */
  --ink: #151515;              /* основной текст, главная кнопка */
  --ink-2: #6B6A64;            /* вторичный текст */
  --line: #E6E4DC;             /* линии 1 px, обводки полей */
  --chip: #EEEDE7;             /* заливка чипов, вторичных кнопок */

  --ok: #1F6F4A;               /* работает / онлайн */
  --warn: #B8741A;             /* внимание — точки, полосы, крупные цифры */
  --warn-text: #98600F;        /* внимание — мелкий текст (контраст 4.6:1 на бумаге) */
  --danger: #B23B2E;           /* авария / истёк */
  --on-accent: #FFFFFF;        /* текст на зелёной и коралловой заливке */

  --ok-soft: rgba(31, 111, 74, .09);
  --warn-soft: rgba(184, 116, 26, .12);
  --danger-soft: rgba(178, 59, 46, .08);
  --warn-edge: rgba(184, 116, 26, .26);
  --danger-edge: rgba(178, 59, 46, .22);

  --ink-soft: rgba(21, 21, 21, .045);   /* наведение на строку и ghost-кнопку */
  --ink-line: rgba(21, 21, 21, .20);    /* линии схемы каскада */
  --chart-fill: rgba(21, 21, 21, .055); /* заливка под линией графика */

  /* инверсная поверхность: тост, плавающая панель, подсказка графика */
  --inv: #151515;
  --inv-text: #F2F1EC;
  --inv-2: rgba(242, 241, 236, .62);
  --inv-hover: rgba(242, 241, 236, .10);
  --inv-line: rgba(242, 241, 236, .16);
  --ok-inv: #7BD39B;
  --danger-inv: #E8735F;

  --scrim: rgba(21, 21, 21, .26);
  --shadow-float: 0 1px 2px rgba(21, 21, 21, .06), 0 18px 44px -14px rgba(21, 21, 21, .24);
  --shadow-seg: 0 1px 2px rgba(21, 21, 21, .08), 0 0 0 .5px rgba(21, 21, 21, .06);
  --focus: 0 0 0 3px rgba(21, 21, 21, .09);

  --f-display: 'Cormorant Garamond', Cormorant, Georgia, 'Times New Roman', serif;
  --f-ui: 'Golos Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --f-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --r-xs: 6px; --r-s: 8px; --r-m: 10px; --r-l: 14px; --r-xl: 20px; --r-pill: 999px;

  --d-press: 100ms; --d-hover: 120ms; --d-fast: 160ms; --d-page: 180ms; --d-row: 240ms;
  --d-drawer: 280ms; --d-state: 400ms; --d-count: 600ms; --d-ring: 3000ms; --d-toast: 4000ms;
  --e-out: cubic-bezier(.2, .8, .2, 1);      /* появление, отклик */
  --e-std: cubic-bezier(.2, 0, 0, 1);        /* нажатие */
  --e-drawer: cubic-bezier(.32, .72, 0, 1);  /* выезд с торможением */
  --e-in: cubic-bezier(.4, 0, 1, 1);         /* уход */
  --e-inout: cubic-bezier(.45, 0, .55, 1);   /* импульс туннеля, скелетон */
  --e-ring: cubic-bezier(.15, .55, .35, 1);  /* круги на воде */

  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 14px;
  line-height: 20px;
  font-variant-numeric: tabular-nums lining-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 1b. Токены: тёмная тема ---------- */
.fc[data-theme="dark"] {
  --paper: #0C0C0B;
  --panel: #1A1A19;
  --raised: #34332F;
  --ink: #F1EFE9;
  --ink-2: #9A9992;
  --line: #2B2B28;
  --chip: #242422;

  --ok: #7BD39B;
  --warn: #E0A648;
  --warn-text: #E0A648;
  --danger: #E8735F;
  --on-accent: #0C0C0B;

  --ok-soft: rgba(123, 211, 155, .10);
  --warn-soft: rgba(224, 166, 72, .12);
  --danger-soft: rgba(232, 115, 95, .11);
  --warn-edge: rgba(224, 166, 72, .26);
  --danger-edge: rgba(232, 115, 95, .26);

  --ink-soft: rgba(241, 239, 233, .05);
  --ink-line: rgba(241, 239, 233, .20);
  --chart-fill: rgba(241, 239, 233, .07);

  --inv: #F1EFE9;
  --inv-text: #151515;
  --inv-2: rgba(21, 21, 21, .60);
  --inv-hover: rgba(21, 21, 21, .08);
  --inv-line: rgba(21, 21, 21, .14);
  --ok-inv: #1F6F4A;
  --danger-inv: #B23B2E;

  --scrim: rgba(0, 0, 0, .55);
  --shadow-float: 0 0 0 1px #2B2B28, 0 22px 48px -12px rgba(0, 0, 0, .72);
  --shadow-seg: 0 1px 2px rgba(0, 0, 0, .4);
  --focus: 0 0 0 3px rgba(241, 239, 233, .14);
}

/* ---------- 2. База ---------- */
.fc *, .fc *::before, .fc *::after { box-sizing: border-box; }
.fc sc-for, .fc sc-if { display: contents; }
.fc :where(h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote) { margin: 0; padding: 0; }
.fc :where(ul, ol) { list-style: none; }
.fc a { color: inherit; text-decoration: none; }
.fc button { font: inherit; }
.fc b, .fc strong { font-weight: 600; }

/* иконки: 24-сетка, штрих 1.6 */
.fc svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fc svg.i--s { width: 16px; height: 16px; }
.fc svg.i--xs { width: 14px; height: 14px; stroke-width: 1.8; }

/* ---------- 3. Типографика ---------- */
.display { font-family: var(--f-display); font-weight: 500; letter-spacing: -.01em; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.h1 { font-family: var(--f-display); font-weight: 500; font-size: 44px; line-height: 48px; letter-spacing: -.015em; }
.h2 { font-family: var(--f-display); font-weight: 500; font-size: 32px; line-height: 36px; letter-spacing: -.01em; }
.h3 { font-family: var(--f-display); font-weight: 500; font-size: 26px; line-height: 30px; letter-spacing: -.005em; }
.num-xl { font-family: var(--f-display); font-weight: 500; font-size: 60px; line-height: 56px; letter-spacing: -.02em; font-variant-numeric: lining-nums tabular-nums; }
.num-l { font-family: var(--f-display); font-weight: 500; font-size: 40px; line-height: 40px; letter-spacing: -.015em; font-variant-numeric: lining-nums tabular-nums; }
.title { font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: -.005em; }
.t-l { font-size: 16px; line-height: 24px; }
.t-body { font-size: 14px; line-height: 20px; }
.t-s { font-size: 13px; line-height: 18px; }
.t-xs { font-size: 12px; line-height: 16px; }
.t-2 { color: var(--ink-2); }
.t-ok { color: var(--ok); }
.t-warn { color: var(--warn-text); }
.t-danger { color: var(--danger); }
.t-600 { font-weight: 600; }
.t-500 { font-weight: 500; }
.mono { font-family: var(--f-mono); font-size: 12.5px; letter-spacing: 0; }
.link { color: var(--ink); text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; text-decoration-thickness: 1px; transition: text-decoration-color var(--d-hover) var(--e-out); }
.link:hover { text-decoration-color: var(--ink); }
.kbd { display: inline-flex; align-items: center; height: 20px; min-width: 20px; justify-content: center; padding: 0 5px; border-radius: 5px; background: var(--chip); color: var(--ink-2); font-size: 11.5px; font-weight: 500; line-height: 1; }
.code { font-family: var(--f-mono); font-size: 12.5px; padding: 2px 6px; border-radius: 6px; background: var(--chip); color: var(--ink); }

/* ---------- 4. Поверхности ---------- */
.panel { background: var(--panel); border-radius: var(--r-xl); }
.panel--clip { overflow: hidden; }
.tile { background: var(--paper); border-radius: var(--r-l); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px 0; min-height: 50px; }
.hr { height: 1px; background: var(--line); flex: none; }
.vr { width: 1px; align-self: stretch; background: var(--line); flex: none; }
.tag { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: var(--r-pill); background: var(--chip); color: var(--ink-2); font-size: 12px; line-height: 1; font-weight: 500; white-space: nowrap; }
.tag--ok { background: var(--ok-soft); color: var(--ok); }
.tag--warn { background: var(--warn-soft); color: var(--warn-text); }
.tag--danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- 5. Каркас приложения ---------- */
.app { display: grid; grid-template-columns: 76px minmax(0, 1fr); height: 100%; }
.main { display: flex; flex-direction: column; gap: 20px; padding: 28px 40px 32px 32px; min-width: 0; min-height: 0; view-transition-name: main; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.head__sub { margin-top: 6px; font-size: 14px; line-height: 20px; color: var(--ink-2); }

.rail { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px 0 20px; min-height: 0; }
.rail__logo { width: 48px; height: 48px; display: grid; place-items: center; margin-bottom: 18px; border-radius: 14px; }
.rail__spacer { flex: 1; }
.nav { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 62px; height: 58px; border-radius: 14px; color: var(--ink-2); font-size: 11px; line-height: 14px; font-weight: 500; transition: background-color var(--d-hover) var(--e-out), color var(--d-hover) var(--e-out); }
.nav:hover { color: var(--ink); background: var(--ink-soft); }
.nav.is-on { color: var(--ink); background: var(--panel); }
.avatar { appearance: none; border: 0; width: 34px; height: 34px; border-radius: 50%; background: var(--chip); color: var(--ink); display: grid; place-items: center; font-size: 13px; font-weight: 600; cursor: pointer; flex: none; }

/* ---------- 6. Кнопки ---------- */
.btn { appearance: none; border: 0; margin: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r-m); background: transparent; color: var(--ink); font-size: 14px; line-height: 20px; font-weight: 500; white-space: nowrap; cursor: pointer; user-select: none; position: relative;
  transition: background-color var(--d-hover) var(--e-out), color var(--d-hover) var(--e-out), box-shadow var(--d-hover) var(--e-out), opacity var(--d-hover) var(--e-out), transform var(--d-press) var(--e-std); }
.btn:active, .btn.is-pressed { transform: scale(.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.btn svg.i { width: 18px; height: 18px; }
.btn--primary { background: var(--ink); color: var(--paper); }
.btn--primary:hover, .btn--primary.is-hover { background: color-mix(in oklab, var(--ink) 84%, var(--paper)); }
.btn--secondary { background: var(--chip); color: var(--ink); }
.btn--secondary:hover, .btn--secondary.is-hover { background: color-mix(in oklab, var(--chip) 91%, var(--ink)); }
.btn--outline { background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.btn--outline:hover, .btn--outline.is-hover { background: color-mix(in oklab, var(--panel) 96%, var(--ink)); }
.btn--ghost:hover, .btn--ghost.is-hover { background: var(--ink-soft); }
.btn--danger { background: var(--danger); color: var(--on-accent); }
.btn--danger:hover, .btn--danger.is-hover { background: color-mix(in oklab, var(--danger) 88%, var(--ink)); }
.btn--danger-ghost { color: var(--danger); }
.btn--danger-ghost:hover, .btn--danger-ghost.is-hover { background: var(--danger-soft); }
.btn:disabled, .btn.is-disabled { opacity: .38; pointer-events: none; }
.btn--s { height: 32px; padding: 0 12px; gap: 6px; font-size: 13px; border-radius: var(--r-s); }
.btn--s svg.i { width: 16px; height: 16px; }
.btn--m44 { height: 44px; }
.btn--l { height: 56px; padding: 0 22px; gap: 10px; font-size: 16px; border-radius: var(--r-l); font-weight: 600; }
.btn--l svg.i { width: 20px; height: 20px; }
.btn--block { width: 100%; }
.btn--icon { width: 40px; padding: 0; }
.btn--icon.btn--s { width: 32px; }

/* «Скачать .conf» → «Скачано» */
.btn-dl { overflow: hidden; transition: background-color var(--d-fast) var(--e-out), color var(--d-fast) var(--e-out), transform var(--d-press) var(--e-std); }
.btn-dl__a, .btn-dl__b { display: inline-flex; align-items: center; justify-content: center; gap: 10px; transition: opacity var(--d-fast) var(--e-out), transform var(--d-fast) var(--e-out); }
.btn-dl__b { position: absolute; inset: 0; opacity: 0; transform: translateY(6px); }
.btn-dl__b path { stroke-dasharray: 22; stroke-dashoffset: 22; transition: stroke-dashoffset 240ms var(--e-out) 80ms; }
.btn-dl.is-done { background: var(--ok); color: var(--on-accent); }
.btn-dl.is-done .btn-dl__a { opacity: 0; transform: translateY(-6px); }
.btn-dl.is-done .btn-dl__b { opacity: 1; transform: none; }
.btn-dl.is-done .btn-dl__b path { stroke-dashoffset: 0; }

/* ---------- 7. Поля ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink); display: flex; justify-content: space-between; gap: 8px; }
.field__label span { color: var(--ink-2); font-weight: 400; }
.field__hint { font-size: 12.5px; line-height: 17px; color: var(--ink-2); }
.field__error { font-size: 12.5px; line-height: 17px; color: var(--danger); }
.input { appearance: none; display: block; width: 100%; height: 40px; margin: 0; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); color: var(--ink); font: inherit; font-size: 14px; outline: none;
  transition: border-color var(--d-hover) var(--e-out), box-shadow var(--d-hover) var(--e-out), background-color var(--d-hover) var(--e-out); }
.input::placeholder { color: var(--ink-2); opacity: .85; }
.input:hover, .input.is-hover { border-color: color-mix(in oklab, var(--line) 62%, var(--ink-2)); }
.input:focus, .input.is-focus { border-color: var(--ink); box-shadow: var(--focus); }
.input.is-error { border-color: var(--danger); }
.input.is-error.is-focus { box-shadow: 0 0 0 3px var(--danger-soft); }
.input:disabled, .input.is-disabled { background: var(--chip); border-color: transparent; color: var(--ink-2); }
.input--l { height: 44px; font-size: 15px; }
.input--icon { padding-left: 36px; }
.input--aside { padding-right: 40px; }
.input--mono { font-family: var(--f-mono); font-size: 13px; }
textarea.input { height: auto; padding: 10px 12px; line-height: 20px; resize: none; }
.input-wrap { position: relative; display: flex; align-items: center; min-width: 0; }
.input-wrap > .input-ic { position: absolute; left: 12px; color: var(--ink-2); pointer-events: none; display: flex; }
.input-wrap > .input-end { position: absolute; right: 10px; display: flex; align-items: center; gap: 6px; color: var(--ink-2); }

/* код 2FA: 6 ячеек */
.otp { display: flex; align-items: center; gap: 8px; }
.otp__slot { position: relative; display: block; }
.otp__cell { appearance: none; display: block; width: 46px; height: 58px; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); font: inherit; font-size: 24px; font-weight: 500; text-align: center; outline: none;
  transition: border-color var(--d-hover) var(--e-out), box-shadow var(--d-hover) var(--e-out); }
.otp__cell.is-focus { border-color: var(--ink); box-shadow: var(--focus); }
.otp__cell.is-error { border-color: var(--danger); }
.otp__caret { position: absolute; left: 50%; top: 17px; width: 1.5px; height: 24px; margin-left: -.75px; background: var(--ink); animation: caret 1060ms steps(1) infinite; pointer-events: none; }
.otp__sep { width: 10px; height: 1.5px; border-radius: 1px; background: var(--line); margin: 0 2px; }
@keyframes caret { 50% { opacity: 0; } }

/* сегменты */
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 11px; background: var(--chip); }
.seg__btn { appearance: none; border: 0; margin: 0; height: 32px; padding: 0 12px; border-radius: 8px; background: transparent; color: var(--ink-2); font-size: 13px; line-height: 1; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color var(--d-fast) var(--e-out), color var(--d-fast) var(--e-out), box-shadow var(--d-fast) var(--e-out); }
.seg__btn:hover { color: var(--ink); }
.seg__btn.is-on { background: var(--raised); color: var(--ink); box-shadow: var(--shadow-seg); }
.seg--block { display: flex; }
.seg--block .seg__btn { flex: 1 1 auto; }
.seg--s .seg__btn { height: 28px; padding: 0 11px; font-size: 12.5px; }
.seg--grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.seg--grid .seg__btn { height: 40px; }

/* чипы-фильтры */
.chips { display: flex; gap: 8px; flex-wrap: nowrap; }
.chip { appearance: none; border: 0; margin: 0; display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: var(--r-pill); background: var(--chip); color: var(--ink); font-size: 13px; line-height: 1; font-weight: 500; white-space: nowrap; cursor: pointer;
  transition: background-color var(--d-hover) var(--e-out), color var(--d-hover) var(--e-out), transform var(--d-press) var(--e-std); }
.chip:hover, .chip.is-hover { background: color-mix(in oklab, var(--chip) 90%, var(--ink)); }
.chip:active { transform: scale(.98); }
.chip__n { color: var(--ink-2); min-width: 1ch; }
.chip.is-on { background: var(--ink); color: var(--paper); }
.chip.is-on .chip__n { color: color-mix(in oklab, var(--paper) 62%, var(--ink)); }
.chip .dot { width: 6px; height: 6px; }

/* чекбокс */
.cb { appearance: none; margin: 0; flex: none; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid color-mix(in oklab, var(--line) 35%, var(--ink-2)); background: var(--panel); display: inline-grid; place-content: center; cursor: pointer;
  transition: background-color var(--d-hover) var(--e-out), border-color var(--d-hover) var(--e-out); }
.cb::after { content: ""; width: 9px; height: 5px; border-left: 2px solid var(--paper); border-bottom: 2px solid var(--paper); transform: translateY(-1px) rotate(-45deg) scale(0); transition: transform var(--d-fast) var(--e-out); }
.cb:checked, .cb.is-on { background: var(--ink); border-color: var(--ink); }
.cb:checked::after, .cb.is-on::after { transform: translateY(-1px) rotate(-45deg) scale(1); }
.cb.is-mixed { background: var(--ink); border-color: var(--ink); }
.cb.is-mixed::after { width: 8px; height: 0; border-left: 0; border-bottom: 2px solid var(--paper); transform: none; }

/* ---------- 8. Знак состояния: точка и круги на воде ---------- */
.mark { --s: 12px; --ring: var(--d-ring); position: relative; display: inline-block; flex: none; width: var(--s); height: var(--s); color: var(--ok); transition: color var(--d-state) var(--e-out); }
.mark::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: currentColor; }
.mark > i { position: absolute; inset: 0; border-radius: 50%; border: 1px solid currentColor; opacity: 0; animation: ring var(--ring) var(--e-ring) infinite; }
.mark > i:nth-child(2) { animation-delay: calc(var(--ring) / -3); }
.mark > i:nth-child(3) { animation-delay: calc(var(--ring) / -1.5); }
.mark--warn { color: var(--warn); --ring: 1600ms; }
.mark--danger { color: var(--danger); }
.mark--danger > i { animation: none; opacity: 0; }
.mark--danger::before { animation: beat 1600ms var(--e-out) infinite; }
.mark--idle { color: var(--ink-2); }
.mark--idle > i { animation: none; opacity: 0; }
.mark--ink { color: var(--ink); --ring: 4200ms; }
.mark--still > i { animation: none; opacity: .32; transform: scale(2); }
.mark--still > i:nth-child(2) { opacity: .16; transform: scale(3); }
.mark--still > i:nth-child(3) { opacity: 0; }
@keyframes ring { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(3.4); opacity: 0; } }
@keyframes beat { 0% { transform: scale(1); } 12% { transform: scale(1.4); } 30% { transform: scale(1); } 100% { transform: scale(1); } }

/* статичные точки (строки таблиц, ленты) */
.dot { display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dot--s { width: 6px; height: 6px; }
.dot--hollow { background: transparent; box-shadow: inset 0 0 0 1.5px currentColor; }
.st { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; line-height: 18px; white-space: nowrap; }

/* ---------- 9. Схема каскада ---------- */
.cascade { display: grid; grid-template-columns: 104px minmax(24px, .5fr) 316px minmax(0, 1.6fr) 316px minmax(24px, .5fr) 84px; align-items: center; }
.node { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px 18px; }
.node__top { display: flex; align-items: center; gap: 12px; }
.node__meta { display: flex; flex-direction: column; gap: 2px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; line-height: 16px; color: var(--ink-2); }
.chk { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.chk svg.i { width: 14px; height: 14px; stroke-width: 2; color: var(--ok); }
.chk.is-bad svg.i { color: var(--danger); }
.chk.is-bad { color: var(--danger); }
.meters { display: grid; grid-template-columns: 38px minmax(0, 1fr) 44px; column-gap: 10px; row-gap: 8px; align-items: center; font-size: 12px; line-height: 16px; }
.meters > .v { text-align: right; color: var(--ink); }
.meters > .k { color: var(--ink-2); }
.ep { display: flex; flex-direction: column; gap: 2px; }
.ep--end { align-items: flex-end; text-align: right; }
.wire { height: 1px; background: var(--ink-line); }
.tun { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 18px; }
.tun__age { font-size: 15px; line-height: 20px; font-weight: 600; }

.tunnel { position: relative; align-self: stretch; height: 2px; border-radius: 1px; background: var(--ink-line); overflow: hidden; }
.tunnel__pulse { position: absolute; inset: 0; animation: tunnel 2400ms var(--e-inout) infinite; }
.tunnel__pulse::after { content: ""; position: absolute; top: 0; right: 0; width: 44px; height: 100%; border-radius: 1px; background: var(--ok); }
.tunnel--warn { background: var(--warn-edge); }
.tunnel--warn .tunnel__pulse { animation-duration: 4200ms; }
.tunnel--warn .tunnel__pulse::after { background: var(--warn); }
.tunnel--danger { height: 0; background: none; border-top: 2px dashed var(--danger); overflow: visible; border-radius: 0; }
.tunnel--danger .tunnel__pulse { display: none; }
.tunnel--v { width: 2px; height: auto; align-self: center; }
.tunnel--v .tunnel__pulse { animation-name: tunnel-v; }
.tunnel--v .tunnel__pulse::after { top: auto; bottom: 0; width: 100%; height: 32px; }
.tunnel--v.tunnel--danger { width: 0; border-top: 0; border-left: 2px dashed var(--danger); }
@keyframes tunnel { 0% { transform: translateX(-100%); opacity: 0; } 14% { opacity: .9; } 86% { opacity: .9; } 100% { transform: translateX(0); opacity: 0; } }
@keyframes tunnel-v { 0% { transform: translateY(-100%); opacity: 0; } 14% { opacity: .9; } 86% { opacity: .9; } 100% { transform: translateY(0); opacity: 0; } }

/* тонкие полосы ресурсов */
.bar { position: relative; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.bar > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--ink); transition: width var(--d-count) var(--e-out); }
.bar--warn > span { background: var(--warn); }
.bar--danger > span { background: var(--danger); }
.bar--none > span { background: transparent; }

/* устаревшие данные: цвета и живые круги гасим */
.is-stale .mark { color: var(--ink-2); }
.is-stale .mark > i { animation: none; opacity: 0; }
.is-stale .mark::before { animation: none; }
.is-stale .tunnel__pulse { display: none; }
.is-stale .t-ok, .is-stale .t-warn, .is-stale .chk svg.i { color: var(--ink-2); }

/* ---------- 10. Метрики ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { display: flex; flex-direction: column; gap: 10px; padding: 20px 24px 20px; min-width: 0; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric__num { display: flex; align-items: baseline; gap: 8px; }
.metric__unit { font-family: var(--f-ui); font-size: 16px; font-weight: 500; color: var(--ink-2); letter-spacing: 0; }
.metric__cap { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; line-height: 18px; color: var(--ink-2); }
.metric__cap b { font-weight: 500; color: var(--ink); }
.count { transition: --n var(--d-count) var(--e-out); counter-reset: n var(--n); }
.count::after { content: counter(n); }

/* ---------- 11. Графики ---------- */
.plot { position: relative; }
.plot svg { display: block; overflow: visible; }
.plot__grid { stroke: var(--line); stroke-width: 1; fill: none; }
.plot__line { fill: none; stroke: var(--ink); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.plot__area { fill: var(--chart-fill); stroke: none; }
.plot__cross { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 2 3; fill: none; }
.plot__dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--ink); box-shadow: 0 0 0 3px var(--panel); }
.plot__ylab { position: absolute; right: 0; font-size: 11.5px; line-height: 14px; color: var(--ink-2); background: var(--panel); padding-left: 6px; }
.plot__x { display: flex; justify-content: space-between; font-size: 11.5px; line-height: 14px; color: var(--ink-2); }
.tip { position: absolute; padding: 6px 10px; border-radius: 8px; background: var(--inv); color: var(--inv-text); font-size: 12px; line-height: 16px; white-space: nowrap; box-shadow: var(--shadow-float); pointer-events: none; }
.tip b { font-weight: 600; }
.tip span { color: var(--inv-2); }
.spark { display: block; width: 96px; height: 24px; overflow: visible; }
.spark .l { fill: none; stroke: var(--ink-2); stroke-width: 1.25; stroke-linejoin: round; stroke-linecap: round; }
.spark .a { fill: var(--chart-fill); stroke: none; }
.spark.is-flat .l { stroke-dasharray: 2 3; }

/* ---------- 12. Таблица ---------- */
.tbl { display: flex; flex-direction: column; }
.tbl__row { display: grid; grid-template-columns: var(--cols); align-items: center; column-gap: 16px; min-height: 56px; padding: 0 20px; border-top: 1px solid var(--line); transition: background-color var(--d-hover) var(--e-out); }
.tbl__head { min-height: 44px; border-top: 0; font-size: 12.5px; line-height: 16px; font-weight: 500; color: var(--ink-2); }
.tbl__row:not(.tbl__head):hover, .tbl__row.is-hover { background: var(--ink-soft); }
.tbl__row.is-selected { background: color-mix(in oklab, var(--panel) 93%, var(--ink)); }
.tbl__row.is-active { background: color-mix(in oklab, var(--panel) 95%, var(--ink)); box-shadow: inset 2px 0 0 var(--ink); }
.cell-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-note { font-size: 13.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-traffic { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.cell-num { text-align: right; }
.row-actions { display: flex; justify-content: flex-end; gap: 2px; opacity: 0; transition: opacity var(--d-hover) var(--e-out); }
.tbl__row:hover .row-actions, .tbl__row.is-hover .row-actions { opacity: 1; }

/* появление и уход строк */
.rowx { display: grid; grid-template-rows: 1fr; opacity: 1; transition: grid-template-rows var(--d-row) var(--e-out), opacity 200ms var(--e-out); }
.rowx > * { min-height: 0; overflow: hidden; }
.rowx.is-hidden { grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows 220ms var(--e-in) 60ms, opacity 120ms var(--e-in); }
.row-new { animation: row-in var(--d-row) var(--e-out) both, row-flash 1600ms var(--e-out) var(--d-row) both; }
@keyframes row-in { from { grid-template-rows: 0fr; opacity: 0; } to { grid-template-rows: 1fr; opacity: 1; } }
@keyframes row-flash { from { background-color: var(--ok-soft); } to { background-color: transparent; } }

/* скелетон: мягкое дыхание, без бегущего блика */
.sk { display: block; height: 10px; border-radius: 5px; background: var(--chip); animation: sk 1200ms var(--e-inout) infinite alternate; }
.sk--dot { width: 8px; height: 8px; border-radius: 50%; }
@keyframes sk { from { opacity: 1; } to { opacity: .45; } }

/* ---------- 13. Лента событий ---------- */
.feed { display: flex; flex-direction: column; }
.feed__item { display: grid; grid-template-columns: 42px 6px minmax(0, 1fr); column-gap: 12px; padding: 9px 20px; align-items: start; }
.feed__time { font-size: 12.5px; line-height: 18px; color: var(--ink-2); }
.feed__item .dot { margin-top: 6px; }
.feed__text { font-size: 13.5px; line-height: 18px; color: var(--ink); }
.feed__who { font-size: 12px; line-height: 16px; color: var(--ink-2); margin-top: 2px; }

/* ---------- 14. Обратная связь ---------- */
.banner { display: flex; align-items: center; gap: 14px; padding: 14px 14px 14px 20px; border-radius: 16px; background: var(--chip); }
.banner--danger { background: var(--danger-soft); box-shadow: inset 0 0 0 1px var(--danger-edge); }
.banner--warn { background: var(--warn-soft); box-shadow: inset 0 0 0 1px var(--warn-edge); }
.banner__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.banner__title { font-size: 14px; line-height: 20px; font-weight: 600; }
.banner__text { font-size: 13px; line-height: 18px; color: var(--ink-2); }
.banner__acts { display: flex; gap: 6px; flex: none; }

.toast { position: absolute; right: 24px; bottom: 24px; width: 380px; display: flex; align-items: flex-start; gap: 12px; padding: 14px 12px 16px 16px; border-radius: var(--r-l); background: var(--inv); color: var(--inv-text); box-shadow: var(--shadow-float); overflow: hidden; }
.toast__ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-inv); color: var(--inv); flex: none; }
.toast__ic svg.i { width: 14px; height: 14px; stroke-width: 2.2; }
.toast__ic--danger { background: var(--danger-inv); }
.toast__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; line-height: 20px; }
.toast__body span { color: var(--inv-2); font-size: 12.5px; line-height: 17px; }
.toast .btn { color: var(--inv-text); height: 28px; padding: 0 8px; font-size: 13px; }
.toast .btn:hover { background: var(--inv-hover); }
.toast__timer { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--inv-line); transform-origin: left center; }
.toast__timer.is-running { animation: toast-timer var(--d-toast) linear forwards; }
.toast:hover .toast__timer { animation-play-state: paused; }
@keyframes toast-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* плавающая панель действий над выбранными строками */
.fbar { position: absolute; bottom: 28px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 2px; height: 56px; padding: 0 8px 0 18px; border-radius: 16px; background: var(--inv); color: var(--inv-text); box-shadow: var(--shadow-float); white-space: nowrap; }
.fbar__count { font-size: 14px; font-weight: 600; margin-right: 10px; }
.fbar__sep { width: 1px; height: 24px; background: var(--inv-line); margin: 0 6px; }
.fbar .btn { color: var(--inv-text); }
.fbar .btn:hover { background: var(--inv-hover); }
.fbar .btn--inv { background: var(--inv-text); color: var(--inv); }
.fbar .btn--inv:hover { background: color-mix(in oklab, var(--inv-text) 88%, var(--inv)); }
.fbar .btn--inv-danger { color: var(--danger-inv); }

/* ---------- 15. Оверлеи ---------- */
.scrim { position: absolute; inset: 0; background: var(--scrim); }
.drawer { position: absolute; top: 12px; right: 12px; bottom: 12px; width: 480px; display: flex; flex-direction: column; background: var(--panel); border-radius: var(--r-xl); box-shadow: var(--shadow-float); overflow: hidden; }
.drawer--wide { width: 560px; }
.drawer__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 22px 20px 0 24px; }
.drawer__body { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 20px; padding: 20px 24px 24px; }
.drawer__foot { display: flex; align-items: center; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--line); }
.modal { position: absolute; left: 50%; top: 50%; width: 440px; transform: translate(-50%, -50%); display: flex; flex-direction: column; gap: 18px; padding: 24px; background: var(--panel); border-radius: var(--r-xl); box-shadow: var(--shadow-float); }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; background: var(--panel); border-radius: 20px 20px 0 0; box-shadow: var(--shadow-float); overflow: hidden; }
.sheet__grab { width: 36px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; flex: none; }

/* анимации появления оверлеев (классы вешает htmx/JS при открытии) */
.drawer.is-entering { animation: drawer-in var(--d-drawer) var(--e-drawer) both; }
.drawer.is-leaving { animation: drawer-out 200ms var(--e-in) both; }
.scrim.is-entering { animation: fade-in 240ms var(--e-out) both; }
.scrim.is-leaving { animation: fade-out 200ms var(--e-in) both; }
.modal.is-entering { animation: modal-in 200ms var(--e-out) both; }
.toast.is-entering { animation: toast-in 240ms var(--e-out) both; }
.toast.is-leaving { animation: toast-out 180ms var(--e-in) both; }
.fbar.is-entering { animation: fbar-in 240ms var(--e-out) both; }
@keyframes drawer-in { from { transform: translateX(calc(100% + 24px)); } to { transform: none; } }
@keyframes drawer-out { from { transform: none; } to { transform: translateX(calc(100% + 24px)); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translate(-50%, -50%) scale(.98); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(8px); } }
@keyframes fbar-in { from { opacity: 0; transform: translate(-50%, 24px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 16. Телефон ---------- */
.tabbar { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); height: 84px; padding: 6px 8px 28px; background: var(--panel); border-top: 1px solid var(--line); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 50px; color: var(--ink-2); font-size: 10.5px; line-height: 13px; font-weight: 500; }
.tab__ic { width: 52px; height: 30px; border-radius: 15px; display: grid; place-items: center; transition: background-color var(--d-fast) var(--e-out); }
.tab.is-on { color: var(--ink); }
.tab.is-on .tab__ic { background: var(--chip); }
.tab svg.i { width: 22px; height: 22px; }

/* QR-заглушка */
.qr { display: block; background: #FFFFFF; border-radius: 12px; padding: 10px; }
.qr path { fill: #151515; stroke: none; }

/* ---------- 17. Переходы между разделами (View Transitions API) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(main) { animation: 120ms cubic-bezier(.4, 0, 1, 1) both vt-out; }
::view-transition-new(main) { animation: 180ms cubic-bezier(.2, .8, .2, 1) both vt-in; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 18. prefers-reduced-motion: всё сводится к простому fade ---------- */
@media (prefers-reduced-motion: reduce) {
  @keyframes drawer-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes drawer-out { from { opacity: 1; } to { opacity: 0; } }
  @keyframes toast-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes toast-out { from { opacity: 1; } to { opacity: 0; } }
  @keyframes fbar-in { from { opacity: 0; transform: translate(-50%, 0); } to { opacity: 1; transform: translate(-50%, 0); } }
  @keyframes modal-in { from { opacity: 0; transform: translate(-50%, -50%); } to { opacity: 1; transform: translate(-50%, -50%); } }
  @keyframes row-in { from { opacity: 0; } to { opacity: 1; } }
  @keyframes vt-in { from { opacity: 0; } }
  .fc .drawer.is-entering, .fc .drawer.is-leaving, .fc .toast.is-entering, .fc .fbar.is-entering, .fc .modal.is-entering { animation-duration: 120ms; }
  .fc .mark > i { animation: none; opacity: .3; transform: scale(2); }
  .fc .mark > i:nth-child(2) { opacity: .15; transform: scale(3); }
  .fc .mark > i:nth-child(3) { opacity: 0; }
  .fc .mark--danger > i, .fc .mark--idle > i { opacity: 0; }
  .fc .mark--danger::before { animation: none; }
  .fc .tunnel__pulse { animation: none; opacity: 0; }
  .fc .sk { animation: none; opacity: .7; }
  .fc .otp__caret { animation: none; }
  .fc .count { transition: none; }
  .fc .btn:active, .fc .chip:active { transform: none; }
  .fc .rowx, .fc .rowx.is-hidden { transition: opacity 120ms linear; }
  .fc .btn-dl__a, .fc .btn-dl__b { transform: none !important; }
}
