/*
  Диспетчерская — оформление панели.

  Токены те же, что в приложении на телефоне (values/colors.xml и
  values-night/colors.xml): менеджер должен узнавать одно и то же изделие на
  экране телефона и на экране компьютера. Светлая тема — тёплая бумага,
  тёмная — угольная панель; сигнальный янтарь только там, где нужно действие.
*/

:root {
  --bg: #F4F1EA;
  --surface: #FFFFFF;
  --surface-2: #EDE8DC;
  --line: #D8D2C4;
  --line-soft: #E9E4D8;
  --ink: #1A1815;
  --ink-2: #6B6559;
  --ink-3: #928C7E;
  --signal: #FFB020;
  --signal-ink: #8A5A05;
  --signal-soft: #FBEFD6;
  /* Второй слой диаграмм. Подложка (--signal-soft) в тёмной теме почти
     сливается с фоном, и столбик «комментарии» пропадал с графика. */
  --signal-2: #E0A84A;
  --on-signal: #17150F;
  --ok: #2F8F4E;
  --ok-soft: #E3F1E7;
  --fail: #C43A27;
  --fail-soft: #FAE5E1;
  --wait: #928C7E;
  /* Цвета мелкого ТЕКСТА (13.10). --ink-3, --ok и --fail на светлой бумаге
     давали 2,7–4,4:1 — ниже 4,5:1 для подписей 10–12 px («Наш ответ»,
     «Показано N из M», строка сведений карточки, пилюли «позитив» и «сбой»).
     Эти три — не темнее чем нужно для 4,5:1 на любой подложке панели
     (белая, --bg, --surface-2 и мягкие --ok/--fail/--signal-soft). Заливки
     графиков, точки и линии берут прежние --ink-3/--ok/--fail. В тёмной теме
     значения равны прежним — там контраст был в норме. */
  --muted-ink: #6D675B;
  --ok-ink: #256F3D;
  --fail-ink: #B93522;

  --sans: 'Golos Text', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --mono: 'IBM Plex Mono', 'Cascadia Mono', Consolas, monospace;
  --display: 'Unbounded', 'Golos Text', system-ui, sans-serif;

  --radius: 0px;
  --gutter: 20px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #121110;
  --surface: #1A1917;
  --surface-2: #232220;
  --line: #2E2C28;
  --line-soft: #262421;
  --ink: #F2EFE9;
  --ink-2: #B8B2A6;
  --ink-3: #8C877D;
  --signal: #FFB020;
  --signal-ink: #FFC65C;
  --signal-soft: #2A2317;
  --signal-2: #8A6520;
  --on-signal: #17150F;
  --ok: #3FBF6A;
  --ok-soft: #16281C;
  --fail: #FF4D3D;
  --fail-soft: #2B1815;
  --wait: #8C877D;
  /* 17.10: #8C877D на подложках карточек (--signal-soft, --ok-soft) давал
     4,35:1 у подписей «Ответа ещё нет» — на тон светлее, ≥4,8:1 везде */
  --muted-ink: #948F85;
  --ok-ink: #3FBF6A;
  --fail-ink: #FF4D3D;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--signal-ink); }

/* ------------------------------------------------------------------ каркас */

#app {
  display: grid;
  grid-template-columns: 236px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 22px var(--gutter) 18px;
  border-bottom: 1px solid var(--line);
}

.brand-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 4px;
}

.nav {
  padding: 10px 0;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px var(--gutter);
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  text-align: left;
  cursor: pointer;
  color: var(--ink-2);
}

.nav-item:hover { background: var(--surface-2); color: var(--ink); }

.nav-item[aria-current='true'] {
  border-left-color: var(--signal);
  color: var(--ink);
  background: var(--surface-2);
  font-weight: 500;
}

.nav-item .count {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-3);
}

.sidebar-user {
  border-top: 1px solid var(--line);
  padding: 12px var(--gutter);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
}
.sidebar-user-icon { width: 18px; height: 18px; flex: 0 0 auto; color: var(--ink-2); }

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------------ шапка */

.topbar {
  position: sticky;
  top: 0;
  /* В отдельном окне на телефоне системная строка лежит поверх страницы:
     без отступа заголовок оказывается под часами и зарядом */
  padding-top: calc(14px + env(safe-area-inset-top));
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 14px var(--gutter);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

/* QA-16: вкладки страницы (карточка телефона, проект, аналитик) липнут к
   верху и уезжали под липкую шапку — при прокрутке их было не видно. На
   странице со вкладками липнут вкладки, а шапка уходит вместе со страницей */
.main:has(.tabs) .topbar { position: static; }

.topbar h1 {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.topbar .spacer { flex: 1; }

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  font-size: 12px;
  border-radius: 6px;
  white-space: nowrap;
}
/* 17.10: нажатие открывает меню, а не выходит — красная рамка при наведении
   обещала выход и больше не нужна. Подпись роли — --muted-ink: --ink-3 на
   светлой бумаге давал 3,35:1 */
.topbar-user:hover, .topbar-user[aria-expanded='true'] { border-color: var(--ink-3); color: var(--ink); }
.topbar-user-icon { width: 16px; height: 16px; }
.topbar-user-name { color: var(--ink); font-weight: 500; }
.topbar-user-role { color: var(--muted-ink); }
.topbar-user-wrap { position: relative; display: inline-flex; }
.topbar-user-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 200px;
  max-width: min(280px, calc(100vw - 32px));
  display: grid;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.topbar-user-menu-who { display: grid; gap: 2px; overflow-wrap: anywhere; }
.topbar-user-logout { justify-content: flex-start; gap: 8px; color: var(--fail-ink); }
.topbar-user-logout .nav-icon { width: 16px; height: 16px; }
@media (max-width: 640px) {
  .topbar-user-name { display: inline; font-size: 11px; max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
  .topbar-user-role { display: none; }
  .topbar-user { padding: 5px 8px; gap: 6px; min-height: 36px; } /* урок 1172: было 28 px */
}

.project-filter {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.project-filter-select { display: none; }
.btn.posts-filters-toggle { display: none; }
@media (max-width: 640px) {
  .btn.posts-filters-toggle { display: inline-flex; }
  .posts-filters:not(.open) { display: none; }
}
@media (max-width: 640px) {
  .project-filter > .chip { display: none; }
  .project-filter-select { display: block; width: 100%; min-height: 40px; }
}

.chip {
  padding: 7px 13px;
  border: 1px solid var(--line);
  background: none;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
}

.chip:hover { border-color: var(--ink-3); color: var(--ink); }

.chip[aria-pressed='true'] {
  border-color: var(--signal);
  color: var(--signal-ink);
  background: var(--signal-soft);
  font-weight: 500;
}

.content {
  padding: var(--gutter);
  flex: 1;
  min-width: 0;
}

.content.flush { padding: 0; }

/* ------------------------------------------------------------------ типографика */

.eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted-ink);
}

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.big {
  font-family: var(--display);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.muted { color: var(--muted-ink); }
.dim { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.ok { color: var(--ok); }
.fail { color: var(--fail); }
.signal { color: var(--signal-ink); }

h2.section {
  font-size: 15px;
  font-weight: 600;
  margin: 26px 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

h2.section:first-child { margin-top: 0; }

/* ------------------------------------------------------------------ блоки */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  /* Длинные адреса без пробелов (vm.tiktok.com/…, reddit.com/r/…) в тексте
     ИИ-аналитика растягивали карточку, и на 375 px страница уезжала вбок (QA 3.10) */
  overflow-wrap: anywhere;
}

.panel-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-body { padding: 16px; }

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}

.stats {
  /* flex вместо grid: при неполном последнем ряде auto-fit оставлял пустые
     дорожки, и фон линий проступал серой областью справа от плиток */
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.stat {
  flex: 1 1 150px;
  background: var(--surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.stat .value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat .label { font-size: 12px; color: var(--muted-ink); }

/* ------------------------------------------------------------------ карточка телефона */

.device-card {
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  font: inherit;
}

.device-card:hover { border-color: var(--ink-3); }

.device-card .head {
  padding: 15px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.device-card .name { font-weight: 600; font-size: 16px; }
/* Урок 1258: и в три колонки на 1280 метки сжимали имя до буквы и вылезали за край (scrollWidth 1314):
   шапка переносится всегда, имени — не меньше 150 px, метка не шире карточки */
.device-card .head { flex-wrap: wrap; row-gap: 8px; }
.device-card .head > div { flex: 1 1 150px !important; }
.device-card .head .pill { max-width: 100%; white-space: normal; }
/* Три метки в шапке (отстаёт от сборки, связь, VPN) на телефоне сжимали имя до одной буквы и
   растягивали страницу до 430 px при экране 375 (обход 13.11): имя — на всю строку, метки — ниже */
@media (max-width: 560px) {
  .device-card .head { flex-wrap: wrap; row-gap: 8px; }
  .device-card .head > div { flex: 1 1 calc(100% - 40px) !important; }
  .device-card .head .pill { white-space: normal; max-width: 100%; }
}

.device-card .row {
  padding: 12px 16px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line-soft);
}

.device-card .row:last-child { border-bottom: 0; }

.metric { display: flex; flex-direction: column; gap: 3px; }
.metric .v { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .k { font-size: 11px; color: var(--ink-3); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--wait);
}

.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.off { background: var(--ink-3); }
.dot.err { background: var(--fail); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  font-size: 11px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  color: var(--ink-2);
  white-space: nowrap;
}

/* Пилюля-кнопка («постит для: проект ✕» в «Аккаунтах») брала серый фон кнопки браузера: в тёмной теме светлый текст на нём не читался */
button.pill { background: transparent; }
.pill.ok { border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); color: var(--ok-ink); background: var(--ok-soft); }
.pill.fail { border-color: color-mix(in srgb, var(--fail) 45%, var(--line)); color: var(--fail-ink); background: var(--fail-soft); }
.pill.warn { border-color: color-mix(in srgb, var(--signal) 55%, var(--line)); color: var(--signal-ink); background: var(--signal-soft); }
/* Пометка с длинным текстом (причина, оговорка): переносится, а не тянет страницу вбок на телефоне */
.pill.wrap { white-space: normal; text-align: left; line-height: 1.35; max-width: 100%; overflow-wrap: anywhere; }
/* break-word, а не anywhere: anywhere разрешал колонке сжаться уже слова,
   и «выключен» рвался на «выключе/н» (13.10, вкладки «Аккаунты») */
.pill.project-account-state,
.pill.device-account-state {
  display: inline-block;
  box-sizing: border-box;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: break-word;
}

.alert {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px 12px;
  font-size: 13px;
  border-left: 2px solid var(--signal);
  background: var(--signal-soft);
  color: var(--ink);
}

.alert.error { border-left-color: var(--fail); background: var(--fail-soft); }
/* урок 1143: информационная строка карточки телефона — факт, не тревога */
.alert.info { border-left-color: var(--muted, #8a8f98); background: transparent; }
.alerts-more { cursor: pointer; text-decoration: underline dotted; }
/* Заявки без ответа (урок 1419): заголовок, подсказка и список — столбиком; длинный адрес
   в тексте переносится, а не растягивает страницу вбок (телефон в Telegram, 18.11) */
.alert.cm-warm { display: block; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.alert.cm-warm > * + * { margin-top: 6px; }
.cm-warm-list { margin: 6px 0 0; padding-left: 18px; }
.cm-warm-list li { margin: 4px 0; overflow-wrap: anywhere; word-break: break-word; }

/* ------------------------------------------------------------------ кнопки */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}

.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:disabled { opacity: 0.45; cursor: default; }

.btn.primary {
  background: var(--signal);
  border-color: var(--signal);
  color: var(--on-signal);
  font-weight: 600;
}

.btn.primary:hover:not(:disabled) { background: #E8940C; border-color: #E8940C; }

.btn.ghost { background: none; }
.btn.small { padding: 6px 11px; font-size: 13px; }
.btn.danger { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 40%, var(--line)); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------------ поля */

/* Скрытое остаётся скрытым.
   Браузер прячет [hidden] правилом display:none, но любое наше
   display в классе его перебивает — и поле кода на входе показывалось
   всем, включая тех, кто одноразовые коды не включал. */
[hidden] { display: none !important; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--ink-2); }

/* Поле без type — тоже текстовое: логин и имя в «Пользователях», название
   группы телефонов стояли светлыми полями браузера высотой 24 px (QA-15) */
input:not([type]),
input[type='text'],
input[type='password'],
input[type='number'],
input[type='search'],
/* Почта, ссылка и время — те же поля: без них «Google-аккаунт телефона»,
   ссылка подтверждения поста и время кампании стояли светлыми полями
   браузера посреди тёмного окна */
input[type='email'],
input[type='url'],
input[type='tel'],
input[type='time'],
input[type='date'],
input[type='datetime-local'],
select,
textarea {
  padding: 11px 13px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  width: 100%;
  outline: none;
}

input:focus, select:focus, textarea:focus { border-color: var(--signal); }

textarea { resize: vertical; min-height: 84px; line-height: 1.5; }

/* ------------------------------------------------------------------ таблицы */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--surface); max-width: 100%; }
@media (max-width: 600px) {
  .collection-status table, .collection-status tbody, .collection-status tr, .collection-status td { display: block; width: 100%; min-width: 0; }
  .collection-status thead { display: none; }
  .collection-status tr { padding: 8px; border-bottom: 1px solid var(--line); }
  .collection-status td { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 8px; padding: 6px 0; border: 0; white-space: normal; overflow-wrap: anywhere; }
  .collection-status td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: normal; }
}
/* Таблица-карточки на телефоне (cardTable в app.js): строка — карточка, подпись колонки слева от значения */
@media (max-width: 600px) {
  .card-table, .card-table tbody, .card-table tr, .card-table td { display: block; width: 100%; min-width: 0 !important; max-width: 100%; box-sizing: border-box; }
  .card-table thead { display: none; }
  .card-table tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .card-table tr:last-child { border-bottom: 0; }
  .card-table td, .card-table td.num, .card-table td.nowrap { padding: 4px 0 4px 118px; min-height: 26px; border: 0; white-space: normal; overflow-wrap: anywhere; text-align: left !important; }
  /* Подпись — плавающим блоком слева: длинная («Неудачные попытки за 7 дней») раздвигает строку, а не налезает на соседнюю */
  .card-table td[data-label]::before { content: attr(data-label); float: left; width: 110px; margin-left: -118px; color: var(--ink-3); font: 400 12px/1.4 var(--sans); overflow-wrap: anywhere; opacity: 1; }
  .card-table td::after { content: ''; display: block; clear: both; }
  .card-table td:not([data-label]) { padding-left: 0; }
  .card-table td:first-child { font-weight: 600; }
  /* Пустая ячейка сводки («·» — аккаунтов этой сети нет) в карточке — лишняя строка */
  .card-table td.cell-empty { display: none; }
  .card-table td * { max-width: 100% !important; }
  /* Ссылка в ячейке («открыть») — цель для пальца не ниже 32px: на 375px она была 17px (QA 09.11) */
  .card-table td a { display: inline-block; min-height: 32px; line-height: 32px; }
}
/* Таблица внутри сетки растягивала колонку и страницу: на телефоне у «Репутации»
   появлялась горизонтальная прокрутка. Ячейка сетки не шире своей колонки. */
.grid > *, .panel { min-width: 0; }

table { border-collapse: collapse; width: 100%; font-size: 14px; }

th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--surface);
}

td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
td.num, th.num { font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; }

/* ------------------------------------------------------------------ вкладки */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  padding: 0 var(--gutter);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 10;
}

