/* tg_parser: оформление как у админки pvedash (токены, каркас и компоненты взяты из dev/pvedash-ref/).
   Шрифт Inter (OFL) лежит локально в fonts/, внешних шрифтов и CDN нет: CSP default-src 'self' не мешает.
   Тёмная тема: [data-theme="dark"] (static/theme.js и кнопка в меню) и prefers-color-scheme, если тема не выбрана вручную.

   КОНТРАКТ CSS-КЛАССОВ (шаблоны страниц наследуют base.html: блоки title, head, content)
   ------------------------------------------------------------------------------------------------
   .panel > .panel-header(h1|h2 + .actions) > [.toolbar] > .panel-body   карточка с шапкой (r14, тень)
   table.grid              таблица (th 12px/700 muted на --u-fill, hover строк); <=800px — карточки: у <td> data-label="Подпись",
                           <td> без data-label (кнопки) занимает всю ширину. Числа: class="num"
   .btn                    нейтральная кнопка; .btn.primary синяя; .btn.danger красная; .btn.small компактная; .btn.wide на всю ширину
   .field > label + input  подпись над полем (.field.row — в строку); .field-row — несколько .field в ряд; .checks / .radio-row — чекбоксы/радио
   .tag(.ok/.warn/.err/.run)  бейдж; .note(.info/.warn/.bad/.ok) и .err — сообщения
   .tiles > .tile          карточки-показатели; .prog/.bar/.bar-fill — прогресс задач; .meter(.warn/.crit) — индикатор
   .chart-*                SVG-графики (src: web/charts.py, app.js): серия --blue, сетка --line, подписи --muted
   .login > .card          страница входа; .cols-2 две карточки в ряд; .stack вертикальный ряд; .muted/.sub второстепенный текст
   .tag.err.prot-tag       красный бейдж с замком «защита контента» (макрос protected_tag): везде, где показан такой чат;
                           .forbid — неактивная подпись «пересылка запрещена»; option.opt-prot — красная строка в выборе источника;
                           .save-panel(.accent) — блок «Сохранить себе» на странице чата (accent — для защищённых чатов)
   .chatpick               выбор чата (app.js, templates/_chatpick.html): .chatpick-fallback — облегчённый список без JS;
                           с JS: .chatpick-field (поле) > .chatpick-chip + .chatpick-input, .chatpick-list > .chatpick-opt
                           (.is-active/.is-selected/.is-disabled/.is-prot), .chatpick-more, .chatpick-status
   .pager                  навигация по страницам /chats: .btn.pager-prev / .pager-nums > .btn.pager-num / .btn.pager-next; .list-caption — подпись
   Макросы (templates/_macros.html): icon(name), status_tag(status), progress(done, total), protected_tag(), protected_label(),
                           protected_hint(), protected_forbid() — единые подписи защиты контента.
*/


