/* =====================================================================
   WA-Рассылки — стили. Одна система токенов (S6).

   Правила:
   - Цвета, радиусы, тени и размеры шрифта — только через токены :root.
     Тёмная тема — те же токены с другими значениями ([data-theme=dark]),
     компоненты о теме не знают.
   - Смысловые цвета парами «текст/фон»: ok, warn, danger, info, neutral.
     Цвет плашки зависит от смысла, а не от места на странице.
   - Без декоративных анимаций, стекла и градиентов в рабочих экранах.
   - Файл разбит на секции; новый компонент пишется в свою секцию.
   ===================================================================== */

/* ---------------------------------------------------------------- 1. Токены */
:root {
  color-scheme: light;
  /* Поверхности */
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #faf6ee;
  --surface-hover: #f3ecdf;
  --chat-wall: #efeae2;
  --chat-dots: radial-gradient(rgba(84, 101, 111, 0.12) 1.2px, transparent 1.4px);
  --border: #e9dfcf;
  --border-strong: #d8c9b3;
  --control-border: #857864;
  /* Текст */
  --text: #1e1b16;
  --text-2: #554c40;
  --text-muted: #5d5346;
  --text-on-brand: #ffffff;
  /* Бренд */
  --brand: #0d7a61;
  --brand-hover: #0a6651;
  --brand-text: #0b6a54;
  --brand-soft: #e6f2ec;
  --accent: #25d366;              /* только заливки с тёмным текстом */
  --on-accent: #0b141a;
  /* Пузыри */
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --bubble-campaign: #e7f8e2;
  --bubble-campaign-border: #b9dfb2;
  --bubble-meta: #56656e;
  --tick-read: #0067c0;           /* синие ✓✓ — прочитано, как в WhatsApp (контраст ≥ 4.5:1 на пузырях) */
  --tick-sent: #8696a0;           /* серые ✓ / ✓✓ — отправлено / дошло */
  /* Смысловые пары */
  --ok: #0a6b4f;      --ok-bg: #e6f6ee;      --ok-border: #b7e3cd;
  --warn: #8a4b00;    --warn-bg: #fff3d6;    --warn-border: #f2d48a;
  --danger: #8a1c33;  --danger-bg: #f9e8eb;  --danger-border: #e8b9c2;
  --info: #0b5d8a;    --info-bg: #e5f3fc;    --info-border: #b7dcf2;
  --neutral: #5a5045; --neutral-bg: #f1ebe1; --neutral-border: #ddd1bf;
  /* Шрифт */
  --font: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 20px; --fs-2xl: 24px;
  --fw-regular: 400; --fw-medium: 500; --fw-bold: 600;
  /* Радиусы и тени */
  --r-sm: 8px; --r-md: 10px; --r-lg: 16px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(70, 50, 25, 0.05), 0 4px 16px rgba(70, 50, 25, 0.06);
  --shadow-pop: 0 18px 44px rgba(70, 50, 25, 0.16);
  --focus: 2px solid var(--sky);
  /* Каркас */
  --topnav-h: 56px;
  /* Шапка — светлая и спокойная, как в новом WhatsApp Web; зелёный — только акцент */
  --header-bg: #fffdf8;
  --header-text: #5a5045;
  --header-text-strong: #1e1b16;
  --header-line: #0d7a61;
  --header-hover: #f3ecdf;
  --header-btn-border: #d8c9b3;
  /* Акценты: небесно-голубой — информация и выделение, бордовый — важное и опасное, бежевый — тёплые подложки */
  --sky: #2f8fcb;
  --sky-soft: #e5f3fc;
  --burgundy: #7a1f2e;
  --burgundy-soft: #f9e8eb;
  --beige: #efe4d2;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14110d;
  --surface: #1c1814;
  --surface-2: #221d18;
  --surface-hover: #2a241e;
  --chat-wall: #120f0c;
  --chat-dots: radial-gradient(rgba(233, 237, 239, 0.06) 1.2px, transparent 1.4px);
  --border: #342d25;
  --border-strong: #453c32;
  --control-border: #8f8476;
  --text: #eee7dc;
  --text-2: #c8bdad;
  --text-muted: #b0a493;
  --brand: #2bae8a;
  --brand-hover: #3cc29c;
  --text-on-brand: #0b141a;          /* светлый текст на ярком зелёном не читается (3:1) */
  --brand-text: #4fd0aa;
  --brand-soft: #142a23;
  --on-accent: #0b141a;
  --bubble-in: #25201a;
  --bubble-out: #005c4b;
  --bubble-campaign: #0d4a3f;
  --bubble-campaign-border: #1d6b5b;
  --bubble-meta: #cfd9de;
  --tick-read: #7fd3ff;
  --tick-sent: #8696a0;
  --ok: #6fd8a8;      --ok-bg: #0f2e23;      --ok-border: #1f5a43;
  --warn: #f3c56b;    --warn-bg: #33270b;    --warn-border: #5f4815;
  --danger: #f9c3ce;  --danger-bg: #3b1720;  --danger-border: #6b2b39;
  --info: #8fd0f6;    --info-bg: #0f2533;    --info-border: #24506d;
  --neutral: #cfc4b4; --neutral-bg: #26201a; --neutral-border: #3d352c;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.30), 0 6px 20px rgba(0, 0, 0, 0.22);
  --shadow-pop: 0 18px 44px rgba(0, 0, 0, 0.55);
  --header-bg: #1c1814;
  --header-text: #b9ad9c;
  --header-text-strong: #eee7dc;
  --header-line: #2bae8a;
  --header-hover: rgba(255, 255, 255, 0.05);
  --header-btn-border: #453c32;
  --sky: #6cc2f0;
  --sky-soft: #0f2533;
  --burgundy: #c75b72;
  --burgundy-soft: #3b1720;
  --beige: #2a2520;
}

/* ---------------------------------------------------------------- 2. Основа */
* { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-md);
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
::selection { background: rgba(0, 128, 105, 0.22); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-sm); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }

h1 { font-size: var(--fs-2xl); font-weight: var(--fw-bold); margin: 0 0 16px; color: var(--text); }
h2 { font-size: var(--fs-lg); font-weight: var(--fw-bold); margin: 0 0 12px; }
h3 { font-size: var(--fs-md); font-weight: var(--fw-bold); margin: 0 0 8px; }
.muted { color: var(--text-muted); }
.small-note { font-size: var(--fs-sm); color: var(--text-muted); margin-top: 6px; }
.text-danger { color: var(--danger); }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
kbd {
  display: inline-block; min-width: 18px; padding: 1px 5px;
  border: 1px solid var(--border-strong); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-2); font: inherit; font-size: var(--fs-xs);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* Атрибут hidden скрывает всегда — даже у блоков с display:flex/grid (иначе «скрытые» поля видны). */
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- 3. Каркас */
.topnav {
  background: var(--header-bg);
  box-shadow: 0 1px 3px rgba(11, 20, 26, 0.18);
  position: sticky; top: 0; z-index: 20;
}
.topnav-inner {
  max-width: 1320px; margin: 0 auto; height: var(--topnav-h);
  padding: 0 24px; display: flex; align-items: center; gap: 8px;
}
.topnav-brand {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0; margin-right: 16px;
  color: var(--header-text-strong); font-weight: var(--fw-bold); font-size: var(--fs-lg);
}
.topnav-brand:hover { text-decoration: none; }
.topnav-brand .logo-mark {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--header-text-strong); color: var(--header-bg);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.topnav-links {
  flex: 1; display: flex; align-items: center; gap: 2px; min-width: 0; height: 100%;
  overflow-x: auto; scrollbar-width: none;
}
.topnav-links::-webkit-scrollbar { display: none; }
.topnav-links a {
  display: flex; align-items: center; gap: 8px; height: 100%;
  padding: 0 12px; color: var(--header-text); font-weight: var(--fw-medium); font-size: var(--fs-md);
  white-space: nowrap; flex-shrink: 0; border-bottom: 3px solid transparent; border-top: 3px solid transparent;
}
.topnav-links a:hover { color: var(--header-text-strong); text-decoration: none; background: var(--header-hover); }
.topnav-links a.active { color: var(--header-text-strong); border-bottom-color: var(--header-line); font-weight: var(--fw-bold); }
.topnav .btn { background: transparent; border-color: var(--header-btn-border); color: var(--header-text-strong); }
.topnav .btn:hover { background: var(--header-hover); border-color: var(--header-text); }
.topnav .btn-primary { background: var(--header-text-strong); border-color: transparent; color: var(--header-bg); }
.topnav .btn-link, .topnav .btn-link:hover { color: var(--header-text); border: 0; }
.topnav .channel-pill { border-color: var(--header-btn-border); color: var(--header-text); }
.topnav .channel-pill:hover { border-color: var(--header-text); }
.topnav .cmdk-chip { background: transparent; border-color: var(--header-btn-border); color: var(--header-text); }
.topnav-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; margin-left: 12px; }
.topnav-right form { margin: 0; }
.topnav-right .btn-link { display: inline-flex; align-items: center; gap: 6px; }
.topnav-user { font-size: var(--fs-sm); color: var(--header-text); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.topnav-user-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
/* Этап 8: семь разделов в шапке помещаются и в окне 1280–1400 px */
@media (max-width: 1400px) {
  .topnav-links a svg { display: none; }
  .topnav-links a { padding: 0 9px; gap: 4px; }
  .topnav-brand { margin-right: 6px; }
}
@media (max-width: 1200px) {
  .topnav .cmdk-chip, .topnav-user-name { display: none; }
  .topnav-right { gap: 8px; }
}
/* Окно ноутбука ~1000 px: все разделы видны — без названия у логотипа и с узкими полями. */
@media (max-width: 1100px) {
  .topnav-inner { padding: 0 14px; }
  .topnav-brand span:last-child { display: none; }
}
@media (max-width: 1000px) {
  .topnav-links a { padding: 0 6px; font-size: var(--fs-sm); }
  .topnav .channel-label { display: none; }  /* состояние канала — цветной точкой, подробности в подсказке */
}
.theme-toggle { min-width: 34px; }

/* Переключатель номеров (аккаунтов) в шапке */
.acc-switch { position: relative; }
.acc-current {
  display: inline-flex; align-items: center; gap: 8px; max-width: 260px; height: 36px; padding: 0 10px;
  border: 1px solid var(--header-btn-border); border-radius: var(--r-pill); background: transparent;
  color: var(--header-text-strong); font: inherit; font-size: var(--fs-sm); cursor: pointer;
}
.acc-current:hover, .acc-current[aria-expanded="true"] { background: var(--header-hover); border-color: var(--header-text); }
.acc-current:focus-visible, .acc-item:focus-visible, .acc-add:focus-visible { outline: var(--focus); outline-offset: 2px; }
.acc-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--header-line); flex-shrink: 0; }
.acc-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.15; }
.acc-name { font-weight: var(--fw-bold); max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-phone { font-size: var(--fs-xs); color: var(--header-text); white-space: nowrap; }
.acc-caret { color: var(--header-text); font-size: var(--fs-xs); }
.acc-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 400; width: 280px; max-height: 70vh; overflow-y: auto;
  padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop);
}
.acc-menu-title { padding: 6px 10px 4px; font-size: var(--fs-xs); color: var(--text-muted); font-weight: var(--fw-bold); }
.acc-item, .acc-add {
  display: flex; flex-direction: column; align-items: flex-start; width: 100%; padding: 8px 10px;
  border: 0; border-radius: var(--r-sm); background: transparent; color: var(--text); font: inherit;
  font-size: var(--fs-md); text-align: left; cursor: pointer;
}
.acc-item:hover, .acc-add:hover { background: var(--surface-hover); }
.acc-item.active { background: var(--brand-soft); }
.acc-item.active .acc-item-name::after { content: " ✓"; color: var(--brand-text); }
.acc-item-name { font-weight: var(--fw-medium); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-item-phone { font-size: var(--fs-xs); color: var(--text-muted); }
.acc-add { margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 var(--r-sm) var(--r-sm);
  color: var(--brand-text); font-weight: var(--fw-bold); }
.acc-dialog {
  width: min(440px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop);
}
.acc-dialog::backdrop { background: rgba(11, 20, 26, 0.45); }
.acc-dialog h2 { margin: 0 0 6px; font-size: var(--fs-xl); }
.acc-dialog label { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.acc-dialog input { width: 100%; }
.acc-dialog .alert { margin: 12px 0 0; }
.acc-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@media (max-width: 1200px) { .acc-phone { display: none; } .acc-name { max-width: 130px; } }
@media (max-width: 759px) {
  .acc-current { max-width: 170px; height: 34px; }
  .acc-name { max-width: 110px; }
  .acc-menu { position: fixed; left: 12px; right: 12px; top: calc(var(--topnav-h) + 4px); width: auto; }
}
/* Телефон: переключатель номеров, тема, «Демо» и выход помещаются в одну строку. */
@media (max-width: 480px) {
  .topnav-right { gap: 6px; margin-left: 6px; }
  .acc-current { max-width: 132px; padding: 0 8px; gap: 6px; }
  .acc-name { max-width: 88px; }
  .acc-caret, .topnav-logout-text { display: none; }
  .topnav .badge-mock { padding: 2px 6px; font-size: var(--fs-xs); }
}

.container { max-width: 1220px; margin: 0 auto; padding: 18px 24px 56px; }

/* ---------------------------------------------------------------- 4. Карточки и сетки */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.kv-list { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; }
.kv-list dt { color: var(--text-muted); }
.kv-list dd { margin: 0; }
.actions-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.filters { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filters select { width: auto; }
.inline-form { display: inline; }

/* ---------------------------------------------------------------- 5. Таблицы */
table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  color: var(--text-muted); font-weight: var(--fw-bold); font-size: var(--fs-xs);
  border-bottom-color: var(--border-strong); white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-hover); }
.table-wrap { overflow-x: auto; }

/* ---------------------------------------------------------------- 6. Кнопки */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 16px;
  border-radius: var(--r-pill); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-md); font-weight: var(--fw-medium);
  cursor: pointer; text-decoration: none;
  transition: background-color .12s ease, border-color .12s ease;
}
.btn:hover { background: var(--surface-hover); border-color: var(--control-border); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--text-on-brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-danger { background: var(--surface); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.btn-sm { min-height: 30px; padding: 4px 12px; font-size: var(--fs-sm); border-radius: var(--r-pill); }
.btn-lg { min-height: 42px; padding: 9px 22px; font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.btn-xl { min-height: 52px; padding: 12px 30px; font-size: 18px; font-weight: var(--fw-bold); width: 100%; max-width: 420px; }
.btn-link { background: none; border: none; color: var(--text-2); cursor: pointer; padding: 4px; font: inherit; }
.btn-link:hover { color: var(--brand-text); text-decoration: underline; }

/* ---------------------------------------------------------------- 7. Поля ввода */
input[type=text], input[type=password], input[type=file], input[type=tel], input[type=number], input[type=email],
input[type=time], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--control-border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-md);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: var(--focus); outline-offset: 0; border-color: var(--brand); }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
label { display: block; font-weight: var(--fw-medium); margin-bottom: 6px; font-size: var(--fs-md); }
.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 220px; }
details > summary { cursor: pointer; }

