/* Adresly admin — общий стиль. Классы описаны в README.md. Темы: light-dark() + color-scheme. */
:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --nav-w: 228px;
  --top-h: 48px;
  --radius: 7px;
  --radius-lg: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);

  /* светлая — тёплая бумага (22.11): фон бежевый, карточки светлее фона, текст тёмно-коричневый (к фону ≈ 13, не 17);
     подсветки статусов (*-soft) заметнее, чем в тёмной, цвет статуса на них ≥ 4,5 — tests/test_theme_tokens.py */
  --bg: light-dark(#f3eee6, #111214);
  --bg-nav: light-dark(#ece5d9, #0c0d0f);
  --surface: light-dark(#fbf8f3, #16171a);
  --surface-2: light-dark(#ebe4d8, #1d1e22);
  --surface-3: light-dark(#e2d9ca, #26272c);
  --nav-hover: light-dark(#e3dbcd, #191a1e);
  --nav-active: light-dark(#dcd2c1, #212227);
  --row-hover: light-dark(#f4eee5, #1a1b1f);
  --border: light-dark(#e0d7c8, #24252a);
  --border-strong: light-dark(#d3c8b6, #33353b);
  --text: light-dark(#2b261f, #e8e9ec);
  --text-2: light-dark(#5c5348, #a0a3ab);
  --text-3: light-dark(#665d51, #8a8e96);  /* подписи и «бледный» текст — контраст ≥ 4,5 на фоне и surface-2 */
  --accent: light-dark(#3d47a8, #8a93f0);  /* текст и ссылки: ≥ 4,5 и на --accent-soft */
  --accent-hover: light-dark(#323b92, #9aa2f3);
  --accent-fg: #ffffff;
  --accent-btn: light-dark(#5e6ad2, #5763cf);  /* фон основной кнопки: белый текст ≥ 4,5 в обеих темах */
  --accent-btn-hover: light-dark(#4e5ac4, #4f5bc4);
  --danger-btn: light-dark(#c53030, #c93a35);
  --accent-soft: light-dark(rgb(94 106 210 / .25), rgb(124 134 234 / .17));
  --danger: light-dark(#a3221e, #f0675f);
  --danger-soft: light-dark(rgb(222 70 60 / .24), rgb(240 103 95 / .15));
  --success: light-dark(#0d5c32, #3fcf80);
  --success-soft: light-dark(rgb(36 160 90 / .3), rgb(63 207 128 / .14));
  --warning: light-dark(#714400, #e9a53c);
  --warning-soft: light-dark(rgb(226 146 18 / .4), rgb(233 165 60 / .15));
  --toast-bg: light-dark(#29241e, #2a2b31);
  --shadow-color: light-dark(rgb(60 42 18 / .16), rgb(0 0 0 / .55));
  --overlay: light-dark(rgb(40 30 16 / .3), rgb(0 0 0 / .5));
  --focus: 0 0 0 3px light-dark(rgb(94 106 210 / .3), rgb(124 134 234 / .35));
  --shadow-sm: 0 1px 2px light-dark(rgb(60 42 18 / .07), rgb(0 0 0 / .3));
  --shadow-lg: 0 16px 40px -10px var(--shadow-color), 0 2px 8px -2px var(--shadow-color);
}
:root[data-theme="light"] { color-scheme: only light; }  /* only — Chrome на Android с тёмной системой не затемняет выбранную светлую сам */
:root[data-theme="dark"] { color-scheme: dark; }
.no-anim *, .no-anim *::before, .no-anim *::after { transition: none !important; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
/* без видимых полос прокрутки (доработка 19): всё внутри страницы листается без полосы — и то, что прокручивается
   по умолчанию браузера (textarea, dialog); собственная полоса страницы (корень) — как в браузере */
body * { scrollbar-width: none; }
body {
  margin: 0; min-height: 100vh;
  font: 13px/1.45 var(--font); color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
kbd {
  font: 500 11px/1 var(--font); padding: 3px 5px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-3);
}
code, .mono { font-family: var(--mono); font-size: 12px; }

/* ---------- раскладка ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--nav-w); z-index: 40;
  display: flex; flex-direction: column; padding: 10px 8px 12px;
  background: var(--bg-nav); border-right: 1px solid var(--border);
  overflow-y: auto; scrollbar-width: none;
}
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top-h); margin-left: var(--nav-w);
  display: flex; align-items: center; gap: 8px; padding: 0 16px 0 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}
.main { margin-left: var(--nav-w); padding: 20px 24px 64px; min-width: 0; }
body.bare .main { margin: 0; }
body.has-nav { position: relative; }
body.has-nav::before {  /* фон меню на всю высоту документа: меню не «обрывается» на длинных страницах */
  content: ""; position: absolute; inset: 0 auto 0 0; width: var(--nav-w); z-index: 0;
  background: var(--bg-nav); border-right: 1px solid var(--border);
}
.nav-backdrop { display: none; }

/* ---------- меню ---------- */
.brand {
  display: flex; align-items: center; gap: 8px; flex: none; height: 32px; padding: 0 8px; margin-bottom: 8px;
  color: var(--text); font-weight: 600; font-size: 14px; letter-spacing: -.01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 18px; height: 18px; border-radius: 5px;
  background: linear-gradient(135deg, var(--accent), #a26bf5); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .15);
}
.brand-sub { color: var(--text-3); font-weight: 500; font-size: 12px; }
/* Группа: линия сверху, заголовок — иконка, ПРОПИСНЫЕ жирные с разрядкой, шеврон справа; пункты — обычным шрифтом,
   текст под текстом заголовка (8 + 16 + 8 = 32 px). Высоты: 25 пунктов × 25 + 6 × (28 + 5) = 823 px из 838 —
   всё меню «Владельца» влезает в 1440 × 900 без прокрутки (на телефоне пункты 34 px, меню листается). */
.nav { display: flex; flex-direction: column; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 8px; flex: none; height: 25px; padding: 0 8px; border-radius: 6px;
  color: var(--text-2); font-weight: 450; white-space: nowrap;
  transition: background-color .12s, color .12s;
}
.nav-item:hover { background: var(--nav-hover); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--nav-active); color: var(--text); font-weight: 500; }
.nav-group-items .nav-item { padding-left: 32px; }
.nav-top:last-child { margin-top: auto; }
.nav .nav-ico { width: 16px; height: 16px; vertical-align: 0; transition: color .12s; }
.nav-item.is-active .nav-ico, .nav-group:has(.is-active) .nav-group-head .nav-ico { color: var(--accent); }
.nav-group { margin-top: 2px; padding-top: 2px; border-top: 1px solid var(--border); }
.nav-group-head {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 28px; padding: 0 6px 0 8px;
  border: 0; border-radius: 6px; background: none; cursor: pointer;
  font: 600 11px/1 var(--font); color: var(--text-2); letter-spacing: .06em; text-transform: uppercase; text-align: left;
  transition: background-color .12s, color .12s;
}
.nav-group-head:hover { background: var(--nav-hover); color: var(--text); }
.nav-group-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-group-head .nav-count { letter-spacing: 0; }
.nav-group-head .chev { width: 14px; height: 14px; color: var(--text-3); transition: transform .16s var(--ease); }
.nav-group.is-collapsed .chev { transform: rotate(-90deg); }
.nav-group-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .18s var(--ease); }
.nav-group-items > div { overflow: hidden; min-height: 0; }
.nav-group.is-collapsed .nav-group-items { grid-template-rows: 0fr; }
.nav-group.is-collapsed .nav-group-items > div { visibility: hidden; transition: visibility 0s .18s; }
.nav-count {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--text-2); font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.nav-count:empty:not(.is-dot) { display: none; }
.nav-count.is-dot { min-width: 7px; width: 7px; height: 7px; padding: 0; background: var(--danger); }

/* ---------- шапка ---------- */
.search-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; min-width: 240px; padding: 0 6px 0 10px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm);
  font: inherit; color: var(--text-3); cursor: pointer; transition: border-color .12s, color .12s;
}
.search-btn:hover { border-color: var(--border-strong); color: var(--text-2); }
.search-btn kbd { margin-left: auto; }
.focus-slot:empty { display: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar-right form { margin: 0; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: var(--radius); background: none; color: var(--text-2); cursor: pointer;
  transition: background-color .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .fill { fill: currentColor; stroke: none; }
.i-light, .i-dark, [data-theme="light"] .i-auto, [data-theme="dark"] .i-auto { display: none; }
[data-theme="light"] .i-light, [data-theme="dark"] .i-dark { display: block; }
.menu-btn { display: none; }
.who { display: inline-flex; align-items: center; gap: 8px; padding: 0 4px; color: var(--text-2); }
.avatar {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600;
}

/* ---------- заголовок страницы ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.crumbs { color: var(--text-3); font-size: 12px; margin-bottom: 2px; }
.page-title { display: flex; align-items: baseline; gap: 8px; font-size: 18px; font-weight: 600; letter-spacing: -.015em; }
.count { color: var(--text-3); font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.section-title { font-size: 13px; font-weight: 600; margin: 20px 0 8px; }

/* ---------- кнопки ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text);
  font: 500 13px/1 var(--font); white-space: nowrap; cursor: pointer; user-select: none;
  transition: background-color .12s, border-color .12s, box-shadow .12s, color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--accent-btn); border-color: transparent; color: var(--accent-fg); --spin: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-btn-hover); }
.btn-danger { background: var(--danger-btn); border-color: transparent; color: #fff; --spin: #fff; }
.btn-danger:hover { background: color-mix(in srgb, var(--danger-btn) 88%, #000); }
.btn-ghost { background: none; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12.5px; }
/* ожидание: htmx (класс htmx-request) или обычная форма (aria-busy от app.js) */
.btn.htmx-request, .htmx-request .btn[type="submit"], .btn[aria-busy="true"] { color: transparent !important; pointer-events: none; }
.btn.htmx-request::after, .htmx-request .btn[type="submit"]::after, .btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--spin, var(--text-2)); border-right-color: transparent; animation: spin .6s linear infinite;
}

/* ---------- формы ---------- */
.field { display: grid; gap: 5px; margin-bottom: 12px; }
.field > label, .label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.input, .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  width: 100%; height: 30px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.field textarea, textarea.input { height: auto; min-height: 76px; padding: 7px 10px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--text-3); }
.field.has-error input, .field.has-error select, .field.has-error textarea, .input.has-error { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12px; }
.hint { color: var(--text-3); font-size: 12px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 14px; height: 14px; margin: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- таблицы ---------- */
.table-wrap { overflow-x: auto; scrollbar-width: none; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-variant-numeric: tabular-nums; }
.table th {
  height: 32px; padding: 0 12px; text-align: left; white-space: nowrap; user-select: none;
  font-size: 12px; font-weight: 500; color: var(--text-3); border-bottom: 1px solid var(--border);
}
.table th a, .table th button { all: unset; display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.table th :is(a, button):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.table th a:hover, .table th button:hover, .table th[aria-sort] { color: var(--text); }
.table td { height: 34px; padding: 0 12px; white-space: nowrap; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color .08s; }
.table tbody tr:hover { background: var(--row-hover); }
.table tbody tr[data-href], .table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr.is-selected { background: var(--accent-soft); }
.table .num { text-align: right; }
.table .col-check { width: 36px; padding-right: 0; }
.truncate { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
/* компьютер: таблица влезает по ширине — длинный текст (.truncate, .wrap) переносится в пределах колонки, а не
   уводит таблицу вбок; даты, числа, метки — строкой. Телефон — строкой, таблица листается свайпом (доработка 19).
   Переносится между словами: anywhere сжимал колонку уже слова — слова рвались по буквам (доработка 24); по любому
   месту — только длинные токены без пробелов: .mono (ключи, домены «Откуда запросы») и .tok (домены ключа, имена файлов) */
@media (min-width: 861px) {
  .table td:is(.truncate, .wrap) { min-width: 7em; padding-top: 3px; padding-bottom: 3px; white-space: normal; overflow-wrap: break-word; }
  .table td:is(.truncate, .wrap):is(.mono, .tok) { overflow-wrap: anywhere; }
}
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 2px; color: var(--text-2); font-size: 12.5px; }
.pager { display: flex; gap: 2px; }
.pager > * {
  display: inline-flex; align-items: center; justify-content: center; min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: 6px; color: var(--text-2); font-variant-numeric: tabular-nums;
}
.pager a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.pager .is-current { background: var(--surface-3); color: var(--text); font-weight: 500; }
.bulkbar {
  position: fixed; left: 50%; bottom: 20px; z-index: 45; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 6px 6px 6px 14px; border-radius: var(--radius-lg);
  background: var(--toast-bg); color: #f2f2f4; box-shadow: var(--shadow-lg); animation: rise-x .18s var(--ease);
}
.bulkbar .btn-ghost { color: #d9dae0; }
.bulkbar .btn-ghost:hover { background: rgb(255 255 255 / .1); color: #fff; }

/* ---------- бейджи, чипы, вкладки, полоска ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px; border-radius: 10px;
  background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2);
  font: 500 12.5px/1 var(--font); cursor: pointer; white-space: nowrap; transition: background-color .12s, color .12s, border-color .12s;
}
.chip:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.chip.is-active { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip-x { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: -5px; border-radius: 50%; }
.chip-x:hover { background: var(--accent-soft); }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); overflow: auto hidden; scrollbar-width: none; }
.tabs a { padding: 8px 10px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.is-active { color: var(--text); border-bottom-color: var(--text); }
.meter { min-width: 60px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); transition: width .3s var(--ease); }
.meter.is-warning > span { background: var(--warning); }
.meter.is-danger > span { background: var(--danger); }

/* ---------- карточки, поля записи ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 40px; padding: 0 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.card-body { padding: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.kv { display: grid; grid-template-columns: minmax(110px, 34%) 1fr; gap: 7px 12px; margin: 0; }
.kv dt { min-width: 0; color: var(--text-3); overflow-wrap: anywhere; }  /* длинный ключ (snapshot_started_at) переносится, не налезает на значение */
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- панель справа ---------- */
.panel {
  position: fixed; inset: 0 0 0 auto; z-index: 50; width: min(560px, 100vw);
  display: flex; flex-direction: column; background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  transform: translateX(100%); visibility: hidden;
  transition: transform .2s var(--ease), visibility 0s .2s;
}
.panel.is-open { transform: none; visibility: visible; transition: transform .2s var(--ease); }
.panel-head { display: flex; align-items: center; gap: 8px; height: var(--top-h); padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.panel-head .icon-btn { margin-left: auto; }
.panel-body { flex: 1; overflow-y: auto; scrollbar-width: none; padding: 16px; }
.panel-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

/* ---------- уведомления ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; min-width: 220px; max-width: 380px; padding: 10px 14px;
  border-radius: var(--radius-lg); background: var(--toast-bg); color: #f2f2f4; box-shadow: var(--shadow-lg);
  pointer-events: auto; animation: rise .18s var(--ease);
}
.toast::before { content: ""; width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; flex: none; background: #8c8f96; }
.toast-success::before { background: #3fcf80; }
.toast-error::before { background: #f0675f; }
.toast.is-leaving { animation: fade-out .15s ease-in forwards; }

/* ---------- пусто, загрузка, ошибка ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 56px 16px; border: 1px dashed var(--border-strong); border-radius: 12px; color: var(--text-2);
}
.empty-icon { width: 30px; height: 30px; color: var(--text-3); stroke-width: 1.3; }
.empty-title { margin-top: 12px; color: var(--text); font-size: 14px; font-weight: 600; }
.empty-text { margin-top: 4px; max-width: 380px; color: var(--text-3); }
.empty .btn { margin-top: 16px; }
.spinner { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent); animation: spin .6s linear infinite; }
.skeleton {
  height: 12px; border-radius: 4px; animation: shimmer 1.3s ease infinite;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 40%, var(--surface-2) 60%) 0 0 / 400% 100%;
}
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; margin-bottom: 12px; border-radius: 8px; background: var(--surface-2); color: var(--text); }
.alert::before { content: ""; width: 7px; height: 7px; margin-top: 6px; border-radius: 50%; flex: none; background: var(--text-3); }
.alert-info { background: var(--accent-soft); } .alert-info::before { background: var(--accent); }
.alert-success { background: var(--success-soft); } .alert-success::before { background: var(--success); }
.alert-warning { background: var(--warning-soft); } .alert-warning::before { background: var(--warning); }
.alert-danger { background: var(--danger-soft); } .alert-danger::before { background: var(--danger); }
.error-page { max-width: 460px; margin: 10vh auto 0; padding: 0 16px; text-align: center; }
/* вход в админку (ADR-131, templates/login.html): карточка по центру; на телефоне поля 16 px — iOS не увеличивает страницу */
.login { max-width: 380px; margin: 10vh auto 0; }
.login-title { margin-bottom: 16px; }
.login-hint { margin-top: 10px; text-align: center; }
/* специфичность не ниже .field input:not(…):not(…) (0,3,1) с font: inherit — иначе 16 px не применяется */
@media (max-width: 860px) { .login .field input.input { height: 38px; font-size: 16px; } }
.error-code {
  font-size: 64px; font-weight: 700; line-height: 1; letter-spacing: -.05em;
  background: linear-gradient(135deg, var(--accent), #a26bf5); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.error-title { margin: 14px 0 6px; font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.error-actions { margin-top: 20px; }

/* ---------- списки (app/listing.py, templates/_list.html) ---------- */
.list { scroll-margin-top: calc(var(--top-h) + 20px); }
.list .page-head { margin-bottom: 12px; }
.list-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn-sm svg { width: 14px; height: 14px; }
.btn.is-active { color: var(--accent); }
.list .table-wrap { transition: opacity .12s; }
.list.htmx-request .table-wrap { opacity: .55; transition-delay: .15s; }
.list-search { position: relative; display: flex; align-items: center; margin: 0; }
.list-search > svg { position: absolute; left: 9px; width: 14px; height: 14px; color: var(--text-3); pointer-events: none; }
.list-search .input { width: 260px; height: 26px; padding: 0 30px 0 29px; }
.list-search kbd { position: absolute; right: 6px; pointer-events: none; }
.list-search .input:focus + kbd, .list-search .input:not(:placeholder-shown) + kbd { display: none; }
.chip .chev { width: 12px; height: 12px; margin-right: -3px; color: var(--text-3); }
.chip-val { color: var(--text); font-weight: 600; }
.chip.is-active .chip-val { color: inherit; }
.chip-x svg { width: 12px; height: 12px; }
.chip-focus { margin-left: auto; cursor: default; }
.chip-focus .chip-x { padding: 0; border: 0; background: none; color: inherit; cursor: pointer; }
.table td a { color: inherit; }
.table td a:hover { color: var(--accent); }
.table tbody tr.is-active { background: var(--row-hover); box-shadow: inset 2px 0 0 var(--accent); }
.table tbody tr.is-selected.is-active { background: var(--accent-soft); }
.meter-cell { display: inline-flex; align-items: center; gap: 8px; }
.meter-cell .meter { width: 64px; }
.meter-cell > span:last-child { min-width: 34px; color: var(--text-2); text-align: right; }
.pager .gap { color: var(--text-3); }
.pager svg { width: 14px; height: 14px; }
.pager-sizes { margin-right: 8px; }
.bulkbar[hidden] { display: none; }
.bulk-count { margin-right: 6px; color: #c9cad0; }
.bulk-count b { color: #fff; font-weight: 600; }
.bulkbar .icon-btn { color: #c9cad0; }
.bulkbar .icon-btn:hover { background: rgb(255 255 255 / .1); color: #fff; }

/* меню-попап на <details>: колонки, виды, фильтры */
.menu { position: relative; display: inline-flex; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] > summary.btn, .menu[open] > summary.chip:not(.is-active) { background: var(--surface-2); color: var(--text); }
.menu-pop {
  position: absolute; z-index: 35; top: calc(100% + 4px); left: 0; min-width: 210px; max-width: min(340px, 90vw);
  max-height: min(420px, 70vh); overflow-y: auto; padding: 4px; scrollbar-width: none;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-lg);
  animation: pop .12s var(--ease);
}
.menu-pop.is-right { left: auto; right: 0; }
.menu-label { padding: 6px 8px 4px; color: var(--text-3); font-size: 11.5px; font-weight: 500; }
.menu-row { display: flex; align-items: center; gap: 2px; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 28px; padding: 0 8px;
  border: 0; border-radius: 5px; background: none; color: var(--text); font: inherit; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); text-decoration: none; }
.menu-item:disabled { color: var(--text-3); background: none; cursor: default; }
.menu-item.is-active { color: var(--accent); font-weight: 550; }
.menu-sep { height: 1px; margin: 4px -4px; background: var(--border); }
.menu-empty { max-width: 250px; padding: 4px 8px 8px; color: var(--text-3); white-space: normal; }
.menu-form { display: flex; align-items: center; gap: 6px; margin: 0; padding: 4px; }
.menu-form .input { flex: 1; min-width: 0; height: 26px; }
.menu-period .input { flex: none; width: 128px; padding: 0 6px; }
.menu-views { min-width: 270px; }
.icon-sm { width: 24px; height: 24px; }
.icon-sm svg { width: 14px; height: 14px; }
.icon-btn:disabled { opacity: .3; pointer-events: none; }
.box {
  display: inline-grid; place-items: center; flex: none; width: 14px; height: 14px;
  border: 1px solid var(--border-strong); border-radius: 4px; transition: background-color .12s, border-color .12s;
}
.box svg { width: 11px; height: 11px; stroke-width: 2.2; opacity: 0; }
.box.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.box.is-on svg { opacity: 1; }

/* панель записи: «было → стало», история, данные */
.panel-title { min-width: 0; }
.panel-body > .kv + .section-title { margin-top: 22px; }
.diff { display: grid; grid-template-columns: minmax(80px, max-content) 1fr; gap: 6px 14px; margin: 0; }
.diff dt { color: var(--text-3); font: 12px/20px var(--mono); }
.diff dd { margin: 0; min-width: 0; line-height: 20px; overflow-wrap: anywhere; }
del, ins { padding: 1px 4px; border-radius: 4px; }
del { background: var(--danger-soft); color: var(--danger); text-decoration: line-through; text-decoration-thickness: 1px; }
ins { background: var(--success-soft); color: var(--success); text-decoration: none; }
.diff-arrow { margin: 0 4px; color: var(--text-3); }
/* иконки-стрелки набора (macros icon): размер по строке, цвет — текущий, вес линии как у остальных значков */
.ico { width: 1.15em; height: 1.15em; vertical-align: -.2em; }
.ico-mid { margin: 0 .3em; color: var(--text-3); }
.table th .ico { width: 12px; height: 12px; vertical-align: 0; }
kbd .ico { width: 10px; height: 10px; vertical-align: -1px; }
.ov-all .ico, .card-link .ico, .src-all .ico, .all-link .ico, .tile-go .ico, .mp-check .ico { width: 14px; height: 14px; margin-right: -3px; vertical-align: 0; }
.tile-go { display: inline-flex; vertical-align: middle; }
.forum-back .ico { width: 14px; height: 14px; margin-left: -4px; vertical-align: 0; }
.drill-sep .ico { width: 12px; height: 12px; vertical-align: -1px; }
.history { display: grid; gap: 14px; margin: 0; padding: 0; list-style: none; }
.history li { display: grid; gap: 6px; padding-left: 12px; border-left: 2px solid var(--border); }
.history-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.raw { margin-top: 18px; }
.raw summary { color: var(--text-2); font-weight: 500; cursor: pointer; }
pre.code {
  max-height: 360px; margin: 8px 0 0; padding: 10px 12px; overflow: auto; scrollbar-width: none; border-radius: 8px;
  background: var(--surface-2); font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}

/* ---------- утилиты ---------- */
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; align-items: center; gap: 8px; }
.stack { display: grid; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes rise-x { from { opacity: 0; transform: translate(-50%, 6px); } }
@keyframes fade-out { to { opacity: 0; transform: translateY(4px); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- узкий экран: меню в кнопку, таблицы прокручиваются ---------- */
@media (max-width: 860px) {
  body.has-nav::before { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s var(--ease); box-shadow: none; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: var(--overlay); }
  .topbar { margin-left: 0; padding: 0 12px; }
  .main { margin-left: 0; padding: 16px 16px 48px; }
  .menu-btn { display: inline-grid; }
  .nav-item { height: 34px; }
  .nav-group-head { height: 36px; font-size: 11.5px; }
  .search-btn { min-width: 0; width: 30px; padding: 0; justify-content: center; border-color: transparent; box-shadow: none; background: none; }
  .search-btn span, .search-btn kbd, .who-name { display: none; }
  .page-head > div:first-child { flex: 1 1 100%; }
  .list-search { flex: 1 1 100%; }
  .list-search .input { width: 100%; }
  .chip-focus { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ==== money ==== */
/* Платежи: плашка тревог оплаты над списком */
.pay-alerts { margin-bottom: 16px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--danger) 28%, var(--border)); border-radius: var(--radius-lg); background: var(--surface); }
.pay-alerts-head { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; background: var(--danger-soft); color: var(--danger); font-size: 12.5px; font-weight: 600; }
.pay-alerts-head .count { color: inherit; opacity: .75; font-size: 12px; }
.pay-alert { display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-top: 1px solid var(--border); }
.pay-alert-text { line-height: 1.45; }
.pay-alert .faint { margin-top: 1px; font-size: 12px; }
.pay-alert .btn { flex: none; }
.pay-panel-alerts { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.pay-panel-alerts li { display: flex; align-items: baseline; gap: 9px; line-height: 1.45; }
.pay-panel-alerts .dot { color: var(--text-3); transform: translateY(-1px); }
.pay-panel-alerts .dot.is-open { color: var(--danger); }
/* Баланс: сумма со знаком и цветом, подтверждение поправки */
.amount-plus { color: var(--success); }
.amount-minus { color: var(--danger); }
.adjust-confirm { display: grid; gap: 3px; margin-top: 4px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.adjust-sum { font-size: 22px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
/* Формы денег и тарифов */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.money-form .form-actions { margin-top: 8px; }
.money-more { margin: 0 0 12px; }
.money-more > summary { margin-bottom: 10px; color: var(--text-2); font-size: 12.5px; font-weight: 500; cursor: pointer; }
.money-checks { display: grid; gap: 8px; margin: 0 0 14px; }
.readonly-value { display: flex; align-items: center; height: 30px; padding: 0 10px; border-radius: var(--radius); background: var(--surface-2); color: var(--text-2); }
.mode-choice { min-width: 0; margin: 0 0 12px; padding: 0; border: 0; }
.mode-choice > legend { margin-bottom: 5px; padding: 0; }
.mode-option { display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; transition: border-color .12s, background-color .12s; }
.mode-option + .mode-option { margin-top: 6px; }
.mode-option:hover { background: var(--row-hover); }
.mode-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.mode-option input { margin-top: 2px; }
.mode-option b { display: block; font-weight: 550; }
.mode-option .hint { display: block; margin-top: 1px; }
.mode-choice.has-error .mode-option:not(:has(input:checked)) { border-color: var(--danger); }
.plan-meta { margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.plan-copies { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.plan-copies li { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 8px; border-radius: var(--radius); }
.plan-copies li:hover { background: var(--row-hover); }
@media (max-width: 860px) {
  .form-grid { grid-template-columns: 1fr; }
  .pay-alert { flex-wrap: wrap; }
}

/* ==== shell ==== */
/* чип фокуса в шапке (#focus-chip) */
.focus-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px;
  background: var(--accent-soft); color: var(--accent); font: 500 12.5px/1 var(--font); white-space: nowrap; max-width: 280px;
}
.focus-chip-label { opacity: .75; }
.focus-chip a { color: inherit; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.focus-chip .chip-x { padding: 0; border: 0; background: none; color: inherit; cursor: pointer; }

/* палитра ⌘K (templates/base.html, _search.html) */
.cmdk {
  width: min(640px, calc(100vw - 32px)); max-width: none; max-height: none; margin: 12vh auto 0; padding: 0;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg), 0 0 0 1px light-dark(transparent, rgb(255 255 255 / .03));
}
.cmdk[open] { animation: pop .12s var(--ease); }
.cmdk::backdrop { background: var(--overlay); }
.cmdk-box { display: flex; flex-direction: column; max-height: min(560px, 76vh); }
.cmdk-head { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 14px; border-bottom: 1px solid var(--border); color: var(--text-3); }
.cmdk-input { flex: 1; min-width: 0; height: 100%; border: 0; background: none; color: var(--text); font: 15px var(--font); outline: none; }
.cmdk-input::placeholder { color: var(--text-3); }
.cmdk-list { flex: 1; overflow-y: auto; padding: 6px; scrollbar-width: none; overscroll-behavior: contain; }
.cmdk-list:empty { display: none; }
.cmdk-group + .cmdk-group { margin-top: 4px; }
.cmdk-label { padding: 8px 10px 4px; color: var(--text-3); font-size: 11.5px; font-weight: 500; }
.cmdk-row { position: relative; }
.cmdk-item {
  display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: 7px;
  color: var(--text); white-space: nowrap; scroll-margin: 6px;
}
.cmdk-item:hover { text-decoration: none; }
.cmdk-item[aria-selected="true"] { background: var(--surface-2); }
.cmdk-item[data-focus] { padding-right: 74px; }
.cmdk-icon { color: var(--text-3); }
.cmdk-item[aria-selected="true"] .cmdk-icon { color: var(--text-2); }
.cmdk-title { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.cmdk-sub { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--text-3); }
.cmdk-kind { margin-left: auto; color: var(--text-3); font-size: 12px; }
.cmdk-act {
  position: absolute; top: 50%; right: 8px; transform: translateY(-50%); display: none;
  height: 22px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 5px;
  background: var(--surface); color: var(--text-2); font: 500 11.5px/1 var(--font); cursor: pointer;
}
.cmdk-act:hover { color: var(--accent); border-color: var(--accent); }
.cmdk-row:hover .cmdk-act, .cmdk-item[aria-selected="true"] + .cmdk-act { display: inline-flex; align-items: center; }
.cmdk-empty { padding: 26px 16px; color: var(--text-3); text-align: center; line-height: 1.6; }
.cmdk-foot {
  display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--border);
  color: var(--text-3); font-size: 11.5px; white-space: nowrap; overflow: hidden;
}
.cmdk-foot kbd { margin-right: 3px; padding: 2px 4px; font-size: 10.5px; }
.cmdk-head kbd { font-size: 10.5px; }

/* подтверждение hx-confirm (base.html #confirm, static/app.js) */
.confirm {
  width: min(420px, calc(100vw - 32px)); margin: 18vh auto 0; padding: 0;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.confirm[open] { animation: pop .12s var(--ease); }
.confirm::backdrop { background: var(--overlay); }
.confirm form { margin: 0; padding: 18px 18px 14px; }  /* форма — на всё окно: клик по полям окна не закрывает его */
.confirm-text { font-size: 14px; line-height: 1.5; white-space: pre-line; }
.confirm .form-actions { margin-top: 18px; }

/* подменю раздела (subnav в контексте страницы) */
.subnav { margin: -4px 0 16px; }

/* Операторы и роли: «Дать доступ», матрица прав, особые права */
.form-narrow { max-width: 520px; }
.menu-error { padding: 0 8px 6px; white-space: normal; max-width: 300px; }
.matrix th, .matrix td { height: 32px; }
.matrix th[scope="row"] { font-size: 13px; font-weight: 450; color: var(--text); }
.matrix th[scope="row"] .check { gap: 10px; }
.matrix .matrix-col, .matrix .matrix-cell { width: 120px; text-align: center; }
.matrix-col .check { justify-content: center; gap: 6px; }
.matrix-group th {
  height: 28px; padding-top: 8px; background: var(--surface-2); color: var(--text-3);
  font-size: 11.5px; font-weight: 500; letter-spacing: .01em;
}
.matrix tbody tr:hover { background: var(--row-hover); }
.matrix tbody tr.matrix-group:hover { background: var(--surface-2); }
.matrix input:disabled { cursor: default; }
.matrix [data-row-all] { opacity: .4; transition: opacity .12s; }
.matrix tr:hover [data-row-all], .matrix [data-row-all]:checked, .matrix [data-row-all]:focus-visible { opacity: 1; }
.perm-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(340px, 100%), 1fr)); gap: 8px; }
.perm {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  transition: border-color .12s, background-color .12s;
}
.perm:hover { border-color: var(--border-strong); }
.perm:has(input:checked) { border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }
.perm:has(input:disabled) { cursor: default; }
.perm input { margin-top: 2px; }
.perm-text { display: grid; gap: 2px; }
.perm-title { font-weight: 500; }
.form-sticky {
  position: sticky; bottom: 0; z-index: 5; margin: 16px -24px 0; padding: 12px 24px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--border);
}
@media (max-width: 860px) {
  .cmdk { margin-top: 8px; width: calc(100vw - 16px); }
  .cmdk-foot { display: none; }
  .cmdk-sub { display: none; }
  .focus-chip { max-width: 150px; }
  .focus-chip-label { display: none; }
  .form-sticky { margin: 16px -16px 0; padding: 12px 16px; }
}

/* ==== clients ==== */
/* Клиенты, карточка клиента, Ключи API, Виджеты (app/sections/clients.py, keys.py, widgets.py) */
:root {
  /* категориальная палитра графиков (dataviz, порядок фиксирован): подсказки, геокодер, карты, маршруты, организации, ФИО */
  --viz-1: light-dark(#2a78d6, #3987e5);
  --viz-2: light-dark(#eb6834, #d95926);
  --viz-3: light-dark(#1baf7a, #199e70);
  --viz-4: light-dark(#eda100, #c98500);
  --viz-5: light-dark(#e87ba4, #d55181);
  --viz-6: light-dark(#008300, #008300);
}
.warn { color: var(--warning); }
.pos { color: var(--success); }
.table td.strong a { font-weight: 550; }
.menu-pop.is-up { top: auto; bottom: calc(100% + 6px); }
.menu-item.is-danger { color: var(--danger); }

/* тариф в строке списка: выбор без рамки, рамка — при наведении */
.plan-cell { margin: 0; }
.plan-pick { display: inline-flex; }
.plan-pick select {
  appearance: none; height: 24px; margin-left: -8px; padding: 0 22px 0 7px; border: 1px solid transparent; border-radius: 6px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M5 6.5l3 3 3-3' fill='none' stroke='%238c8f96' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 4px center / 14px;
  color: inherit; font: inherit; cursor: pointer; transition: border-color .12s, background-color .12s;
}
.plan-pick select:hover { border-color: var(--border-strong); background-color: var(--surface); }
.plan-pick select:focus-visible { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.plan-pick.is-expired select { color: var(--text-3); }

/* карточка: липкая шапка */
.client-head {
  position: sticky; top: var(--top-h); z-index: 15; margin: -20px -24px 14px; padding: 14px 24px 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: saturate(1.6) blur(10px);
  border-bottom: 1px solid var(--border);
}
.client-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.client-id { min-width: 0; }
.client-id .crumbs a { color: var(--text-3); }
.client-id .page-title { align-items: center; flex-wrap: wrap; }
.client-sub { display: flex; flex-wrap: wrap; gap: 4px 0; margin-top: 2px; color: var(--text-2); }
.client-sub > span + span::before { content: "·"; margin: 0 7px; color: var(--text-3); }
.client-actions { display: flex; align-items: center; gap: 6px; }
.client-actions form { margin: 0; }
.client-actions .btn svg { width: 14px; height: 14px; }
.facts { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 12px 0 0; }
.facts > div { min-width: 0; }
.facts dt { color: var(--text-3); font-size: 11.5px; margin-bottom: 2px; }
.facts dd { display: flex; align-items: center; gap: 8px; margin: 0; white-space: nowrap; font-weight: 500; }
.facts .meter { width: 96px; }

/* сигналы */
.signals { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; }
.signal {
  display: inline-flex; align-items: center; gap: 7px; min-height: 26px; padding: 3px 11px; border-radius: 13px;
  background: var(--surface-2); color: var(--text); font-size: 12.5px; font-weight: 500;
}
.signal .dot { width: 6px; height: 6px; }
.signal-danger { background: var(--danger-soft); color: var(--danger); }
.signal-warning { background: var(--warning-soft); color: var(--warning); }
.signal-accent { background: var(--accent-soft); color: var(--accent); }

/* блоки */
.client-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.client-col { display: grid; gap: 12px; min-width: 0; }
.cblock { min-width: 0; overflow: hidden; }
.cblock .card-head { height: 38px; font-weight: 400; }
.card-title { font-size: 13px; font-weight: 600; }
.cblock .card-head .count { font-size: 12px; }
.card-meta { flex: 1; min-width: 0; color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cblock .card-body.muted, .cblock > .card-body .muted:only-child { color: var(--text-3); }
/* «все →» в шапке блока: карточка клиента (форма фокуса), «Обзор», отчёты — одна кнопка-ссылка */
.all-link { margin: 0; }
.all-link button, .card-link, .ov-all {
  flex: none; display: inline-flex; align-items: center; height: 24px; margin-left: auto; padding: 0 6px;
  border: 0; border-radius: 5px; background: none; cursor: pointer;
  color: var(--text-3); font: 500 12px var(--font); white-space: nowrap;
}
.all-link button:hover, .card-link:hover, .ov-all:hover { background: var(--surface-2); color: var(--accent); text-decoration: none; }
.sub-head { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px; border-top: 1px solid var(--border); }
.card-head + .sub-head { border-top: 0; }
.sub-head h3 { font-size: 12px; font-weight: 600; color: var(--text-2); }
.sub-head + .card-body { padding-top: 4px; }
.ctable-wrap { overflow-x: auto; scrollbar-width: none; }
.ctable th { height: 28px; font-size: 11.5px; }
.ctable td { height: 32px; }
.ctable th:first-child, .ctable td:first-child { padding-left: 14px; }
.ctable th:last-child, .ctable td:last-child { padding-right: 14px; }
.ctable .truncate { max-width: 200px; }
.ctable tr[data-revoked] td { color: var(--text-3); }
.sub-head + .ctable-wrap .ctable tr:first-child td { border-top: 1px solid var(--border); }
/* кнопки строки: колонка действий движка (Col kind="actions") и строки блоков карточки */
.table .col-actions { width: 1%; text-align: right; }
.row-actions { display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; }
td.row-actions { display: table-cell; text-align: right; white-space: nowrap; }
td.row-actions .btn + .btn { margin-left: 4px; }
.row-actions .btn { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.ops { margin: 0; padding: 0; list-style: none; }
.ops li { display: flex; align-items: center; gap: 10px; min-height: 34px; padding: 4px 14px; border-top: 1px solid var(--border); }
.card-head + .ops li:first-child { border-top: 0; }
.ops li > .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ops .num { font-weight: 500; }
.ops .faint { white-space: nowrap; font-size: 12px; }
.feed { display: grid; gap: 12px; margin: 0; padding: 12px 14px 14px; list-style: none; }
.feed li { position: relative; display: grid; gap: 4px; padding-left: 16px; }
.feed li::before { content: ""; position: absolute; left: 1px; top: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.feed li:first-child::before { background: var(--accent); }
.feed li:not(:last-child)::after { content: ""; position: absolute; left: 4px; top: 17px; bottom: -11px; width: 1px; background: var(--border); }
.feed-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.feed-head b { font-weight: 550; }
.feed-head .faint { font-size: 12px; }
.feed .diff { font-size: 12px; }

/* график расхода (серверный SVG) */
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-bottom: 8px; color: var(--text-2); font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; }
.chart-legend .lim { width: 12px; height: 0; border-radius: 0; border-top: 1.5px dashed var(--danger); }
.usage-chart { display: block; width: 100%; height: auto; overflow: visible; }
.usage-chart path, .usage-chart text { stroke: none; }
.usage-chart .gl { stroke: var(--border); stroke-width: 1; }
.usage-chart .limit { stroke: var(--danger); stroke-width: 1; stroke-dasharray: 4 3; }
.usage-chart .axis { fill: var(--text-3); font: 10px var(--font); font-variant-numeric: tabular-nums; }
.usage-chart .hit { fill: transparent; }
.usage-chart .day:hover .hit { fill: var(--surface-2); }
.usage-chart .viz-1, .chart-legend .viz-1 { fill: var(--viz-1); background: var(--viz-1); }
.usage-chart .viz-2, .chart-legend .viz-2 { fill: var(--viz-2); background: var(--viz-2); }
.usage-chart .viz-3, .chart-legend .viz-3 { fill: var(--viz-3); background: var(--viz-3); }
.usage-chart .viz-4, .chart-legend .viz-4 { fill: var(--viz-4); background: var(--viz-4); }
.usage-chart .viz-5, .chart-legend .viz-5 { fill: var(--viz-5); background: var(--viz-5); }
.usage-chart .viz-6, .chart-legend .viz-6 { fill: var(--viz-6); background: var(--viz-6); }

/* панели: формы, секрет один раз */
.panel-sub { margin: -2px 0 14px; color: var(--text-2); }
.panel-sub b { color: var(--text); font-weight: 550; }
.secret {
  display: flex; align-items: center; gap: 8px; margin: 6px 0 8px; padding: 6px 6px 6px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2);
}
.secret-value { flex: 1; min-width: 0; overflow-wrap: anywhere; user-select: all; font-size: 12.5px; }
.choice { display: flex; align-items: flex-start; gap: 10px; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: border-color .12s, background-color .12s; }
.choice + .choice { margin-top: 6px; }
.choice:hover { border-color: var(--border-strong); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { margin-top: 2px; }
.choice > span { display: grid; gap: 2px; }
.choice b { font-weight: 550; }
.form-note { margin-top: 12px; }
.kv-tight { margin-bottom: 14px; }
.inline-form { margin: 0; }
.panel-links { margin: 18px 0 0; }
#key-plain .secret-value { padding: 2px 6px; border-radius: 4px; background: var(--surface-2); }

@media (max-width: 1180px) {
  .client-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .client-head { position: static; margin: -16px -16px 12px; padding: 12px 16px; }
  .facts { gap: 8px 18px; }
}
/* clients: поправки после просмотра */
.usage-chart rect { stroke: none; }
.field > label.choice { color: var(--text); font-size: 13px; font-weight: 400; }
#list[data-path="/admin/clients"] .table :is(th, td) { padding-left: 9px; padding-right: 9px; }
#list[data-path="/admin/clients"] .table td { height: 40px; line-height: 1.3; }
.cell-main { display: block; font-weight: 550; }
.cell-sub { display: block; max-width: 240px; overflow: hidden; text-overflow: ellipsis; color: var(--text-3); font-size: 12px; }
/* тариф и срок — двумя строками, как логин и почта: колонка вдвое уже (таблица влезает в 1440, доработка 19) */
.plan-cell { display: flex; flex-direction: column; align-items: flex-start; }
.plan-term { display: block; color: var(--text-3); font-size: 12px; line-height: 1.3; white-space: nowrap; }
.plan-term.warn { color: var(--warning); }
.ctable td .badge { height: 18px; padding: 0 6px; font-size: 11px; }
.cell-main .badge { height: 17px; margin-left: 6px; padding: 0 6px; font-size: 11px; font-weight: 500; vertical-align: 1px; }
.plan-pick select { field-sizing: content; }

/* ==== u1 ==== */
/* плашка тревог «Платежей»: не выталкивает список за экран — прокрутка внутри, заголовок на месте */
.list-top .pay-alerts { margin-bottom: 12px; max-height: 236px; overflow-y: auto; scrollbar-width: none; }
.list-top .pay-alerts-head { position: sticky; top: 0; z-index: 1; background: linear-gradient(var(--danger-soft), var(--danger-soft)), var(--surface); }
/* формы в панели: кнопки формы — сразу под последним полем, одинаково во всех панелях */
.panel-body .form-actions { margin-top: 4px; }

/* ==== overview ==== */
/* Обзор (app/sections/overview.py, templates/overview.html + _overview.html): поломки, новые клиенты, лимиты, ждёт действия */
.ov-live { display: inline-flex; align-items: center; gap: 7px; color: var(--text-3); font-size: 12px; }
.ov-live-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.ov { display: grid; gap: 12px; align-items: start; grid-template-columns: minmax(0, 1fr); }  /* узко — блоки по порядку */
@media (min-width: 1400px) {  /* широко: поломки сверху, слева новые клиенты и «ждёт действия», справа лимиты */
  .ov {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); grid-template-rows: auto auto 1fr;
    grid-template-areas: "problems problems" "new limits" "waiting limits";
  }
  .ov > [data-block="problems"] { grid-area: problems; }
  .ov > [data-block="new"] { grid-area: new; }
  .ov > [data-block="limits"] { grid-area: limits; }
  .ov > [data-block="waiting"] { grid-area: waiting; }
  .ov > .empty { grid-column: 1 / -1; }
  .ov-new { table-layout: fixed; }  /* таблица всегда влезает в колонку: длинный логин и источник — с многоточием */
  .ov-new th:nth-child(2) { width: 108px; }
  .ov-new th:nth-child(3) { width: 132px; }
  .ov-new th:nth-child(4) { width: 170px; }
  .ov-new th:nth-child(5) { width: 104px; }
}
.ov-checked { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* поломки: зелёная строка или красный список */
.ov-ok { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.ov-ok b { font-weight: 550; }
.ov-ok-dot { width: 8px; height: 8px; margin-right: 2px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-soft); }
.ov-alerts { overflow: hidden; border: 1px solid color-mix(in srgb, var(--danger) 30%, var(--border)); border-radius: var(--radius-lg); background: var(--surface); }
.ov-alerts-head { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 14px; background: var(--danger-soft); color: var(--danger); font-size: 12.5px; font-weight: 600; }
.ov-alerts-head .count { color: inherit; opacity: .75; font-size: 12px; }
.ov-alerts-head .ov-checked { margin-left: auto; color: inherit; opacity: .7; font-weight: 500; }
.ov-alert { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 7px 14px; border-top: 1px solid var(--border); color: var(--text); transition: background-color .08s; }
.ov-alert::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.ov-alert:hover { background: var(--row-hover); text-decoration: none; }
.ov-alert-title { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.ov-alert-detail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.ov-go { display: inline-flex; align-items: center; gap: 3px; flex: none; color: var(--text-3); font-size: 12px; }
.ov-go svg { width: 13px; height: 13px; }
.ov-alert:hover .ov-go { color: var(--accent); }

/* блоки */
.ov-card { min-width: 0; overflow: hidden; }
.ov-card .card-head { height: 40px; font-weight: 400; }
.ov-meta { margin-right: auto; color: var(--text-3); font-size: 12px; }
.ov-stats { display: flex; gap: 36px; padding: 12px 14px 11px; border-bottom: 1px solid var(--border); }
.ov-stat { display: grid; gap: 1px; }
.ov-stat b { font-size: 22px; font-weight: 600; line-height: 1.15; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.ov-stat span { color: var(--text-3); font-size: 12px; }
.ov-new th:first-child, .ov-new td:first-child { padding-left: 14px; }
.ov-new th:last-child, .ov-new td:last-child { padding-right: 14px; }
.ov-new td { overflow: hidden; text-overflow: ellipsis; }
.ov-yes { display: inline-flex; align-items: center; gap: 5px; color: var(--success); }
.ov-yes svg { width: 13px; height: 13px; stroke-width: 2; }

/* лимиты: группы со строками-ссылками в карточку клиента */
.ov-group + .ov-group { border-top: 1px solid var(--border); }
.ov-group-head { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px 0 14px; background: var(--surface-2); }
.ov-group-head h3 { font-size: 12px; font-weight: 600; color: var(--text-2); }
.ov-group-head .count { font-size: 12px; }
.ov-gdot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
[data-group="hit"] .ov-gdot { background: var(--danger); }
[data-group="near"] .ov-gdot { background: var(--warning); }
[data-group="overdraft"] .ov-gdot { background: var(--accent); }
[data-group="expiring"] .ov-gdot { background: none; box-shadow: inset 0 0 0 1.5px var(--warning); }
.ov-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px minmax(128px, auto); align-items: center; gap: 12px; height: 34px; padding: 0 14px; border-top: 1px solid var(--border); color: var(--text); transition: background-color .08s; }
.ov-row.is-term { grid-template-columns: minmax(0, 1fr) auto auto; }
.ov-row:hover { background: var(--row-hover); text-decoration: none; }
.ov-row .meter { min-width: 0; }
.ov-login { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ov-plan { color: var(--text-2); white-space: nowrap; }
.ov-num { color: var(--text-2); font-size: 12.5px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ждёт действия */
.ov-task { display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px 0 14px; border-top: 1px solid var(--border); color: var(--text); transition: background-color .08s; }
.card-head + .ov-task { border-top: 0; }
.ov-task:hover { background: var(--row-hover); text-decoration: none; }
.ov-task-title { flex: 1; font-weight: 500; }
.ov-task-n { padding: 1px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 550; font-variant-numeric: tabular-nums; }
.ov-task svg { width: 14px; height: 14px; color: var(--text-3); }
.ov-task:hover svg { color: var(--accent); }

@media (max-width: 860px) {
  .ov-alert { flex-wrap: wrap; row-gap: 2px; }
  .ov-alert-title { flex: 1; max-width: none; white-space: normal; }
  .ov-row { grid-template-columns: minmax(0, 1fr) auto; }
  .ov-row .meter { display: none; }
  .ov-alert-detail { flex-basis: 100%; order: 3; padding-left: 17px; white-space: normal; }
  .ov-stats { gap: 24px; }
}

/* ==== sources ==== */
.funnel { display: grid; gap: 2px; width: 88px; }
.funnel i { display: block; height: 4px; border-radius: 2px; background: var(--accent); }
.funnel i:first-child { background: var(--border-strong); }
.funnel i:last-child { background: var(--success); }
.src-cell { display: block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
@media (min-width: 861px) {  /* компьютер: источник переносится, а не обрезается (доработка 19), между словами (24) */
  .src-cell { min-width: 6em; white-space: normal; overflow-wrap: break-word; }
}
.fact-src { max-width: 220px; overflow: hidden; text-overflow: ellipsis; display: block !important; }
.src-all { display: inline-flex; align-items: center; height: 24px; padding: 0 6px; border-radius: 5px;
  color: var(--text-3); font: 500 12px var(--font); white-space: nowrap; }
.src-all:hover { background: var(--surface-2); color: var(--accent); }

/* ==== usage ==== */
/* Использование: Расход, Лимиты и отказы, Ошибки API, Файлы, Организации (app/sections/usage.py, limits.py, errors.py,
   batch.py, party.py; templates/_report.html) */
.report .page-title .count { font-weight: 450; }
/* переключатель: период, разрез, вид ошибок */
.seg { display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.seg-item {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px; border-radius: 5px;
  color: var(--text-2); font: 500 12.5px/1 var(--font); white-space: nowrap; cursor: pointer; list-style: none;
  transition: background-color .12s, color .12s;
}
.seg-item::-webkit-details-marker { display: none; }
.seg-item:hover { color: var(--text); text-decoration: none; }
.seg-item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg-item .chev { width: 12px; height: 12px; margin-right: -3px; color: var(--text-3); }
.seg .menu-pop { top: calc(100% + 6px); }
/* итоги */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 9px 12px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
}
.tile-label { color: var(--text-3); font-size: 12px; line-height: 1.3; overflow-wrap: anywhere; }
a.tile-label:hover { color: var(--accent); text-decoration: none; }
.tile-go { margin-left: 4px; }
.tile-value { font-size: 20px; font-weight: 600; letter-spacing: -.02em; line-height: 1.25; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tile-sub { color: var(--text-3); font-size: 12px; line-height: 1.3; overflow-wrap: anywhere; }
.tile.is-warning .tile-value { color: var(--warning); }
.tile.is-danger .tile-value { color: var(--danger); }
.delta { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.is-up { color: var(--success); }
.delta.is-down { color: var(--danger); }
.delta.is-new { color: var(--accent); }
/* график и разрез */
.report-card { margin-bottom: 12px; }
.report-card .card-body { padding: 12px 14px 8px; }
.report-svg { max-height: 220px; }
.drill { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin: 4px 0 10px; font-size: 13px; }
.drill a { color: var(--text-2); }
.drill a:hover { color: var(--accent); }
.drill [aria-current] { font-weight: 600; }
.drill-sep { color: var(--text-3); margin: 0 2px; }
.rtable tbody tr.is-link { position: relative; cursor: pointer; }
.rtable tbody tr.is-link td.name a::after { content: ""; position: absolute; inset: 0; }
.rtable td.name a { font-weight: 500; }
.rtable td.name .faint { margin-left: 6px; font-size: 12px; }
.share { display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; }
.share-n { min-width: 34px; text-align: right; }
.share-bar { width: 48px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.share-bar > span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.bad { color: var(--danger); }
.warn-n { color: var(--warning); }
.strong-num { font-weight: 600; }
/* ошибки: полоса по часам/суткам — только ячейки с ошибками, подсказка — title */
.heat-col { width: 34%; min-width: 220px; }
.heat { position: relative; z-index: 1; height: 14px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.heat > i { position: absolute; top: 0; bottom: 0; width: var(--w); min-width: 2px; }
/* c — ошибся клиент, s — сбой у нас (есть хоть один); 1…4 — сколько ошибок относительно максимума страницы */
.heat > .c1, .heat > .c2, .heat > .c3, .heat > .c4 { background: var(--warning); }
.heat > .s1, .heat > .s2, .heat > .s3, .heat > .s4 { background: var(--danger); }
.heat > .c1, .heat > .s1 { opacity: .35; } .heat > .c2, .heat > .s2 { opacity: .55; }
.heat > .c3, .heat > .s3 { opacity: .78; }
.report .section-title { display: flex; align-items: baseline; gap: 6px; margin: 18px 0 8px; }
.report .section-title .faint { font-size: 12px; font-weight: 400; }
.report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 16px; align-items: start; }
.report-grid .ctable { width: 100%; }
.report-grid > .card { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.report-grid > .card:last-child:nth-child(odd):has(> .table) { grid-column: 1 / -1; }  /* таблица одна в ряду — на всю ширину */
.empty-sm { padding: 28px 16px; }
.reason-chips { gap: 6px; }
.chip-n { margin-left: 2px; padding: 1px 6px; border-radius: 9px; background: var(--surface-3); color: var(--text-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.chip.is-active .chip-n { background: var(--surface); color: var(--accent); }
.chip.is-zero:not(.is-active) { color: var(--text-3); }
/* лимиты: действия в строке */
/* файлы: панель */
.progress { display: inline-flex; align-items: center; gap: 10px; }
.progress .meter { width: 120px; }
.cols-list { display: flex; flex-wrap: wrap; gap: 4px; }
.col-name { padding: 1px 7px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); font-size: 12px; }
.col-name.is-addr { background: var(--accent-soft); color: var(--accent); font-weight: 550; }
pre.code.json { max-height: 300px; }
@media (max-width: 1100px) {
  .report-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 17px; }
  .heat-col { min-width: 160px; }
}

/* ==== a9 ==== */
/* письма: шаблон и предпросмотр */
.mail-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 6px; font-size: 12px; }
.mail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
#mail-form textarea { min-height: 300px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; }
.mail-vars { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.mail-vars .faint { margin-right: 2px; font-size: 12px; }
.mail-vars .chip { height: 24px; font-size: 12px; cursor: pointer; }
.mail-vars .chip:disabled { cursor: default; opacity: .6; }
.mail-preview { display: grid; gap: 10px; }
.mail-preview-subject { padding-bottom: 10px; border-bottom: 1px solid var(--border); font-weight: 600; overflow-wrap: anywhere; }
.mail-preview-body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.mail-history { margin-bottom: 8px; }
.mail-table td.name .faint { margin-left: 6px; font-size: 12px; }
/* песочница */
.sbx-card { margin-bottom: 12px; }
.sbx-card .card-meta { margin-left: 10px; text-align: right; font-weight: 400; }
.mail-grid .card-meta { margin-left: 8px; font-weight: 400; }
.sbx-note { margin: 0 0 4px; }
.sbx-card .secret { max-width: 640px; }
.sbx-table { border: 0; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
@media (max-width: 860px) {
  .mail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ==== a8 ==== */
/* Поиск и карты: Проверка поиска, Отладка карты, Геобаза, Карты (app/sections/search_check.py, map_debug.py, geo.py,
   maps.py; static/map_debug.js) */
.table-wrap.a8-flush { border: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); background: none; }
/* переключатель на радиокнопках (без JS): .seg > label.seg-item > input[type=radio] */
.seg-item > input[type="radio"] { position: absolute; opacity: 0; pointer-events: none; }
.seg-item:has(> input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.seg-item:has(> input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }
/* проверка поиска */
.sc-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; align-items: start; }
.sc-main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; }
.sc-main > .alert { margin: 0; }
.sc-form .card-body { padding: 12px 14px 2px; }
.sc-svc { margin-bottom: 12px; }
.sc-row { display: flex; flex-wrap: wrap; gap: 0 10px; align-items: flex-start; }
.sc-row > div { flex: 1 1 150px; min-width: 0; }
.sc-row > .sc-q { flex: 4 1 280px; }
.sc-row > .sc-n { flex: 0 1 130px; }
.sc-row > .sc-go { flex: 0 0 auto; padding-top: 22px; margin-bottom: 12px; }
.sc-form:has(input[value="reverse"]:checked) .only-text,
.sc-form:not(:has(input[value="reverse"]:checked)) .only-rev,
.sc-form:not(:has(input[value="suggest"]:checked)) .only-sug { display: none; }
.sc-extra { margin-bottom: 10px; }
.sc-extra > summary { width: max-content; margin-bottom: 8px; color: var(--text-2); font-size: 12px; font-weight: 500; cursor: pointer; }
.sc-extra textarea { font-family: var(--mono); font-size: 12px; }
.sc-card .card-head .seg { height: 26px; }
.sc-card .card-head .seg-item { height: 20px; }
.sc-resp:has(input[value="json"]:checked) .sc-read,
.sc-resp:has(input[value="read"]:checked) .sc-json { display: none; }
.sc-resp pre.sc-json { max-height: 520px; margin: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.sc-read .table td { height: auto; padding-top: 6px; padding-bottom: 6px; }
.sc-read .table td:nth-child(2) { white-space: normal; min-width: 260px; }
.sc-act { text-align: right; }
.sc-why { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 9px 14px; border-bottom: 1px solid var(--border); }
.sc-step + .sc-step { border-top: 1px solid var(--border); }
.sc-step > summary { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 5px 14px; list-style: none; cursor: pointer; }
.sc-step > summary::-webkit-details-marker { display: none; }
.sc-step > summary:hover { background: var(--row-hover); }
.sc-step > summary .chev { width: 14px; height: 14px; color: var(--text-3); transition: transform .12s; }
.sc-step[open] > summary .chev { transform: rotate(90deg); }
.sc-step-name { font-weight: 550; }
.sc-step-why { padding: 1px 8px; border-radius: 9px; background: var(--accent-soft); color: var(--accent); font-size: 12px; }
.sc-ms { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.sc-bar { width: 90px; height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; }
.sc-bar > i { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: var(--accent); }
.sc-step-body { display: grid; gap: 10px; padding: 4px 14px 14px 36px; }
.sc-step-body .kv { grid-template-columns: minmax(90px, max-content) 1fr; }
.sc-cand .table-wrap { margin-top: 4px; border-radius: var(--radius); }
.sc-cand .table td { height: 28px; }
.sc-hist { position: sticky; top: calc(var(--top-h) + 12px); max-height: calc(100vh - var(--top-h) - 24px); overflow-y: auto; scrollbar-width: none; }
.sc-htable td { height: auto; padding-top: 6px; padding-bottom: 6px; vertical-align: top; white-space: normal; }
.sc-htable td a { font-weight: 500; overflow-wrap: anywhere; }
.sc-htable .faint { font-size: 12px; }
.sc-when { text-align: right; white-space: nowrap !important; font-size: 12px; }
/* отладка карты */
.md .page-head { margin-bottom: 10px; }
.md-find { position: relative; flex: 0 1 300px; }
.md-find svg { position: absolute; top: 50%; left: 9px; color: var(--text-3); transform: translateY(-50%); pointer-events: none; }
.md-find .input { width: 100%; padding-left: 30px; }
.md-chip { user-select: none; }
.md-chip > input { margin: 0; accent-color: var(--accent); }
.md-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1.5px #fff, 0 0 0 2.5px var(--border); }
.md-dot.is-gar { background: #2443b8; }
.md-dot.is-osm { background: #e8710a; }
.md-dot.is-ov { background: #d6403f; }
.md-dot-n { display: inline-grid; place-items: center; width: 16px; height: 16px; color: #fff; font: 600 10px/1 var(--font); font-style: normal; }
.md-map-wrap { position: relative; height: max(420px, calc(100dvh - var(--top-h) - 150px)); overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-2); }
.md-map-wrap > .md-map { position: absolute; inset: 0; } /* сильнее .maplibregl-map { position: relative } */
.md-map > .empty { height: 100%; }
.md-hint { position: absolute; top: 12px; left: 50%; z-index: 2; padding: 7px 14px; border-radius: 999px; background: var(--toast-bg); color: #fff; font-weight: 500; box-shadow: var(--shadow-lg); transform: translateX(-50%); pointer-events: none; white-space: nowrap; }
.md-legend { position: absolute; bottom: 10px; left: 10px; z-index: 2; display: flex; gap: 12px; padding: 5px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: color-mix(in srgb, var(--surface) 92%, transparent); color: var(--text-2); font-size: 12px; }
.md-legend span { display: inline-flex; align-items: center; gap: 6px; }
.md-sel { width: 24px; height: 24px; border: 2.5px solid #5e6ad2; border-radius: 50%; box-shadow: 0 0 0 2px #fff, 0 1px 6px rgb(0 0 0 / .4); pointer-events: none; }
.mp-list { margin: 14px 0 0; padding: 0; list-style: none; }
.mp-addr { padding: 10px 0; border-top: 1px solid var(--border); }
.mp-addr:first-child { padding-top: 0; border-top: 0; }
.mp-addr[data-fly] { cursor: pointer; }
.mp-addr[data-fly]:hover b { color: var(--accent); }
.mp-head { display: flex; align-items: baseline; gap: 8px; }
.mp-check { margin-left: auto; font-size: 12px; white-space: nowrap; }
.mp-meta { margin-top: 3px; color: var(--text-3); font-size: 12px; overflow-wrap: anywhere; }
.mp-meta .mono { color: var(--text-2); font-size: 11.5px; }
/* геобаза, карты */
.maps-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.maps-open { text-align: right; }
@media (max-width: 1100px) {
  .sc-layout { grid-template-columns: minmax(0, 1fr); }
  .sc-hist { position: static; max-height: none; }
}
@media (max-width: 860px) {
  .md-find { flex: 1 1 100%; }
  .md-legend { display: none; }
  .sc-step-body { padding-left: 14px; }
  .sc-bar, .sc-step > summary > .mono { display: none; }
}

/* ==== a10 ==== */
/* состояние: пробы полосой за сутки, диски, .env */
.st-block { margin-bottom: 12px; }
.st-block + .report-grid { margin-top: 0; }
.report-grid > .st-block { margin-bottom: 0; }
.report-grid + .st-block { margin-top: 12px; }
.st-probes { width: 100%; }
.st-block .ctable td.mono { white-space: nowrap; }
.st-probes td, .st-probes th { white-space: nowrap; }
.st-bar-col { width: 55%; }
.st-bar { display: flex; gap: 1px; height: 18px; min-width: 240px; }
.seg { min-width: 1px; border-radius: 2px; }
.seg-ok { background: var(--success); opacity: .55; }
.seg-warn { background: var(--warning); }
.seg-bad { background: var(--danger); }
.seg-none { background: var(--surface-3); }
.st-err { color: var(--danger); font-size: 12px; }
.st-disk { margin-right: 8px; }
.st-disk .meter { width: 120px; }
.st-env { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 12px 14px 14px; list-style: none; }
.st-env li { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 8px; border-radius: 6px; background: var(--surface-2); font-size: 12px; }
.st-env li:not(.is-set) .mono { color: var(--text-3); }
/* настройки: строка «подпись — поле — откуда — кнопки» */
.set-card { margin-bottom: 12px; }
.set-row { display: grid; grid-template-columns: minmax(200px, 1fr) minmax(200px, 320px) 120px 250px; gap: 6px 14px; align-items: start; padding: 12px 14px; border-top: 1px solid var(--border); }
.set-card > .set-row:first-child, .card-head + .set-row, .card-body > .set-row:first-of-type { border-top: 0; }
.card-body > .set-row { padding-left: 0; padding-right: 0; }
.set-label label { font-weight: 500; }
.set-label .hint { margin-top: 2px; }
.set-value { margin: 0; }
.set-source { display: flex; align-items: center; min-height: 32px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 32px; }
.set-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 12px; }
.set-events { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 6px 0 4px; }
.tg-head { margin-top: 18px; }
.tg-find { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 8px; }
.tg-found { display: grid; gap: 0; margin: 0 0 12px; padding: 0; list-style: none; border: 1px solid var(--border); border-radius: var(--radius); }
.tg-found li { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 10px; border-top: 1px solid var(--border); }
.tg-found li:first-child { border-top: 0; }
.tg-found form { margin: 0; }
.tg-none { margin: 4px 0 8px; }
.tg-chat { padding: 10px 0; border-top: 1px solid var(--border); }
.tg-chat.is-off .tg-chat-title { color: var(--text-3); }
.tg-chat-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tg-chat-title { font-weight: 550; }
.tg-chat-head .check { margin-left: auto; }
.tg-chat .set-actions { margin-top: 6px; }
@media (max-width: 1180px) {
  .set-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .set-row { grid-template-columns: minmax(0, 1fr); }
  .set-source, .set-actions { min-height: 0; }
  .st-bar { min-width: 180px; }
}

/* ==== u2a ==== */
/* панель записи: кнопок больше, чем влезает в строку (файл: скачать исходник и результат, повторить, удалить) */
.panel-foot { flex-wrap: wrap; }

/* ==== a6b ==== */
/* карточка: «Расход» — сегодня по часам (SVG 1000 в ширину ужат до колонки: подписи крупнее, чтобы читались) */
.hour-chart { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.mini-title { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.hour-chart .usage-chart .axis { font-size: 17px; }
.hour-chart .chart-legend { display: none; }
/* панель ключа: откуда запросы */
.ctable.origins { width: 100%; }
.ctable.origins td:first-child { padding-left: 0; width: 1%; }
.ctable.origins td:last-child { padding-right: 0; white-space: nowrap; }
.ctable.origins .truncate { max-width: 260px; }

/* ==== u4 ==== */
/* меню: счётчик группы — только у свёрнутой (сумма пунктов, тон самого тревожного: app/shell.py counts) */
.nav-group:not(.is-collapsed) .nav-gcount { display: none; }
.nav-gcount.is-danger { background: var(--danger-btn); color: #fff; }
/* шапка: «На сайт» (узко — иконка, подпись для экранного чтеца), меню оператора: «Кабинет», «Выйти» */
.site-link svg { width: 15px; height: 15px; }
.who { height: 30px; padding: 0 6px 0 4px; border-radius: var(--radius); cursor: pointer; transition: background-color .12s, color .12s; }
.who:hover, .who-menu[open] > .who { background: var(--surface-2); color: var(--text); }
.who .chev { width: 12px; height: 12px; margin-left: -4px; color: var(--text-3); }
@media (max-width: 860px) {
  .site-link { width: 30px; padding: 0; }
  .site-link-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .who .chev { display: none; }
}
/* расход сверх лимита (тариф сменился днём): полоска полная, «сверх лимита» и причина — строкой ниже (_macros over_limit) */
.over-limit { display: block; max-width: 280px; margin-top: 2px; color: var(--danger); font-size: 12px; line-height: 1.35; white-space: normal; }
.over-limit b { font-weight: 600; }
.facts .over-limit { max-width: 360px; }
.ov-row:has(.over-limit) { height: auto; min-height: 34px; padding-top: 6px; padding-bottom: 6px; row-gap: 1px; }
.ov-row .over-limit { grid-column: 1 / -1; max-width: none; margin-top: 0; }
/* всплывающие окна в экране. Шире 640 px меню прижимается к видимой области (static/app.js: is-flip-x/-y — в другую
   сторону, иначе сдвиг и высота по месту); ≤ 640 px — лист снизу на всю ширину с затемнением (тап мимо — закрыть) */
.menu-pop.is-flip-x { left: auto; right: 0; }
.menu-pop.is-right.is-flip-x { left: 0; right: auto; }
.menu-pop.is-flip-y { top: auto; bottom: calc(100% + 4px); }
.menu-pop.is-up.is-flip-y { top: calc(100% + 4px); bottom: auto; }
@keyframes sheet { from { transform: translateY(100%); } }
@media (max-width: 640px) {
  .menu[open] > .menu-pop {
    position: fixed; inset: auto 0 0 0; z-index: 48; min-width: 0; max-width: none; max-height: 75dvh;
    padding: 6px 8px calc(12px + env(safe-area-inset-bottom)); border-width: 1px 0 0; border-radius: 14px 14px 0 0;
    animation: sheet .2s var(--ease);
  }
  .menu[open] > summary::before { content: ""; position: fixed; inset: 0; z-index: 47; background: var(--overlay); cursor: default; }
  .menu[open] > .menu-pop .menu-item { min-height: 40px; }
  .menu[open] > .menu-pop .menu-form .input { height: 34px; font-size: 16px; }  /* 16 px — телефон не увеличивает страницу */
  .menu[open] > .menu-pop .menu-empty, .menu[open] > .menu-pop .menu-error { max-width: none; }
  .menu-period { flex-wrap: wrap; }
  .menu-period .input { flex: 1 1 120px; }
  /* position: fixed внутри — от экрана: у предков меню нет transform и backdrop-filter */
  .topbar, .client-head, .form-sticky { backdrop-filter: none; background: var(--bg); }
  .bulkbar { left: 8px; right: 8px; bottom: 8px; transform: none; flex-wrap: wrap; animation-name: rise; }
  .toasts { left: 8px; right: 8px; bottom: 8px; }
  .toast { min-width: 0; max-width: none; }
}
/* ==== Форум ==== */
/* Темы и переписка (app/sections/forum.py, templates/forum_topic.html, forum_title_cell.html, static/forum.js).
   Список тем — общий движок; тема — панель записи: на широком экране второй колонкой рядом с узким списком
   (заголовок, метки, время), на телефоне — отдельным экраном с «← Темы». */
#list[data-path="/admin/forum"] td.ftopic { min-width: 260px; max-width: 560px; padding-top: 6px; padding-bottom: 6px; white-space: normal; }
.ftopic-main { display: flex; flex-wrap: wrap; align-items: center; gap: 3px 6px; }
.ftopic-title { min-width: 0; font-weight: 550; overflow-wrap: anywhere; }
.ftopic-main .badge, .msg-head .badge { height: 18px; padding: 0 6px; font-size: 11px; }
.ftopic-meta { display: none; margin-top: 2px; color: var(--text-3); font-size: 12px; }
/* текст сообщения как на сайте, без HTML */
.forum-body { display: grid; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); line-height: 1.5; overflow-wrap: anywhere; }
.forum-body p { margin: 0; white-space: pre-wrap; }
.forum-body pre { margin: 0; padding: 8px 10px; border-radius: 6px; background: var(--surface-3); overflow-x: auto; scrollbar-width: none; }
.forum-body pre code { white-space: pre; }
.forum-note { margin: 14px 0 0; }
/* переписка: шапка темы, сообщения по порядку (команда — правее и с акцентом), ответ — внизу панели */
.thread-head { display: grid; gap: 8px; padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.thread-tags, .thread-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.thread-title { font-size: 16px; font-weight: 600; line-height: 1.3; letter-spacing: -.01em; overflow-wrap: anywhere; }
.msgs { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.msg { display: grid; gap: 6px; min-width: 0; margin-right: 40px; scroll-margin: 16px; }
.msg.is-team { margin: 0 0 0 40px; }
.msg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-height: 26px; font-size: 12.5px; }
.msg-author { min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.msg-author a { color: var(--text); }
.msg-writer { color: var(--text-3); font-weight: 400; }
.msg-actions { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; }
.msg.is-team .forum-body { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, var(--border)); }
.msg.is-pending .forum-body { border-style: dashed; border-color: color-mix(in srgb, var(--warning) 60%, var(--border)); }
.msg:is(.is-hidden, .is-deleted) .forum-body { border-style: dashed; background: none; color: var(--text-2); }
.msg.is-target .forum-body { box-shadow: var(--focus); }
.msg-actions { flex-wrap: wrap; justify-content: flex-end; max-width: 100%; }
.msg-edited { font-size: 11.5px; }
.msg-quote { display: flex; gap: 6px; min-width: 0; padding: 4px 10px; border-left: 3px solid var(--border-strong, var(--border)); border-radius: 0 6px 6px 0; background: var(--surface-2); color: var(--text-2); font-size: 12.5px; line-height: 1.4; }
.msg-quote:hover { text-decoration: none; background: var(--surface-3); }
.msg-quote b { flex: none; max-width: 40%; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-quote span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-edit { display: grid; gap: 8px; }
.msg-edit .field { margin: 0; }
.msg-edit .form-actions { margin: 0; }
.msg-edit textarea { min-height: 96px; }
.reply-plate { display: flex; align-items: center; gap: 6px; min-width: 0; margin-bottom: 8px; padding: 4px 4px 4px 10px; border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0; background: var(--accent-soft); font-size: 12.5px; }
.reply-plate[hidden] { display: none; }
.reply-plate-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thread-log { margin-top: 18px; }
.thread-log .history { margin-top: 10px; }
.forum-reply { flex: 1; min-width: 0; }
.forum-reply .field { margin-bottom: 8px; }
.forum-reply .form-actions { margin-top: 0; }
.forum-back { display: none; margin-right: 6px; }
#panel .panel-title:has(.forum-back) { max-width: none; white-space: nowrap; }
@media (min-width: 1100px) {  /* две колонки: узкий список тем слева, переписка справа под шапкой */
  body:has(#list[data-path="/admin/forum"]) #panel { top: var(--top-h); left: calc(var(--nav-w) + 420px); width: auto; box-shadow: none; }
  body:has(#list[data-path="/admin/forum"]):has(#panel.is-open) .main { width: 420px; }
  body:has(#list[data-path="/admin/forum"]):has(#panel.is-open) #list-table thead,
  body:has(#list[data-path="/admin/forum"]):has(#panel.is-open) #list-table td:not(.ftopic) { display: none; }
  body:has(#list[data-path="/admin/forum"]):has(#panel.is-open) #list td.ftopic { min-width: 0; max-width: none; }
  body:has(#list[data-path="/admin/forum"]):has(#panel.is-open) .ftopic-meta { display: block; }
  body:has(#list[data-path="/admin/forum"]):has(#panel.is-open) .list-search,
  body:has(#list[data-path="/admin/forum"]):has(#panel.is-open) .list-search .input { flex: 1 1 100%; width: 100%; }
}
@media (max-width: 640px) {  /* телефон: список — заголовок, метки, время; тема — отдельный экран, назад — «← Темы» */
  #list[data-path="/admin/forum"] #list-table thead,
  #list[data-path="/admin/forum"] #list-table td:not(.ftopic, .col-check) { display: none; }
  #list[data-path="/admin/forum"] td.ftopic { min-width: 0; max-width: none; }
  #list[data-path="/admin/forum"] .ftopic-meta { display: block; }
  body:has(#list[data-path="/admin/forum"]) #panel { width: 100vw; }
  .forum-reply .hint { display: none; }
  .forum-reply .field textarea { min-height: 52px; }
  .forum-back { display: inline-flex; }
  #panel .panel-head:has(.forum-back) > .icon-btn[data-panel-close] { display: none; }
  .msg { margin-right: 16px; }
  .msg.is-team { margin: 0 0 0 16px; }
}

/* овердрафт: подпись под заголовком группы «Обзора» и надбавка у числа */
.ov-hint { margin: 2px 14px 6px; color: var(--text-3); font-size: 12px; line-height: 1.4; }
.ov-od { color: var(--warning); cursor: help; }

/* map popup (доработка 16): окно maplibre у точки «Отладки карты» (templates/map_popup.html) и карточка адреса
   в панели (.mp-card, templates/map_point.html). CSS maplibre подключён после app.css — селекторы сильнее его. */
.md-map .md-popup { z-index: 3; font: 13px/1.45 var(--font); color: var(--text); }
.md-map .md-popup .maplibregl-popup-content { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-lg); }
.md-map .md-popup[class*="anchor-top"] .maplibregl-popup-tip { border-bottom-color: var(--surface); }
.md-map .md-popup[class*="anchor-bottom"] .maplibregl-popup-tip { border-top-color: var(--surface); }
.md-map .md-popup.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--surface); }
.md-map .md-popup.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--surface); }
.md-map .md-popup .maplibregl-popup-close-button { top: 6px; right: 6px; width: 26px; height: 26px; border-radius: var(--radius); color: var(--text-3); font: 18px/1 var(--font); }
.md-map .md-popup .maplibregl-popup-close-button:hover { background: var(--surface-2); color: var(--text); }
.md-map .md-popup .maplibregl-popup-close-button:focus-visible { outline: none; box-shadow: var(--focus); }
.md-pop { width: min(300px, calc(100vw - 100px)); }  /* окно с хвостиком уже карты: у точки в центре maplibre ставит его по центру */
.md-pop-more { display: block; color: var(--text-3); font-weight: 400; }
.md-pop-head { display: flex; align-items: center; gap: 8px; min-height: 26px; padding-right: 26px; margin-bottom: 4px; }
.md-pop-list { margin: 0; padding: 0; list-style: none; max-height: min(240px, 36vh); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.md-pop-list::-webkit-scrollbar { display: none; }
.md-pop .mp-addr { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.md-pop .mp-addr:first-child { padding-top: 4px; }
.md-pop .mp-addr:last-child { padding-bottom: 0; }
.md-pop-list:first-child > .mp-addr:first-child { padding-right: 28px; }  /* без заголовка: «Подробнее» левее крестика */
.md-pop .mp-head { flex: 1; min-width: 0; }
.md-pop-addr { min-width: 0; overflow-wrap: anywhere; }
.md-pop .btn { flex: none; }
.md-pop-empty { padding: 2px 28px 2px 0; color: var(--text-2); }
.mp-card .btn .ico { width: 14px; height: 14px; margin-right: -3px; }

/* map all addresses (доработка 23) */
/* «Все адреса» у наложения в окне (templates/map_popup.html) и широкая панель со всеми адресами точки
   (templates/map_all*.html): поиск и слой, группы по улице, строки, карточка поверх списка (map_card.html). */
.md-pop-head:has([data-all]) { flex-wrap: wrap; row-gap: 6px; }
.md-pop-head:has([data-all]) > b { flex: 1 0 100%; }
#panel:has(.mpa) { width: min(880px, 100vw); }
.mpa:has(#mpa-card:not(:empty)) > .mpa-list { display: none; }  /* карточка открыта — список ждёт под ней как был */
.mpa-tools { display: flex; gap: 8px; margin-bottom: 12px; }
.mpa-tools [type="search"] { flex: 1; min-width: 0; }
.mpa-tools select { flex: none; width: auto; }
.mpa-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; margin-bottom: 6px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.mpa-head .btn svg { width: 14px; height: 14px; }
.mpa-group { border-top: 1px solid var(--border); }
.mpa-group > summary { display: flex; align-items: baseline; gap: 8px; padding: 9px 2px; cursor: pointer; list-style: none; }
.mpa-group > summary::-webkit-details-marker { display: none; }
.mpa-group > summary::before { content: ""; flex: none; width: 6px; height: 6px; border: solid var(--text-3); border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(-45deg); transition: transform .15s var(--ease); }
.mpa-group[open] > summary::before { transform: translateY(-3px) rotate(45deg); }
.mpa-group > summary:hover .mpa-key { color: var(--accent); }
.mpa-key { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 550; }
.mpa-rows { margin: 0 0 8px; padding: 0 0 0 14px; list-style: none; }
.mpa-rows .mp-addr { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.mpa-rows .mp-head { flex: 1; min-width: 0; }
.mpa-rows .btn { flex: none; }
.mpa-next { padding: 8px 0 2px; }
.mpa-back { margin: -6px 0 10px -8px; }
.mpa-back .ico { width: 14px; height: 14px; margin-left: -3px; vertical-align: 0; }

/* client combobox (доработка 22) */
/* Поле выбора клиента (макрос client_pick, static/client_pick.js): свой список под полем вместо <datalist>. Список —
   popover в верхнем слое: место (left, top/bottom, width) и высоту — целым числом строк до края видимой части экрана
   (клавиатуры телефона) — ставит JS. Отступ 4 px вокруг строк — рамка цвета фона, внешняя линия — тень: прокручиваемые
   строки под отступ не заезжают, видимая область — ровно строки. Не влезли все — внизу «ещё N ↓» (.cpick-more,
   прилипает к низу, строки не перекрывает; доработка 25). Крестик — пока в поле есть текст и оно не только для чтения. */
.cpick .cpick-box { position: relative; }
.cpick .cpick-box > input.input { padding-right: 32px; }
.cpick-x {
  position: absolute; top: 50%; right: 3px; transform: translateY(-50%); display: inline-grid; place-items: center;
  width: 24px; height: 24px; padding: 0; border: 0; border-radius: 5px; background: none; color: var(--text-3); cursor: pointer;
}
.cpick-x:hover { background: var(--surface-2); color: var(--text); }
.cpick-box > .input:placeholder-shown ~ .cpick-x, .cpick-box > .input[readonly] ~ .cpick-x { display: none; }
.cpick-list {
  inset: auto; margin: 0; padding: 0;
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none;
  border: 4px solid var(--surface); border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  box-shadow: 0 0 0 1px var(--border), var(--shadow-lg);
}
.cpick-list::-webkit-scrollbar { display: none; }
.cpick-opt { display: grid; gap: 1px; padding: 6px 10px; border-radius: var(--radius); cursor: pointer; }
.cpick-more {
  position: sticky; bottom: 0; height: 28px; border-top: 1px solid var(--border); background: var(--surface);
  color: var(--text-3); font-size: 12px; line-height: 27px; text-align: center; cursor: pointer; user-select: none;
}
.cpick-opt[aria-selected="true"] { background: var(--surface-2); }
.cpick-opt b, .cpick-opt span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cpick-opt b { font-weight: 600; }
.cpick-opt span { color: var(--text-3); font-size: 12px; }
.cpick-opt mark { border-radius: 2px; background: var(--accent-soft); color: inherit; }
.cpick-list[aria-busy="true"] .cpick-opt { opacity: .55; }
.cpick-note { padding: 8px 10px; color: var(--text-3); }
.cpick-note.is-error { color: var(--danger); }
.field.cpick { scroll-margin-top: 8px; }
@media (max-width: 640px) {  /* телефон: тот же список под полем, строки крупнее, высота — до клавиатуры */
  .cpick-opt { min-height: 48px; align-content: center; padding: 8px 12px; }
  .cpick-opt b { font-size: 15px; }
  .cpick-opt span { font-size: 13px; }
}

/* services chips (доработка 24): «Лимиты и отказы → История» — строка в одну линию. Сервисы — чипы (макрос svc_chips):
   два, дальше «+N» — <details> раскрывает остальные в той же ячейке (закрыт — строкой, открыт — с переносом).
   Причина — бейдж с точкой цвета фильтр-чипа (data-reason, категориальная палитра графиков; старая — серая). */
.svc-chips { display: flex; align-items: center; gap: 4px; }
.svc-chips:has(> .svc-more[open]) { flex-wrap: wrap; padding: 6px 0; }
.svc {
  display: inline-flex; align-items: center; flex: none; height: 20px; padding: 0 7px; border: 1px solid var(--border-strong);
  border-radius: 10px; color: var(--text-2); font-size: 11.5px; font-weight: 500; line-height: 1; white-space: nowrap;
}
.svc-more[open] { display: contents; }  /* открыт: «+N» и остальные чипы — в общем ряду, ряд переносится */
.svc-more > span + span { margin-left: 4px; }
.svc-n { background: var(--surface-2); color: var(--text-3); cursor: pointer; list-style: none; user-select: none; }
.svc-n::-webkit-details-marker { display: none; }
.svc-n:hover { color: var(--text); }
.svc-n:focus-visible { outline: none; box-shadow: var(--focus); }
.svc-more[open] > .svc-n { border-color: transparent; background: var(--accent-soft); color: var(--accent); }
:is(.reason-chips .chip, .rsn)[data-reason] { --rc: var(--text-3); }  /* «Домен не разрешён» — старое правило */
:is(.reason-chips .chip, .rsn)[data-reason="daily_limit"] { --rc: var(--viz-2); }
:is(.reason-chips .chip, .rsn)[data-reason="rate"] { --rc: var(--viz-4); }
:is(.reason-chips .chip, .rsn)[data-reason="token"] { --rc: var(--viz-5); }
:is(.reason-chips .chip, .rsn)[data-reason="public"] { --rc: var(--viz-1); }
:is(.reason-chips .chip, .rsn)[data-reason="balance"] { --rc: var(--viz-6); }
:is(.reason-chips .chip, .rsn)[data-reason="party"] { --rc: var(--viz-3); }
.reason-chips .dot, .rsn .dot { background: var(--rc); }
.reason-chips .chip.is-zero:not(.is-active) .dot { opacity: .45; }
.hist .cut { display: inline-block; max-width: 13em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; }
.hist .faint.cut { max-width: 8em; }

/* phone sub-line (доработка 25): раскрытый «+N» — на его месте «свернуть». Телефон (≤ 860 px): главное строки — второй
   строкой в ячейке «Клиент» (.ph-sub): причина и чипы «Истории», бейдж состояния «Сегодня»; их колонки (.ph-off, у
   «Сегодня» ещё th[data-col=state]) скрыты — на первом экране без свайпа. Вторая строка не шире видимой части таблицы
   (контейнер .table-wrap): не влезла — многоточие у текста причины, чипы не режутся. Компьютер — как было. */
.svc-more:not([open]) .svc-n-less, .svc-more[open] .svc-n-more { display: none; }
.ph-sub { display: none; }
@media (max-width: 860px) {
  .table-wrap:has(.ph-sub) { container-type: inline-size; }
  .table:has(.ph-sub) td { padding-top: 6px; padding-bottom: 6px; }
  .table:has(.ph-sub) .ph-off, .table:has(.ph-sub) th[data-col="state"] { display: none; }
  .ph-sub { display: flex; align-items: center; gap: 4px 6px; max-width: calc(100cqw - 24px); margin-top: 4px; }
  .ph-sub .rsn { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; line-height: 20px; }
  .ph-sub .rsn .dot { margin-right: 5px; vertical-align: 1px; }
  /* раскрытый «+N»: строка — во всю видимую ширину (колонка не сжимается до самого длинного чипа), переносятся чипы,
     причина целая */
  .ph-sub:has(.svc-more[open]) { width: calc(100cqw - 24px); }
  .ph-sub:has(.svc-more[open]) .rsn { flex-shrink: 0; }
}
