/* B&R — админ-панель. Источник правды: docs/PANEL_DESIGN.md (надстройка над
   docs/DESIGN.md). Палитра, шрифт, радиусы, тени и движение — общие с мини-аппом
   (app/templates/miniapp/_styles.html), здесь только плотность панели.

   Тема одна — светлая. color-scheme: light перебивает системную тёмную тему
   и заставляет браузер рисовать светлыми нативные контролы.

   Порядок файла:
     1. Шрифт и токены           6. Таблица, тулбар, пагинация
     2. База                     7. Шторка, модалка, тост, поповер
     3. Каркас: меню, шапка      8. Сводка
     4. Кнопки                   9. Вход
     5. Поля, сегменты, бейджи, 10. Ширины, движение, forced-colors
        чипы, дерево, плитки

   Движение: анимируются только transform и opacity. Нет backdrop-filter,
   filter: blur(), переходов box-shadow / width / height / background. */

/* ── 1. Шрифт и токены ────────────────────────────────────────────────── */

/* Golos Text — один переменный файл 400–700 на подмножество (Google Fonts, OFL),
   со своего сервера: вход не зависит от внешнего домена, планшет работает офлайн.
   Фирменный вид «мороженое» (холст Claude Design, решение владельца 25.11.2026). */
@font-face { font-family: 'Golos Text'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/static/fonts/golos-text-cyrillic.woff2') format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Golos Text'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/static/fonts/golos-text-cyrillic-ext.woff2') format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F; }
@font-face { font-family: 'Golos Text'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/static/fonts/golos-text-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Golos Text'; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url('/static/fonts/golos-text-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  color-scheme: light;

  /* DESIGN.md §2.2 — один в один с мини-аппом. Поверхностей четыре, новых не заводить.
     Цвета — фирменный вид «мороженое» (25.11.2026): шоколадный главный цвет и
     текст, кремовые фоны, розовый — только в логотипе (26.11.2026: розовый
     спорил с красными статусами); статусы прежние. Контраст — tests/e2e/panel/test_brand.py. */
  --color-bg: #F9F9F9;
  --color-surface: #FFFFFF;
  --color-surface-2: #F2E9E5;
  --color-surface-3: #E8DAD3;
  --color-border: #DADADA;
  --color-border-control: #646464;
  --color-text: #402022;
  --color-text-2: #6B655B;
  --color-text-disabled: #8C867C;
  --color-accent: #402022;
  --color-accent-hover: #5A3336;
  --color-accent-pressed: #2E1618;
  --color-on-accent: #FFFFFF;
  --color-accent-ink: #402022;
  --color-accent-soft: #EFE3DD;
  --color-accent-soft-pressed: #E8D9D1;
  --color-ok: #11774A;   --color-ok-soft: #E6F4EC;
  --color-warn: #9A5300; --color-warn-soft: #FCF0E1;
  --color-err: #C0263D;  --color-err-soft: #FCE9EC;
  --color-info: #1D5FBF; --color-info-soft: #E8F0FC;
  --color-err-hover: #A51F33;
  --color-err-soft-hover: #F9DCE1;
  --color-focus: #402022;
  --color-scrim: rgba(64, 32, 34, .40);
  --color-inverse: #402022;
  --color-on-inverse: #FFFFFF;
  --color-inverse-ok: #5BD69A;
  --color-inverse-err: #FF8A9A;
  --color-inverse-ink: #E8D3C8;   /* действие в тосте, 6.9 на inverse */
  --color-inverse-2: #D3B5A7;     /* подписи в подсказке графика, 8.60 */
  --gradient-brand: linear-gradient(90deg, #402022 0%, #402022 100%);

  --font-display: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-text: 'Golos Text', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius-xs: 4px; --radius-sm: 8px; --radius-md: 12px; --radius-lg: 16px; --radius-pill: 999px;
  --shadow-1: 0 1px 2px rgba(64, 32, 34, .06), 0 1px 1px rgba(64, 32, 34, .04);
  --shadow-2: 0 8px 24px rgba(64, 32, 34, .14);
  --dur-1: 120ms; --dur-2: 180ms; --dur-3: 240ms;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-sheet: cubic-bezier(0.32, 0.72, 0, 1);

  /* Надстройка панели, PANEL_DESIGN.md §3 */
  --p-sidebar: 248px;
  --p-rail: 64px;
  --p-gutter: 32px;          /* 24 на <1280, 16 на <768 */
  --p-control: 40px;
  --p-control-sm: 32px;
  --p-thead: 40px;
  --p-row: 52px;
  --p-row-2: 60px;
  --p-drawer: 520px;
  --p-modal: 480px;
  --p-modal-sm: 400px;

}

/* ── 2. База ──────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--color-bg);
  color: var(--color-text);
  font: 400 14px/20px var(--font-text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-display); font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--color-accent-ink); }
svg { flex: none; }
img { max-width: 100%; }

/* Фокус — везде одинаковый и без смены скругления (дефект §0.1 п.6). */
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

[hidden] { display: none !important; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.is-err  { color: var(--color-err) !important; }
.is-warn { color: var(--color-warn) !important; }
.is-ok   { color: var(--color-ok) !important; }
.is-mute { color: var(--color-text-2) !important; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon--16 { width: 16px; height: 16px; }
.icon--24 { width: 24px; height: 24px; }
.icon.is-spin { animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.skip-link {
  position: fixed; z-index: 300; left: 16px; top: 8px;
  padding: 8px 16px; border-radius: var(--radius-xs);
  background: var(--color-inverse); color: var(--color-on-inverse); font-weight: 600; text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus-visible { transform: none; }

/* ── 3. Каркас ────────────────────────────────────────────────────────── */

.app { display: grid; grid-template-columns: var(--p-sidebar) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 40;
  display: flex; flex-direction: column;
  padding: 12px; overflow-y: auto; overscroll-behavior: contain;
  background: var(--color-surface); border-right: 1px solid var(--color-border);
}
.brand { display: flex; align-items: center; gap: 12px; height: 48px; padding: 0 4px 0 8px; margin-bottom: 8px; flex: none; }
.brand__logo { width: 32px; height: 32px; border-radius: var(--radius-xs); flex: none; display: block; }
.brand__title { flex: 1; min-width: 0; font: 600 14px/20px var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav__link {
  position: relative; display: flex; align-items: center; gap: 12px;
  height: 40px; padding: 0 8px 0 10px; border-radius: var(--radius-xs);
  color: var(--color-text); text-decoration: none; font-weight: 500;
}
.nav__link .icon { color: var(--color-text-2); }
.nav__link[aria-current] { background: var(--color-accent-soft); color: var(--color-accent-ink); font-weight: 600; }
.nav__link[aria-current] .icon { color: var(--color-accent-ink); }
@media (hover: hover) { .nav__link:not([aria-current]):hover { background: var(--color-surface-2); } }
.nav__link:active { background: var(--color-surface-3); }
.nav__link:focus-visible { outline-offset: -2px; }
.nav__label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav__count {
  min-width: 24px; height: 24px; padding: 0 8px; border-radius: var(--radius-pill);
  background: var(--color-err-soft); color: var(--color-err);
  font-weight: 600; line-height: 24px; text-align: center; font-variant-numeric: tabular-nums;
}

.sidebar__foot {
  margin-top: auto; padding: 12px 0 0 8px; flex: none;
  display: flex; align-items: center; gap: 12px;
  border-top: 1px solid var(--color-border);
}
.me { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.me__text { min-width: 0; }
.me__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me__role { color: var(--color-text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Подсказка пункта в rail. Один узел на документ, позиционируется из JS
   (position: fixed): у .sidebar overflow-y: auto, и абсолютная подсказка
   обрезалась бы его краем. */
.nav-tip {
  position: fixed; z-index: 250; pointer-events: none;
  padding: 4px 8px; border-radius: var(--radius-xs);
  background: var(--color-inverse); color: var(--color-on-inverse); white-space: nowrap;
  opacity: 0; transition: opacity var(--dur-1) linear;
}
.nav-tip.is-on { opacity: 1; }

.nav-scrim { position: fixed; inset: 0; z-index: 39; background: var(--color-scrim); }

/* Вторая колонка каркаса: полоса страниц раздела и рабочая область (NAV_IA §9.2). */
.app__col { display: flex; flex-direction: column; min-width: 0; }
.main { flex: 1; min-width: 0; padding: 24px var(--p-gutter) 48px; }

/* Полоса второй ступени — страницы раздела (NAV_IA §3.2). Не липкая. */
.subnav { background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 8px var(--p-gutter); }
.subnav__row { max-width: 1536px; margin: 0 auto; display: flex; align-items: center; gap: 4px; min-width: 0; }
.subnav__list { position: relative; display: flex; gap: 4px; min-width: 0; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain; padding: 2px 0; margin: -2px 0; }
.subnav__list::-webkit-scrollbar { display: none; }
.subnav__link {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px; border-radius: var(--radius-xs);
  color: var(--color-text-2); text-decoration: none; font-weight: 500; white-space: nowrap;
}
.subnav__link::after { content: ""; position: absolute; inset: -2px 0; }
@media (hover: hover) { .subnav__link:not([aria-current]):hover { background: var(--color-surface-2); color: var(--color-text); } }
.subnav__link:active { background: var(--color-surface-3); }
.subnav__link[aria-current] { background: var(--color-accent-soft); color: var(--color-accent-ink); font-weight: 600; }
.subnav__link:focus-visible { outline-offset: -2px; }
.subnav .burger { display: none; }
.main:focus { outline: none; }
.page { max-width: 1536px; margin: 0 auto; animation: page-in var(--dur-2) linear; }
@keyframes page-in { from { opacity: 0; } }

/* Шапка страницы — часть страницы, не липкая. Один h1. */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; min-height: 40px; margin-bottom: 24px; }
.page-head__title { display: flex; align-items: center; gap: 12px; margin-right: auto; min-width: 0; }
.page-head h1 { font: 700 24px/32px var(--font-display); letter-spacing: -0.01em; display: flex; align-items: baseline; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.page-head__count { font: 400 16px/24px var(--font-text); color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.page-head__tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.page-head .burger { display: none; }

/* Демо-режим без API (index.html): плашка над страницей. */

/* ── 4. Кнопки ────────────────────────────────────────────────────────── */

/* .btn без варианта = neutral. */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--p-control); padding: 0 16px;
  border: 1px solid var(--color-border); border-radius: var(--radius-xs);
  background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-1);
  font: 600 14px/20px var(--font-display); white-space: nowrap; text-decoration: none; cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out);
}
.btn::after { content: ""; position: absolute; inset: -3px -1px; }  /* 40 → 44 */
.btn .icon { color: var(--color-text-2); }
.btn:active { transform: scale(.98); }
@media (hover: hover) { .btn:hover { background: var(--color-bg); } }

.btn--primary { background: var(--color-accent); border-color: transparent; color: var(--color-on-accent); box-shadow: none; }
.btn--primary .icon { color: inherit; }
.btn--secondary { background: var(--color-accent-soft); border-color: transparent; color: var(--color-accent-ink); box-shadow: none; }
.btn--secondary .icon, .btn--ghost .icon { color: inherit; }
.btn--ghost { background: transparent; border-color: transparent; color: var(--color-accent-ink); box-shadow: none; }
.btn--danger { background: var(--color-err); border-color: transparent; color: #fff; box-shadow: none; }
.btn--danger .icon, .btn--danger-soft .icon { color: inherit; }
.btn--danger-soft { background: var(--color-err-soft); border-color: transparent; color: var(--color-err); box-shadow: none; }
@media (hover: hover) {
  .btn--primary:hover { background: var(--color-accent-hover); }
  .btn--secondary:hover, .btn--ghost:hover { background: var(--color-accent-soft-pressed); }
  .btn--ghost:hover { background: var(--color-accent-soft); }
  .btn--danger:hover { background: var(--color-err-hover); }
  .btn--danger-soft:hover { background: var(--color-err-soft-hover); }
}
.btn--primary:active { background: var(--color-accent-pressed); }
.btn--secondary:active { background: var(--color-accent-soft-pressed); }

.btn--sm { height: var(--p-control-sm); padding: 0 12px; }
.btn--sm::after { inset: -6px -1px; }
.btn--block { width: 100%; }

.btn:disabled, .btn[aria-disabled="true"] {
  background: var(--color-surface-2); color: var(--color-text-disabled);
  border-color: transparent; box-shadow: none; cursor: default; transform: none;
}
.btn:disabled .icon { color: inherit; }
.btn[aria-busy="true"] { cursor: progress; }

/* Иконочная кнопка: 40 или 32, aria-label обязателен. */
.ibtn {
  position: relative; display: inline-grid; place-items: center; flex: none;
  width: var(--p-control); height: var(--p-control); padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-xs);
  background: transparent; color: var(--color-text-2); cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out);
}
.ibtn::after { content: ""; position: absolute; inset: -2px; }
.ibtn:active { transform: scale(.96); }
.ibtn--sm { width: var(--p-control-sm); height: var(--p-control-sm); }
.ibtn--sm::after { inset: -6px; }
.ibtn--neutral { background: var(--color-surface); border-color: var(--color-border); box-shadow: var(--shadow-1); color: var(--color-text); }
.ibtn--danger { color: var(--color-err); }
@media (hover: hover) {
  .ibtn:hover { background: var(--color-surface-2); color: var(--color-text); }
  .ibtn--neutral:hover { background: var(--color-bg); }
  .ibtn--danger:hover { background: var(--color-err-soft); color: var(--color-err); }
}
.ibtn:disabled { color: var(--color-text-disabled); background: transparent; box-shadow: none; border-color: transparent; cursor: default; transform: none; }
.ibtn--neutral:disabled { background: var(--color-surface-2); }

/* ── 5. Поля, сегменты, вкладки, бейджи, карточки ─────────────────────── */

.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field__label { font-weight: 600; color: var(--color-text); }
.field__hint { color: var(--color-text-2); margin-top: -4px; }
.field__error { display: flex; align-items: flex-start; gap: 4px; color: var(--color-err); margin-top: -4px; }
.field__error .icon { margin-top: 2px; }
.field--grow { flex: 1 1 220px; }
.span-2 { grid-column: 1 / -1; }

.input, .select, .textarea {
  display: block; width: 100%; min-width: 0; height: var(--p-control); padding: 0 12px;
  border: 1px solid var(--color-border-control); border-radius: var(--radius-xs);
  background: var(--color-surface); color: var(--color-text); font: 400 14px/20px var(--font-text);
}
.textarea { height: auto; min-height: 88px; padding: 8px 12px; resize: vertical; }
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235E5670' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input::placeholder, .textarea::placeholder { color: var(--color-text-2); opacity: 1; }
/* Фокус: рамка 2px с компенсацией padding — текст не прыгает. */
.input:focus, .select:focus, .textarea:focus {
  outline: none; border: 2px solid var(--color-accent); padding-left: 11px;
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}
.select:focus { padding-right: 35px; }
.textarea:focus { padding-top: 7px; padding-right: 11px; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border: 2px solid var(--color-err); padding-left: 11px; }
.input:disabled, .select:disabled, .textarea:disabled { background: var(--color-surface-2); border-color: transparent; color: var(--color-text-disabled); cursor: not-allowed; }
.input[readonly] { background: var(--color-surface-2); border-color: transparent; }
input[type="date"].input, input[type="time"].input, .input--time { font-variant-numeric: tabular-nums; }
@media (pointer: coarse) { .input, .select, .textarea { font-size: 16px; line-height: 24px; } }

/* Поле с ведущей иконкой и/или кнопкой справа (поиск, пароль). */
.with-icon { position: relative; display: block; min-width: 0; }
.with-icon > .icon { position: absolute; left: 12px; top: 12px; color: var(--color-text-2); pointer-events: none; }
.with-icon--lead > .input { padding-left: 40px; }
.with-icon--lead > .input:focus { padding-left: 39px; }
.with-icon--end > .input { padding-right: 44px; }
.with-icon--end > .input:focus { padding-right: 43px; }
.with-icon__end { position: absolute; right: 4px; top: 4px; }
.search { width: 280px; }
.search .input::-webkit-search-cancel-button { display: none; }

/* Чекбокс: нативный input визуально скрыт и остаётся в фокусе. */
.check { position: relative; display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 10px 0; cursor: pointer; }
.check input, .cb input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.check__box {
  display: grid; place-items: center; width: 20px; height: 20px; flex: none;
  border: 2px solid var(--color-border-control); border-radius: 4px;
  background: var(--color-surface); color: transparent;
}
.check__box .icon { width: 16px; height: 16px; }
.check input:checked + .check__box, .cb input:checked + .check__box,
.cb input:indeterminate + .check__box { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.check input:focus-visible + .check__box, .cb input:focus-visible + .check__box { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.check input:disabled + .check__box { background: var(--color-surface-2); border-color: var(--color-surface-3); }
.check__text { min-width: 0; }
.check__hint { display: block; color: var(--color-text-2); }
.cb { position: relative; display: inline-grid; place-items: center; width: 44px; height: 44px; margin: -12px 0; cursor: pointer; }
.cb .check__box { width: 18px; height: 18px; }
.cb .i-minus { display: none; }
.cb input:indeterminate + .check__box .i-check { display: none; }
.cb input:indeterminate + .check__box .i-minus { display: block; }

/* Радио: как чекбокс, круг 20; выбран — кольцо 6px accent. */
.radios { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; }
.radios > legend { padding: 0; margin-bottom: 4px; }
.radio { position: relative; display: flex; align-items: flex-start; gap: 12px; min-height: 44px; padding: 10px 0; cursor: pointer; }
.radio input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.radio__dot { width: 20px; height: 20px; flex: none; border-radius: 50%; border: 2px solid var(--color-border-control); background: var(--color-surface); }
.radio input:checked + .radio__dot { border: 6px solid var(--color-accent); }
.radio input:focus-visible + .radio__dot { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.radios:disabled .radio { cursor: default; color: var(--color-text-2); }
.radios:disabled .radio input:checked + .radio__dot { border-color: var(--color-text-disabled); }

/* Переключатель 36×20, зона 44 через ::before (KB_TICKETS_DESIGN §6.5). */
.switch {
  position: relative; width: 36px; height: 20px; flex: none; padding: 0; border: 0; cursor: pointer;
  border-radius: var(--radius-pill); background: var(--color-border-control);
  transition: background-color var(--dur-2) var(--ease-out);
}
.switch::before { content: ""; position: absolute; inset: -12px -4px; }
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; transition: transform var(--dur-2) var(--ease-out);
}
.switch[aria-checked="true"] { background: var(--color-accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }
.switch:disabled { cursor: default; opacity: .6; }
.switch:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }

/* Сетка иконок справочника: 8 колонок по 40. */
.icon-grid { display: grid; grid-template-columns: repeat(8, 40px); gap: 4px; max-width: 100%; }
.icon-grid button {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0; cursor: pointer;
  border: 1px solid transparent; border-radius: var(--radius-xs); background: none; color: var(--color-text-2);
}
@media (hover: hover) { .icon-grid button[aria-pressed="false"]:hover { background: var(--color-surface-2); } }
.icon-grid button[aria-pressed="true"] { background: var(--color-accent-soft); border: 2px solid var(--color-accent); color: var(--color-accent-ink); }
@media (max-width: 420px) { .icon-grid { grid-template-columns: repeat(auto-fill, 40px); } }

/* Поле с чипами-тегами. */
.tags {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 40px; padding: 4px 8px;
  border: 1px solid var(--color-border-control); border-radius: var(--radius-xs); background: var(--color-surface); cursor: text;
}
.tags:focus-within { border: 2px solid var(--color-accent); padding: 3px 7px; box-shadow: 0 0 0 3px var(--color-accent-soft); }
.tags__list { display: contents; }
.tag { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 4px 0 10px; border-radius: var(--radius-pill); background: var(--color-surface-2); color: var(--color-text-2); font-weight: 600; max-width: 100%; }
.tag > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag__x { position: relative; display: grid; place-items: center; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; }
.tag__x::before { content: ""; position: absolute; inset: -10px -4px; }
@media (hover: hover) { .tag__x:hover { background: var(--color-surface-3); } }
.tags__input { flex: 1; min-width: 120px; height: 30px; border: 0; padding: 0 4px; background: none; font: inherit; color: var(--color-text); }
.tags__input:focus { outline: none; }

/* Сетка формы: две колонки в шторке, полная ширина — .span-2. */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; min-width: 0; }
.form-grid > * { min-width: 0; }
.form-section { grid-column: 1 / -1; font: 600 16px/24px var(--font-display); margin-top: 16px; }
.form-section:first-child { margin-top: 0; }

/* Сегменты: взаимоисключающие значения до 4. */
.seg { display: inline-flex; gap: 4px; height: var(--p-control); padding: 4px; border-radius: var(--radius-xs); background: var(--color-surface-2); max-width: 100%; }
.seg button {
  position: relative; height: 32px; padding: 0 12px; border: 0; border-radius: 6px;
  background: transparent; color: var(--color-text-2); font-weight: 600; white-space: nowrap; cursor: pointer;
}
.seg button::after { content: ""; position: absolute; inset: -6px 0; }
.seg button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-1); }
@media (hover: hover) { .seg button[aria-pressed="false"]:hover { color: var(--color-text); } }
.seg button:focus-visible { outline-offset: 0; }
.seg--sm { height: 32px; padding: 2px; gap: 2px; }
.seg--sm button { height: 28px; padding: 0 10px; }
.seg--sm button::after { inset: -8px 0; }

/* Вкладки. Полоса без анимации. */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--color-border); overflow-x: auto; scrollbar-width: none; }
.tab { position: relative; flex: none; height: 40px; padding: 0; border: 0; background: transparent; font-weight: 600; color: var(--color-text-2); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--color-text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; border-radius: 2px 2px 0 0; background: var(--color-accent); }
@media (hover: hover) { .tab:hover { color: var(--color-text); } }
.tab:focus-visible { outline-offset: -2px; }

/* Бейдж: всегда иконка + текст, не только цвет. */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: var(--radius-pill); font-weight: 500; white-space: nowrap; background: var(--color-surface-2); color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.badge .icon { width: 16px; height: 16px; }
.b-ok { background: var(--color-ok-soft); color: var(--color-ok); }
.b-warn { background: var(--color-warn-soft); color: var(--color-warn); }
.b-err { background: var(--color-err-soft); color: var(--color-err); }
.b-info { background: var(--color-info-soft); color: var(--color-info); }
.b-mute { background: var(--color-surface-2); color: var(--color-text-2); }
.b-accent { background: var(--color-accent-soft); color: var(--color-accent-ink); }

.notice { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius-sm); min-width: 0; }
.notice__text { flex: 1; min-width: 0; }
.notice--warn { background: var(--color-warn-soft); color: var(--color-warn); }
.notice--err { background: var(--color-err-soft); color: var(--color-err); }
.notice--info { background: var(--color-info-soft); color: var(--color-info); }
.notice--mute { background: var(--color-surface-2); color: var(--color-text-2); }
.notice .btn { flex: none; }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm); min-width: 0; }
.card__head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 56px; padding: 8px 16px; border-bottom: 1px solid var(--color-border); }
.card__head h2 { font: 600 16px/24px var(--font-display); }
.card__meta { color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.card__tools { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.card__body { padding: 16px; min-width: 0; }

.avatar {
  display: grid; place-items: center; flex: none; overflow: hidden; object-fit: cover;
  width: 32px; height: 32px; border-radius: var(--radius-xs);
  background: var(--color-accent-soft); color: var(--color-accent-ink); font: 600 14px/20px var(--font-display);
}
.avatar--40 { width: 40px; height: 40px; border-radius: var(--radius-sm); font-size: 16px; }
.avatar--lg { width: 64px; height: 64px; border-radius: var(--radius-sm); font-size: 20px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-warn); flex: none; }
.dot--ok { background: var(--color-ok); }
.dot--err { background: var(--color-err); }

/* Пустое состояние — внутри своей карточки. */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 24px; }
.empty__ic { display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--radius-pill); background: var(--color-accent-soft); color: var(--color-accent-ink); }
.empty__ic--ok { background: var(--color-ok-soft); color: var(--color-ok); }
.empty__ic--err { background: var(--color-err-soft); color: var(--color-err); }
.empty h3 { margin-top: 16px; font: 600 16px/24px var(--font-display); color: var(--color-text); }
.empty p { margin-top: 4px; max-width: 360px; color: var(--color-text-2); font-size: 16px; line-height: 24px; overflow-wrap: anywhere; }
.empty .btn { margin-top: 16px; }
.empty--tall { min-height: 240px; justify-content: center; }
/* Пустая таблица — одна строка: надпись и подчёркнутая ссылка (26.11.2026). */
.empty.empty--line { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: baseline;
  gap: 4px 12px; padding: 20px 16px; color: var(--color-text-2); font-size: 14px; line-height: 20px; }