/* ---------------------------------------------------------------- 8. Плашки статусов
   Единая система: .chip + смысл (chip-ok/warn/danger/info/neutral). Старые имена
   (badge-*, status-*, conv-status-*) сохранены и сведены к тем же смысловым парам. */
.chip, .badge, .status-pill, .conv-status, .tpl-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 20px;
  border: 1px solid var(--neutral-border); background: var(--neutral-bg); color: var(--neutral);
  white-space: nowrap;
}
.chip-ok, .badge-running, .badge-done, .status-read, .status-delivered, .conv-status-lead, .conv-status-won, .conv-status-offer_sent, .tpl-badge-approved,
.tpl-badge-media { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.chip-warn, .badge-paused, .badge-mock, .conv-status-in_progress, .conv-status-later, .tpl-badge-marketing,
.status-unknown { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.chip-danger, .badge-stopped, .status-failed, .conv-status-escalated { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.chip-info, .badge-scheduled, .status-sent, .conv-status-new, .conv-status-waiting_client, .tpl-badge-utility,
.tpl-badge-authentication { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
.chip-neutral, .badge-draft, .status-queued, .status-sending, .status-cancelled, .conv-status-closed, .conv-status-lost,
.tpl-badge-lang, .status-pill[class*="status-skipped"] { color: var(--neutral); background: var(--neutral-bg); border-color: var(--neutral-border); }
.chip-outline { background: transparent; }
.badge-running::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0;
}

.waba-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 7px; vertical-align: middle; }
.waba-green { background: var(--ok); }
.waba-yellow { background: var(--warn); }
.waba-red { background: var(--danger); }
.waba-gray { background: var(--neutral); }

/* ---------------------------------------------------------------- 9. Сообщения и баннеры */
.alert, .mock-banner, .health-banner {
  display: block; padding: 11px 14px; border-radius: var(--r-md); margin-bottom: 14px;
  font-size: var(--fs-md); border: 1px solid transparent;
}
.alert-error, .health-banner { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.alert-success { color: var(--ok); background: var(--ok-bg); border-color: var(--ok-border); }
.alert-warning, .mock-banner { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.alert-info { color: var(--info); background: var(--info-bg); border-color: var(--info-border); }
/* Блоком, а не flex: текст со ссылкой внутри не разваливается на колонки на узком экране. */
.mock-banner, .health-banner { display: block; font-weight: var(--fw-medium); }
.mock-banner > .icon:first-child, .health-banner > .icon:first-child { margin-right: 6px; vertical-align: -4px; }
.alert a, .mock-banner a, .health-banner a { color: inherit; text-decoration: underline; }

.empty-state { text-align: center; padding: 36px 16px; color: var(--text-muted); }
td.empty-state { border: none; }
div.empty-state { border: 1px dashed var(--border-strong); border-radius: var(--r-md); background: var(--surface-2); }

/* ---------------------------------------------------------------- 10. Показатели */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tile {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 16px; display: flex; flex-direction: column-reverse; gap: 2px; box-shadow: var(--shadow-1);
}
.stat-tile .value { font-size: var(--fs-2xl); font-weight: var(--fw-bold); line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-tile .label { color: var(--text-muted); font-size: var(--fs-sm); }
.stat-tile.accent { border-color: var(--ok-border); }
.stat-tile.accent .value { color: var(--brand-text); }
.kpi-sub { font-size: var(--fs-xs); color: var(--text-muted); }

.progress-bar { height: 6px; border-radius: var(--r-pill); background: var(--border); overflow: hidden; min-width: 140px; }
.progress-bar-fill { height: 100%; border-radius: var(--r-pill); background: var(--brand); transition: width .4s ease; }
.progress-bar-fill.warn { background: var(--warn); }
.progress-bar-fill.danger { background: var(--danger); }
/* «Течёт» только у идущей кампании (класс running ставит шаблон). */
.progress-bar.running .progress-bar-fill {
  background: linear-gradient(90deg, var(--brand), var(--accent), var(--brand)); background-size: 200% 100%;
  animation: bar-flow 3s linear infinite;
}
@keyframes bar-flow { from { background-position: 0% 0; } to { background-position: 200% 0; } }

.trend-chart { display: flex; align-items: flex-end; gap: 6px; height: 180px; padding-top: 10px; }
.trend-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.trend-bar { width: 100%; max-width: 28px; min-height: 3px; border-radius: var(--r-sm) var(--r-sm) 0 0; background: var(--brand); }
.trend-bar-label { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 6px; white-space: nowrap; }

/* Суточный лимит на странице «Рассылки» */
.daily-limit-row { display: grid; grid-template-columns: 1fr 220px; gap: 12px; margin-bottom: 16px; }
.daily-limit-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-1);
}
.daily-limit-card.warn { border-color: var(--warn-border); }
.daily-limit-card.danger { border-color: var(--danger-border); }
.dl-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.dl-title { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-muted); }
.dl-value { font-size: var(--fs-xl); font-weight: var(--fw-bold); }
.dl-bar { height: 8px; border-radius: var(--r-pill); background: var(--border); overflow: hidden; }
.dl-bar-fill { height: 100%; border-radius: var(--r-pill); background: var(--brand); transition: width .4s ease; }
.daily-limit-card.warn .dl-bar-fill { background: var(--warn); }
.daily-limit-card.danger .dl-bar-fill { background: var(--danger); }
.dl-note { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.dl-note.warn { color: var(--warn); }
.dl-note.danger { color: var(--danger); }
.dl-unsub-values { display: flex; gap: 22px; align-items: baseline; }
.dl-sub { font-size: var(--fs-sm); color: var(--text-muted); }

/* ---------------------------------------------------------------- 11. Вход */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); }
.login-wrap { max-width: 385px; width: 100%; padding: 20px; }
.login-wrap .card { padding: 28px 26px; box-shadow: var(--shadow-pop); }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 6px; }
.login-brand .logo-dot {
  width: 36px; height: 36px; border-radius: var(--r-md); background: var(--brand); color: var(--text-on-brand);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

/* ---------------------------------------------------------------- 12. Мастер кампании и шаблоны */
.stepper { display: flex; align-items: flex-start; gap: 4px; margin-bottom: 20px; overflow-x: auto; padding-bottom: 4px; }
.stepper-item { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 84px; position: relative; }
.stepper-item:not(:last-child)::after {
  content: ""; position: absolute; top: 14px; left: calc(50% + 18px); right: calc(-50% + 18px);
  height: 2px; background: var(--border-strong);
}
.stepper-item.done:not(:last-child)::after { background: var(--brand); }
.stepper-circle {
  width: 28px; height: 28px; border-radius: 50%; z-index: 1;
  background: var(--surface); border: 2px solid var(--control-border); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; font-size: var(--fs-sm); font-weight: var(--fw-bold);
}
.stepper-item.active .stepper-circle { background: var(--brand); border-color: var(--brand); color: var(--text-on-brand); }
.stepper-item.done .stepper-circle { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-text); }
.stepper-label { font-size: var(--fs-xs); color: var(--text-muted); text-align: center; }
.stepper-item.active .stepper-label { color: var(--brand-text); font-weight: var(--fw-bold); }

.wizard-step { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 18px; }
.wizard-step:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.wizard-step[hidden] { display: none; }
.step-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--brand); color: var(--text-on-brand);
  display: flex; align-items: center; justify-content: center; font-size: var(--fs-sm); font-weight: var(--fw-bold); flex-shrink: 0;
}

.template-choice {
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer; background: var(--surface);
}
.template-choice:hover { border-color: var(--brand); }
.template-choice.selected { border-color: var(--brand); background: var(--brand-soft); }
.template-choice .tpl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.template-choice .tpl-name { font-weight: var(--fw-bold); }
.template-choice .tpl-body { color: var(--text-2); font-size: var(--fs-sm); margin-top: 6px; }

