/* ===== Цвета: светлая и тёмная тема ===== */
:root {
  /* Фирменный стиль «Дмитрий Мелешко»: синий градиент сайта, жёлтые кнопки, Montserrat */
  --brand-1: #3c7bb5; --brand-2: #2f6ba6; --brand-3: #1f5794;
  --yellow: #fbb93e; --yellow-hover: #f4a91f; --on-yellow: #17294a;
  --bg: #f2f6fa; --surface: #ffffff; --surface-2: #f6f9fc; --surface-3: #e9eff6;
  --text: #17294a; --muted: #5d6b82; --faint: #8f9bb0; --line: #e1e8f0; --line-strong: #cbd6e3;
  --accent: #2867a8; --accent-hover: #1f5794; --accent-soft: #e5eff9; --accent-text: #1f5794;
  --ok: #18794e; --ok-soft: #e3f5ec; --warn: #a35200; --warn-soft: #fff1de; --danger: #c62a2f; --danger-soft: #fdecec;
  --tg-bg: #dfe8ef; --tg-bubble: #ffffff; --tg-btn: #f1f5f8; --tg-link: #2481cc;
  --grid: #e3e6ec;
  --shadow: 0 1px 2px rgba(23,41,74,.05), 0 2px 6px rgba(23,41,74,.05);
  --shadow-lg: 0 14px 36px rgba(23,41,74,.16);
  --radius: 16px;
  --sidebar-bg: linear-gradient(165deg, var(--brand-1) 0%, var(--brand-2) 55%, var(--brand-3) 100%);
  --node-message: #2867a8; --node-delay: #d97706; --node-condition: #0e9f6e; --node-action: #db2777; --node-start: #475467;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1520; --surface: #142030; --surface-2: #182638; --surface-3: #1f2f44;
    --text: #e6edf6; --muted: #9eadc2; --faint: #6c7d95; --line: #233349; --line-strong: #31455f;
    --accent: #5f9fe0; --accent-hover: #7db2ea; --accent-soft: #17324f; --accent-text: #9cc6f2;
    --sidebar-bg: linear-gradient(165deg, #1d4a7a 0%, #163a62 55%, #0f2a48 100%);
    --ok: #4cc38a; --ok-soft: #15301f; --warn: #f0a44b; --warn-soft: #33240f; --danger: #ff6369; --danger-soft: #3a1618;
    --tg-bg: #0e1621; --tg-bubble: #182533; --tg-btn: #22303f; --tg-link: #6ab3f3;
    --grid: #20242d;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1520; --surface: #142030; --surface-2: #182638; --surface-3: #1f2f44;
  --text: #e6edf6; --muted: #9eadc2; --faint: #6c7d95; --line: #233349; --line-strong: #31455f;
  --accent: #5f9fe0; --accent-hover: #7db2ea; --accent-soft: #17324f; --accent-text: #9cc6f2;
  --sidebar-bg: linear-gradient(165deg, #1d4a7a 0%, #163a62 55%, #0f2a48 100%);
  --ok: #4cc38a; --ok-soft: #15301f; --warn: #f0a44b; --warn-soft: #33240f; --danger: #ff6369; --danger-soft: #3a1618;
  --tg-bg: #0e1621; --tg-bubble: #182533; --tg-btn: #22303f; --tg-link: #6ab3f3;
  --grid: #20242d;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* ===== База ===== */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font-family: Montserrat, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-text); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 700; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 700; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; }
.nowrap { white-space: nowrap; }
code { background: var(--surface-3); border-radius: 6px; padding: 1px 6px; font-size: 12.5px; }
pre { background: var(--surface-3); border-radius: 8px; padding: 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; font-size: 12.5px; margin: 0; }

/* ===== Каркас: боковое меню + контент ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--sidebar-bg); color: #fff;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 12px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 22px; }
.brand-logo { width: 38px; height: 38px; border-radius: 50%; background: var(--yellow); color: var(--on-yellow); display: grid; place-items: center;
  font-weight: 800; font-size: 14px; letter-spacing: -.02em; flex-shrink: 0; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.brand-name { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name b { font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
.brand-name small { font-size: 11px; opacity: .75; font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 999px; color: rgba(255,255,255,.82); font-weight: 500; }
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.nav a.active { background: #fff; color: var(--brand-3); font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,.12); }
.sidebar .nav-badge { background: var(--yellow); color: var(--on-yellow); }
.sidebar .bot-chip { color: rgba(255,255,255,.75); }
.sidebar #userbox { border-top-color: rgba(255,255,255,.18) !important; }
.sidebar #userbox .muted { color: rgba(255,255,255,.7); }
.sidebar .btn.ghost { color: rgba(255,255,255,.75); } .sidebar .btn.ghost:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px; }
.bot-chip { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); overflow: hidden; }
.bot-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.bot-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content { flex: 1; min-width: 0; padding: 28px 32px 48px; }
.page { max-width: 1120px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }

/* ===== Карточки, сетки ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid.kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.grid.two { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.kpi-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-card .label { color: var(--muted); font-size: 13px; }
.kpi-card .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-card .delta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1; min-width: 160px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .icon { font-size: 34px; margin-bottom: 8px; }

/* ===== Формы ===== */
label.field { display: block; font-weight: 550; font-size: 13px; margin: 14px 0 6px; }
label.field:first-child { margin-top: 0; }
label.field .hint { font-weight: 400; color: var(--muted); }
.hint { color: var(--muted); font-size: 12px; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=number], input[type=time], input[type=datetime-local], input[type=search], input:not([type]), textarea, select {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 10px; font: inherit; color: var(--text);
  background: var(--surface); transition: border-color .12s, box-shadow .12s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }

/* ===== Кнопки ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 999px;
  padding: 9px 18px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s;
  background: var(--yellow); color: var(--on-yellow); }
.btn:hover { background: var(--yellow-hover); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--accent-text); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.icon { padding: 7px; }
.btn svg { width: 16px; height: 16px; }

/* ===== Таблицы, теги, бейджи ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent-text); border-radius: 999px;
  padding: 2px 9px; margin: 2px 2px 2px 0; font-size: 12px; font-weight: 500; white-space: nowrap; }
.tag button { border: 0; background: none; color: inherit; cursor: pointer; padding: 0; font-size: 14px; line-height: 1; opacity: .6; }
.tag button:hover { opacity: 1; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; flex-shrink: 0; font-size: 13px; }

/* ===== Каналы ===== */
.ch-logo { display: inline-grid; place-items: center; border-radius: 28%; color: #fff; font-weight: 700; flex-shrink: 0; letter-spacing: -.02em; }
.pick { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 12px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer; font: inherit; color: var(--text); text-align: center; transition: border-color .12s, background .12s; }
.pick:hover { border-color: var(--accent); background: var(--accent-soft); }
.pick-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 560px) { .pick-grid { grid-template-columns: 1fr; } }
.callout .tag { background: var(--surface); }
ol.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.5; }

/* ===== Мастер рассылки ===== */
.wizard { padding-bottom: 90px; }
.stepper { display: flex; align-items: center; gap: 4px; margin-bottom: 18px; overflow-x: auto; padding-bottom: 2px; }
.sitem { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; font: inherit; font-weight: 550; color: var(--muted);
  padding: 8px 10px; border-radius: 10px; cursor: pointer; white-space: nowrap; }
.sitem:disabled { cursor: default; }
.sitem.cur { color: var(--text); background: var(--surface); box-shadow: var(--shadow); }
.sitem:not(:disabled):not(.cur):hover { background: var(--surface-3); }
.snum { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--line-strong); color: #fff; font-size: 13px; }
.sitem.cur .snum, .sitem.done .snum { background: var(--accent); }
.sline { flex: 0 1 60px; min-width: 16px; height: 2px; background: var(--line); }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); cursor: pointer; font: inherit; color: var(--text); text-align: left; transition: border-color .12s, background .12s; }
.choice:hover { border-color: var(--line-strong); background: var(--surface-2); }
.choice.on { border-color: var(--accent); background: var(--accent-soft); }
.choice .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.choice .logos { display: grid; grid-template-columns: 18px 18px; gap: 2px; width: 38px; justify-items: center; }
.choice .radio { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-strong); flex-shrink: 0; }
.choice.on .radio { border: 5px solid var(--accent); }
.wizard-foot { position: fixed; left: 232px; right: 0; bottom: 0; z-index: 8; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 32px; background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(16,24,40,.06); flex-wrap: wrap; }
.btn.go { background: var(--ok); } .btn.go:hover { filter: brightness(.95); background: var(--ok); }
.summary-t td { padding: 7px 0; border-bottom: 1px solid var(--line); } .summary-t td:first-child { width: 110px; padding-right: 10px; }
@media (max-width: 900px) {
  .wizard-foot { left: 0; padding: 10px 16px; }
  #w3 { grid-template-columns: 1fr !important; }
  .sline { display: none; }
  .sitem { padding: 6px 8px; }
}

