/* Панель службы заботы НЕВПН.
   Визуальный язык — личный кабинет npven.me (репо npven-site, docs/design-system.md):
   те же токены, радиусы и примитивы, переведённые с Tailwind на обычный CSS. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/inter-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/inter-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(fonts/inter-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Цвета — токены nevpn-* из globals.css сайта */
  --orange: #F3651E;
  --orange-light: #FF8A4C;
  --orange-bg: #FFF4EE;
  --purple: #4D1F5C;
  --purple-bg: #F3EDF6;
  --purple-icon: #EDE4F2;
  --dark: #0f172a;
  --text: #1e293b;
  --text-2: #64748b;
  --placeholder: #94a3b8;
  --lilac: #DAD5EC;
  --bg: #F8F4FA;
  --bg-soft: #F3EDF6;
  --border: #e2e8f0;
  --white: #ffffff;

  /* Статусы: зелёный — успех, красный — только настоящая авария, оранжевый — «требует внимания» */
  --green-text: #15803d;
  --green-bg: #f0fdf4;
  --green-border: #bbf7d0;
  --red: #ef4444;
  --red-text: #b91c1c;
  --red-bg: #fef2f2;
  --red-border: #fecaca;
  --amber-text: #9a3412;

  /* Радиусы: --radius: .75rem и шкала из неё, как в Tailwind-конфиге сайта */
  --r-md: .6rem;
  --r-lg: .75rem;
  --r-xl: 1.05rem;
  --r-2xl: 1.35rem;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, .05);
  --shadow-menu: 0 8px 30px rgba(77, 31, 92, .12);
  --shadow-modal: 0 24px 60px rgba(77, 31, 92, .22);
  --ring: 0 0 0 3px rgba(243, 101, 30, .18);

  --sidebar-w: 220px;
  --list-w: 320px;
  --chat-max-w: 760px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--dark);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.hidden { display: none !important; }
button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--orange); }
code { font-family: ui-monospace, 'Geist Mono', SFMono-Regular, Menlo, Consolas, monospace; }

/* Иконки — контур lucide, толщина 1.75 как на сайте */
.icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ============ КНОПКИ — роли и размеры Button из ui/button-variants.ts ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--r-xl);
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .15s, border-color .15s, color .15s, transform .1s;
  user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .icon { width: 16px; height: 16px; }
.btn-h9  { height: 36px; padding: 0 12px; font-size: 12px; border-radius: var(--r-lg); }
.btn-h11 { height: 44px; padding: 0 20px; font-size: 14px; }
.btn-block { width: 100%; }

.btn-brand { background: var(--orange); color: #fff; }
.btn-brand:hover { background: var(--orange-light); }
.btn-line { background: var(--white); color: var(--dark); border-color: var(--border); }
.btn-line:hover { background: var(--bg-soft); }
.btn-danger { background: var(--white); color: var(--text-2); border-color: var(--border); }
.btn-danger:hover { background: var(--red-bg); color: var(--red); border-color: var(--red-border); }

/* Квадратная иконка-кнопка */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--text-2);
  padding: 0;
  text-decoration: none;
  transition: background-color .15s, color .15s, border-color .15s;
}
.icon-btn .icon { width: 16px; height: 16px; }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-btn:hover { background: var(--bg-soft); color: var(--dark); }
.icon-btn-lg { width: 36px; height: 36px; border-radius: var(--r-lg); }
.icon-btn-lg .icon { width: 18px; height: 18px; }

/* Сегмент-контрол — переключатель периода из дашборда метрик */
.segment {
  display: inline-flex; flex-wrap: wrap; gap: 4px;
  background: var(--bg);
  border-radius: var(--r-xl);
  padding: 4px;
}
.segment > button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-lg);
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 500;
  transition: background-color .15s, color .15s, box-shadow .15s;
}
.segment > button .icon { width: 14px; height: 14px; }
.segment > button:hover { color: var(--dark); }
.segment > button.active { background: var(--white); color: var(--dark); box-shadow: var(--shadow-sm); }

/* Поля ввода — Input h-11 rounded-xl, фокус фиолетовой рамкой как в дашборде */
.input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--white);
  color: var(--dark);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--placeholder); }
.input:focus { border-color: var(--orange); box-shadow: var(--ring); }
.input-sm { height: 36px; padding: 0 10px; font-size: 14px; border-radius: var(--r-lg); width: auto; }
select.input {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}
.textarea-flat {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--white);
  color: var(--dark);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea-flat:focus { border-color: var(--orange); box-shadow: var(--ring); }

/* Переключатель — rounded-full, оранжевый во включённом состоянии */
.switch { position: relative; display: inline-flex; align-items: center; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 40px; height: 24px;
  border-radius: 999px;
  background: var(--lilac);
  position: relative;
  transition: background-color .15s;
  flex-shrink: 0;
}
.switch-track::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .2);
  transition: transform .15s;
}
.switch input:checked + .switch-track { background: var(--orange); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }
.switch-inline { gap: 8px; height: 36px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--white); }
.switch-inline .switch-track { width: 32px; height: 18px; }
.switch-inline .switch-track::after { width: 14px; height: 14px; top: 2px; left: 2px; }
.switch-inline input:checked + .switch-track::after { transform: translateX(14px); }
.switch-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.switch-inline:has(input:checked) .switch-label { color: var(--dark); }

/* Карточка — panelVariants(): белая, rounded-2xl, рамка. Одно правило на все белые панели. */
.card, .pf-block {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: 20px;
}

/* Плитка под иконку — IconTile size xs/sm, tone purple */
.icon-tile {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--r-xl);
  background: var(--purple-icon);
  color: var(--purple);
  flex-shrink: 0;
}
.icon-tile .icon { width: 20px; height: 20px; }

/* Бейджи — rounded-lg, xs, semibold */
.badge {
  display: inline-flex; align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-md);
  white-space: nowrap;
  line-height: 1.5;
}
.badge-draft { background: var(--orange-bg); color: var(--orange); }
.badge-manual { background: var(--purple-bg); color: var(--purple); }
.badge-gen { background: var(--bg-soft); color: var(--text-2); font-weight: 500; }
/* Тестовый аккаунт: виден, но тихо — пунктир, серый текст, не спорит с «черновиком» и «ручным» */
.badge-test { background: var(--white); color: var(--text-2); border: 1px dashed var(--placeholder); font-weight: 500; }
/* Человек заблокировал бота: написать ему нельзя — серым, это не призыв к действию */
.badge-blocked { background: var(--bg-soft); color: var(--text-2); font-weight: 500; }

/* Стадии обращения. Живые — фиолетовые, решение — оранжевое (бот действует), проверка — тихая
   (ждём человека), у человека — плотный фиолетовый как прежний «человек», исходы — зелёный/красный. */
.badge-stage { background: var(--purple-bg); color: var(--purple); }
.badge-stage.stage-solving { background: var(--orange-bg); color: var(--orange); }
.badge-stage.stage-check { background: var(--white); color: var(--text-2); border: 1px solid var(--border); }
.badge-stage.stage-escalated { background: var(--purple); color: #fff; }
.badge-stage.stage-resolved { background: var(--green-bg); color: var(--green-text); }
.badge-stage.stage-unresolved { background: var(--red-bg); color: var(--red-text); }

/* Чип факта: «устройство: Android» */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-md);
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--dark);
  font-size: 12px;
  line-height: 1.5;
  max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip-k { color: var(--text-2); }
.chip-k::after { content: ':'; }

/* ============ ВХОД ============ */
.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--bg);
}
.login-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-2xl);
  padding: 32px;
  width: 100%; max-width: 384px;
  display: flex; flex-direction: column; gap: 12px;
}
.login-logo { height: 25px; width: auto; align-self: flex-start; margin-bottom: 12px; }
.login-title { font-size: 24px; font-weight: 700; color: var(--dark); margin: 0; line-height: 1.2; }
.login-sub { margin: 0 0 12px; color: var(--text-2); font-size: 14px; }
.login-error {
  background: var(--red-bg);
  color: #dc2626;
  border-radius: var(--r-xl);
  padding: 12px;
  font-size: 14px;
}

/* ============ КАРКАС ============ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
/* Сводка, поиск и песочница идут без левого списка. Колонку убираем из самого грида:
   если просто спрятать .list-pane, её место займёт контент и вёрстка съедет. */
.app.no-list { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }

/* ============ САЙДБАР — DashboardSidebar кабинета ============ */
.sidebar {
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-height: 0;
}
.sidebar-logo {
  display: flex; align-items: center;
  height: 64px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-logo img { height: 20px; width: auto; display: block; }
.nav-items { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 16px 8px 8px; }
/* Пункт меню — ссылка на хэш раздела (средняя кнопка открывает новую вкладку), «Выйти» — кнопка */
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--r-xl);
  background: transparent;
  color: var(--text-2);
  text-align: left;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background-color .15s, color .15s;
}
.nav-item:hover { background: var(--bg-soft); color: var(--dark); }
.nav-item.active { background: var(--orange-bg); color: var(--orange); }
.nav-item:focus-visible { outline: none; box-shadow: var(--ring); }
.nav-label { white-space: nowrap; }
.sidebar-foot { padding: 8px; border-top: 1px solid var(--border); }
.nav-item.logout:hover { background: var(--red-bg); color: var(--red); }

/* Счётчик неутверждённых на пункте «Диалоги» */
.nav-badge {
  margin-left: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--orange); color: #fff;
  font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
}