@font-face {
  font-family: "Inter";
  src: url("fonts/inter-cyrillic-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Inter";
  src: url("fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2190-21FF, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  --bg: #f3f6f8; --surface: #fff; --surface-2: #f8fafb;
  --ink: #17212b; --soft: #4a5a66;
  --muted: #66737e;          /* чуть темнее #72808b: контраст мелкого текста ≥ 4.5:1 */
  --line: #dfe7eb; --line-2: #ebf0f3;
  --blue: #146ef5; --blue-ink: #1259c7; --blue-soft: #edf5ff; --blue-line: #bed7ff; --blue-mid: #8cb8fb;
  --green: #0da46b; --green-ink: #087a4f; --green-soft: #e9faf3; --green-line: #b7ebd5;
  --red: #d84c50; --red-ink: #b8343a; --red-soft: #fff0f0; --red-line: #f6c9ca;
  --orange: #c97a16; --orange-ink: #93590a; --orange-soft: #fff8e5; --orange-line: #f1dba9;
  --violet: #7651c9; --teal: #0b7f91; --slate: #4a5a66;
  --track: #e8eef2;
  --radius: 14px; --radius-s: 10px;
  --shadow: 0 12px 34px #17212b08, 0 1px 2px #17212b0a;
  --ring: 0 0 0 3px rgba(20, 110, 245, .18);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1620; --surface: #161f2b; --surface-2: #1a2431;
  --ink: #e7edf3; --soft: #b8c4ce; --muted: #8d9aa6;
  --line: #263243; --line-2: #1f2a38;
  --blue: #4f95ff; --blue-ink: #7fb1ff; --blue-soft: #15243a; --blue-line: #27456f; --blue-mid: #3a6fbf;
  --green: #2fbf86; --green-ink: #4fd6a0; --green-soft: #0f2a20; --green-line: #1d4d3a;
  --red: #f0686c; --red-ink: #ff8d90; --red-soft: #33191c; --red-line: #5a2a2e;
  --orange: #e3a14a; --orange-ink: #f0b766; --orange-soft: #2e2311; --orange-line: #574118;
  --violet: #a98bf2; --teal: #47c6d6; --slate: #9aa8b4;
  --track: #233041;
  --shadow: 0 12px 34px #00000038, 0 1px 2px #0000004d;
  --ring: 0 0 0 3px rgba(79, 149, 255, .3);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1620; --surface: #161f2b; --surface-2: #1a2431;
    --ink: #e7edf3; --soft: #b8c4ce; --muted: #8d9aa6;
    --line: #263243; --line-2: #1f2a38;
    --blue: #4f95ff; --blue-ink: #7fb1ff; --blue-soft: #15243a; --blue-line: #27456f; --blue-mid: #3a6fbf;
    --green: #2fbf86; --green-ink: #4fd6a0; --green-soft: #0f2a20; --green-line: #1d4d3a;
    --red: #f0686c; --red-ink: #ff8d90; --red-soft: #33191c; --red-line: #5a2a2e;
    --orange: #e3a14a; --orange-ink: #f0b766; --orange-soft: #2e2311; --orange-line: #574118;
    --violet: #a98bf2; --teal: #47c6d6; --slate: #9aa8b4;
    --track: #233041;
    --shadow: 0 12px 34px #00000038, 0 1px 2px #0000004d;
    --ring: 0 0 0 3px rgba(79, 149, 255, .3);
  }
}


/* ---------- производные токены каркаса (как в shell.css эталона) ---------- */
:root {
  --sidebar-w: 268px; --appbar-h: 60px; --tabbar-h: 64px; --gutter: clamp(14px, 2.4vw, 32px);
  --nav-hover: color-mix(in srgb, var(--line) 40%, var(--surface));
  --u-hover: color-mix(in srgb, var(--ink) 4%, var(--surface));
  --u-fill: color-mix(in srgb, var(--ink) 2.5%, var(--surface));
  --u-line-2: color-mix(in srgb, var(--line) 55%, var(--surface));
  --u-field-line: color-mix(in srgb, var(--line) 70%, var(--muted));
  --u-shadow-sm: 0 1px 2px color-mix(in srgb, var(--ink) 5%, transparent);
  --u-ring: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent);
  --u-blue-hover: color-mix(in srgb, var(--blue) 86%, var(--ink));
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ---------- основа ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 90px; }
body {
  margin: 0; min-width: 320px; color: var(--ink);
  font: 400 14.5px/1.5 var(--font);
  font-feature-settings: "cv11", "ss01"; font-variant-numeric: tabular-nums;
  background: radial-gradient(circle at 85% -10%, color-mix(in srgb, var(--blue) 12%, var(--bg)) 0, transparent 36%), var(--bg);
  background-attachment: fixed; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
h1, h2, h3 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
p { margin: 0 0 10px; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; box-shadow: none; border-radius: 6px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.sub { display: block; color: var(--muted); font-size: 12.5px; }
.sr-only, .sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.nowrap { white-space: nowrap; }
.wrap-any { overflow-wrap: anywhere; }
.spaced { margin-top: 12px; }
svg.icon { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; padding: 1px 6px; border-radius: 6px; background: var(--u-fill); border: 1px solid var(--u-line-2); overflow-wrap: anywhere; }
details > summary { cursor: pointer; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 300; padding: 10px 14px; border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.skip-link:focus { left: 8px; }
.nav-toggle { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.nav-toggle:focus-visible ~ .shell .burger, .nav-toggle:focus-visible ~ .tabbar label.tab:last-child { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- каркас: боковое меню, шапка, нижние вкладки ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.main > .wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 22px var(--gutter) 48px; }
.main > .wrap:has(> .panel > table.grid, > .panel > .panel-body > table.grid) { max-width: 1360px; }

.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column; z-index: 60;
  background: color-mix(in srgb, var(--surface) 80%, transparent); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-right: 1px solid var(--line);
}
.side-head { display: flex; align-items: center; gap: 10px; padding: 20px 14px 14px; }
.brand-link { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-decoration: none; color: var(--ink); border-radius: var(--radius-s); }
.brand-link:hover { color: var(--ink); text-decoration: none; }
.brand-mark { display: block; width: 38px; height: 38px; border-radius: 11px; flex: none; box-shadow: 0 6px 14px color-mix(in srgb, var(--blue) 24%, transparent); }
.brand-link strong { display: block; font-size: 16px; letter-spacing: -.02em; line-height: 1.2; }
.brand-link small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.shell-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); cursor: pointer; transition: background-color .15s, border-color .15s; }
.shell-btn:hover { background: var(--nav-hover); text-decoration: none; }
.shell-btn svg { width: 20px; height: 20px; stroke-width: 2; }
.side-close { display: none; }
.nav { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; display: flex; flex-direction: column; gap: 2px; padding: 4px 12px 12px; }
.nav-group { margin: 0; padding: 18px 12px 6px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.nav-group:first-child { padding-top: 8px; }
.nav a { display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-s); color: var(--soft); font-weight: 600; font-size: 14px; text-decoration: none; transition: background-color .15s, color .15s; }
.nav a:hover { background: var(--nav-hover); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--blue-soft); color: var(--blue-ink); }
.nav svg { width: 20px; height: 20px; }
.side-tg { padding: 0 12px 10px; }
.tg-state { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--u-fill); color: var(--soft); font-size: 13px; font-weight: 600; white-space: nowrap; }
.tg-state .dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
.tg-state.ok .dot { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.tg-state.ok { color: var(--green-ink); }
.tg-state a { color: var(--blue-ink); font-weight: 650; }
.nav-foot { display: flex; align-items: center; gap: 6px; padding: 12px 10px; border-top: 1px solid var(--line); }
.nav-foot form { margin: 0; flex: none; }
.user-chip { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 4px; border-radius: var(--radius-s); color: var(--ink); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--blue-soft); color: var(--blue-ink); font-weight: 700; text-transform: uppercase; }
.user-chip .who { min-width: 0; }
.user-chip b { display: block; font-size: 13.5px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-foot .shell-btn { width: 36px; height: 36px; }
.nav-logout { color: var(--red-ink); }
.nav-logout:hover { background: var(--red-soft); border-color: var(--red-line); }
/* переключатель темы: солнце — светлая, луна — тёмная (data-mode ставит app.js) */
.js-theme svg { display: none; }
.js-theme[data-mode="light"] svg:nth-child(1), .js-theme[data-mode="dark"] svg:nth-child(2) { display: block; }
.theme-float { position: fixed; top: 14px; right: 14px; z-index: 5; }
.backdrop { position: fixed; inset: 0; z-index: 59; background: color-mix(in srgb, var(--ink) 40%, transparent); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; }

.appbar { display: none; position: sticky; top: 0; z-index: 50; align-items: center; gap: 10px; min-height: var(--appbar-h); padding: 10px var(--gutter); background: color-mix(in srgb, var(--bg) 84%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--line); }
.appbar .brand-link { flex: 0 1 auto; }
.appbar .brand-mark { width: 32px; height: 32px; border-radius: 10px; }
.appbar .grow { flex: 1; }
.appbar .tg-state { padding: 6px 12px; border-radius: 999px; background: var(--surface); }

.tabbar { display: none; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--muted); font: 600 11px/1.1 var(--font); text-decoration: none; border-radius: 12px; cursor: pointer; padding: 4px 2px; min-width: 0; }
.tab:hover { text-decoration: none; color: var(--ink); }
.tab svg { width: 23px; height: 23px; }
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--blue-ink); }
.tab[aria-current="page"] span { font-weight: 700; }