/* ===== Общее для новых разделов ===== */
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mobile-only { display: none !important; }
.nav a .grow { flex: 1; }
.nav-badge { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; line-height: 16px; }
.popover { position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 14px; width: 320px; max-width: calc(100vw - 16px); }
.popover .pop-title { font-weight: 600; margin-bottom: 8px; }
.popover.menu { padding: 8px; width: 280px; }
.popover.menu .items { display: flex; flex-direction: column; max-height: 360px; overflow-y: auto; }
.popover.menu button { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.popover.menu button:hover { background: var(--surface-2); }
.popover .fi { width: 22px; text-align: center; color: var(--muted); }

/* ===== Подписчики ===== */
.subs-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 20px; align-items: start; }
.page:has(.subs-layout) { max-width: 1400px; }
.subs-nav { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 2px; }
.subs-nav button { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 9px 10px; border-radius: 8px; cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.subs-nav button span:last-child { margin-left: auto; color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.subs-nav button:hover { background: var(--surface-3); }
.subs-nav button.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.subs-nav button.sub { padding-left: 36px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent-text); border-radius: 8px; padding: 5px 6px 5px 10px; font-size: 13px; cursor: pointer; font-weight: 500; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 4px; opacity: .6; }
.chip button:hover { opacity: 1; }
.bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px; background: var(--accent-soft); border-radius: 10px; margin-bottom: 12px; }
.subs-table th.sortable { cursor: pointer; user-select: none; } .subs-table th.sortable:hover { color: var(--text); }
.subs-table td { padding-top: 9px; padding-bottom: 9px; }
.subs-table .ellipsis { max-width: 170px; display: inline-block; }
@media (max-width: 1350px) { .hide-md { display: none; } }