.tab {
  padding: 12px 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
  font-size: 14px;
}

.tab:hover { color: var(--ink); }
.tab[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--signal); font-weight: 500; }

/* ------------------------------------------------------------------ чат */

.chat-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  height: calc(100vh - 57px);
  min-height: 0;
}

.chat-list {
  border-right: 1px solid var(--line);
  overflow-y: auto;
  background: var(--surface);
}

.chat-entry {
  width: 100%;
  text-align: left;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid var(--line-soft);
  border-left: 2px solid transparent;
  background: none;
  cursor: pointer;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-entry:hover { background: var(--surface-2); }
.chat-entry[aria-current='true'] { background: var(--surface-2); border-left-color: var(--signal); }

.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.chat-head {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
}

.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg { display: flex; gap: 12px; max-width: 780px; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }

.msg .bubble {
  padding: 12px 15px;
  border: 1px solid var(--line);
  background: var(--surface);
  white-space: pre-wrap;
  word-break: break-word;
  min-width: 0;
}

.msg.user .bubble { background: var(--surface-2); border-color: var(--line); }
.msg.action .bubble { background: none; border: 0; border-left: 2px solid var(--line); color: var(--ink-3); font-size: 13px; padding: 4px 0 4px 12px; }
.msg.error .bubble { border-color: color-mix(in srgb, var(--fail) 45%, var(--line)); background: var(--fail-soft); }

.msg .who {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 6px;
}

.composer {
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.composer-row { display: flex; gap: 10px; align-items: flex-end; }
.composer textarea { min-height: 52px; max-height: 220px; }
/* На телефоне скрепка, поле и «Отправить» в одну строку оставляли полю ~130px:
   подсказка в нём ломалась на четыре строки. Поле — во всю ширину, кнопки под ним */
@media (max-width: 480px) {
  /* Пятая вкладка карточки проекта уезжала за край без признака прокрутки (урок 1104) */
  .tabs { flex-wrap: wrap; overflow-x: visible; }
  .composer-row { flex-wrap: wrap; }
  .composer-row textarea { flex: 1 1 100%; order: -1; }
  .composer-row .btn.primary { margin-left: auto; }
}

.attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
}

.attach-preview img, .attach-preview video {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.typing i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--ink-3);
  animation: blink 1.2s infinite;
}

.typing i:nth-child(2) { animation-delay: 0.2s; }
.typing i:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 60%, 100% { opacity: 0.25; }
  30% { opacity: 1; }
}

/* ------------------------------------------------------------------ медиатека */

.media-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}

.media-card {
  border: 1px solid var(--line);
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.media-thumb {
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

/* Кадр целиком, а не середина: у вертикального ролика и баннера надпись
   стоит сверху, и обрезанное превью читалось как обрезанный баннер (29.09) */
.media-thumb img, .media-thumb video { width: 100%; height: 100%; object-fit: contain; }
.video-preview { position: relative; width: 100%; height: 100%; display: grid; place-items: center; }
.video-preview video { position: absolute; inset: 0; background: var(--surface-2); }
.media-meta { padding: 11px 12px; display: flex; flex-direction: column; gap: 7px; }
.media-name { font-size: 13px; font-weight: 500; word-break: break-word; }

.dropzone {
  border: 1px dashed var(--line);
  padding: 26px;
  text-align: center;
  color: var(--ink-3);
  background: var(--surface);
}

.dropzone.hot { border-color: var(--signal); background: var(--signal-soft); color: var(--ink); }

/* ------------------------------------------------------------------ график */

.chart { width: 100%; height: 150px; display: block; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--signal); stroke-width: 2; }
.chart .area { fill: color-mix(in srgb, var(--signal) 14%, transparent); }
.chart .bar { fill: var(--signal); }
.chart .bar.soft { fill: var(--ink-3); }
.chart text { font-family: var(--mono); font-size: 10px; fill: var(--ink-3); }

/* ------------------------------------------------------------------ лента событий */

.feed { display: flex; flex-direction: column; }

.feed-item {
  display: flex;
  gap: 12px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}

.feed-item:last-child { border-bottom: 0; }
/* Длинное слово без пробелов (адрес, почта, ключ) в событии растягивало
   страницу на десятки тысяч пикселей — лента на «Обзоре» и в карточке
   телефона не в прокручиваемой рамке (QA-13) */
.feed-item > :not(time) { min-width: 0; overflow-wrap: anywhere; }
.feed-item time { font-family: var(--mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; }

/* ------------------------------------------------------------------ вход */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-box { width: 100%; max-width: 380px; }
/* Вход кончился посреди работы: вход поверх экрана и его окон, набранное под ним цело */
.login-screen.session-expired {
  position: fixed;
  inset: 0;
  z-index: 2000;
  min-height: 0;
  overflow: auto;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(3px);
}
.login-screen.session-expired .login-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}

/* ------------------------------------------------------------------ служебное */

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 14px;
}

.toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
  max-width: min(400px, calc(100vw - 40px));
}

.toast {
  padding: 12px 15px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
  font-size: 14px;
  animation: rise 0.18s ease-out;
}

.toast.err { border-left: 3px solid var(--fail); }
.toast.ok { border-left: 3px solid var(--ok); }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.modal-host {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 90;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--line);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
}

.modal-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  /* Длинный ник без пробелов в заголовке («Ответить @очень_длинный…») на
     телефоне обрезался краем окна */
  min-width: 0;
  overflow-wrap: anywhere;
}
/* Окно получает фокус само, когда в нём нет ни поля, ни кнопки: рамка тут ни о чём не говорит */
.modal:focus { outline: none; }

/* Составление публикации: в 460px текст поста и проверка не помещаются */
.modal.wide { max-width: 760px; }

.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
/* Длинное окно на телефоне (ответ в личку с цитатой и пояснениями, 390 px):
   кнопка «Отправить» уходила ниже края окна и под нижнюю полосу (QA 17.10) —
   ряд кнопок держится у нижнего края прокручиваемого окна, а окно — в видимой
   высоте экрана с учётом строки браузера */
.modal-foot { position: sticky; bottom: 0; background: var(--surface); }
@media (max-width: 900px) {
  .modal { max-height: calc(100dvh - 40px - env(safe-area-inset-bottom)); }
}

.code-display {
  font-family: var(--mono);
  font-size: 38px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-align: center;
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  user-select: all;
}

.code-display.expired { color: var(--ink-2); font-size: 22px; letter-spacing: 0.04em; user-select: none; }
.expired-note { color: var(--fail); }

.steps { counter-reset: step; display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }

.steps li {
  counter-increment: step;
  display: flex;
  gap: 12px;
  font-size: 14px;
  line-height: 1.5;
}

.steps li::before {
  content: counter(step);
  font-family: var(--mono);
  font-size: 12px;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  color: var(--ink-3);
}

.mobile-nav { display: none; }

/* ------------------------------------------------------------------ телефон и планшет */

@media (max-width: 900px) {
  :root { --gutter: 16px; }

  #app { grid-template-columns: 1fr; }

  .sidebar { display: none; }

  .mobile-nav {
    display: grid;
    grid-auto-flow: column;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface);
    border-top: 1px solid var(--line);
    z-index: 50;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .mobile-nav button {
    border: 0;
    background: none;
    padding: 9px 4px 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--ink-3);
    font-size: 10px;
    cursor: pointer;
  }

  .mobile-nav button[aria-current='true'] { color: var(--signal-ink); }
  .mobile-nav .nav-icon { width: 20px; height: 20px; }
  /* Ждущие комментарии на нижней полосе: число над значком, пусто — не видно */
  .mobile-nav button.has-badge { position: relative; }
  .mobile-nav .m-count {
    position: absolute;
    top: 4px;
    left: calc(50% + 6px);
    min-width: 16px;
    padding: 0 4px;
    border-radius: 8px;
    background: var(--signal-ink);
    color: var(--surface);
    font-family: var(--mono);
    font-size: 10px;
    line-height: 16px;
    text-align: center;
  }
  .mobile-nav .m-count:empty { display: none; }

  .main { padding-bottom: 68px; }

  /* Шапка с фильтром проектов и кнопками на телефоне занимала 250–350 px из
     844 — треть экрана навсегда (QA-16). Навигация — нижняя панель */
  .topbar { padding: 12px var(--gutter); position: static; }
  .topbar h1 { font-size: 19px; }

  .grid { grid-template-columns: 1fr; }

  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-list { border-right: 0; border-bottom: 1px solid var(--line); max-height: 40vh; }
  .chat-layout.talking .chat-list { display: none; }
  .chat-layout:not(.talking) .chat-main { display: none; }
  .chat-main { height: calc(100vh - 57px - 68px); }
  .chat-scroll { padding: 16px var(--gutter); }

  .media-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

  .toast-host { left: 16px; right: 16px; bottom: 76px; max-width: none; }
}

@media (max-width: 560px) {
  .stats .stat { flex: 1 1 45%; }
  .big { font-size: 28px; }
  .msg { max-width: 100%; }
}

/* Fleet controls stay usable on the manager's phone as well as a desktop. */
.fleet-workspace { padding: 20px 28px 0; display: grid; gap: 14px; }
.fleet-filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 10px; }
.fleet-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.fleet-card { min-width: 0; }
.fleet-card .device-card { width: 100%; text-align: left; }
.fleet-choice { display: flex; gap: 10px; align-items: center; padding: 8px 0; cursor: pointer; }
.fleet-choices { max-height: 280px; overflow: auto; display: grid; gap: 8px; margin: 12px 0; }
@media (max-width: 800px) { .fleet-filters { grid-template-columns: 1fr 1fr; } .fleet-workspace { padding: 16px 16px 0; } }
@media (max-width: 480px) { .fleet-filters { grid-template-columns: 1fr; } }

.system-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.system-shortcuts { padding: 0 14px; }
.system-batch { border-top: 1px solid var(--line); padding: 10px 0; margin-top: 10px; overflow-wrap: anywhere; }
.system-layout .bubble { overflow-wrap: anywhere; }
.system-layout select { max-width: 100%; width: 100%; }
.system-controls summary { cursor: pointer; padding: 6px 0 10px; }
@media (max-width: 900px) {
  .system-layout { display: flex; flex-direction: column; height: calc(100dvh - 125px); }
  .system-layout .chat-list { display: block; max-height: 94px; flex-shrink: 0; overflow-y: auto; width: 100%; }
  .system-layout .chat-list .eyebrow { display: none; }
  .chat-layout.system-layout .chat-main { display: flex; min-height: 0; height: auto; flex: 1; }
  .system-layout .chat-scroll { min-height: 90px; }
  .system-layout .chat-head { flex-wrap: wrap; }
  .system-layout .chat-head .tiny { display: none; }
  /* Урок 1186: на 375 px ярлыки уходили за край без признака прокрутки — переносим строкой */
  .system-shortcuts { flex-wrap: wrap; overflow-x: visible; flex-shrink: 0; }
  .system-shortcuts .btn { flex-shrink: 0; }
  .system-controls[open] { max-height: 200px; overflow-y: auto; }
  /* 17.10, 375 px: история ~190 px из 812 — поле и кнопка в одну строку, подсказка под полем скрыта */
  .system-layout .composer-row { flex-wrap: nowrap; }
  .system-layout .composer-row textarea { flex: 1 1 auto; order: 0; min-height: 44px; }
  .system-layout .composer-row .btn.primary { margin-left: 0; }
  .system-layout .system-note { display: none; }
}

/* ------------------------------------------------------------------ стена экранов
   Главный вид «Телефоны»: плитки с живым экраном каждого устройства.
   Три размера — как у ориентира: авто подгоняет, крупные и компактные фиксируют. */