@media (max-width: 1099px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: min(86vw, 320px); transform: translateX(-104%); visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; background: var(--surface); box-shadow: 0 30px 80px color-mix(in srgb, var(--ink) 30%, transparent); }
  .nav-toggle:checked ~ .shell .sidebar { transform: none; visibility: visible; transition: transform .22s ease; }
  .nav-toggle:checked ~ .backdrop { opacity: 1; pointer-events: auto; }
  body:has(.nav-toggle:checked) { overflow: hidden; }
  .side-close { display: inline-grid; }
  .appbar { display: flex; }
}
@media (max-width: 719px) {
  body { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 58; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 6px 6px env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px); border-top: 1px solid var(--line); }
  .appbar .tg-prefix { display: none; }
  .appbar .tg-state { padding: 6px 10px; font-size: 12px; }
  .main > .wrap { padding-top: 16px; }
}
@media (min-width: 1700px) { :root { --sidebar-w: 288px; } .main > .wrap { max-width: 1280px; } .main > .wrap:has(> .panel > table.grid, > .panel > .panel-body > table.grid) { max-width: 1480px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---------- заголовок страницы ---------- */
.ph1 { font-size: clamp(20px, 2vw, 24px); letter-spacing: -.03em; font-weight: 700; line-height: 1.15; margin: 2px 0 16px; }

/* ---------- карточки ---------- */
.panel, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--u-shadow-sm), var(--shadow); min-width: 0; margin: 0 0 18px; overflow: hidden; }
.panel.narrow { max-width: 520px; }
.panel-header { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; padding: 16px 20px 14px; border-bottom: 1px solid var(--u-line-2); }
.panel-header h1, .panel-header h2 { font-size: 17px; font-weight: 700; letter-spacing: -.015em; }
.panel-header .count { font-size: 13.5px; font-weight: 400; }
.panel-header .actions, .actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 400; }
.panel-body { padding: 18px 20px 20px; min-width: 0; }
.panel-body.flush, .panel-body:has(> table.grid:only-child) { padding: 0; }
.panel-body > :last-child { margin-bottom: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px; background: var(--u-fill); border-bottom: 1px solid var(--u-line-2); }
.toolbar form { display: contents; }
.toolbar .grow { flex: 1 1 200px; min-width: 0; }
.toolbar > label { font-weight: 600; font-size: 13px; color: var(--soft); }
.toolbar > .muted { margin-left: auto; font-size: 13px; }
.toolbar .btn { min-height: 42px; }
.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 4px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 2px; }
.form-actions form { margin: 0; }
.chat-title { margin: 0; font-size: 15px; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.sub-h { margin: 6px 0 0; font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; }
.panel-body .sub-h:first-child { margin-top: 0; }
.panel > form.spaced { margin-top: 10px; }
.backup-codes { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: 4px 12px; }
.backup-codes code { font-size: 15px; background: transparent; border: 0; padding: 0; }
.qr-box { display: inline-block; background: #fff; padding: 12px; border: 1px solid var(--line); border-radius: 12px; line-height: 0; }
.qr-box img { width: 260px; height: 260px; max-width: 100%; height: auto; }
form.inline { display: inline-flex; margin: 0; }

/* ---------- кнопки ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; line-height: 1.2; white-space: nowrap; cursor: pointer; text-decoration: none;
  box-shadow: var(--u-shadow-sm); transition: background-color .15s, border-color .15s, box-shadow .15s, transform .16s, color .15s; }
.btn:hover:not(:disabled) { background: var(--u-hover); border-color: var(--u-field-line); color: var(--ink); text-decoration: none; transform: translateY(-1px); box-shadow: 0 8px 18px color-mix(in srgb, var(--ink) 8%, transparent); }
.btn:active:not(:disabled) { transform: none; box-shadow: none; }
.btn.primary { border-color: var(--blue); background: var(--blue); color: #fff; box-shadow: 0 1px 2px color-mix(in srgb, var(--blue) 28%, transparent); }
.btn.primary:hover:not(:disabled) { background: var(--u-blue-hover); border-color: var(--u-blue-hover); color: #fff; box-shadow: 0 8px 18px color-mix(in srgb, var(--blue) 26%, transparent); }
.btn.danger { background: var(--red-soft); border-color: var(--red-line); color: var(--red-ink); box-shadow: none; }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 12%, var(--surface)); border-color: color-mix(in srgb, var(--red) 45%, var(--surface)); color: var(--red-ink); box-shadow: 0 8px 18px color-mix(in srgb, var(--red) 14%, transparent); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; gap: 6px; }
.btn.wide { width: 100%; }
.btn.grow { flex: 1 1 auto; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: default; }

/* ---------- поля ---------- */
input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], input[type=tel], input[type=email], input[type=url], input[type=datetime-local], input[type=file], select, textarea {
  min-width: 0; max-width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--u-field-line); border-radius: var(--radius-s); background-color: var(--surface); color: var(--ink);
  font-size: 14.5px; line-height: 1.35; transition: border-color .15s, box-shadow .15s; }
