:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #f1f3f7;
  --border: #e6e8ee;
  --border-strong: #d4d8e1;
  --text: #0f1422;
  --text-2: #4a5263;
  --muted: #8a92a3;
  --accent: #6d5efc;
  --accent-2: #5a4af0;
  --accent-soft: #efedff;
  --accent-text: #4f3fe0;
  --ok: #16a34a;
  --ok-soft: #dcfce7;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 4px 14px rgba(16, 24, 40, .08);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, .18);
  --canvas: #f2f3f7;
  --dot: #d3d7e2;
  --edge: #a9b0c0;
  --tg-bg: #d9e3ec;
  --tg-bubble: #ffffff;
  --tg-btn: rgba(255, 255, 255, .72);
  --font: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f14; --surface: #151820; --surface-2: #1a1e27; --surface-3: #212632;
    --border: #252a35; --border-strong: #343a48; --text: #eceef3; --text-2: #aab0bd; --muted: #6f7686;
    --accent: #7d6fff; --accent-2: #8e82ff; --accent-soft: #231f45; --accent-text: #b8afff;
    --ok-soft: #0f2d1b; --warn-soft: #33260a; --danger-soft: #3a1515;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 4px 14px rgba(0, 0, 0, .4); --shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
    --canvas: #101218; --dot: #262b36; --edge: #4b5263;
    --tg-bg: #0e1621; --tg-bubble: #182533; --tg-btn: rgba(255, 255, 255, .08);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 600; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.ic { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ic svg { display: block; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.hidden { display: none !important; }

/* ============ Layout ============ */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 248px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 14px 12px; gap: 6px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 12px; font-weight: 700; font-size: 15px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #8b7dff, #5a4af0); display: grid; place-items: center; color: #fff; box-shadow: 0 4px 12px rgba(109, 94, 252, .35); }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); margin-top: -2px; }
.bot-switch { position: relative; }
.bot-switch-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); cursor: pointer; text-align: left; }
.bot-switch-btn:hover { border-color: var(--border-strong); }
.bot-switch-btn .grow div:first-child { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-menu { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.bot-menu button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; }
.bot-menu button:hover { background: var(--surface-3); }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; color: var(--text-2); font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.nav-sep { height: 1px; background: var(--border); margin: 8px 4px; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
.main { flex: 1; min-width: 0; }
.page { max-width: 1180px; margin: 0 auto; padding: 28px 32px 60px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex-shrink: 0; }
.status-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.status-dot.err { background: #ef4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .18); }

.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; color: #fff; flex-shrink: 0; }
.avatar.sm { width: 28px; height: 28px; font-size: 11.5px; }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }

/* ============ Controls ============ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s, box-shadow .12s; text-decoration: none !important; }
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(109, 94, 252, .28); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: transparent; }
.btn.danger-solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; }
.btn.icon { width: 36px; padding: 0; }
.btn.icon.sm { width: 30px; }
.btn.icon.xs { width: 26px; }

.input, .select, .textarea { width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; }
.textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 84px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input.sm, .select.sm { height: 30px; font-size: 13px; border-radius: 8px; padding: 0 9px; }
.select { appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a92a3' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; cursor: pointer; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 10px 0 0 10px; }
.input-group .btn { border-radius: 0 10px 10px 0; border-left: 0; }
.input-suffix { position: relative; }
.input-suffix span { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.fields { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 36px; height: 21px; border-radius: 99px; background: var(--border-strong); position: relative; transition: background .15s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch .lbl { font-size: 13px; color: var(--text-2); }

.segmented { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.segmented button { border: 0; background: transparent; padding: 5px 11px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 550; color: var(--text-2); display: inline-flex; align-items: center; gap: 6px; }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.segmented.full { display: flex; }
.segmented.full button { flex: 1; justify-content: center; }

.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 99px; background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 550; white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.chip.accent { background: var(--accent-soft); color: var(--accent-text); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip button { border: 0; background: none; padding: 0; margin-right: -3px; cursor: pointer; color: inherit; opacity: .6; display: inline-flex; }
.chip button:hover { opacity: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 36px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: text; }
.chips-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.chips-input input { border: 0; outline: 0; background: none; flex: 1; min-width: 90px; height: 24px; }

/* ============ Cards ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.card-body { padding: 18px 20px; }
.cards { display: grid; gap: 16px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { padding: 16px 18px; }
.stat .lbl { display: flex; align-items: center; gap: 7px; color: var(--text-2); font-size: 12.5px; font-weight: 550; }
.stat .val { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: -.02em; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat .lbl .ic { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-text); }

.banner { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 12px; margin-bottom: 16px; font-size: 13.5px; }
.banner.err { background: var(--danger-soft); color: var(--danger); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--accent-soft); color: var(--accent-text); }
.banner .grow { color: var(--text); }

.checklist { display: flex; flex-direction: column; }
.check-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--border); }
.check-item:last-child { border-bottom: 0; }
.check-item .box { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.check-item.done .box { background: var(--ok); border-color: var(--ok); }
.check-item.done .t { color: var(--muted); text-decoration: line-through; }

/* ============ Table ============ */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.table td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 54px 20px; }
.empty .ic { width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent-text); margin: 0 auto 14px; }
.empty h3 { font-size: 16px; }
.empty p { color: var(--text-2); max-width: 420px; margin: 6px auto 18px; }

