/* Кабинет Bot-Platform. Стиль — в духе higgsfield.ai: почти чёрный фон, один кислотно-лаймовый акцент, плотная вёрстка.
   Заголовки — Onest 600 строчными (заглавных нет нигде), текст — Inter 13. Красный — только для проблем.
   Цвета — токенами:
   --accent      — акцент для текста и иконок (в светлой теме темнее, иначе лайм не читается на белом);
   --accent-fill — заливка главной кнопки и плашек (лайм в обеих темах), текст на ней — --accent-text.
   Акцент: сплошной лайм — одно главное действие на экране; лаймовый оттенок с полосой или кольцом — «выбрано»;
   лаймовый текст — ссылки и ключевые проценты; остальное серое. */
:root, html[data-theme="dark"] {
  --bg: #0e0e0e;
  --surface: #171717;
  --surface-2: #1f1f1f;
  --border: #2a2a2a;
  --text: #f2f2f2;
  --muted: #8f8f8f;
  --accent: #d1fe17;
  --accent-fill: #d1fe17;
  --accent-text: #0e0e0e;
  --accent-weak: rgba(209, 254, 23, .10);
  --accent-glow: 0 0 0 1px rgba(209, 254, 23, .35), 0 6px 22px rgba(209, 254, 23, .22);
  --danger: #ff5a5a;
  --danger-weak: rgba(255, 90, 90, .12);
  --input-bg: #111111;
  --tg-bubble: #1f2b37;
  --tg-chat: #0f1720;
  --tg-button: #253442;
  --sidebar: #121212;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f4f1;
  --surface: #ffffff;
  --surface-2: #f0f0ec;
  --border: #e1e1db;
  --text: #141414;
  --muted: #6e6e68;
  --accent: #5a7300;
  --accent-fill: #d1fe17;
  --accent-text: #0e0e0e;
  --accent-weak: rgba(150, 190, 0, .14);
  --accent-glow: 0 0 0 1px rgba(120, 150, 0, .35), 0 6px 18px rgba(150, 190, 0, .25);
  --danger: #d6342c;
  --danger-weak: rgba(214, 52, 44, .08);
  --input-bg: #ffffff;
  --tg-bubble: #ffffff;
  --tg-chat: #dfe8d6;
  --tg-button: #eef3e6;
  --sidebar: #fafaf7;
  color-scheme: light;
}
/* Размеры. Шрифты: Onest — один вес 600 (заголовки, названия, числа), Inter — текст, JetBrains Mono — код.
   Высоты: --h — поля и кнопки, --h-sm — мелкие (фильтры, действия в строке, плашки), --h-lg — одна главная кнопка шага.
   Ширину панели блока на карте задаёт funnel-map.css. */