.wall {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.wall.large { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.wall.compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }

.wall-tile {
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: inherit;
  font: inherit;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.wall-tile:hover { border-color: var(--ink-3); }
.wall-tile[aria-current='true'] { border-color: var(--signal); }

/* Экран телефона вертикальный: держим соотношение, чтобы плитки были ровными */
.wall-screen {
  position: relative;
  aspect-ratio: 9 / 19;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.wall-screen img { width: 100%; height: 100%; object-fit: cover; display: block; }
.wall-screen .placeholder { color: var(--ink-3); font-size: 12px; text-align: center; padding: 12px; }
.wall-screen .badge {
  position: absolute; top: 6px; left: 6px;
  display: flex; align-items: center; gap: 5px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  padding: 3px 7px; font-size: 11px;
}
.wall-screen .badge.right { left: auto; right: 6px; }
.wall-foot { padding: 8px 10px; border-top: 1px solid var(--line-soft); }
.wall-foot .name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wall-foot .sub { font-size: 11px; color: var(--ink-3); }
.wall.compact .wall-foot .sub { display: none; }

.view-toggle { display: inline-flex; border: 1px solid var(--line); }
.view-toggle button {
  border: 0; background: none; color: var(--ink-2);
  padding: 7px 12px; cursor: pointer; font-size: 13px;
}
.view-toggle button[aria-pressed='true'] { background: var(--signal-soft); color: var(--signal-ink); font-weight: 500; }

/* ------------------------------------------------------------------ инфографика
   Путь размещения, ритм недели, что сработало и где срывается. Те же приёмы,
   что на экране аналитики в приложении и в PDF: одна полоса — одно число. */
.funnel { display: grid; gap: 14px; }
.funnel-row {
  display: grid;
  grid-template-columns: 150px 1fr 56px;
  align-items: center;
  gap: 10px;
}
.funnel-row .k { font-size: 12px; color: var(--ink-3); }
.funnel-row .v { font-family: var(--mono); font-size: 15px; text-align: right; }
.funnel-row .note {
  grid-column: 2 / 4;
  font-size: 11px;
  color: var(--ink-3);
  margin-top: -6px;
}
.track { background: var(--surface-2); height: 12px; overflow: hidden; }
.track .fill, .track i { display: block; height: 100%; background: var(--signal); transition: width .6s ease; }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; }
.bar-slot { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-stack {
  flex: 1;
  width: 60%;
  max-width: 34px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-bottom: 2px solid var(--surface-2);
}
.bar-stack .seg { background: var(--signal); transition: height .6s ease; }
.bar-stack .seg.soft { background: var(--signal-2); }
.bar-stack .seg.fail { background: var(--fail); }
.bar-label { font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin-top: 6px; }
.legend { display: flex; gap: 16px; margin-top: 12px; font-size: 11px; color: var(--ink-3); }
.legend .dot { display: inline-block; width: 9px; height: 9px; background: var(--signal); margin-right: 5px; }
.legend .dot.soft { background: var(--signal-2); }
.legend .dot.fail { background: var(--fail); }

.top-head { display: flex; align-items: center; gap: 10px; padding-bottom: 6px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.top-head .tiny { letter-spacing: .04em; }

.top-row { margin-bottom: 14px; }
.top-row:last-child { margin-bottom: 0; }
.top-row .head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.top-row .text {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-row a.text { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.top-row a.text:hover { border-bottom-color: var(--signal); }
.top-row .v { font-family: var(--mono); font-size: 13px; }
.top-row .track { height: 6px; }

.fail-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.fail-row:last-child { margin-bottom: 0; }
.fail-row .text { flex: 1; min-width: 0; font-size: 13px; }
.fail-row .small-track { width: 70px; height: 6px; }
.fail-row .small-track i { background: var(--fail); }
.fail-row .v.fail { font-family: var(--mono); color: var(--fail); font-size: 13px; }

@media (max-width: 560px) {
  .funnel-row { grid-template-columns: 110px 1fr 46px; }
  .fail-row .small-track { width: 46px; }
}

/* ------------------------------------------------------------------ динамика показателей
   Ряд замеров по площадке и советы по нему. Столбиков в ряду бывает несколько
   десятков, поэтому они тянутся, а не встают по фиксированной ширине: иначе
   график вылезал бы за экран телефона. */
.trend-figures { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 16px; }
.trend-figure { min-width: 0; }
.trend-figure .v {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.trend-figure .v.up { color: var(--ok); }
.trend-figure .k { font-size: 11px; color: var(--ink-3); margin-top: 7px; }

.trend-bars { display: flex; align-items: flex-end; gap: 3px; height: 96px; }
.trend-bar {
  flex: 1;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  border-bottom: 2px solid var(--surface-2);
}
.trend-bar .seg { background: var(--signal-2); transition: height .6s ease; }
.trend-bar .seg.gain { background: var(--signal); }

.trend-span {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}

.advice { border-top: 1px solid var(--line-soft); padding: 14px 0; }
.advice:first-child { border-top: 0; padding-top: 0; }
.advice:last-child { padding-bottom: 0; }
.advice-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.advice-text { font-size: 14px; line-height: 1.5; }
.advice-ground { font-size: 11px; color: var(--ink-3); line-height: 1.5; margin-top: 6px; }
.advice-actions { margin-top: 10px; }

/* ------------------------------------------------------------------ статистика
   Переключатели разреза, крупные числа по направлениям и выводы. Числа
   считает телефон — панель только раскладывает их по экрану. */

.cut-bar {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 4px 14px;
  margin-bottom: 14px;
}

.cut-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.cut-row:first-child { border-top: 0; }

/* Подпись фиксированной ширины держит ряды кнопок в одной колонке: без
   этого «Проект», «Направление» и «Площадка» начинались в разных местах */
.cut-label { width: 92px; flex: none; }

.cut-chips { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; }

.cut-note { margin-bottom: 16px; line-height: 1.5; }

.stat-figures {
  display: grid;
  gap: 16px 20px;
  grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
}

.stat-figure { min-width: 0; }

.stat-figure .v {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-figure .v.good { color: var(--ok); }
.stat-figure .v.bad { color: var(--fail); }

.stat-figure .k {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 7px;
  line-height: 1.35;
}

.stat-note {
  font-size: 14px;
  line-height: 1.55;
  padding: 12px 0;
  border-top: 1px solid var(--line-soft);
}

.stat-note:first-child { border-top: 0; padding-top: 0; }
.stat-note:last-child { padding-bottom: 0; }

/* Телефон шириной 390: подпись разреза встаёт над кнопками, иначе ряд чипов
   ужимается до одной кнопки в строку и блок вырастает на пол-экрана */
@media (max-width: 560px) {
  .cut-row { align-items: flex-start; gap: 6px; flex-direction: column; }
  .cut-label { width: auto; }
  .stat-figures { grid-template-columns: repeat(auto-fit, minmax(86px, 1fr)); }
}

/* ------------------------------------------------------------------ аудитория
   Кому адресована работа: сегменты, их запросы и площадки. Раздел читают
   глазами, а не считают, поэтому здесь просторнее, чем в статистике. */

.aud-project { padding: 16px; margin-bottom: 14px; }

.aud-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.aud-head h2.section { margin: 0; }

.aud-business {
  font-size: 15px;
  line-height: 1.55;
  margin: 12px 0 16px;
}

.aud-seg { padding: 14px; }

.aud-seg-name { font-weight: 600; font-size: 15px; }

.aud-seg-need {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  margin-top: 4px;
}

.aud-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

/* Подпись фиксированной ширины: «ищем по» и «где они» должны начинаться
   в одной колонке, иначе списки запросов выглядят рваными */
.aud-label { width: 64px; flex: none; }

.aud-chips { display: flex; gap: 6px; flex-wrap: wrap; min-width: 0; flex: 1; }

.aud-chip {
  border: 1px solid var(--line);
  padding: 3px 9px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-2);
}

.aud-chip.soft { border-style: dashed; color: var(--ink-3); }
.aud-channels { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.aud-ch { display: grid; grid-template-columns: 92px 120px 40px minmax(0, 1fr); align-items: center; column-gap: 10px; }
.aud-ch.off { opacity: 0.45; }
.aud-ch-name { font-weight: 600; }
.aud-ch-bar { height: 8px; border-radius: 4px; background: var(--line, #e3e6ea); overflow: hidden; }
.aud-ch-bar > div { height: 100%; background: var(--accent, #2f7d5a); }
.aud-ch.off .aud-ch-bar > div { background: var(--muted, #9aa3ad); }
.aud-ch-why { min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 560px) {
  .aud-row { flex-direction: column; gap: 6px; }
  .aud-label { width: auto; }
  .aud-ch { grid-template-columns: 92px minmax(0, 1fr) 40px; row-gap: 2px; }
  .aud-ch-why { grid-column: 1 / -1; margin-bottom: 6px; }
}

/* Состояние ключей ИИ в карточке телефона: «отвечает» зелёным, беда красным.
   Классы .good/.bad до этого жили только внутри .stat-figure. */
td.good { color: var(--ok); }
td.bad { color: var(--fail); font-weight: 600; }

/* ------------------------------------------------------------------ одноразовые коды
   QR показывается на светлой подложке всегда: на тёмной теме чёрные
   модули на тёмном фоне камера не различает. */

.qr-box {
  background: #ffffff;
  padding: 12px;
  width: max-content;
  margin: 0 auto 16px;
  border: 1px solid var(--line);
}

/* QR шире окна на телефоне (285–325px при 297px места): ужимается, а не обрезается краем окна */
.qr-box { max-width: 100%; box-sizing: border-box; }
.qr-box svg { display: block; max-width: 100%; height: auto; }

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 15px;
  letter-spacing: 1px;
}

.recovery-codes div {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: center;
}

/* ------------------------------------------------------------------ подсказки графиков
   Одна на всю панель (app.js, data-tip). Колонка под указателем светлеет,
   чтобы было видно, к какому столбику относится подсказка. */
.chart-tip {
  position: fixed;
  z-index: 1000;
  display: none;
  max-width: 280px;
  padding: 8px 10px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .28);
  font-size: 12px;
  line-height: 1.45;
  pointer-events: none;
}
.chart-tip .tip-head { font-weight: 600; margin-bottom: 3px; }
.chart-tip .tip-row { font-family: var(--mono); font-variant-numeric: tabular-nums; color: var(--ink-2, var(--ink)); }
.chart .hit { fill: transparent; }
.chart .col { cursor: default; outline: none; }
.chart .col.tip-on .hit, .chart .col:focus-visible .hit { fill: color-mix(in srgb, var(--ink) 7%, transparent); }
.chart .col.tip-on .bar { filter: brightness(1.18); }
.chart .dot { fill: var(--signal); stroke: var(--surface); stroke-width: 1.5; opacity: .55; }
.chart .col.tip-on .dot { opacity: 1; r: 5; }
.bar-slot[data-tip], .trend-bar[data-tip], .funnel-row[data-tip] { cursor: default; outline: none; }
.bar-slot.tip-on, .bar-slot:focus-visible,
.trend-bar.tip-on, .trend-bar:focus-visible { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.funnel-row.tip-on .track .fill { filter: brightness(1.18); }

/* Вопрос агента с вариантами ответа (views/chat.js, ai/ChatAsk.kt) */
.ask-card { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.ask-q { font-weight: 600; margin-bottom: 2px; }
.ask-opt {
  text-align: left; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
  padding: 9px 12px; cursor: pointer; font: inherit; width: 100%;
}
.ask-opt:hover:not([disabled]) { border-color: var(--signal); }
.ask-opt.rec { border-color: var(--signal); }
.ask-opt.picked { background: color-mix(in srgb, var(--signal) 18%, var(--surface-2)); }
.ask-opt[disabled] { opacity: .55; cursor: default; }
.ask-label { font-weight: 500; }
.ask-desc { font-size: 12px; color: var(--ink-3); margin-top: 3px; line-height: 1.4; }

/* ------------------------------------------------------------------ статистика: графики и детализация
   Раздел «Статистика» (views/stats.js, charts.js). Цвета — токены системы:
   янтарь — основной ряд, приглушённый янтарь — второй слой, красный и
   зелёный — только состояния (срыв, негатив / позитив) и всегда с подписью.
   Появление анимировано; «уменьшить движение» в системе его выключает. */

.sx-page { transition: opacity .2s; }
.sx-page.sx-loading { opacity: .6; }
/* QA 03.11: при смене периода 2–5 с на экране стояли числа прежнего отбора без единого слова */
.sx-page.sx-loading::before { content: 'Считаем новый отбор…'; display: block; font-size: 12px; color: var(--muted, #9a9a9a); margin: 0 0 8px; }

.sx-head { margin: -2px 0 16px; display: grid; gap: 4px; }
.sx-reconcile { padding: 8px 10px; border: 1px dashed var(--line); margin-top: 6px; }
.sx-reconcile.warn { border-style: solid; border-color: color-mix(in srgb, var(--warn, #b7791f) 50%, var(--line)); }
.sx-reconcile.ok { border-style: solid; border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); color: var(--ok); }

.sx-kpis {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(auto-fit, minmax(176px, 1fr));
  /* Разделители — у самих карточек: при неполном последнем ряде фон
     сетки не проступает серым прямоугольником */
  gap: 0;
  background: var(--surface);
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
  margin-bottom: 8px;
}
.sx-kpi {
  background: var(--surface);
  padding: 14px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  border: 0;
  color: inherit;
  font: inherit;
  min-width: 0;
  position: relative;
  box-shadow: inset -1px -1px 0 var(--line);
}
.sx-kpi.clickable { cursor: pointer; }
.sx-delta-vs { color: var(--ink-3); }
.sx-page h2.section { flex-wrap: wrap; row-gap: 2px; }
.sx-page h2.section > .tiny { font-weight: 400; }
.sx-kpi.clickable:hover, .sx-kpi.clickable:focus-visible { background: var(--surface-2); outline: none; }
.sx-kpi.clickable::after {
  content: '\2192'; position: absolute; top: 12px; right: 14px; color: var(--ink-3); font-size: 13px;
  opacity: 0; transition: opacity .15s, transform .15s; transform: translateX(-4px);
}
.sx-kpi.clickable:hover::after, .sx-kpi.clickable:focus-visible::after { opacity: 1; transform: none; }
.sx-kpi-label { font-family: var(--mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.sx-kpi-value { font-size: 30px; font-weight: 600; line-height: 1.05; letter-spacing: -0.01em; }
.sx-kpi-sub { font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.sx-delta { font-size: 12px; font-family: var(--mono); font-variant-numeric: tabular-nums; line-height: 1.3; }
.sx-delta.up { color: var(--ok); }
.sx-delta.down { color: var(--fail); }
.sx-delta.flat { color: var(--ink-3); font-family: var(--sans); }
.sx-ghost-card { min-height: 128px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: sx-shimmer 1.2s linear infinite; }
.sx-skeleton { display: grid; gap: 1px; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); background: var(--line); border: 1px solid var(--line); }

.sx-spark-box { margin-top: auto; padding-top: 4px; }
.sx-spark { width: 100%; height: 34px; display: block; overflow: visible; }
.sx-spark-line { fill: none; stroke: var(--signal); stroke-width: 1.6; }
.sx-spark-area { fill: color-mix(in srgb, var(--signal) 13%, transparent); }
.sx-spark-ghost { fill: none; stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; opacity: .7; }
.sx-spark.sx-anim .sx-spark-line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: sx-draw .9s .15s cubic-bezier(.3,.7,.2,1) forwards; }
.sx-spark.sx-anim .sx-spark-area { animation: sx-fade .6s .5s both; }

.sx-charts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.sx-chart-panel .panel-head { flex-wrap: wrap; row-gap: 6px; font-weight: 600; font-size: 14px; }
.sx-chart-panel .panel-head .spacer { flex: 1; }
.sx-chart-panel .panel-body { padding: 10px 12px 12px; }
.sx-fit { width: 100%; min-width: 0; }
.sx-chart { width: auto; height: auto; overflow: visible; }
.sx-chart .grid-line.soft { stroke: var(--line-soft); stroke-dasharray: 2 3; }
.sx-chart text.axis { font-size: 10px; }
.sx-chart .sx-bar { fill: var(--signal); }
.sx-chart .sx-bar.s2 { fill: var(--signal-2); }
.sx-chart .sx-bar.bad { fill: var(--fail); }
.sx-chart .sx-bar.good { fill: var(--ok); }
.sx-chart .sx-bar.neutral { fill: var(--ink-3); }
.sx-chart .sx-ghost { fill: none; stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 4 4; opacity: .75; pointer-events: none; }
.sx-chart .col.pick { cursor: pointer; }
.sx-chart .sx-nodata { fill: color-mix(in srgb, var(--ink-3) 9%, transparent); }
.sx-chart .col.tip-on .sx-bar { filter: brightness(1.15); }
.sx-chart.sx-anim .sx-bar {
  transform-box: fill-box; transform-origin: 50% 100%;
  animation: sx-grow .55s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: calc(var(--i, 0) * 18ms);
}
.sx-chart.sx-anim .sx-ghost { stroke-dasharray: 1; stroke-dashoffset: 1; animation: sx-draw 1s .35s ease-out forwards; }

.sx-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11px; color: var(--ink-3); font-weight: 400; }
.sx-key { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.sx-swatch { width: 9px; height: 9px; display: inline-block; background: var(--signal); }
.sx-swatch.s2 { background: var(--signal-2); }
.sx-swatch.bad { background: var(--fail); }
.sx-swatch.good { background: var(--ok); }
.sx-swatch.neutral { background: var(--ink-3); }
.sx-swatch.sx-ghost-key { background: none; border-top: 2px dashed var(--ink-2); height: 0; width: 14px; }

.sx-table td.sx-cell { white-space: nowrap; }
.sx-meter { display: block; height: 3px; background: var(--line-soft); margin-top: 5px; min-width: 48px; }
.sx-meter-fill { display: block; height: 100%; background: var(--signal); transform-origin: left; animation: sx-growx .7s cubic-bezier(.2,.8,.2,1) both; }
.sx-meter.bad .sx-meter-fill { background: var(--fail); }
.sx-cell-btn { background: none; border: 0; padding: 0; margin: 0; color: inherit; font: inherit; cursor: pointer; text-align: right; width: 100%; display: block; }
.sx-cell-btn:hover span:first-child, .sx-cell-btn:focus-visible span:first-child { color: var(--signal-ink); text-decoration: underline; }
.link-btn { background: none; border: 0; padding: 0; color: var(--signal-ink); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.sx-table tfoot td { font-weight: 600; border-top: 1px solid var(--line); }

.sx-details { margin: 12px 0 0; }
.sx-details summary { cursor: pointer; color: var(--ink-2); padding: 6px 0; }
.sx-details[open] summary { margin-bottom: 8px; }

.sx-projects { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.sx-project .panel-head .spacer { flex: 1; }
.sx-project-name { font-weight: 600; color: var(--ink); text-decoration: none; min-width: 0; overflow-wrap: anywhere; }
.sx-project-name:hover { color: var(--signal-ink); text-decoration: underline; }
.sx-fig-btn { background: none; border: 0; padding: 0; text-align: left; color: inherit; font: inherit; cursor: pointer; }
.sx-fig-btn:disabled { cursor: default; }
.sx-fig-btn:not(:disabled):hover .v { color: var(--signal-ink); }
.sx-share { margin-top: 12px; }
.sx-share .sx-meter { height: 5px; }

.sx-top { display: grid; gap: 0; padding: 4px 16px; }
.sx-top-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.sx-top-row:first-child { border-top: 0; }
.sx-top-rank { color: var(--ink-3); font-size: 13px; }
.sx-top-text { font-size: 13px; line-height: 1.45; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sx-top-num { font-size: 18px; font-weight: 600; text-align: right; line-height: 1.1; }

.sx-items { display: grid; }
.sx-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.sx-item:first-child { border-top: 0; }
.sx-item-main { flex: 1; min-width: 0; }
.sx-item-meta a { color: var(--ink-2); }
.sx-item-text { font-size: 14px; line-height: 1.45; margin: 3px 0 6px; overflow-wrap: anywhere; }
.sx-item-badges { display: flex; flex-wrap: wrap; gap: 6px; }
/* Размещение: аккаунт, язык, аудитория, «под постом»; причина без адреса */
.sx-item-more { margin: 2px 0 6px; line-height: 1.5; overflow-wrap: anywhere; }
.sx-item-more a { color: var(--ink-2); }
.sx-meta-k { color: var(--ink-3); }
.pill.sx-noaddr { white-space: normal; text-align: left; line-height: 1.35; font-family: inherit; letter-spacing: 0; max-width: 100%; overflow-wrap: anywhere; }
.sx-top-link { margin-top: 4px; }
.sx-links { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }
.sx-links .sx-meter { margin-top: 10px; }
.sx-reasons { display: grid; gap: 2px; }
.sx-reason { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; background: none; border: 0; border-top: 1px solid var(--line-soft); padding: 8px 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.sx-reason:first-child { border-top: 0; }
.sx-reason:hover .sx-reason-text { color: var(--signal-ink); text-decoration: underline; }
.sx-reason .sx-meter { grid-column: 1 / -1; margin-top: 2px; height: 4px; }
.sx-reason-text { font-size: 13px; line-height: 1.4; overflow-wrap: anywhere; }
.sx-placements td { vertical-align: top; }
.sx-placements td:nth-child(5) { min-width: 180px; }

.sx-report-head { margin-bottom: 8px; display: grid; gap: 4px; }
.sx-report-title { font-family: var(--display); font-size: 22px; margin: 2px 0; letter-spacing: -0.01em; }

@keyframes sx-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes sx-growx { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes sx-draw { to { stroke-dashoffset: 0; } }
@keyframes sx-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes sx-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  .sx-chart.sx-anim .sx-bar, .sx-meter-fill, .sx-spark.sx-anim .sx-spark-area, .sx-ghost-card { animation: none; }
  .sx-chart.sx-anim .sx-ghost, .sx-spark.sx-anim .sx-spark-line { animation: none; stroke-dashoffset: 0; }
}

@media (max-width: 560px) {
  .sx-kpis, .sx-skeleton { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sx-kpi { padding: 12px 12px 8px; }
  .sx-kpi-value { font-size: 24px; }
  .sx-charts, .sx-projects { grid-template-columns: minmax(0, 1fr); }
  .sx-top-row { grid-template-columns: 18px minmax(0, 1fr) auto; }
  .sx-top-row > .btn { display: none; }
  .sx-item { flex-direction: column; gap: 6px; }
  .sx-links { grid-template-columns: minmax(0, 1fr); }
  /* Переключатели разреза — лентой с прокруткой внутри ряда: четыре ряда
     кнопок в столбик занимали весь первый экран */
  .sx-page .cut-chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; scrollbar-width: none; }
  .sx-page .cut-row { align-items: stretch; }
}

@media print {
  .sidebar, .mobile-nav, .sx-noprint, .toast-host, .chart-tip { display: none !important; }
  #app { display: block; }
  body, .panel, .table-wrap, .sx-kpi { background: #fff !important; color: #000; }
  .sx-report .content { padding: 0; }
  .table-wrap { overflow: visible; border-color: #bbb; }
  h2.section { break-after: avoid; }
  tr, .sx-top-row { break-inside: avoid; }
}

/* Тач-цели на телефоне: кнопки «small» были 30 px в высоту, ссылки-кнопки
   в таблицах «Статистики» (языки, аудитории) — 21 px; пальцем по ним
   промахиваются. На узком экране и сенсоре — не меньше 40 px (QA-13) */
@media (max-width: 900px), (pointer: coarse) {
  .btn, .chip { min-height: 40px; }
  .btn.small { padding-block: 8px; }
  /* «X» (сеть) в строке статистики была целью 9×40 (QA-15) */
  .link-btn { display: inline-flex; align-items: center; min-height: 40px; min-width: 32px; text-align: left; }
  /* Пилюля-кнопка (готовность аккаунта, снятие назначения): 29 px в высоту —
     мимо пальца на 390 px (QA-16) */
  button.pill { display: inline-flex; align-items: center; min-height: 36px; }
  /* Имя телефона в таблице «Статистики» (17 px) и почта в обращениях сайта
     (23 px) — ссылки-строки, по которым промахивался палец */
  a.touch-link { display: inline-flex; align-items: center; min-height: 36px; }
  /* Ссылки-переходы в сводке по проектам и «Открыть ↗» у лучших записей: 16–23 px в высоту */
  .sx-project-name, .sx-top-link a { display: inline-flex; align-items: center; min-height: 40px; }
  .view-toggle button, .sx-cell-btn { min-height: 40px; }
  /* Флажки выбора телефонов были 13×13 — меньше минимума 24×24 */
  /* !important: у флажков в диалогах стоит style="width: auto" — было 13×24 (QA-15) */
  input[type='checkbox'], input[type='radio'] { width: 32px !important; height: 32px; } /* урок 1172: было 24 */
}

/* ------------------------------------------------------------------ автоматизации
   Редактор цепочки слева, песочница и воронка справа; на узком экране — столбиком. */
.au-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); gap: 16px; align-items: start; }
.au-main, .au-side { min-width: 0; }
.au-side { position: sticky; top: 12px; }
.au-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.au-step { border: 1px solid var(--line); background: var(--surface); margin-bottom: 10px; }
.au-step-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.au-step-head select { width: auto; max-width: 240px; }
.au-step-num { font-family: var(--mono); font-size: 12px; min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; background: var(--signal); color: #1a1405; }
.au-step-body { padding: 12px 12px 10px; }
.au-button-row { display: grid; grid-template-columns: minmax(130px, 1.2fr) 92px minmax(140px, 1.3fr) auto auto; gap: 6px; align-items: center; }
.au-qs { display: flex; flex-direction: column; gap: 12px; }
.au-qs-step { display: flex; gap: 12px; align-items: flex-start; }
.au-qs-num { flex: none; width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center; font-family: var(--mono); font-size: 13px; border: 1px solid var(--line); background: var(--surface-2); }
.au-qs-step.done .au-qs-num { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, var(--line)); }
.au-qs-step.done > div:last-child { opacity: .8; }
.au-button-row + .au-button-row { border-top: 1px dashed var(--line); padding-top: 8px; }
.au-chat { display: flex; flex-direction: column; gap: 8px; max-height: 420px; min-height: 160px; overflow-y: auto; padding: 8px; background: var(--surface-2); border: 1px solid var(--line); }
.au-bubble { max-width: 88%; padding: 8px 11px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid var(--line); }
.au-bubble.bot { align-self: flex-start; background: var(--surface); }
.au-bubble.user { align-self: flex-end; background: var(--signal-soft); border-color: color-mix(in srgb, var(--signal) 40%, var(--line)); }
.au-note { align-self: center; font-size: 11px; color: var(--ink-3); text-align: center; max-width: 95%; overflow-wrap: anywhere; }
.au-buttons { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.au-btn { display: block; text-align: center; padding: 6px 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; white-space: normal; }
span.au-btn { cursor: default; }
.au-btn:hover { border-color: var(--signal); }
@media (max-width: 1100px) {
  .au-layout { grid-template-columns: minmax(0, 1fr); }
  .au-side { position: static; }
}
@media (max-width: 560px) {
  .au-button-row { grid-template-columns: 1fr auto; }
  .au-button-row > input, .au-button-row > select { grid-column: 1 / -1; }
  .au-step-head select { max-width: 100%; }
}

/* Динамика по часам и «день недели × час» (charts.js hourBars/heatmap, stats-dynamics.js) */
.sx-dyn-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0 0 12px; }
.sx-dyn-bar .cut-chips { flex-wrap: wrap; }
.sx-chart .sx-daysep { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 2 3; opacity: .55; }
.sx-chart text.sx-axis-day { font-weight: 600; fill: var(--ink-2); }
.sx-chart .sx-bar.est { opacity: .78; }
.sx-est-note { display: inline-flex; align-items: center; gap: 6px; }
.sx-est-note::before { content: '≈'; font-family: var(--mono); color: var(--signal-ink, var(--signal)); font-weight: 600; }
.sx-heat-fit { overflow: hidden; }
.sx-chart .sx-heat { fill: var(--signal); fill-opacity: var(--o, 1); }
.sx-chart .sx-heat.zero { fill: var(--line-soft); fill-opacity: 1; }
.sx-chart .sx-heat.none { fill: none; stroke: var(--line-soft); stroke-dasharray: 2 2; }
.cut-chips.sx-wrap { flex-wrap: wrap; overflow: visible; }
.sx-chart .col.tip-on .sx-heat { stroke: var(--ink); stroke-width: 1.5; }
.sx-chart.sx-anim .sx-heat { animation: sx-heat-in .45s cubic-bezier(.2,.8,.2,1) both; animation-delay: calc(var(--i, 0) * 14ms); transform-box: fill-box; transform-origin: 50% 50%; }
@keyframes sx-heat-in { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }
.sx-heat-scale { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.sx-heat-sw { width: 12px; height: 12px; display: inline-block; background: var(--signal); opacity: var(--o, 1); border-radius: 1.5px; }
.sx-heat-sw.zero { background: var(--line-soft); opacity: 1; }
@media (prefers-reduced-motion: reduce) { .sx-chart.sx-anim .sx-heat { animation: none; } }
/* ---------------------------------------------------------------- карточка записи (web/post-card.js) */
:root { --pc-views: var(--signal); --pc-likes: var(--ok); --pc-comments: #3A6EA5; --pc-shares: #8B5CB5; }
:root[data-theme='dark'] { --pc-comments: #6FA3DC; --pc-shares: #B994E0; }
.pc-open { cursor: pointer; }
tr.pc-open:hover > td, .pc-open:hover { background: var(--surface-2); }
.pc-open:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
.pc-host { position: fixed; inset: 0; z-index: 95; background: rgba(0, 0, 0, .35); display: flex; justify-content: flex-end; animation: pc-fade .16s ease-out both; }
.pc-host.pc-leaving { animation: pc-fade .16s ease-in reverse both; }
.pc-drawer { background: var(--surface); border-left: 1px solid var(--line); width: min(620px, 100%); height: 100%; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; animation: pc-slide .2s cubic-bezier(.2,.8,.2,1) both; }
.pc-head { position: sticky; top: 0; z-index: 1; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.pc-spacer { flex: 1; }
.pc-body { padding: 16px; display: grid; gap: 16px; min-width: 0; }
.pc-loading { padding: 24px 0; }
.pc-title { font-weight: 600; font-size: 17px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.pc-when { font-size: 13px; font-weight: 400; color: var(--ink-3); }
.pc-meta { display: grid; gap: 4px; }
.pc-meta-row { display: grid; grid-template-columns: 84px 1fr; gap: 8px; align-items: baseline; }
.pc-meta-k { color: var(--ink-3); }
.pc-meta-more { margin-top: 2px; }
.pc-text { margin: 0; padding: 10px 12px; border-left: 3px solid var(--line); background: var(--bg); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; max-height: 220px; overflow-y: auto; }
.pc-kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.pc-kpi { background: var(--surface); padding: 10px; display: grid; gap: 2px; align-content: start; min-width: 0; }
.pc-kpi-value { font-size: 22px; font-weight: 600; line-height: 1.1; }
.pc-section { display: grid; gap: 8px; min-width: 0; }
.pc-h { margin: 0; font-size: 14px; font-weight: 600; }
.pc-h-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.pc-sub { margin-top: 4px; }
.pc-keys, .pc-modes { display: flex; flex-wrap: wrap; gap: 6px; }
.pc-key, .pc-mode { font: inherit; font-size: 12px; color: var(--ink-2); background: none; border: 1px solid var(--line); padding: 3px 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 28px; }
.pc-key[aria-pressed='false'] { opacity: .45; text-decoration: line-through; }
.pc-mode[aria-pressed='true'] { color: var(--ink); border-color: var(--signal); background: var(--signal-soft); }
.pc-swatch { width: 10px; height: 3px; display: inline-block; background: currentColor; }
.pc-swatch.pc-views { background: var(--pc-views); }
.pc-swatch.pc-likes { background: var(--pc-likes); }
.pc-swatch.pc-comments { background: var(--pc-comments); }
.pc-swatch.pc-shares { background: var(--pc-shares); }
.sx-ml .sx-ml-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sx-ml .sx-ml-line.pc-views { stroke: var(--pc-views); }
.sx-ml .sx-ml-line.pc-likes { stroke: var(--pc-likes); }
.sx-ml .sx-ml-line.pc-comments { stroke: var(--pc-comments); stroke-dasharray: 5 3; }
.sx-ml .sx-ml-line.pc-shares { stroke: var(--pc-shares); stroke-dasharray: 2 3; }
.sx-ml .sx-ml-dot { fill: var(--surface); stroke-width: 1.5; }
.sx-ml .sx-ml-dot.pc-views { stroke: var(--pc-views); }
.sx-ml .sx-ml-dot.pc-likes { stroke: var(--pc-likes); }
.sx-ml .sx-ml-dot.pc-comments { stroke: var(--pc-comments); }
.sx-ml .sx-ml-dot.pc-shares { stroke: var(--pc-shares); }
.sx-ml .sx-ml-cursor { stroke: var(--ink-3); stroke-width: 1; opacity: 0; }
.sx-ml .col:hover .sx-ml-cursor, .sx-ml .col.tip-on .sx-ml-cursor, .sx-ml .col:focus-visible .sx-ml-cursor { opacity: .6; }
.sx-ml.sx-anim .sx-ml-line { stroke-dashoffset: 0; animation: sx-fade .5s ease-out both; }
.pc-table td, .pc-table th { padding-top: 5px; padding-bottom: 5px; }
.pc-table td:first-child, .pc-table th:first-child { text-align: left; }
.pc-delta { font-size: 11px; font-family: var(--mono); }
.pc-delta.up { color: var(--ok); }
.pc-delta.down { color: var(--fail); }
@keyframes pc-slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pc-fade { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 640px) {
  .pc-drawer { width: 100%; border-left: 0; }
  .pc-body { padding: 12px; }
  .pc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pc-kpi:last-child { grid-column: 1 / -1; }
  .pc-meta-row { grid-template-columns: 72px 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .pc-host, .pc-drawer, .pc-host.pc-leaving { animation: none; }
}
.pc-link { display: inline-block; margin-top: 4px; text-decoration: underline; text-underline-offset: 2px; }

/* ------------------------------------------------------------------ статистика: период, сравнение, сводная таблица
   Свой период и сравнение (web/stats-period.js), «было / стало» и сводная
   таблица телефон × сеть × проект × аккаунт (web/stats-matrix.js). До 560 px
   таблица — карточками: у неё до 16 колонок, и вбок она уезжала бы. */

.sx-period { display: grid; gap: 8px; min-width: 0; flex: 1; }
.sx-range { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.sx-range[hidden] { display: none; }
.sx-range-field { display: grid; gap: 3px; }
.sx-range-field input { width: 158px; padding: 7px 9px; }
.sx-account-pick select { width: auto; max-width: 360px; padding: 7px 9px; }

.sx-compare-box > summary { font-weight: 500; }
.sx-compare td.good { color: var(--ok); font-weight: 500; }
.sx-compare td.bad { color: var(--fail); font-weight: 500; }
.sx-th-sub { font-weight: 400; text-transform: none; letter-spacing: 0; white-space: nowrap; }

.sx-mx { transition: opacity .2s; }
.sx-mx.sx-loading { opacity: .55; }
.sx-mx-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 10px; }
.sx-mx-bar .spacer { flex: 1; }
.sx-mx-bar .chip:disabled { opacity: .55; cursor: default; }
.sx-sort { background: none; border: 0; padding: 0; color: inherit; font: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; white-space: nowrap; }
.sx-sort:hover, .sx-sort.on { color: var(--ink); }
.sx-sort-mark { color: var(--signal-ink); }
.sx-mx-table td { white-space: nowrap; }
.sx-mx-dim { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.sx-mx-toggle { background: none; border: 0; padding: 0; color: var(--ink); font: inherit; cursor: pointer; text-align: left; display: inline-flex; gap: 6px; align-items: baseline; max-width: 100%; }
.sx-mx-toggle:hover { color: var(--signal-ink); }
.sx-mx-caret { color: var(--ink-3); width: 10px; flex: none; }
.sx-mx-row.open td { background: var(--signal-soft); }
.sx-mx-detail td { white-space: normal; background: var(--surface); }
.sx-mx-more { display: grid; gap: 10px; padding: 4px 0; }
.sx-mx-cmp { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.sx-mx-cmp-item { border: 1px solid var(--line-soft); padding: 8px 10px; }
.sx-mx .good { color: var(--ok); }
.sx-mx .bad { color: var(--fail); }
.sx-mx-cards { display: none; gap: 10px; }
.sx-mx-sortsel { display: grid; gap: 4px; }
.sx-mx-sortsel select { padding: 8px 10px; }
.sx-mx-card { padding: 0 12px 12px; }
.sx-mx-card-head { display: flex; width: 100%; gap: 8px; align-items: flex-start; justify-content: space-between; background: none; border: 0; padding: 12px 0 8px; color: var(--ink); font: inherit; text-align: left; cursor: pointer; min-height: 44px; }
.sx-mx-card-title { font-weight: 600; overflow-wrap: anywhere; }
.sx-mx-card-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; }
.sx-mx-kv { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line-soft); padding-top: 5px; }
.sx-mx-card .sx-mx-more { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.sx-mx-total { border-color: var(--ink-3); }

@media (max-width: 560px) {
  .sx-mx-table { display: none; }
  .sx-mx-cards { display: grid; }
  .sx-mx-bar .cut-label { width: auto; }
  .sx-range-field input { width: 100%; }
  .sx-range-field { flex: 1 1 130px; }
  .sx-account-pick { flex-wrap: wrap !important; }
  .sx-account-pick select { max-width: 100%; width: 100%; }
  .sx-compare th, .sx-compare td { padding: 8px 6px; font-size: 12px; }
  .sx-compare .sx-th-sub { white-space: normal; }
}

@media print {
  .sx-mx-cards { display: none !important; }
  .sx-mx-table { display: block !important; }
}

/* «Выгрузить отчёт»: выбор формата (web/report-export.js) */
.export-choices { display: grid; gap: 8px; }
.export-choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left;
  width: 100%; padding: 10px 12px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); cursor: pointer; font: inherit;
}
.export-choice:hover, .export-choice:focus-visible { border-color: var(--ink-2); background: var(--surface-2); }
.export-choice.primary { border-color: var(--signal); box-shadow: inset 3px 0 0 var(--signal); }
.export-choice-title { font-weight: 600; }

/* Ссылка для клиента на отчёт (web/report-links.js) */
.rl-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rl-form select, .rl-form input { flex: 1 1 140px; min-width: 0; }
.rl-form .btn { flex: 0 0 auto; }
.rl-fresh { margin-top: 10px; padding: 10px; border: 1px solid var(--signal); background: var(--signal-soft); color: var(--ink); display: grid; gap: 6px; }
.rl-url-row { display: flex; gap: 8px; }
.rl-url-row .rl-url { flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px; }
.rl-list { margin-top: 10px; display: grid; gap: 6px; }
.rl-item { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 8px 10px; border: 1px solid var(--line-soft); }
.rl-item-main { min-width: 0; }
.rl-off { opacity: 0.6; }
.rl-state.rl-active { color: var(--ok); }
.rl-state.rl-revoked, .rl-state.rl-expired { color: var(--ink-3); }
.export-links { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.export-links h3 { margin: 0 0 6px; font-size: 14px; }

.btn.primary:disabled { filter: grayscale(1); }

/* ------------------------------------------------------------------ комментарии (web/views/comments.js)
   Лента того, что люди пишут нашим аккаунтам: плитки-отборы, карточка записи
   с текстом человека и блоком нашего ответа. Тексты приходят из сети — любой
   длины и без пробелов, поэтому переносы включены везде, где есть чужой текст. */
.cm-tiles { margin-bottom: 14px; }
.cm-tile { border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; min-width: 0; }
.cm-tile:hover { background: var(--surface-2); }
.cm-tile[aria-pressed='true'] { box-shadow: inset 0 -3px 0 var(--signal); }
.cm-tile:focus-visible { outline: 2px solid var(--signal); outline-offset: -2px; }
.cm-loading .cm-list { opacity: .6; transition: opacity .15s; }
.cm-picks { flex: 1 1 auto; align-items: center; }
.cm-picks select { width: auto; flex: 0 1 230px; min-width: 0; max-width: 100%; padding: 7px 10px; font-size: 13px; }
.cm-picks input[type='search'] { flex: 1 1 200px; min-width: 0; max-width: 320px; padding: 7px 10px; font-size: 13px; }
.cm-post-note { margin-bottom: 14px; align-items: center; flex-wrap: wrap; }
.cm-count { margin: 0 0 8px; }
.cm-card { padding: 14px 16px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
/* Горячий сигнал виден в ленте с первого взгляда — янтарной кромкой, как всё, что требует действия */
.cm-card.cm-hot { border-left: 3px solid var(--signal); }
.cm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; min-width: 0; }
.cm-who { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 6px; min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.cm-author { font-weight: 600; }
.cm-arrow { color: var(--ink-3); }
.cm-account { color: var(--ink-2); }
.cm-when { margin-left: auto; white-space: nowrap; }
.cm-meta { overflow-wrap: anywhere; }
.cm-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-text { font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-cut { font-size: 12px; white-space: normal; }
.cm-handler { font-size: 12px; opacity: .85; } /* урок 1171: строкой занята система */
.cm-our { font-size: 13px; color: var(--ink-2); }
.cm-our summary { cursor: pointer; color: var(--ink-3); }
.cm-our-text { margin-top: 6px; padding: 8px 10px; border-left: 2px solid var(--line); background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; }
.cm-links { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.cm-our-post { cursor: pointer; text-decoration: underline; text-underline-offset: 2px; color: var(--ink-2); }
.cm-answer { padding: 10px 12px; border: 1px solid var(--line-soft); border-left: 2px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.cm-answer-ok { border-left-color: var(--ok); background: var(--ok-soft); }
.cm-answer-wait { border-left-color: var(--signal); background: var(--signal-soft); }
.cm-answer-fail { border-left-color: var(--fail); background: var(--fail-soft); }
.cm-answer-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.cm-answer-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.45; }
.cm-draft { margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--line); }
.cm-command { overflow-wrap: anywhere; }
.cm-command.fail { color: var(--fail); }
.cm-actions { margin-top: 2px; }
.cm-more { display: flex; justify-content: center; margin: 14px 0 6px; }
/* Запись из ссылки уведомления — видно, какая именно */
.cm-card.cm-focused { outline: 2px solid var(--signal); outline-offset: 2px; }
.cm-author-role { font-style: italic; }
.cm-form { display: grid; gap: 12px; min-width: 0; }
.cm-form > * { min-width: 0; overflow-wrap: anywhere; }
.cm-queued-note { padding: 8px 10px; border-left: 2px solid var(--signal); background: var(--signal-soft); }
.cm-kept-note { margin-top: 4px; }
.cm-load-error { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.cm-quote { margin: 0; padding: 8px 12px; border-left: 2px solid var(--signal); background: var(--surface-2); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow-y: auto; font-size: 14px; }
.cm-lang-note { color: var(--signal-ink); }
.cm-project-line { margin: 10px 0 0; overflow-wrap: anywhere; }
/* 13.10: подписи раздела — цветом текста, а не линий (контраст от 4,5:1 в светлой теме) */
.cm-arrow, .cm-our summary { color: var(--muted-ink); }
.cm-command.fail, .cm-answer-fail .fail { color: var(--fail-ink); }
/* Ответ мог уйти, а запись не обновилась: не сбой и не ожидание */
.cm-doubt-line { color: var(--signal-ink); }
/* Запись изменилась, пока окно ответа было открыто: отправка закрыта */
.cm-stale-note { padding: 8px 10px; border-left: 2px solid var(--fail); background: var(--fail-soft); }
.cm-stale-note[hidden] { display: none; }
/* Режим «Выбрать»: флажок в шапке карточки и полоса действий над списком */
.cm-pick { display: inline-flex; align-items: center; justify-content: center; flex: none; margin: -6px 0 -6px -6px; padding: 6px; cursor: pointer; }
.cm-pick input { width: 18px !important; height: 18px; margin: 0; cursor: pointer; accent-color: var(--signal); }
.cm-card.cm-picked { outline: 2px solid var(--signal); outline-offset: -2px; background: color-mix(in srgb, var(--signal-soft) 45%, var(--surface)); }
.cm-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 10px; min-width: 0; }
.cm-bulk[hidden] { display: none; }
.cm-bulk-act { position: sticky; top: 0; z-index: 5; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--signal); }
.cm-bulk-count { font-weight: 600; margin-right: 4px; }
.cm-bulk-hint { color: var(--muted-ink); margin-right: 4px; }
.cm-bulk-failed { color: var(--fail-ink); flex-basis: 100%; }
.pc-comments-link { display: inline-block; margin-top: 2px; }
@media (max-width: 720px) {
  /* Длинное имя в списке «Аккаунт»/«Телефон» растягивало список по самой
     длинной строке, и страница на телефоне уезжала вбок (ширина 1043 при 390) */
  .cm-cut .cut-row { min-width: 0; }
  .cm-picks { align-self: stretch; width: 100%; min-width: 0; max-width: 100%; }
  .cm-picks select, .cm-picks input[type='search'] { flex: 1 1 100%; width: 100%; min-width: 0; max-width: 100%; }
}
@media (max-width: 560px) {
  .cm-card { padding: 12px; }
  /* Время уходит на свою строку шапки, а не выталкивает метки за край */
  .cm-when { margin-left: 0; }
  /* Флажок отметки — под палец: цель 44 px */
  .cm-pick { min-width: 44px; min-height: 44px; margin: -10px 0 -10px -10px; }
  .cm-pick input { width: 24px !important; height: 24px; }
  /* Полоса действия на телефоне — одним рядом: число отмеченных уже стоит на кнопке */
  .cm-bulk-act .btn.primary { flex: 1 1 auto; }
  .cm-bulk-count { display: none; }
  .cm-bulk-hint { flex-basis: 100%; }
}

/* ------------------------------------------------------------------ база знаний */

/* Кнопка «?» в шапке каждого экрана: статья об этом экране */
.kb-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; /* урок 1172 (P2-C): цель нажатия не меньше 32 px — было 26 */
  height: 32px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink-2);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  line-height: 1;
}
.kb-help:hover, .kb-help:focus-visible { border-color: var(--signal); color: var(--signal-ink); background: var(--signal-soft); }

.kb-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); align-items: start; min-width: 0; }
.kb-list {
  border-right: 1px solid var(--line);
  background: var(--surface);
  position: sticky;
  top: 57px;
  max-height: calc(100vh - 57px);
  overflow-y: auto;
  min-width: 0;
}
.kb-search { padding: 12px; border-bottom: 1px solid var(--line); }
.kb-search input { width: 100%; min-width: 0; }
.kb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-left: 2px solid transparent;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
}
.kb-item:hover { background: var(--surface-2); color: var(--ink); }
.kb-item[aria-current='true'] { border-left-color: var(--signal); background: var(--signal-soft); color: var(--ink); font-weight: 500; }
.kb-item-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.kb-none { padding: 18px 14px; line-height: 1.5; }
.kb-problems { padding: 12px 14px; color: var(--fail); overflow-wrap: anywhere; }
.kb-problems p { margin: 8px 0 0; color: var(--ink-2); }

.kb-pane { min-width: 0; padding: var(--gutter); }
.kb-center { display: flex; justify-content: center; }
.kb-article { max-width: 860px; min-width: 0; display: flex; flex-direction: column; gap: 14px; overflow-wrap: anywhere; }
.kb-back { display: none; }
.kb-lead h2 { font-family: var(--display); font-size: 22px; letter-spacing: -0.02em; margin: 0 0 10px; }
.kb-summary { font-size: 16px; line-height: 1.55; margin: 0 0 14px; }
.kb-article .btn { text-decoration: none; }

.kb-video { background: #000; border: 1px solid var(--line); aspect-ratio: 16 / 9; width: 100%; }
.kb-video video { display: block; width: 100%; height: 100%; background: #000; }
.kb-video-wait {
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  text-align: center;
}
.kb-video-wait-title { font-family: var(--display); font-size: 17px; color: var(--ink-2); }
.kb-video-note { margin-top: -8px; }

.kb-block h3 { margin: 0; font-size: 15px; font-weight: 600; }
.kb-block .panel-body { line-height: 1.6; }
.kb-block .panel-body > p { margin: 0 0 10px; }
.kb-block .panel-body > p:last-child { margin-bottom: 0; }
.kb-task + .kb-task { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.kb-task h4 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.kb-task ol { margin: 0; padding-left: 22px; }
.kb-task li { margin: 4px 0; }
.kb-pairs { margin: 0; display: grid; grid-template-columns: minmax(120px, 220px) minmax(0, 1fr); gap: 10px 16px; }
.kb-pairs dt { font-weight: 600; min-width: 0; }
.kb-pairs dd { margin: 0; min-width: 0; color: var(--ink-2); }
.kb-faq { border-bottom: 1px solid var(--line-soft); padding: 10px 0; }
.kb-faq:first-child { padding-top: 0; }
.kb-faq:last-child { border-bottom: 0; padding-bottom: 0; }
.kb-faq summary { cursor: pointer; font-weight: 600; }
.kb-faq p { margin: 8px 0 0; color: var(--ink-2); }
.kb-related { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-related .chip { text-decoration: none; white-space: normal; }

@media (max-width: 900px) {
  /* На телефоне — одно из двух: список или статья (как в чате) */
  .kb-layout { grid-template-columns: minmax(0, 1fr); }
  .kb-list { position: static; max-height: none; border-right: 0; }
  .kb-layout.reading .kb-list { display: none; }
  .kb-layout:not(.reading) .kb-pane { display: none; }
  .kb-back { display: inline-block; }
  .kb-item { padding: 14px var(--gutter); }
  .kb-search { padding: 12px var(--gutter); }
}
@media (max-width: 560px) {
  .kb-pairs { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  .kb-pairs dd { margin-bottom: 10px; }
  .kb-pairs dd:last-child { margin-bottom: 0; }
  .kb-lead h2 { font-size: 19px; }
  .kb-lead .btn { width: 100%; justify-content: center; }
}

/* Персонаж проекта (web/mascot-block.js): миниатюры поз на шахматном поле —
   у поз прозрачный фон, и белый персонаж на белой карточке был бы не виден */
.mascot-poses { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.mascot-poses-off { opacity: .45; }
.mascot-pose { margin: 0; width: 96px; text-align: center; }
.mascot-pose-img { width: 96px; height: 120px; border-radius: 10px; border: 1px solid var(--line, rgba(127,127,127,.3)); display: flex; align-items: center; justify-content: center; overflow: hidden;
  background-color: #6b7486; background-image: linear-gradient(45deg, rgba(255,255,255,.08) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.08) 75%), linear-gradient(45deg, rgba(255,255,255,.08) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.08) 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px; }
.mascot-pose-img img { max-width: 88px; max-height: 112px; display: block; }
.mascot-pose-missing { color: #fff; font-size: 12px; }
.mascot-pose figcaption { margin-top: 4px; overflow-wrap: anywhere; }
.mascot-upload { margin-top: 12px; max-width: 420px; }
.mascot-upload select, .mascot-own select { max-width: 100%; }
@media (max-width: 480px) { .mascot-pose, .mascot-pose-img { width: 84px; } .mascot-pose-img { height: 106px; } .mascot-pose-img img { max-width: 76px; max-height: 98px; } }

/* Отборы раздела за кнопкой «Фильтры» на узком экране, числа — сразу под ними (Статистика, 24.10) */
.btn.view-filters-toggle { display: none; }
@media (max-width: 640px) {
  .btn.view-filters-toggle { display: inline-flex; min-height: 40px; margin: 4px 0 8px; }
  .view-filters:not(.open) { display: none; }
  .sx-page { display: flex; flex-direction: column; }
  .sx-page > .sx-controls { order: -2; }
  .sx-page > .sx-kpis { order: -1; }
}

/* Воронка проекта: показы → переходы → события сайта → заявки (урок 1044) */
.conv-funnel { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; }
.conv-step { flex: 1 1 150px; min-width: 0; padding: 10px 12px; border: 1px solid var(--border, rgba(127,127,127,.3)); border-radius: 10px; }
.conv-num { font-size: 26px; font-weight: 700; line-height: 1.1; }
.conv-arrow { align-self: center; opacity: .5; font-size: 18px; }
@media (max-width: 640px) { .conv-arrow { display: none; } .conv-step { flex-basis: 100%; } }

/* Урок 1172 (P2-C): широкая таблица — первая колонка (имя телефона/аккаунта) остаётся на месте при прокрутке вправо.
   Только на ширине таблицы: ниже 600 px таблица и так становится карточками (.card-table). */
@media (min-width: 601px) {
  .sticky-first th:first-child, .sticky-first td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 1px 0 0 var(--line); }
}

/* Воронка заявок (web/lead-funnel-block.js, 18.11): ступени в ряд, на узком экране — 2 в ряд */
.lf-tabs { display: flex; gap: 6px; margin: 4px 0 10px; }
.lf-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.lf-step { border: 1px solid var(--line, #ddd); border-radius: 8px; padding: 8px 10px; min-width: 0; }
.lf-num { font-size: 20px; font-weight: 600; }
.lf-breaks { margin: 4px 0; padding-left: 18px; }
.lf-breaks li { margin-bottom: 6px; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .lf-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [data-lead-funnel] .sx-table th, [data-lead-funnel] .sx-table td { padding-left: 6px; padding-right: 6px; letter-spacing: 0; }
}