.prelaunch-report { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 14px 16px; }

/* Макет телефона для предпросмотра — как в WhatsApp Web */
.phone-mock { max-width: 340px; border-radius: 18px; background: var(--border-strong); padding: 10px; box-shadow: var(--shadow-1); }
.phone-mock-screen {
  background: var(--chat-wall); border-radius: var(--r-lg); padding: 16px 12px; min-height: 140px;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.wa-bubble, .wa-bubble-preview {
  background: var(--bubble-out); color: var(--text); white-space: pre-wrap; font-size: var(--fs-md);
  box-shadow: var(--shadow-1);
}
.wa-bubble { border-radius: var(--r-md) var(--r-md) var(--r-md) 2px; padding: 8px 10px 6px; max-width: 88%; align-self: flex-start; }
.wa-bubble .wa-meta { display: block; text-align: right; font-size: var(--fs-xs); color: var(--bubble-meta); margin-top: 4px; }
.wa-bubble .wa-meta .ticks { color: var(--tick-read); margin-left: 3px; }
.wa-bubble-preview { border-radius: var(--r-md) var(--r-md) 2px var(--r-md); padding: 9px 12px; margin: 10px 0; max-width: 480px; }
.tpl-preview-buttons { max-width: 480px; }
.tpl-preview-btn {
  background: var(--bubble-in); color: var(--info); text-align: center; font-weight: var(--fw-bold); font-size: var(--fs-md);
  border-radius: var(--r-md); padding: 8px 12px; margin-top: 4px; box-shadow: var(--shadow-1);
}
.preview-header-media { margin-bottom: 8px; }
.preview-header-media img { max-width: 100%; max-height: 160px; border-radius: var(--r-md); display: block; object-fit: cover; }
.preview-media-file {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 20px; text-align: center; font-size: var(--fs-sm); color: var(--text-muted);
}

/* ---------------------------------------------------------------- 12a. Простой мастер (1.3.0)
   Четыре крупных шага-карточки; выбор — большими плитками, сообщения — пузырями WhatsApp. */
.wiz-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.wiz-back {
  width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--text-2); background: var(--surface); box-shadow: var(--shadow-1);
}
.wiz-back:hover { text-decoration: none; background: var(--surface-hover); color: var(--text); }
.wiz-top #draft-status { margin-left: auto; }
.wiz-stepper {
  list-style: none; padding: 12px 8px 10px; margin: 0 0 14px; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--shadow-1); position: sticky; top: calc(var(--topnav-h) + 8px); z-index: 6;
}
.wiz-stepper .stepper-circle { width: 32px; height: 32px; font-size: var(--fs-md); }
.wiz-stepper .stepper-item:not(:last-child)::after { top: 16px; }
.wiz-stepper .stepper-label { font-size: var(--fs-sm); font-weight: var(--fw-medium); }
.wiz-stepper .stepper-item.done .stepper-circle { background: var(--brand); color: var(--text-on-brand); }
.wiz-card { scroll-margin-top: calc(var(--topnav-h) + 92px); }
.wiz-card.wizard-step { border-top: 0; padding-top: 20px; margin-top: 0; }
.wiz-card .step-title { font-size: 20px; margin: 0 0 14px; }
.wiz-card .step-num { width: 32px; height: 32px; font-size: var(--fs-lg); }
.wiz-card h3 { font-size: var(--fs-lg); margin: 18px 0 8px; }
.wiz-sub { margin-top: 14px; }
.wiz-sub[hidden], .wiz-more[hidden] { display: none; }

.wiz-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.wiz-choice {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 20px 14px;
  border: 2px solid var(--border); border-radius: 16px; background: var(--surface-2); color: var(--text);
  font: inherit; cursor: pointer; text-align: center; transition: border-color .12s ease, background-color .12s ease;
}
.wiz-choice:hover { border-color: var(--brand); background: var(--brand-soft); }
.wiz-choice[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.wiz-choice-ico { font-size: 34px; line-height: 1.1; }
.wiz-choice-title { font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.wiz-choice-sub { font-size: var(--fs-sm); color: var(--text-muted); }

.wiz-result:not(:empty) { margin-top: 14px; }
.wiz-loading { padding: 14px; border-radius: var(--r-lg); background: var(--surface-2); color: var(--text-2); }
.wiz-found {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 10px;
  border-radius: var(--r-lg); background: var(--ok-bg); border: 1px solid var(--ok-border); color: var(--text);
  font-size: var(--fs-lg);
}
.wiz-found b { font-size: 22px; color: var(--ok); }
.wiz-found small { display: block; font-size: var(--fs-sm); color: var(--text-muted); }
.wiz-found-ico {
  width: 40px; height: 40px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--brand); color: var(--text-on-brand); font-size: 20px; font-weight: var(--fw-bold);
}
.wiz-found.bad { background: var(--danger-bg); border-color: var(--danger-border); }
.wiz-found.bad b { color: var(--danger); }
.wiz-found.bad .wiz-found-ico { background: var(--danger); }

.wiz-more { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.wiz-more > summary { color: var(--text-2); font-weight: var(--fw-medium); padding: 4px 0; }
.wiz-more > summary:hover { color: var(--brand-text); }

/* Выбор сообщения: пузыри на фоне чата */
.tpl-pick { border: 0; padding: 0; margin: 10px 0 0; min-width: 0; }
.tpl-wall {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px;
  padding: 14px; border-radius: var(--r-lg); background-color: var(--chat-wall); background-image: var(--chat-dots);
  background-size: 22px 22px; margin-bottom: 8px;
}
.tpl-wall .template-choice {
  position: relative; margin: 0; padding: 8px 10px 10px; border: 2px solid transparent; border-radius: 10px 10px 10px 2px;
  background: var(--bubble-in); box-shadow: var(--shadow-1); display: flex; flex-direction: column; gap: 4px;
}
.tpl-wall .template-choice:hover { border-color: var(--brand); }
.tpl-wall .template-choice.selected { border-color: var(--brand); background: var(--bubble-out); }
.tpl-wall .tpl-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding-right: 28px; }
.tpl-wall .tpl-name { font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--brand-text); }
.tpl-wall .tpl-body { color: var(--text); font-size: var(--fs-md); white-space: pre-wrap; margin: 0; max-height: 220px; overflow: auto; }
.tpl-check {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid var(--control-border); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: var(--fw-bold); color: transparent; background: var(--surface);
}
.template-choice.selected .tpl-check { background: var(--brand); border-color: var(--brand); color: var(--text-on-brand); }

/* Предпросмотр: телефон с шапкой чата */
.wiz-card .phone-mock { max-width: 380px; padding: 0; overflow: hidden; border-radius: 18px; border: 6px solid var(--text); background: var(--text); }
.phone-mock-bar { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--header-bg); color: var(--header-text-strong); }
.phone-mock-bar small { display: block; font-size: var(--fs-xs); color: var(--header-text); font-weight: var(--fw-regular); }
.pm-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--header-text-strong); color: var(--header-bg);
}
.wiz-card .phone-mock-screen { border-radius: 0; min-height: 200px; background-image: var(--chat-dots); background-size: 22px 22px; }

/* Итог и «Когда?» */
.wiz-total {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; padding: 14px 18px; margin-bottom: 12px;
  border-radius: var(--r-lg); background: var(--brand-soft); border: 1px solid var(--ok-border);
}
.wiz-total-num { font-size: 36px; font-weight: var(--fw-bold); color: var(--brand-text); line-height: 1.1; font-variant-numeric: tabular-nums; }
.wiz-total-label { font-size: var(--fs-lg); color: var(--text); }
.wiz-seg { display: flex; gap: 8px; flex-wrap: wrap; }
.wiz-seg-btn, .chip-btn {
  min-height: 40px; padding: 8px 18px; border-radius: var(--r-pill); border: 2px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: inherit; font-weight: var(--fw-medium); cursor: pointer;
}
.chip-btn { min-height: 34px; padding: 5px 14px; border-width: 1px; font-size: var(--fs-sm); }
.wiz-seg-btn:hover, .chip-btn:hover { border-color: var(--brand); }
.wiz-seg-btn[aria-pressed="true"], .chip-btn[aria-pressed="true"] { border-color: var(--brand); background: var(--brand); color: var(--text-on-brand); }
.wiz-check {
  display: flex; align-items: center; gap: 12px; margin: 14px 0; padding: 12px 14px; cursor: pointer;
  border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); font-size: var(--fs-lg); font-weight: var(--fw-medium);
}
.wiz-check input { width: 22px; height: 22px; flex: none; accent-color: var(--brand); margin: 0; }
.wiz-check:has(input:checked) { border-color: var(--ok-border); background: var(--ok-bg); }
#launch-btn { margin-top: 6px; }

/* ---------------------------------------------------------------- 12b. Список рассылок — как список чатов */
.camp-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.camp-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.camp-row:last-child { border-bottom: 0; }
.camp-row:hover { background: var(--surface-hover); }
.camp-avatar {
  width: 50px; height: 50px; border-radius: 50%; flex: none; display: flex; align-items: center; justify-content: center;
  background: var(--neutral-bg); color: var(--neutral);
}
.camp-running .camp-avatar, .camp-done .camp-avatar { background: var(--brand); color: var(--text-on-brand); }
.camp-paused .camp-avatar { background: var(--warn-bg); color: var(--warn); }
.camp-stopped .camp-avatar { background: var(--danger-bg); color: var(--danger); }
.camp-scheduled .camp-avatar { background: var(--info-bg); color: var(--info); }
.camp-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.camp-top { display: flex; align-items: baseline; gap: 10px; }
.camp-name { flex: 1; min-width: 0; font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.camp-name:hover { color: var(--brand-text); }
.camp-time { font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }
.camp-sub { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-2); }
.camp-stats { display: flex; gap: 6px 14px; flex-wrap: wrap; font-size: var(--fs-sm); color: var(--text-2); font-variant-numeric: tabular-nums; }
.camp-stats b { color: var(--text); }
.camp-read, .camp-read b { color: var(--tick-read); }
.camp-replied b { color: var(--brand-text); }
.camp-main .progress-bar { max-width: 420px; height: 5px; margin-top: 2px; }
.camp-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 300px; }
@media (max-width: 760px) {
  .camp-row { flex-wrap: wrap; }
  .camp-actions { max-width: none; width: 100%; justify-content: flex-start; padding-left: 64px; }
}


/* ---------------------------------------------------------------- 13. Чаты */
.chat-shell {
  display: flex; height: calc(100vh - var(--topnav-h) - 40px); min-height: 440px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); overflow: hidden;
}
.chat-list-pane { width: 340px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--surface); }
.chat-list-header { padding: 10px 12px 6px; font-weight: var(--fw-bold); }
.chat-search { border-radius: var(--r-pill); background: var(--surface-2); border-color: var(--border-strong); }
.chat-list-scroll { flex: 1; overflow-y: auto; }
.inbox-tabs { display: flex; gap: 4px; padding: 4px 10px 6px; flex-wrap: wrap; }
.inbox-tab {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2); border: 1px solid transparent;
}
.inbox-tab:hover { background: var(--surface-hover); text-decoration: none; }
.inbox-tab.active { background: var(--brand-soft); color: var(--brand-text); border-color: var(--ok-border); }
.inbox-tab-count {
  min-width: 18px; padding: 0 5px; border-radius: var(--r-pill); font-size: var(--fs-xs); line-height: 18px;
  text-align: center; background: var(--neutral-bg); color: var(--text-2);
}
.inbox-tab-count.hot { background: var(--accent); color: var(--on-accent); }
.chat-status-filter { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px 8px; flex-wrap: wrap; }
.conv-status-filter, .conv-status-select { width: auto; padding: 4px 8px; font-size: var(--fs-sm); }

