/* 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: 1360px; margin: 0 auto; padding: 22px var(--gutter) 48px; }

.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: 12px 12px 4px; 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: 36px; padding: 6px 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: 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=time], 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):not(.att-row) { 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; }
.login { grid-template-columns: minmax(0, 1fr); justify-items: center; align-content: center; gap: 12px; padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.login .login-install { width: min(420px, 100%); }
.login .login-install[hidden] { display: none; }
.login-again { display: flex; justify-content: center; align-items: center; min-height: 32px; margin: 10px 0 -8px; font-size: 14px; font-weight: 600; }
.set-tabs { display: flex; gap: 4px; padding: 3px; margin-bottom: 16px; width: max-content; max-width: 100%; overflow-x: auto; scrollbar-width: none; background: var(--u-fill); border: 1px solid var(--line); border-radius: 12px; }
.set-tabs a { padding: 7px 14px; border-radius: 9px; color: var(--soft); font-weight: 600; font-size: 13.5px; white-space: nowrap; text-decoration: none; }
.set-tabs a.on { background: var(--surface); color: var(--blue-ink); box-shadow: var(--u-shadow-sm); }

/* ---------- планшет ---------- */
@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], input[type=time], 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; }
}

/* Аккаунты Telegram: страница «Аккаунты и учёт» */
.acc-table td.num, .acc-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.acc-table .acc-name { font-weight: 650; }
.acc-table td, .acc-table th { vertical-align: middle; }
.acc-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; justify-content: flex-end; min-width: max-content; }
.acc-more[open] { flex-basis: 100%; }
.acc-actions form { margin: 0; }
.acc-actions .btn { white-space: nowrap; }
.acc-more > summary { list-style: none; cursor: pointer; }
.acc-more > summary::-webkit-details-marker { display: none; }
.acc-more[open] > summary { background: var(--u-fill); }
.acc-pop { display: grid; gap: 14px; margin-top: 8px; padding: 12px; width: min(340px, 100%); border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); text-align: left; }
.acc-pop label { display: block; margin-bottom: 4px; color: var(--soft); font-size: 12.5px; font-weight: 600; }
.acc-pop .opt { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 8px; font-weight: 500; line-height: 1.35; }
.acc-pop .opt input { margin-top: 3px; flex: none; }
.acc-row { display: flex; gap: 8px; }
.acc-row input[type=text] { flex: 1; min-width: 0; min-height: 34px; }
.acc-remove { padding-top: 12px; border-top: 1px solid var(--line); }
.acc-total td { font-weight: 700; border-top: 2px solid var(--line); }
.acc-table .actions-cell { width: 1%; white-space: nowrap; }
.tg-state .tg-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Вход в Telegram: шаги, форма и запасные способы */
.auth-panel { max-width: 520px; }
.auth-body { gap: 18px; }
.auth-lead { margin: 0; line-height: 1.5; }
.auth-form { gap: 14px; margin: 0; }
.auth-form .field > input { max-width: none; width: 100%; min-height: 44px; font-size: 16px; }
.btn.wide { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 42px; text-align: center; }
.auth-alt { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.auth-alt form { margin: 0; }
.auth-alt p { margin: 0; font-size: 13.5px; line-height: 1.45; }
.auth-or { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .06em; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.auth-steps { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }
.auth-steps li { flex: 1; display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-s); color: var(--muted); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.auth-steps li span { flex: none; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--u-fill); font-size: 12px; }
.auth-steps li.on { color: var(--blue-ink); border-color: var(--blue-line); background: var(--blue-soft); }
.auth-steps li.on span { background: var(--blue); color: #fff; }
.auth-steps li.done { color: var(--green-ink); }
.auth-steps li.done span { background: var(--green-soft); color: var(--green-ink); }
.auth-panel .qr-box { align-self: center; }
@media (max-width: 480px) { .auth-steps li { padding: 6px 8px; font-size: 12px; } .auth-steps li span { display: none; } }

/* ===== Аккаунты: карточки, окна, QR-вход, вкладки аккаунтов ===== */
.acc-lead { margin: 0; line-height: 1.5; max-width: 780px; }
.acc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.acc-card { display: flex; flex-direction: column; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.acc-card.is-current { border-color: var(--blue-line); box-shadow: 0 0 0 3px var(--blue-soft); }
.acc-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.acc-avatar { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-ink); font-size: 18px; font-weight: 700; }
.acc-id { flex: 1; min-width: 0; }
.acc-title { font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-phone { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-head > .tag { flex: none; }
.acc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0; }
.acc-stats > div { padding: 10px 12px; border-radius: var(--radius-s); background: var(--u-fill); min-width: 0; }
.acc-stats dt { margin: 0 0 2px; color: var(--muted); font-size: 12px; }
.acc-stats dd { margin: 0; font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.acc-stats dd small { font-size: 12px; font-weight: 500; color: var(--muted); }
.acc-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }
.acc-btns form { margin: 0; }
.acc-table td.num, .acc-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.acc-table .acc-name { font-weight: 650; }
.acc-total td { font-weight: 700; border-top: 2px solid var(--line); }

dialog.dlg { width: min(460px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: inherit; box-shadow: var(--shadow); }
dialog.dlg::backdrop { background: #0b1220a8; backdrop-filter: blur(2px); }
.dlg-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg-title { margin: 0; font-size: 18px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dlg .field > input { max-width: none; width: 100%; }
.dlg .opt { display: flex; gap: 8px; align-items: center; }

.qr-login { display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.qr-stage { display: flex; justify-content: center; }
.qr-frame { position: relative; width: 264px; height: 264px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.qr-img { display: block; width: 240px; height: 240px; }
.qr-skeleton { position: absolute; inset: 12px; border-radius: 8px; background: linear-gradient(100deg, #e9eef5 30%, #f6f8fb 50%, #e9eef5 70%); background-size: 200% 100%; animation: qr-shimmer 1.3s linear infinite; }
@keyframes qr-shimmer { to { background-position: -200% 0; } }
.qr-msg { min-height: 20px; text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.45; }
.qr-msg.ok { color: var(--green-ink); font-weight: 650; font-size: 15px; }
.qr-msg.err { color: var(--red-ink, #b3261e); }
.qr-msg.warn { color: var(--orange, #b45309); }
.qr-login[data-step="ok"] .qr-msg { padding: 18px 0; }
.qr-add .qr-msg { text-align: left; min-height: 0; }
.qr-add .qr-msg:empty { display: none; }

.acc-tabs { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.acc-tabs-label { color: var(--muted); font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-right: 2px; }
.acc-tab { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: inherit; font-size: 14px; font-weight: 600; text-decoration: none; }
.acc-tab:hover { border-color: var(--blue-line); }
.acc-tab.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.acc-tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.acc-tab .dot.ok { background: var(--green); }
.acc-tab.on .dot { box-shadow: 0 0 0 2px #ffffff66; }
.acc-tab small { font-size: 11.5px; font-weight: 500; opacity: .75; }
.acc-tab-link { font-size: 13px; }
@media (max-width: 480px) { .acc-grid { grid-template-columns: 1fr; } }

/* Кнопки-иконки в списке чатов */
.icon-row { display: inline-flex; gap: 8px; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--soft); transition: background .15s, color .15s, border-color .15s, transform .1s; }
.icon-btn .icon { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:hover { background: var(--blue-soft); border-color: var(--blue-line); color: var(--blue-ink); }
.icon-btn:active { transform: scale(.94); }
.icon-btn:first-child { background: var(--blue); border-color: var(--blue); color: #fff; }
.icon-btn:first-child:hover { background: var(--blue-ink); border-color: var(--blue-ink); color: #fff; }
.icon-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* Интеграции, пользователи и прочие формы инструментов */
.steps { margin: 0; padding-left: 1.3em; line-height: 1.6; }
ul.plain { list-style: none; margin: 6px 0; padding: 0; display: grid; gap: 4px; font-size: 13.5px; }
.inline-edit { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.inline-edit select, .inline-edit input[type=password] { min-height: 34px; max-width: 200px; }
.api-doc pre { overflow-x: auto; padding: 12px; border-radius: var(--radius-s); background: var(--u-fill); border: 1px solid var(--line); font-size: 12.5px; line-height: 1.5; }
.api-doc summary { cursor: pointer; font-weight: 600; }
.logo-preview img { max-height: 64px; padding: 6px; border: 1px solid var(--line); border-radius: var(--radius-s); background: repeating-conic-gradient(#e5e9ef 0 25%, #fff 0 50%) 0 / 14px 14px; }
.note.ok { background: var(--green-soft); border-color: var(--green-line); color: var(--green-ink); }

/* Серверы клиентов: журнал выгрузки */
.deploy-log { max-height: 480px; overflow: auto; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--u-fill); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.steps .st-done::marker { color: var(--green-ink); }
.steps .st-failed { color: var(--red-ink); }
.steps .st-running { font-weight: 700; }
.steps .st-skipped, .steps .st-pending { color: var(--soft); }
.pthumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); vertical-align: middle; margin-right: 10px; background: var(--u-fill); }
.pquick { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px; }
.pquick label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--soft); }
.pquick label.checks { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }
.pquick input[type=text] { width: 90px; }
.pedit { margin-top: 8px; }
.pedit summary { cursor: pointer; color: var(--blue); font-size: 13px; }
.pedit form { margin-top: 8px; }
.poll-card { padding: 4px 0 14px; border-bottom: 1px solid var(--line-2); }
.poll-card:last-child { border-bottom: 0; }
.poll-row { display: grid; grid-template-columns: minmax(90px, 2fr) 3fr minmax(70px, auto); gap: 10px; align-items: center; margin-top: 6px; }
.poll-bar { height: 10px; border-radius: 999px; background: var(--u-fill); overflow: hidden; }
.poll-bar span { display: block; height: 100%; background: var(--blue); border-radius: 999px; }
.poll-num { font-size: 13px; color: var(--soft); text-align: right; white-space: nowrap; }
@media (max-width: 560px) { .poll-row { grid-template-columns: 1fr auto; } .poll-bar { grid-column: 1 / -1; order: 3; } }
.note.info .muted { color: var(--blue-ink); }

/* Раскрывающееся описание страницы (как в эталоне redirect) */
.page-help { margin: 0 0 16px; border: 1px solid var(--blue-line); border-radius: var(--radius); background: var(--blue-soft); }
.page-help > summary { cursor: pointer; list-style: none; padding: 10px 14px; font-weight: 600; color: var(--blue-ink); display: flex; align-items: center; gap: 10px; user-select: none; }
.page-help > summary::-webkit-details-marker { display: none; }
.page-help > summary::after { content: '▾'; margin-left: auto; }
.page-help[open] > summary::after { content: '▴'; }
.ph-ico { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--blue); color: #fff; font: italic 700 14px/1 Georgia, serif; }
.ph-body { padding: 0 16px 14px; }
.ph-body p { margin: 0 0 8px; }
.ph-body ul { margin: 0; padding-left: 18px; }
.ph-body li { margin: 4px 0; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--blue-line); border-top-color: var(--blue); border-radius: 50%; animation: tg-spin .8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes tg-spin { to { transform: rotate(360deg); } }
.chk { width: 34px; text-align: center; }
.assets-member > summary { cursor: pointer; list-style: none; display: flex; gap: 12px; align-items: baseline; }
.assets-member > summary::-webkit-details-marker { display: none; }

/* ---------- анимированные графики (static/charts.js, web/vcharts.py) ---------- */
.vchart { margin: 0; position: relative; }
.vchart-canvas { position: relative; }
.vchart-svg { display: block; max-width: 100%; overflow: visible; }
.vc-grid { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.vc-tick, .vc-xtick { fill: var(--muted); font: 11.5px var(--font); }
.vc-line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.vc-dot { stroke: var(--surface); stroke-width: 1.5; }
.vc-hover { stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.vc-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }
.vc-hoverbar { fill: var(--ink); opacity: .05; pointer-events: none; }
.vc-bar { transition: filter .15s; }
.vc-track { stroke: var(--track); }
.vc-arc { transition: opacity .15s, stroke-width .15s; cursor: default; outline: none; }
.vc-centre { fill: var(--ink); font: 700 22px var(--font); }
.vc-centre-sub { fill: var(--muted); font: 12px var(--font); }
.vchart-empty { display: grid; place-items: center; min-height: 120px; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius-s); font-size: 13.5px; text-align: center; padding: 16px; }
.vchart-tip { position: absolute; z-index: 6; pointer-events: none; padding: 7px 10px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); font-size: 12.5px; white-space: nowrap; }
.vchart-tip .tip-head { color: var(--muted); margin-bottom: 3px; }
.vchart-tip .tip-row { display: flex; align-items: center; gap: 6px; }
.vchart-tip .tip-name { color: var(--soft); }
.vchart-tip .tip-val { margin-left: auto; padding-left: 10px; font-variant-numeric: tabular-nums; }
.tip-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; }
.vchart-legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 8px; }
.lg-item { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; padding: 2px 6px; border-radius: 8px; color: var(--soft); font: 12.5px var(--font); cursor: pointer; }
.lg-item:hover { background: var(--u-hover); }
.lg-item[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.vc-donut { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; justify-content: center; }
.vc-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 180px; flex: 1 1 180px; max-width: 360px; }
.vc-list li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.vc-list .li-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vc-list .li-val { font-variant-numeric: tabular-nums; color: var(--soft); font-weight: 600; }
.vc-hbar { display: grid; gap: 9px; }
.hb-row { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; gap: 10px; align-items: center; font-size: 13.5px; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--soft); }
.hb-track { height: 14px; background: var(--track); border-radius: 8px; overflow: hidden; }
.hb-fill { height: 100%; width: 0; border-radius: 8px; }
.hb-val { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 3ch; text-align: right; }
.vc-funnel { display: grid; gap: 8px; }
.fn-row { display: grid; gap: 4px; }
.fn-head { display: flex; align-items: baseline; gap: 10px; font-size: 13.5px; }
.fn-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--soft); }
.fn-val { font-variant-numeric: tabular-nums; }
.fn-conv { font-size: 12px; color: var(--muted); }
.fn-track { height: 12px; background: var(--track); border-radius: 7px; overflow: hidden; }
.fn-bar { height: 100%; width: 0; border-radius: 7px; }
.vc-heat { display: grid; gap: 3px; align-items: center; font-size: 11.5px; }
.hm-col, .hm-row { color: var(--muted); text-align: center; }
.hm-row { text-align: right; padding-right: 6px; }
.hm-cell { aspect-ratio: 1.5 / 1; min-height: 18px; border-radius: 5px; background: color-mix(in srgb, var(--hm, var(--blue)) calc(var(--k) * 1%), var(--surface-2)); border: 1px solid var(--line-2); transition: transform .12s; }
.hm-cell.zero { background: var(--surface-2); }
.hm-cell:hover, .hm-cell:focus-visible { transform: scale(1.18) !important; position: relative; z-index: 2; }
.vc-gauge { display: flex; justify-content: center; }
.vchart-spark { display: inline-block; width: 96px; height: 30px; vertical-align: middle; }
.vchart-spark .vchart-svg { width: 100%; height: 100%; }

/* ---------- плитки статистики и появление блоков ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { position: relative; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--kpi, var(--blue)); }
.kpi-label { color: var(--muted); font-size: 12.5px; }
.kpi-value { font-size: 28px; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.delta { font-weight: 650; white-space: nowrap; }
.kpi-foot span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.delta.up { color: var(--green-ink); } .delta.down { color: var(--red-ink); }
.period-tabs { display: inline-flex; gap: 4px; padding: 3px; background: var(--u-fill); border: 1px solid var(--line); border-radius: 12px; }
.period-tabs a { padding: 5px 12px; border-radius: 9px; color: var(--soft); font-weight: 600; font-size: 13px; }
.period-tabs a.on { background: var(--surface); color: var(--blue-ink); box-shadow: var(--u-shadow-sm); }
@keyframes tg-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise > * { animation: tg-rise .5s ease both; }
.rise > *:nth-child(2) { animation-delay: .06s; } .rise > *:nth-child(3) { animation-delay: .12s; } .rise > *:nth-child(4) { animation-delay: .18s; }
.rise > *:nth-child(5) { animation-delay: .24s; } .rise > *:nth-child(n+6) { animation-delay: .3s; }
@media (prefers-reduced-motion: reduce) { .rise > * { animation: none; } }

.journal-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters input[type=search] { flex: 1 1 220px; min-width: 160px; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; }
.nowrap { white-space: nowrap; }
.sec { margin: 28px 0 12px; font-size: 18px; scroll-margin-top: 80px; }
.stats-nav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; position: sticky; top: 0; z-index: 4; padding: 8px 0; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(6px); }
.stats-nav a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--soft); font-size: 13px; font-weight: 600; }
.stats-nav a:hover { border-color: var(--blue-line); color: var(--blue-ink); }
.kpi-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .cols-3 { grid-template-columns: 1fr; } }
.feed { display: grid; gap: 8px; font-size: 13.5px; }
.feed-row { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: baseline; }
.appbar-search { position: relative; display: flex; align-items: center; margin-right: 8px; }
.appbar-search input { width: 220px; padding: 7px 34px 7px 34px; border-radius: 12px; transition: width .2s; }
.appbar-search input:focus { width: 300px; }
.appbar-search .s-ico { position: absolute; left: 10px; display: grid; place-items: center; color: var(--muted); pointer-events: none; }
.appbar-search .s-ico .icon { width: 16px; height: 16px; }
.appbar-search kbd { position: absolute; right: 9px; font: 11px var(--font); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; background: var(--surface-2); pointer-events: none; }
.appbar-search input:focus + kbd { display: none; }
.side-search { margin: 4px 12px 10px; }
.side-search input { width: 100%; }
.side-search input:focus { width: 100%; }

.attention.is-ok { border-color: var(--green-line); }
.att-list { display: grid; }
.att-row { display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; align-items: center; padding: 11px 20px; border-top: 1px solid var(--line-2); color: var(--ink); }
.att-row:hover { background: var(--u-hover); text-decoration: none; }
.att-main { display: grid; gap: 1px; min-width: 0; }
.att-main .muted { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--blue); }
.att-row.err .att-dot { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); animation: att-pulse 2s ease-in-out infinite; }
.att-row.warn .att-dot { background: var(--orange); }
.att-go { color: var(--blue-ink); font-weight: 600; font-size: 13px; white-space: nowrap; }
@keyframes att-pulse { 50% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .att-row.err .att-dot { animation: none; } }

/* ---------- узкий экран: общая подгонка (в конце файла, чтобы перекрывать правила блоков выше) ---------- */
@media (max-width: 719px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 12px 12px 14px; min-width: 0; }
  .kpi-value { font-size: 23px; overflow-wrap: anywhere; }
  .kpi-row { flex-wrap: wrap; }
  .kpi .vchart[data-chart*='"spark"'] { max-width: 100%; }
  .kpi-foot { flex-wrap: wrap; row-gap: 2px; }
  .kpi-foot span:last-child { white-space: normal; }
  .btn { max-width: 100%; white-space: normal; text-align: center; }
  .btn-row { display: flex; flex-wrap: wrap; max-width: 100%; }
  table.grid td .btn-row { flex-wrap: wrap; }
  /* ряды вкладок — одна прокручиваемая строка вместо пяти-шести этажей кнопок */
  .acc-tabs, .bot-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; padding-bottom: 2px; }
  .acc-tabs::-webkit-scrollbar, .bot-tabs::-webkit-scrollbar { display: none; }
  .acc-tabs > *, .bot-tabs > * { flex: 0 0 auto; }
  .bot-tabs .btn { white-space: nowrap; max-width: none; }
  .acc-title { white-space: normal; overflow-wrap: anywhere; }
}
@media (max-width: 719px) {
  .acc-head { flex-wrap: wrap; }
  .acc-head > .acc-id { flex: 1 1 9rem; min-width: 0; }
  .acc-title .tag { white-space: nowrap; }
  .appbar .brand-link { white-space: nowrap; }
}
@media (max-width: 359px) {
  .appbar { gap: 6px; padding-left: 10px; padding-right: 10px; }
  .appbar .brand-link strong { font-size: 14px; }
  .appbar .brand-mark { display: none; }
}
/* установленное приложение на телефоне с вырезом: содержимое не уходит под край экрана и жест «домой» */
.appbar { padding-top: max(10px, env(safe-area-inset-top)); }
@media (max-width: 1099px) {
  .appbar, .main > .wrap { padding-left: max(var(--gutter), env(safe-area-inset-left)); padding-right: max(var(--gutter), env(safe-area-inset-right)); }
  .sidebar { padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
}

/* ---------- отступы там, где у контейнера нет своей раскладки: поля, кнопки и подписи не слипаются ---------- */
form:not([class]) > :not([type=hidden]) ~ :not([type=hidden]) { margin-top: 14px; }
details > .field + .field, details > .field-row + .field-row { margin-top: 14px; }
.panel-body h2:not([class]), .panel-body h3:not([class]) { font-size: 15px; font-weight: 700; letter-spacing: -.01em; margin: 8px 0 0; }
.login p.lead code { white-space: nowrap; }


/* ---------- приложение и уведомления в левом меню ---------- */
.app-menu { display: grid; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--line); flex: none; }
.app-menu:not(:has(> :not([hidden]))) { display: none; }
.app-notify { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px; }
.app-notify:hover { background: var(--nav-hover); color: var(--ink); text-decoration: none; }
.app-notify svg.icon { width: 20px; height: 20px; }
.app-notify .app-name { flex: 1; min-width: 0; }
.app-state { font-size: 11.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.app-state.ok { color: var(--green-ink); border-color: var(--green-line); background: var(--green-soft); }
.app-state.warn { color: var(--orange-ink); border-color: var(--orange-line); background: var(--orange-soft); }
.app-menu .btn svg.icon { width: 20px; height: 20px; }
/* невысокий экран ноутбука: блок и учётная запись остаются внизу на виду, прокручивается только список разделов */
@media (max-height: 800px) {
  .side-head { padding-top: 12px; padding-bottom: 8px; } .side-tg { padding-bottom: 6px; } .app-menu { padding-top: 8px; padding-bottom: 8px; }
  .app-notify, .app-menu .btn.wide { min-height: 38px; } .nav-foot { padding-top: 8px; padding-bottom: 8px; }
}
/* совсем низкий (телефон боком): прокручивается всё меню, а не узкая полоска пунктов */
@media (max-height: 520px) { .sidebar { overflow-y: auto; } .sidebar .nav { flex: none; overflow: visible; } }

/* ---------- длинные названия, слова без пробелов, ссылки: переносятся, а не распирают таблицы и карточки ----------
   .brk ставит app.js элементам, в тексте которых есть «слово» от 22 знаков; короткие колонки по буквам не рвутся */
.brk, table.grid td.brk, table.grid td .brk { overflow-wrap: anywhere; min-width: 0; }
.tag.brk { white-space: normal; }
table.grid td.date-cell { white-space: nowrap; }
.ph1, .panel-header h1, .panel-header h2, .card-title, .att-main b { overflow-wrap: anywhere; min-width: 0; }
.att-row { grid-template-columns: 14px minmax(0, 1fr) auto; }
.feed-row { grid-template-columns: 90px minmax(0, 1fr); }
.feed-row > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.vc-list { grid-template-columns: minmax(0, 1fr); }
.vc-list li { min-width: 0; }
.lg-item { max-width: 100%; min-width: 0; text-align: left; overflow-wrap: anywhere; }

/* кнопки в строках таблиц: одна высота и ширина, ровные промежутки */
table.grid td .btn-row { align-items: center; }
table.grid td .btn-row > .btn, table.grid td .btn-row > form.inline { margin: 0; }
@media (min-width: 801px) {
  table.grid td:is(.actions-cell, [data-label="Действия"]) > a.btn { display: flex; width: max-content; min-width: 124px; margin: 0 0 6px; }
}
@media (max-width: 800px) {
  table.grid td[data-label="Действия"] { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px 6px; }
  table.grid td[data-label="Действия"]::before { content: none; }
  table.grid td[data-label="Действия"] > * { margin: 0; }
}

/* меню: список разделов прокручивается — край тает, чтобы было видно, что есть ещё */
@media (min-height: 521px) {
  .sidebar .nav { padding-top: 8px; padding-bottom: 26px; -webkit-mask-image: linear-gradient(to bottom, transparent, #000 14px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 14px, #000 calc(100% - 28px), transparent); }
}
@media (max-height: 960px) and (min-width: 1100px) {
  .side-head { padding-top: 12px; padding-bottom: 8px; } .side-tg { padding-bottom: 6px; } .app-menu { padding-top: 8px; padding-bottom: 8px; }
  .app-notify, .app-menu .btn.wide { min-height: 36px; } .nav-foot { padding-top: 8px; padding-bottom: 8px; }
}

/* телефон: шапка не обрезает состояние Telegram */
@media (max-width: 719px) {
  .appbar .brand-link { min-width: 0; overflow: hidden; }
  .appbar .brand-link strong { overflow: hidden; text-overflow: ellipsis; }
  .appbar .tg-state { flex: none; }
}
@media (max-width: 399px) { .appbar { gap: 7px; } .appbar .brand-mark { display: none; } }

/* касание: не меньше 44px на телефоне и на планшете с пальцем */
@media (max-width: 719px), (max-width: 1099px) and (pointer: coarse) {
  .btn, .btn.small, .toolbar .btn, .login .form-actions .btn { min-height: 44px; }
  .shell-btn, .nav-foot .shell-btn { width: 44px; height: 44px; }
  .nav a, .app-notify, .app-menu .btn.wide, .side-search input { 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], input[type=time], input[type=file], select, textarea { min-height: 44px; }
  summary { min-height: 44px; }
  details > summary:not([class]) { padding-top: 12px; padding-bottom: 12px; }
  .set-tabs a { display: inline-flex; align-items: center; min-height: 44px; }
  .checks label, .radio-row label, label.opt { min-height: 44px; }
  .lg-item { min-height: 32px; }
}

/* бейджи и ники с длинными «словами» в узкой колонке не сжимаются до столбика по букве */
table.grid td .brk:is(.tag, .muted) { display: inline-block; min-width: 12ch; }
li pre, li code { white-space: pre-wrap; overflow-wrap: anywhere; }
table.grid td .btn.small { white-space: nowrap; }
/* поле и кнопка в одной строке таблицы или формы — одной высоты и без нижних отступов */
table.grid td .btn-row { row-gap: 8px; }
table.grid td form.inline:has(> input[type=text]) { align-items: center; gap: 6px; }
table.grid td form.inline:has(> input[type=text]) .btn { min-width: 0; align-self: stretch; }
table.grid td .btn-row > form.inline > .btn, table.grid td .btn-row > .btn { min-height: 40px; }
.field-row .field > input[type=file] { min-height: 40px; height: 40px; }
@media (max-width: 719px), (max-width: 1099px) and (pointer: coarse) {
  .btn.wide, .acc-tab, .inline-edit select, .inline-edit input[type=password], .chatpick-input, .ed-name, #ed-name { min-height: 44px; }
  .field-row .field > input[type=file] { height: auto; min-height: 46px; }
  table.grid td .btn-row > form.inline > .btn, table.grid td .btn-row > .btn { min-height: 44px; }
}

/* широкие таблицы (7 колонок и больше) помещаются в карточку: кнопки переносятся, у первой колонки есть ширина */
@media (min-width: 801px) {
  table.grid:has(th:nth-child(7)):not(:has(td:first-child.num)) th:first-child { width: 190px; }
  table.grid:has(th:nth-child(7)) td .btn-row { flex-wrap: wrap; min-width: 150px; }
  table.grid:has(th:nth-child(9)) { font-size: 12.5px; }
  table.grid:has(th:nth-child(9)) th { white-space: normal; vertical-align: bottom; }
  table.grid:has(th:nth-child(9)) th, table.grid:has(th:nth-child(9)) td { padding-left: 6px; padding-right: 6px; }
  table.grid:has(th:nth-child(9)) th:first-child, table.grid:has(th:nth-child(9)) td:first-child { padding-left: 14px; }
  table.grid:has(th:nth-child(9)) th:last-child, table.grid:has(th:nth-child(9)) td:last-child { padding-right: 14px; }
  table.grid:has(th:nth-child(9)):not(:has(td:first-child.num)) th:first-child { width: 200px; }
  table.grid:has(th:nth-child(9)) td .btn-row { min-width: 110px; }
  table.grid:has(th:nth-child(9)) td .btn { padding: 0 8px; min-width: 0; }
  table.grid:has(th:nth-child(9)) td input[type=text] { width: 4.5rem !important; }
}
table.grid td code:not(.brk) { overflow-wrap: normal; white-space: nowrap; }

/* вход: «Установить приложение» той же ширины, что карточка (общий .btn.wide растягивал на весь экран) */
.login .btn.login-install { width: min(420px, 100%); }
/* список с галочками: длинное название и @ник переносятся под ним, а не сжимают друг друга */
.checks label { min-width: 0; }
.checks label:has(> .muted, > .tag) { display: grid; grid-template-columns: auto minmax(0, 1fr); align-content: center; row-gap: 2px; }
.checks label > .muted, .checks label > .tag { grid-column: 2; justify-self: start; min-width: 0; }
table.grid td form.inline label { white-space: nowrap; }
table.grid td form.inline:has(label) { flex-wrap: wrap; align-items: center; gap: 6px; }
.inline-num { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.panel-header .actions select { max-width: 100%; }
@media (max-width: 719px) { .panel-header form.actions { margin-left: 0; flex: 1 1 100%; } .panel-header form.actions select { width: 100%; min-width: 0; } }
@media (max-width: 560px) {
  .att-row { grid-template-columns: 14px minmax(0, 1fr); padding-left: 16px; padding-right: 16px; }
  .att-go { grid-column: 2; }
}

/* средние ширины (узкий ноутбук, планшет): таблицы уплотняются, заголовки и кнопки переносятся — колонки не уезжают за карточку */
@media (min-width: 801px) and (max-width: 1360px) {
  table.grid { font-size: 13px; }
  table.grid th { white-space: normal; vertical-align: bottom; }
  table.grid th, table.grid td, table.grid:has(th:nth-child(7)) th, table.grid:has(th:nth-child(7)) td { padding-left: 7px; padding-right: 7px; }
  table.grid th:first-child, table.grid td:first-child, table.grid:has(th:nth-child(7)) th:first-child, table.grid:has(th:nth-child(7)) td:first-child { padding-left: 14px; }
  table.grid th:last-child, table.grid td:last-child, table.grid:has(th:nth-child(7)) th:last-child, table.grid:has(th:nth-child(7)) td:last-child { padding-right: 14px; }
  table.grid td .btn-row { flex-wrap: wrap; min-width: 104px; }
  table.grid td .btn, table.grid td form.inline .btn, table.grid.jobs td .btn, table.grid.jobs td form.inline .btn { min-width: 0; padding-left: 8px; padding-right: 8px; }
  table.grid td:is(.actions-cell, [data-label="Действия"]) > a.btn { min-width: 0; }
  table.grid.jobs td .btn, table.grid.jobs td form.inline .btn { width: 92px; }
  table.grid td.actions-cell { min-width: 0; }
  table.grid .bar, table.grid .prog { min-width: 70px; }
}
@media (max-width: 719px), (max-width: 1099px) and (pointer: coarse) {
  .chatpick-field input.chatpick-input { min-height: 44px; }
  table.grid.jobs td .btn, table.grid.jobs td form.inline .btn { min-height: 44px; }
}

/* таблица, которая и после уплотнения шире своей карточки (класс .as-cards ставит app.js): строки показываются карточками, как на телефоне */
@media (min-width: 801px) {
  table.grid.as-cards, table.grid.as-cards tbody { display: block; width: 100%; }
  table.grid.as-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.grid.as-cards tbody { padding: 10px 10px 2px; }
  table.grid.as-cards tbody tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); align-items: start; margin: 0 0 10px; padding: 4px 0; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
  table.grid.as-cards tbody tr:hover td { background: transparent; }
  table.grid.as-cards.as-cards td { display: block; width: auto; min-width: 0; border: 0; padding: 6px 12px; text-align: left; white-space: normal; }
  table.grid.as-cards td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 2px; color: var(--muted); font-weight: 650; font-size: 12px; }
  table.grid.as-cards.as-cards td:is(.actions-cell, [data-label="Действия"], :not([data-label]):not([colspan])) { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid var(--u-line-2); padding-top: 10px; margin-top: 4px; }
  table.grid.as-cards td[data-label="Действия"]::before { content: none; }
  table.grid.as-cards td[colspan] { grid-column: 1 / -1; }
  table.grid.as-cards td.actions-cell.none { display: none; }
  table.grid.as-cards td > .btn, table.grid.as-cards td form.inline { margin: 0; }
}

/* подпись с галочкой, помеченная классом checks, — это строка, а не сетка списка */
label.checks { display: flex; align-items: center; gap: 9px; min-height: 28px; cursor: pointer; }
@media (min-width: 801px) { table.grid td.wide-cell { min-width: 170px; } }
@media (max-width: 800px) {
  /* форма, раскрытая внутри строки таблицы, занимает всю ширину карточки */
  table.grid td[data-label]:has(details[open]), table.grid td[data-label]:first-child:has(details[open]) { padding-left: 12px; padding-top: 26px; }
}
@media (max-width: 719px), (max-width: 1099px) and (pointer: coarse) { label.checks { min-height: 44px; } }

@media (max-width: 719px), (max-width: 1099px) and (pointer: coarse) {
  /* поле выбора чата той же высоты, что соседние поля; двухстрочные подписи галочек не слипаются */
  .chatpick-field { padding-top: 0; padding-bottom: 0; }
  .chatpick-field .chatpick-chip { margin: 4px 0; }
  .checks label { padding-top: 4px; padding-bottom: 4px; }
}

/* карточка аккаунта: название и бейдж «выбран» переносятся, а не обрезаются многоточием */
.acc-head { flex-wrap: wrap; }
.acc-head > .acc-id { flex: 1 1 9rem; min-width: 0; }
.acc-title, .acc-phone { white-space: normal; overflow: visible; overflow-wrap: anywhere; }
.acc-title .tag { white-space: nowrap; }

.logout-all { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--u-line-2); }

/* боты: правило об оплате (цифровое — только за Stars) */
.goods-alert ul { margin: 6px 0; padding-left: 20px; }
.plan-risk { display: none; }
.plan-risk.on { display: block; }
/* редакционная лента и кривые просмотров: чужие тексты переносятся и не распирают страницу на телефоне */
.feed-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.feed-item .panel-header h2 { overflow-wrap: anywhere; }
.feed-item form.feed-digest { display: flex; flex-wrap: wrap; gap: 8px; max-width: 100%; min-width: 0; }
.feed-item .feed-digest select { flex: 1 1 200px; width: auto; min-width: 0; max-width: 100%; }
.feed-item .btn-row { flex-wrap: wrap; max-width: 100%; }
td.curve-post { overflow-wrap: anywhere; }

/* ---------- ход долгих дел на кнопках (progress.js): заливка по проценту, а когда процента нет — бегущие полосы ---------- */
@property --p { syntax: "<percentage>"; inherits: false; initial-value: 0%; }
.btn.working { opacity: 1; cursor: progress; color: var(--ink); min-width: 190px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums;
  border-color: var(--blue); transform: none; box-shadow: none; transition: --p .9s linear;
  background: linear-gradient(90deg, color-mix(in srgb, var(--blue) 30%, var(--surface)) var(--p), var(--surface) var(--p)); }
.btn.working.unknown { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--blue) 22%, var(--surface)) 0 12px, var(--surface) 12px 24px);
  background-size: 34px 100%; animation: tg-stripes 1s linear infinite; }
@keyframes tg-stripes { to { background-position: 34px 0; } }
.btn.small.working { min-width: 170px; }
.jobprog { display: grid; gap: 5px; min-width: 150px; }
.jobline { font-size: 13px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.bar.indet { background-size: 23px 100%; animation: tg-stripes-bar 1s linear infinite; }
@keyframes tg-stripes-bar { to { background-position: 23px 0; } }
@media (prefers-reduced-motion: reduce) { .btn.working.unknown, .bar.indet { animation: none; } .btn.working { transition: none; } }