input:hover:not(:disabled):not([type=checkbox]):not([type=radio]), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--blue); box-shadow: var(--u-ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .75; }
input:disabled, select:disabled, textarea:disabled { background-color: var(--u-hover); color: var(--muted); cursor: not-allowed; }
textarea { min-height: 96px; resize: vertical; width: 100%; }
select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
input[type=number] { width: 6rem; }
input[type=file] { padding: 7px 10px; width: 100%; }
input[type=file]::file-selector-button { margin-right: 12px; padding: 5px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--u-fill); color: var(--ink); font: 600 13px var(--font); cursor: pointer; }
input.code { letter-spacing: .25em; font-size: 20px; font-weight: 650; text-align: center; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; margin: 0; accent-color: var(--blue); flex: none; }
fieldset { border: 0; margin: 0 0 10px; padding: 0; min-width: 0; }
legend { padding: 0; font-weight: 600; margin-bottom: 4px; }

.field { display: flex; flex-direction: column; gap: 6px; margin: 0; min-width: 0; }
.field > label:first-child { font-size: 13px; font-weight: 650; color: var(--soft); }
.field > label .muted { font-weight: 400; }
.field > input, .field > select, .field > textarea { max-width: 640px; }
.field:has(> .label) { flex-direction: row; align-items: baseline; gap: 12px; }
.field > .label { flex: 0 0 11rem; font-size: 13px; font-weight: 650; color: var(--soft); }
.field.row { flex-direction: row; align-items: center; gap: 8px; }
.field .muted:not(.label) { font-size: 12.5px; }
.field-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 14px 16px; }
.field-row > .field { flex: 1 1 240px; }
.field-row > .field.row { flex: none; }
.field-row > label.opt { flex: none; min-height: 42px; }
.field-row .field > input, .field-row .field > select, .field-row .field > textarea { max-width: none; }
.field-row .field > input[type=number] { max-width: 6rem; }
.stack > .field-row { margin: 0; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 16px; }
.checks label, .radio-row label, label.opt { display: flex; align-items: center; gap: 9px; min-height: 28px; cursor: pointer; }
.checks:has(> label:only-child) { display: block; }
.panel .panel { box-shadow: none; }
.checks .muted, label.opt .muted { font-size: 12.5px; }
.radio-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 20px; }
.radio-row.col { flex-direction: column; align-items: stretch; gap: 10px; }
.radio-row.col label { display: block; position: relative; padding-left: 28px; }
.radio-row.col label input { position: absolute; left: 0; top: 4px; }
.radio-row.nowrap { flex-wrap: nowrap; gap: 8px; }
.radio-row.nowrap input[type=text] { width: 7rem; }
.radio-row.nowrap select { flex: 0 1 auto; }

/* ---------- бейджи и сообщения ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--u-hover); color: var(--soft); font-size: 12px; font-weight: 700; line-height: 1.35; vertical-align: middle; max-width: 100%; }
.tag.ok::before, .tag.warn::before, .tag.err::before, .tag.run::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; flex: none; }
.tag.ok { background: var(--green-soft); border-color: var(--green-line); color: var(--green-ink); }
.tag.warn { background: var(--orange-soft); border-color: var(--orange-line); color: var(--orange-ink); }
.tag.err { background: var(--red-soft); border-color: var(--red-line); color: var(--red-ink); }
.tag.run { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-ink); }
.note { display: block; margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--u-fill); color: var(--soft); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.note.info { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-ink); }
.note.warn { background: var(--orange-soft); border-color: var(--orange-line); color: var(--orange-ink); }
.note.bad { background: var(--red-soft); border-color: var(--red-line); color: var(--red-ink); }
.note.ok { background: var(--green-soft); border-color: var(--green-line); color: var(--green-ink); }
.note a { font-weight: 600; text-decoration: underline; }
.note p:last-child { margin-bottom: 0; }
.note .muted { color: inherit; opacity: .8; }
.err:not(.tag) { display: block; margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--red-line); border-radius: var(--radius-s); background: var(--red-soft); color: var(--red-ink); font-size: 13.5px; line-height: 1.5; overflow-wrap: anywhere; }
.stack > .muted { font-size: 13px; }
.stack > .note, .stack > .err:not(.tag), .panel-body > .note:last-child { margin-bottom: 0; }
.no2fa-banner { margin-bottom: 18px; }
.flush-note { margin: 12px 20px; }
td .note, td .err:not(.tag) { min-width: 160px; margin: 6px 0 0; padding: 7px 10px; font-size: 12.5px; }

/* ---------- таблицы ---------- */
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
table.grid th { padding: 11px 14px; text-align: left; white-space: nowrap; background: var(--u-fill); color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .02em; border-bottom: 1px solid var(--line); }
table.grid td { padding: 12px 14px; border-bottom: 1px solid var(--u-line-2); vertical-align: middle; overflow-wrap: break-word; }
table.grid th:first-child, table.grid td:first-child { padding-left: 20px; }
table.grid th:last-child, table.grid td:last-child { padding-right: 20px; }
table.grid tbody tr:last-child td { border-bottom: 0; }
table.grid tbody tr:hover td { background: var(--u-fill); }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid td.empty, table.grid td[colspan] { color: var(--muted); padding: 18px 20px; }
table.grid td form.inline { display: flex; margin: 0 0 6px; }
table.grid td form.inline:last-child { margin-bottom: 0; }
table.grid td .btn { margin: 0 6px 6px 0; white-space: normal; text-align: center; }
table.grid td form.inline .btn { margin: 0; min-width: 124px; }
table.grid:has(th:nth-child(7)) { font-size: 13.5px; }
table.grid:has(th:nth-child(7)) th, table.grid:has(th:nth-child(7)) td { padding-left: 9px; padding-right: 9px; }
table.grid:has(th:nth-child(7)) th:first-child, table.grid:has(th:nth-child(7)) td:first-child { padding-left: 20px; }
table.grid:has(th:nth-child(7)) th:last-child, table.grid:has(th:nth-child(7)) td:last-child { padding-right: 20px; }
table.grid td .btn:last-child { margin-bottom: 0; }
table.grid td.actions-cell { min-width: 150px; }
.panel > table.grid { margin: 0; }
.panel:has(> table.grid), .panel:has(> .panel-body > table.grid) { overflow-x: auto; }