.chat-list-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 8px 14px; min-height: 64px;
  border-bottom: 1px solid var(--border); border-left: 3px solid transparent; color: var(--text);
}
.chat-list-item:hover { background: var(--surface-hover); text-decoration: none; }
.chat-list-item.active { background: var(--brand-soft); border-left-color: var(--brand); }
.clp-avatar, .cth-avatar, .crp-avatar {
  border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  color: #ffffff; font-weight: var(--fw-bold);
}
.clp-avatar { width: 40px; height: 40px; font-size: var(--fs-sm); }
.cth-avatar { width: 36px; height: 36px; font-size: var(--fs-xs); }
.crp-avatar { width: 24px; height: 24px; font-size: 10px; }
.clp-body { flex: 1; min-width: 0; }
.clp-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.clp-phone { font-weight: var(--fw-medium); font-size: var(--fs-md); }
.clp-time { font-size: var(--fs-xs); color: var(--text-muted); flex-shrink: 0; }
.clp-bottom { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 2px; }
.clp-preview { font-size: var(--fs-sm); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clp-company { font-size: var(--fs-xs); color: var(--brand-text); font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clp-meta-row { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.clp-unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.clp-unread-count {
  flex: none; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--on-accent); font-size: var(--fs-xs); font-weight: var(--fw-bold); line-height: 20px; text-align: center;
}
.chat-list-item.unread .clp-phone { font-weight: var(--fw-bold); }
.chat-list-item.unread .clp-preview { color: var(--text); }
.chat-list-item.unread .clp-time { color: var(--brand-text); font-weight: var(--fw-bold); }
.clp-blocked { color: var(--danger); font-size: var(--fs-xs); font-weight: var(--fw-bold); display: flex; align-items: center; gap: 4px; margin-top: 3px; }
/* «ждёт 20 мин» — спокойная; после часа ожидания — янтарная (правило SLA придёт в S9). */
.clp-waiting, .clp-window {
  font-size: var(--fs-xs); font-weight: var(--fw-medium); border-radius: var(--r-pill); padding: 0 7px; line-height: 18px;
  color: var(--neutral); background: var(--neutral-bg); border: 1px solid var(--neutral-border);
}
.clp-waiting { color: var(--info); background: var(--info-bg); border-color: var(--info-border); font-weight: var(--fw-bold); }
.clp-waiting.amber { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.clp-window.closed { color: var(--text-muted); background: transparent; }
.clp-meta-row { flex-wrap: wrap; }
.clp-meta-row:empty { display: none; }
.chat-list-more { display: block; margin: 10px auto; }
.nav-badge {
  margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: var(--r-pill); line-height: 18px;
  background: var(--accent); color: var(--on-accent); font-size: var(--fs-xs); font-weight: var(--fw-bold); text-align: center;
}

.chat-reminders { border-bottom: 1px solid var(--border); background: var(--warn-bg); padding: 8px 12px; max-height: 160px; overflow-y: auto; }
.chat-reminders-title { font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--warn); display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.chat-reminder-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text); }
.chat-reminder-item:hover { background: var(--surface-hover); text-decoration: none; }
.chat-reminder-item.overdue .crp-time { color: var(--danger); font-weight: var(--fw-bold); }
.crp-phone { font-weight: var(--fw-medium); flex: 1; }
.crp-time { font-size: var(--fs-xs); color: var(--text-muted); }

.chat-thread-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-thread-header {
  padding: 8px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2);
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-weight: var(--fw-bold);
}
.cth-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Длинные имя/номер не наезжают на статус — обрезаются многоточием. */
.cth-info > span, .cth-info > .small-note { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cth-company { max-width: 100%; }
.conv-status-select { flex: none; }
.cth-phone-sub { color: var(--text-muted); font-weight: var(--fw-regular); font-size: var(--fs-sm); }
.cth-company { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-xs); color: var(--brand-text); font-weight: var(--fw-medium); }
.chat-tool-box { padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.chat-tool-box label { margin-bottom: 6px; }
.chat-tool-box textarea { margin-bottom: 8px; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px 22px; background: var(--chat-wall);
  display: flex; flex-direction: column; gap: 6px;
}
.chat-msg {
  max-width: min(62%, 520px); padding: 7px 10px 5px; font-size: var(--fs-md); line-height: 1.42;
  white-space: pre-wrap; overflow-wrap: break-word; color: var(--text); box-shadow: var(--shadow-1);
}
.chat-msg.in { align-self: flex-start; background: var(--bubble-in); border-radius: var(--r-md) var(--r-md) var(--r-md) 2px; }
.chat-msg.out { align-self: flex-end; background: var(--bubble-out); border-radius: var(--r-md) var(--r-md) 2px var(--r-md); }
.chat-msg.campaign { align-self: flex-end; background: var(--bubble-campaign); border: 1px dashed var(--bubble-campaign-border); border-radius: var(--r-md) var(--r-md) 2px var(--r-md); }
.chat-msg a { color: inherit; text-decoration: underline; }
.chat-msg .btn { background: transparent; border-color: var(--border-strong); color: var(--text); }
.chat-msg .cm-meta { display: block; text-align: right; font-size: var(--fs-xs); color: var(--bubble-meta); margin-top: 3px; }
.chat-msg .cm-meta .ticks-read { color: var(--tick-read); }
.chat-msg .cm-meta .ticks-failed { color: var(--danger); }
.chat-msg .cm-error { display: block; margin-top: 4px; font-size: var(--fs-xs); line-height: 1.35; color: var(--danger); white-space: pre-wrap; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--text-muted); text-align: center; padding: 40px; background: var(--chat-wall); }

.quick-replies-bar { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px 0; border-top: 1px solid var(--border); }
.qr-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 260px;
  background: var(--brand-soft); color: var(--brand-text); border: 1px solid var(--ok-border); border-radius: var(--r-pill);
  padding: 4px 10px; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.qr-chip:hover { border-color: var(--brand); text-decoration: none; }
.qr-chip.active { background: var(--brand); color: var(--text-on-brand); border-color: var(--brand); }
.qr-chip-remove { background: none; border: none; color: inherit; opacity: .7; cursor: pointer; font-size: var(--fs-md); line-height: 1; padding: 0; flex-shrink: 0; }
.qr-chip-remove:hover { opacity: 1; }
.qr-chip-add { background: transparent; border-style: dashed; border-color: var(--border-strong); color: var(--text-2); }
.chat-input-bar { display: flex; gap: 10px; padding: 10px 16px 12px; align-items: flex-end; background: var(--surface-2); }
.chat-input-bar textarea { resize: none; min-height: 42px; max-height: 160px; }
.chat-window-closed {
  padding: 9px 18px; background: var(--warn-bg); color: var(--warn); font-size: var(--fs-sm); border-top: 1px solid var(--warn-border);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.chat-window-open-note { padding: 5px 18px; background: var(--brand-soft); color: var(--brand-text); font-size: var(--fs-xs); font-weight: var(--fw-medium); border-top: 1px solid var(--border); }

/* S8: тред — дни, цитаты, файлы, действия, окно 24 ч, быстрые фразы, перетаскивание */
.chat-day { align-self: center; margin: 8px 0 2px; }
.chat-day span {
  display: inline-block; padding: 3px 10px; border-radius: var(--r-md); font-size: var(--fs-xs);
  background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-1);
}
.chat-older { align-self: center; }
.cm-label { display: block; font-size: var(--fs-xs); color: var(--bubble-meta); margin-bottom: 3px; }
.cm-quote {
  display: block; border-left: 3px solid var(--brand); background: rgba(0, 0, 0, 0.05);
  padding: 3px 8px; margin-bottom: 5px; border-radius: var(--r-sm); font-size: var(--fs-sm); color: var(--text-2);
  white-space: pre-wrap; max-height: 4.5em; overflow: hidden;
}
.cm-author { color: var(--bubble-meta); }
.cm-image { display: block; max-width: 240px; max-height: 240px; border-radius: var(--r-sm); margin-bottom: 4px; }
/* Пока фото грузится (медленный интернет) — видно место под него, а не пустоту. */
.cm-image-link { display: block; width: fit-content; }
.cm-image-link:not(.loaded):not(.failed) { min-width: 160px; min-height: 120px; border-radius: var(--r-sm);
  background: rgba(0, 0, 0, 0.06) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 24 24' fill='none' stroke='%23889' stroke-width='1.6'%3E%3Crect x='3' y='5' width='18' height='14' rx='2'/%3E%3Ccircle cx='9' cy='10' r='2'/%3E%3Cpath d='M21 16l-5-5-8 8'/%3E%3C/svg%3E") center / 28px no-repeat; }
.cm-image-link.failed { padding: 8px 10px; border-radius: var(--r-sm); background: rgba(0, 0, 0, 0.06); font-size: var(--fs-sm); }
.cm-video { display: block; max-width: 260px; margin-bottom: 4px; }
.cm-file {
  display: flex; align-items: center; gap: 10px; min-width: 220px; padding: 8px 10px; margin-bottom: 5px;
  border-radius: var(--r-md); background: rgba(0, 0, 0, 0.05); color: var(--text); text-decoration: none;
}
.cm-file:hover { text-decoration: none; background: rgba(0, 0, 0, 0.09); }
.cm-file-icon { font-size: 22px; }
.cm-file-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.cm-file-name { font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cm-file-size { font-size: var(--fs-xs); color: var(--bubble-meta); }
.cm-file-open { font-size: var(--fs-sm); color: var(--brand-text); font-weight: var(--fw-medium); }
.cm-link { font-size: var(--fs-sm); }
.cm-reaction {
  display: inline-block; margin-top: 3px; padding: 0 6px; border-radius: var(--r-pill);
  background: var(--surface); box-shadow: var(--shadow-1); font-size: var(--fs-md);
}
.cm-ticks.ticks-read { color: var(--tick-read); }
.cm-ticks.ticks-failed, .cm-ticks.ticks-unknown { color: var(--danger); font-weight: var(--fw-bold); }
.cm-actions { display: flex; gap: 6px; margin-top: 6px; white-space: normal; }
.clp-draft { color: var(--danger); font-weight: var(--fw-medium); }
.chat-window-open-note.warn { color: var(--warn); background: var(--warn-bg); }
.chat-window-open-note.danger { color: var(--danger); background: var(--danger-bg); }
.chat-attach { min-width: 40px; font-size: var(--fs-lg); padding: 4px 8px; }
.qr-hint { margin: 0 0 0 auto; align-self: center; }
.qr-chip-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 210px;
  background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer;
}
.qr-picker {
  margin: 6px 16px 0; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); box-shadow: var(--shadow-pop); max-height: 220px; overflow-y: auto;
}
.qr-option { padding: 7px 10px; cursor: pointer; font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qr-option.on, .qr-option:hover { background: var(--brand-soft); color: var(--brand-text); }
.chat-thread-pane.drop-target { outline: 2px dashed var(--brand); outline-offset: -6px; }

/* Голосовые «как в WhatsApp» */
.wa-voice { display: flex; align-items: center; gap: 8px; min-width: 230px; max-width: 300px; margin-bottom: 4px; }
.wa-voice audio { display: none; }
.wa-voice-play {
  width: 34px; height: 34px; flex: none; border-radius: 50%; border: none; cursor: pointer;
  background: var(--brand); color: var(--text-on-brand); font-size: 13px; line-height: 34px; padding: 0;
}
.wa-voice-play:disabled { background: var(--control-border); cursor: default; }
.wa-voice-track { position: relative; flex: 1; height: 6px; border-radius: 3px; background: var(--border-strong); cursor: pointer; }
.wa-voice-fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; border-radius: 3px; background: var(--brand); }
.wa-voice-time { font-size: var(--fs-xs); color: var(--bubble-meta); min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.wa-voice-speed { border: none; border-radius: var(--r-pill); padding: 2px 7px; font-size: var(--fs-xs); font-weight: var(--fw-bold); background: var(--neutral-bg); color: var(--text-2); cursor: pointer; }

/* S9: панель клиента — третья колонка от 1280 px, уже — выдвижная справа. */
.chat-context {
  width: 320px; flex-shrink: 0; border-left: 1px solid var(--border); background: var(--surface);
  overflow-y: auto; padding: 12px 14px 20px; font-size: var(--fs-sm);
}
.ctx-section { padding: 10px 0; border-bottom: 1px solid var(--border); }
.ctx-section:last-child { border-bottom: 0; }
.ctx-title { font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.ctx-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.ctx-row label { margin: 0; font-weight: var(--fw-medium); min-width: 92px; }
.ctx-row input, .ctx-row select { flex: 1; min-width: 0; padding: 4px 8px; font-size: var(--fs-sm); }
.ctx-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ctx-list li { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.ctx-muted { color: var(--text-muted); font-size: var(--fs-xs); }
.ctx-task-overdue { color: var(--danger); font-weight: var(--fw-bold); }
.ctx-task-done { color: var(--text-muted); text-decoration: line-through; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: var(--r-pill);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-2);
  font: inherit; font-size: var(--fs-xs); cursor: pointer;
}
.tag-chip.on { color: var(--text-on-brand); background: var(--brand); border-color: var(--brand); }
.tag-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.clp-assignee { font-size: var(--fs-xs); color: var(--text-muted); }
.ctx-toggle { display: none; }
.desk-menu { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; flex-basis: 100%; }
/* Кнопки не сжимаются: «Взять себе» не разламывается на две строки. */
.desk-menu > *, .desk-menu .btn { flex: none; white-space: nowrap; }
.desk-more { position: relative; }
.desk-more > summary { list-style: none; }
.desk-more > summary::-webkit-details-marker { display: none; }
.desk-more-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 60; min-width: 210px;
  display: flex; flex-direction: column; gap: 2px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-pop);
}
.desk-more-menu .btn { justify-content: flex-start; width: 100%; border-color: transparent; background: transparent; border-radius: var(--r-sm); }
.desk-more-menu .btn:hover { background: var(--surface-hover); }
@media (max-width: 1279px) {
  .ctx-toggle { display: inline-flex; }
  .chat-context {
    position: fixed; top: var(--topnav-h); right: 0; bottom: 0; z-index: 300; width: min(360px, 92vw);
    box-shadow: var(--shadow-pop); transform: translateX(105%); transition: transform .2s ease;
  }
  .chat-context.open { transform: translateX(0); }
}