/* ============ СПИСОК ============ */
.list-pane {
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0;
}
.list-section { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.list-header {
  height: 64px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  flex-shrink: 0;
}
.list-title { font-size: 16px; font-weight: 700; color: var(--dark); }
.list-header-counter {
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  background: var(--bg);
  border-radius: 999px;
  padding: 2px 10px;
  font-variant-numeric: tabular-nums;
}
.list-header-counter:empty { display: none; }
.list-header-counter.hot { background: var(--orange); color: #fff; }
.list-header-side { display: flex; align-items: center; gap: 8px; }

/* Фильтр списка — заголовок-кнопка с меню: выбранный пункт, его счётчик и стрелка */
.list-filter {
  display: inline-flex; align-items: center; gap: 8px;
  min-width: 0; height: 40px;
  margin-left: -10px; padding: 0 10px;
  border: 0; border-radius: var(--r-lg);
  background: transparent; color: var(--dark);
  transition: background-color .12s;
}
.list-filter:hover, .list-filter[aria-expanded="true"] { background: var(--bg-soft); }
.list-filter:focus-visible { outline: none; box-shadow: var(--ring); }
.list-filter .list-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-filter-chev { width: 16px; height: 16px; color: var(--text-2); transition: transform .15s; }
.list-filter[aria-expanded="true"] .list-filter-chev { transform: rotate(180deg); }
.icon-btn[aria-pressed="true"] { background: var(--orange-bg); border-color: #FBC7A9; color: var(--orange); }

/* Поиск по диалогам: строка под шапкой списка, найденное — в строках списка и в ленте (search.js) */
.list-search {
  display: flex; align-items: center; gap: 8px;
  height: 40px;
  margin: 10px 12px 0; padding: 0 4px 0 12px;
  border: 1px solid var(--border); border-radius: var(--r-xl);
  background: var(--white);
  flex-shrink: 0;
  transition: border-color .15s, box-shadow .15s;
}
.list-search:focus-within { border-color: var(--orange); box-shadow: var(--ring); }
.list-search > .icon { width: 16px; height: 16px; color: var(--text-2); flex-shrink: 0; }
.list-search-input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: none; background: transparent;
  color: var(--dark); font: inherit; font-size: 14px;
}
.list-search-input::placeholder { color: var(--placeholder); }
.list-search-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; padding: 0; flex-shrink: 0;
  border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--text-2);
}
.list-search-close:hover { background: var(--bg-soft); color: var(--dark); }
.list-search-close:focus-visible { outline: none; box-shadow: var(--ring); }
.list-search-close .icon { width: 16px; height: 16px; }
.dialogs-list.is-stale { opacity: .55; transition: opacity .15s; }
.dialog-last.search-snippet {
  white-space: normal;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  line-height: 1.45;
}
.search-who { color: var(--text); font-weight: 500; }
mark.search-mark { background: #FFE2CF; color: var(--dark); border-radius: 3px; padding: 0 1px; }
.dialog-item.active mark.search-mark { background: #FFCBAA; }
.search-fields { color: var(--text-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.search-empty { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.search-note { padding: 8px 12px 4px; font-size: 12px; color: var(--text-2); text-align: center; }
/* Слова запроса в ленте открытого диалога — без правки разметки пузырей (CSS Custom Highlight API) */
::highlight(dialog-search) { background-color: #FFCBAA; color: #0f172a; }
.message.search-hit { animation: search-hit 2.6s ease-out; }
@keyframes search-hit {
  0%, 45% { box-shadow: 0 0 0 3px var(--orange); }
  100% { box-shadow: 0 0 0 3px rgba(243, 101, 30, 0); }
}

.dialogs-list { overflow-y: auto; flex: 1; padding: 8px 8px 12px; }
/* Строка списка — ссылка #conv=<id>: цвет и подчёркивание глобального a здесь не нужны */
.dialog-item {
  width: 100%;
  color: inherit; text-decoration: none;
  border-radius: var(--r-xl);
  padding: 10px 12px;
  margin-bottom: 2px;
  display: flex; flex-direction: column; gap: 4px;
  transition: background-color .12s;
}
.dialog-item:hover { background: var(--bg-soft); }
.dialog-item.active { background: var(--orange-bg); }
.dialog-item:focus-visible { outline: none; box-shadow: var(--ring); }
.dialog-row { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.dialog-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  flex: 1; min-width: 0;
}
.dialog-item.active .dialog-name { color: var(--orange); }
.dialog-time { color: var(--text-2); font-size: 12px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.dialog-last {
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-height: 18px;
}
.dialog-badges { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }
.dialog-row .badge-stage { flex-shrink: 0; font-size: 11px; padding: 1px 6px; }
/* Чей ход: «ждёт вас 23 мин» краснеет после 15 минут — человек с неработающим VPN уже уходит */
.dialog-wait { font-size: 12px; color: var(--text-2); }
.dialog-wait.wait-hot { color: var(--red-text); font-weight: 600; }
.dialog-wait.wait-muted { color: var(--placeholder); }

/* Список раздела «Агент» */
.agent-list { overflow-y: auto; flex: 1; padding: 12px 8px; }
.agent-list-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: var(--r-xl);
  color: var(--dark);
  text-decoration: none;
  padding: 10px 12px;
  text-align: left;
  margin-bottom: 2px;
  transition: background-color .12s;
}
.agent-list-item:hover { background: var(--bg-soft); }
.agent-list-item:focus-visible, .kb-file:focus-visible { outline: none; box-shadow: var(--ring); }
.agent-list-item.active { background: var(--orange-bg); }
.agent-list-item.active .agent-list-title { color: var(--orange); }
.agent-list-icon {
  width: 36px; height: 36px;
  border-radius: var(--r-lg);
  background: var(--purple-icon);
  color: var(--purple);
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.agent-list-icon .icon { width: 18px; height: 18px; }
.agent-list-item.active .agent-list-icon { background: var(--white); color: var(--orange); }
.agent-list-text { min-width: 0; flex: 1; }
.agent-list-title { font-weight: 600; font-size: 14px; }
.agent-list-sub { color: var(--text-2); font-size: 12px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.agent-list-divider {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 12px 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}

.kb-files { display: flex; flex-direction: column; }
.kb-empty { padding: 24px 12px; color: var(--text-2); font-size: 14px; text-align: center; }
.kb-file {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  background: transparent;
  border: 0;
  border-radius: var(--r-lg);
  color: var(--text);
  text-decoration: none;
  padding: 8px 12px;
  text-align: left;
  font-size: 14px;
  transition: background-color .12s;
}
.kb-file:hover { background: var(--bg-soft); }
.kb-file.active { background: var(--orange-bg); color: var(--orange); font-weight: 600; }
.kb-file.off .kb-file-title { opacity: .5; text-decoration: line-through; }
.kb-file-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ КОНТЕНТ ============ */
.content-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.view { display: flex; flex-direction: column; flex: 1; min-height: 0; }

.empty-state {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-2);
  gap: 16px;
  font-size: 14px;
}
.empty-state p { margin: 0; }
.empty-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--purple-icon);
  color: var(--purple);
  display: flex; align-items: center; justify-content: center;
}
.empty-icon .icon { width: 32px; height: 32px; }

.content-header {
  min-height: 64px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.content-header-info { min-width: 0; flex: 1; }
.content-header-name {
  font-weight: 700;
  font-size: 20px;
  line-height: 1.25;
  color: var(--dark);
  margin: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.content-header-meta { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.content-header-meta:empty { display: none; }
.content-header-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; flex-wrap: wrap; }
.back-btn {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin-left: -8px;
  border: 0; border-radius: var(--r-lg); background: transparent; color: var(--text-2); padding: 0;
}
.back-btn:hover { background: var(--bg-soft); color: var(--dark); }
/* Чат, открытый с доски: «назад» ведёт на доску и виден на десктопе тоже */
.chat.from-board .back-btn { display: inline-flex; }

.page-body { flex: 1; min-height: 0; overflow-y: auto; padding: 24px; }

.title-input {
  background: transparent;
  border: 0;
  color: var(--dark);
  font-size: 20px;
  font-weight: 700;
  line-height: 1.25;
  padding: 0;
  width: 100%;
  outline: none;
}
.title-input::placeholder { color: var(--placeholder); font-weight: 500; }
.title-input:focus { color: var(--orange); }

/* Ручной режим — оператор взял диалог на себя */
.mode-btn.manual { background: var(--orange-bg); border-color: var(--orange); color: var(--orange); }

/* ============ ЧАТ ============ */
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.profile-strip {
  padding: 10px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
  display: flex; gap: 6px 16px; flex-wrap: wrap;
  flex-shrink: 0;
}
.profile-strip .field strong { color: var(--dark); font-weight: 600; }
.profile-strip:empty { display: none; }
.profile-strip .field strong.strip-warn { color: var(--orange); }

/* Карточка обращения над полосой подписки: стадия селектом, сводка, чипы фактов */
.ticket-strip { align-items: center; gap: 6px 10px; background: var(--bg-soft); }
/* Селект стадии в цветах её бейджа (.badge-stage): на нём текущая стадия, клик — список, куда переставить */
.ticket-strip .ticket-select {
  height: 30px; width: auto;
  padding: 0 28px 0 10px;
  font-size: 12px; font-weight: 600;
  border-radius: var(--r-md);
  /* Рамка обязательна: фон полосы (--bg-soft) совпадает с --purple-bg, без неё «Новое» и «Диагностика» сливаются */
  border-color: var(--lilac);
  background-color: var(--purple-bg); color: var(--purple);
  background-position: right 8px center;
  cursor: pointer;
}
.ticket-strip .ticket-select.stage-solving { background-color: var(--orange-bg); color: var(--orange); border-color: rgba(243, 101, 30, .3); }
.ticket-strip .ticket-select.stage-check { background-color: var(--white); color: var(--text-2); border-color: var(--border); }
.ticket-strip .ticket-select.stage-escalated {
  background-color: var(--purple); color: #fff; border-color: var(--purple);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
.ticket-strip .ticket-select.stage-resolved { background-color: var(--green-bg); color: var(--green-text); border-color: var(--green-border); }
.ticket-strip .ticket-select.stage-unresolved { background-color: var(--red-bg); color: var(--red-text); border-color: var(--red-border); }
/* После цветов стадий — иначе их рамка перебьёт наведение */
.ticket-strip .ticket-select:hover { border-color: currentColor; }
/* Сам список — обычными цветами: Chrome на Windows красит пункты цветом селекта */
.ticket-strip .ticket-select option { background-color: var(--white); color: var(--dark); }
.ticket-strip .ticket-select option:disabled { color: var(--placeholder); }
.ticket-strip .ticket-select:disabled { opacity: .5; cursor: progress; }
.ticket-summary { color: var(--dark); font-weight: 600; font-size: 13px; }
/* Что делать по причине передачи — рядом с причиной, в строке обращения и на карточке доски */
.ticket-strip .reason-hint { color: var(--purple); font-weight: 500; }
.ticket-history { text-decoration: underline dotted; cursor: help; }
/* «Подробнее / Свернуть» — факты, попытки и полоса подписки (tickets.js: setDetailsOpen) */
.ticket-more {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 8px;
  border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--text-2);
  font-size: 12px; font-weight: 500; white-space: nowrap;
}
.ticket-more:hover { background: rgba(77, 31, 92, .06); color: var(--dark); }
.ticket-more:focus-visible { outline: none; box-shadow: var(--ring); }
.ticket-more .icon { width: 14px; height: 14px; transition: transform .15s; }
.ticket-strip.details-open .ticket-more .icon { transform: rotate(180deg); }
.ticket-details { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ticket-strip:not(.details-open) .ticket-details { display: none; }

.messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 20px max(20px, calc((100% - var(--chat-max-w)) / 2));
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg);
}
.message {
  max-width: 72%;
  padding: 10px 14px;
  border-radius: var(--r-xl);
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.5;
}
.message-user { align-self: flex-start; background: var(--white); border: 1px solid var(--border); color: var(--dark); border-bottom-left-radius: var(--r-md); }
.message-bot { align-self: flex-end; background: var(--purple); color: #fff; border-bottom-right-radius: var(--r-md); }
/* Ответ оператора — светло-оранжевый: рядом с фиолетовым ботом не спутать, чей ответ */
.message-human { align-self: flex-end; background: #FFE8D9; border: 1px solid #FBC7A9; color: var(--dark); border-bottom-right-radius: var(--r-md); }
.message a { color: inherit; text-decoration: underline; }
.message-time { font-size: 12px; opacity: .7; margin-top: 4px; }
.message-bot .message-time { color: rgba(255, 255, 255, .85); }
.message-user .message-time, .message-human .message-time { color: var(--text-2); }

/* Оформление Telegram в пузыре — как его видит человек (format.js: fmtDisplayHtml) */
.message b, .message strong { font-weight: 700; }
.message code, .message pre { font-family: ui-monospace, 'Geist Mono', SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.message code { background: rgba(15, 23, 42, .06); padding: 1px 4px; border-radius: 4px; }
.message pre { margin: 4px 0; padding: 8px 10px; background: rgba(15, 23, 42, .06); border-radius: var(--r-md); white-space: pre-wrap; }
.message pre code { background: none; padding: 0; }
.message blockquote { margin: 2px 0; padding: 2px 0 2px 10px; border-left: 3px solid currentColor; }
.message-bot code, .message-bot pre { background: rgba(255, 255, 255, .16); }
/* Скрытый текст закрашен цветом текста; навёл или сфокусировал — виден */
.tg-spoiler { background: currentColor; border-radius: 4px; transition: background-color .15s; }
.tg-spoiler:hover, .tg-spoiler:focus { background: transparent; }

/* «…» под своим сообщением — то же меню, что правый клик; на тач-экране видна всегда */
.msg-more {
  display: inline-flex; align-items: center; justify-content: center; vertical-align: middle;
  width: 22px; height: 18px; margin-left: 6px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: inherit;
  opacity: 0; transition: opacity .12s, background-color .12s;
}
.msg-more .icon { width: 14px; height: 14px; }
.message:hover .msg-more, .msg-more:focus-visible, .msg-more[aria-expanded="true"] { opacity: 1; }
.msg-more:hover { background: rgba(15, 23, 42, .08); }
.message-bot .msg-more:hover { background: rgba(255, 255, 255, .18); }
.msg-more:focus-visible { outline: none; box-shadow: var(--ring); }
@media (hover: none) { .msg-more { opacity: 1; } }

/* Ручной ответ в пути, не ушедший или с неясной судьбой; своё сообщение, пока идёт правка или удаление */
.message.is-sending, .message.is-busy { opacity: .6; }
.message.is-failed, .message.is-unknown, .message.is-partial { background: var(--red-bg); border-color: var(--red-border); }
.msg-status { display: inline-flex; align-items: center; gap: 4px; }
.msg-status .icon { width: 13px; height: 13px; flex-shrink: 0; }
/* Не ушло: причина строкой, под ней действия; опасный красный — только причина */
.msg-fail-row { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; opacity: 1; }
.msg-fail { color: var(--red-text); align-items: flex-start; }
.msg-fail .icon { margin-top: 3px; }
.msg-actions { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; }
.msg-actions .link-btn { font-size: 12px; }
.message-system {
  align-self: center;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  max-width: 80%;
  text-align: center;
}
/* День ленты: плашка даты липнет к верху, пока день на экране; следующий день её выталкивает */
.day-group { display: flex; flex-direction: column; gap: 8px; }
.date-separator {
  position: sticky; top: 0; z-index: 2;
  align-self: center;
  margin: 8px 0 4px;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--lilac);
  box-shadow: var(--shadow-sm);
  color: var(--purple);
  font-size: 12px;
  font-weight: 500;
}
/* Смена стадии — системная строка между сообщениями (tickets.js: stageEventHtml), в тоне
   .message-system, но без подложки: бейджи стадий на ней бы слились. Узко — «кто · заметка ·
   время» уходит строкой ниже, а длинная причина переносится: на телефоне подсказки title нет. */
.stage-event {
  align-self: center;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 2px 8px;
  max-width: 100%;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}
.stage-event-what { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 4px; }
.stage-event .badge-stage { font-size: 11px; padding: 1px 6px; }
.stage-event-arrow { color: var(--text-2); }
.stage-event-meta { max-width: 100%; text-align: center; overflow-wrap: anywhere; }
.stage-event-meta > span + span::before { content: '·'; margin: 0 4px; }
.stage-event-time { font-variant-numeric: tabular-nums; }
.message img { max-width: 260px; max-height: 180px; border-radius: var(--r-lg); display: block; margin-bottom: 4px; }
/* Скриншот человека: превью в ленте, клик открывает файл целиком в новой вкладке. Высота задана
   заранее: картинка грузится после прокрутки ленты вниз и иначе сдвинула бы низ ленты за край. */
.message-photo { display: block; margin: 2px 0 4px; }
.message-photo img { height: 240px; width: auto; max-width: min(260px, 100%); max-height: none; object-fit: contain; object-position: left; margin-bottom: 0; cursor: zoom-in; }
.message-video { display: block; height: 240px; width: auto; max-width: min(260px, 100%); margin: 2px 0 4px; border-radius: 8px; background: #000; }
.message-photo-desc { font-size: 12px; line-height: 1.4; color: var(--text-2); }
/* Пометки сообщения человека: прежняя версия под текстом, удалённое — приглушённым, пунктиром */
.message-was { font-size: 12px; line-height: 1.4; color: var(--text-2); margin-top: 4px; }
.message.is-user-deleted { opacity: .6; border-style: dashed; }
/* Реакция человека у времени: эмодзи на ступень крупнее подписи, иначе её не разглядеть */
.msg-reaction { font-size: 14px; }

/* Композер: капсула с автоподъёмом, оранжевая круглая кнопка */
.composer {
  flex-shrink: 0;
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--white);
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 22px;
  color: var(--dark);
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.5;
  max-height: 160px;
  overflow-y: hidden;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.composer textarea::placeholder { color: var(--placeholder); }
.composer textarea:focus { border-color: var(--orange); background: var(--white); box-shadow: var(--ring); }
.composer-send {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 0;
  background: var(--orange); color: #fff;
  display: flex; align-items: center; justify-content: center;
  transition: background-color .15s;
}
.composer-send:hover { background: var(--orange-light); }
.composer-send:disabled { opacity: .5; cursor: default; }
.composer-send .icon { width: 20px; height: 20px; stroke-width: 2.2; }
.composer-centered { padding: 12px max(20px, calc((100% - var(--chat-max-w)) / 2)); }

/* Поле ручного ответа: полоса правки, кнопки оформления, само поле — столбиком слева от стрелки */
.composer-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
#send-form .composer-body textarea { flex: none; width: 100%; }
.fmt-bar { display: flex; flex-wrap: wrap; gap: 2px; margin-left: 6px; }
.fmt-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 26px; padding: 0;
  border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--text-2);
  transition: background-color .12s, color .12s;
}
.fmt-btn .icon { width: 16px; height: 16px; }
.fmt-btn:hover { background: var(--bg-soft); color: var(--dark); }
.fmt-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.edit-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 12px;
  border-left: 3px solid var(--orange);
  border-radius: var(--r-md);
  background: var(--orange-bg);
}
.edit-bar > .icon { width: 16px; height: 16px; color: var(--orange); }
.edit-bar-text { flex: 1; min-width: 0; }
.edit-bar-title { font-size: 12px; font-weight: 600; color: var(--orange); }
.edit-bar-quote { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-bar .icon-btn { border: 0; background: transparent; }
.composer.editing textarea { border-color: var(--orange); }
/* Скриншот к ручному ответу: превью над полем, крестик в углу, как в Telegram */
.attach-bar { display: flex; align-items: flex-end; gap: 12px; margin: 8px 0 0 6px; }
.attach-thumb { position: relative; flex-shrink: 0; }
.attach-thumb img {
  display: block; max-width: 220px; max-height: 140px; margin: 0;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--bg);
}
.attach-remove {
  position: absolute; top: -9px; right: -9px;
  width: 24px; height: 24px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--white); border-radius: 50%;
  background: var(--dark); color: #fff;
  transition: background-color .12s;
}
.attach-remove .icon { width: 14px; height: 14px; stroke-width: 2.5; }
.attach-remove:hover { background: var(--red); }
.attach-remove:focus-visible { outline: none; box-shadow: var(--ring); }
.attach-note { font-size: 12px; line-height: 1.4; color: var(--text-2); }
@media (pointer: coarse) { .attach-remove { width: 30px; height: 30px; top: -12px; right: -12px; } }

/* ============ ВСПЛЫВАЮЩЕЕ МЕНЮ — фильтр списка и действия над сообщением (app.js: openMenu) ============ */
.menu {
  position: fixed; z-index: 300;
  min-width: 220px; max-width: min(320px, calc(100vw - 16px));
  max-height: calc(100dvh - 16px); overflow-y: auto;
  padding: 6px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-menu);
}
.menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--r-lg);
  background: transparent; color: var(--dark);
  font-size: 14px; text-align: left;
}
.menu-item:hover:not(:disabled), .menu-item:focus-visible { background: var(--bg-soft); outline: none; }
.menu-item:disabled { color: var(--placeholder); cursor: default; }
.menu-item .icon { width: 16px; height: 16px; color: var(--text-2); }
.menu-item:disabled .icon { color: var(--placeholder); }
.menu-item.danger:not(:disabled) { color: var(--red-text); }
.menu-item.danger:not(:disabled) .icon { color: var(--red); }
.menu-item.danger:hover:not(:disabled), .menu-item.danger:focus-visible { background: var(--red-bg); }
.menu-check { visibility: hidden; }
.menu-item[aria-checked="true"] .menu-check { visibility: visible; color: var(--orange); }
.menu-item[aria-checked="true"] .menu-label { font-weight: 600; }
.menu-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.menu-hint { font-size: 12px; line-height: 1.35; color: var(--text-2); }
.menu-count {
  min-width: 22px; height: 20px; padding: 0 7px;
  border-radius: 999px; background: var(--bg); color: var(--text-2);
  font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.menu-count.hot { background: var(--orange); color: #fff; }
.menu-sep { height: 1px; margin: 6px 4px; background: var(--border); }
@media (pointer: coarse) {
  .menu-item { padding: 12px; }
  .fmt-btn { width: 36px; height: 34px; flex-shrink: 0; }
}
/* Телефон: кнопки оформления — одной строкой с прокруткой вбок, а не двумя рядами поверх ленты */
@media (max-width: 860px) {
  .fmt-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: 0; }
  .fmt-bar::-webkit-scrollbar { display: none; }
}

/* ============ ЧЕРНОВИКИ (режим утверждения) ============ */
/* Карточка живёт прямо в ленте диалога: ответ читается в контексте переписки.
   Оранжевый — валюта внимания, и здесь он по делу: черновик ждёт нажатия. */
.draft-card {
  align-self: stretch;
  border: 1px solid rgba(243, 101, 30, .35);
  background: var(--orange-bg);
  border-radius: var(--r-2xl);
  padding: 14px 16px;
  margin: 6px 0;
  display: flex; flex-direction: column; gap: 10px;
}
.draft-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.draft-card-title { font-weight: 700; font-size: 14px; color: var(--orange); }
.draft-card-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.draft-card-tags .badge { background: var(--white); color: var(--text-2); font-weight: 500; }
.draft-text {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--dark);
  background: var(--white);
  resize: none;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.draft-text:focus { border-color: var(--orange); box-shadow: var(--ring); }
/* Под полем — как черновик увидит человек: те же пузыри, что в ленте (app.js:draftPreviewHtml) */
.draft-preview { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.draft-preview:empty { display: none; }
.draft-preview-title { align-self: flex-start; font-size: 12px; color: var(--text-2); }
.draft-card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.draft-hint { color: var(--text-2); font-size: 12px; margin-left: auto; }
.draft-status { font-size: 12px; color: var(--text-2); }
.draft-status:empty { display: none; }
.draft-status.error { color: var(--red); }

/* ============ РЕДАКТОРЫ (ПРОМТ / СТРАНИЦА БАЗЫ) ============ */
.editor-body { flex: 1; min-height: 0; display: flex; flex-direction: column; background: var(--white); }
.code-textarea {
  flex: 1;
  min-height: 0;
  background: var(--white);
  border: 0;
  color: var(--dark);
  resize: none;
  outline: none;
}
/* Подложка подсветки повторяет геометрию textarea теми же правилами — иначе на другом
   брейкпоинте маркеры съезжают относительно текста. */
.code-textarea, .hl-backdrop {
  padding: 24px 32px;
  font-family: ui-monospace, 'Geist Mono', SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
}
.hl-wrap { position: relative; flex: 1; min-height: 0; display: flex; background: var(--white); }
.hl-wrap > textarea { flex: 1; position: relative; z-index: 1; background: transparent; }
.hl-backdrop {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
  margin: 0; border: 0; z-index: 0; color: transparent;
  white-space: pre-wrap; word-wrap: break-word; overflow-wrap: break-word;
}
.hl-backdrop mark { background: #fde9d9; color: transparent; border-radius: 3px; }

.md-preview {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 32px;
  background: var(--white);
  color: var(--text);
  font-size: 14px;
  line-height: 1.65;
}
.md-preview > :first-child { margin-top: 0; }
.md-preview h1, .md-preview h2, .md-preview h3, .md-preview h4 {
  font-weight: 700; line-height: 1.3; margin: 1.4em 0 .5em; color: var(--dark);
}
.md-preview h1 { font-size: 22px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.md-preview h2 { font-size: 18px; }
.md-preview h3 { font-size: 16px; }
.md-preview h4 { font-size: 14px; color: var(--text-2); }
.md-preview p { margin: .6em 0; }
.md-preview ul, .md-preview ol { margin: .6em 0; padding-left: 24px; }
.md-preview li { margin: .25em 0; }
.md-preview ul li::marker { color: var(--purple); }
.md-preview strong { color: var(--dark); font-weight: 700; }
.md-preview code {
  background: var(--purple-bg); border-radius: 6px;
  padding: 1px 6px;
  font-size: 12px; color: var(--purple);
}
.md-preview pre {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 12px 16px; overflow-x: auto; margin: 1em 0;
}
.md-preview pre code { background: transparent; border: 0; padding: 0; color: var(--text); font-size: 12px; line-height: 1.55; }
.md-preview blockquote {
  margin: 1em 0; padding: 8px 16px; border-left: 3px solid var(--purple);
  color: var(--text-2); background: var(--purple-bg); border-radius: 0 var(--r-lg) var(--r-lg) 0;
}
.md-preview hr { border: 0; border-top: 1px solid var(--border); margin: 1.6em 0; }
.md-preview table { border-collapse: collapse; margin: 1em 0; font-size: 14px; width: 100%; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 6px 12px; text-align: left; }
.md-preview th { background: var(--bg); font-weight: 600; }
.md-preview a { color: var(--orange); text-decoration: underline; }

.marker-legend {
  font-size: 12px; color: var(--text-2);
  padding: 10px 24px;
  line-height: 1.5;
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.marker-legend mark { background: #fde9d9; color: var(--dark); padding: 0 4px; border-radius: 3px; }
.marker-legend code { background: var(--purple-bg); color: var(--purple); padding: 0 5px; border-radius: 4px; font-size: 12px; }

.status-bar {
  padding: 8px 24px; font-size: 12px; color: var(--text-2);
  border-top: 1px solid var(--border); background: var(--white); min-height: 34px;
  flex-shrink: 0;
}
.status-bar.ok, .status-bar.success { color: var(--green-text); }
.status-bar.error { color: var(--red); }

/* ============ НАСТРОЙКИ ============ */
.settings-form { display: flex; flex-direction: column; gap: 16px; }
.settings-form > * { width: 100%; max-width: 720px; }
.setting-block { margin: 0; }
.setting-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 4px; }
.setting-text { display: block; }
.setting-title { display: block; font-weight: 700; font-size: 14px; color: var(--dark); margin-bottom: 2px; }
.setting-sub { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 10px; line-height: 1.5; }
.setting-sub code { background: var(--purple-bg); color: var(--purple); padding: 0 5px; border-radius: 4px; font-size: 12px; }
.setting-row { display: flex; align-items: flex-start; gap: 14px; cursor: pointer; }
.setting-row .switch { margin-top: 1px; }
.setting-row .setting-sub { margin-bottom: 0; }
.setting-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; margin-top: 14px;
}
.setting-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 500; color: var(--text-2); }
.setting-grid .input { height: 40px; }
.setting-block-inner { display: block; margin-top: 14px; }
.setting-title-sm { display: block; font-weight: 600; font-size: 12px; color: var(--text-2); margin: 0 0 6px; }

.wh-grid { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px; }
.wh-row { display: flex; align-items: center; gap: 10px; font-size: 14px; flex-wrap: wrap; }
.wh-row .wh-ch { min-width: 76px; font-weight: 600; color: var(--dark); }
.wh-dash { color: var(--text-2); }

/* Вариант ответа — плитки выбора, выбранная на оранжевой подложке */
.radio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-row label {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  height: 40px; padding: 0 14px; background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-xl); font-size: 14px; font-weight: 500; color: var(--text);
  transition: background-color .15s, border-color .15s, color .15s;
}
.radio-row label:hover { background: var(--bg-soft); }
.radio-row label:has(input:checked) { background: var(--orange-bg); border-color: var(--orange); color: var(--orange); font-weight: 600; }
.radio-row input[type="radio"] { accent-color: var(--orange); margin: 0; }

/* ============ ПЕСОЧНИЦА ============ */
.sandbox-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sandbox-body {
  display: grid; grid-template-columns: minmax(0, 1fr) 360px;
  flex: 1; min-height: 0;
}
.sandbox-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.sandbox-debug {
  background: var(--white); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 16px; font-size: 12px;
}
.sandbox-debug-section { margin-bottom: 16px; }
.sandbox-debug-title {
  font-weight: 600; font-size: 14px;
  color: var(--text-2);
  margin-bottom: 8px;
}
.sandbox-snapshot {
  white-space: pre-wrap; font-family: ui-monospace, 'Geist Mono', SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.45; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-xl); padding: 12px; margin: 0;
  max-height: 40vh; overflow-y: auto;
}
.sandbox-debug .pf-detail { margin-top: 6px; }
/* Стадия до → после одного хода */
.sb-stages { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sb-arrow { color: var(--text-2); font-size: 14px; }

/* ============ АНАЛИТИКА (analytics.js) ============
   Цвета частей итога и «вашей очереди» проверены валидатором dataviz на белом (tmp/analytics/spec.md):
   фиолетовый — бот, оранжевый — вы и больше ничего, красный — ушёл без решения, сиреневый — без итога. */
:root {
  --an-bot: #703384;
  --an-silent: #AA7EC2;
  --an-left: #B91C1C;
  --an-you: #F3651E;
  --an-open: #DAD5EC;
  --an-stuck: #AC430E;
  --an-morning: #D35E2C;
  --an-axis: #cbd5e1;
}
.an-c-bot { fill: var(--an-bot); background: var(--an-bot); }
.an-c-silent { fill: var(--an-silent); background: var(--an-silent); }
.an-c-left { fill: var(--an-left); background: var(--an-left); }
.an-c-you { fill: var(--an-you); background: var(--an-you); }
.an-c-open { fill: var(--an-open); background: var(--an-open); }
.an-c-stuck { fill: var(--an-stuck); background: var(--an-stuck); }
.an-c-morning { fill: var(--an-morning); background: var(--an-morning); }
.an-s-bot { stroke: var(--an-bot); }
.an-s-left { stroke: var(--an-left); }
.an-s-you { stroke: var(--an-you); }

.an-root { display: flex; flex-direction: column; gap: 16px; max-width: 1180px; transition: opacity .15s; }
/* Пересчёт периода: прежняя отрисовка остаётся полупрозрачной до ответа — без «Считаю…» и прыжка */
.an-root.is-stale { opacity: .5; }
.an-loading { margin: 0; }
.an-error {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 10px 14px; border-radius: var(--r-xl);
  background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red-text); font-size: 13px;
}
#analytics-refresh.is-busy .icon { animation: an-spin 1s linear infinite; }
@keyframes an-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { #analytics-refresh.is-busy .icon { animation: none; } }

/* Hero «Вчера» — фиолетовая плашка, как «Касса сегодня» в дашборде метрик кабинета */
.hero {
  background: var(--purple);
  color: #fff;
  border-radius: var(--r-2xl);
  padding: 24px;
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px;
}
.hero-label { font-size: 12px; font-weight: 500; color: rgba(255, 255, 255, .7); }
.hero-value { font-size: 36px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin-top: 8px; }
.hero-hint { font-size: 12px; color: rgba(255, 255, 255, .7); margin-top: 8px; }
.hero-side { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: rgba(255, 255, 255, .7); text-align: right; }
.hero-side b { color: #fff; font-weight: 600; }
/* Тёплым — выше обычного (7,5:1 на фиолетовом), мягким зелёным — ниже (9:1) */
.hero .hero-warn, .hero .hero-warn b { color: #fdba74; }
.hero .an-hero-calm, .hero .an-hero-calm b { color: #86efac; }
.an-hero-main { min-width: 0; }
/* «Сейчас» перенёсся под «Вчера» (узкий компьютер) — остаётся у правого края, а не висит посередине */
.an-hero-side { margin-left: auto; }
.an-hero-figs { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 16px; font-size: 13px; color: rgba(255, 255, 255, .78); }
.an-hero-fig b { font-size: 18px; font-weight: 700; color: #fff; margin-right: 2px; }
.an-hero-fig .an-hero-usual { color: rgba(255, 255, 255, .6); }
.an-hero-now { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: rgba(255, 255, 255, .55); }
.an-now-waiting { font-size: 14px; font-weight: 600; color: #fff; }
.an-now-waiting b { font-size: 18px; font-weight: 700; }
.hero .an-now-waiting.hero-warn b { color: #fdba74; }

/* Строка периода — одна, над всеми секциями; белая полоса, как блок с пресетами в «Метриках» кабинета */
.an-period {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; min-width: 0;
  padding: 8px 12px; background: var(--white); border: 1px solid var(--border); border-radius: var(--r-xl);
}
.an-presets { flex-wrap: nowrap; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.an-presets::-webkit-scrollbar { display: none; }
.an-presets > button { flex-shrink: 0; white-space: nowrap; }
.an-presets > button[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.an-presets > button[aria-disabled="true"]:hover { color: var(--text-2); }
.an-range { display: flex; align-items: center; gap: 10px; }
.an-range-f { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.input.an-date { width: auto; height: 32px; padding: 0 8px; font-size: 12px; border-radius: var(--r-lg); }
.an-period-note { font-size: 12px; color: var(--text-2); }

.an-section { display: flex; flex-direction: column; gap: 12px; margin-top: 8px; }
.an-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.an-h2 { font-size: 16px; font-weight: 700; line-height: 1.3; color: var(--dark); margin: 0; }
.an-h3 { font-size: 14px; font-weight: 700; color: var(--dark); margin: 0; }
.an-section-sub { font-size: 12px; color: var(--text-2); margin: 2px 0 0; }
.an-note { font-size: 12px; line-height: 1.5; color: var(--text-2); margin: 0; max-width: 860px; }
.an-empty, .an-foot { font-size: 12px; color: var(--text-2); margin: 0; }
.an-foot { margin-top: 12px; }

/* Плитки: подпись, крупная цифра (пропорциональные цифры), «k из n», сравнение, подсказка */
.an-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.an-tiles-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card.an-tile { padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.an-tile-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.an-tile-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; color: var(--dark); }
.an-tile-value.an-calm { font-size: 18px; color: var(--green-text); }
.an-tile-sub { font-size: 12px; color: var(--text); }
.an-tile-hint { font-size: 12px; line-height: 1.45; color: var(--text-2); }
.an-cmp { font-size: 12px; font-weight: 600; align-self: flex-start; }
.an-cmp[data-an-tip], .an-tile-sub.an-has-tip { cursor: help; text-decoration: underline dotted rgba(100, 116, 139, .5); text-underline-offset: 3px; }
.an-cmp-good { color: var(--green-text); }
.an-cmp-bad { color: var(--red-text); }
.an-cmp-flat, .an-cmp-none { color: var(--text-2); font-weight: 500; }
.an-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.chip.an-chip { white-space: normal; cursor: help; }
.an-chip b { font-weight: 700; color: var(--dark); margin-left: 2px; }

/* Карточка графика: заголовок, легенда, сам график */
.card.an-card { padding: 20px; min-width: 0; }
.an-card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-bottom: 14px; }
.an-card-note { font-size: 12px; color: var(--text-2); }
.an-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--text-2); }
.an-key { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.an-sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
/* Подложка — область, а не часть столбика: шире и ниже ключа «ещё открыто», с рамкой */
.an-sw.an-sw-fresh { width: 18px; height: 12px; border-radius: 2px; background: var(--purple-bg); box-shadow: inset 0 0 0 1px #d9c9e2; }
.an-sw-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-2); display: inline-block; }
.an-sw-dot.an-sw-hollow { background: transparent; box-shadow: inset 0 0 0 1.5px rgba(100, 116, 139, .6); }
.an-sw-line { width: 14px; height: 2px; border-radius: 1px; background: var(--text-2); display: inline-block; }
.an-sw-band { width: 14px; height: 10px; border-radius: 2px; background: rgba(100, 116, 139, .18); display: inline-block; }
.an-chart { position: relative; width: 100%; min-width: 0; }
.an-chart:focus { outline: none; }
.an-chart:focus-visible { box-shadow: var(--ring); border-radius: var(--r-md); }
.an-svg { display: block; overflow: visible; }
.an-svg text { font-size: 11px; fill: var(--text-2); font-variant-numeric: tabular-nums; }
.an-svg .an-strip-label { font-size: 11px; font-weight: 600; }
.an-grid { stroke: var(--border); stroke-width: 1; shape-rendering: crispEdges; }
.an-base { stroke: var(--an-axis); stroke-width: 1; shape-rendering: crispEdges; }
.an-fresh { fill: var(--purple-bg); }
/* «Ещё открыто» и «обращений» того же сиреневого, что подложка свежих дней: на ней — кольцо цвета карточки */
.an-col-fresh .an-c-open { stroke: #fff; stroke-width: 2; paint-order: stroke; }
.an-cursor { fill: rgba(77, 31, 92, .07); }
.an-hit { fill: transparent; }
.an-cross { stroke: var(--text-2); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.an-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.an-band { opacity: .14; }
.an-whisker { stroke-width: 2; stroke-linecap: round; opacity: .35; }
/* Точка устоявшегося дня — залита цветом серии; полая (свежий день, мало обращений) — тише неё */
.an-dot { stroke: #fff; stroke-width: 2; }
.an-dot-h { fill: #fff; stroke-width: 1.5; stroke-opacity: .5; }
.an-shares { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px 20px; }
/* Заголовок в две строки у одного из трёх — графики всё равно на одной высоте: прижаты к низу ячейки */
.an-share { min-width: 0; display: flex; flex-direction: column; }
.an-share > .an-chart { margin-top: auto; }
.an-share-title { font-size: 13px; font-weight: 600; color: var(--dark); margin-bottom: 6px; }
.an-share-title span { font-weight: 500; color: var(--text-2); }
.an-pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; align-items: start; }
.an-tile .an-chart { margin-top: 2px; }

/* «Почему ушло к вам»: полосы корзин, прошлый период серым числом */
.an-reasons { display: flex; flex-direction: column; gap: 10px; }
.an-reason { display: grid; grid-template-columns: minmax(0, 1fr) minmax(120px, 44%); gap: 4px 12px; align-items: center; font-size: 13px; }
.an-reason-label { color: var(--text); font-weight: 500; min-width: 0; }
.an-flag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--bg); color: var(--text-2); font-size: 11px; font-weight: 600; white-space: nowrap; }
.an-reason-bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.an-bar-track { flex: 1; min-width: 24px; height: 10px; }
.an-bar-fill { display: block; height: 100%; min-width: 2px; background: var(--an-you); border-radius: 0 4px 4px 0; }
.an-reason-n { min-width: 24px; text-align: right; font-weight: 700; color: var(--dark); font-variant-numeric: tabular-nums; }
.an-reason-prev { min-width: 64px; font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.an-tail {
  list-style: none; margin: -2px 0 2px; padding: 2px 0 2px 12px; border-left: 2px solid var(--border);
  display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--text-2);
}
.an-tail li { overflow-wrap: anywhere; }
.an-tail b { color: var(--dark); font-weight: 600; white-space: nowrap; }

/* Таблицы: «Где бот не справляется» и «Все числа по дням» */
.an-table-wrap { max-width: 100%; overflow-x: auto; }
.an-table { width: 100%; border-collapse: collapse; font-size: 13px; }
/* Справа у ячейки 8 px, у последней — 0: «Все числа по дням» (19 колонок) влезают в карточку на 1440 px
   и с видимой полосой прокрутки Windows */
.an-table th {
  text-align: left; font-weight: 500; color: var(--text-2); font-size: 12px;
  padding: 0 8px 8px 0; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: bottom;
}
.an-table td { padding: 7px 8px 7px 0; border-bottom: 1px solid var(--border); vertical-align: middle; font-variant-numeric: tabular-nums; }
.an-table tbody tr > :last-child, .an-table thead tr:first-child > :last-child { padding-right: 0; }
.an-table tbody tr:last-child td, .an-table tbody tr:last-child th { border-bottom: 0; }
.an-table .num { text-align: right; }
.an-type { color: var(--text); font-weight: 500; min-width: 130px; }
.an-share-cell { display: flex; flex-direction: column; gap: 4px; min-width: 130px; }
.an-mini { display: flex; gap: 2px; height: 8px; width: 100%; }
.an-mini > span { flex-basis: 0; min-width: 2px; height: 100%; }
.an-mini > span:first-child { border-radius: 3px 0 0 3px; }
.an-mini > span:last-child { border-radius: 0 3px 3px 0; }
.an-mini > span:only-child { border-radius: 3px; }
.an-mini-t, .an-mini-x { font-size: 12px; color: var(--text-2); white-space: nowrap; }
/* «к вам · без решения» под полосой — только на телефоне, где эти две колонки скрыты */
.an-mini-x { display: none; }
/* Заголовки чисел — в две строки: таблица влезает в половину ряда на узком компьютере */
.an-types thead th.num { white-space: normal; min-width: 64px; }
.an-types tbody tr:hover td { background: var(--bg-soft); }
/* Тип закреплён, когда таблица на телефоне листается вбок */
.an-types .an-type, .an-types thead th:first-child { position: sticky; left: 0; z-index: 1; background: var(--white); }
.an-types-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 12px; }
.link-btn.an-more { color: var(--text-2); }
.link-btn.an-more:hover { color: var(--dark); }

.an-days > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; cursor: pointer; list-style: none; }
.an-days > summary::-webkit-details-marker { display: none; }
.an-chev { width: 18px; height: 18px; color: var(--text-2); transform: rotate(-90deg); transition: transform .15s; }
.an-days[open] .an-chev { transform: none; }
.an-days[open] > summary { margin-bottom: 14px; }
.an-daytable th, .an-daytable td { white-space: nowrap; }
/* Заголовки колонок — в две строки, чтобы 19 колонок влезали в карточку на компьютере */
.an-daytable thead th { background: var(--white); white-space: normal; min-width: 36px; max-width: 84px; line-height: 1.3; }
.an-daytable thead th.an-stick { min-width: 0; }
.an-daytable .an-gstart { border-left: 1px solid var(--border); padding-left: 8px; }
.an-daytable .an-group { text-align: center; color: var(--dark); font-weight: 600; border-bottom-color: var(--an-axis); }
.an-daytable tbody th { text-align: left; font-weight: 600; color: var(--dark); font-size: 13px; padding: 7px 8px 7px 0; border-bottom: 1px solid var(--border); }
/* Дата закреплена при прокрутке таблицы вбок */
.an-daytable .an-stick { position: sticky; left: 0; z-index: 1; background: var(--white); }
.an-daytable .an-row-fresh td, .an-daytable .an-row-fresh .an-stick { background: var(--purple-bg); }
.an-fresh-dot { display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--an-silent); vertical-align: middle; }

/* Подсказка по наведению и касанию — одна на страницу, вне прокрутки раздела */
.an-tip {
  position: fixed; z-index: 70; pointer-events: none;
  max-width: 320px; padding: 8px 12px;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-menu);
  font-size: 12px; line-height: 1.45; color: var(--text-2);
}
.an-tip-h { font-weight: 700; color: var(--dark); margin-bottom: 4px; }
.an-tip-r { display: flex; align-items: baseline; gap: 6px; }
.an-tip-r b { color: var(--dark); font-weight: 700; font-variant-numeric: tabular-nums; }
.an-tip-r span { color: var(--text); }
.an-tk { flex: 0 0 10px; height: 3px; border-radius: 2px; align-self: center; }
.an-tip-sub { display: block; padding-left: 16px; color: var(--text-2); }
.an-tip-note { margin-top: 4px; color: var(--purple); font-weight: 600; }
/* Подсказка выкаток шире: строки subject — темы коммитов, им тесно в 320 px */
.an-tip:has(.an-tip-rels) { max-width: 420px; }
.an-tip-rels .an-tip-sub { overflow-wrap: anywhere; }
.an-tip .an-tip-rel { display: flex; align-items: center; gap: 4px; }
.an-tip .an-tip-rel b { margin-left: 2px; }

/* Выкатки: значки под осью дней «Чем кончились» и «Долей». Фигура различает вид (код — квадрат, ядро —
   ромб, база знаний — треугольник), цвет один — текста, не серии; на нахлёсте — кольцо цвета карточки */
.an-rel { fill: var(--text-2); stroke: var(--white); stroke-width: 1.5; paint-order: stroke; }
.an-rel-hit { cursor: pointer; }
.an-rel-ic { display: inline-block; flex-shrink: 0; width: 10px; height: 10px; overflow: visible; vertical-align: -1px; }
.an-rel-ic .an-rel { stroke: none; }
.an-rel-ic + .an-rel-ic { margin-left: 1px; }
.an-keys { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 0; }
.an-rel-key .an-key { gap: 4px; }
/* Справа без отрицательного отступа: колонка последняя, без поля справа — кнопка вылезла бы за карточку */
.an-rel-btn {
  display: inline-flex; align-items: center; gap: 3px; padding: 2px 4px; margin: -2px 0 -2px -4px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font: inherit; cursor: pointer;
}
.an-rel-btn span { margin-left: 2px; color: var(--dark); font-variant-numeric: tabular-nums; }
.an-rel-btn:hover { background: var(--bg-soft); }
.an-rel-btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* «До и после выкатки» — плашка над плитками бота */
.an-ba {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 12px 16px; border-radius: var(--r-xl); background: var(--purple-bg); border: 1px solid #d9c9e2;
  font-size: 13px; line-height: 1.45; color: var(--text);
}
.an-ba-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 360px; }
.an-ba b { color: var(--dark); }
.an-ba-sub { color: var(--text-2); font-size: 12px; }
.an-ba-mix { color: var(--purple); font-weight: 600; font-size: 12px; }

/* Число → «эти диалоги»: ссылка без цвета ссылки, подчёркивание — на наведении */
.an-link { color: inherit; text-decoration: none; border-radius: 4px; cursor: pointer; }
.an-link:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.an-link:focus-visible { outline: none; box-shadow: var(--ring); }
a.an-tile-value { align-self: flex-start; }
a.an-tile-value:hover { color: var(--purple); text-decoration-thickness: 2px; text-underline-offset: 5px; }
.hero .an-link:hover { text-decoration-color: rgba(255, 255, 255, .7); }
.hero .an-link:focus-visible { box-shadow: 0 0 0 2px rgba(255, 255, 255, .8); }
.an-reason.an-link-row { color: inherit; text-decoration: none; border-radius: 6px; margin: -3px -6px; padding: 3px 6px; cursor: pointer; }
.an-reason.an-link-row:hover { background: var(--bg-soft); }
.an-reason.an-link-row:hover .an-reason-label { text-decoration: underline; text-underline-offset: 3px; }
.an-reason.an-link-row:focus-visible { outline: none; box-shadow: var(--ring); }
.an-daytable .an-link:hover { color: var(--purple); }

/* Выборка из «Аналитики» в списке «Диалогов»: плашка над строками, крестик снимает выборку */
.an-sample-bar {
  position: sticky; top: -8px; z-index: 2;
  display: flex; align-items: flex-start; gap: 6px;
  margin: -8px -8px 6px; padding: 10px 8px 10px 14px;
  background: var(--purple-bg); border-bottom: 1px solid #d9c9e2;
  font-size: 13px; line-height: 1.4; color: var(--dark);
}
.an-sample-text { flex: 1; min-width: 0; padding-top: 4px; }
.an-sample-close {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--r-md);
  background: transparent; color: var(--text-2);
}
.an-sample-close:hover { background: var(--white); color: var(--dark); }
.an-sample-close:focus-visible { outline: none; box-shadow: var(--ring); }
.an-sample-close .icon { width: 16px; height: 16px; }

@media (max-width: 1180px) {
  .an-tiles:not(.an-tiles-3) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .an-pair { grid-template-columns: minmax(0, 1fr); }
}

/* ============ ПОИСК ЧЕЛОВЕКА ============ */
.lookup-body > * { max-width: 920px; }
.lookup-form { display: flex; flex-wrap: wrap; gap: 10px; }
.lookup-input { flex: 1 1 320px; }
.lookup-hint { flex-basis: 100%; margin: 0; }
.lookup-result { margin-top: 16px; display: flex; flex-direction: column; gap: 12px; }
.lookup-result:empty { display: none; }
.lookup-found {
  font-size: 14px;
  color: var(--text-2);
  padding: 0 4px;
}

/* ============ ОКНО «О ЧЕЛОВЕКЕ» ============ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  z-index: 200;
}
.modal {
  background: var(--bg);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-modal);
  width: 100%; max-width: 640px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-weight: 700; font-size: 18px; color: var(--dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.modal-actions { display: flex; gap: 8px; flex-shrink: 0; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }

/* Блоки карточки — белые панели; заголовок как h2 карточки кабинета, с плиткой-иконкой (IconTile xs) */
.pf-block { padding: 16px 18px; }
.pf-block-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600;
  color: var(--dark); margin-bottom: 12px;
}
.pf-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--r-md);
  background: var(--purple-icon);
  color: var(--purple);
  flex-shrink: 0;
}
.pf-icon .icon { width: 15px; height: 15px; }
.pf-row { display: flex; gap: 12px; padding: 4px 0; font-size: 14px; }
.pf-label { color: var(--text-2); flex: 0 0 42%; }
.pf-value { color: var(--dark); font-weight: 500; word-break: break-word; }
.pf-detail { color: var(--text-2); font-size: 12px; line-height: 1.5; margin: 8px 0 0; }
.pf-empty p { margin: 0 0 6px; font-size: 14px; color: var(--dark); }

/* Тревожные строки — то, что объясняет «оплатил, а не работает» */
.pf-alerts { display: flex; flex-direction: column; gap: 8px; background: transparent; border: 0; padding: 0; }
.pf-alert {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--orange-bg);
  border: 1px solid rgba(243, 101, 30, .35);
  color: var(--amber-text);
  border-radius: var(--r-xl);
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.45;
}
.pf-alert .icon { width: 18px; height: 18px; margin-top: 1px; color: var(--orange); }

/* Таблицы внутри карточки: устройства, транзакции, история подписок */
.mini-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mini-table th {
  text-align: left; font-weight: 500; color: var(--text-2);
  font-size: 12px; padding: 0 10px 6px 0; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.mini-table td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--border); vertical-align: top; }