.empty.empty--line .btn { height: auto; margin: 0; padding: 0; border: 0; background: none; box-shadow: none;
  color: var(--color-accent-ink); font: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; }
.empty.empty--line .btn .icon { display: none; }
@media (hover: hover) { .empty.empty--line .btn:hover { background: none; color: var(--color-accent-hover); } }

/* Скелет: opacity-пульс, без бегущего градиента. */
.sk { display: block; border-radius: 6px; background: var(--color-surface-2); animation: sk 1.6s ease-in-out infinite; }
@keyframes sk { 50% { opacity: .5; } }
.skeleton-rows { display: flex; flex-direction: column; gap: 12px; padding: 16px; }
.skeleton-rows > .sk { height: 16px; }

/* Чипы-чекбоксы (chipChecks): весь список виден сразу, выбранное —
   заливкой и галочкой, а не только цветом. Зона касания 44. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
/* Выбор кафе таблетками (ui.js branchChips): свой ряд, не влезает — прокрутка вбок. */
.branch-chips {
  flex: 1 1 100%; display: flex; gap: 6px; min-width: 0; max-width: 100%;
  overflow-x: auto; scrollbar-width: thin; padding: 2px 0 4px;
}
.branch-chip {
  flex: 0 0 auto; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--color-border-control); background: var(--color-surface);
  color: var(--color-text); font: 500 13px/18px var(--font-body, inherit); white-space: nowrap; cursor: pointer;
}
@media (hover: hover) { .branch-chip[aria-pressed="false"]:hover { border-color: var(--color-accent); } }
.branch-chip[aria-pressed="true"] { border-color: var(--color-accent); background: var(--color-accent-soft); color: var(--color-accent-ink); font-weight: 600; }
.branch-chip:focus-visible { outline-offset: 1px; }
/* «Открытие кафе» → «Все»: название кафе одной строкой, не по слогам. */
.cafe-all td:first-child { white-space: nowrap; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; min-width: 64px; max-width: 100%; padding: 0 12px;
  border: 1px solid var(--color-border-control); border-radius: var(--radius-xs);
  background: var(--color-surface); color: var(--color-text); cursor: pointer; overflow-wrap: anywhere;
}
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.chip__box {
  display: grid; place-items: center; width: 18px; height: 18px; flex: none;
  border: 2px solid var(--color-border-control); border-radius: 4px; color: transparent;
}
.chip__box .icon { width: 14px; height: 14px; }
.chip:has(input:checked) { border-color: var(--color-accent); background: var(--color-accent-soft); color: var(--color-accent-ink); font-weight: 600; }
.chip:has(input:checked) .chip__box { background: var(--color-accent); border-color: var(--color-accent); color: #fff; }
.chip:has(input:focus-visible) { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.chip:has(input:disabled) { cursor: default; color: var(--color-text-2); }
@media (hover: hover) { .chip:not(:has(input:checked)):not(:has(input:disabled)):hover { background: var(--color-bg); } }

/* Дерево (tree): должности и оргструктура. Вложенность — отступ и линия
   уровня; строку оформляет страница своим rowClass. */
.tree, .tree__children { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tree__children { margin: 4px 0 0 23px; padding-left: 12px; border-left: 1px solid var(--color-border); }
.tree__node { min-width: 0; }
.tree__row { display: flex; align-items: center; gap: 12px; min-width: 0; border-radius: var(--radius-xs); }
.tree__toggle .icon { transition: transform var(--dur-1) var(--ease-out); }
.tree__toggle[aria-expanded="true"] .icon { transform: rotate(90deg); }
.tree__gap { width: 32px; flex: none; }

/* Плитки-цифры (statTiles) над таблицей в шторке. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 12px 16px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); min-width: 0; }
.stat__label { color: var(--color-text-2); }
.stat__value { font: 600 20px/28px var(--font-display); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* ── 6. Таблица, тулбар, пагинация ────────────────────────────────────── */

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 64px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); min-width: 0; }
.toolbar__right { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.toolbar--select { background: var(--color-surface); }
.toolbar--select .toolbar__count { font-weight: 600; }

/* Кнопка-фильтр: «Филиал Все ⇅». */
.filter-btn { font-family: var(--font-text); font-weight: 400; color: var(--color-text-2); }
.filter-btn b { font-weight: 600; color: var(--color-text); max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.filter-btn.is-applied { border-color: var(--color-accent); }
.filter-btn.is-applied b { color: var(--color-accent-ink); }
.filter-btn .icon--16 { color: var(--color-text-2); }

/* Обёртка обязана быть position: relative — иначе sr-only внутри ячеек
   выходит из клипа и даёт горизонтальный скролл всей странице (§5.1). */
.tbl-wrap { position: relative; overflow-x: auto; overscroll-behavior-x: contain; }
.tbl { width: 100%; min-width: var(--tbl-min, 0); border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
/* Пустая таблица не прокручивается вбок: ширина колонок нужна только данным (26.11.2026). */
.tbl:has(td.empty-cell) { min-width: 0; }
.tbl th {
  height: var(--p-thead); padding: 0 12px; text-align: left; font-weight: 600; color: var(--color-text-2);
  white-space: nowrap; border-bottom: 1px solid var(--color-border); background: var(--color-surface);
  position: sticky; top: 0; z-index: 1;
}
.tbl td { height: var(--p-row); padding: 8px 12px; border-bottom: 1px solid var(--color-border); vertical-align: middle; overflow-wrap: break-word; }
.tbl tr > :first-child { padding-left: 16px; }
.tbl tr > :last-child { padding-right: 16px; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .r, .tbl .num { text-align: right; white-space: nowrap; }
.tbl .shrink { width: 1%; white-space: nowrap; }
.tbl .nowrap { white-space: nowrap; }
.tbl .wrap-word { word-break: break-word; }
.tbl .td-2 { height: var(--p-row-2); }
.tbl .td-cb { width: 44px; padding-right: 0; }
.tbl tbody tr.is-link { cursor: pointer; }
@media (hover: hover) { .tbl tbody tr.is-link:hover td { background: var(--color-bg); } }
.tbl tbody tr[aria-selected="true"] td, .tbl tbody tr[aria-current="true"] td { background: var(--color-accent-soft); }
.tbl[aria-busy="true"] tbody { opacity: .6; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--color-border); border-bottom: 0; }
.tbl .empty-cell { padding: 0; height: auto; }
.tbl .mute { color: var(--color-text-2); }
.th-sort {
  position: relative; display: inline-flex; align-items: center; gap: 4px;
  height: 32px; margin: 0 -8px; padding: 0 8px; border: 0; border-radius: 6px;
  background: transparent; font-weight: 600; color: inherit; cursor: pointer; white-space: nowrap;
}
.th-sort::after { content: ""; position: absolute; inset: -6px 0; }
.th-sort .icon { opacity: 0; transition: opacity var(--dur-1) linear; }
.th-sort[data-active] { color: var(--color-text); }
.th-sort[data-active] .icon, .th-sort:focus-visible .icon { opacity: 1; }
@media (hover: hover) { .th-sort:hover .icon { opacity: 1; } .th-sort:hover { background: var(--color-surface-2); } }
.r .th-sort { flex-direction: row-reverse; }

.cell2 { display: flex; flex-direction: column; min-width: 0; }
.cell2__a { font-weight: 600; }
.cell2__b { color: var(--color-text-2); }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person .cell2 { word-break: break-word; }
.rowlink { all: unset; cursor: pointer; font-weight: 600; color: var(--color-text); overflow-wrap: anywhere; }
.rowlink:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; border-radius: 4px; }

.tfoot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 52px; padding: 8px 8px 8px 16px; border-top: 1px solid var(--color-border); color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.tfoot__pages { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* Меню строки и кнопки-фильтры: поповер-список. */
.pop {
  position: fixed; z-index: 120; min-width: 200px; max-width: 320px; max-height: min(400px, 70vh);
  display: flex; flex-direction: column; padding: 4px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xs); box-shadow: var(--shadow-2);
  animation: pop-in var(--dur-1) var(--ease-out);
}
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
.pop__search { padding: 4px 4px 8px; }
.pop__list { overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 2px; }
.pop__item {
  position: relative; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px 0 8px;
  border: 0; border-radius: 6px; background: transparent; color: var(--color-text); text-align: left; cursor: pointer;
}
.pop__item .icon { color: var(--color-text-2); }
.pop__item .pop__check { visibility: hidden; color: var(--color-accent-ink); }
.pop__item[aria-selected="true"] { font-weight: 600; }
.pop__item[aria-selected="true"] .pop__check { visibility: visible; }
.pop__item.is-active, .pop__item:focus-visible { background: var(--color-surface-2); outline: none; }
@media (hover: hover) { .pop__item:hover { background: var(--color-surface-2); } }
.pop__item--danger, .pop__item--danger .icon { color: var(--color-err); }
.pop__sep { height: 1px; margin: 4px 0; background: var(--color-border); }
.pop__empty { padding: 8px 12px; color: var(--color-text-2); }
.pop--date { padding: 12px; }
.datepop { display: flex; flex-direction: column; gap: 8px; }
.datepop__row { display: flex; gap: 12px; justify-content: space-between; }

/* ── 7. Шторка, модалка, тост ─────────────────────────────────────────── */

/* Оба слоя — <dialog> + showModal(): ловушку фокуса, Esc и inert фона даёт
   браузер. Закрытие по подложке — только если и mousedown, и mouseup были
   на ней (промах при выделении текста не теряет введённое). */
dialog { color: inherit; }
dialog::backdrop { background: var(--color-scrim); }

.drawer {
  position: fixed; inset: 0 0 0 auto; margin: 0; padding: 0; border: 0;
  width: min(var(--p-drawer), 100vw); max-width: 100vw; height: 100dvh; max-height: 100dvh;
  display: flex; flex-direction: column;
  background: var(--color-surface); box-shadow: var(--shadow-2);
}
.drawer:not([open]) { display: none; }
.drawer[open] { animation: drawer-in var(--dur-3) var(--ease-sheet); }
.drawer.is-closing { animation: drawer-out var(--dur-2) var(--ease-in-out) forwards; }
@keyframes drawer-in { from { transform: translateX(100%); } }
@keyframes drawer-out { to { transform: translateX(100%); } }
.drawer__head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 16px 0 24px; }
.drawer__title { flex: 1; min-width: 0; }
.drawer__title h2 { font: 600 20px/28px var(--font-display); overflow-wrap: anywhere; }
.drawer__title p { color: var(--color-text-2); overflow-wrap: anywhere; }
.drawer__kicker { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.drawer__tabs { padding: 0 24px; margin-top: 16px; }
.drawer__head + .drawer__body { margin-top: 8px; }
.drawer__body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 24px; display: flex; flex-direction: column; gap: 32px; }
.drawer__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--color-border); }
.drawer__lead { margin-right: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.dirty { display: flex; align-items: center; gap: 8px; color: var(--color-text-2); }

.modal {
  width: min(var(--p-modal), calc(100vw - 32px)); max-height: 80dvh; margin: auto; padding: 0; border: 0;
  border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-2);
  flex-direction: column;
}
.modal[open] { display: flex; animation: modal-in var(--dur-2) var(--ease-out); }
.modal.is-closing { animation: fade-out var(--dur-1) linear forwards; }
.modal--sm { width: min(var(--p-modal-sm), calc(100vw - 32px)); }
.modal--wide { width: min(760px, calc(100vw - 32px)); }
@keyframes modal-in { from { opacity: 0; transform: scale(.96); } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
.modal__head { display: flex; align-items: flex-start; gap: 12px; padding: 24px 16px 0 24px; }
.modal__title { flex: 1; min-width: 0; font: 600 20px/28px var(--font-display); overflow-wrap: anywhere; padding-top: 6px; }
.modal__body { padding: 16px 24px; overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.modal__body > p { color: var(--color-text-2); font-size: 16px; line-height: 24px; }
.modal__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 8px 24px 24px; }

.toasts { position: fixed; z-index: 400; right: 24px; bottom: 24px; width: 360px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 12px 16px;
  border-radius: var(--radius-xs); background: var(--color-inverse); color: var(--color-on-inverse);
  box-shadow: var(--shadow-2); pointer-events: auto;
  animation: toast-in var(--dur-2) var(--ease-out);
}
.toast.is-closing { animation: fade-out var(--dur-1) linear forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.toast__icon { display: flex; color: var(--color-on-inverse); }
.toast--success .toast__icon { color: var(--color-inverse-ok); }
.toast--error .toast__icon { color: var(--color-inverse-err); }
.toast__text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast__action {
  position: relative; flex: none; padding: 0; border: 0; background: transparent;
  color: var(--color-inverse-ink); font-weight: 600; cursor: pointer;
}
.toast__action::after { content: ""; position: absolute; inset: -12px -8px; }
.toast__action:focus-visible { outline-color: var(--color-inverse-ink); }

/* Плашка «Панель обновилась» (js/version.js): внизу слева, над контентом,
   не перекрывает тосты справа. */
.update-bar {
  position: fixed; z-index: 390; left: calc(var(--p-sidebar) + 24px); bottom: 24px;
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - var(--p-sidebar) - 48px);
  padding: 8px 8px 8px 16px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-2);
  animation: toast-in var(--dur-2) var(--ease-out);
}
.update-bar[hidden] { display: none; }
.update-bar__icon { display: flex; color: var(--color-accent-ink); }
.update-bar__text { font-weight: 600; white-space: nowrap; }
@media (min-width: 1024px) { .app.is-rail ~ .update-bar { left: calc(var(--p-rail) + 24px); max-width: calc(100vw - var(--p-rail) - 48px); } }
@media (max-width: 1023px) { .update-bar { left: calc(var(--p-rail) + 24px); max-width: calc(100vw - var(--p-rail) - 48px); } }
@media (max-width: 767px) { .update-bar { left: 16px; right: 16px; bottom: 16px; max-width: none; } .update-bar__text { flex: 1; white-space: normal; } }
@media (prefers-reduced-motion: reduce) { .update-bar { animation: none; } }