/* S10: «Контроль» */
.ctl-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.ctl-periods { margin-left: auto; padding: 0; }
.ctl-den { font-size: var(--fs-md); }
a.stat-tile { color: inherit; text-decoration: none; }
a.stat-tile:hover { border-color: var(--brand); }
.ctl-funnel { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.ctl-funnel li { display: grid; grid-template-columns: 120px 1fr 48px; align-items: center; gap: 10px; }
.ctl-funnel-label { font-size: var(--fs-sm); color: var(--text-2); }
.ctl-funnel-bar { height: 10px; border-radius: 5px; background: var(--neutral-bg); overflow: hidden; }
.ctl-funnel-bar span { display: block; height: 100%; background: var(--brand); }
.ctl-funnel b { text-align: right; font-variant-numeric: tabular-nums; }

/* S12: состояние канала, разделы настроек, диагностика */
.channel-pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill);
  border: 1px solid var(--border); color: var(--text-2); text-decoration: none; font-size: var(--fs-xs); }
.channel-pill:hover { border-color: var(--brand); }
.channel-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; background: var(--neutral); }
.channel-ok { background: var(--ok); }
.channel-warn { background: var(--warn); }
.channel-danger { background: var(--danger); }
.channel-neutral { background: var(--neutral); }
.settings-nav { padding: 0 0 14px; }
.app-footer { text-align: center; font-size: var(--fs-xs); padding: 24px 0 8px; }
.diag-log { max-height: 280px; overflow: auto; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px; font-size: var(--fs-xs); white-space: pre-wrap; }
@media (max-width: 860px) { .channel-label { display: none; } }

/* S13: AI-помощник */
.ai-btn { white-space: nowrap; }
.ai-out { margin-top: 8px; white-space: pre-wrap; font-size: var(--fs-sm); }
.ai-out:empty { display: none; }
.ai-check { color: var(--warn); font-weight: var(--fw-bold); font-size: var(--fs-xs); margin-bottom: 6px; }
.ai-table { width: 100%; border-collapse: collapse; font-size: var(--fs-xs); margin-bottom: 6px; }
.ai-table th { text-align: left; color: var(--text-muted); font-weight: var(--fw-medium); padding: 2px 4px; }
.ai-table td { padding: 2px; }
.ai-table input { width: 100%; padding: 3px 5px; font-size: var(--fs-xs); }
.cluster { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cluster > input { flex: 1; min-width: 180px; }
/* Фильтры в строку: выпадающие списки и даты — по содержимому, а не на всю ширину. */
.cluster > select, .cluster > label > select, .cluster > label > input[type=date] { width: auto; max-width: 100%; }
.cluster > label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: var(--fw-regular, 400); }
.cluster > input[type=date] { flex: 0 1 auto; min-width: 0; width: auto; }

/* S14: служебные классы (вместо inline-стилей) и доступность */
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.page-tabs { padding: 0 0 12px; }
.contacts-filters > input[type=search] { flex: 1; min-width: 220px; }
.template-group { border: 0; padding: 0; margin: 0; min-width: 0; }
.template-choice { display: block; }
.template-choice:focus-within { outline: var(--focus); outline-offset: 2px; }
.icon { vertical-align: -0.15em; }

/* S14: полоса KPI */
.kpi-strip {
  display: flex; align-items: stretch; gap: 0; min-height: 56px; max-height: 64px; margin-bottom: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow-x: auto;
  box-shadow: var(--shadow-1);
}
.kpi { display: flex; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 14px; min-width: 104px;
  border-right: 1px solid var(--border); white-space: nowrap; }
.kpi:last-child { border-right: 0; }
.kpi-label { font-size: var(--fs-xs); color: var(--text-muted); }
.kpi-value { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-value .dl-value { font-size: inherit; }
.kpi-sub { font-size: var(--fs-xs); font-weight: var(--fw-regular); color: var(--text-muted); }
.kpi-accent .kpi-value { color: var(--brand-text); }
.kpi-limit { min-width: 160px; }
.kpi-bar { display: block; height: 4px; border-radius: 2px; background: var(--neutral-bg); overflow: hidden; }
.kpi-bar > span { display: block; height: 100%; background: var(--ok); }
.kpi-limit.warn .kpi-bar > span { background: var(--warn); }
.kpi-limit.danger .kpi-bar > span { background: var(--danger); }
.kpi-link { margin-left: auto; justify-content: center; color: var(--brand-text); font-size: var(--fs-sm); }
.kpi-links { margin-left: auto; gap: 4px; }
.kpi-links .kpi-link { margin: 0; display: inline-flex; align-items: center; gap: 5px; font-weight: var(--fw-medium); }
/* Телефон: сводка — сетка 2×2 вместо полосы с прокруткой вбок, ссылки — отдельной строкой. */
@media (max-width: 759px) {
  /* Линии между ячейками — фоном полосы сквозь зазор 1 px (без привязки к позиции плитки). */
  .kpi-strip { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); max-height: none; overflow: hidden; }
  .kpi { min-width: 0; white-space: normal; border: 0; background: var(--surface); }
  .kpi.kpi-links { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; flex-wrap: wrap; margin: 0; }
}
.stat-grid.compact .stat-tile { padding: 10px 12px; }
.stat-grid.compact .value { font-size: var(--fs-lg); }

.trend-bar-value { font-size: var(--fs-xs); color: var(--text-2); text-align: center; font-variant-numeric: tabular-nums; min-height: 1.2em; }
.reply-preview { color: var(--text); }
.small-value { font-size: 1rem; }