.mini-table tr:last-child td { border-bottom: none; }
/* Статус платежа виден цветом: отменённые не должны читаться как успешные */
.mini-table tr.tx-ok td:nth-child(3) { color: var(--green-text); font-weight: 600; }
.mini-table tr.tx-fail td:nth-child(3) { color: var(--text-2); }
.mini-table tr.tx-pending td:nth-child(3) { color: var(--orange); font-weight: 600; }
.mini-table tr.sub-current td { font-weight: 600; }
.mini-table td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mini-table tr.tx-test td { color: var(--text-2); font-style: italic; }

/* ============ ДЕЙСТВИЯ НАД ПОДПИСКОЙ (actions.js) ============ */
.pf-actions .act-group { display: flex; flex-direction: column; gap: 6px; padding: 6px 0; }
.pf-actions .act-group + .act-group { border-top: 1px solid var(--border); }
.act-group-label { font-size: 12px; color: var(--text-2); }
.act-group-btns { display: flex; flex-wrap: wrap; gap: 8px; }
/* Кнопки действий — тонированные, чтобы читались как кнопки, а не сливались с карточкой:
   обычные — фиолетовая плашка, при наведении заливка; опасные — красная; главная — оранжевая */
.act-btn.btn-line { background: var(--purple-bg); color: var(--purple); border-color: transparent; }
.act-btn.btn-line:hover { background: var(--purple); color: #fff; }
.act-btn.btn-danger { background: var(--red-bg); color: var(--red-text); border-color: transparent; }
.act-btn.btn-danger:hover { background: var(--red); color: #fff; border-color: transparent; }
.act-btn.btn-brand { box-shadow: 0 1px 2px rgba(243, 101, 30, .25); }
.act-btn-xs { height: 28px; padding: 0 10px; font-size: 12px; border-radius: var(--r-md); }
.mini-table td.act-cell { text-align: right; white-space: nowrap; padding-right: 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--orange); font: inherit; font-size: 12px; cursor: pointer; text-decoration: underline; }

/* Окно действия живёт поверх карточки «О человеке», оба видны */
.modal-backdrop-top { z-index: 210; }
.modal-sm { max-width: 520px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 20px;
  background: var(--white);
  border-top: 1px solid var(--border);
}
.act-body { gap: 14px; }
.act-target { font-size: 14px; color: var(--text-2); }
.act-target b { color: var(--dark); }
.act-fields { display: flex; flex-direction: column; gap: 12px; }
.act-fields:empty { display: none; }
.act-field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.act-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.act-current { font-weight: 400; }
.act-field .input { width: 100%; }
.act-inline { display: flex; gap: 8px; align-items: center; }
.act-inline .input { flex: 1 1 auto; min-width: 0; }
.act-inline .act-limit-val { flex: 0 0 120px; }
.act-hint { margin: -4px 0 0; }
.act-check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--dark); cursor: pointer; line-height: 1.45; }
.act-check input { margin: 3px 0 0; accent-color: var(--orange); flex-shrink: 0; }
.act-static { font-size: 14px; color: var(--dark); }
.act-web-result { margin: 0; }
.act-web-result:empty { display: none; }