/* ── 8. Сводка ────────────────────────────────────────────────────────── */

.updated { display: inline-flex; align-items: center; gap: 8px; margin-right: 8px; color: var(--color-text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.datebar { display: flex; gap: 4px; }
.datebar .filter-btn b { max-width: none; }

/* DOM-порядок: плитки → «Требует внимания» (правая колонка) → «Филиалы»
   (левая): скринридер первым слышит то, что требует действия (§7.7).
   dense — чтобы левая колонка встала рядом с правой, а не под неё. */
.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-flow: row dense; align-items: start; gap: 16px; }
.dash__banner { grid-column: 1 / -1; }
.dash__kpis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.dash__col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
/* Таблица филиалов ушла на «Открытие кафе» — «Требует внимания» во всю ширину. */
.dash__col--r { grid-column: 1 / -1; }
.dash__single { grid-column: 1 / -1; }

.kpi {
  position: relative; display: flex; flex-direction: column; min-height: 112px; min-width: 0; padding: 16px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  color: inherit; text-decoration: none;
}
@media (hover: hover) { a.kpi:hover { box-shadow: var(--shadow-1); border-color: var(--color-surface-3); } a.kpi:hover .kpi__go { opacity: 1; } }
a.kpi:focus-visible .kpi__go { opacity: 1; }
.kpi__label { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--color-text-2); min-width: 0; }
.kpi__label > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi__label .icon { margin-left: auto; }
.kpi__value { margin-top: 8px; font: 600 28px/36px var(--font-display); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; }
.kpi__value small { font: 400 16px/24px var(--font-text); color: var(--color-text-2); letter-spacing: 0; margin-left: 4px; }
.kpi__sub { margin-top: auto; padding-top: 4px; padding-right: 20px; color: var(--color-text-2); display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; min-width: 0; }
.kpi__go { position: absolute; right: 16px; bottom: 18px; display: flex; color: var(--color-text-2); opacity: 0; transition: opacity var(--dur-1) linear; }
.bar { position: relative; display: block; height: 4px; border-radius: var(--radius-pill); background: var(--color-surface-2); overflow: hidden; }
.bar > i { position: absolute; inset: 0; transform-origin: left; background: var(--color-text-2); border-radius: inherit; }
.bar--accent > i { background: var(--color-accent); }
.kpi .bar { margin-top: 8px; }