/* ---------- прогресс и индикаторы ---------- */
.bar { position: relative; height: 8px; min-width: 90px; border-radius: 99px; background: var(--track); overflow: hidden; }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--blue); transition: width .4s ease; }
.bar.indet { background: repeating-linear-gradient(135deg, var(--track) 0 8px, color-mix(in srgb, var(--blue) 14%, var(--track)) 8px 16px); }
.prog { display: grid; gap: 5px; min-width: 130px; }
.bar-text { font-size: 12px; color: var(--muted); white-space: nowrap; }
.meter { position: relative; height: 8px; border-radius: 99px; background: var(--track); overflow: hidden; }
.meter-fill { height: 100%; border-radius: inherit; background: var(--blue); min-width: 2px; transition: width .4s ease; }
.meter.warn .meter-fill { background: var(--orange); }
.meter.crit .meter-fill { background: var(--red); }
.meter.na .meter-fill { display: none; }

/* ---------- обзор: карточки-показатели ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--u-shadow-sm), var(--shadow); padding: 16px 18px; min-width: 0; }
.tile-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.tile-value { font-size: 30px; line-height: 1.15; font-weight: 760; letter-spacing: -.035em; margin: 6px 0 4px; }
.tile-value.mid { font-size: 20px; overflow-wrap: anywhere; letter-spacing: -.02em; }
.tile-value.small { font-size: 16px; line-height: 1.35; letter-spacing: -.01em; font-weight: 700; margin: 8px 0 4px; }
.tile-sub .tag { padding: 1px 8px; }
.tile-sub { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: center; }
.summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px 28px; align-items: start; }
.summary .sum-label { color: var(--soft); font-weight: 600; font-size: 13.5px; margin-bottom: 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.summary .sum-label .sub { font-weight: 400; }
.summary .sum-text { margin-top: 6px; font-size: 12.5px; color: var(--soft); }
.summary .sum-text b { color: var(--ink); font-weight: 650; }
.summary .sum-big { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }

/* ---------- графики ---------- */
.chart { margin: 0; }
.chart-plot { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; user-select: none; -webkit-user-select: none; border-radius: 6px; }
.chart-svg:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.chart-svg [hidden] { display: none; }
.chart-grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.chart-tick, .chart-xtick { fill: var(--muted); font: 11px var(--font); }
.chart-line { fill: none; stroke: var(--blue); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: var(--blue); fill-opacity: .1; stroke: none; }
.chart-end, .chart-hover { fill: var(--blue); stroke: var(--surface); stroke-width: 2; }
.chart-endval { fill: var(--ink); font: 650 12px var(--font); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.chart-cross { stroke: var(--muted); stroke-width: 1; shape-rendering: crispEdges; }
.chart-empty { fill: var(--muted); font: 13px var(--font); }
.chart-bar { fill: var(--blue); shape-rendering: geometricPrecision; }
.chart-bar.is-hover { fill: var(--blue-ink); }
.chart-svg-bars { cursor: default; }
.chart-tip { position: absolute; top: 0; left: 0; z-index: 5; pointer-events: none; padding: 6px 10px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-s); box-shadow: var(--shadow); white-space: nowrap; line-height: 1.3; }
.chart-tip::before { content: ""; display: inline-block; width: 14px; height: 0; border-top: 2px solid var(--blue); vertical-align: middle; margin-right: 6px; border-radius: 1px; }
.tip-val { font-weight: 700; font-size: 14px; }
.tip-unit { color: var(--muted); font-size: 12px; }
.tip-lbl { display: block; color: var(--muted); font-size: 12px; }
.chart-data { margin-top: 8px; font-size: 13px; }
.chart-data summary { color: var(--blue-ink); font-weight: 650; padding: 4px 0; border-radius: 6px; }
.chart-table { max-height: 15rem; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-s); margin-top: 6px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 6px 12px; text-align: left; border-bottom: 1px solid var(--u-line-2); }
table.data tr:last-child td { border-bottom: 0; }
table.data th { position: sticky; top: 0; background: var(--u-fill); color: var(--muted); font-size: 12px; font-weight: 700; }
table.data .num { text-align: right; white-space: nowrap; }