/* ===== Сообщения ===== */
body.page-messages .content { padding: 0; }
body.page-messages .page { max-width: none; }
.inbox { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100vh; background: var(--surface); position: relative; }
.ib-side { display: none; }
/* На средних экранах панель «О подписчике» выезжает поверх чата, на широких — отдельная колонка. */
.inbox.side-open .ib-side { display: block; position: absolute; right: 0; top: 0; bottom: 0; width: 320px; background: var(--surface);
  box-shadow: var(--shadow-lg); z-index: 5; }
@media (min-width: 1400px) {
  .side-close { display: none; }
  .inbox { grid-template-columns: 340px minmax(0, 1fr) 300px; }
  .ib-side, .inbox.side-open .ib-side { display: block; position: static; width: auto; box-shadow: none; }
}
.ib-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.ib-head { padding: 14px; border-bottom: 1px solid var(--line); }
.ib-tabs { display: flex; width: 100%; } .ib-tabs button { flex: 1; white-space: nowrap; } .ib-tabs span { color: var(--faint); font-size: 12px; margin-left: 4px; }
.ib-items { flex: 1; overflow-y: auto; }
.ib-item { display: flex; gap: 10px; width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 12px 14px; cursor: pointer; font: inherit; color: var(--text); text-align: left; }
.ib-item:hover { background: var(--surface-2); }
.ib-item.on { background: var(--accent-soft); }
.ib-item.unread b { font-weight: 700; }
.ib-item .ib-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ib-prev { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ib-item.unread .ib-prev { color: var(--text); }
.ava-wrap { position: relative; flex-shrink: 0; height: 34px; }
.ava-wrap .avatar { width: 40px; height: 40px; }
.ava-wrap .ch-dot { position: absolute; right: -4px; bottom: -8px; border: 2px solid var(--surface); border-radius: 6px; line-height: 0; }
.ib-chat { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.ib-chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-host { flex: 1; display: flex; flex-direction: column; min-height: 0; padding: 0 16px 14px; }
.chat-host .chat { flex: 1; height: auto; min-height: 200px; background: transparent; padding: 16px 0; border-radius: 0; }
.chat-card .chat-host { padding: 0; height: 560px; } .chat-card .chat-host .chat { background: var(--surface-2); padding: 12px; border-radius: 10px; }
.bubble .who { font-size: 11px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.bubble.out.manual { background: #e3f5ec; } :root[data-theme="dark"] .bubble.out.manual { background: #15301f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bubble.out.manual { background: #15301f; } }
.bubble img { max-width: 260px; max-height: 260px; border-radius: 8px; display: block; margin-bottom: 4px; }
.bubble .file { display: block; margin-bottom: 4px; }
.sys-line { align-self: center; font-size: 11.5px; color: var(--faint); background: var(--surface-3); padding: 3px 10px; border-radius: 999px; max-width: 90%; text-align: center; }
.composer { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; padding: 8px; }
.composer textarea { border: 0; box-shadow: none; resize: none; min-height: 38px; max-height: 160px; padding: 8px; background: transparent; }
.composer textarea:focus { box-shadow: none; }
.composer .att { font-size: 13px; padding: 4px 8px 8px; }
.ib-side { border-left: 1px solid var(--line); overflow-y: auto; }
.ib-side-in { padding: 16px; }
.notes { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.note { background: var(--warn-soft); border-radius: 10px; padding: 8px 10px; font-size: 13px; white-space: pre-wrap; word-wrap: break-word; }
.note-head { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 3px; }
.note-head .btn { margin-left: auto; padding: 0 6px; }
@media (max-width: 900px) {
  .mobile-only { display: inline-flex !important; }
  .subs-layout { grid-template-columns: 1fr; }
  .subs-nav { display: none; }
  .hide-sm { display: none; }
  .inbox { grid-template-columns: 1fr; height: calc(100vh - 53px); }
  .inbox.side-open .ib-side { position: static; width: auto; box-shadow: none; }
  .inbox .ib-chat, .inbox .ib-side { display: none; }
  .inbox.show-chat .ib-list { display: none; }
  .inbox.show-chat .ib-chat { display: flex; }
  .inbox.show-chat.side-open .ib-chat { display: none; }
  .inbox.show-chat.side-open .ib-side { display: block; }
}

/* ===== Аналитика и графики ===== */
/* Цвета рядов проверены на различимость при дальтонизме (светлая и тёмная тема — свои оттенки). */
:root { --s-blue: #2a78d6; --s-red: #e34948; --s-violet: #4a3aa7; --s-aqua: #1baf7a; --s-orange: #eb6834; --heat: 42,120,214; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --s-blue: #3987e5; --s-red: #e66767; --s-violet: #9085e9; --s-aqua: #199e70; --s-orange: #d95926; --heat: 57,135,229; } }
:root[data-theme="dark"] { --s-blue: #3987e5; --s-red: #e66767; --s-violet: #9085e9; --s-aqua: #199e70; --s-orange: #d95926; --heat: 57,135,229; }
.an-layout { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 20px; align-items: start; }
.page:has(.an-layout) { max-width: 1400px; }
.an-filter { gap: 8px; align-items: center; } .an-filter .lbl { min-width: 70px; }
.viz { position: relative; }
.viz-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.viz-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--c); margin-right: 6px; vertical-align: middle; }
.viz-legend i.dash { background: repeating-linear-gradient(90deg, var(--c) 0 4px, transparent 4px 7px); }
.viz svg { display: block; overflow: visible; }
.viz .grid { stroke: var(--line); stroke-width: 1; }
.viz .ax { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.viz .cross { stroke: var(--line-strong); stroke-width: 1; }
.viz .hit.on { fill: var(--text); opacity: .04; }
.viz-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 8px 10px; font-size: 12.5px; min-width: 150px; }
.viz-tip .tip-h { color: var(--muted); margin-bottom: 4px; }
.viz-tip .tip-r { display: flex; align-items: center; gap: 6px; } .viz-tip .tip-r i { width: 10px; height: 10px; border-radius: 3px; background: var(--c); }
.viz-tip .tip-r b { font-variant-numeric: tabular-nums; } .viz-tip .tip-r span { color: var(--muted); }
.viz-table { margin-top: 8px; font-size: 12.5px; } .viz-table summary { color: var(--muted); cursor: pointer; } .viz-table table { margin-top: 6px; }
.viz-table td, .viz-table th { padding: 5px 8px; }
.kpi-card .value.c-new { color: var(--s-blue); } .kpi-card .value.c-gone { color: var(--s-red); }
.kpi-card .value.c-goal { color: var(--s-violet); } .kpi-card .value.c-time { color: var(--s-orange); }
.up { color: var(--ok); font-weight: 600; } .down { color: var(--danger); font-weight: 600; }
.heat { display: grid; grid-template-columns: 26px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 10.5px; color: var(--faint); max-width: 900px; }
.heat .hh { text-align: left; } .heat .hd { align-self: center; }
.heat .hc { height: 22px; border-radius: 4px; background: rgba(var(--heat), var(--a)); box-shadow: inset 0 0 0 1px var(--line); }
.heat-scale { display: flex; align-items: center; gap: 3px; font-size: 11px; color: var(--faint); margin-top: 8px; justify-content: flex-end; }
.heat-scale i { width: 14px; height: 10px; border-radius: 2px; background: rgba(var(--heat), var(--a)); }
.mini-bar { display: inline-block; width: 50px; height: 5px; background: var(--surface-3); border-radius: 3px; overflow: hidden; vertical-align: middle; margin: 0 4px; }
.mini-bar i { display: block; height: 100%; border-radius: 3px; }
.wait-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.wait-row:hover { text-decoration: none; background: var(--surface-2); }
@media (max-width: 900px) { .an-layout { grid-template-columns: 1fr; } .an-nav { display: none; } }

/* ===== Воронки: список ===== */
.c-blue { color: var(--s-blue); } .c-green { color: var(--ok); } .c-orange { color: var(--s-orange); }
.fn-layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); gap: 20px; align-items: start; }
.page:has(.fn-layout) { max-width: 1400px; }
.fn-side { position: sticky; top: 20px; }
.fn-side .fold { font-size: 14px; }
.fn-ic { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.fn-ic svg { width: 18px; height: 18px; }
.fn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.fn-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
  cursor: pointer; display: flex; flex-direction: column; gap: 10px; transition: box-shadow .15s, border-color .15s; }
.fn-card:hover { box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.fn-top { display: flex; gap: 12px; align-items: flex-start; }
.fn-name { font-weight: 700; font-size: 16px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fn-meta { margin-left: 48px; margin-top: -6px; }
.fn-stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; padding: 8px 0; }
.fn-stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; } .fn-stats span { font-size: 12px; color: var(--muted); }
.fn-foot { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding-top: 12px; }
.fn-foot > :nth-child(2) { margin-left: auto; }
.st-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.st-badge.on { background: var(--ok); color: #fff; } .st-badge.off { background: var(--surface-3); color: var(--muted); }

/* ===== Воронка: режим «Шаги» ===== */
.steps-view { flex: 1; overflow-y: auto; padding: 20px 24px 40px; min-width: 0; }
.st-tiles { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.st-tiles > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 18px; text-align: center; min-width: 110px; }
.st-tiles b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; } .st-tiles span { font-size: 12px; color: var(--muted); }
.st-info { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.st-list { margin-bottom: 14px; }
.st-list tr.sel td { background: var(--accent-soft); }
.st-list .handle { color: var(--faint); cursor: grab; font-size: 16px; text-align: center; user-select: none; }
.st-list tr.dragging { opacity: .4; }
.st-list tr.drop-before td { box-shadow: inset 0 2px 0 var(--accent); } .st-list tr.drop-after td { box-shadow: inset 0 -2px 0 var(--accent); }
.st-list .timing { color: var(--accent-text); font-weight: 600; margin-top: 2px; }
.st-list .timing.off { color: var(--faint); }
.wd-checks { display: grid; grid-template-columns: repeat(5, auto); gap: 10px 14px; justify-content: start; }
.wd-checks input { width: 18px; height: 18px; }
.card-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-top: 12px; background: var(--surface-2); }
.cb-head { display: flex; align-items: center; gap: 4px; }
.card-box .btn-row { grid-template-columns: 120px minmax(0, 1fr) auto; grid-template-areas: "t t r" "y v v"; padding: 8px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.card-box .btn-row .bt { grid-area: t; } .card-box .btn-row .ty { grid-area: y; } .card-box .btn-row .bv { grid-area: v; } .card-box .btn-row .rm { grid-area: r; }
.add-cards { display: flex; flex-wrap: wrap; gap: 6px; }
.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; margin-top: 8px; }
.gal-item, .gal-add { position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--surface-3); display: grid; place-items: center; }
.gal-item img, .pv-gal img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gal-item button { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 50%; width: 20px; height: 20px; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; line-height: 1; }
.gal-add { cursor: pointer; font-size: 22px; color: var(--accent); border: 1.5px dashed var(--line-strong); }
.pv-gal { margin: 0; padding: 2px; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); }
@media (max-width: 900px) { .fn-layout { grid-template-columns: 1fr; } .fn-side { display: none; } .steps-view { padding: 14px; } }

/* ===== Переключатель ===== */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line-strong); border-radius: 20px; cursor: pointer; transition: .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(16px); }