.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s; }

/* ============ Overlays ============ */
.overlay { position: fixed; inset: 0; background: rgba(10, 12, 20, .45); backdrop-filter: blur(2px); z-index: 200; display: grid; place-items: center; padding: 20px; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 100%; max-width: 480px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; animation: pop .16s ease-out; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.modal-body { padding: 12px 20px 8px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }
.drawer-overlay { place-items: stretch end; padding: 0; }
.drawer { background: var(--surface); width: min(560px, 100vw); height: 100vh; overflow: auto; box-shadow: var(--shadow-lg); animation: slide .18s ease-out; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 400; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #151823; color: #fff; padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); font-weight: 500; display: flex; align-items: center; gap: 8px; animation: pop .16s; max-width: 90vw; }
.toast.err { background: var(--danger); }
.menu { position: fixed; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 300; min-width: 190px; animation: pop .1s; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: none; padding: 8px 10px; border-radius: 8px; cursor: pointer; text-align: left; font-size: 13.5px; }
.menu button:hover { background: var(--surface-3); }
.menu button.danger { color: var(--danger); }
.menu .menu-title { font-size: 11.5px; font-weight: 600; color: var(--muted); padding: 6px 10px 4px; text-transform: uppercase; letter-spacing: .04em; }

/* ============ Auth ============ */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 20% -10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 420px; padding: 32px; }
.auth-card .brand { justify-content: center; padding: 0 0 18px; font-size: 18px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: s; display: flex; gap: 12px; align-items: flex-start; color: var(--text-2); }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 12px; display: grid; place-items: center; flex-shrink: 0; }

/* ============ Flows list ============ */
.flow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.flow-card { padding: 18px; display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: box-shadow .15s, border-color .15s, transform .15s; }
.flow-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); transform: translateY(-1px); }
.flow-card h3 { font-size: 15px; }
.flow-card .dots { display: flex; gap: 4px; flex-wrap: wrap; }
.flow-card .dots span { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; color: #fff; }
.flow-card .foot { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 12.5px; border-top: 1px solid var(--border); padding-top: 12px; }
.tpl-grid { display: grid; gap: 10px; }
.tpl { display: flex; gap: 12px; padding: 14px; border: 1.5px solid var(--border); border-radius: 12px; cursor: pointer; text-align: left; background: var(--surface); }
.tpl:hover { border-color: var(--border-strong); }
.tpl.on { border-color: var(--accent); background: var(--accent-soft); }
.tpl .ic { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-3); }
.tpl.on .ic { background: var(--accent); color: #fff; }
.tpl p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-2); }