/* S14: служебные классы вместо частых inline-стилей (настройки, мастер кампании) */
.m-0 { margin: 0; }
.mb-0 { margin-bottom: 0; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.grow { flex: 1; min-width: 160px; }
.grow-wide { flex: 1; min-width: 220px; }
.no-grow { flex: none; }
.min-160 { min-width: 160px; }
.align-end { align-items: flex-end; }
.nowrap { white-space: nowrap; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-inline { font-weight: 400; display: flex; align-items: center; gap: 5px; }

/* S14: рабочие экраны начинаются с работы — плотнее сверху */
.card.card-tight { padding-top: 10px; }
.page-head + .mock-banner, .page-head + .kpi-strip { margin-top: -4px; }
.mock-banner { padding-top: 8px; padding-bottom: 8px; margin-bottom: 10px; }
.kpi-strip + nav.inbox-tabs, .kpi-strip + .dl-note + nav.inbox-tabs { padding-bottom: 6px !important; }

/* 1.1.1: подключение в один шаг и «с чего начать» */
.connect-card { border-color: var(--brand); border-width: 2px; }
.card[id] { scroll-margin-top: calc(var(--topnav-h) + 12px); }  /* ссылки вида #connect не прячут заголовок под шапку */
.connect-card h2 { display: flex; align-items: center; gap: 8px; }
.connect-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 12px 0 6px; }
.connect-form input { flex: 1; min-width: 260px; font-size: var(--fs-lg); padding: 10px 14px; }
.connect-form .btn { padding: 10px 24px; font-size: var(--fs-lg); }
.connect-steps { margin: 8px 0 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.connect-steps li.done { color: var(--text-muted); }
.connect-steps li.done::marker { color: var(--ok); }
.getting-started { text-align: left; max-width: 640px; margin: 0 auto; }
.getting-started h2 { margin-top: 0; }
a.demo-link { text-decoration: none; }
a.demo-link:hover { text-decoration: underline; }
.stack-form { display: flex; flex-direction: column; gap: 6px; max-width: 460px; }
/* Этап 2: контакты, компании, импорт */
.filters-more { margin-top: 8px; }
.filters-more summary { cursor: pointer; color: var(--text-2); font-size: var(--fs-sm); }
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 12px; margin: 8px 0; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2, var(--surface)); position: sticky; top: calc(var(--topnav-h) + 4px); z-index: 5; }
.bulk-bar[hidden] { display: none; }
.bulk-bar select, .bulk-bar input[type=text] { width: auto; max-width: 100%; }
.bulk-bar label { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.col-check { width: 32px; }
.dropzone { border: 2px dashed var(--control-border); border-radius: var(--r-md); padding: 28px 16px; text-align: center; color: var(--text-2); cursor: pointer; }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.map-table select { min-width: 170px; }
.map-table td, .map-table th { white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin: 10px 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px 14px; }
.chat-optout-note { padding: 6px 12px; display: flex; gap: 6px; align-items: flex-start; }

/* ---------------------------------------------------------------- 14. Тосты */
.toast-wrap {
  position: fixed; top: 16px; right: 16px; z-index: 500;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: min(380px, 92vw);
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: var(--r-md);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left-width: 4px;
  box-shadow: var(--shadow-pop); font-size: var(--fs-md); line-height: 1.4;
  transform: translateX(16px); opacity: 0; transition: transform .2s ease, opacity .2s ease;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast-ico { flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-weight: var(--fw-bold); font-size: var(--fs-sm); }
.toast-success { border-left-color: var(--ok); }
.toast-success .toast-ico { background: var(--ok-bg); color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-ico { background: var(--danger-bg); color: var(--danger); }
.toast-info { border-left-color: var(--info); }
.toast-info .toast-ico { background: var(--info-bg); color: var(--info); }
.toast-msg { flex: 1; }
.toast-close { flex-shrink: 0; background: none; border: 0; padding: 0 2px; margin-left: 4px; color: inherit; opacity: .7; font-size: var(--fs-lg); line-height: 1; cursor: pointer; }
.toast-close:hover, .toast-close:focus-visible { opacity: 1; }

/* ---------------------------------------------------------------- 15. Командная палитра (Ctrl+K) */
.cmdk { position: fixed; inset: 0; z-index: 480; opacity: 0; visibility: hidden; transition: opacity .15s ease, visibility .15s; }
.cmdk.show { opacity: 1; visibility: visible; }
/* Единственное размытие в интерфейсе — фон модального окна. */
.cmdk-backdrop { position: absolute; inset: 0; background: rgba(11, 20, 26, 0.45); backdrop-filter: blur(2px); }
.cmdk-panel {
  position: absolute; left: 50%; top: 14vh; transform: translateX(-50%); width: min(600px, 92vw);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-pop);
}
.cmdk-inp { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.cmdk-search { color: var(--brand-text); font-size: var(--fs-lg); }
.cmdk-inp:focus-within { box-shadow: inset 0 -2px 0 var(--brand); }
.cmdk-inp input { flex: 1; background: none; border: none; outline: none; color: var(--text); font: inherit; font-size: var(--fs-lg); padding: 0; }
.cmdk-list { max-height: 46vh; overflow-y: auto; padding: 6px; }
.cmdk-item { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: var(--r-md); cursor: pointer; border-left: 3px solid transparent; }
.cmdk-item.on { background: var(--brand-soft); border-left-color: var(--brand); }
.cmdk-t { color: var(--text); font-weight: var(--fw-bold); }
.cmdk-s { color: var(--text-muted); font-size: var(--fs-sm); }
.cmdk-empty { padding: 28px; text-align: center; color: var(--text-muted); }
.cmdk-foot { display: flex; gap: 18px; padding: 9px 16px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: var(--fs-xs); }
.cmdk-foot kbd { margin-right: 3px; }
.cmdk-chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px; border-radius: var(--r-sm);
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text-2);
  font: inherit; font-size: var(--fs-xs); font-weight: var(--fw-medium); cursor: pointer;
}
.cmdk-chip:hover { border-color: var(--brand); color: var(--brand-text); }

/* ---------------------------------------------------------------- 16. Узкие экраны */
@media (max-width: 860px) {
  .topnav-inner { padding: 0 12px; gap: 4px; }
  .topnav-brand span:last-child { display: none; }
  .topnav-links a { padding: 0 6px; }
  .topnav-user { display: none; }
  .container { padding: 16px 12px 40px; }
}
@media (max-width: 700px) {
  .daily-limit-row { grid-template-columns: 1fr; }
  .cmdk-chip { display: none; }
}

/* ---------------------------------------------------------------- 17. Телефон (S14) */
.mobile-tabs, .chat-back { display: none; }
.chat-input-bar { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
@media (max-width: 759px) {
  :root { --mobile-tabs-h: 58px; }
  .topnav-links, .topnav-user, .cmdk-chip { display: none; }
  .topnav-inner { padding: 0 12px; }
  .container { padding: 12px 10px calc(var(--mobile-tabs-h) + 16px); }
  h1 { font-size: 1.35rem; }

  .mobile-tabs {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 250;
    height: calc(var(--mobile-tabs-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: var(--shadow-1);
  }
  .mobile-tabs > a, .mobile-more > summary {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 44px; color: var(--text-2); font-size: var(--fs-xs); text-decoration: none; cursor: pointer; list-style: none;
  }
  .mobile-more { flex: 1; display: flex; position: relative; }
  .mobile-more > summary::-webkit-details-marker { display: none; }
  .mobile-tabs > a.active { color: var(--brand-text); font-weight: var(--fw-bold); }
  .mobile-more-menu {
    position: absolute; right: 8px; bottom: calc(100% + 6px); min-width: 180px; display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  }
  .mobile-more-menu a, .mobile-more-menu .btn { padding: 12px 16px; min-height: 44px; color: var(--text); text-align: left; }

  /* Цели нажатия не меньше 44 px */
  .btn, .inbox-tab, select, input[type=text], input[type=tel], input[type=search], .qr-chip-text, .tag-chip { min-height: 44px; }
  .btn-sm { min-height: 40px; }

  /* Чат: одна панель — список или тред с «←»; высота по видимой области (клавиатура не прячет поле ввода) */
  .chat-shell { height: calc(100dvh - var(--topnav-h) - var(--mobile-tabs-h) - 24px); min-height: 0; border-radius: var(--r-md); }
  .chat-list-pane { width: 100%; border-right: 0; }
  .chat-shell.has-active .chat-list-pane { display: none; }
  .chat-shell:not(.has-active) .chat-thread-pane { display: none; }
  .chat-back { display: inline-flex; }
  .chat-thread-header { flex-wrap: wrap; padding: 8px 10px; gap: 8px; }
  .desk-menu { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
  .desk-menu::-webkit-scrollbar { display: none; }
  /* Меню «Ещё» в прокручиваемой полосе кнопок — листом над нижними вкладками, чтобы не обрезалось. */
  .desk-more-menu { position: fixed; top: auto; left: 10px; right: 10px; bottom: calc(var(--mobile-tabs-h) + 12px); }
  .desk-more-menu .btn { min-height: 44px; }
  .conv-status-select { max-width: 46vw; }
  .chat-messages { padding: 10px; }
  .wa-bubble, .chat-msg { max-width: 88%; }
  .chat-input-bar { position: sticky; bottom: 0; padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)); gap: 6px; }
  .quick-replies-bar { flex-wrap: nowrap; overflow-x: auto; padding: 6px 10px 0; }
  .qr-hint { display: none; }

  /* Панель «О клиенте» — лист снизу */
  .chat-context {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 78dvh; border-left: 0;
    border-top-left-radius: var(--r-lg); border-top-right-radius: var(--r-lg);
    transform: translateY(105%);
  }
  .chat-context.open { transform: translateY(0); }

  /* Таблицы — прокрутка внутри своей карточки, страница не ездит вбок */
  .card { padding: 14px 12px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row { flex-direction: column; align-items: stretch !important; }
  .field-row > .field { min-width: 0 !important; }
}

/* Этап 4: рабочее место чатов — внутренние заметки, поиск в переписке, связь */
.chat-msg.note { align-self: center; max-width: 86%; background: var(--warn-bg); border: 1px dashed var(--warn-border); color: var(--text); }
.chat-msg.note .cm-label { color: var(--warn); font-weight: var(--fw-bold, 600); }
#chat-input.note-mode { background: var(--warn-bg); border-color: var(--warn-border); }
.btn.btn-note { background: var(--warn); border-color: var(--warn); color: #fff; }
#note-mode-btn.active { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn); }
.thread-tools { display: flex; gap: 8px; align-items: center; padding: 6px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.thread-tools input[type=search] { width: auto; flex: 0 1 240px; padding: 4px 9px; font-size: var(--fs-sm); }
.chat-offline { color: var(--danger); font-size: var(--fs-sm); }
.chat-msg.found { outline: 2px solid var(--brand); outline-offset: 2px; }
.qr-category { width: auto; padding: 2px 6px; font-size: var(--fs-sm); }

/* Этап 5: заявки */
.lead-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(280px, 2fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .lead-grid { grid-template-columns: 1fr; } }
.lead-form[disabled] { opacity: .75; }
.items-table input { min-width: 90px; padding: 5px 8px; }
.items-table .i-name { min-width: 180px; }
.fact-list { list-style: none; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 8px; }
.fact { padding: 6px 8px; border-radius: var(--r-md); border: 1px solid var(--border); }
.fact-conflict { border-color: var(--danger-border); }
.fact-confirmed { background: var(--surface); }
.tight-list { margin: 4px 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }
.tight-list.small { font-size: var(--fs-sm); }
.lead-status-draft, .lead-status-cancelled, .lead-status-duplicate, .lead-status-not_target { color: var(--text-2); background: var(--surface-2, var(--surface)); border-color: var(--border); }
.lead-status-forming, .lead-status-needs_info, .lead-status-handing_off { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.lead-status-ready, .lead-status-handed_off { color: var(--info, var(--brand-text)); background: var(--info-bg, var(--brand-soft)); border-color: var(--info-border, var(--brand)); }
.lead-status-accepted { color: var(--ok); background: var(--ok-bg, var(--brand-soft)); border-color: var(--ok-border, var(--brand)); }
.lead-status-handoff_failed { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.inbox-tabs-lead { flex-wrap: wrap; gap: 4px; padding-top: 0; }
.inbox-tabs-lead .inbox-tab { font-size: var(--fs-xs); padding: 3px 8px; }
.ctx-lead { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.lead-form { border: 0; padding: 0; margin: 0; min-width: 0; }
.handoff-row { padding: 8px 0; border-top: 1px solid var(--border); }
.handoff-row:first-of-type { border-top: 0; }

/* Этап 7: панель */
.section-title { margin: 20px 0 8px; font-size: var(--fs-lg); }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.kpi-grid a.stat-tile { text-decoration: none; color: inherit; }
.kpi-grid a.stat-tile:hover { border-color: var(--brand); }
.stat-tile.danger .value { color: var(--danger); }
.period-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border: 1px solid var(--border);
  border-radius: var(--r-pill); cursor: pointer; margin: 0; font-weight: var(--fw-regular, 400); }
.period-chip input { width: auto; margin: 0; }
.period-chip.active { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); }
.metric-table { width: 100%; }
.metric-table td { padding: 5px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.metric-table td.num { text-align: right; white-space: nowrap; }
.grid-2 > * { min-width: 0; }
.metric-table td:last-child { overflow-wrap: anywhere; }
.metric-table td:first-child { overflow-wrap: anywhere; }

/* «Чаты» как в WhatsApp: четыре главные вкладки, остальные отборы — под «Ещё фильтры» */
.chat-more-filters { margin: 2px 0 6px; }
.chat-more-filters > summary { cursor: pointer; padding: 2px 4px; list-style: none; }
.chat-more-filters > summary::before { content: "▸ "; }
.chat-more-filters[open] > summary::before { content: "▾ "; }

/* ---------------------------------------------------------------- 18. «Как поднять лимит» (1.3.0) */
.lim-hero { display: flex; align-items: stretch; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.lim-tile {
  flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 4px; padding: 18px 20px;
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-1);
}
.lim-goal { background: var(--brand-soft); border: 1px solid var(--ok-border); }
.lim-label { font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-medium); }
.lim-big { font-size: 30px; font-weight: var(--fw-bold); color: var(--text); line-height: 1.15; }
.lim-goal .lim-big { color: var(--brand-text); }
.lim-arrow { align-self: center; font-size: 30px; color: var(--brand); }
.lim-step h2 { display: flex; align-items: center; gap: 10px; font-size: 19px; }
.lim-step h2 .step-num { width: 30px; height: 30px; font-size: var(--fs-md); }
.lim-progress { height: 16px; border-radius: var(--r-pill); background: var(--neutral-bg); overflow: hidden; margin: 12px 0 6px; }
.lim-progress-fill { height: 100%; border-radius: var(--r-pill); background: var(--brand); min-width: 4px; }
.lim-progress-text { font-size: var(--fs-lg); margin: 0 0 8px; }
.lim-days { display: flex; align-items: flex-end; gap: 10px; height: 120px; margin-top: 12px; max-width: 520px; }
.lim-day { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; }
.lim-day-bar { width: 100%; max-width: 40px; min-height: 3px; border-radius: 6px 6px 0 0; background: var(--brand); }
.lim-day-val { font-size: var(--fs-xs); color: var(--text-2); font-variant-numeric: tabular-nums; }
.lim-day-label { font-size: var(--fs-xs); color: var(--text-muted); }
.lim-checks { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.lim-check {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-lg);
  border: 1px solid var(--neutral-border); background: var(--surface-2);
}
.lim-check-main { flex: 1; min-width: 0; }
.lim-check-main small { display: block; color: var(--text-muted); font-size: var(--fs-sm); }
.lim-check-val { font-weight: var(--fw-bold); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lim-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--neutral); }
.lim-ok { border-color: var(--ok-border); background: var(--ok-bg); }
.lim-ok .lim-dot { background: var(--ok); }
.lim-warn { border-color: var(--warn-border); background: var(--warn-bg); }
.lim-warn .lim-dot { background: var(--warn); }
.lim-danger { border-color: var(--danger-border); background: var(--danger-bg); }
.lim-danger .lim-dot { background: var(--danger); }
.lim-letter textarea { font-family: ui-monospace, Consolas, monospace; font-size: var(--fs-sm); background: var(--surface-2); }
@media (max-width: 700px) { .lim-arrow { display: none; } }
@media print {
  .topnav, .mobile-tabs, .app-footer, .no-print, .health-banner { display: none !important; }
  body, html { background: #fff !important; }
  .card, .lim-tile { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .lim-letter textarea[hidden] { display: none; }
}


/* ---------------------------------------------------------------- 19. Минимальный вид (1.4.0)
   Три раздела: Чаты, Рассылки, Настройки. Светлая шапка, белые панели, зелёный — акцент. */
.topnav { box-shadow: none; border-bottom: 1px solid var(--border); }
.topnav-brand .logo-mark { background: var(--brand); color: #ffffff; }
.topnav .btn-primary { background: var(--brand); color: var(--text-on-brand); }
.topnav-links a { border-radius: var(--r-sm); }
.topnav-links a.active { color: var(--brand-text); }
.card { border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.page-head h1 { letter-spacing: -0.01em; }

/* Чаты */
.chat-shell { border-radius: var(--r-lg); }
.chat-list-header { padding: 14px 14px 8px; }
.chat-list-title { font-size: var(--fs-xl); margin: 0 0 10px; }
input.chat-search, input.chat-search:focus { border: 1px solid transparent; background: var(--surface-2); padding: 8px 14px; }
.chat-list-item { border-bottom-color: transparent; border-left-width: 0; margin: 0 6px; border-radius: var(--r-md); }
.chat-list-item.active { background: var(--surface-hover); }
.chat-thread-pane { position: relative; }
.chat-thread-header { background: var(--surface); padding: 10px 18px; min-height: 60px; }
.cth-name { font-size: var(--fs-lg); }
.cth-company { color: var(--text-muted); font-weight: var(--fw-regular); }
.thread-tools { position: absolute; top: 14px; right: 18px; z-index: 2; display: flex; gap: 8px; align-items: center; }
.thread-tools input[type=search] { width: 190px; padding: 6px 12px; border-radius: var(--r-pill); border: 0; background: var(--surface-2); font-size: var(--fs-sm); }
.chat-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; height: 100%;
  color: var(--text-muted); text-align: center; background: var(--surface-2); }
.chat-empty b { color: var(--text); font-size: var(--fs-xl); font-weight: var(--fw-medium); }
.chat-empty-mark { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand-text); margin-bottom: 6px; }
.chat-input-bar { background: var(--surface-2); align-items: flex-end; }
.chat-input-bar textarea { border-radius: var(--r-lg); border-color: transparent; background: var(--surface); }
.chat-attach { border: 0; background: transparent; color: var(--text-2); padding: 8px; }
.chat-send { width: 42px; height: 42px; min-height: 42px; padding: 0; border-radius: 50%; flex: none; }
.chat-window-closed { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: space-between; }

/* Рассылки: статистика по дням */
.stats-card { padding-bottom: 12px; }
.stats-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.stats-head h2 { margin: 0; }
.stats-limit { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-2);
  padding: 3px 10px; border-radius: var(--r-pill); background: var(--surface-2); }
.stats-limit.warn { color: var(--warn); background: var(--warn-bg); }
.stats-limit.danger { color: var(--danger); background: var(--danger-bg); }
.stats-table th, .stats-table td { white-space: nowrap; font-variant-numeric: tabular-nums; }
.stats-table tbody th { font-weight: var(--fw-medium); text-align: left; }
.stats-table tr.is-today th, .stats-table tr.is-today td { background: var(--brand-soft); }
.stats-table .pct { color: var(--text-muted); font-size: var(--fs-xs); margin-left: 2px; }
.stats-table .good { color: var(--ok); font-weight: var(--fw-bold); }
.stats-table .bad { color: var(--danger); }

/* Настройки: ссылка для входа и сотрудники */
.set-link-row { display: flex; gap: 8px; align-items: center; }
.set-link-row input { flex: 1; min-width: 0; font-size: var(--fs-lg); padding: 10px 14px; background: var(--surface-2); }
.set-code { font-size: 1.4rem; letter-spacing: 2px; }
.set-users { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; }
.set-user { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 0; border-bottom: 1px solid var(--border); }
.set-user-name { flex: 1; min-width: 160px; }
.set-user-actions { display: flex; gap: 6px; margin: 0; }
.set-user-actions input { width: 120px; }
.set-add-title { margin-top: 6px; }
.set-add { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.set-add input, .set-add select { flex: 1; min-width: 150px; width: auto; }
.set-user-accounts { flex-basis: 100%; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0; }
.set-user-accounts fieldset, .set-add-accounts { display: flex; align-items: center; gap: 4px 14px; flex-wrap: wrap; border: 0; margin: 0; padding: 0; }
.set-user-accounts legend, .set-add-accounts legend { float: left; margin: 0 6px 0 0; padding: 0; }
.set-add-accounts { flex-basis: 100%; }
.set-check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); cursor: pointer; }
.set-check input, .set-add .set-check input { flex: none; min-width: 0; width: auto; margin: 0; }
.acc-rename input { width: 200px; }
@media (max-width: 759px) {
  .thread-tools { position: static; padding: 6px 10px 0; }
  .thread-tools input[type=search] { width: 100%; }
  .set-link-row { flex-direction: column; align-items: stretch; }
}

/* «Написать шаблоном»: шаблоны карточками с полным текстом */
.cd-box { display: flex; flex-direction: column; gap: 10px; }
.cd-head { display: flex; flex-direction: column; gap: 2px; }
.cd-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; }
.cd-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 10px 12px; cursor: pointer;
  background: var(--bubble-out); color: var(--text); border: 2px solid transparent; border-radius: var(--r-md);
  font: inherit; box-shadow: var(--shadow-1); }
.cd-card:hover { border-color: var(--border-strong); }
.cd-card[aria-checked="true"] { border-color: var(--brand); }
.cd-card-name { font-size: var(--fs-xs); color: var(--text-muted); }
.cd-card-body { white-space: pre-wrap; font-size: var(--fs-md); line-height: 1.4; }
.cd-variables { display: flex; gap: 8px; flex-wrap: wrap; }
.cd-variables .field { flex: 1; min-width: 180px; margin: 0; }
.cd-preview-wrap { display: flex; flex-direction: column; gap: 4px; }
.cd-actions { display: flex; gap: 8px; align-items: center; }

/* Галочки как в WhatsApp: серые — отправлено/дошло, ярко-синие и жирнее — прочитано */
.cm-ticks, .chat-msg .cm-meta .cm-ticks { color: var(--tick-sent); font-weight: var(--fw-bold); letter-spacing: -2px; }
.cm-ticks.ticks-read, .chat-msg .cm-meta .ticks-read, .clp-preview .ticks-read { color: var(--tick-read); }
.cm-ticks.ticks-failed, .cm-ticks.ticks-unknown { color: var(--danger); letter-spacing: 0; }
.clp-preview .ticks-read { font-weight: var(--fw-bold); }

/* «Отчёты по клиентам»: две плитки (без файла / своя база), цвета результатов — как в Excel.
   Подложки мягкие (токены --*-bg), текст на них — тёмный своего цвета: спокойно для глаз и в тёмной теме. */
.base-check { padding: 20px 22px; }
.base-check .stats-head { margin-bottom: 2px; }
.base-check .bc-legend { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 2px; }
.bc-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px;
  border: 1px solid transparent; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); line-height: 1.6; white-space: nowrap;
}
.bc-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .75; }
.bc-chip b { font-weight: var(--fw-bold); font-variant-numeric: tabular-nums; }
.bc-ok      { color: var(--ok);      background: var(--ok-bg);      border-color: var(--ok-border); }
.bc-info    { color: var(--info);    background: var(--info-bg);    border-color: var(--info-border); }
.bc-neutral { color: var(--neutral); background: var(--neutral-bg); border-color: var(--neutral-border); }
.bc-warn    { color: var(--warn);    background: var(--warn-bg);    border-color: var(--warn-border); }
.bc-danger  { color: var(--danger);  background: var(--danger-bg);  border-color: var(--danger-border); }
.bc-totals .bc-chip { font-size: var(--fs-sm); padding: 4px 12px 4px 10px; }

.bc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.bc-tile {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 16px 18px 16px 20px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  overflow: hidden;
}
/* Тонкая цветная кромка слева: зелёная — главное действие, синяя — проверка своего файла */
.bc-tile::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; }
.bc-tile-sent  { background: linear-gradient(180deg, var(--brand-soft), transparent 70%), var(--surface); }
.bc-tile-sent::before  { background: var(--brand); }
.bc-tile-check { background: linear-gradient(180deg, var(--info-bg), transparent 70%), var(--surface); }
.bc-tile-check::before { background: var(--info); opacity: .6; }
.bc-tile-title { margin: 0; font-size: var(--fs-md); font-weight: var(--fw-bold); color: var(--text); }
.bc-tile .small-note { margin: 0; line-height: 1.5; }
.base-check .bc-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.base-check .bc-row input[type=file] { flex: 1; min-width: 180px; }
.base-check .bc-row select { flex: 1; min-width: 150px; }
#bc-result:not(:empty) { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
#bc-result .small-note { margin: 0 0 6px; }
@media (max-width: 759px) {
  .base-check { padding: 16px; }
  .bc-grid { grid-template-columns: 1fr; gap: 10px; }
  .bc-chip { white-space: normal; }
}