/* ---------- вход ---------- */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 12px; }
.login > .card { width: min(420px, 100%); padding: 28px 26px; margin: 0; overflow: visible; }
.login .logo { display: block; width: 34px; height: 34px; border-radius: 10px; margin-bottom: 14px; box-shadow: 0 6px 14px color-mix(in srgb, var(--blue) 28%, transparent); }
.login h1 { font-size: 24px; font-weight: 760; letter-spacing: -.03em; margin-bottom: 6px; }
.login p.lead { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login .field { margin-bottom: 14px; }
.login .field > input { max-width: none; }
.login .form-actions { margin-top: 0; }
.login .form-actions .btn { min-height: 40px; }

/* ---------- планшет ---------- */
@media (max-width: 1100px) {
  .cols-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 801px) {
  .tiles.tiles-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .tiles.tiles-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
}

/* ---------- телефон ---------- */
@media (max-width: 800px) {
  .panel-header { padding: 14px 16px 12px; }
  .panel-body { padding: 14px 16px 16px; }
  .toolbar { padding: 12px 16px; }
  .toolbar .grow, .toolbar input, .toolbar select, .toolbar > label { flex: 1 1 100%; }
  .toolbar > .muted { margin-left: 0; }
  .flush-note { margin: 12px 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tile { padding: 14px; }
  .tile-value { font-size: 26px; }
  .tile-value.small { font-size: 15px; }
  .tile-value.mid { font-size: 18px; }
  .summary { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .field:has(> .label) { flex-direction: column; align-items: stretch; gap: 2px; }
  .field > .label { flex: none; }
  .field-row > .field { flex-basis: 100%; }
  .field > input, .field > select, .field > textarea { max-width: none; }
  .checks { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .radio-row { gap: 0 18px; }
  .radio-row.col { gap: 4px; }
  .qr-box img { width: 100%; max-width: 260px; }
  .chart-tick, .chart-xtick { font-size: 13px; }
  .chart-endval { font-size: 14px; }
  .chart-empty { font-size: 16px; }
  .chart-data summary { padding: 12px 0; }
  .form-actions .btn { flex: 1 1 auto; }
  .panel:has(> table.grid), .panel:has(> .panel-body > table.grid) { overflow-x: visible; }

  /* таблицы становятся карточками: у <td> задан data-label */
  table.grid, table.grid tbody, table.grid tr, table.grid td { display: block; width: 100%; }
  table.grid thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .panel-body:has(> table.grid:only-child) { padding: 10px; }
  .panel > table.grid { padding: 10px 10px 2px; }
  table.grid tbody tr { border: 1px solid var(--line); border-radius: var(--radius-s); margin: 0 0 10px; padding: 4px 0; background: var(--surface); }
  table.grid tbody tr:hover td { background: transparent; }
  table.grid td { position: relative; border: 0; padding: 6px 12px; min-height: 34px; text-align: left; }
  table.grid td:first-child, table.grid td:last-child { padding-left: 12px; padding-right: 12px; }
  table.grid td[data-label] { padding-left: 42%; }
  table.grid td[data-label]:first-child { padding-left: 42%; }
  table.grid td[data-label]::before { content: attr(data-label); position: absolute; left: 12px; top: 7px; width: 36%; color: var(--muted); font-weight: 650; font-size: 12px; line-height: 1.5; }
  table.grid td.num { text-align: left; white-space: normal; }
  table.grid td.actions-cell, table.grid td:not([data-label]):not([colspan]) { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; border-top: 1px solid var(--u-line-2); margin-top: 4px; white-space: normal; }
  table.grid td.actions-cell.none { display: none; }
  table.grid td form.inline, table.grid td .btn { margin: 0; }
  table.grid td form.inline .btn { min-width: 0; }
  table.grid:has(th:nth-child(7)) { font-size: 14px; }
  table.grid:has(th:nth-child(7)) td { padding-left: 12px; padding-right: 12px; }
  table.grid td form.inline { display: inline-flex; }
  table.grid td .btn { white-space: nowrap; }
  table.grid td.empty, table.grid td[colspan] { padding: 14px 12px; }
  .prog { min-width: 0; }
  table.grid:has(th:nth-child(7)) td[data-label] { padding-left: 42%; padding-right: 12px; }
}
@media (max-width: 719px) {
  .btn { min-height: 44px; }
  .btn.small { min-height: 44px; }
  input[type=text], input[type=password], input[type=date], input[type=number], input[type=search], input[type=tel], input[type=email], input[type=url], input[type=datetime-local], select, textarea { min-height: 46px; font-size: 16px; }
  input[type=file] { min-height: 46px; font-size: 16px; }
  input[type=number] { width: 7rem; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  .checks label, .radio-row label, label.opt { min-height: 44px; }
  .radio-row { flex-direction: column; align-items: stretch; gap: 0; }
  .radio-row.nowrap { flex-direction: row; align-items: center; gap: 8px; }
  .radio-row.col label { min-height: 0; }
  .tg-state a { display: inline-flex; align-items: center; min-height: 32px; }
  .chart-svg { touch-action: pan-y; }
}
@media (max-width: 420px) {
  .tiles { gap: 8px; }
  .login > .card { padding: 24px 20px; }
}
@media print { .sidebar, .appbar, .tabbar, .toolbar, .backdrop { display: none !important; } .shell { display: block; } }

/* ---------- страница «Провайдеры» (templates/providers.html) ---------- */
.prov-cols { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px 24px; align-items: start; }
.prov-proxy { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--u-fill); }
.prov-proxy .sub-h { margin: 0; }
.prov .err-text { color: var(--red-ink); }
.prov .field > input, .prov .field > select { max-width: none; }
.prov .panel-header .actions { margin-left: auto; }
@media (max-width: 960px) { .prov-cols { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 719px) { .prov .panel-header .actions { margin-left: 0; } }

/* ---------- потоки (templates/forwards.html, flow.html, _flow_source.html, _flow_target.html) ----------
   КОНТРАКТ: .ph2 заголовок раздела; .crumb «← назад»; .lead пояснение под заголовком; .empty-state пустой блок;
   details.panel.disclose > summary.panel-header — сворачиваемая карточка (форма «Создать поток»);
   .flow-cards > form.panel.flow-card — карточки источников/целей (сетка, на телефоне одна колонка), .is-off — выключенная;
   .card-title — заголовок карточки; .picker-list > label.pick > (input, .pick-t, .pick-k) — список чатов с чекбоксами и поиском;
   fieldset.ai-block — блок «ИИ» в карточке источника (data-ai, select[data-ai-provider], select[data-ai-model]). */
.ph2 { font-size: 18px; font-weight: 700; letter-spacing: -.02em; margin: 26px 0 6px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.ph2 .muted { font-size: 13.5px; font-weight: 400; letter-spacing: 0; }
.crumb { margin: 0 0 4px; font-size: 13.5px; }
.crumb a { display: inline-flex; align-items: center; min-height: 32px; }
.lead { margin: 0 0 14px; font-size: 13.5px; }
.empty-state { padding: 6px 0; color: var(--muted); }
.panel-body:has(> .empty-state:only-child) { padding: 18px 20px; }
.panel-body:has(> table.grid:only-child) > table.grid { margin: 0; }
details.disclose > summary.panel-header { cursor: pointer; list-style: none; position: relative; padding-right: 48px; }
details.disclose > summary.panel-header::-webkit-details-marker { display: none; }
details.disclose > summary.panel-header::after { content: ""; position: absolute; right: 22px; top: 50%; width: 8px; height: 8px; margin-top: -6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
details.disclose[open] > summary.panel-header::after { transform: rotate(-135deg); margin-top: -2px; }
details.disclose:not([open]) > summary.panel-header { border-bottom-color: transparent; }
details.disclose > summary.panel-header .muted { font-size: 13px; }
.flow-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 440px), 1fr)); gap: 0 18px; align-items: start; margin-bottom: 18px; }
.flow-cards > .note { grid-column: 1 / -1; }
.flow-card { margin-bottom: 18px; }
.flow-card.is-off > .panel-body { opacity: .6; }
.flow-card.is-off > .panel-header .card-title::after { content: " · выключен"; color: var(--muted); font-weight: 500; font-size: 13px; }
.card-title { font-size: 16px; font-weight: 700; letter-spacing: -.015em; min-width: 0; flex: 1 1 200px; }
.panel-header label.opt { min-height: 34px; font-weight: 600; font-size: 13.5px; }
.ai-block { margin: 0; padding: 14px 14px 16px; border: 1px solid var(--blue-line); border-radius: var(--radius-s); background: color-mix(in srgb, var(--blue-soft) 55%, var(--surface)); display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ai-block legend { margin: 0; padding: 0 6px; font-weight: 700; font-size: 13.5px; color: var(--blue-ink); }
.ai-block .note { margin: 0; }
.ai-block .field > select + input[type=text] { margin-top: 6px; }
.picker-list { display: flex; flex-direction: column; max-height: 260px; overflow-y: auto; border: 1px solid var(--u-field-line); border-radius: var(--radius-s); background: var(--surface); padding: 4px; }
.pick { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 4px 8px; border-radius: 8px; cursor: pointer; }
.pick:hover { background: var(--u-hover); }
.pick:has(input:checked) { background: var(--blue-soft); }
.pick:has(input:disabled) { cursor: not-allowed; color: var(--muted); }
.pick .pick-t { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.pick .pick-k { flex: none; color: var(--muted); font-size: 12px; text-align: right; }
.pick[hidden] { display: none; }
td .sub { margin-top: 2px; }
@media (max-width: 800px) {
  .flow-cards { grid-template-columns: minmax(0, 1fr); }
  .panel-body:has(> .empty-state:only-child) { padding: 14px 16px; }
  .picker-list { max-height: 240px; }
  .ph2 { margin-top: 22px; }
}
@media (max-width: 719px) {
  .pick { min-height: 44px; }
  .crumb a { min-height: 44px; }
  .ai-block { padding: 12px 10px 14px; }
}
#flows table.grid td[data-label="Поток"] { min-width: 140px; }
#flows table.grid td[data-label="Счётчики"] { min-width: 150px; }
#flows table.grid td .tag, #pairs table.grid td .tag { white-space: nowrap; }
.flow-card .checks { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }
.flow-card .checks:has(> label:only-child) { display: block; }
.flow-card .field-row > .field { flex-basis: 180px; }

/* ---------- защита контента и «Сохранить себе» (templates/_macros.html: protected_*, _save_form.html, chats.html) ---------- */
.tag.prot-tag { gap: 5px; border-color: var(--red); background: var(--red-soft); color: var(--red-ink); font-weight: 700; white-space: nowrap; cursor: help; }
.tag.prot-tag::before { display: none; }
.tag.prot-tag svg.icon { width: 14px; height: 14px; stroke-width: 2.2; }
td .tag.prot-tag, .chat-title .tag.prot-tag { margin-left: 4px; }
.pick .prot-tag { flex: none; padding: 2px 8px; }
.pick:has(input:disabled) .prot-tag { color: var(--red-ink); }
option.opt-prot { color: var(--red-ink); }
.prot-count { display: inline-flex; align-items: center; gap: 5px; font-size: 13.5px; color: var(--red-ink); font-weight: 600; }
.prot-count svg.icon { width: 15px; height: 15px; stroke-width: 2; }
.prot-count a { font-weight: 600; text-decoration: underline; }
.forbid { display: inline-flex; align-items: center; min-height: 30px; padding: 0 10px; border: 1px dashed var(--red-line); border-radius: var(--radius-s); color: var(--red-ink); font-size: 12.5px; font-weight: 600; cursor: help; white-space: nowrap; }
.save-panel.accent { border-color: var(--red-line); }
.save-panel.accent > .panel-header { background: var(--red-soft); border-bottom-color: var(--red-line); }
.save-panel .panel-header .prot-tag { margin-left: 0; }
.save-mode { gap: 8px; }
.save-mode > .field.row { align-items: center; }
.panel-body:has(> .note:first-child) > .note:first-child { margin-bottom: 0; }
#protected-note p { margin: 0 0 6px; }
#protected-note p:last-child { margin-bottom: 0; }
@media (max-width: 800px) { .forbid { white-space: normal; } }
table.grid td .btn-row .btn { white-space: nowrap; margin: 0; }
.btn-row { display: inline-flex; flex-wrap: nowrap; gap: 8px; vertical-align: middle; }
.actions-cell > .forbid { display: flex; width: fit-content; margin-top: 6px; }
.pick { flex-shrink: 0; }
@media (max-width: 719px) {
  .pick { flex-wrap: wrap; row-gap: 2px; }
  .pick .pick-t { flex: 1 1 calc(100% - 80px); }
  .pick .prot-tag { margin-left: 32px; }
}

/* ---------- выбор чата (static/app.js, templates/_chatpick.html) ---------- */
.chatpick { position: relative; width: 100%; max-width: 640px; min-width: 0; }
.chatpick-fallback { display: flex; flex-direction: column; gap: 6px; }
.chatpick-fallback > select { max-width: 640px; }
.chatpick-hint { font-size: 12.5px; }
.chatpick-anchor { position: relative; }
.chatpick-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 44px; padding: 4px 8px; border: 1px solid var(--u-field-line); border-radius: var(--radius-s); background: var(--surface); cursor: text; transition: border-color .15s, box-shadow .15s; }
.chatpick-field:hover { border-color: var(--muted); }
.chatpick-field:focus-within { border-color: var(--blue); box-shadow: var(--u-ring); }
.chatpick-chips { display: contents; }
.chatpick-field .chatpick-input { flex: 1 1 140px; min-width: 120px; min-height: 34px; padding: 4px; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.chatpick-field .chatpick-input:focus { box-shadow: none; }
.chatpick-field .chatpick-input[hidden] { display: none; }
.chatpick-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-height: 32px; padding: 2px 3px 2px 10px; border: 1px solid var(--blue-line); border-radius: 8px; background: var(--blue-soft); color: var(--blue-ink); font-size: 13.5px; font-weight: 600; }
.chatpick-chip-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chatpick-chip-k { flex: none; color: var(--muted); font-size: 12px; font-weight: 500; }
.chatpick-x { flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: inherit; font-size: 18px; line-height: 1; cursor: pointer; }
.chatpick-x:hover { background: color-mix(in srgb, var(--blue) 16%, transparent); }
.chatpick-x:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
.chatpick-list { position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; max-height: min(340px, 55vh); overflow-y: auto; overscroll-behavior: contain; background: var(--surface); border: 1px solid var(--u-field-line); border-radius: var(--radius-s); box-shadow: var(--shadow); }
.chatpick-list[hidden] { display: none; }
.chatpick-list.is-loading { opacity: .6; }
.chatpick-opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 44px; padding: 6px 10px; border-radius: 8px; cursor: pointer; }
.chatpick-opt.is-active { background: var(--blue-soft); }
.chatpick-opt.is-selected { color: var(--blue-ink); font-weight: 600; }
.chatpick-opt.is-disabled { cursor: not-allowed; color: var(--muted); }
.chatpick-opt.is-prot { color: var(--red-ink); }
.chatpick-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.chatpick-t { overflow-wrap: anywhere; }
.chatpick-u { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.chatpick-meta { display: inline-flex; align-items: center; gap: 8px; flex: none; color: var(--muted); font-size: 12px; font-weight: 400; }
.chatpick-opt .prot-tag { padding: 2px 8px; }
.chatpick-check { color: var(--blue-ink); font-weight: 700; font-size: 14px; }
.chatpick-more { justify-content: center; color: var(--blue-ink); font-weight: 650; }
.chatpick-status { padding: 12px; text-align: center; color: var(--muted); font-size: 13.5px; }
.chatpick-status.is-err { color: var(--red-ink); }
.chatpick-msg { margin-top: 6px; font-size: 12.5px; }
.chatpick-msg[hidden] { display: none; }
.panel:has(.chatpick-list) { overflow: visible; }      /* список не обрезается карточкой; скругление шапки задаём сами */
.panel:has(.chatpick-list) > .panel-header, .panel:has(.chatpick-list) > summary.panel-header { border-radius: var(--radius) var(--radius) 0 0; }
.field > .chatpick, .field > .chatpick .chatpick-fallback { max-width: 640px; }
@media (max-width: 719px) {
  .chatpick-field .chatpick-input { font-size: 16px; min-height: 40px; }
  .chatpick-x { width: 36px; height: 36px; }
  .chatpick-opt { flex-wrap: wrap; row-gap: 2px; }
  .chatpick-list { max-height: min(320px, 50vh); }
}

/* ---------- постраничный вывод /chats ---------- */
.list-caption { padding: 10px 20px 0; font-size: 13px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--u-line-2); }
.pager-nums { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; }
.pager .btn { min-width: 44px; min-height: 44px; }
.pager .btn.is-off { opacity: .45; pointer-events: none; }
.pager .btn[aria-current="page"] { cursor: default; }
.pager-gap { min-width: 22px; text-align: center; color: var(--muted); }
@media (max-width: 719px) {
  .list-caption { padding: 10px 16px 0; }
  .pager { padding: 12px 16px; }
  .pager-prev, .pager-next { flex: 1 1 calc(50% - 5px); order: 1; }
  .pager-next { order: 2; }
  .pager-nums { order: 3; flex: 1 1 100%; flex-wrap: nowrap; gap: 4px; }
  .pager-nums .btn { padding: 0 8px; }
  .pager-gap { min-width: 16px; }
}
.toolbar select.per-page { flex: 0 0 auto; width: auto; }
@media (max-width: 800px) { .toolbar select.per-page { flex: 0 0 112px; } }

/* ---------- «Задачи»: все кнопки в таблице одного размера ---------- */
table.grid.jobs td .btn, table.grid.jobs td form.inline .btn { box-sizing: border-box; width: 112px; min-width: 0; min-height: 36px; padding: 0 8px; }
table.grid.jobs td form.inline { margin: 0 6px 6px 0; display: inline-flex; }
table.grid.jobs td form.inline:last-child { margin-bottom: 6px; }
@media (max-width: 719px) {
  table.grid.jobs td.actions-cell, table.grid.jobs td[data-label="Файлы"] { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  table.grid.jobs td[data-label="Файлы"] { padding: 28px 12px 6px; border-top: 0; margin-top: 0; }
  table.grid.jobs td[data-label="Файлы"]:has(> .muted:only-child) { display: block; padding: 6px 12px 6px 42%; }
  table.grid.jobs td[data-label="Файлы"]::before { width: auto; }
  table.grid.jobs td[data-label="Файлы"] > .muted { grid-column: 1 / -1; }
  table.grid.jobs td .btn, table.grid.jobs td form.inline .btn { width: 100%; min-height: 44px; margin: 0; }
  table.grid.jobs td form.inline { display: flex; margin: 0; }
  table.grid.jobs td.actions-cell.none { display: none; }
}