:root {
  --font: "Inter", -apple-system, system-ui, sans-serif;
  --display: "Onest", "Inter", -apple-system, system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --fs-h1: 22px; --fs-h2: 16px; --fs-h3: 14px;
  --fs: 13px; --fs-sm: 12px; --fs-xs: 11px; --fs-kpi: 22px;
  --h: 32px; --h-sm: 26px; --h-lg: 38px;
  --radius-sm: 6px; --radius: 10px; --radius-lg: 12px;
  --sidebar-w: 216px; --main-max: 1320px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: var(--fs)/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Заголовки: Onest 600 строчными; синтетический жирный выключен — у Onest загружен только вес 600. */
h1, h2, h3 { font-family: var(--display); font-weight: 600; text-transform: none; font-synthesis-weight: none; }
h1 { font-size: var(--fs-h1); line-height: 28px; letter-spacing: -.01em; margin: 0 0 12px; }
h2 { font-size: var(--fs-h2); line-height: 22px; letter-spacing: -.005em; margin: 20px 0 8px; }
h3 { font-size: var(--fs-h3); line-height: 20px; letter-spacing: 0; margin: 14px 0 6px; }
.card > :is(h2, h3):first-child, .card > form > h2:first-child { margin-top: 0; }
b, strong { font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: 12px; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.danger-text { color: var(--danger); }
/* Фокус с клавиатуры виден всегда: кольцо цветом акцента (мышью — без кольца). */
:is(a, button, summary, .btn, .icon-btn, .seg a, .st-seg button, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* каркас: левая панель + основная область */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 10px; padding: 12px 8px 10px; background: var(--sidebar); border-right: 1px solid var(--border); overflow-y: auto; }
.brand { font-family: var(--display); font-weight: 600; font-synthesis-weight: none; text-transform: none; letter-spacing: -.01em; color: var(--text); padding: 2px 8px 0; font-size: 15px; line-height: 20px; }
.brand span { color: var(--accent); }
.brand:hover { text-decoration: none; }
.ico { flex: none; }
.project-switch { position: relative; }
.project-switch summary { list-style: none; cursor: pointer; }
.project-switch summary::-webkit-details-marker { display: none; }
.project-card { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.project-card:hover { border-color: var(--muted); }
.project-card > .ico { color: var(--muted); transform: rotate(90deg); transition: transform .15s; }
.project-switch[open] .project-card > .ico { transform: rotate(-90deg); }
.project-logo { width: 28px; height: 28px; flex: none; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--accent-fill); color: var(--accent-text); font-weight: 600; font-size: 11px; }
.project-logo img { width: 100%; height: 100%; object-fit: cover; }
.project-logo.big { width: 48px; height: 48px; font-size: 16px; }
.project-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.project-title { font-weight: 600; font-size: 13px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-desc { color: var(--muted); font-size: var(--fs-xs); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.project-menu { margin-top: 6px; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); display: flex; flex-direction: column; gap: 2px; }
.project-item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: var(--radius-sm); color: var(--text); font-size: 13px; }
.project-item .project-logo { width: 22px; height: 22px; font-size: 10px; }
.project-item:hover { background: var(--surface-2); text-decoration: none; }
.new-project-form { display: flex; gap: 6px; padding: 4px; }
.new-project-form input { flex: 1; min-width: 0; height: var(--h-sm); padding: 0 8px; }
.divider { height: 1px; background: var(--border); margin: 2px 4px; }
.sections { display: flex; flex-direction: column; gap: 1px; }
.sections a { display: flex; align-items: center; gap: 8px; height: 30px; padding: 0 8px; border-radius: var(--radius-sm); color: var(--muted); font-size: 13px; }
.sections a .ico { width: 16px; height: 16px; }
.sections a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.sections a.active { color: var(--text); background: var(--accent-weak); font-weight: 500; box-shadow: inset 2px 0 0 var(--accent); }
.sections a.active .ico { color: var(--accent); }
/* красная точка у пункта меню: бот не работает, у кнопки под постом ошибка проверки */
.nav-dot { width: 7px; height: 7px; margin-left: auto; border-radius: 50%; background: var(--danger); flex: none; }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 6px; padding: 4px 0 4px 6px; border-radius: 8px; border: 1px solid transparent; background: none; }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-fill); color: var(--accent-text); font-weight: 600; font-size: 11px; flex: none; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta { color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* иконки в карточке пользователя: тема и «Выйти» */
.user-act { display: grid; place-items: center; width: 24px; height: 24px; flex: none; padding: 0; border: 0; border-radius: var(--radius-sm); background: none; color: var(--muted); cursor: pointer; }
.user-act:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
/* переключатель темы — одна иконка: в тёмной теме солнце (перейти в светлую), в светлой — луна */
html[data-theme="light"] .user-act[data-theme-set="light"], html:not([data-theme="light"]) .user-act[data-theme-set="dark"] { display: none; }
.main { min-width: 0; padding: 16px 24px 32px; max-width: var(--main-max); width: 100%; }
/* страницы-формы (настройки, боты, копирование воронки, списки): поля не растягиваются на весь экран */
.main.narrow { max-width: 960px; }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .main { padding: 16px 16px 32px; }
}

/* страница входа */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 340px; }
.login-card .brand { display: block; padding: 0 0 12px; }
.login-card .btn.primary { width: 100%; margin-top: 16px; }