/* ---------------------------------------------------------------- 1.4.7: полировка */
/* Выбор файла — кнопкой в стиле программы, а не серой системной */
input[type=file] { padding: 5px 6px; cursor: pointer; color: var(--text-2); font-size: var(--fs-sm); }
input[type=file]::file-selector-button {
  margin-right: 10px; padding: 6px 14px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: var(--fw-medium);
}
input[type=file]::file-selector-button:hover { border-color: var(--brand); color: var(--brand-text); }

/* Счётчики отчёта: ровные ряды по 4 (не «6 + 2»), на телефоне — по 3 */
.stat-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.filters select { max-width: 280px; }
@media (max-width: 759px) {
  .stat-grid.compact { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat-grid.compact .stat-tile { padding: 8px 10px; }
  .stat-grid.compact .label { font-size: var(--fs-xs); }
  /* Список рассылок: значок занимает место, действия — под текстом во всю ширину */
  .camp-avatar { display: none; }
  .camp-actions { padding-left: 0; }
  .filters form { flex-wrap: wrap; }
  .filters select { max-width: none; }
  .base-check .bc-row input[type=file] { flex-basis: 100%; }
  .base-check .bc-row .btn { width: 100%; }
}

/* ---------------------------------------------------------------- 1.5: спокойный премиальный вид
   Тише и аккуратнее, а не ярче: одна серо-зелёная гамма (токены), мягкие тонированные тени, ровный
   ритм отступов, плавные (но короткие) состояния кнопок и полей. Компоненты о теме не знают. */
html { scroll-behavior: smooth; }
body { text-rendering: optimizeLegibility; font-feature-settings: "kern"; }
h1, .page-head h1 { font-size: 26px; font-weight: var(--fw-bold); letter-spacing: -0.018em; line-height: 1.2; }
h2 { font-size: 17px; letter-spacing: -0.006em; line-height: 1.3; }
h3 { letter-spacing: -0.003em; }
.small-note, .muted { line-height: 1.55; }
p, .small-note { text-wrap: pretty; }

/* Шапка: тонкая линия вместо тени, активный раздел — мягкая плашка бренда */
.topnav { border-bottom: 1px solid var(--border); box-shadow: 0 1px 0 rgba(21, 45, 38, 0.02); }
.topnav-links a { transition: color .18s ease, background-color .18s ease; }
.topnav-links a.active { color: var(--brand-text); }

/* Карточки: чуть воздушнее, без жёстких рамок */
.card { border-color: var(--border); padding: 22px 24px; margin-bottom: 18px; }
.card > h2:first-child, .card .stats-head h2 { margin-bottom: 10px; }
.stat-tile { border-color: var(--border); transition: box-shadow .2s ease, border-color .2s ease; }
a.stat-tile:hover { border-color: var(--border-strong); box-shadow: var(--shadow-pop); }

/* Кнопки: мягкий отклик на наведение и нажатие */
.btn {
  transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease, color .18s ease,
              transform .12s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { box-shadow: 0 1px 2px rgba(13, 122, 97, 0.22); }
.btn-primary:hover { box-shadow: 0 4px 14px rgba(13, 122, 97, 0.24); }
.btn-danger:hover { box-shadow: 0 2px 10px rgba(180, 35, 24, 0.10); }

/* Поля: спокойная рамка, при фокусе — мягкий ореол бренда вдобавок к контуру */
input[type=text], input[type=password], input[type=file], input[type=tel], input[type=number], input[type=email],
input[type=time], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease;
}
input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) {
  border-color: var(--text-2);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { box-shadow: 0 0 0 4px var(--brand-soft); }

/* Таблицы: тихая шапка, разделители тоньше, наведение мягкое */
th { font-weight: var(--fw-medium); letter-spacing: 0.01em; color: var(--text-muted); border-bottom-color: var(--border); }
td { border-bottom-color: var(--border); }
tbody tr { transition: background-color .15s ease; }

/* Плашки, вкладки, баннеры */
.inbox-tab { transition: background-color .18s ease, color .18s ease; }
.alert, .mock-banner, .health-banner { border-radius: var(--r-md); line-height: 1.5; }
div.empty-state { border-style: dashed; border-color: var(--border-strong); background: var(--surface-2); }

/* Тёмная тема: кнопки на тёмной поверхности, а не светлые «системные» */
:root[data-theme="dark"] .card .btn:not(.btn-primary):not(.btn-danger):not(.btn-link) {
  background: var(--surface-2); border-color: var(--border-strong); color: var(--text);
}
:root[data-theme="dark"] .card .btn:not(.btn-primary):not(.btn-danger):not(.btn-link):hover {
  background: var(--surface-hover); border-color: var(--control-border);
}
:root[data-theme="dark"] .btn-primary { box-shadow: none; }
:root[data-theme="dark"] .btn-primary:hover { box-shadow: 0 4px 16px rgba(43, 174, 138, 0.22); }

/* Плитки показателей: число — главное на плитке, подпись — тихая */
.stat-tile { gap: 4px; }
.stat-tile .value { letter-spacing: -0.01em; }
.stat-grid.compact .stat-tile { padding: 12px 14px; }
.stat-grid.compact .value { font-size: 22px; font-weight: var(--fw-bold); }
.stat-tile .label { font-size: var(--fs-xs); letter-spacing: 0.01em; }
@media (max-width: 759px) {
  .stat-grid.compact .value { font-size: 18px; }
}
/* Ключ дополнительного номера: подсказка помещается целиком */
.acc-key input { min-width: 240px; }
@media (max-width: 759px) { .acc-key input { min-width: 0; } }

/* «Настройки → Отправка»: четыре поля в ряд, на телефоне — столбиком */
.limits-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px 12px; align-items: end; margin: 6px 0 4px; }
.limits-form label { margin: 0; font-size: var(--fs-sm); color: var(--text-2); }
.limits-form input { margin-top: 4px; }
@media (max-width: 759px) { .limits-form { grid-template-columns: 1fr 1fr; } .limits-form .btn { grid-column: 1 / -1; } }

