:root {
  --bg: #f4f5f2; --surface: #ffffff; --surface-2: #f8f9f7; --ink: #121815; --ink-2: #3c4541; --muted: #6b746f; --line: #e3e6e1; --line-2: #eef0ec;
  --accent: #0b6e4f; --accent-ink: #ffffff; --accent-soft: #e5f2ec; --accent-2: #12a06f;
  --out: #dcf1e5; --in: #ffffff; --note: #fff6d6; --chat-bg: #efeae2;
  --warn: #a15c00; --warn-soft: #fff1db; --danger: #c0262d; --danger-soft: #fde7e7; --info: #1d5fd1; --info-soft: #e5eefc;
  --shadow: 0 1px 2px rgba(16,24,20,.06), 0 4px 16px rgba(16,24,20,.06); --shadow-lg: 0 12px 48px rgba(16,24,20,.18);
  --r: 10px; --r-lg: 14px; --nav-w: 224px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1311; --surface: #151b18; --surface-2: #1a211e; --ink: #e9eeeb; --ink-2: #c3ccc7; --muted: #8b958f; --line: #26302b; --line-2: #1f2824;
    --accent: #23b37f; --accent-ink: #04140d; --accent-soft: #143127; --accent-2: #3fd29c;
    --out: #13392b; --in: #1d2622; --note: #3a3216; --chat-bg: #0b100e;
    --warn: #f0b04c; --warn-soft: #3a2a0f; --danger: #f06a6f; --danger-soft: #3d1517; --info: #7aa7ff; --info-soft: #172743;
    --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 48px rgba(0,0,0,.6); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1311; --surface: #151b18; --surface-2: #1a211e; --ink: #e9eeeb; --ink-2: #c3ccc7; --muted: #8b958f; --line: #26302b; --line-2: #1f2824;
  --accent: #23b37f; --accent-ink: #04140d; --accent-soft: #143127; --accent-2: #3fd29c;
  --out: #13392b; --in: #1d2622; --note: #3a3216; --chat-bg: #0b100e;
  --warn: #f0b04c; --warn-soft: #3a2a0f; --danger: #f06a6f; --danger-soft: #3d1517; --info: #7aa7ff; --info-soft: #172743;
  --shadow: 0 1px 2px rgba(0,0,0,.4); --shadow-lg: 0 12px 48px rgba(0,0,0,.6); color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; } h2 { font-size: 17px; font-weight: 650; } h3 { font-size: 15px; font-weight: 650; }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .tiny { font-size: 11.5px; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; } .col { display: flex; flex-direction: column; gap: 8px; }
.between { justify-content: space-between; } .end { justify-content: flex-end; } .gap-lg { gap: 16px; } .mt { margin-top: 12px; } .mt-lg { margin-top: 20px; } .mb { margin-bottom: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.show-sm { display: none; }
@media (max-width: 860px) { .show-sm { display: inline; } }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }

/* ---------- shell ---------- */
#app { display: flex; height: 100vh; height: 100dvh; }
.nav { width: var(--nav-w); flex: none; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: -0.03em; }
.brand b { display: block; font-size: 15px; } .brand span { display: block; font-size: 11.5px; color: var(--muted); }
.nav a.item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px; color: var(--ink-2); font-weight: 500; position: relative; }
.nav a.item:hover { background: var(--surface-2); color: var(--ink); }
.nav a.item.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a.item .badge { margin-left: auto; }
.nav .sep { height: 1px; background: var(--line); margin: 8px 6px; }
.nav .foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.numsel { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-2); }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; }
.me:hover { background: var(--surface-2); }
main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.page { flex: 1; overflow: auto; padding: 22px 28px 40px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.demo-banner { background: var(--warn-soft); color: var(--warn); padding: 7px 16px; font-size: 13px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); }
.demo-banner a { color: inherit; text-decoration: underline; font-weight: 600; }
.tabbar { display: none; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 550; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; text-decoration: none; }
.btn:hover { background: var(--surface-2); border-color: #cdd2cc; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); } .btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; } .btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; } .btn.icon { padding: 7px; } .btn.sm.icon { padding: 5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.input, .select, textarea.input { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); outline: none; transition: border-color .12s, box-shadow .12s; }
.input:focus, .select:focus, textarea.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 84px; line-height: 1.5; }
label.f { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; } label.f:first-child { margin-top: 0; }
label.f .muted { font-weight: 400; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.switch { position: relative; width: 38px; height: 22px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: #c9cfca; cursor: pointer; transition: .15s; }
.switch span::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--accent); } .switch input:checked + span::after { transform: translateX(16px); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 550; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.chip .x { cursor: pointer; opacity: .6; } .chip .x:hover { opacity: 1; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 650; letter-spacing: .02em; text-transform: uppercase; background: var(--surface-2); color: var(--muted); }
.pill.green { background: var(--accent-soft); color: var(--accent); } .pill.amber { background: var(--warn-soft); color: var(--warn); } .pill.red { background: var(--danger-soft); color: var(--danger); } .pill.blue { background: var(--info-soft); color: var(--info); }
.badge { min-width: 19px; height: 19px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; }
.badge.warn { background: var(--warn); color: #fff; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.card + .card { margin-top: 14px; }
.card h3 + p { margin: 4px 0 0; }
.grid { display: grid; gap: 14px; } .g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; cursor: pointer; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; cursor: pointer; font-weight: 550; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
table.t td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr.click { cursor: pointer; } table.t tr.click:hover td { background: var(--surface-2); }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: auto; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg.i { width: 36px; height: 36px; stroke-width: 1.4; margin-bottom: 8px; color: var(--accent); }
.empty h3 { color: var(--ink); margin-bottom: 4px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; font-size: 14px; color: #fff; flex: none; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.kpi .v { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bar { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; } .bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

/* ---------- modal + toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10,16,13,.42); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .12s; }
.modal { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; animation: pop .14s; }
.modal.wide { width: min(880px, 100%); } .modal.xwide { width: min(1100px, 100%); }
.modal .mh { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal .mb { padding: 18px 20px; overflow: auto; }
.modal .mf { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #17201c; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-weight: 500; max-width: min(520px, 92vw); animation: pop .15s; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--accent); color: var(--accent-ink); }
@keyframes fade { from { opacity: 0; } } @keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.98); } }
.drop { position: absolute; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-lg); z-index: 40; min-width: 200px; max-height: 320px; overflow: auto; padding: 4px; }
.drop .opt { padding: 8px 10px; border-radius: 7px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.drop .opt:hover, .drop .opt.on { background: var(--surface-2); }

/* ---------- inbox ---------- */
.inbox { flex: 1; display: grid; grid-template-columns: 340px minmax(0,1fr) 300px; min-height: 0; }
.inbox.noinfo { grid-template-columns: 340px minmax(0,1fr); }
.inbox.noinfo .cinfo, .inbox.nochat .cinfo { display: none; }
.inbox.nochat { grid-template-columns: 340px minmax(0,1fr); }
.clist { border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.clist .top { padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.search { position: relative; } .search svg.i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); } .search .input { padding-left: 34px; background: var(--surface-2); }
.filters { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.filters button { border: 1px solid var(--line); background: var(--surface); padding: 4px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 550; cursor: pointer; white-space: nowrap; color: var(--ink-2); display: inline-flex; gap: 5px; align-items: center; }
.filters button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.filters button .n { font-size: 11px; opacity: .8; }
.citems { overflow: auto; flex: 1; }
.citem { display: flex; gap: 11px; padding: 11px 14px; cursor: pointer; border-bottom: 1px solid var(--line-2); position: relative; }
.citem:hover { background: var(--surface-2); } .citem.on { background: var(--accent-soft); }
.citem .nm { font-weight: 600; } .citem .tm { font-size: 11.5px; color: var(--muted); flex: none; }
.citem .pv { color: var(--muted); font-size: 13px; } .citem.unread .pv { color: var(--ink); font-weight: 550; } .citem.unread .tm { color: var(--accent); font-weight: 650; }
.citem .flags { display: flex; gap: 4px; align-items: center; flex: none; }
.ldots { display: flex; gap: 3px; margin-top: 4px; flex-wrap: wrap; } .ldots .chip { font-size: 10.5px; padding: 1px 6px; }
.conv { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--chat-bg); }
.chead { background: var(--surface); border-bottom: 1px solid var(--line); padding: 10px 14px; display: flex; align-items: center; gap: 11px; min-height: 62px; }
.chead .who { min-width: 110px; flex: 1 1 auto; }
.chead > .btn, .chead > .ai-toggle, .chead > .winbadge { flex: none; }
.chead .who b { display: block; font-size: 15px; } .chead .who span { font-size: 12.5px; color: var(--muted); }
.winbadge { font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.winbadge.open { background: var(--accent-soft); color: var(--accent); } .winbadge.closed { background: var(--warn-soft); color: var(--warn); }
.ai-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; padding: 4px 6px 4px 10px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); }
.msgs { flex: 1; overflow: auto; padding: 16px 6% 10px; display: flex; flex-direction: column; gap: 3px; }
.day { align-self: center; background: var(--surface); color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 8px; margin: 12px 0 8px; box-shadow: var(--shadow); }
.bub { max-width: min(78%, 560px); padding: 7px 10px 6px; border-radius: 10px; position: relative; box-shadow: 0 1px .5px rgba(0,0,0,.08); word-wrap: break-word; overflow-wrap: anywhere; }
.bub.in { align-self: flex-start; background: var(--in); border-top-left-radius: 3px; }
.bub.out { align-self: flex-end; background: var(--out); border-top-right-radius: 3px; }
.bub.note { align-self: center; background: var(--note); max-width: 86%; border: 1px dashed #d9c27a; font-size: 13px; }
.bub .txt { white-space: pre-wrap; }
.bub .meta { display: flex; gap: 6px; justify-content: flex-end; align-items: center; font-size: 11px; color: var(--muted); margin-top: 2px; }
.bub .by { font-size: 11px; font-weight: 650; color: var(--accent); margin-bottom: 2px; display: flex; gap: 5px; align-items: center; }
.bub .by.bot { color: #7c3aed; } .bub .by.broadcast, .bub .by.sequence { color: var(--info); } .bub .by.flow, .bub .by.rule { color: #0e7490; }
.ticks { display: inline-flex; } .ticks.read { color: #2b8af7; } .ticks.failed { color: var(--danger); }
.bub img.media, .bub video.media { display: block; max-width: 100%; max-height: 320px; border-radius: 7px; margin: -2px -4px 4px; }
.bub .doc { display: flex; align-items: center; gap: 8px; padding: 8px; background: rgba(0,0,0,.04); border-radius: 7px; margin-bottom: 4px; }
.bub .ibtns { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.bub .ibtns span { display: block; text-align: center; padding: 6px; border-radius: 7px; background: var(--surface); color: var(--info); font-weight: 600; font-size: 13px; border: 1px solid var(--line); }
.bub .ibtns span[data-choice]:hover { border-color: var(--info); }
.bub .thead { font-weight: 700; margin-bottom: 3px; } .bub .tfoot { font-size: 12px; color: var(--muted); margin-top: 4px; }
.bub .err { color: var(--danger); font-size: 12px; margin-top: 3px; }
.bub .react { position: absolute; bottom: -12px; right: 8px; background: var(--surface); border-radius: 99px; padding: 0 5px; box-shadow: var(--shadow); font-size: 13px; }
.bub.in .react { right: auto; left: 8px; }
.bub + .bub.react-gap { margin-top: 10px; }
.composer { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 12px; position: relative; }
.composer .modes { display: flex; gap: 2px; margin-bottom: 8px; }
.composer .modes button { border: 0; background: transparent; padding: 3px 10px; border-radius: 7px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.composer .modes button.on { background: var(--accent-soft); color: var(--accent); } .composer.note-mode .modes button.on { background: var(--note); color: #8a6d00; }
.composer .box { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; min-height: 42px; max-height: 180px; outline: none; background: var(--surface-2); line-height: 1.4; }
.composer.note-mode textarea { background: var(--note); }
.composer textarea:focus { border-color: var(--accent); }
.sendbtn { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex: none; }
.closed-note { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--warn-soft); color: var(--warn); border-radius: 10px; font-size: 13px; }
.simbar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--info-soft); border-top: 1px solid var(--line); font-size: 12.5px; color: var(--info); }
.simbar .input { padding: 6px 10px; background: var(--surface); }
.cinfo { border-left: 1px solid var(--line); background: var(--surface); overflow: auto; padding: 18px 16px 30px; }
.cinfo .sec { padding: 14px 0; border-bottom: 1px solid var(--line-2); } .cinfo .sec:last-child { border: 0; }
.cinfo .sec > h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin-bottom: 9px; display: flex; justify-content: space-between; align-items: center; }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 8px; font-size: 13px; align-items: center; } .kv .k { color: var(--muted); }
.kv input { border: 1px solid transparent; background: transparent; padding: 3px 6px; border-radius: 6px; width: 100%; margin-left: -6px; }
.kv input:hover { border-color: var(--line); } .kv input:focus { border-color: var(--accent); outline: none; background: var(--surface); }
.qr-pop { position: absolute; bottom: calc(100% + 4px); left: 12px; right: 12px; max-height: 260px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow-lg); padding: 4px; z-index: 5; }
.qr-pop .opt { padding: 8px 10px; border-radius: 7px; cursor: pointer; } .qr-pop .opt.on, .qr-pop .opt:hover { background: var(--surface-2); }
.no-chat { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 30px; }

/* ---------- builders ---------- */
.step { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; position: relative; }
.step .shead { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.step .sid { font-size: 11px; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.step-link { display: flex; justify-content: center; padding: 4px 0; color: var(--muted); }
.step-link button { border: 1px dashed var(--line); background: transparent; border-radius: 99px; padding: 2px 10px; font-size: 12px; cursor: pointer; color: var(--muted); }
.step-link button:hover { border-color: var(--accent); color: var(--accent); }
.action { display: grid; grid-template-columns: 170px 1fr auto; gap: 8px; align-items: start; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.action + .action { margin-top: 8px; }
.phone { width: 300px; background: #0f1512; border-radius: 34px; padding: 10px; box-shadow: var(--shadow-lg); flex: none; }
.phone .scr { background: var(--chat-bg); border-radius: 26px; overflow: hidden; height: 540px; display: flex; flex-direction: column; }
.phone .ph { background: var(--accent); color: #fff; padding: 12px 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.phone .pb { flex: 1; padding: 12px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.phone .bub { max-width: 92%; font-size: 13px; }
.split { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 24px; align-items: start; }
.home-split { grid-template-columns: minmax(0,1fr) 340px; gap: 14px; }
.sticky { position: sticky; top: 0; }
.funnel { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 10px; }
.funnel .kpi .pct { font-size: 12.5px; font-weight: 650; color: var(--accent); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); } .legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .tip { position: fixed; pointer-events: none; background: #17201c; color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 7px; z-index: 60; white-space: nowrap; }
.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; }
.copy { cursor: pointer; }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(400px, 100%); padding: 28px; box-shadow: var(--shadow); }

/* ---------- phones / tablets ---------- */
@media (max-width: 1500px) { .hide-md { display: none !important; } }
@media (max-width: 1180px) { .inbox, .inbox.nochat, .inbox.noinfo { grid-template-columns: 300px minmax(0,1fr); } .cinfo { position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 92vw); z-index: 30; box-shadow: var(--shadow-lg); } .inbox.noinfo .cinfo, .inbox.nochat .cinfo { display: none; } .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .funnel { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 860px) {
  .nav { display: none; }
  #app { flex-direction: column; }
  .page { padding: 16px 16px 90px; }
  .tabbar { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); z-index: 20; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; font-weight: 600; color: var(--muted); padding: 6px 0; position: relative; }
  .tabbar a.on { color: var(--accent); }
  .tabbar a .badge { position: absolute; top: 0; left: 55%; height: 16px; min-width: 16px; font-size: 10px; }
  .inbox, .inbox.nochat, .inbox.noinfo { grid-template-columns: 1fr; padding-bottom: 0; }
  .inbox .conv { display: none; } .inbox.chat-open .clist { display: none; } .inbox.chat-open .conv { display: flex; }
  .inbox.chat-open ~ .tabbar, body.chat-open .tabbar { display: none; }
  .clist { padding-bottom: 62px; }
  .msgs { padding: 12px 10px; } .bub { max-width: 88%; }
  .chead { padding: 8px 8px; gap: 6px; } .chead .hide-sm { display: none; } .chead .btn.icon { padding: 5px; } .chead .avatar { width: 34px; height: 34px; font-size: 12px; } .ai-toggle { padding: 3px 4px 3px 8px; } .chead .who { min-width: 60px; }
  .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .kpi .v { font-size: 20px; } .funnel { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split, .home-split { grid-template-columns: 1fr; } .phone { width: 100%; max-width: 320px; margin: 0 auto; }
  .action { grid-template-columns: 1fr; }
  .modal { max-height: calc(100dvh - 16px); } .overlay { padding: 8px; align-items: end; } .modal { border-radius: 16px 16px 12px 12px; }
  .hide-sm { display: none !important; }
  h1 { font-size: 19px; }
}

/* ---------- chart series (validated reference palette; dark steps chosen for dark surface) ---------- */
:root { --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --grid: #e7e9e5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --grid: #26302b; } }
:root[data-theme="dark"] { --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --grid: #26302b; }
.hbar { display: grid; grid-template-columns: 110px 1fr 46px; gap: 8px; align-items: center; font-size: 13px; padding: 4px 0; }
.hbar .track { height: 10px; background: var(--line-2); border-radius: 4px; overflow: hidden; } .hbar .track i { display: block; height: 100%; background: var(--s1); border-radius: 0 4px 4px 0; }
.hbar b { text-align: right; font-variant-numeric: tabular-nums; }

/* v3: review queue + AI feedback + installed phone app */
.newdiv { align-self: stretch; display: flex; align-items: center; gap: 8px; margin: 10px 0 6px; color: #7c3aed; font-size: 11.5px; font-weight: 650; }
.newdiv::before, .newdiv::after { content: ''; flex: 1; height: 1px; background: #c4b5fd; }
.aifb { display: inline-flex; gap: 2px; margin-right: auto; }
.aifb button { border: 0; background: transparent; cursor: pointer; font-size: 12px; padding: 0 3px; opacity: .45; border-radius: 6px; }
.aifb button:hover { opacity: 1; background: var(--line-2); }
@media (display-mode: standalone) { body { padding-top: env(safe-area-inset-top); } }
.clist { min-width: 0; }
.revbar { background: #f1ecff; color: #3b0764; flex-wrap: wrap; }
.revbar > .grow { min-width: 0; flex: 1 1 160px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .revbar { background: #2a2140; color: #ddd0ff; } :root:not([data-theme="light"]) .newdiv { color: #b9a4ff; } }
:root[data-theme="dark"] .revbar { background: #2a2140; color: #ddd0ff; } :root[data-theme="dark"] .newdiv { color: #b9a4ff; }

.numsel-top { display: none; margin-bottom: 8px; font-weight: 600; }
@media (max-width: 860px) { .numsel-top { display: block; } }