.cnts { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.cnt { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.pct { color: inherit; text-decoration: none; display: grid; grid-template-columns: 64px auto; align-items: center; gap: 0 8px; white-space: nowrap; }
.pct b { font-weight: 600; }
.pct > span:last-child { grid-column: 1 / -1; color: var(--color-text-2); }
.chev { display: flex; color: var(--color-text-2); }
.shift { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

.att { list-style: none; margin: 0; padding: 0; }
.att li { border-bottom: 1px solid var(--color-border); }
.att li:last-child { border-bottom: 0; }
.att__row { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; align-items: start; min-height: 64px; padding: 12px 16px; color: inherit; text-decoration: none; }
@media (hover: hover) { a.att__row:hover { background: var(--color-bg); } }
a.att__row:focus-visible { outline-offset: -2px; }
.att__ic { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-pill); }
.att__title { display: block; font-weight: 600; }
.att__detail { display: block; color: var(--color-text-2); overflow-wrap: anywhere; }
.att__time { color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.att__more { padding: 8px 16px 12px; border-top: 1px solid var(--color-border); }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--color-text-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 8px; vertical-align: 1px; }
.trend { position: relative; padding: 16px 16px 12px; }
.chart { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 0 8px; }
.chart__cap { grid-column: 1 / -1; margin: 16px 0 8px; font-weight: 600; }
.chart__cap:first-child { margin-top: 0; }
.chart__y { position: relative; color: var(--color-text-2); text-align: right; font-variant-numeric: tabular-nums; }
.chart__y span { position: absolute; right: 0; transform: translateY(-50%); }
.chart svg { display: block; width: 100%; overflow: visible; cursor: pointer; }
.chart__x { grid-column: 2; position: relative; height: 20px; margin-top: 8px; color: var(--color-text-2); font-variant-numeric: tabular-nums; }
.chart__x span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.chart__x span.is-sel { color: var(--color-text); font-weight: 600; }
.tip {
  position: absolute; z-index: 5; top: 24px; left: 0; min-width: 184px; padding: 8px 12px;
  border-radius: var(--radius-xs); background: var(--color-inverse); color: var(--color-on-inverse);
  box-shadow: var(--shadow-2); pointer-events: none; font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity var(--dur-1) linear;
}
.tip.is-on { opacity: 1; }
.tip b { display: block; font-weight: 600; margin-bottom: 4px; }
.tip div { display: flex; justify-content: space-between; gap: 16px; color: var(--color-inverse-2); }
.tip div span:last-child { color: #fff; }

.rate { list-style: none; margin: 0; padding: 4px 0; }
.rate li > a, .rate li > div { display: grid; grid-template-columns: 24px 32px minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 56px; padding: 8px 16px; color: inherit; text-decoration: none; }
@media (hover: hover) { .rate li > a:hover { background: var(--color-bg); } }
.rate li > a:focus-visible { outline-offset: -2px; }
.rate__n { color: var(--color-text-2); font-variant-numeric: tabular-nums; text-align: right; }
.rate__who { min-width: 0; }
.rate__name, .rate__br { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rate__name { font-weight: 600; }
.rate__br { color: var(--color-text-2); }
.rate__score { font: 600 16px/24px var(--font-display); font-variant-numeric: tabular-nums; }
.rate__cap { display: none; padding: 12px 16px 0; font-weight: 600; color: var(--color-text-2); }
.rate-split > div[data-list="bottom"] { display: none; }
.rate-split.show-bottom > div[data-list="top"] { display: none; }
.rate-split.show-bottom > div[data-list="bottom"] { display: block; }

/* ── 9. Вход ──────────────────────────────────────────────────────────── */

.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login__card { width: min(400px, 100%); padding: 32px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); box-shadow: var(--shadow-1); }
.login__logo { display: block; width: 40px; height: 40px; border-radius: var(--radius-sm); }
.login__card h1 { margin-top: 24px; font: 700 24px/32px var(--font-display); letter-spacing: -0.01em; }
.login__lead { margin-top: 8px; color: var(--color-text-2); font-size: 16px; line-height: 24px; }
.login__form { margin-top: 24px; display: flex; flex-direction: column; gap: 16px; }
.login__form .btn--primary { margin-top: 8px; }
.login__caps { display: flex; align-items: center; gap: 8px; color: var(--color-warn); margin-top: -4px; }
.login__err { display: flex; align-items: flex-start; gap: 8px; color: var(--color-err); }
.login__foot { margin-top: 24px; text-align: center; color: var(--color-text-2); }

/* ── 10. Ширины ───────────────────────────────────────────────────────── */

/* Меню свёрнуто кнопкой «Свернуть» на ≥1024 — та же раскладка, что rail. */
@media (min-width: 1024px) {
  .app.is-rail { grid-template-columns: var(--p-rail) minmax(0, 1fr); }
}
@media (min-width: 1280px) and (max-width: 1439px) {
  .kpi__label .icon, .kpi__sub .icon { display: none; }
}
@media (max-width: 1279px) {
  :root { --p-gutter: 24px; }
  .dash { display: flex; flex-direction: column; align-items: stretch; }
  .dash__col { display: contents; }
  .dash__banner { order: -3; }
  .dash__kpis { order: -2; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash__attention { order: -1; }
  .dash__rating { order: 1; }
  .rate-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rate-split > div[data-list] { display: block !important; }
  .rate-split > div + div { border-left: 1px solid var(--color-border); }
  .rate__cap { display: block; }
  .rate-seg { display: none !important; }
}
/* Rail: 768–1023 всегда, на ≥1024 — когда меню свёрнуто. */
@media (min-width: 768px) and (max-width: 1023px) {
  .app { grid-template-columns: var(--p-rail) minmax(0, 1fr); }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .app .sidebar { padding: 12px 8px; }
  .app .brand { padding: 0; justify-content: center; }
  .app .brand__title, .app .brand .ibtn, .app .sidebar .nav__count, .app .me__text, .app .sidebar__foot .me { display: none; }
  .app .nav__label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .app .nav__link { justify-content: center; padding: 0; }
  .app .nav__link.has-count::after { content: ""; position: absolute; top: 8px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-err); }
  .app .sidebar__foot { padding-left: 0; justify-content: center; }
}
@media (min-width: 1024px) {
  .app.is-rail .sidebar { padding: 12px 8px; }
  .app.is-rail .brand { padding: 0; flex-direction: column; height: auto; gap: 8px; }
  .app.is-rail .brand__title, .app.is-rail .sidebar .nav__count, .app.is-rail .me__text, .app.is-rail .sidebar__foot .me { display: none; }
  .app.is-rail .nav__label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .app.is-rail .nav__link { justify-content: center; padding: 0; }
  .app.is-rail .nav__link.has-count::after { content: ""; position: absolute; top: 8px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--color-err); }
  .app.is-rail .sidebar__foot { padding-left: 0; justify-content: center; }
}
@media (max-width: 767px) {
  :root { --p-gutter: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(280px, 85vw); transform: translateX(-100%); visibility: hidden; transition: transform var(--dur-3) var(--ease-sheet), visibility 0s linear var(--dur-3); box-shadow: var(--shadow-2); }
  .app.is-nav-open .sidebar { transform: none; visibility: visible; transition: transform var(--dur-3) var(--ease-sheet); }
  .brand .ibtn-collapse { display: none; }
  .page-head .burger { display: inline-grid; }
  .subnav .burger { display: inline-grid; flex: none; margin-right: 4px; }
  .app.has-subnav .page-head .burger { display: none; }
  .page-head__tools { width: 100%; }
  .dash__kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .search, .toolbar .search { width: 100%; }
  .seg { overflow-x: auto; scrollbar-width: none; }
  .rate-split { display: block; }
  .rate-split > div + div { border-left: 0; border-top: 1px solid var(--color-border); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .toasts { left: 16px; right: 16px; bottom: 16px; width: auto; }
  .drawer { width: 100vw; }
  .tree__children { margin-left: 15px; padding-left: 8px; }
  .login__card { padding: 24px; }
  .updated { width: 100%; margin-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0ms !important; }
  .btn:active, .ibtn:active { transform: none; }
  .page { animation: none; }
  .drawer[open], .modal[open] { animation: fade-in var(--dur-1) linear; }
  .drawer.is-closing, .modal.is-closing { animation: fade-out var(--dur-1) linear forwards; }
  .toast, .pop { animation: fade-in var(--dur-1) linear; }
  .sk { animation-duration: 2.4s; }
  .icon.is-spin { animation-duration: 1.2s; }
  .tree__toggle .icon { transition: none; }
}
@media (forced-colors: active) {
  .btn, .ibtn, .seg button { border: 1px solid transparent; }
  .nav__link[aria-current], .subnav__link[aria-current], .tbl tbody tr[aria-current="true"] td, .seg button[aria-pressed="true"] { outline: 2px solid Highlight; outline-offset: -2px; }
  .tab[aria-selected="true"]::after { background: Highlight; }
  .subnav { border-bottom-color: CanvasText; }
  .bar > i { background: CanvasText; }
  .chip:has(input:checked) { outline: 2px solid Highlight; outline-offset: -2px; }
  .switch { border: 1px solid ButtonBorder; }
  .switch[aria-checked="true"]::after { background: Highlight; }
  .icon-grid button[aria-pressed="true"] { outline: 2px solid Highlight; }
  .badge, .tag { border: 1px solid CanvasText; }
}

/* Справочник с перетаскиванием (sortableTable): ручка, взятая строка. */
.sortable .td-grip { width: 1%; padding-right: 0; }
.sortable .grip { cursor: grab; touch-action: none; color: var(--color-text-2); }
.sortable .grip[aria-pressed="true"] { background: var(--color-accent-soft); color: var(--color-accent-ink); }
.sortable tr.is-dragging td, .sortable tr.is-grabbed td { background: var(--color-accent-soft); }
.sortable tr.is-dragging .grip { cursor: grabbing; }
.sortable td { height: var(--p-row-2); }
.ico-cell { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.ico-cell .icon { flex: none; color: var(--color-text-2); }

/* Шапка Сводки: группа действий переносится целиком (VISUAL_QA M7). */
/* Таблетки кафе (.branch-chips) — свой ряд во всю ширину; запрет переноса
   шапки сжимал их до огрызка с прокруткой рядом с датой. */
.dash-datebox { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }

/* Подвал меню с «Выйти» всегда на виду (VISUAL_QA L10): меню прокручивается под ним. */
.sidebar__foot { position: sticky; bottom: -12px; margin-bottom: -12px; padding-bottom: 12px; background: var(--color-surface); z-index: 1; }
/* Иконка и текст во вложенной подписи плитки — с зазором (L1). */
.kpi__sub > span { display: inline-flex; align-items: center; gap: 4px; }

/* Ручное открытие/закрытие смены и вкладка «Смены» карточки филиала. */
.bs-force { display: flex; flex-direction: column; gap: 12px; }
.bs-tab { display: flex; flex-direction: column; gap: 32px; min-width: 0; }
.bs-sec { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.bs-sec > h3 { font: 600 16px/24px var(--font-display); }
.bs-now { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bs-facts { display: flex; flex-direction: column; gap: 4px; }
.bs-stale { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.bs-forced { padding: 8px 12px; border-radius: var(--radius-sm); background: var(--color-warn-soft); overflow-wrap: anywhere; }
.bs-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Бейдж в двухстрочной ячейке — по своему тексту, а не на всю колонку. */
.cell2 > .badge { align-self: flex-start; }

/* Телефон: строка списка — карточка (план оптимизации, этап 1, 24.11.2026).
   Таблица шире экрана прятала статус и срок за краем без видимой прокрутки.
   Первая колонка — заголовок карточки, остальные — «Подпись: значение»,
   прочерки не показываются, меню строки — в правом верхнем углу. */
@media (max-width: 767px) {
  .dtable .tbl { min-width: 0; }
  .dtable .tbl thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .dtable .tbl tbody tr, .dtable .tbl tfoot tr { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); }
  .dtable .tbl tbody tr:last-child { border-bottom: 0; }
  .dtable .tbl td { display: block; height: auto; min-width: 0 !important; max-width: 100%; width: auto; padding: 0 !important; border: 0; text-align: left; }
  .dtable .tbl td.td-main { flex: 1 1 100%; padding-right: 40px !important; }
  .dtable .tbl td.td-cb { flex: none; width: auto; order: -1; }
  .dtable .tbl td.td-cb + td.td-main { flex: 1 1 calc(100% - 56px); }  /* 44 чекбокс + 12 зазор */
  .dtable .tbl td.is-blank { display: none; }
  .dtable .tbl td, .dtable .tbl td * { white-space: normal; }
  .dtable .tbl td > * { max-width: 100%; }
  .dtable .tbl td .fc-verdict { flex-wrap: wrap; }
  .dtable .tbl td:not(.td-main):not(.td-cb):not(.shrink)[data-label]::before { content: attr(data-label) ": "; color: var(--color-text-2); }
  .dtable .tbl td.shrink { position: absolute; top: 8px; right: 8px; width: auto; }
  .dtable .tbl td.empty-cell { flex: 1 1 100%; }
  .dtable .tbl tbody tr:has(td.empty-cell) { padding: 0; }
}

/* Полоса раздела: прокрутка вбок не режет пункт у левого края. */
.subnav__list { scroll-snap-type: x proximity; }
.subnav__link { scroll-snap-align: start; }