/* ============ Chart ============ */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .grid { stroke: var(--border); stroke-dasharray: 3 3; }

/* ============ Telegram preview ============ */
.tg { background: var(--tg-bg); border-radius: 14px; padding: 16px 14px; background-image: radial-gradient(circle at 20px 20px, rgba(255, 255, 255, .25) 2px, transparent 2.5px); background-size: 34px 34px; }
.tg-msg { max-width: 320px; }
.tg-bubble { background: var(--tg-bubble); border-radius: 14px 14px 14px 4px; overflow: hidden; box-shadow: 0 1px 1px rgba(0, 0, 0, .1); font-size: 14px; }
.tg-text { padding: 7px 11px 8px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; }
.tg-text:empty { display: none; }
.tg-text a { color: #2f86d6; }
.tg-text code, .tg-text pre { background: rgba(0, 0, 0, .06); }
.tg-text blockquote { border-left: 3px solid #2f86d6; margin: 2px 0; padding: 1px 8px; background: rgba(47, 134, 214, .08); border-radius: 4px; }
.tg-text .tg-spoiler, .tg-text tg-spoiler { background: rgba(120, 120, 120, .35); color: transparent; border-radius: 3px; }
.tg-text .var { background: var(--accent-soft); color: var(--accent-text); border-radius: 4px; padding: 0 3px; }
.tg-time { float: right; font-size: 11px; color: var(--muted); margin: 6px 0 -4px 10px; }
.tg-media { background: linear-gradient(135deg, #8aa4c0, #b7c7d8); height: 160px; display: grid; place-items: center; color: rgba(255, 255, 255, .95); font-weight: 600; gap: 6px; }
.tg-media img, .tg-media video { width: 100%; height: 100%; object-fit: cover; }
.tg-media.file { height: auto; padding: 10px; background: none; color: var(--text); display: flex; justify-content: flex-start; }
.tg-media.file .ic { width: 42px; height: 42px; border-radius: 50%; background: #3b93e0; color: #fff; }
.tg-media.round { width: 170px; height: 170px; border-radius: 50%; margin: 8px; }
.tg-kb { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.tg-kb-row { display: flex; gap: 4px; }
.tg-kb-row > span { flex: 1; background: var(--tg-btn); backdrop-filter: blur(6px); color: var(--text); border-radius: 9px; padding: 8px 6px; text-align: center; font-size: 13px; font-weight: 550; display: flex; align-items: center; justify-content: center; gap: 4px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-reply-kb { margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.tg-reply-kb span { background: var(--tg-bubble); border-radius: 8px; padding: 8px; text-align: center; font-size: 13px; }

/* ============ Content editor ============ */
.toolbar { display: flex; gap: 2px; padding: 4px; border: 1px solid var(--border); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--surface-2); flex-wrap: wrap; }
.toolbar button { border: 0; background: none; height: 28px; min-width: 28px; padding: 0 6px; border-radius: 6px; cursor: pointer; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 4px; font-size: 12.5px; font-weight: 600; }
.toolbar button:hover { background: var(--surface-3); color: var(--text); }
.toolbar + .textarea { border-radius: 0 0 10px 10px; }
.counter { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: -2px; }
.counter.over { color: var(--danger); font-weight: 600; }
.btn-list { display: flex; flex-direction: column; gap: 8px; }
.btn-item { border: 1px solid var(--border); border-radius: 11px; padding: 9px; display: flex; flex-direction: column; gap: 7px; background: var(--surface-2); }
.media-box { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px dashed var(--border-strong); border-radius: 11px; }
.media-box .ic.big { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-3); }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 11px; padding: 16px; text-align: center; color: var(--text-2); cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

.list-editor { display: flex; flex-direction: column; gap: 8px; }
.list-row { display: flex; gap: 6px; align-items: flex-start; padding: 9px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); }
.list-row .col { gap: 6px; }

.section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 6px 0 -4px; display: flex; align-items: center; gap: 8px; }
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
details.more summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 6px; }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary .ic { transform: rotate(90deg); }
details.more > div { margin-top: 12px; }

/* ============ Editor ============ */
.editor { position: fixed; inset: 0; z-index: 100; display: flex; flex-direction: column; background: var(--canvas); }
.ed-top { height: 56px; flex-shrink: 0; display: flex; align-items: center; gap: 10px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 3; }
.ed-name { font-size: 15px; font-weight: 650; border: 1px solid transparent; background: transparent; padding: 5px 8px; border-radius: 8px; width: 340px; max-width: 30vw; outline: none; }
.ed-name:hover { border-color: var(--border); }
.ed-name:focus { border-color: var(--accent); background: var(--surface); }
.save-state { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.save-state.err { color: var(--danger); }
.ed-body { flex: 1; display: flex; min-height: 0; }
.ed-palette { width: 212px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); padding: 12px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.ed-palette h4 { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 6px 4px; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: grab; border: 1px solid transparent; user-select: none; background: none; text-align: left; width: 100%; }
.pal-item:hover { background: var(--surface-2); border-color: var(--border); }
.pal-item:active { cursor: grabbing; }
.pal-item .ic { width: 30px; height: 30px; border-radius: 9px; color: #fff; background: var(--c); }
.pal-item b { display: block; font-size: 13px; font-weight: 600; }
.pal-item small { display: block; font-size: 11.5px; color: var(--muted); line-height: 1.25; }
.ed-canvas { flex: 1; position: relative; overflow: hidden; background-color: var(--canvas); background-image: radial-gradient(var(--dot) 1.2px, transparent 1.3px); touch-action: none; cursor: default; }
.ed-canvas.panning { cursor: grabbing; }
.ed-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; width: 0; height: 0; }
.ed-edges { position: absolute; left: 0; top: 0; width: 1px; height: 1px; overflow: visible; pointer-events: none; }
.ed-edges path.edge { fill: none; stroke: var(--edge); stroke-width: 2; transition: stroke .12s; }
.ed-edges path.edge.stat { stroke-width: 2.5; }
.ed-edges path.hit { fill: none; stroke: transparent; stroke-width: 16; pointer-events: stroke; cursor: pointer; }
.ed-edges g:hover path.edge { stroke: var(--accent); }
.ed-edges g.sel path.edge { stroke: var(--accent); stroke-width: 3; }
.ed-edges path.temp { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 6 5; }
.ed-edges .arrow { fill: var(--edge); }
.ed-edges g:hover .arrow, .ed-edges g.sel .arrow { fill: var(--accent); }
.edge-del { position: absolute; transform: translate(-50%, -50%); width: 24px; height: 24px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); display: grid; place-items: center; cursor: pointer; color: var(--danger); z-index: 5; }

.node { position: absolute; width: 256px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); user-select: none; cursor: grab; }
.node:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.node.sel { border-color: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent), var(--shadow-md); }
.node.drop-target { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.node.dragging { cursor: grabbing; box-shadow: var(--shadow-lg); z-index: 4; }
.node-head { display: flex; align-items: center; gap: 9px; padding: 10px 12px 8px; }
.node-head .ic { width: 26px; height: 26px; border-radius: 8px; background: var(--c); color: #fff; }
.node-head .t { flex: 1; min-width: 0; }
.node-head .t b { display: block; font-size: 13px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-head .t small { display: block; font-size: 11px; color: var(--muted); margin-top: -1px; }
.node-warn { width: 18px; height: 18px; border-radius: 50%; background: var(--warn-soft); color: var(--warn); display: grid; place-items: center; }
.node-stat { font-size: 11px; font-weight: 650; padding: 2px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); display: inline-flex; align-items: center; gap: 3px; }
.node-body { padding: 0 12px 10px; font-size: 12.5px; color: var(--text-2); line-height: 1.4; }
.node-body .preview { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; word-break: break-word; }
.node-body .kv { display: flex; align-items: center; gap: 6px; }
.node-body .empty-hint { color: var(--muted); font-style: italic; }
.node-media { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; color: var(--text-2); background: var(--surface-3); border-radius: 6px; padding: 2px 7px; margin-bottom: 6px; }
.node-ports { border-top: 1px solid var(--border); padding: 4px 0; }
.port-row { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding: 5px 20px 5px 12px; font-size: 12px; color: var(--text-2); min-height: 28px; }
.port-row.btn-port span.lbl { background: var(--surface-3); border-radius: 7px; padding: 2px 8px; font-weight: 550; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.port-row .cnt { font-size: 10.5px; color: var(--accent-text); font-weight: 650; }
.port-out { position: absolute; right: -8px; top: 50%; width: 15px; height: 15px; margin-top: -7.5px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--c); cursor: crosshair; transition: transform .1s; z-index: 2; }
.port-out:hover { transform: scale(1.3); background: var(--c); }
.port-out.connected { background: var(--c); }
.port-out.yes { border-color: #16a34a; } .port-out.yes.connected { background: #16a34a; }
.port-out.no { border-color: #ef4444; } .port-out.no.connected { background: #ef4444; }
.port-in { position: absolute; left: -8px; top: 20px; width: 15px; height: 15px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--edge); }
.node.has-in .port-in { border-color: var(--c); background: var(--c); }

.ed-zoom { position: absolute; left: 14px; bottom: 14px; display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 4px; box-shadow: var(--shadow-md); z-index: 3; align-items: center; }
.ed-zoom span { font-size: 12px; font-weight: 600; min-width: 42px; text-align: center; color: var(--text-2); }
.ed-hint { position: absolute; right: 14px; bottom: 14px; font-size: 11.5px; color: var(--muted); background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 5px 10px; border-radius: 8px; z-index: 3; pointer-events: none; }
.ed-empty { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); text-align: center; color: var(--muted); pointer-events: none; }

.ed-inspector { width: 400px; flex-shrink: 0; background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.insp-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.insp-head .ic.type { width: 34px; height: 34px; border-radius: 10px; background: var(--c); color: #fff; }
.insp-head input { font-weight: 650; font-size: 15px; border: 1px solid transparent; background: none; padding: 3px 6px; margin-left: -6px; border-radius: 7px; width: 100%; outline: none; }
.insp-head input:hover { border-color: var(--border); }
.insp-head input:focus { border-color: var(--accent); }
.insp-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.insp-foot { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; gap: 6px; }
.warn-list { display: flex; flex-direction: column; gap: 6px; }
.warn-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 11px; background: var(--warn-soft); border-radius: 10px; cursor: pointer; font-size: 13px; }
.warn-item .ic { color: var(--warn); margin-top: 1px; }
.qa-menu { max-height: 70vh; overflow-y: auto; }
.qa-menu button .ic { width: 24px; height: 24px; border-radius: 7px; color: #fff; background: var(--c); }

@media (max-width: 1100px) {
  .ed-palette { width: 64px; }
  .ed-palette h4, .pal-item small, .pal-item b { display: none; }
  .ed-inspector { width: 340px; }
}
@media (max-width: 860px) {
  .sidebar { width: 72px; padding: 12px 8px; }
  .brand span, .brand small, .bot-switch-btn .grow, .bot-switch-btn > .ic, .nav a span.t, .sidebar-foot span.t { display: none; }
  .nav a { justify-content: center; }
  .page { padding: 20px 16px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
  .ed-inspector { position: absolute; right: 0; top: 56px; bottom: 0; z-index: 10; box-shadow: var(--shadow-lg); width: min(400px, 100vw); }
  .ed-inspector.closed { display: none; }
}

/* ============ v2: кнопки, эмодзи, анимации ============ */
.tg-kb-row > span.st-primary { background: #3390ec; color: #fff; }
.tg-kb-row > span.st-success { background: #31b545; color: #fff; }
.tg-kb-row > span.st-danger { background: #e5484d; color: #fff; }
.tg-reply-kb .tg-kb-row > span { background: var(--tg-bubble); }
.tg-reply-kb .tg-kb-row > span.st-primary { background: #3390ec; color: #fff; }
.tg-reply-kb .tg-kb-row > span.st-success { background: #31b545; color: #fff; }
.tg-reply-kb .tg-kb-row > span.st-danger { background: #e5484d; color: #fff; }
.btn-emoji { font-style: normal; margin-right: 2px; }
.tg-text tg-emoji { display: inline-block; filter: drop-shadow(0 0 3px rgba(255, 190, 60, .9)); }
.tg-typing { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); background: var(--tg-bubble); border-radius: 12px; padding: 4px 10px; margin-bottom: 8px; }
.tg-typing .dots { display: inline-flex; gap: 3px; }
.tg-typing .dots i { width: 5px; height: 5px; border-radius: 50%; background: #3390ec; animation: blink 1.2s infinite; }
.tg-typing .dots i:nth-child(2) { animation-delay: .2s; } .tg-typing .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.tg-effect { font-size: 11.5px; color: var(--text-2); margin-top: 6px; }
.tg-media.spoiler img, .tg-media.spoiler .ic { filter: blur(14px); }
.tg-album { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px; }
.tg-album-item { aspect-ratio: 1; background: linear-gradient(135deg, #8aa4c0, #b7c7d8); display: grid; place-items: center; color: #fff; overflow: hidden; }
.tg-album-item img { width: 100%; height: 100%; object-fit: cover; }
.tg-sticker { width: 140px; height: 140px; display: grid; place-items: center; color: #f5a623; }
.tg-sticker img { max-width: 100%; max-height: 100%; }
.album-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.album-cell { position: relative; aspect-ratio: 1; border-radius: 8px; background: var(--surface-3); display: grid; place-items: center; overflow: hidden; color: var(--muted); }
.album-cell img { width: 100%; height: 100%; object-fit: cover; }
.album-cell button { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; cursor: pointer; }
.swatches { display: inline-flex; gap: 5px; }
.sw { width: 22px; height: 22px; border-radius: 7px; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.sw.on { border-color: var(--text); }
.sw-default { background: var(--surface-3); }
.sw-primary { background: #3390ec; } .sw-success { background: #31b545; } .sw-danger { background: #e5484d; }
.toolbar button.premium { color: #b7791f; }
.insp-head input::placeholder { color: var(--text); opacity: 1; }
.provider-card { border: 1px solid var(--border); border-radius: 12px; }
.provider-card > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; font-weight: 600; }
.provider-card > summary::-webkit-details-marker { display: none; }
.provider-card[open] > summary { border-bottom: 1px solid var(--border); }
.provider-card > div { padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.provider-logo { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.emoji-cell { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; }
.emoji-cell span.e { font-size: 20px; }
.emoji-cell code { font-size: 10.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; }
.funnel-steps { display: flex; flex-direction: column; gap: 8px; }
.funnel-step { display: grid; grid-template-columns: 200px 1fr 90px; gap: 12px; align-items: center; }
.funnel-bar { height: 28px; background: var(--surface-3); border-radius: 8px; overflow: hidden; position: relative; }
.funnel-bar > div { height: 100%; border-radius: 8px; background: var(--c, var(--accent)); opacity: .85; }
.funnel-bar > span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 12px; font-weight: 650; color: var(--text); }
.stat .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty .btn { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 860px) { .funnel-step { grid-template-columns: 1fr; gap: 4px; } .br-grid { grid-template-columns: 1fr !important; } }