.act-preview {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--dark);
}
.act-preview-danger { margin-top: 6px; font-size: 12px; color: var(--amber-text); }
.act-preview-confirm { border-color: var(--orange); box-shadow: var(--ring); }
.act-preview-confirm .act-preview-danger::before { content: 'Проверьте и нажмите ещё раз. '; font-weight: 600; }
.btn-confirm { background: var(--red); }
.btn-confirm:hover { background: var(--red-text); }

.act-error {
  background: var(--red-bg); border: 1px solid var(--red-border); color: var(--red-text);
  border-radius: var(--r-xl); padding: 10px 14px; font-size: 14px; line-height: 1.45;
}
.act-warn {
  background: var(--orange-bg); border: 1px solid rgba(243, 101, 30, .35); color: var(--amber-text);
  border-radius: var(--r-xl); padding: 10px 14px; font-size: 14px; line-height: 1.45; margin-top: 8px;
}
.act-result { display: flex; flex-direction: column; gap: 10px; }
.act-ok { font-weight: 600; color: var(--green-text); font-size: 14px; }
.act-changed td { padding: 6px 8px 6px 0; }
.act-changed td:first-child { color: var(--text-2); }
.act-changed td.act-arrow { color: var(--text-2); padding: 6px 8px; }
.act-details { font-size: 14px; line-height: 1.5; color: var(--dark); }
.act-raw summary { font-size: 12px; color: var(--text-2); cursor: pointer; }
.act-raw pre { font-size: 12px; white-space: pre-wrap; word-break: break-word; background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 8px 10px; margin: 6px 0 0; }