/* плашки: ошибка — в потоке страницы, с красной полосой слева; «Сохранено» и другие успешные — всплывающим
   сообщением в правом нижнем углу, гаснет через 4 с (без JS) */
.flash { padding: 7px 12px; border-radius: 8px; margin-bottom: 12px; border: 1px solid var(--border); border-left-width: 3px; background: var(--surface); font-size: 13px; }
.flash.ok { border-color: var(--border); border-left-color: var(--accent); }
.flash.err { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); border-left-color: var(--danger); background: var(--danger-weak); }
.flash.small { padding: 5px 10px; font-size: var(--fs-sm); }
.main > .flash.ok { position: fixed; right: 16px; bottom: 16px; z-index: 120; max-width: 360px; margin: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .3); animation: bp-toast-out .3s ease 4s forwards; }
@keyframes bp-toast-out { to { opacity: 0; visibility: hidden; transform: translateY(6px); } }

/* карточки и сетки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 28px; margin-bottom: 10px; }
.card-head > :is(h2, h3) { margin: 0; }
.card-title { font: 600 15px/20px var(--display); letter-spacing: -.005em; font-synthesis-weight: none; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.top { align-items: flex-start; }
/* шапка страницы: h1 слева, действия и фильтры — справа, в одну строку */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 32px; margin-bottom: 12px; }
.page-head h1 { margin: 0; }
.page-head + .report-status { margin: -6px 0 12px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 12px; margin-bottom: 12px; }
.grid3 > .card { margin: 0; padding: 10px 14px; }
@media (max-width: 800px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.stat { font: 600 var(--fs-kpi)/1.15 var(--display); letter-spacing: -.01em; font-variant-numeric: tabular-nums; font-synthesis-weight: none; }
.stat-label { margin-top: 2px; color: var(--muted); font-size: var(--fs-sm); }

/* таблицы: шапка мелкая серая, цифры одной ширины; таблица — единственное в карточке — идёт в край карточки */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 10px; line-height: 1.35; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: var(--fs-sm); white-space: nowrap; }
td[colspan].muted { padding: 18px 10px; text-align: center; }
tr.problem td { background: var(--danger-weak); }
tr:hover td { background: var(--surface-2); }
.card:has(> table:only-child) { padding: 0; overflow-x: auto; }
.card:has(> table:only-child) :is(th, td):first-child { padding-left: 16px; }
.card:has(> table:only-child) :is(th, td):last-child { padding-right: 16px; }
.card:has(> table:only-child) tr:last-child td { border-bottom: 0; }

/* формы: поля 32 px, при фокусе — рамка и мягкое кольцо акцента */
label { display: block; color: var(--muted); font-size: var(--fs-sm); line-height: 16px; margin: 8px 0 3px; }
input:not([type]), input[type=text], input[type=email], input[type=number], input[type=url], input[type=datetime-local],
input[type=date], input[type=time], input[type=search], input[type=password], select, textarea {
  width: 100%; background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); font: inherit;
}
input:not([type]), input[type=text], input[type=email], input[type=number], input[type=url], input[type=datetime-local],
input[type=date], input[type=time], input[type=search], input[type=password], select { height: var(--h); padding: 0 10px; }
textarea { min-height: 72px; padding: 6px 10px; line-height: 1.45; resize: vertical; font-family: var(--font); }
:is(input, select, textarea):hover { border-color: color-mix(in srgb, var(--muted) 40%, var(--border)); }
:is(input:not([type=checkbox], [type=radio], [type=file]), select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
::placeholder { color: var(--muted); opacity: .7; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent-fill); }
.check { display: flex; align-items: center; gap: 6px; color: var(--text); font-size: 13px; margin: 6px 0; }
/* ползунок (стрелка «Отменить, если покинул блок», блок «Отвечать 1 раз», «Тестовый получатель» в диалоге):
   сам флажок спрятан, видна дорожка с бегунком */