/* ---------------------------------------------------------------- 1.6: кнопки и акценты (бежевый, небо, бордо)
   Зелёный — главное действие (как в WhatsApp), небесно-голубой — вторичные действия, выбор и фокус,
   бордовый — удалить/остановить/ошибка, бежевый — тёплые подложки и наведение. */
.btn {
  position: relative; min-height: 36px; padding: 7px 16px; gap: 7px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: var(--fw-medium); letter-spacing: 0.005em;
  box-shadow: 0 1px 1px rgba(70, 50, 25, 0.04);
}
.btn:hover:not(:disabled) { background: var(--beige); border-color: var(--control-border); color: var(--text); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:focus-visible { outline: var(--focus); outline-offset: 2px; }
.btn:disabled { opacity: .5; }

.btn-primary {
  background: var(--brand); border-color: var(--brand); color: var(--text-on-brand);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 1px 2px rgba(13, 122, 97, 0.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-hover); border-color: var(--brand-hover); color: var(--text-on-brand);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 6px 16px rgba(13, 122, 97, 0.24);
}

/* Небесная — вторичное, но важное действие: проверить, привязать, скачать */
.btn-sky { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }
.btn-sky:hover:not(:disabled) { background: var(--sky-soft); border-color: var(--sky); color: var(--info);
  box-shadow: 0 4px 12px rgba(47, 143, 203, 0.16); }

/* Бордовая — удалить, остановить, отключить */
.btn-danger { background: var(--surface); border-color: var(--danger-border); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--burgundy); color: var(--danger);
  box-shadow: 0 4px 12px rgba(122, 31, 46, 0.12); }

.btn-sm { min-height: 30px; padding: 4px 13px; font-size: var(--fs-sm); }
.btn-lg { min-height: 44px; padding: 10px 24px; }
.btn-link { color: var(--info); text-underline-offset: 3px; }
.btn-link:hover { color: var(--info); text-decoration: underline; }

/* Круглая кнопка-иконка («+ Новый чат») */
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 34px; height: 34px; padding: 0; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--ok-border); background: var(--brand-soft); color: var(--brand-text);
  font: inherit; font-size: 22px; font-weight: var(--fw-regular); line-height: 1;
  transition: background-color .18s ease, color .18s ease, transform .12s ease, box-shadow .18s ease;
}
.btn-icon:hover { background: var(--brand); border-color: var(--brand); color: var(--text-on-brand);
  box-shadow: 0 6px 16px rgba(13, 122, 97, 0.24); }
.btn-icon:active { transform: scale(0.94); }
.btn-icon:focus-visible { outline: var(--focus); outline-offset: 2px; }
/* «Удалить чат»: спокойная бордовая — заметна, но не кричит рядом с поиском. */
.btn-icon-danger { width: 32px; height: 32px; border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.btn-icon-danger:hover { background: var(--burgundy); border-color: var(--burgundy); color: #fff;
  box-shadow: 0 6px 16px rgba(122, 31, 46, 0.24); }

/* Выбор файла — бежевая кнопка в общей гамме */
input[type=file]::file-selector-button { background: var(--beige); border-color: var(--border-strong); }
input[type=file]::file-selector-button:hover { border-color: var(--sky); color: var(--info); }

/* Выбранная вкладка и выбранная карточка шаблона — небо */
.inbox-tab.active { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }
.cd-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  transition: border-color .18s ease, box-shadow .18s ease, background-color .18s ease; }
.cd-card:hover { border-color: var(--sky); background: var(--surface-2); }
.cd-card[aria-checked="true"] { border-color: var(--sky); background: var(--info-bg); box-shadow: 0 0 0 3px var(--sky-soft); }

/* Шапки таблиц и плиток — тёплая подложка */
th { background: var(--surface-2); }
.stat-tile { background: var(--surface); }

/* «Новый чат» */
.chat-list-titlebar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.chat-list-titlebar .chat-list-title { margin: 0; }
/* Прижат к верху: когда появляются поля и превью, окно растёт вниз, кнопки не прыгают под курсором. */
.newchat-dialog { width: min(640px, calc(100vw - 32px)); margin-top: 6vh; max-height: 88vh; overflow-y: auto; }
.newchat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.newchat-section-title { margin: 14px 0 6px; font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--text-2); }
.newchat-list { max-height: 240px; }
#newchat-variables { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.newchat-var { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: var(--fs-sm); }
.newchat-bubble { background: var(--bubble-out); color: var(--text); border-radius: 12px 12px 4px 12px;
  padding: 10px 12px; white-space: pre-wrap; max-width: 92%; margin-left: auto; box-shadow: var(--shadow-1); }
@media (max-width: 759px) {
  .newchat-row, #newchat-variables { grid-template-columns: 1fr; }
}

/* Ссылки в тексте сообщений — небесные, длинный адрес переносится, а не раздвигает пузырь. */
.chat-msg a.cm-text-link { color: var(--info); text-decoration: underline; text-underline-offset: 2px; overflow-wrap: anywhere; }
.chat-msg a.cm-text-link:hover { text-decoration-thickness: 2px; }

/* Поиск по переписке и «Удалить чат» — в одну строку в шапке чата. */
@media (min-width: 760px) {
  .thread-tools { flex-wrap: nowrap; }
  .thread-tools input[type=search] { flex: 0 1 190px; }
  .thread-tools form { flex: none; }
}