/* Журнал партнёра внизу карточки */
.act-log-table td { font-size: 13px; }
.act-log-err { color: var(--red-text); }

/* ============ ДОСКА (board.js) ============ */
/* Колонки фиксированной ширины в горизонтальной ленте: карточка никогда не ужимается, на ноутбуке
   доска скроллится вбок. Свёрнутая колонка — полоска 40px, она же принимает брошенную карточку. */
.board {
  flex: 1; min-height: 0;
  display: flex; align-items: stretch; gap: 10px;
  overflow-x: auto; overflow-y: hidden;
  padding: 20px;
}
/* Ширина резиновая: четыре рабочие колонки и четыре полоски укладываются в 1440px без скролла
   (1440 − 220 сайдбар − 40 поля − 4×40 полоски − 7×10 зазоры = 950 → 237 на колонку). Развернул пятую —
   лента скроллится вбок, карточка уже 236px не ужимается. На широком экране колонка растёт до 340. */
.board-col {
  flex: 1 1 236px; min-width: 236px; max-width: 340px;
  display: flex; flex-direction: column; min-height: 0;
  background: var(--bg-soft);
  border: 1px solid transparent;
  border-radius: var(--r-2xl);
  transition: opacity .15s, border-color .15s, background-color .15s;
}
.board-col-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 10px 8px 12px;
  border: 0; background: transparent; color: var(--dark); text-align: left;
  border-radius: var(--r-2xl) var(--r-2xl) 0 0;
  flex-shrink: 0;
}
.board-col-head:hover { background: rgba(77, 31, 92, .05); }
.board-col-head:focus-visible { outline: none; box-shadow: var(--ring); }
.board-col-title { flex: 1; min-width: 0; display: flex; }
.board-col-vtitle { display: none; }
.board-col-count {
  font-size: 12px; font-weight: 600; color: var(--text-2);
  font-variant-numeric: tabular-nums; line-height: 20px; min-width: 20px; text-align: center;
  border-radius: 999px; padding: 0 6px;
}
/* В колонке есть карточка, где ход за оператором, — счётчик оранжевый, чтобы свёрнутое «Новое» не спрятало зависшее */
.board-col-count.hot { background: var(--orange); color: #fff; }
.board-col-chev { width: 16px; height: 16px; color: var(--placeholder); }
.board-cards { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; }
.board-empty {
  min-height: 96px; border: 1px dashed var(--lilac); border-radius: var(--r-xl);
  display: flex; align-items: center; justify-content: center;
  color: var(--placeholder); font-size: 12px;
}
.board-col-foot { padding: 4px 12px 10px; font-size: 12px; color: var(--text-2); flex-shrink: 0; }
/* Всё пусто — на телефоне вместо ленты пустых колонок одна строка (на десктопе колонки остаются: это цели броска) */
.board-none {
  display: none; flex: 1; align-items: center; justify-content: center;
  color: var(--text-2); font-size: 14px; text-align: center; padding: 24px;
}
.board-col-foot:empty { display: none; }
.board-col-foot .link-btn { font-size: 12px; }

/* Карточка — ссылка на диалог; глобальный a оранжевый и подчёркнутый, здесь сбрасываем */
.board-card {
  display: block; color: inherit; text-decoration: none;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 10px 12px;
  transition: border-color .12s, box-shadow .12s, opacity .15s;
}
.board-card[draggable="true"] { cursor: grab; }
.board-card:hover { border-color: var(--lilac); box-shadow: var(--shadow-sm); }
.board-card:focus-visible { outline: none; box-shadow: var(--ring); }
.board-card.dragging { opacity: .4; user-select: none; }
.board-card.pending { opacity: .5; pointer-events: none; }
.board-card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.board-card-sub + .board-card-row, .board-card-row + .board-card-row { margin-top: 6px; }
.board-card-name {
  font-weight: 600; font-size: 14px; color: var(--dark);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0;
}
.board-card-age { font-size: 11px; color: var(--text-2); font-variant-numeric: tabular-nums; flex-shrink: 0; }
/* Дольше суток в стадии, и таймер её не закроет — это и есть «зависло»; мелкий акцент только --amber-text */
.board-card-age.stale { color: var(--amber-text); font-weight: 600; }
.board-card-sub {
  font-size: 12px; color: var(--text-2); margin-top: 2px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  /* Ссылка или почта без пробелов иначе режется посреди буквы в первой строке, без многоточия */
  overflow-wrap: anywhere;
}
.board-card-sub b { color: var(--dark); font-weight: 600; }
.board-card-hint { font-size: 12px; color: var(--purple); font-weight: 500; margin-top: 4px; line-height: 1.4; }
.board-card-hint + .board-card-row { margin-top: 6px; }
.board-turn { font-size: 12px; color: var(--text-2); }
.board-turn.hot { color: var(--red-text); font-weight: 600; }
.board-turn.muted { color: var(--placeholder); }
.board-card-note { font-size: 11px; color: var(--text-2); margin-top: 4px; }
.board-card .dialog-badges .badge { font-size: 11px; padding: 1px 6px; }

/* «У человека» — очередь оператора: фиолетовый тон колонки, без оранжевого и красного */
.board-col[data-stage="escalated"] { background: var(--purple-icon); border-color: #E3D8EA; }
/* «Только ждут меня»: очередь оператора — первой. Ждущих колонок бывает больше четырёх (бот завис у всех),
   и шестая по счёту «У человека» уехала бы за край ленты */
.board.mine .board-col[data-stage="escalated"] { order: -1; }

/* Свёрнутая колонка — полоска: счётчик сверху, название повёрнуто */
.board-col.collapsed { flex: 0 0 40px; min-width: 40px; max-width: 40px; }
.board-col.collapsed .board-col-head {
  flex: 1; flex-direction: column; align-items: center; justify-content: flex-start; gap: 10px;
  padding: 10px 0; border-radius: var(--r-2xl);
}
.board-col.collapsed .board-col-title { display: none; }
.board-col.collapsed .board-col-vtitle {
  display: block; writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 12px; font-weight: 600; color: var(--text-2); white-space: nowrap;
}
.board-col.collapsed .board-col-chev { transform: rotate(180deg); }
.board-col.collapsed .board-cards, .board-col.collapsed .board-col-foot { display: none; }

/* Перенос: разрешённые колонки — пунктир, под курсором — оранжевая рамка; остальные и исходная приглушены */
.board.drag-active .board-col.can-drop { border-color: var(--lilac); border-style: dashed; }
.board.drag-active .board-col.can-drop.drop-over { background: var(--orange-bg); border-color: var(--orange); border-style: solid; }
.board.drag-active .board-col:not(.can-drop) { opacity: .45; cursor: not-allowed; }
/* Размер колонок во время переноса не меняем: сдвиг под курсором сбрасывает бросок на соседа или в пустоту */
/* Пока тянем, дети колонок не перехватывают dragover — иначе подсветка мигает на каждой карточке */
.board.drag-active .board-cards > * { pointer-events: none; }

/* ============ ПРОКРУТКА ============ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d9d0e0; border-radius: 5px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #c4b7cf; background-clip: padding-box; }

/* ============ ТЕЛЕФОН — нижняя навигация, как BottomNav кабинета ============ */
@media (max-width: 860px) {
  .app, .app.no-list {
    display: flex; flex-direction: column;
    height: 100vh; height: 100dvh;
  }
  .sidebar {
    order: 3;
    flex-direction: row;
    height: 64px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-sizing: content-box;
    border-right: 0;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }
  .sidebar-logo { display: none; }
  /* Пункты как в BottomNav кабинета: колонка иконка+подпись, активный — на оранжевой плашке rounded-xl */
  .nav-items { flex-direction: row; align-items: center; padding: 0 4px; gap: 0; flex: 1; justify-content: space-around; }
  .sidebar-foot { padding: 0 4px 0 0; border: 0; display: flex; align-items: center; }
  .nav-item {
    flex: 0 1 auto; flex-direction: column; justify-content: center; gap: 2px;
    padding: 6px 8px; border-radius: var(--r-xl); font-size: 11px; font-weight: 600;
    width: auto; min-width: 56px;
  }
  .nav-item:hover { background: transparent; }
  .nav-item.active { background: var(--orange-bg); }
  .nav-item.logout:hover { background: transparent; }
  .nav-item .icon { width: 20px; height: 20px; }
  .nav-badge { position: absolute; top: 2px; right: 4px; margin: 0; min-width: 18px; height: 18px; line-height: 18px; font-size: 11px; padding: 0 5px; }

  .list-pane { border-right: 0; flex: 1; min-height: 0; }
  .content-pane { flex: 1; min-height: 0; }
  /* Одна колонка: пока обращение не выбрано — список, выбрали — контент с кнопкой «назад» */
  .app:not(.no-list):not(.show-content) .content-pane { display: none; }
  .app:not(.no-list).show-content .list-pane { display: none; }
  .back-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px; margin-left: -8px;
    border: 0; border-radius: var(--r-lg); background: transparent; color: var(--text-2); padding: 0;
  }
  .back-btn:hover { background: var(--bg-soft); color: var(--dark); }

  /* Шапка в две строки: имя с кнопкой «назад», под ними действия — иначе имя сжимается до трёх букв */
  .content-header { padding: 12px 16px; row-gap: 10px; }
  .content-header-info { flex: 1 1 0; }
  .content-header-actions { flex-basis: 100%; justify-content: flex-start; }
  .chat .content-header-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .content-header-name, .title-input { font-size: 18px; }
  /* iOS Safari масштабирует страницу при фокусе на поле мельче 16px */
  .input, .input-sm, select.input, .composer textarea, .draft-text, .textarea-flat, .code-textarea, .hl-backdrop, .title-input { font-size: 16px; }
  /* Тач-таргеты: сегменты и иконки-кнопки до 36px */
  .segment > button { height: 36px; padding: 0 14px; }
  .icon-btn { width: 36px; height: 36px; border-radius: var(--r-lg); }
  .icon-btn .icon { width: 18px; height: 18px; }
  .page-body { padding: 16px; }
  .profile-strip { padding: 8px 16px; }
  .messages { padding: 16px; }
  .message { max-width: 86%; }
  .composer, .composer-centered { padding: 10px 12px; }
  .marker-legend, .status-bar { padding-left: 16px; padding-right: 16px; }
  .md-preview, .code-textarea, .hl-backdrop { padding: 16px; }
  .hero { padding: 20px; }
  .hero-value { font-size: 30px; }
  .hero-side { text-align: left; }
  /* Аналитика в одну колонку: плитки по две, третья в ряду из трёх — на всю ширину */
  .an-root { gap: 14px; }
  .an-tiles, .an-tiles-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .an-tiles-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .card.an-tile { padding: 14px; }
  .an-tile-value { font-size: 22px; }
  .card.an-card { padding: 16px; }
  .an-shares { grid-template-columns: minmax(0, 1fr); }
  .an-period { flex-direction: column; align-items: stretch; padding: 8px; }
  /* Пресеты делят ширину строки; не влезли (узкий телефон) — строка листается вбок */
  .an-presets { display: flex; width: 100%; gap: 2px; padding: 3px; }
  .an-presets > button { flex: 1 0 auto; justify-content: center; padding: 0 6px; }
  /* «Где бот не справляется»: «Ушло к вам» и «Ушёл без решения» — строкой под полосой, таблица без прокрутки вбок */
  .an-type { min-width: 88px; }
  .an-share-cell { min-width: 104px; }
  .an-types .an-opt { display: none; }
  .an-types tr > :nth-child(3) { padding-right: 0; }
  .an-mini-x { display: block; white-space: normal; }
  .an-hero-side { margin-left: 0; }
  .an-range { flex-wrap: wrap; }
  .input.an-date { height: 36px; font-size: 16px; }
  .an-reason { grid-template-columns: minmax(0, 1fr); }
  /* Ключи графика — под заголовком, от левого края */
  .an-keys { align-items: flex-start; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 92vh; max-height: 92dvh; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .modal-body { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }

  /* Доска: седьмой пункт в нижнюю навигацию не влезает (7 × 56px > 375px) — вход кнопкой «Доской» в шапке списка */
  .nav-item[data-section="board"] { display: none; }
  .board { padding: 12px 16px; gap: 10px; scroll-snap-type: x mandatory; scroll-padding: 0 16px; }
  .board-col { flex: 0 0 82vw; min-width: 0; max-width: none; scroll-snap-align: start; }
  /* На телефоне переноса нет, поэтому пустая колонка не нужна ни глазу, ни как цель броска — лента
     начинается с первой колонки, где есть карточки. Сворачивание тоже не действует: полоски неудобны. */
  .board-col.is-empty { display: none; }
  .board-col-head { pointer-events: none; }
  .board-col-chev { display: none; }
  .board-col.collapsed { flex: 0 0 82vw; min-width: 0; max-width: none; }
  .board-col.collapsed .board-col-head { flex: 0 0 auto; flex-direction: row; padding: 10px 10px 8px 12px; }
  .board-col.collapsed .board-col-title { display: flex; }
  .board-col.collapsed .board-col-vtitle { display: none; }
  .board-col.collapsed .board-cards { display: flex; }
  .board-col.collapsed .board-col-foot:not(:empty) { display: block; }
  .board.all-empty .board-none { display: flex; }
}

/* Песочница: до 1000px чат и снапшот промта в одну колонку */
@media (max-width: 1000px) {
  .sandbox-body { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .sandbox-debug { border-left: 0; border-top: 1px solid var(--border); max-height: 36vh; }
}