.e-switch { position: relative; display: flex; align-items: center; gap: 10px; margin: 14px 0 0; color: var(--text); font-size: 13px; cursor: pointer; }
.e-switch input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.e-switch .sw { position: relative; flex: none; width: 34px; height: 20px; border-radius: 99px; background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border); transition: background .15s; }
.e-switch .sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--muted); transition: transform .15s, background .15s; }
.e-switch input:checked + .sw { background: var(--accent-fill); box-shadow: none; }
.e-switch input:checked + .sw::after { transform: translateX(14px); background: var(--accent-text); }
.e-switch input:focus-visible + .sw { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=file] { font-size: var(--fs-sm); color: var(--muted); }
input[type=file]::file-selector-button { height: var(--h-sm); margin-right: 8px; padding: 0 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer; }
/* кнопки: обычная — серая с рамкой; основная — лайм без свечения (одна на экран); опасная — красный текст без заливки;
   .ghost — «Отмена», «Сбросить»; .small — 26 px */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: var(--h); padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  white-space: nowrap; cursor: pointer; text-decoration: none; }
.btn .ico { width: 16px; height: 16px; }
.btn:hover { border-color: color-mix(in srgb, var(--muted) 55%, var(--border)); text-decoration: none; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-text); font-weight: 600; box-shadow: none; }
.btn.primary:hover { filter: brightness(1.06); border-color: var(--accent-fill); }
.btn.danger { color: var(--danger); background: transparent; }
.btn.danger:hover { border-color: var(--danger); background: var(--danger-weak); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.small { height: var(--h-sm); padding: 0 8px; gap: 4px; font-size: var(--fs-sm); border-radius: 5px; }
.btn.small .ico { width: 14px; height: 14px; }
.btn[disabled] { opacity: .45; cursor: default; }
form.inline { display: inline; }

/* метки */
.tag { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); font-size: var(--fs-xs); font-weight: 500; line-height: 1; white-space: nowrap; vertical-align: middle; }
.tag.accent { color: var(--accent-text); border-color: var(--accent-fill); background: var(--accent-fill); font-weight: 600; }
.tag.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-weak); }

/* сегменты-переключатели (период на «Главном», «Все / С проблемами» в диалогах): выбранный — лаймовый оттенок */
.seg, .st-seg { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.seg a, .st-seg button { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--muted); font: inherit; font-size: var(--fs-sm); white-space: nowrap; cursor: pointer; }
.seg a:hover, .st-seg button:hover { color: var(--text); text-decoration: none; }
.seg a.on, .st-seg button[aria-checked="true"] { background: var(--accent-weak); color: var(--text); font-weight: 500;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 45%, transparent); }

/* ссылка для копирования */
.copy { display: flex; gap: 6px; align-items: center; }
.copy input { font-family: var(--mono); height: var(--h-sm); font-size: var(--fs-sm); flex: 1; min-width: 220px; max-width: 460px; }