/* ===== Список воронок ===== */
.funnel-card { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.funnel-card:last-child { border-bottom: 0; }
.funnel-card .info { flex: 1; min-width: 0; }
.funnel-card .title { font-weight: 600; font-size: 15px; cursor: pointer; }
.funnel-card .title:hover { color: var(--accent-text); }
.funnel-card .meta { color: var(--muted); font-size: 13px; margin-top: 4px; display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; }
.metric { text-align: right; min-width: 64px; }
.metric b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; }
.metric span { font-size: 12px; color: var(--muted); }

/* ===== Редактор сообщения + превью Telegram ===== */
.msg-editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }
.msg-editor.compact { grid-template-columns: 1fr; }
.toolbar { display: flex; gap: 2px; padding: 4px; border: 1px solid var(--line-strong); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--surface-2); flex-wrap: wrap; }
.toolbar button { border: 0; background: none; padding: 4px 9px; border-radius: 6px; cursor: pointer; color: var(--text); font: inherit; font-size: 13px; min-width: 28px; }
.toolbar button:hover { background: var(--surface-3); }
.toolbar + textarea { border-radius: 0 0 8px 8px; }
.media-box { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--surface-2); flex-wrap: wrap; }
.media-box.drag { border-color: var(--accent); background: var(--accent-soft); }
.media-box img { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; }
.media-box .file-icon { width: 54px; height: 54px; border-radius: 6px; background: var(--surface-3); display: grid; place-items: center; font-size: 22px; }
.media-box .name { flex: 1; min-width: 120px; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-rows { display: flex; flex-direction: column; gap: 8px; }
.btn-row { display: grid; grid-template-columns: minmax(0, 1.1fr) 120px minmax(0, 1.4fr) auto; gap: 6px; align-items: center; }
/* В узкой панели конструктора — кнопка в две строки: текст сверху, тип и значение снизу. */
.msg-editor.compact .btn-row { grid-template-columns: 130px minmax(0, 1fr) auto; grid-template-areas: "t t r" "y v v";
  padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.msg-editor.compact .btn-row .bt { grid-area: t; } .msg-editor.compact .btn-row .ty { grid-area: y; }
.msg-editor.compact .btn-row .bv { grid-area: v; } .msg-editor.compact .btn-row .rm { grid-area: r; }
.tg-preview { background: var(--tg-bg); border-radius: 12px; padding: 14px; min-height: 140px; align-self: start; position: sticky; top: 16px; }
.tg-preview .cap { font-size: 11px; color: var(--muted); text-align: center; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .04em; }
.tg-bubble { background: var(--tg-bubble); border-radius: 12px 12px 12px 4px; overflow: hidden; box-shadow: 0 1px 1px rgba(0,0,0,.08); max-width: 100%; }
.tg-bubble img { display: block; width: 100%; max-height: 220px; object-fit: cover; }
.tg-bubble .tg-file { display: flex; align-items: center; gap: 10px; padding: 10px 12px 0; font-size: 13px; }
.tg-bubble .tg-file i { width: 38px; height: 38px; border-radius: 50%; background: var(--tg-link); color: #fff; display: grid; place-items: center; font-style: normal; }
.tg-bubble .tg-text { padding: 8px 12px 10px; white-space: pre-wrap; word-wrap: break-word; font-size: 14px; }
.tg-bubble .tg-text a { color: var(--tg-link); }
.tg-buttons { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.tg-buttons div { background: var(--tg-btn); color: var(--tg-link); text-align: center; padding: 8px; border-radius: 8px; font-size: 13.5px; font-weight: 500; }
.tg-buttons div.url::after { content: " ↗"; font-size: 11px; }

/* ===== Карточка подписчика / чат ===== */
.chat { height: 440px; overflow-y: auto; background: var(--surface-2); border-radius: 10px; padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 78%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; font-size: 13.5px; }
.bubble.in { background: var(--surface); border: 1px solid var(--line); align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.out { background: var(--accent-soft); align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble small { display: block; color: var(--faint); font-size: 11px; margin-top: 3px; }

/* ===== График ===== */
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar-new { fill: var(--accent); } .chart .bar-gone { fill: var(--danger); opacity: .7; }
.chart .axis { stroke: var(--line); } .chart text { fill: var(--faint); font-size: 12px; }
.chart rect:hover { opacity: .75; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-list .item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 4px 10px; font-size: 13px; }
.bar-list .track { grid-column: 1 / -1; height: 6px; background: var(--surface-3); border-radius: 4px; overflow: hidden; }
.bar-list .fill { height: 100%; background: var(--accent); border-radius: 4px; }

/* ===== Модальное окно, уведомления ===== */
.modal-back { position: fixed; inset: 0; background: rgba(10,12,18,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 860px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: #1d2029; color: #fff; padding: 10px 18px;
  border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; box-shadow: var(--shadow-lg); max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); }

/* ===== Конструктор воронок ===== */
.builder { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--bg); z-index: 20; }
.builder-top { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: nowrap; min-width: 0; }
.builder-top .name { font-size: 15px; font-weight: 600; border-color: transparent; background: transparent; flex: 0 1 320px; min-width: 110px; }
.builder-top .trig { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex-shrink: 1; }
.builder-top .dirty, .builder-top .stepcount { white-space: nowrap; }
.builder-top .modes { flex-shrink: 0; }
.builder-top .modes button { padding: 6px 12px; }
.builder-top .name:hover { border-color: var(--line-strong); }
.builder-main { flex: 1; display: flex; min-height: 0; position: relative; }
.palette { position: absolute; left: 14px; top: 14px; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.palette button { display: flex; align-items: center; gap: 8px; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font: inherit; color: var(--text); text-align: left; white-space: nowrap; }
.palette button:hover { background: var(--surface-2); }
.palette .sw { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: 12px; }
.zoom-ctl { position: absolute; left: 14px; bottom: 14px; z-index: 5; display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 4px; box-shadow: var(--shadow); }
.zoom-ctl button { border: 0; background: none; width: 30px; height: 30px; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 16px; }
.zoom-ctl button:hover { background: var(--surface-2); }
.zoom-ctl span { align-self: center; font-size: 12px; color: var(--muted); min-width: 40px; text-align: center; }
.canvas { flex: 1; position: relative; overflow: hidden; cursor: grab; touch-action: none;
  background-color: var(--bg); background-image: radial-gradient(var(--grid) 1.2px, transparent 1.2px); background-size: 22px 22px; }
.canvas.panning { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.world svg.wires { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.wire { fill: none; stroke: var(--line-strong); stroke-width: 2.2; }
.wire-hit { fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer; }
.wire-group:hover .wire { stroke: var(--danger); }
.wire-del { opacity: 0; pointer-events: none; cursor: pointer; }
.wire-group:hover .wire-del { opacity: 1; pointer-events: all; }
.wire-del circle { fill: var(--danger); } .wire-del text { fill: #fff; font-size: 13px; font-weight: 700; }
.wire.temp { stroke: var(--accent); stroke-dasharray: 6 4; }
.node { position: absolute; width: 264px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  cursor: default; user-select: none; }
.node.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-lg); }
.node.drop-target { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.node-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: move; border-radius: 12px 12px 0 0; }
.node-head .ic { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: 12px; flex-shrink: 0; }
.node-head .t { font-weight: 600; font-size: 13px; flex: 1; }
.node-head .st { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.node-body { padding: 10px 12px; font-size: 12.5px; color: var(--muted); }
.node-body .txt { color: var(--text); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-wrap; word-wrap: break-word; }
.node-body .media { font-size: 12px; margin-bottom: 6px; }
.node-body img { width: 100%; max-height: 90px; object-fit: cover; border-radius: 6px; margin-bottom: 6px; display: block; }
.node-outs { border-top: 1px solid var(--line); }
.node-out { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 22px 7px 12px; font-size: 12px; border-bottom: 1px solid var(--line); }
.node-out:last-child { border-bottom: 0; }
.node-out.btn-out { color: var(--text); }
.node-out .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node-out .cnt { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.port { position: absolute; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--line-strong); cursor: crosshair; z-index: 2; }
.port:hover, .port.on { border-color: var(--accent); background: var(--accent); }
.port.out { right: -8px; top: 50%; margin-top: -7px; }
.port.in { left: -8px; top: 20px; cursor: default; }
.node-out.yes .lbl { color: var(--ok); font-weight: 600; } .node-out.no .lbl { color: var(--danger); font-weight: 600; }
.node-out.timeout .lbl { color: var(--warn); }
.panel { width: 420px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.panel-head h2 { margin: 0; flex: 1; }
.panel-body { padding: 18px; flex: 1; }
.panel-foot { display: flex; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--line); }
.weekdays { display: flex; gap: 4px; flex-wrap: wrap; }
.weekdays label { display: grid; place-items: center; width: 38px; height: 32px; border: 1px solid var(--line-strong); border-radius: 8px; cursor: pointer; font-size: 12.5px; user-select: none; }
.weekdays input { display: none; }
.weekdays label.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; background: var(--surface); padding: 7px 12px; cursor: pointer; font: inherit; color: var(--muted); }
.segmented button + button { border-left: 1px solid var(--line-strong); }
.segmented button.on { background: var(--accent-soft); color: var(--accent-text); font-weight: 550; }
.callout { background: var(--accent-soft); color: var(--accent-text); border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.callout.warn { background: var(--warn-soft); color: var(--warn); }
.dirty-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); display: inline-block; }

/* ===== Телефон и планшет ===== */
.mobile-bar { display: none; }
@media (max-width: 900px) {
  .layout { flex-direction: column; }
  .sidebar { display: none; }
  .mobile-bar { display: flex; position: sticky; top: 0; z-index: 10; background: var(--sidebar-bg); color: #fff;
    align-items: center; gap: 4px; padding: 8px 12px; overflow-x: auto; }
  .mobile-bar .brand { padding: 0 8px 0 0; }
  .mobile-bar .brand .brand-name { display: none; }
  .mobile-bar .brand-logo { width: 32px; height: 32px; font-size: 12px; }
  .mobile-bar a { padding: 7px 12px; border-radius: 999px; color: rgba(255,255,255,.85); white-space: nowrap; font-weight: 500; font-size: 13px; }
  .mobile-bar a.active { background: #fff; color: var(--brand-3); font-weight: 600; }
  .mobile-bar .nav-badge { background: var(--yellow); color: var(--on-yellow); }
  .content { padding: 18px 16px 40px; }
  .grid.two { grid-template-columns: 1fr; }
  .msg-editor { grid-template-columns: 1fr; }
  .tg-preview { position: static; }
  .funnel-card { flex-wrap: wrap; }
  .funnel-card .metric { text-align: left; }
  .panel { position: absolute; left: 0; right: 0; bottom: 0; width: auto; max-height: 62%; border-left: 0; border-top: 1px solid var(--line);
    border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg); z-index: 6; }
  .palette { flex-direction: row; top: auto; bottom: 64px; left: 14px; right: 14px; overflow-x: auto; }
  .palette button span.lbl { display: none; }
  .builder-top .hide-sm { display: none; }
  .builder-top { gap: 6px; padding: 8px 10px; }
  .builder-top .name { min-width: 60px; }
  .builder-top .save { padding: 7px 12px; }
}
@media (max-width: 560px) {
  .grid.kpi { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-card .value { font-size: 22px; }
  .page-head h1 { font-size: 20px; }
  .btn-row { grid-template-columns: 1fr 1fr; }
  .btn-row > :nth-child(3) { grid-column: 1 / 2; }
  th, td { padding: 9px 10px; }
  .hide-xs { display: none; }
  .modal-back { padding: 0; }
  .modal { border-radius: 0; min-height: 100%; }
}

/* ===== Инструменты роста ===== */
.tool-pick { align-items: flex-start; text-align: left; padding: 18px; gap: 6px; }
.tool-ic { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 22px; background: var(--accent-soft); color: var(--accent); }
.tool-cols { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, 1fr); gap: 20px; align-items: start; }
.tool-form { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; }
.tool-form section { padding: 16px 0; border-top: 1px solid var(--line); }
.tool-form section:first-child { border-top: 0; padding-top: 4px; }
.tool-form section h2 { font-size: 15px; margin: 0 0 10px; }
.tool-form pre { background: var(--surface-3); border-radius: 10px; padding: 12px; white-space: pre-wrap; word-break: break-all; font-size: 12.5px; margin: 0; }
.tool-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); margin-top: 6px; }
.tool-prev { position: sticky; top: 16px; min-width: 0; }
.prev-box { position: relative; min-height: 460px; border-radius: 14px; border: 1px solid var(--line); overflow: hidden; padding: 28px 18px;
  background: repeating-linear-gradient(0deg, transparent 0 22px, rgba(127,127,127,.06) 22px 23px), var(--surface-2, #f4f6fa); transition: max-width .2s; margin: 0 auto; }
.prev-box.mob { max-width: 375px; }
.prev-box.dark-bg { background: linear-gradient(160deg, var(--brand-1), var(--brand-3)); }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 16px; }
.opt-grid .segmented { flex-wrap: wrap; }
@media (max-width: 980px) { .tool-cols { grid-template-columns: 1fr; } .tool-prev { position: static; order: -1; } .prev-box { min-height: 340px; } }
.tool-form .ttags { margin-bottom: 4px; }

/* ===== Настройки ===== */
.set-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 18px; align-items: start; margin-bottom: 18px; }
.set-grid .card h2 { font-size: 16px; margin: 0 0 8px; }
.howto { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; margin: 6px 0 4px; font-size: 13px; }
.howto summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.howto ol { margin: 10px 0 2px; padding-left: 20px; line-height: 1.65; }
@media (max-width: 980px) { .set-grid { grid-template-columns: 1fr; } }

.slug-row { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; }
.slug-row .slug-pre { padding: 0 2px 0 12px; color: var(--muted); font-size: 13px; white-space: nowrap; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.slug-row input { border: 0; box-shadow: none; padding-left: 2px; min-width: 0; flex: 1; }
.slug-row:focus-within { border-color: var(--accent); }
.card-box.vk-linked { border-color: #0077ff55; background: color-mix(in srgb, #0077ff 5%, var(--surface)); }

/* ===== Теги ===== */
.tags-wrap { max-height: calc(100vh - 260px); overflow: auto; }
.tags-table thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.tags-table th .ch-name { font-weight: 500; }
.tags-table td.faint { color: var(--faint); }

/* ===== База знаний ===== */
.kb { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 18px; align-items: start; }
.kb-side { position: sticky; top: 16px; padding: 12px; }
.kb-side input { margin-bottom: 8px; }
.kb-side button { display: flex; gap: 10px; align-items: center; width: 100%; text-align: left; border: 0; background: none; font: inherit;
  padding: 9px 10px; border-radius: 10px; cursor: pointer; color: var(--text); }
.kb-side button:hover { background: var(--surface-3); }
.kb-side button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.kb-body { padding: 26px 30px; line-height: 1.65; max-width: 860px; }
.kb-body h1 { font-size: 24px; margin: 0 0 14px; }
.kb-body h3 { margin: 22px 0 8px; font-size: 16px; }
.kb-body ol, .kb-body ul { padding-left: 22px; }
.kb-body li { margin: 4px 0; }
.kb-body table td, .kb-body table th { padding: 8px 10px; }
@media (max-width: 860px) { .kb { grid-template-columns: 1fr; } .kb-side { position: static; } .kb-body { padding: 18px; } }
