/* Семантический CSS поверх Tailwind. Tailwind остаётся для прочих страниц.
 * Здесь — компоненты с динамическими цветами которые Tailwind безопасным
 * списком обслуживал плохо: .scenario-card, .hero-card, .sidebar. */

/* ============ Sidebar ============ */
.sidebar {
  width: 256px;
  height: 100dvh; /* dvh: на мобиле учитывает тулбар браузера (100vh прятал низ) */
  background: #1a1a2e;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  overflow-y: auto;
}
.sidebar__brand {
  padding: 16px 12px 20px;
}
.sidebar__brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}
.sidebar__brand p {
  font-size: 12px;
  color: #9ca3af;
  margin: 2px 0 0 0;
}
.sidebar__nav {
  flex: 1;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #d1d5db;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.sidebar__item svg { flex-shrink: 0; }
/* NEW-бейдж (пункт «Триггерные») */
.sidebar__badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}
.sidebar__item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.sidebar__item.is-active {
  background: #3b82f6;
  color: #fff;
}
.sidebar__footer {
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: #6b7280;
}
.sidebar__footer button {
  background: none;
  border: 0;
  color: #9ca3af;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.sidebar__footer button:hover { color: #fff; }

/* ============ Account switcher (мультилогин) ============ */
/* Единый размер/шрифт/выравнивание для ВСЕХ строк (текущий, другие акки, добавить,
   выйти). `.sidebar__footer .acct-row` (2 класса) перебивает legacy
   `.sidebar__footer button {font-size:12px;padding:0}` (класс+элемент) по специфичности. */
.acct-switch { position: relative; margin-bottom: 8px; }
.acct-menu {
  position: absolute;          /* всплывает НАД кнопкой — текущий аккаунт не прыгает */
  bottom: 100%;
  left: 0; right: 0;
  margin-bottom: 6px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  background: #23234a;
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.45);
}
.sidebar__footer .acct-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  color: #d1d5db;
  text-align: left;
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar__footer .acct-row:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar__footer .acct-row--current { background: rgba(255, 255, 255, 0.06); color: #fff; }
.acct-row__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-row__chev { flex-shrink: 0; color: #9ca3af; transition: transform 0.15s; }
.acct-row__chev--open { transform: rotate(180deg); }

/* ============ Mobile drawer (sidebar) ============ */
@media (max-width: 767px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar.is-open { transform: translateX(0); }
  .js-mobile-only { /* виден только на mobile */ }
  /* На мобиле drawer — тач-таргеты ≥44px (десктоп компактнее, py-2). */
  .sidebar__item { min-height: 44px; }
}
@media (min-width: 768px) {
  .js-mobile-only { display: none !important; }
}

/* ============ Hero / Потенциальная выручка ============ */
.hero-card {
  background: #059669;          /* emerald-600 */
  color: #fff;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}
.hero-card__label  { font-size: 14px; opacity: .9; }
.hero-card__value  { font-size: 36px; font-weight: 700; margin-top: 4px; word-break: break-word; }
.hero-card__meta   { font-size: 14px; opacity: .9; margin-top: 4px; }

/* ============ Scenario card (Где деньги) — 5 вариантов цвета ============ */
.scenario-card {
  --bg: #fef3c7;
  --border: #fcd34d;
  --accent: #d97706;
  --btn-bg: #fbbf24;
  --btn-hover: #f59e0b;
  --btn-text: #78350f;

  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}
.scenario-card--vip    { --bg: #fef3c7; --border: #fcd34d; --accent: #b45309; --btn-bg: #fbbf24; --btn-hover: #f59e0b; --btn-text: #78350f; }
.scenario-card--loyal  { --bg: #d1fae5; --border: #6ee7b7; --accent: #047857; --btn-bg: #34d399; --btn-hover: #10b981; --btn-text: #064e3b; }
.scenario-card--new    { --bg: #dbeafe; --border: #93c5fd; --accent: #1d4ed8; --btn-bg: #60a5fa; --btn-hover: #3b82f6; --btn-text: #1e3a8a; }
.scenario-card--active { --bg: #ede9fe; --border: #c4b5fd; --accent: #6d28d9; --btn-bg: #a78bfa; --btn-hover: #8b5cf6; --btn-text: #4c1d95; }
.scenario-card--lost   { --bg: #ffe4e6; --border: #fda4af; --accent: #be123c; --btn-bg: #fb7185; --btn-hover: #f43f5e; --btn-text: #881337; }

.scenario-card__head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.scenario-card__icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}
.scenario-card__title { font-size: 18px; font-weight: 700; color: #0f172a; margin: 0; }
.scenario-card__subtitle { font-size: 12px; color: #64748b; margin-top: 2px; }

.scenario-card__metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.scenario-card__metric {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  min-width: 0;
}
.scenario-card__metric-label { font-size: 12px; color: #64748b; }
.scenario-card__metric-value { font-size: 18px; font-weight: 700; color: var(--accent); word-break: break-word; }

.scenario-card__sms {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 16px;
}
.scenario-card__sms-label { font-size: 12px; color: #64748b; margin-bottom: 4px; }
.scenario-card__sms-text  { font-size: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #1e293b; margin: 0; }

.scenario-card__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  border: 0;
  cursor: pointer;
  transition: background 0.15s;
}
.scenario-card__btn:hover { background: var(--btn-hover); }

/* ============ AI Ассистент — quick prompts (pill row) ============ */
.assistant-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.assistant-quick__btn {
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 9999px;
  padding: 6px 14px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.assistant-quick__btn:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}
.assistant-quick__btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============ ИИ-маркетолог /ai (O7, мокап ai-chat.html) ============ */
/* Центральная колонка ~780px: «чат не делит экран ни с чем» + не узкий.
   Высота = вьюпорт минус p-4/p-8 паддинги <main> (как было у страницы). */
.aichat {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  height: calc(100dvh - 4rem);
}
@media (max-width: 767px) {
  .aichat { height: calc(100dvh - 2rem); }
}

/* ============ Chat (AI Ассистент) ============ */
.chat-shell {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 520px;
}
.chat-body {
  flex: 1 1 auto;
  overflow-y: auto;
  /* overflow-x:hidden — без него overflow-y:auto делает X тоже `auto` (CSS-спек:
     visible→auto когда другая ось не visible) → широкий контент (таблица/seg-card)
     заставлял ВЕСЬ чат свайпаться вбок на телефоне. Широкие таблицы скроллятся
     внутри себя (см. .chat-bubble table ниже), остальное вписано mobile-капом пузыря. */
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}
/* Ряд — flex; align-self на ряду = ключ от растягивания внутри chat-body (flex-col, stretch). */
.chat-row {
  display: flex;
  gap: 10px;                 /* mockup gap-2.5 */
  align-items: flex-start;
  margin-bottom: 16px;       /* mockup space-y-4 */
}
.chat-row--assistant { align-self: flex-start; justify-content: flex-start; }
.chat-row--user      { align-self: flex-end;   justify-content: flex-end; }
.chat-avatar {
  width: 28px; height: 28px; /* mockup w-7 h-7 */
  border-radius: 9999px;
  flex: 0 0 28px;
  display: flex; align-items: center; justify-content: center;
}
.chat-avatar svg { width: 16px; height: 16px; }
.chat-avatar--ai { background: #dbeafe; color: #2563eb; }
.chat-avatar--user { background: #2563eb; color: #fff; }
/* Bubble: flex:0 0 auto + width:fit-content + max-width — иначе block-дети от marked.js тянут шире. */
.chat-bubble,
.chat-bubble--ai {
  flex: 0 0 auto !important;
  min-width: 0;
  width: fit-content;
  max-width: 85%;            /* mockup max-w-[85%] */
  border-radius: 16px;       /* mockup rounded-2xl */
  padding: 10px 14px;        /* mockup px-3.5 py-2.5 */
  font-size: 13px;           /* mockup text-[13px] */
  line-height: 1.375;        /* mockup leading-snug */
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}
/* «хвост» пузыря — острый верхний угол со стороны автора (mockup rounded-tl-sm / rounded-tr-sm) */
.chat-bubble--ai   { border-top-left-radius: 4px; }
.chat-bubble--user {
  max-width: 85%;
  white-space: pre-wrap;
  border-top-right-radius: 4px;
}
/* Контент от marked.js (p, ul, ol, div) не должен растягивать родителя */
.chat-bubble > p,
.chat-bubble > ul,
.chat-bubble > ol,
.chat-bubble > pre,
.chat-bubble > div,
.chat-bubble > blockquote {
  margin: 0 0 8px 0;
  max-width: 100% !important;
}
.chat-bubble > *:last-child { margin-bottom: 0; }
.chat-bubble--ai:has(.seg-card) {
  max-width: min(720px, 92vw);
  padding: 0;
  background: transparent;
}
.chat-bubble--ai   { background: #f1f5f9; color: #1f2937; }  /* mockup bg-slate-100 */
.chat-bubble--user { background: #2563eb; color: #fff; }     /* mockup bg-blue-600 */
.chat-bubble--tool { background: #f8fafc; color: #64748b; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; border: 1px solid #e2e8f0; }
.chat-bubble__time { font-size: 11px; opacity: .7; margin-top: 6px; }
.chat-bubble--user .chat-bubble__time { color: #bfdbfe; }
.chat-bubble--ai   .chat-bubble__time { color: #9ca3af; }

/* Anti-overflow for long <pre><code> blocks (SQL, code) emitted by AI via marked.js */
.chat-bubble pre, .chat-bubble--ai pre {
  overflow-x: auto;
  white-space: pre;
  max-height: 360px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-bubble pre code, .chat-bubble--ai pre code { white-space: pre; word-break: normal; }

/* Typing dots */
.chat-typing {
  display: flex; gap: 4px; align-items: center;
}
.chat-typing__dot {
  width: 8px; height: 8px; border-radius: 9999px; background: #60a5fa;
  animation: chat-bounce 0.9s infinite;
}
.chat-typing__dot:nth-child(2) { animation-delay: 150ms; }
.chat-typing__dot:nth-child(3) { animation-delay: 300ms; }
@keyframes chat-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .55; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* Input bar */
.chat-input {
  border-top: 1px solid #e5e7eb;
  background: #f9fafb;
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-input textarea {
  flex: 1 1 auto;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  resize: none;
  background: #fff;
  outline: none;
  /* авто-рост (JS autoGrow) капается тут → дальше скролл внутри поля, не обрезка */
  max-height: 140px;
  overflow-y: auto;
  transition: box-shadow .15s, border-color .15s;
}
.chat-input textarea:focus { border-color: #3b82f6; box-shadow: 0 0 0 2px rgba(59,130,246,.25); }
.chat-input__send {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: 8px;
  background: #2563eb; color: #fff;
  display: flex; align-items: center; justify-content: center;
  border: 0; cursor: pointer;
  transition: background .15s, opacity .15s;
}
.chat-input__send:hover { background: #1d4ed8; }
.chat-input__send:disabled { opacity: .5; cursor: not-allowed; }

/* ============ Segment preview card (внутри AI ответа) ============ */
.seg-card {
  margin-top: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.seg-card__head {
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  color: #fff;
  padding: 10px 16px;
}
.seg-card__head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.seg-card__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.seg-card__desc { font-size: 13px; color: #4b5563; margin: 0; }
.seg-card__metrics {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
@media (max-width: 700px) {
  .seg-card__metrics { grid-template-columns: repeat(2, 1fr); }
}
.seg-metric {
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}
.seg-metric__label { font-size: 11px; color: #6b7280; margin: 0; }
.seg-metric__value { font-size: 15px; font-weight: 700; margin: 2px 0 0; }
.seg-metric--guests   { background: #eff6ff; }
.seg-metric--guests .seg-metric__value   { color: #1d4ed8; }
.seg-metric--conv     { background: #ecfdf5; }
.seg-metric--conv   .seg-metric__value   { color: #047857; }
.seg-metric--avg      { background: #fffbeb; }
.seg-metric--avg    .seg-metric__value   { color: #b45309; }
.seg-metric--rev      { background: #f5f3ff; }
.seg-metric--rev    .seg-metric__value   { color: #6d28d9; }
.seg-metric--romi     { background: #ecfdf5; }
.seg-metric--romi   .seg-metric__value   { color: #047857; }

.seg-card__sms {
  border: 1px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 12px;
}
.seg-card__sms-label { font-size: 11px; color: #6b7280; margin: 0 0 4px; }
.seg-card__sms-text  { font-size: 13px; font-style: italic; color: #1f2937; margin: 0; }

.seg-card__criteria summary {
  font-size: 12px; color: #6b7280; cursor: pointer; padding: 4px 0;
}
.seg-card__criteria summary:hover { color: #1f2937; }
.seg-card__criteria code {
  display: block; margin-top: 6px; padding: 8px 10px;
  background: #f8fafc; border-radius: 6px;
  font-size: 11px; word-break: break-all;
}

.seg-card__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  cursor: pointer; border: 0;
  text-decoration: none;
  white-space: normal;
  transition: background .15s, border-color .15s, color .15s;
  line-height: 1.2;
}
.seg-btn svg { flex-shrink: 0; }

/* seg-card должна нормально рендерить пробелы (внутри chat-bubble--ai наследует pre-wrap) */
.seg-card, .seg-card * { white-space: normal; }
.seg-card .seg-card__sms-text { white-space: pre-wrap; }
.seg-btn--ghost {
  background: #fff; color: #374151; border: 1px solid #d1d5db;
}
.seg-btn--ghost:hover { background: #f9fafb; }
.seg-btn--primary {
  background: #2563eb; color: #fff;
}
.seg-btn--primary:hover { background: #1d4ed8; }

/* ============ KPI card (Обзор) ============ */
.kpi-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.kpi-card__label  { font-size: 13px; color: #6b7280; }
.kpi-card__value  { font-size: 26px; font-weight: 700; color: #0f172a; word-break: break-word; line-height: 1.2; }
.kpi-card__delta  {
  font-size: 12px;
  color: #047857;
  display: inline-flex; align-items: center; gap: 4px;
}
.kpi-card__delta--neutral { color: #6b7280; }
.kpi-card__icon {
  position: absolute;
  top: 16px; right: 16px;
  width: 40px; height: 40px;
  border-radius: 9999px;
  background: #dbeafe;
  color: #2563eb;
  display: flex; align-items: center; justify-content: center;
}

/* ============ Insights cards ============ */
.ins-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  min-width: 0;
}
.ins-card__title {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 700; color: #0f172a;
  margin: 0;
}
.ins-card__title-icon { display: inline-flex; }
.ins-card__subtitle { font-size: 12px; color: #6b7280; margin: -8px 0 0; }
.ins-card__big { font-size: 28px; font-weight: 700; color: #0f172a; line-height: 1.1; }

/* LTV pair */
.ins-ltv {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.ins-ltv__cell {
  border-radius: 8px; padding: 10px 12px;
}
.ins-ltv__cell--hi { background: #ecfdf5; }
.ins-ltv__cell--lo { background: #fef2f2; }
.ins-ltv__cell-label { font-size: 11px; font-weight: 600; }
.ins-ltv__cell--hi .ins-ltv__cell-label { color: #047857; }
.ins-ltv__cell--lo .ins-ltv__cell-label { color: #b91c1c; }
.ins-ltv__cell-value { font-size: 18px; font-weight: 700; color: #0f172a; }
.ins-ltv__cell-hint  { font-size: 11px; color: #6b7280; }

/* Todo (Что делать сегодня) */
.todo-card {
  border-left: 4px solid #94a3b8;
  border-radius: 0 8px 8px 0;
  padding: 12px 14px;
  background: #f8fafc;
  display: flex; flex-direction: column; gap: 4px;
}
.todo-card--urgent    { border-color: #ef4444; background: #fef2f2; }
.todo-card--important { border-color: #f59e0b; background: #fffbeb; }
.todo-card--normal    { border-color: #3b82f6; background: #eff6ff; }
.todo-card__head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.todo-card__title { font-size: 14px; font-weight: 600; color: #0f172a; margin: 0; }
.todo-card__chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 9999px;
  background: #e2e8f0;
  color: #475569;
}
.todo-card--urgent    .todo-card__chip { background: #fecaca; color: #b91c1c; }
.todo-card--important .todo-card__chip { background: #fde68a; color: #92400e; }
.todo-card--normal    .todo-card__chip { background: #dbeafe; color: #1d4ed8; }
.todo-card__big   { font-size: 22px; font-weight: 700; color: #0f172a; }
.todo-card__hint  { font-size: 12px; color: #4b5563; }

/* Bar lists */
.bar-list { display: flex; flex-direction: column; gap: 8px; }
.bar-row__head { display: flex; justify-content: space-between; font-size: 13px; color: #0f172a; margin-bottom: 4px; }
.bar-row__track { height: 8px; background: #f1f5f9; border-radius: 9999px; overflow: hidden; }
.bar-row__fill { height: 100%; border-radius: 9999px; background: #3b82f6; }
.bar-row__fill--amber { background: #f59e0b; }
.bar-row__fill--emerald { background: #10b981; }

/* ============ Утилиты для legacy x-cloak (Alpine) ============ */
[x-cloak] { display: none !important; }

/* ============ Mobile (≤767px) — адаптив контента (стандарт §templates/CLAUDE.md) ============ */
@media (max-width: 767px) {
  /* iOS auto-zoom: любой input/textarea/select с font-size <16px дёргает зум при
     фокусе. !important обязателен — бьёт Tailwind-утилиту text-sm и класс
     .chat-input textarea (иначе их специфичность не перекрыть). НЕ user-scalable=no. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  textarea, select { font-size: 16px !important; }
}
/* AI Ассистент: на телефоне 6 quick-prompt чипов едят экран до чата →
   один свайпаемый ряд вместо стопки (кнопки уже flex:0 0 auto + white-space:nowrap). */
@media (max-width: 640px) {
  .assistant-quick { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .assistant-quick::-webkit-scrollbar { display: none; }
  .assistant-quick__btn { min-height: 44px; }
  /* Пузырь на телефоне: десктопный кап min(600px,88vw) НЕ учитывает аватар(32)+gap(12)
     +padding чата(32) → ряд не влезал в экран. Кап = 100vw − ~112px (всё это chrome). */
  .chat-bubble,
  .chat-bubble--ai,
  .chat-bubble--user,
  .chat-bubble--ai:has(.seg-card) { max-width: calc(100vw - 112px); }
}

/* AI-чат: markdown-таблицы из ответов агента (выручка по дням/часам, сегменты) →
   компактная мини-таблица вместо «текста колонками». marked.js рендерит GFM | таблицы | в <table>. */
.chat-bubble table {
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 13px;
  /* display:block + width:max-content + overflow-x:auto = таблица сама себе
     горизонтальный скролл-контейнер, капнутый шириной пузыря. Иначе nowrap-ячейки
     (см. ниже) распирали таблицу шире пузыря и тянули весь чат вбок (mobile-свайп). */
  display: block;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.chat-bubble th,
.chat-bubble td {
  border: 1px solid #e2e8f0;
  padding: 4px 10px;
  text-align: left;
  white-space: nowrap;
}
.chat-bubble th {
  background: #f1f5f9;
  font-weight: 600;
}
.chat-bubble td:not(:first-child),
.chat-bubble th:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.chat-bubble table tr:nth-child(even) td { background: #f8fafc; }

/* 

==== Триггеры (/triggers, O4) — классы из мокапа rassylki-v2/_shared.css ============ */
/* Тумблер вкл/выкл триггера */
.tgl { position: relative; width: 40px; height: 22px; border-radius: 999px; background: #cbd5e1; cursor: pointer; transition: background .15s; flex-shrink: 0; border: 0; }
.tgl::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.tgl.is-on { background: #16a34a; }
.tgl.is-on::after { transform: translateX(18px); }

/* Карточка триггера */
.trig-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; transition: box-shadow .15s, border-color .15s; }
.trig-card:hover { box-shadow: 0 4px 14px rgba(15,23,42,.07); border-color: #cbd5e1; }
.trig-card.is-off { background: #f8fafc; }
.trig-card.is-off .trig-card__title, .trig-card.is-off .trig-metrics { opacity: .45; }
.trig-card__title { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.trig-card__rule { font-size: 12px; color: #64748b; }
.trig-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: auto; }
.trig-metrics div { background: #f8fafc; border-radius: 8px; padding: 6px 8px; }
.trig-metrics b { display: block; font-size: 13px; font-variant-numeric: tabular-nums; }
.trig-metrics span { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: .03em; }

/* Бейдж сегмента на карточке */
.seg-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.seg-chip--sleep { background: #ede9fe; color: #6d28d9; }
.seg-chip--risk  { background: #fef3c7; color: #b45309; }
.seg-chip--lost  { background: #fee2e2; color: #b91c1c; }
.seg-chip--vip   { background: #fce7f3; color: #be185d; }
.seg-chip--new   { background: #dcfce7; color: #15803d; }
.seg-chip--deliv { background: #dbeafe; color: #1d4ed8; }
/* hotfix 2026-06-11: серый фоллбэк — «Все гости» + неизвестные старые segment_key */
.seg-chip--none  { background: #f1f5f9; color: #64748b; }

/* Вкладка «Рассылки» (R1, мокап final-mailings.html): карточка = <a> поверх .trig-card,
   статус-пилюли РОВНО ТРЁХ UI-статусов (ключи = services/mailings.ui_status). */
.mail-card { cursor: pointer; color: inherit; text-decoration: none; }
.mail-card:hover { border-color: #93c5fd; }
.st-pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.st-pill--draft { background: #f1f5f9; color: #64748b; }
.st-pill--planned { background: #dbeafe; color: #1d4ed8; }
.st-pill--sent { background: #dcfce7; color: #15803d; }

/* Карточка-форма создания (дашед-рамка) + раскрытая правка карточки: одни поля */
.trig-create { border: 1.5px dashed #94a3b8; background: #fff; }
.trig-create input, .trig-create select, .trig-create textarea,
.trig-edit input, .trig-edit select, .trig-edit textarea {
  width: 100%; border: 1px solid #e2e8f0; border-radius: 8px; padding: 7px 10px; font-size: 12.5px; background: #fff;
}
.trig-create input:focus, .trig-create select:focus, .trig-create textarea:focus,
.trig-edit input:focus, .trig-edit select:focus, .trig-edit textarea:focus {
  outline: none; border-color: #93c5fd; box-shadow: 0 0 0 2px #dbeafe;
}
.trig-create label, .trig-edit label {
  display: block; font-size: 10.5px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px;
}
/* ── Календарь /calendar (UI v2 O6) — классы мокапа rassylki-v2/_shared.css ──
   Чипы: серый done = факт отправки, синий camp = запланированная разовая,
   фиолетовый trig = триггер (план/~прогноз). Ячейки: mute = чужой месяц,
   today = обводка сегодняшнего дня. seg-chip — ярлык сегмента (легенда шапки). */
/* фидбэк Владимира 2026-06-11: чипы крупнее (шрифт 10.5→12px) + 2 строки вместо
   однострочной обрезки названия (line-clamp вместо nowrap+ellipsis) */
.cal-chip { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: 12px; line-height: 1.25; font-weight: 600; padding: 3px 7px; border-radius: 6px; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-chip--camp { background: #dbeafe; color: #1d4ed8; }
.cal-chip--trig { background: #ede9fe; color: #6d28d9; }
.cal-chip--done { background: #f1f5f9; color: #64748b; }
.cal-cell { min-height: 118px; border: 1px solid #f1f5f9; padding: 5px 7px; font-size: 13px; background: #fff; } /* фидбэк Владимира: ячейки дней покрупнее (86→118px, шрифт 12→13px) */
.cal-cell--mute { background: #f8fafc; color: #cbd5e1; }
.cal-cell--today { outline: 2px solid #2563eb; outline-offset: -2px; border-radius: 4px; }

/* ── Гости /guests (UI v2 O8) — классы мокапа rassylki-v2/final-guests.html ──
   chip-row = ряд чипов слоя (Жизненный цикл / Поведение); fchip = чип-фильтр
   (is-on = активен); flt-pop = строка ручного конструктора условий;
   gkpis = KPI-строка выбранной базы. */
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip-row .lbl, .flt-pop .lbl { font-size: 11px; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-right: 4px; }
.fchip { font-size: 12px; font-weight: 600; padding: 4px 11px; border-radius: 999px; border: 1px solid #e2e8f0; background: #fff; color: #475569; cursor: pointer; display: inline-flex; align-items: center; gap: 3px; }
.fchip:hover { border-color: #cbd5e1; }
.fchip.is-on { background: #2563eb; border-color: #2563eb; color: #fff; }
.fchip small { font-weight: 400; opacity: .75; }
.flt-pop { border: 1px solid #e2e8f0; border-radius: 12px; background: #fff; padding: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.flt-pop select, .flt-pop input { border: 1px solid #e2e8f0; border-radius: 8px; padding: 7px 10px; font-size: 12.5px; background: #fff; }
.gkpis { display: flex; gap: 26px; flex-wrap: wrap; padding: 13px 0; }
.gkpis b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.gkpis span { font-size: 10.5px; color: #94a3b8; text-transform: uppercase; letter-spacing: .03em; }

/* ── Настройки /settings (UI v2 O9) — классы мокапов final-settings*.html ──
   Карточка-сет, плитки выбора провайдера, поля, кнопки, бейджи статусов,
   прогресс-полоса бутстрапа. Вариант 2: одна кнопка «Сохранить». */
.set-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 20px; max-width: 620px; }
.set-card + .set-card { margin-top: 16px; }
.set-card.is-dev { opacity: .55; }
.prov-pick { display: flex; gap: 10px; }
.prov { flex: 1; border: 1.5px solid #e2e8f0; border-radius: 10px; padding: 12px 14px; cursor: pointer; font-weight: 600; font-size: 14px; background: #fff; text-align: left; }
.prov.is-sel { border-color: #2563eb; background: #eff6ff; }
.prov small { font-size: 11px; color: #94a3b8; font-weight: 400; display: block; }
.fld { margin-top: 12px; }
.fld label { display: block; font-size: 10.5px; font-weight: 600; color: #94a3b8; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.fld input { width: 100%; border: 1px solid #e2e8f0; border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.fld input:focus { outline: none; border-color: #93c5fd; box-shadow: 0 0 0 2px #dbeafe; }
.fld .hint { font-size: 11.5px; color: #94a3b8; margin-top: 3px; }
.btn { border-radius: 8px; padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.btn--blue { background: #2563eb; color: #fff; }
.btn--blue:hover { background: #1d4ed8; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.ok-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: #15803d; background: #dcfce7; border-radius: 999px; padding: 3px 10px; }
.err-badge { display: inline-flex; font-size: 12px; font-weight: 600; color: #b91c1c; background: #fee2e2; border-radius: 999px; padding: 3px 10px; }
.dev-badge { display: inline-flex; font-size: 11px; font-weight: 600; color: #92400e; background: #fef3c7; border-radius: 999px; padding: 2px 9px; }
.conn-row { display: flex; align-items: center; gap: 12px; }
.conn-ico { width: 40px; height: 40px; border-radius: 10px; background: #f1f5f9; display: grid; place-items: center; font-size: 19px; flex-shrink: 0; }
.lim-input { width: 64px; border: 1px solid #e2e8f0; border-radius: 8px; padding: 8px 10px; font-size: 14px; font-weight: 700; text-align: center; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid #cbd5e1; border-top-color: #2563eb; border-radius: 50%; animation: o9-sp .7s linear infinite; vertical-align: -2px; }
@keyframes o9-sp { to { transform: rotate(360deg); } }
.sync-bar { height: 8px; border-radius: 999px; background: #e2e8f0; overflow: hidden; margin-top: 8px; }
.sync-bar div { height: 100%; width: 0%; background: #16a34a; border-radius: 999px; transition: width .3s; }
.sync-bar .sync-bar__fill { animation: o9-pulse 1.6s ease-in-out infinite; }
@keyframes o9-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