/* редактор сообщения: панель оформления и поле — одним блоком */
.editor-toolbar { display: flex; gap: 2px; flex-wrap: wrap; margin: 0; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-bottom: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.editor-toolbar button { height: 24px; padding: 0 7px; border: 0; border-radius: 4px; background: none; color: var(--muted); cursor: pointer; font: inherit; font-size: var(--fs-sm); }
.editor-toolbar button:hover { background: var(--surface); color: var(--text); }
.editor-toolbar button.on { background: var(--accent-weak); color: var(--text); }
.editor-toolbar ~ textarea { border-top-left-radius: 0; border-top-right-radius: 0; }
.video-ids { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 8px 10px; border: 1px solid var(--border); border-bottom: 0; border-radius: 0; background: var(--surface-2); }
.video-ids[hidden] { display: none; }
.video-ids label { margin-top: 0; }
.video-ids input { font-size: var(--fs-sm); }
/* поле ссылки под панелью оформления */
.link-pop { margin: 2px 0 8px; padding: 10px 12px 12px; border: 1px solid var(--accent-fill); border-radius: var(--radius); background: var(--surface-2); }
.link-pop label { margin-top: 6px; }
.link-pop label:first-child { margin-top: 0; }
.link-pop .flash { margin: 8px 0 0; padding: 6px 10px; font-size: 13px; }
.link-pop-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.toolbar-hint { margin: 0 0 6px; font-size: var(--fs-sm); color: var(--danger); }
/* превью сообщения как в Telegram */
.tg-chat { background: var(--tg-chat); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.tg-msg { background: var(--tg-bubble); border-radius: 14px 14px 14px 4px; max-width: 420px; width: 100%; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.tg-media img, .tg-media video { display: block; width: 100%; max-height: 420px; object-fit: cover; background: #000; }
.tg-media .tg-file { display: flex; align-items: center; gap: 10px; padding: 10px 12px 0; font-size: 13px; }
.tg-msg-solo .tg-file { padding-bottom: 10px; }
/* длинный текст с файлом: в Telegram — два сообщения (файл, потом текст) */
.tg-split-note { margin: 8px 0 0; font-size: var(--fs-sm); color: var(--muted); }
.tg-split-note.over { color: var(--danger); }
/* под текстом: «Не показывать превью ссылок» и счётчик символов */
.text-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.text-foot .check { margin: 6px 0; font-size: var(--fs-sm); color: var(--muted); }
.text-count { color: var(--muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-count.split { color: var(--accent); font-weight: 600; }
.text-count.over { color: var(--danger); font-weight: 600; }
.tg-preview { padding: 8px 11px 9px; white-space: normal; word-wrap: break-word; font-size: 14px; line-height: 1.4; }
.tg-preview:empty { display: none; }
.tg-preview blockquote { border-left: 3px solid var(--accent); margin: 4px 0; padding-left: 8px; }
.tg-preview tg-spoiler { background: var(--muted); color: transparent; border-radius: 3px; }
.tg-buttons { display: flex; flex-direction: column; gap: 4px; max-width: 420px; width: 100%; }
.tg-buttons:empty { display: none; }
.tg-buttons span { background: var(--tg-button); border-radius: 8px; text-align: center; padding: 7px; font-size: 13px; font-weight: 500; }
.tg-buttons span.is-link::after { content: " ↗"; opacity: .6; font-size: 11px; }

/* блоки формы сообщения: вложение и кнопки */
.content-form { display: flex; flex-direction: column; gap: 14px; }
.block-title { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font: 600 13px/18px var(--display); font-synthesis-weight: none; }
.block-title .ico { width: 14px; height: 14px; color: var(--accent); }
.attach-block, .buttons-block { border-top: 1px solid var(--border); padding-top: 12px; }
.attach-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.attach-btn { cursor: pointer; border-style: dashed; padding: 0 12px; }
.attach-btn:hover { border-color: var(--accent); color: var(--accent); }
.file-chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 9px; border-radius: 99px; background: var(--accent-weak); border: 1px solid var(--border); font-size: var(--fs-sm); max-width: 100%; }
.file-chip > span:not(.muted) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 280px; }
.file-chip.removed { opacity: .45; text-decoration: line-through; }
.chip-remove { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; border: 0; background: none; color: var(--muted); cursor: pointer; margin: 0; padding: 0; }
.chip-remove .ico { width: 12px; height: 12px; }
.chip-remove:hover { color: var(--danger); background: var(--danger-weak); }
.icon-btn { display: inline-grid; place-items: center; width: var(--h); height: var(--h); padding: 0; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.icon-btn .ico { width: 16px; height: 16px; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }
.add-btn { padding: 0 12px; border-style: dashed; }
.add-btn:hover { border-color: var(--accent); color: var(--accent); }
/* кнопки под сообщением — плашки, как в Salebot; клик — окно «Изменить кнопку» */
.btn-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.btn-items:empty { display: none; }
.btn-item { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.btn-item:hover { border-color: var(--muted); }
.btn-item.dragging { opacity: .45; border-style: dashed; }
.btn-item-grip { display: grid; place-items: center; width: 24px; flex: none; color: var(--muted); cursor: grab; border-right: 1px solid var(--border); }
.btn-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 10px; border: 0; background: none; color: var(--text); font: inherit; cursor: pointer; text-align: center; }
.btn-item-text { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.btn-item-sub { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; color: var(--muted); font-size: var(--fs-xs); font-family: var(--mono); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.btn-item-sub .ico { flex: none; color: var(--accent); }

/* окно поверх (кнопка, подтверждение, окна страниц): ширина 520, подтверждение — 380; шапка 48 px */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: rgba(0, 0, 0, .45); }
.modal { width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: 0 24px 70px rgba(0, 0, 0, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; padding: 8px 10px 8px 16px; border-bottom: 1px solid var(--border);
  font: 600 15px/20px var(--display); font-synthesis-weight: none; }
.modal-head b { font-weight: inherit; }
.modal-body { padding: 4px 16px 14px; overflow-y: auto; }
.modal-body .flash { margin: 12px 0 0; }
.modal-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; border-top: 1px solid var(--border); }
.grow { flex: 1; }
.modal-sm { width: min(380px, 100%); }
.modal-sm .modal-head { min-height: 0; border-bottom: 0; padding: 16px 16px 4px; }
.modal-sm .modal-body p { margin: 0; }
.modal-sm .modal-foot { border-top: 0; padding: 12px 16px 14px; }
.modal-sm .btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.modal-head .icon-btn { width: 28px; height: 28px; background: none; border-color: transparent; color: var(--muted); }
.modal-head .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.input-count { position: relative; }
.input-count input { padding-right: 56px; }
.input-count .count { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: var(--fs-xs); }
.m-extra { margin-top: 10px; }
.m-extra > summary { cursor: pointer; color: var(--muted); font-size: var(--fs-sm); }

textarea.code { min-height: 110px; font-family: var(--mono); font-size: var(--fs-sm); line-height: 1.5; tab-size: 2; white-space: pre; overflow-wrap: normal; overflow-x: auto; }
.calc-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.calc-result { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: 13px; }
.calc-result > div:not(.calc-col) { grid-column: 1 / -1; }
.calc-result.err { border-color: var(--danger); background: var(--danger-weak); }
.calc-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.calc-var { overflow-wrap: anywhere; }
.calc-err { color: var(--danger); }
.calc-ok { color: var(--accent); font-weight: 600; }
.calc-last-error { margin: 10px 0 0; font-size: var(--fs-sm); }
@media (max-width: 700px) { .calc-result { grid-template-columns: 1fr; } }

/* плашка выбранного значения (условия рассылки, списки подписчика) */
.value-chip { display: inline-flex; align-items: center; gap: 2px; height: 24px; padding: 0 3px 0 9px; border-radius: 99px; background: var(--accent-fill); color: var(--accent-text); font-size: var(--fs-sm); font-weight: 500; }
.value-chip .chip-remove { color: var(--accent-text); width: 18px; height: 18px; }
.value-chip .chip-remove:hover { background: rgba(0,0,0,.12); color: var(--accent-text); }

/* Значок мессенджера бота (Telegram / MAX). MAX — знак из brand/max, Telegram — самолётик цветом акцента. */
.pf { display: inline-flex; align-items: center; justify-content: center; vertical-align: -3px; flex: none; }
.pf-max { border-radius: 4px; }
.pf-tg { color: var(--accent); }

/* Ссылки бота (страница «Боты», templates/_links.html). */
.link-row { display: flex; gap: 8px 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px dashed var(--border); }
.link-main { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.link-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.link-edit, .link-new { flex: 0 0 auto; }
.link-edit[open], .link-new[open] { flex: 1 1 100%; }
.link-edit > summary, .link-new > summary { list-style: none; cursor: pointer; display: inline-flex; }
.link-edit > summary::-webkit-details-marker, .link-new > summary::-webkit-details-marker { display: none; }
.link-edit[open] > form, .link-new[open] > form { margin-top: 10px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.link-edit[open] > form + form { margin-top: 6px; padding: 0; border: 0; background: none; }  /* «Удалить ссылку» — без рамки */
.link-new { margin-top: 10px; }
.check-list { max-height: 150px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 2px 10px; }
.check-list .check { margin: 6px 0; }
.nowrap { white-space: nowrap; }


/* строка фильтров без подписей (подписчики): мелкие поля 26 px; справа — итог и действия */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.filter-bar :is(select, input[type=search], input[type=text]) { width: auto; height: var(--h-sm); padding: 0 8px; font-size: var(--fs-sm); }
.filter-bar select { max-width: 190px; }
.filter-bar input[type=text] { width: 260px; }
.filter-bar-end { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: var(--fs-sm); }
.search-field { position: relative; }
.search-field .ico { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-field input[type=search] { width: 220px; padding-left: 28px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: var(--fs-sm); }
/* действия в строке таблицы — иконками справа */
td.row-actions { width: 1%; text-align: right; white-space: nowrap; }
td.row-actions .icon-btn { width: 28px; height: 28px; background: none; border-color: transparent; color: var(--muted); }
td.row-actions .icon-btn:hover { border-color: var(--border); color: var(--text); }
td.row-actions .icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

/* кнопки формы под полями; короткая строка под полем */
.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.field-note { margin: 4px 0 10px; }

/* «Боты»: шапка карточки бота, ссылки бота — первыми, настройки бота — свёрнуты */
.bot-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.bot-card > .flash { margin: 0 0 10px; }
.bot-links .block-title { margin-bottom: 2px; }
.bot-links .link-new { margin-top: 8px; }
details.bot-settings { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
details.bot-settings > summary { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--fs-sm); cursor: pointer; list-style: none; }
details.bot-settings > summary::-webkit-details-marker { display: none; }
details.bot-settings > summary:hover { color: var(--text); }
details.bot-settings > summary .ico { transition: transform .15s; }
details.bot-settings[open] > summary .ico { transform: rotate(90deg); }


/* карточка-ссылка: клик по любому месту карточки открывает объект */
.card-link { display: block; color: inherit; text-decoration: none; transition: border-color .15s; }
.card-link:hover { border-color: color-mix(in srgb, var(--muted) 70%, var(--border)); text-decoration: none; }
/* сводка из трёх чисел, как на карточке автоответов Instagram: число, подпись */
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.mt { display: flex; flex-direction: column; min-width: 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.mt b { font: 600 17px/1.2 var(--display); font-variant-numeric: tabular-nums; font-synthesis-weight: none; color: var(--text); }
.mt span { color: var(--muted); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt i { color: var(--accent); font-size: var(--fs-xs); font-style: normal; font-weight: 500; white-space: nowrap; }

/* список воронок: слева название, триггеры и «сейчас в воронке», справа три числа; выключенные — приглушены */
.fn-list { display: flex; flex-direction: column; gap: 8px; }
.fn-card { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 400px); align-items: center; gap: 16px; margin: 0; padding: 12px 16px; }
.fn-card.off { opacity: .6; }
.fn-card.off:hover { opacity: .85; }
.fn-left { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fn-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.fn-name .card-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fn-triggers { color: var(--muted); font: var(--fs-xs)/16px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fn-trigger .ico { margin-right: 2px; vertical-align: -1px; }
.fn-no-trigger { color: var(--danger); font-family: var(--font); }
.fn-now { color: var(--muted); font-size: var(--fs-xs); }
@media (max-width: 760px) { .fn-card { grid-template-columns: 1fr; gap: 10px; } }
/* копирование воронки: название · триггер · сдвиг дат — одной строкой */
.copy-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; align-items: end; }
.copy-fields.with-days { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) auto; }
.copy-fields input[type=number] { width: 88px; }
.copy-preview { margin-top: 12px; }
@media (max-width: 700px) { .copy-fields, .copy-fields.with-days { grid-template-columns: 1fr; } }

/* пустые состояния: одна строка, при необходимости — мелкая кнопка */
.empty, .bc-empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty > .ico { width: 24px; height: 24px; margin-bottom: 6px; opacity: .5; }
.empty b { display: block; margin-bottom: 2px; color: var(--text); font-weight: 500; }
.empty .btn, .bc-empty .btn { margin-top: 10px; }

/* сворачиваемые карточки (Платёжные системы): стрелка раскрытия у заголовка */
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .card-title .ico { color: var(--muted); transition: transform .15s; vertical-align: -2px; }
details.card[open] > summary .card-title .ico { transform: rotate(90deg); }
