/* Кабинет Bot-Platform. Стиль — в духе higgsfield.ai: почти чёрный фон, один кислотно-лаймовый акцент,
   узкие заглавные заголовки. Красный — только для проблем. Цвета — токенами:
   --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;
}
:root {
  --radius: 14px;
  --font: "Inter", -apple-system, system-ui, sans-serif;
  --display: "Oswald", "Inter", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --sidebar-w: 260px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-family: var(--display); font-size: 30px; line-height: 1.1; margin: 0 0 18px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
h2 { font-family: var(--display); font-size: 18px; margin: 24px 0 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
h3 { font-size: 14px; margin: 16px 0 8px; font-weight: 600; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* каркас: левая панель + основная область */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 14px; padding: 18px 12px 14px; background: var(--sidebar); border-right: 1px solid var(--border); overflow-y: auto; }
.brand { font-family: var(--display); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text); padding: 0 10px 4px; font-size: 18px; }
.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: 12px; padding: 10px; border-radius: 12px; 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: 40px; height: 40px; flex: none; border-radius: 50%; display: grid; place-items: center; overflow: hidden; background: var(--accent-fill); color: var(--accent-text); font-weight: 700; font-size: 14px; text-transform: uppercase; }
.project-logo img { width: 100%; height: 100%; object-fit: cover; }
.project-logo.big { width: 56px; height: 56px; font-size: 18px; }
.project-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.project-title { font-weight: 650; font-size: 15px; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-desc { color: var(--muted); font-size: 12px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.project-menu { margin-top: 6px; padding: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); display: flex; flex-direction: column; gap: 2px; }
.project-item { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; color: var(--text); }
.project-item .project-logo { width: 28px; height: 28px; font-size: 11px; }
.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; padding: 6px 8px; }
.divider { height: 1px; background: var(--border); margin: 2px 4px; }
.sections { display: flex; flex-direction: column; gap: 2px; }
.sections a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); }
.sections a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.sections a.active { color: var(--text); background: var(--accent-weak); }
.sections a.active .ico { color: var(--accent); }
.sidebar-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.theme-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.theme-switch button { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 6px 8px; border: 0; border-radius: 7px; background: none; color: var(--muted); font: inherit; font-size: 12.5px; cursor: pointer; }
.theme-switch button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-fill); color: var(--accent-text); font-weight: 700; flex: none; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 600; font-size: 13.5px; }
.user-meta { color: var(--muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout { color: var(--muted); display: grid; place-items: center; }
.logout:hover { color: var(--text); }
.started { padding: 0 10px; font-size: 11.5px; }
.main { min-width: 0; padding: 28px 32px 48px; max-width: 1200px; width: 100%; }
@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: 20px 16px 40px; }
}

/* страница входа */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }

/* плашки */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; border: 1px solid var(--border); background: var(--surface); }
.flash.ok { border-color: var(--accent); }
.flash.err { border-color: var(--danger); background: var(--danger-weak); }

/* карточки и сетки */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.top { align-items: flex-start; }
.page-head { margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 800px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.stat { font-size: 26px; font-weight: 650; }
.stat-label { color: var(--muted); font-size: 12.5px; }

/* таблицы */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12.5px; }
tr.problem td { background: var(--danger-weak); }
tr:hover td { background: var(--surface-2); }

/* формы */
label { display: block; color: var(--muted); font-size: 12.5px; margin: 10px 0 4px; }
input:not([type]), input[type=text], input[type=email], input[type=number], input[type=url], input[type=datetime-local], input[type=date], input[type=search], input[type=password], select, textarea {
  width: 100%; background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font: inherit;
}
textarea { min-height: 140px; resize: vertical; font-family: var(--font); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent-fill); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; margin: 10px 0; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary { background: var(--accent-fill); border-color: var(--accent-fill); color: var(--accent-text); font-weight: 600; box-shadow: var(--accent-glow); }
.btn.primary:hover { filter: brightness(1.06); border-color: var(--accent-fill); }
.btn.danger { color: var(--danger); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn[disabled] { opacity: .5; cursor: default; }
form.inline { display: inline; }

/* метки */
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); font-size: 12px; }
.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: var(--danger); background: var(--danger-weak); }

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

/* редактор сообщения */
.editor-toolbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.editor-toolbar button { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 6px; padding: 3px 9px; cursor: pointer; font: inherit; font-size: 13px; }
.editor-toolbar button:hover { border-color: var(--accent); }
/* превью сообщения как в Telegram */
.tg-chat { background: var(--tg-chat); border-radius: var(--radius); padding: 16px; 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-preview { padding: 9px 12px 10px; white-space: normal; word-wrap: break-word; font-size: 14.5px; line-height: 1.45; }
.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: 10px; text-align: center; padding: 8px; font-size: 13.5px; font-weight: 500; }

/* блоки формы сообщения: вложение и кнопки */
.content-form { display: flex; flex-direction: column; gap: 18px; }
.block-title { display: flex; align-items: center; gap: 8px; font-weight: 600; margin-bottom: 10px; }
.block-title .ico { color: var(--accent); }
.attach-block, .buttons-block { border-top: 1px solid var(--border); padding-top: 16px; }
.attach-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.attach-btn { cursor: pointer; border-style: dashed; padding: 10px 16px; }
.attach-btn:hover { border-color: var(--accent); color: var(--accent); }
.attach-kind { width: auto; font-size: 12.5px; padding: 6px 8px; }
.file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px 6px 10px; border-radius: 99px; background: var(--accent-weak); border: 1px solid var(--border); font-size: 13px; 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: 22px; height: 22px; border-radius: 50%; border: 0; background: none; color: var(--muted); cursor: pointer; margin: 0; }
.chip-remove:hover { color: var(--danger); background: var(--danger-weak); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.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: 10px 16px; border-style: dashed; }
.add-btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.btn-row { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.btn-row-head { display: flex; align-items: center; gap: 10px; }
.btn-row-head select { width: auto; flex: 1; max-width: 260px; }
.btn-row-head .icon-btn { margin-left: auto; }
.btn-row-ico { color: var(--accent); display: grid; place-items: center; }
.btn-row-fields { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.btn-row .action-fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
@media (max-width: 800px) { .btn-row-fields, .btn-row .action-fields { grid-template-columns: 1fr; } }

/* лента шагов воронки */
.timeline { position: relative; margin-left: 14px; padding-left: 22px; border-left: 2px solid var(--border); }
.timeline .step { position: relative; }
.timeline .step::before { content: ""; position: absolute; left: -30px; top: 18px; width: 12px; height: 12px; border-radius: 50%; background: var(--accent-fill); box-shadow: 0 0 10px rgba(209, 254, 23, .5); }
.timeline .when { color: var(--accent); font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }

/* диалог */
.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 72%; padding: 8px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.msg.out { align-self: flex-end; }
.msg.in { align-self: flex-start; background: var(--surface); }
.msg.failed { border-color: var(--danger); background: var(--danger-weak); }
.msg .meta { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.msg.event { align-self: center; background: none; border: none; color: var(--muted); font-size: 12.5px; padding: 2px; }

/* плашка выбранного значения (условия рассылки, списки подписчика) */
.value-chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 4px 4px 10px; border-radius: 99px; background: var(--accent-fill); color: var(--accent-text); font-size: 13px; font-weight: 500; }
.value-chip .chip-remove { color: var(--accent-text); width: 20px; height: 20px; }
.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); }
