:root {
  --canvas: #F5F7FC;
  --surface: #FFFFFF;
  --ink: #04122E;
  --ink-2: #3B4763;
  --muted: #6B7690;
  --line: #E4E9F2;
  --line-2: #EEF2F8;
  --accent: #4A7DFF;
  --accent-ink: #2F5FE0;
  --accent-soft: #EDF2FF;
  --gain: #0F9D6B;
  --gain-soft: #E6F6EF;
  --loss: #E5484D;
  --loss-soft: #FDECEC;
  --warn: #B7791F;
  --warn-soft: #FEF5E3;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(4, 18, 46, .04), 0 2px 8px rgba(4, 18, 46, .04);
  --shadow-lg: 0 12px 32px rgba(4, 18, 46, .10);
  --sidebar: 236px;
  --head: 'Poppins', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--body); font-size: 14px; line-height: 1.5; color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--head); margin: 0; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 14px; font-weight: 600; }
.num, td.num, .kpi-value { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: #fff; display: grid; place-items: center; padding: 3px; box-shadow: 0 0 0 1px rgba(4,18,46,.08); flex: none; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.boot-wait .brand-mark { width: 64px; height: 64px; border-radius: 16px; padding: 6px; }
.brand-name { font-family: var(--head); font-weight: 600; font-size: 15px; line-height: 1.1; }
.brand-name small { display: block; font-family: var(--body); font-weight: 500; color: var(--muted); font-size: 12px; }
.nav-group { margin-top: 14px; }
.nav-label { color: var(--muted); font-size: 12px; font-weight: 500; padding: 0 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--ink-2); font-weight: 500; text-decoration: none; position: relative; transition: background .12s, color .12s; }
.nav a svg { width: 17px; height: 17px; flex: none; color: var(--muted); }
.nav a:hover { background: var(--line-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav a.active::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav a.active svg { color: var(--accent-ink); }
.nav .count { margin-left: auto; font-size: 11px; background: var(--warn-soft); color: var(--warn); border-radius: 20px; padding: 1px 7px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid var(--line-2); font-size: 12px; color: var(--muted); }
.mode-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 20px; font-weight: 600; font-size: 12px; }
.mode-chip.test { background: var(--warn-soft); color: var(--warn); }
.mode-chip.live { background: var(--gain-soft); color: var(--gain); }
.mode-chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(244, 246, 251, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 10px 28px; }
.search { position: relative; flex: 1; max-width: 460px; }
.search input { width: 100%; padding-left: 34px; background: var(--surface); }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--muted); }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; background: var(--canvas); font-family: var(--body); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 30px rgba(4, 18, 46, .12); padding: 6px; display: none; max-height: 420px; overflow: auto; }
.search-results.open { display: block; }
.search-results a { display: flex; gap: 10px; align-items: baseline; padding: 8px 10px; border-radius: 7px; color: var(--ink); text-decoration: none; }
.search-results a:hover, .search-results a.hl { background: var(--accent-soft); }
.search-results .t { font-size: 11px; color: var(--muted); width: 62px; flex: none; }
.user-menu { margin-left: auto; position: relative; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; border: 0; cursor: pointer; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 30px rgba(4, 18, 46, .12); min-width: 220px; padding: 6px; display: none; }
.menu.open { display: block; }
.menu .who { padding: 8px 10px 10px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
.menu .who b { display: block; }
.menu .who span { color: var(--muted); font-size: 12px; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; font: inherit; color: var(--ink); cursor: pointer; }
.menu button:hover { background: var(--line-2); }

.view { padding: 24px 28px 64px; max-width: 1280px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 240px; }
.page-head p { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.crumb a { color: var(--muted); }

/* ---------- controls ---------- */
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 11px; min-height: 36px; outline: none; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { width: 100%; min-height: 90px; resize: vertical; }
textarea.code { font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; font-size: 12.5px; min-height: 420px; }
input[type=checkbox], input[type=radio] { min-height: 0; width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
input[type=color] { padding: 2px; width: 44px; }
.btn { font: inherit; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border-radius: var(--radius-sm); padding: 8px 14px; min-height: 36px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; text-decoration: none; box-shadow: 0 1px 1px rgba(4, 18, 46, .04); transition: background .12s, border-color .12s, box-shadow .12s; }
.btn:hover { background: var(--line-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: linear-gradient(180deg, #5A89FF, var(--accent)); border-color: #3F72F5; color: #fff; box-shadow: 0 1px 2px rgba(47, 95, 224, .35), inset 0 1px 0 rgba(255, 255, 255, .18); }
.btn.primary:hover { background: var(--accent-ink); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.danger { color: var(--loss); }
.btn.danger.solid { background: var(--loss); border-color: var(--loss); color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label, .label { font-weight: 600; font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.check { display: flex; gap: 9px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 3px; }
.seg-ctl { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 2px; }
.seg-ctl button { border: 0; background: none; font: inherit; font-weight: 500; padding: 5px 12px; border-radius: 5px; color: var(--ink-2); cursor: pointer; }
.seg-ctl button.on { background: var(--ink); color: #fff; }

/* ---------- panels, tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 15px 20px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.panel-head h2 { flex: 1; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; font-weight: 400; }
.panel-body { padding: 20px; }
.panel-body.tight { padding: 0; }
table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 11px 16px; border-bottom: 1px solid var(--line); background: #FAFBFE; white-space: nowrap; }
table.t th:first-child { border-top-left-radius: var(--radius); } table.t th:last-child { border-top-right-radius: var(--radius); }
table.t td { padding: 13px 16px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #F8FAFE; }
table.t th.num, table.t td.num { text-align: right; }
td .sub { display: block; color: var(--muted); font-size: 12.5px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; text-decoration: none; }
.tabs a.on { color: var(--ink); border-color: var(--ink); }
.tabs a .c { color: var(--muted); font-weight: 500; margin-left: 4px; }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.pill.green { background: var(--gain-soft); color: var(--gain); }
.pill.blue { background: var(--accent-soft); color: var(--accent-ink); }
.pill.amber { background: var(--warn-soft); color: var(--warn); }
.pill.red { background: var(--loss-soft); color: var(--loss); }
.pill.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px; border-radius: 20px; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-size: 13px; }
.chip.ex { background: var(--loss-soft); color: var(--loss); }
.chip button { border: 0; background: rgba(255,255,255,.6); color: inherit; width: 20px; height: 20px; border-radius: 50%; cursor: pointer; font-size: 14px; line-height: 1; }

/* ---------- P&L strip (home) ---------- */
.pnl { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); background: radial-gradient(120% 140% at 0% 0%, #10275A 0%, var(--ink) 55%); border-radius: 18px; color: #fff; overflow: hidden; margin-bottom: 22px; box-shadow: 0 18px 40px rgba(4, 18, 46, .18); }
.pnl > div { padding: 18px 20px 14px; border-right: 1px solid rgba(255,255,255,.08); position: relative; min-width: 0; }
.pnl > div:last-child { border-right: 0; }
.pnl .k { font-size: 12.5px; color: #A9B4CF; }
.pnl .v { font-family: var(--head); font-size: 26px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.pnl .hero .v { font-size: 36px; }
.pnl .d { font-size: 12.5px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.pnl .d.up { color: #34D399; } .pnl .d.down { color: #FB7185; } .pnl .d.flat { color: #A9B4CF; }
.pnl .spark { display: block; margin-top: 8px; width: 100%; height: 30px; }
.pnl .split { font-size: 12px; color: #A9B4CF; margin-top: 6px; }
.pnl .split b { color: #fff; font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow); overflow: hidden; }
.kpi { padding: 16px 20px; border-right: 1px solid var(--line-2); }
.kpi:last-child { border-right: 0; }
.kpi .k { color: var(--muted); font-size: 12.5px; }
.kpi .kpi-value { font-family: var(--head); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.kpi .s { font-size: 12.5px; color: var(--muted); }
.delta.up { color: var(--gain); } .delta.down { color: var(--loss); }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cols-31 { display: grid; grid-template-columns: minmax(0, 2.1fr) minmax(280px, 1fr); gap: 18px; align-items: start; }
.chart { width: 100%; display: block; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.bar-track { height: 6px; background: var(--line-2); border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar-track span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

.callout { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--accent-soft); color: var(--ink-2); margin-bottom: 16px; align-items: flex-start; }
.callout.warn { background: var(--warn-soft); }
.callout.bad { background: var(--loss-soft); }
.callout.good { background: var(--gain-soft); }
.callout b { color: var(--ink); }
.callout .grow { flex: 1; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); font-size: 16px; margin-bottom: 6px; }
.empty p { max-width: 46ch; margin: 0 auto 16px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; }
.stack > * + * { margin-top: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 360px; display: inline-block; vertical-align: bottom; }

/* ---------- modal & toast ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4, 18, 46, .38); display: grid; place-items: center; z-index: 100; padding: 20px; animation: fade .12s ease; }
.modal { background: var(--surface); border-radius: 18px; width: min(560px, 100%); max-height: calc(100vh - 40px); overflow: auto; box-shadow: 0 30px 80px rgba(4, 18, 46, .3); animation: pop .16s ease; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } }
.modal.wide { width: min(900px, 100%); }
.modal-head { padding: 18px 22px 0; display: flex; align-items: center; }
.modal-head h2 { flex: 1; font-size: 17px; }
.modal-body { padding: 16px 22px; }
.modal-foot { padding: 14px 22px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.x { border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; padding: 4px 8px; border-radius: 6px; }
.x:hover { background: var(--line-2); }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 500; box-shadow: 0 10px 30px rgba(4, 18, 46, .25); animation: fade .15s ease; max-width: 560px; }
.toast.error { background: var(--loss); }

/* ---------- condition builder ---------- */
.cond-group { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: #FAFBFD; }
.cond-and { font-weight: 700; font-size: 12px; color: var(--ink-2); margin: 8px 0 8px 14px; }
.cond { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; }
.cond + .cond { margin-top: 0; }
.cond-or { font-size: 12px; font-weight: 700; color: var(--accent-ink); margin: 6px 0 6px 10px; }
.cond select, .cond input { min-height: 32px; padding: 5px 9px; }
.cond input.n { width: 76px; }

/* ---------- flow builder ---------- */
.flow-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background-color: #FBFCFE; background-image: radial-gradient(#D9E0EE 1px, transparent 1px); background-size: 18px 18px; min-height: 420px; }
.flow-canvas { display: flex; flex-direction: column; align-items: center; padding: 24px 24px 48px; min-width: max-content; margin: 0 auto; }
.node { width: 340px; max-width: 86vw; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; cursor: pointer; position: relative; box-shadow: var(--shadow); transition: border-color .12s, box-shadow .12s; }
.node:hover { border-color: #C9D3E6; }
.node.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.node .top { display: flex; align-items: center; gap: 10px; }
.node .ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; }
.node .ic svg { width: 16px; height: 16px; }
.node.trigger .ic { background: var(--ink); color: #fff; }
.node.email .ic { background: var(--accent-soft); color: var(--accent-ink); }
.node.delay .ic { background: var(--warn-soft); color: var(--warn); }
.node.split .ic { background: #F3E8FF; color: #7C3AED; }
.node.update_profile .ic, .node.list_add .ic, .node.list_remove .ic { background: var(--gain-soft); color: var(--gain); }
.node.notify .ic, .node.webhook .ic { background: #E0F2FE; color: #0369A1; }
.branches { display: flex; gap: 32px; align-items: flex-start; position: relative; padding-top: 22px; margin-top: 0; }
.branches::before { content: ''; position: absolute; top: 0; left: 50%; width: 2px; height: 12px; background: #C9D3E6; transform: translateX(-1px); }
.branches::after { content: ''; position: absolute; top: 12px; left: calc(25% ); right: calc(25%); height: 2px; background: #C9D3E6; }
.branch { display: flex; flex-direction: column; align-items: center; min-width: 300px; flex: 1; position: relative; }
.branch-label { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 20px; position: relative; z-index: 1; }
.branch-label.yes { background: var(--gain-soft); color: var(--gain); }
.branch-label.no { background: var(--loss-soft); color: var(--loss); }
.node .ttl { font-weight: 600; flex: 1; min-width: 0; }
.node .ttl small { display: block; font-weight: 400; color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.node .stats { display: flex; gap: 14px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.node .stats b { color: var(--ink); font-variant-numeric: tabular-nums; }
.node.delay { width: auto; min-width: 220px; padding: 8px 14px; border-radius: 30px; }
.node.delay .stats { display: none; }
.wire { width: 2px; height: 22px; background: #C9D3E6; }
.add-step { width: 28px; height: 28px; border-radius: 50%; border: 1px dashed #A9B6D0; background: var(--surface); color: var(--ink-2); cursor: pointer; font-size: 17px; line-height: 1; }
.add-step:hover { border-style: solid; border-color: var(--accent); color: var(--accent-ink); }
.flow-end { margin-top: 0; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 3px 12px; }
.waiting { position: absolute; right: -10px; top: -10px; background: var(--warn); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 20px; }
.inspector { position: sticky; top: 74px; }

/* ---------- email editor ---------- */
.editor { display: grid; grid-template-columns: 380px minmax(0, 1fr); gap: 18px; align-items: start; }
.block-list .blk { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin-bottom: 8px; }
.blk-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; cursor: pointer; }
.blk-head .name { flex: 1; font-weight: 600; min-width: 0; }
.blk-head .name small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.blk-head button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 3px 5px; border-radius: 5px; font-size: 14px; }
.blk-head button:hover { background: var(--line-2); color: var(--ink); }
.blk.open { border-color: var(--accent); }
.blk-body { padding: 4px 10px 12px; border-top: 1px solid var(--line-2); }
.blk-body .field { margin-bottom: 10px; }
.preview-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; position: sticky; top: 74px; }
.preview-bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line-2); }
.preview-bar .subj { flex: 1; min-width: 0; }
.preview-bar .subj b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-bar .subj span { color: var(--muted); font-size: 12.5px; }
.preview-frame { width: 100%; height: calc(100vh - 210px); min-height: 520px; border: 0; display: block; background: #fff; margin: 0 auto; transition: width .2s; }
.preview-frame.mobile { width: 390px; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
.rte-bar { display: flex; gap: 2px; margin-bottom: 4px; }
.rte-bar button { border: 1px solid var(--line); background: var(--surface); border-radius: 5px; min-width: 28px; height: 26px; cursor: pointer; font-weight: 700; color: var(--ink-2); }
.rte { min-height: 90px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 11px; background: var(--surface); outline: none; }
.rte:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.tpl-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; text-align: left; padding: 0; font: inherit; color: inherit; }
.tpl-card:hover { border-color: #C3CEE4; }
.tpl-thumb { height: 230px; overflow: hidden; background: var(--canvas); position: relative; pointer-events: none; }
.tpl-thumb iframe { width: 640px; height: 900px; border: 0; transform: scale(.36); transform-origin: 0 0; }
.tpl-card .meta { padding: 10px 12px; border-top: 1px solid var(--line-2); }
.tpl-card .meta b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tpl-card .meta span { color: var(--muted); font-size: 12.5px; }
.starter { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.starter:hover, .starter.on { border-color: var(--accent); background: var(--accent-soft); }
.starter b { display: block; margin-bottom: 2px; }
.starter span { color: var(--muted); font-size: 13px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.timeline li:last-child { border-bottom: 0; }
.tl-dot { width: 10px; height: 10px; border-radius: 50%; margin: 5px 6px; background: var(--line); }
.tl-dot.event { background: var(--accent); } .tl-dot.opened, .tl-dot.clicked { background: var(--gain); } .tl-dot.bounced, .tl-dot.failed { background: var(--loss); } .tl-dot.received { background: #9AA8C4; }
.timeline .when { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.props { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--ink-2); }
.props span b { color: var(--muted); font-weight: 500; }

.cohort td { text-align: center; font-variant-numeric: tabular-nums; font-size: 12.5px; }
.code-box { background: #0B1735; color: #D6E1FF; border-radius: var(--radius-sm); padding: 12px 14px; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; white-space: pre-wrap; word-break: break-all; position: relative; }
.copy { position: absolute; top: 8px; right: 8px; }
.score-ring { width: 108px; height: 108px; flex: none; }
.check-list li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); align-items: flex-start; }
.check-list { list-style: none; padding: 0; margin: 0; }
.check-list .ok { color: var(--gain); font-weight: 700; } .check-list .no { color: var(--loss); font-weight: 700; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { color: #fff; font-size: 34px; line-height: 1.15; max-width: 14ch; font-weight: 600; }
.auth-side p { color: #A9B4CF; max-width: 40ch; }
.auth-tape { display: flex; gap: 22px; font-variant-numeric: tabular-nums; color: #A9B4CF; font-size: 13px; flex-wrap: wrap; }
.auth-tape b { display: block; color: #fff; font-family: var(--head); font-size: 22px; font-weight: 600; }
.auth-tape .up { color: #34D399; }
.auth-form { display: grid; place-items: center; padding: 32px; }
.auth-form form { width: min(380px, 100%); }
.auth-form h2 { font-size: 22px; margin-bottom: 4px; }
.auth-form p { color: var(--muted); margin: 0 0 22px; }
.auth-form input { width: 100%; }
.auth-form .btn { width: 100%; margin-top: 6px; }
.err { color: var(--loss); font-size: 13px; min-height: 18px; margin: 4px 0; }

@media (max-width: 1100px) {
  .pnl { grid-template-columns: repeat(2, 1fr); }
  .pnl .hero { grid-column: 1 / -1; }
  .cols, .cols-31, .editor { grid-template-columns: 1fr; }
  .inspector, .preview-wrap { position: static; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(4,18,46,.2); }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-flex !important; }
  .view { padding: 18px 16px 48px; }
  .topbar { padding: 10px 16px; }
  .search kbd { display: none; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  table.t { display: block; overflow-x: auto; }
}
.menu-btn { display: none; }

.title-input { font-family: var(--head); font-size: 20px; font-weight: 600; border-color: transparent; background: transparent; padding: 2px 6px; margin-left: -7px; width: min(520px, 100%); }
.title-input:hover { border-color: var(--line); background: var(--surface); }

/* ---------- v4 additions ---------- */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 6px; background: #EEF1F8; color: var(--ink-2); font-size: 12px; font-weight: 600; vertical-align: 1px; }
.tag button { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: -6px 0 14px; }
.fchip { padding: 4px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: 13px; font-weight: 600; text-decoration: none; }
.fchip:hover { text-decoration: none; border-color: #C9D3E6; }
.fchip.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg-ctl.wrap { flex-wrap: wrap; }
.nowrap-row { flex-wrap: nowrap; }
.ai-btn { color: #7C3AED; border-color: #E9D5FF; background: #FAF5FF; }
.ai-btn:hover { background: #F3E8FF; }
.ai-options { display: grid; gap: 8px; }
.ai-opt { text-align: left; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; color: var(--ink); line-height: 1.5; }
.ai-opt:hover { border-color: #C4B5FD; background: #FAF5FF; }
.ai-opt p { margin: 0 0 6px; }
.sub-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px; margin-bottom: 10px; background: #FAFBFE; }
.show-if { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
.show-if summary { cursor: pointer; }

/* calendar */
.cal-head, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line-2); }
.cal-cell { min-height: 112px; border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.out { background: #FAFBFE; }
.cal-cell.today .cal-day { background: var(--accent); color: #fff; }
.cal-day { font-size: 12px; font-weight: 600; color: var(--ink-2); width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; }
.cal-item { display: block; font-size: 12px; padding: 3px 6px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; font-weight: 600; }
.cal-item span { font-weight: 500; opacity: .8; }
.cal-item.sent { background: var(--gain-soft); color: var(--gain); }
.cal-item.draft, .cal-item.cancelled { background: var(--line-2); color: var(--ink-2); }
.cal-item:hover { text-decoration: none; filter: brightness(.97); }

/* image library */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.img-card { margin: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.img-card[data-url] { cursor: pointer; }
.img-card[data-url]:hover, .img-card[data-url]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.img-thumb { height: 120px; background: repeating-conic-gradient(#F1F4FA 0% 25%, #fff 0% 50%) 50% / 16px 16px; display: grid; place-items: center; }
.img-thumb img { max-width: 100%; max-height: 120px; object-fit: contain; }
.img-card figcaption { padding: 8px 10px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.upload-drop { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 22px; border: 2px dashed #C9D3E6; border-radius: var(--radius); cursor: pointer; background: #FAFBFE; }
.upload-drop:hover { border-color: var(--accent); background: var(--accent-soft); }

/* test inbox */
.inbox-layout { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); gap: 18px; align-items: start; }
tr.picked td { background: var(--accent-soft) !important; }

/* bottom navigation (phones) */
.bottom-nav { display: none; }

@media (max-width: 1100px) {
  .inbox-layout { grid-template-columns: 1fr; }
  .flow-layout { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { padding-bottom: 68px; }
  h1 { font-size: 21px; }
  .topbar { gap: 8px; }
  .search { max-width: none; }
  .page-head { margin-bottom: 14px; }
  .page-head .actions { width: 100%; }
  .page-head .actions .btn { flex: 1 1 auto; }
  .panel-head, .panel-body { padding-left: 14px; padding-right: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { border-bottom: 1px solid var(--line-2); padding: 12px 14px; }
  .kpi .kpi-value { font-size: 19px; }
  .pnl { grid-template-columns: 1fr 1fr; border-radius: 16px; }
  .pnl > div { border-bottom: 1px solid rgba(255,255,255,.08); padding: 14px 16px 12px; }
  .pnl .v { font-size: 21px; } .pnl .hero .v { font-size: 30px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .tabs a { white-space: nowrap; }
  /* tables turn into cards */
  table.t.resp, table.t.resp tbody, table.t.resp tr, table.t.resp td { display: block; width: 100%; }
  table.t.resp thead { display: none; }
  table.t.resp tr { padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
  table.t.resp td { padding: 3px 0; border: 0; text-align: left !important; display: flex; justify-content: space-between; gap: 12px; }
  table.t.resp td[data-l]::before { content: attr(data-l); color: var(--muted); font-size: 12.5px; font-weight: 500; flex: none; }
  table.t.resp td:first-child { display: block; padding-bottom: 6px; }
  table.t.resp td:first-child::before { content: none; }
  table.t.resp td.right { justify-content: flex-start; flex-wrap: wrap; }
  .cal-cell { min-height: 64px; padding: 3px; }
  .cal-item { font-size: 10.5px; padding: 2px 4px; }
  .cal-item span { display: none; }
  .modal { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; align-self: end; }
  .overlay { padding: 0; place-items: end center; }
  .modal-foot { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line-2); }
  .modal-foot .btn { flex: 1; }
  .branches { gap: 16px; }
  .branch { min-width: 260px; }
  .node { width: 280px; }
  .toasts { bottom: 80px; }
  .bottom-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .bottom-nav a, .bottom-nav button { display: flex; flex-direction: column; align-items: center; gap: 2px; font: inherit; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; background: none; border: 0; padding: 4px 0; cursor: pointer; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .active { color: var(--accent-ink); }
  .sidebar-backdrop.open { display: block; }
}
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(4,18,46,.35); z-index: 45; }

/* ---------- sign-up forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.form-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; text-align: left; font: inherit; padding: 0; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.form-card:hover { border-color: #C9D3E6; box-shadow: var(--shadow-lg); text-decoration: none; transform: translateY(-1px); }
.form-card .meta { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 3px; }
.form-thumb { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: linear-gradient(180deg, #EEF2FA, #E3E9F5); border-bottom: 1px solid var(--line); }
.form-thumb iframe { position: absolute; top: 0; left: 0; width: 1200px; height: 750px; border: 0; transform-origin: 0 0; transform: scale(.22); pointer-events: none; }
.mini-stats { display: flex; gap: 14px; margin-top: 8px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.mini-stats b { color: var(--ink); font-weight: 700; font-size: 14px; margin-right: 2px; }
.tpl-pick { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 6px; }

.builder { display: grid; grid-template-columns: 400px 1fr; gap: 18px; align-items: start; }
.builder-side { position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.builder-side > .panel-body { overflow-y: auto; }
.builder-tabs { margin: 0; padding: 0 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.builder-tabs a { white-space: nowrap; padding: 13px 10px 11px; font-size: 13px; margin-bottom: 0; }
.builder-side details { border-top: 1px solid var(--line-2); padding: 10px 0; }
.builder-side summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.builder-side summary::after { content: '+'; color: var(--muted); font-size: 18px; font-weight: 400; }
.builder-side details[open] summary::after { content: '\2212'; }
.d-in { padding-top: 10px; }
.color-field input[type=color] { width: 38px; height: 38px; padding: 2px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); flex: none; cursor: pointer; }
.layout-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.layout-pick button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 6px 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.layout-pick button.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); color: var(--accent-ink); }
.lay-ic { position: relative; width: 46px; height: 32px; border-radius: 5px; background: var(--line-2); border: 1px solid var(--line); overflow: hidden; }
.lay-ic::after { content: ''; position: absolute; background: var(--accent); border-radius: 2px; }
.lay-ic.lay-popup::after { inset: 8px 12px; }
.lay-ic.lay-fullscreen::after { inset: 2px; }
.lay-ic.lay-flyout::after { right: 3px; bottom: 3px; width: 15px; height: 12px; }
.lay-ic.lay-bar::after { left: 0; right: 0; top: 0; height: 6px; border-radius: 0; }
.lay-ic.lay-drawer::after { right: 0; top: 0; bottom: 0; width: 14px; border-radius: 0; }
.lay-ic.lay-embed::after { left: 8px; right: 8px; top: 12px; height: 9px; }
.grad-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.grad-pick button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.grad-pick button.on { box-shadow: 0 0 0 2px var(--accent); }
.sub-card { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 8px; background: var(--canvas); }
.step-list { display: flex; flex-direction: column; gap: 6px; }
.step-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: var(--surface); }
.step-item.on { border-color: var(--accent); background: var(--accent-soft); }
.step-item .num { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 11.5px; font-weight: 700; flex: none; }
.step-item .grow { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; }
.step-item small { display: block; color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-item button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 2px 4px; border-radius: 4px; }
.step-item button:hover { background: var(--line-2); color: var(--ink); }
.rule-group { padding-bottom: 6px; margin-bottom: 14px; border-bottom: 1px solid var(--line-2); }
.rule-group > .label { display: block; margin-bottom: 10px; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.builder-main { min-width: 0; }
.stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.stage-bar .row { gap: 6px; flex-wrap: wrap; }
.stage-wrap { background: repeating-linear-gradient(45deg, #EDF1F8 0 10px, #F3F6FB 10px 20px); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; justify-content: center; }
.stage { --fw: 760px; position: relative; width: 100%; height: 640px; background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 20px 50px rgba(4, 18, 46, .14); transition: width .25s; }
.stage.dev-mobile { width: 390px; height: 720px; border-radius: 30px; border: 8px solid #0E1A33; }
.stage iframe { position: absolute; border: 0; background: transparent; }
.stage.lay-popup iframe, .stage.lay-fullscreen iframe { inset: 0; width: 100%; height: 100%; }
.stage.lay-flyout iframe { bottom: 16px; right: 16px; width: min(var(--fw), calc(100% - 32px)); height: 420px; border-radius: 18px; box-shadow: 0 18px 50px rgba(4, 18, 46, .25); }
.stage.lay-flyout.pos-bl iframe { right: auto; left: 16px; }
.stage.lay-bar iframe { left: 0; right: 0; top: 0; width: 100%; height: 72px; box-shadow: 0 4px 18px rgba(4, 18, 46, .18); }
.stage.lay-bar.pos-bottom iframe { top: auto; bottom: 0; }
.stage.lay-drawer iframe { top: 0; bottom: 0; right: 0; height: 100%; width: min(var(--fw), 100%); box-shadow: 0 0 50px rgba(4, 18, 46, .3); }
.stage.lay-drawer.pos-left iframe { right: auto; left: 0; }
.stage.lay-embed iframe { left: 50%; top: 170px; transform: translateX(-50%); width: min(var(--fw), calc(100% - 32px)); height: 420px; }
.stage.lay-embed .sm-hero { height: 110px; }
.site-mock { position: absolute; inset: 0; padding: 18px 22px; display: flex; flex-direction: column; gap: 18px; }
.sm-nav { display: flex; gap: 10px; align-items: center; }
.sm-nav span { height: 10px; border-radius: 5px; background: #E7ECF5; width: 60px; }
.sm-nav span:first-child { width: 90px; height: 16px; background: #0B1F4D; }
.sm-hero { height: 240px; border-radius: 14px; background: linear-gradient(135deg, #E9EEF8, #DCE5F5); }
.sm-row { display: flex; gap: 14px; }
.sm-row span { flex: 1; height: 110px; border-radius: 12px; background: #F1F4FA; }
.dev-mobile .sm-hero { height: 180px; }
.dev-mobile .sm-row { flex-direction: column; }

@media (max-width: 1100px) {
  .builder { grid-template-columns: 1fr; }
  .builder-side { position: static; max-height: none; order: 2; }
  .builder-main { order: 1; }
  .stage { height: 560px; }
}
@media (max-width: 640px) {
  .stage-wrap { padding: 8px; }
  .stage.dev-mobile { width: 100%; border-width: 5px; }
  .layout-pick { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- template gallery, pre-send check, dark preview ---------- */
.tpl-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.tpl-pickcard { display: flex !important; flex-direction: column; padding: 0 !important; overflow: hidden; text-align: left; }
.tpl-pickcard .tpl-thumb { height: 190px; position: relative; overflow: hidden; background: #EEF1F8; border-bottom: 1px solid var(--line); }
.tpl-pickcard .tpl-thumb iframe { position: absolute; top: 0; left: 0; width: 640px; height: 900px; border: 0; transform-origin: 0 0; pointer-events: none; }
.tpl-pickcard .meta { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.tpl-pickcard .meta span { color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.tpl-pickcard.on { border-color: var(--accent) !important; box-shadow: 0 0 0 3px var(--accent-soft); }
.html-thumb { display: grid; place-items: center; background: #0E1A33 !important; color: #8FB0FF; font-family: ui-monospace, monospace; font-size: 28px; font-weight: 700; }
.dark-sim { filter: invert(1) hue-rotate(180deg); background: #fff; }
.qa-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.qa-score { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.qa-score > div:last-child { display: flex; flex-direction: column; }
.ring { --p: 0; --c: var(--gain); width: 62px; height: 62px; border-radius: 50%; background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--line-2) 0); display: grid; place-items: center; flex: none; }
.ring.amber { --c: var(--warn); } .ring.red { --c: var(--loss); }
.ring span { width: 48px; height: 48px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-family: var(--head); font-weight: 700; font-size: 17px; }
.qa-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.qa-list li { display: flex; gap: 10px; padding: 8px 10px; border-radius: 9px; background: var(--canvas); }
.qa-list li > div { display: flex; flex-direction: column; min-width: 0; font-size: 13px; }
.qa-list li span:not(.qa-ic) { color: var(--muted); font-size: 12.5px; word-break: break-word; }
.qa-ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none; color: #fff; margin-top: 1px; }
.qa-list li.ok .qa-ic { background: var(--gain); } .qa-list li.warn .qa-ic { background: var(--warn); } .qa-list li.bad .qa-ic { background: var(--loss); }
.inbox-mock { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; margin-bottom: 10px; }
.inbox-mock.desk .ib-row { display: flex; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line-2); font-size: 13px; }
.ib-row .ib-from { width: 130px; flex: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-row.unread .ib-from { font-weight: 700; }
.ib-row .ib-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ib-row .ib-pre { color: var(--muted); }
.ib-row .ib-time { color: var(--muted); font-size: 12px; }
.ib-row.ghost .ib-from, .ib-row.ghost .ib-text { height: 9px; border-radius: 5px; background: var(--line-2); }
.inbox-mock.phone { max-width: 340px; border-radius: 18px; }
.ib-p { padding: 12px 16px; font-size: 14px; }
.ib-ps { font-weight: 600; margin-top: 2px; }
.ib-pp { color: var(--muted); font-size: 13px; line-height: 1.4; margin-top: 2px; }
.qa-dark { width: 100%; height: 340px; border: 1px solid var(--line); border-radius: 12px; }
@media (max-width: 900px) { .qa-wrap { grid-template-columns: 1fr; } }

/* ---------- home dashboard ---------- */
.quick-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.quick { display: flex; gap: 12px; align-items: center; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.quick:hover { border-color: #C9D3E6; box-shadow: var(--shadow-lg); text-decoration: none; }
.quick .qi { width: 38px; height: 38px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.quick .qi svg { width: 19px; height: 19px; }
.quick b { display: block; font-size: 14px; }
.quick small { color: var(--muted); font-size: 12.5px; }
.dash-hero { display: grid; grid-template-columns: 1fr 260px; background: radial-gradient(120% 160% at 0% 0%, #12306E 0%, #071A40 45%, var(--ink) 100%); border-radius: 20px; color: #fff; overflow: hidden; margin-bottom: 18px; box-shadow: 0 22px 50px rgba(4, 18, 46, .22); }
.dh-main { padding: 22px 24px 14px; min-width: 0; }
.dh-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; }
.dash-hero .k { font-size: 13px; color: #A9B4CF; }
.dash-hero .v { font-family: var(--head); font-size: 44px; font-weight: 600; letter-spacing: -0.03em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.dash-hero .d { font-size: 13px; font-weight: 600; } .dash-hero .d.up { color: #34D399; } .dash-hero .d.down { color: #FB7185; } .dash-hero .d.flat { color: #A9B4CF; }
.dh-split { display: flex; gap: 22px; flex-wrap: wrap; }
.dh-split > div { display: flex; flex-direction: column; font-size: 12.5px; color: #A9B4CF; }
.dh-split b { color: #fff; font-family: var(--head); font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.dh-split .sw { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.dh-empty { border: 1px dashed rgba(255, 255, 255, .2); border-radius: 12px; padding: 22px; color: #C6CFE3; font-size: 13.5px; max-width: 640px; }
.dash-chart { position: relative; }
.dash-chart svg { display: block; width: 100%; height: 200px; cursor: crosshair; }
.dash-axis { display: flex; justify-content: space-between; color: #7F8BA8; font-size: 11.5px; margin-top: 6px; }
.dash-tip { position: absolute; top: 4px; width: 150px; background: #fff; color: var(--ink); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); pointer-events: none; display: flex; flex-direction: column; gap: 2px; }
.dash-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.dh-today { background: rgba(255, 255, 255, .04); border-left: 1px solid rgba(255, 255, 255, .08); padding: 22px 20px; display: flex; flex-direction: column; }
.dh-today .k { margin-bottom: 8px; }
.dt-row { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: 1px solid rgba(255, 255, 255, .07); font-size: 13.5px; color: #C6CFE3; }
.dt-row b { color: #fff; font-family: var(--head); font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; text-align: right; }
.dt-row b small { display: block; font-family: var(--body); font-size: 11.5px; color: #8FE3C0; font-weight: 600; }
.dt-live { margin-top: auto; padding-top: 12px; font-size: 12.5px; color: #8FE3C0; display: flex; align-items: center; gap: 8px; }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: #34D399; box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: pulse 1.8s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 8px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }
.dash-kpis .kpi .spark { display: block; width: 100%; height: 26px; margin-top: 6px; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.dash-col { min-width: 0; }
.board { list-style: none; margin: 0; padding: 0; }
.board li { display: flex; gap: 14px; align-items: flex-start; padding: 14px 20px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.board li:last-child { border-bottom: 0; }
.board li:hover { background: var(--canvas); }
.board .rank { width: 26px; height: 26px; border-radius: 8px; background: var(--line-2); color: var(--ink-2); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.board li:first-child .rank { background: var(--ink); color: #fff; }
.board .grow { flex: 1; min-width: 0; }
.board-bar { height: 6px; border-radius: 3px; background: var(--line-2); margin: 8px 0; overflow: hidden; }
.board-bar span { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #4A7DFF, #5EEAD4); }
.board-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); align-items: center; }
.growth { display: flex; align-items: flex-end; gap: 2px; height: 120px; }
.gcol { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; gap: 1px; min-width: 2px; }
.gcol .gn { background: #4A7DFF; border-radius: 2px 2px 0 0; min-height: 0; }
.gcol .gu { background: #FB7185; border-radius: 0 0 2px 2px; }
.growth-net { font-family: var(--head); font-size: 22px; font-weight: 600; text-align: right; line-height: 1; }
.growth-net small { display: block; font-family: var(--body); font-size: 12px; color: var(--muted); font-weight: 500; }
.growth-net.up { color: var(--gain); } .growth-net.down { color: var(--loss); }
.health-badge { font-size: 12.5px; font-weight: 700; padding: 4px 10px; border-radius: 20px; }
.health-badge.good { background: var(--gain-soft); color: var(--gain); } .health-badge.warn { background: var(--warn-soft); color: var(--warn); } .health-badge.bad { background: var(--loss-soft); color: var(--loss); } .health-badge.muted { background: var(--line-2); color: var(--muted); }
.meter { margin-bottom: 14px; font-size: 13.5px; }
.meter .hint { font-size: 12px; }
.meter-track { position: relative; display: flex; height: 6px; border-radius: 3px; overflow: visible; margin: 7px 0 4px; }
.meter-track span { height: 100%; }
.meter-track .m-good { background: #BDE8D3; border-radius: 3px 0 0 3px; } .meter-track .m-warn { background: #F8DFA8; } .meter-track .m-bad { flex: 1; background: #F9C5C8; border-radius: 0 3px 3px 0; }
.meter-track i { position: absolute; top: -4px; width: 4px; height: 14px; border-radius: 2px; background: var(--ink); transform: translateX(-2px); }
.h-good { color: var(--gain); } .h-warn { color: var(--warn); } .h-bad { color: var(--loss); }
.outlook > div { display: flex; flex-direction: column; padding: 10px 12px; background: var(--canvas); border-radius: 10px; }
.outlook .k { font-size: 12px; color: var(--muted); }
.outlook b { font-family: var(--head); font-size: 20px; font-weight: 600; }
.risk-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; }
.risk-bar .r-low { background: #34D399; } .risk-bar .r-medium { background: #FBBF24; } .risk-bar .r-high { background: #FB7185; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 12px; align-items: center; padding: 10px 20px; border-bottom: 1px solid var(--line-2); font-size: 13.5px; cursor: pointer; }
.feed li:last-child { border-bottom: 0; }
.feed li:hover { background: var(--canvas); }
.feed .grow { flex: 1; min-width: 0; }
.feed .sub { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fi { width: 30px; height: 30px; border-radius: 50%; background: var(--line-2); color: var(--ink-2); display: grid; place-items: center; flex: none; }
.fi svg { width: 15px; height: 15px; }
.fi.money { background: var(--gain-soft); color: var(--gain); }
.up-row { display: flex; gap: 10px; margin-bottom: 10px; }
.up-row .cal { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.up-row .cal svg { width: 15px; height: 15px; }
@media (max-width: 1180px) { .dash-grid { grid-template-columns: 1fr; } .quick-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) { .dash-hero { grid-template-columns: 1fr; } .dh-today { border-left: 0; border-top: 1px solid rgba(255,255,255,.08); display: grid; grid-template-columns: 1fr 1fr; column-gap: 18px; } .dh-today .k, .dt-live { grid-column: 1 / -1; } }
@media (max-width: 640px) { .quick-row { grid-template-columns: 1fr 1fr; gap: 8px; } .quick small { display: none; } .quick { padding: 10px; } .dash-hero .v { font-size: 34px; } .dh-main { padding: 18px 16px 10px; } .dash-chart svg { height: 150px; } .board li, .feed li { padding: 12px 14px; } }
.dash-tip[hidden] { display: none; }
.growth-net { margin-left: auto; }
.who { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.av { width: 28px; height: 28px; border-radius: 50%; color: #fff; display: inline-grid; place-items: center; font-size: 11.5px; font-weight: 700; flex: none; letter-spacing: .02em; }

/* ---------- v6: channels ---------- */
.nav .count.unread { background: var(--accent-soft); color: var(--accent-ink); }
.big-num { font-family: var(--head); font-size: 30px; font-weight: 600; }
.sticky-col { position: sticky; top: 16px; }
.preview-phone { display: flex; justify-content: center; background: linear-gradient(180deg, #F3F6FC, #E9EEF8); border-radius: var(--radius); }
.preview-mini { margin-top: 14px; display: flex; justify-content: center; transform: scale(.82); transform-origin: top center; margin-bottom: -90px; }
.pm-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 12px 0; }
.pm-phone { position: relative; width: 280px; height: 520px; border-radius: 40px; background: #0B1220; padding: 10px; box-shadow: 0 24px 60px rgba(4, 18, 46, .28), inset 0 0 0 2px #2A3550; overflow: hidden; display: flex; flex-direction: column; }
.pm-phone > *:not(.pm-notch) { border-radius: 0; }
.pm-notch { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); width: 86px; height: 22px; border-radius: 12px; background: #000; z-index: 3; }
.pm-phone.sms, .pm-phone.wa { background: #0B1220; }
.pm-bar { background: #F6F7F9; border-radius: 30px 30px 0 0; padding: 44px 14px 10px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid #E3E7EE; }
.pm-bar b { display: block; font-size: 13px; color: #111; } .pm-bar span { font-size: 11px; color: #6B7280; }
.pm-av { width: 32px; height: 32px; border-radius: 50%; background: #9AA6BD; color: #fff; display: grid !important; place-items: center; font-weight: 700; font-size: 14px !important; }
.pm-chat { flex: 1; background: #fff; border-radius: 0 0 30px 30px; padding: 14px 12px; overflow-y: auto; display: flex; flex-direction: column; justify-content: flex-start; }
.pm-msg { align-self: flex-start; max-width: 86%; background: #E9E9EB; color: #111; border-radius: 18px 18px 18px 6px; padding: 9px 12px 18px; font-size: 13.5px; line-height: 1.38; position: relative; word-wrap: break-word; overflow-wrap: anywhere; }
.pm-msg img { display: block; width: 100%; border-radius: 12px; margin-bottom: 6px; }
.pm-msg u { color: #0A66D8; text-decoration: none; }
.pm-t { position: absolute; right: 10px; bottom: 4px; font-size: 10px; color: #8A8F98; }
.pm-empty { margin: auto; color: #9AA3B2; font-size: 13px; }
.pm-phone.wa .pm-bar { background: #075E54; border-bottom: 0; } .pm-phone.wa .pm-bar b { color: #fff; } .pm-phone.wa .pm-bar span { color: #CDE6E2; }
.pm-phone.wa .pm-av { background: #25D366; }
.pm-phone.wa .pm-chat { background: #ECE5DD radial-gradient(circle at 20% 20%, rgba(255,255,255,.35) 0 2px, transparent 3px) 0 0 / 22px 22px; }
.pm-phone.wa .pm-msg { background: #fff; border-radius: 4px 14px 14px 14px; box-shadow: 0 1px 1px rgba(0,0,0,.08); }
.pm-phone.wa .pm-msg u { color: #027EB5; }
.pm-phone.lock { background: linear-gradient(160deg, #1D3A8A 0%, #0B1F4D 45%, #04122E 100%); padding: 0; }
.pm-time { margin-top: 70px; text-align: center; color: #fff; font-family: var(--head); font-size: 54px; font-weight: 600; letter-spacing: -0.02em; }
.pm-date { text-align: center; color: rgba(255,255,255,.8); font-size: 13px; margin-top: -4px; }
.pm-notif { margin: 26px 12px 0; background: rgba(255,255,255,.82); backdrop-filter: blur(12px); border-radius: 18px; padding: 10px 12px 12px; color: #111; }
.pm-notif b { display: block; font-size: 13.5px; } .pm-notif p { margin: 2px 0 0; font-size: 13px; color: #333; line-height: 1.35; }
.pm-notif img { display: block; width: 100%; border-radius: 10px; margin-top: 8px; max-height: 120px; object-fit: cover; }
.pm-nh { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: #555; margin-bottom: 4px; }
.pm-nh span:nth-child(2) { flex: 1; }
.pm-ic { width: 18px; height: 18px; border-radius: 5px; background: #0B1F4D; color: #fff; display: grid; place-items: center; }
.pm-ic svg { width: 11px; height: 11px; }
.pm-desk { width: 300px; }
.pm-dn { display: flex; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; box-shadow: var(--shadow-lg); }
.pm-dn b { display: block; font-size: 13.5px; } .pm-dn p { margin: 2px 0 4px; font-size: 13px; color: var(--ink-2); }
.pm-dn .pm-ic { width: 32px; height: 32px; border-radius: 8px; flex: none; } .pm-dn .pm-ic svg { width: 16px; height: 16px; }
.text-editor .panel textarea { font-size: 15px; }
.setup-card h2 { margin-bottom: 10px; }
.steps-list { margin: 0; padding-left: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 14px; }
.steps-list li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr; column-gap: 12px; }
.steps-list li::before { content: counter(s); grid-row: span 2; width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.steps-list li span { color: var(--ink-2); font-size: 13.5px; }
.fi.ch-sms { background: var(--accent-soft); color: var(--accent-ink); } .fi.ch-whatsapp { background: #E3F8EC; color: #128C4B; } .fi.ch-instagram { background: #FDEAF2; color: #C13584; }
.fi.err { background: var(--loss-soft); color: var(--loss); }
.inbox-layout.convo { grid-template-columns: 340px 1fr; }
.threads { list-style: none; margin: 0; padding: 0; max-height: calc(100vh - 220px); overflow-y: auto; }
.threads li { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.threads li:hover { background: var(--canvas); } .threads li.picked { background: var(--accent-soft); }
.threads li.unread b { color: var(--ink); } .threads li .grow { min-width: 0; flex: 1; }
.threads .sub { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread { display: flex; flex-direction: column; min-height: 520px; }
.bubbles { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 320px); background: var(--canvas); }
.bubble { max-width: 72%; padding: 9px 13px; border-radius: 16px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.bubble span { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.bubble.in { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.out { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 5px; }
.bubble.out span { color: #A9B4CF; } .bubble.out u { color: #BFD0FF; }
.reply-box { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); align-items: flex-end; }
.reply-box textarea { flex: 1; min-height: 46px; max-height: 140px; }
.channel-rows .ch-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-2); }
.channel-rows .ch-row:last-child { border-bottom: 0; } .channel-rows .grow { flex: 1; min-width: 0; } .channel-rows .sub { display: block; font-size: 12px; color: var(--muted); }
.rule-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.rule-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.rule-card.paused { opacity: .7; }
.rule-card .sub { display: block; color: var(--muted); font-size: 12.5px; }
.rule-card .kw { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.rule-flow { display: flex; flex-direction: column; gap: 8px; border-left: 2px solid var(--line); padding-left: 12px; }
.rule-flow p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-2); }
.connect-row { margin-bottom: 16px; }
.connect { border: 1px dashed var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; background: var(--surface); }
.connect span { color: var(--muted); font-size: 13px; } .connect.on { border-style: solid; border-color: #BDE8D3; background: var(--gain-soft); } .connect.on span { color: var(--gain); }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.product-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; font: inherit; text-align: left; padding: 0; cursor: pointer; }
.product-card:hover { box-shadow: var(--shadow-lg); text-decoration: none; }
.product-card .pimg { position: relative; aspect-ratio: 4 / 3; background: linear-gradient(140deg, #0B1F4D, #2147C9); display: grid; place-items: center; overflow: hidden; }
.product-card .pimg img { width: 100%; height: 100%; object-fit: cover; }
.product-card .pimg > span:not(.pill) { color: #fff; font-family: var(--head); font-size: 28px; font-weight: 700; opacity: .9; }
.product-card .sale { position: absolute; top: 10px; left: 10px; }
.product-card .meta { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.product-card .price { font-family: var(--head); font-weight: 600; font-size: 17px; }
.product-grid.pick { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); max-height: 60vh; overflow-y: auto; }
.ticks { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 8px; }
.ticks li { padding-left: 24px; position: relative; font-size: 13.5px; color: var(--ink-2); }
.ticks li::before { content: ''; position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--gain-soft); box-shadow: inset 0 0 0 4px var(--gain); }
.callout.bad { background: var(--loss-soft); border-color: #F6C9CB; }
.bm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.bm-row { padding: 10px 0 12px; border-bottom: 1px solid var(--line-2); }
.bm-row:last-child { border-bottom: 0; }
.bm-bar { position: relative; height: 10px; border-radius: 5px; background: var(--line-2); margin: 10px 0 6px; }
.bm-range { position: absolute; top: 0; bottom: 0; background: #D7E2FB; border-radius: 5px; }
.bm-mid { position: absolute; top: -3px; width: 2px; height: 16px; background: var(--ink-2); transform: translateX(-1px); }
.bm-you { position: absolute; top: -5px; width: 20px; height: 20px; border-radius: 50%; transform: translateX(-10px); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(4,18,46,.25); background: var(--accent); }
.bm-you.ahead { background: var(--gain); } .bm-you.behind { background: var(--loss); }
.bm-meta { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.bm-meta details { font-size: 12px; } .bm-meta summary { cursor: pointer; color: var(--accent-ink); }
.bm-meta ul { margin: 6px 0 0; padding-left: 16px; } .bm-meta p { margin: 6px 0 0; }
.bm-legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--muted); margin: -6px 0 14px; flex-wrap: wrap; }
.bm-legend i { display: inline-block; vertical-align: middle; margin-right: 6px; }
.bm-range-key { width: 22px; height: 8px; border-radius: 4px; background: #D7E2FB; } .bm-mid-key { width: 2px; height: 12px; background: var(--ink-2); } .bm-you-key { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); }
@media (max-width: 900px) {
  .inbox-layout.convo { grid-template-columns: 1fr; }
  .threads { max-height: 320px; }
  .bm-grid { grid-template-columns: 1fr; }
  .sticky-col { position: static; }
}
@media (max-width: 640px) { .pm-phone { width: 250px; height: 470px; } .pm-time { font-size: 44px; } .bubble { max-width: 88%; } .rule-cards { grid-template-columns: 1fr; } }
.channel-rows .ch-row > .pill, .channel-rows .ch-row > .btn { flex: none; }
.channel-rows .grow b { display: block; white-space: nowrap; }
.channel-rows .sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-rows .ch-row .btn.sm { padding: 4px 8px; }
[data-pick] { margin-bottom: 14px; }
.inbox-layout.convo > * { min-width: 0; }
.threads li .row { min-width: 0; }
.threads li .ellipsis { max-width: 100%; display: block; }

/* ---------- phone menu fixes (iPhone Safari) ---------- */
@media (max-width: 760px) {
  /* Fit the visible screen (not 100vh, which is taller than the screen on iPhone), sit above the bottom bar, scroll on its own. */
  .sidebar { top: 0; bottom: 0; height: auto; max-height: 100dvh; z-index: 70; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y;
    padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(24px + env(safe-area-inset-bottom)); width: min(280px, 84vw); }
  .sidebar-backdrop { z-index: 65; }
  .sidebar-backdrop.open { touch-action: none; }
  html.menu-open, html.menu-open body { overflow: hidden; overscroll-behavior: none; }
  .bottom-nav a, .bottom-nav button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; min-height: 48px; justify-content: center; }
  .bottom-nav button * { pointer-events: none; }
  .bottom-nav button.active { color: var(--accent-ink); }
  .sidebar .nav a { padding: 11px 10px; }
}

/* ===== v7: AI designer + HTML paste ===== */
.aid { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: 16px; align-items: start; }
.aid > .panel { margin-bottom: 0; }
.aid-chat { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 560px; position: sticky; top: 12px; }
.aid-thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; overscroll-behavior: contain; }
.aid-msg { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.aid-msg.me { align-items: flex-end; }
.aid-msg .bubble { padding: 10px 13px; border-radius: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; max-width: 92%; }
.aid-msg.me .bubble { background: var(--ink); color: #fff; border-bottom-right-radius: 4px; }
.aid-msg.ai .bubble { background: var(--canvas); color: var(--ink-2); border-bottom-left-radius: 4px; }
.aid-meta { font-size: 12px; color: var(--muted); }
.aid-err { margin: 0; font-size: 13px; }
.aid-opts { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.aid-card { display: flex; flex-direction: column; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; cursor: pointer; text-align: left; font: inherit; color: inherit; transition: border-color .15s, box-shadow .15s; }
.aid-card:hover { border-color: #C9D5EE; }
.aid-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.aid-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.aid-thumb { height: 150px; overflow: hidden; position: relative; background: #EEF1F8; pointer-events: none; }
.aid-thumb iframe { position: absolute; top: 0; left: 0; width: 640px; height: 1100px; border: 0; transform-origin: 0 0; transform: scale(.19); }
.aid-card .meta { padding: 7px 9px 9px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.aid-card .meta b { font-size: 12.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aid-card .meta span { font-size: 11.5px; color: var(--muted); }
.aid-card.skel { cursor: default; }
.aid-card.skel .aid-thumb, .aid-card.skel .meta b, .aid-card.skel .meta span { background: linear-gradient(90deg, #EEF1F8 0%, #F7F9FD 50%, #EEF1F8 100%); background-size: 200% 100%; animation: aidShimmer 1.4s linear infinite; }
.aid-card.skel .meta b { height: 11px; width: 80%; border-radius: 4px; }
.aid-card.skel .meta span { height: 9px; width: 45%; border-radius: 4px; }
@keyframes aidShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.aid-composer { border-top: 1px solid var(--line); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
.aid-input { width: 100%; resize: vertical; min-height: 76px; font: inherit; }
.aid-start .aid-input { min-height: 110px; }
.aid-base { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 11px; border-radius: 9px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; }
.aid-base.off { background: var(--line-2); color: var(--ink-2); }
.aid-base button { border: 0; background: var(--surface); color: inherit; font: inherit; font-size: 12.5px; padding: 4px 9px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.aid-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-top: 4px; }
.aid-ctl { display: flex; flex-direction: column; gap: 3px; }
.aid-ctl > span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.aid-ctl .seg-ctl button { padding: 5px 10px; }
.aid-ctl .seg-ctl button:disabled { opacity: .4; cursor: not-allowed; }
.aid-go { margin-left: auto; }
.aid-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 4px; }
.aid-sugg { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 20px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.aid-sugg:hover { border-color: var(--accent); color: var(--accent-ink); }
.aid-hello { margin: auto 0; display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); }
.aid-hello span { color: var(--muted); }
.aid-canvas { min-height: 560px; display: flex; flex-direction: column; }
.aid-canvas-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 14px 16px 10px; flex-wrap: wrap; }
.aid-canvas-title { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.aid-canvas-title > b { font-family: var(--head); font-size: 16px; }
.aid-canvas-title span { font-size: 13px; color: var(--ink-2); }
.aid-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; border-bottom: 1px solid var(--line); }
.aid-frame-wrap { background: #EEF1F8; flex: 1; display: flex; justify-content: center; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.aid-frame { width: 100%; height: calc(100vh - 290px); min-height: 520px; border: 0; background: #fff; transition: width .2s; }
.aid-frame.mobile { width: 390px; max-width: 100%; }
.aid-empty { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted); padding: 40px 20px; }
.aid-empty svg { width: 30px; height: 30px; color: var(--accent); }
.aid-empty b { color: var(--ink); font-family: var(--head); }
.aid-chats { display: flex; flex-direction: column; }
.aid-chat-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--line-2); color: var(--ink); }
.aid-chat-row:hover { background: var(--canvas); text-decoration: none; }
.aid-chat-row span { color: var(--muted); font-size: 13px; text-align: right; }
.paste-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.paste-area { min-height: 320px !important; width: 100%; }
.paste-frame { width: 100%; height: 470px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.paste-info { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.paste-info .pill { white-space: normal; }
@media (max-width: 1000px) {
  .aid { grid-template-columns: 1fr; }
  .aid-chat { position: static; height: auto; min-height: 0; }
  .aid-thread { max-height: 62vh; }
  .aid-frame { height: 70vh; min-height: 420px; }
}
@media (max-width: 760px) {
  .paste-grid { grid-template-columns: 1fr; }
  .paste-area { min-height: 200px !important; }
  .paste-frame { height: 380px; }
  .aid-go { margin-left: 0; width: 100%; }
  .aid-chat-row { flex-direction: column; gap: 2px; }
  .aid-chat-row span { text-align: left; }
}
.ai-thumb { background: linear-gradient(160deg, #0B1F4D, #2F5FE0) !important; color: #fff; }
.ai-thumb svg { width: 40px; height: 40px; }
/* v7.1 footer settings */
.footer-set { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.footer-frame { width: 100%; height: 330px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #EEF1F8; }
@media (max-width: 900px) { .footer-set { grid-template-columns: 1fr; } }
.cells { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.cell-form { border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 8px 9px 2px; background: var(--canvas); min-width: 0; }
.cell-form .label { margin-bottom: 6px; }
@media (max-width: 1250px) { .cells { grid-template-columns: 1fr; } }
.preview-bar { flex-wrap: wrap; }
.preview-bar .subj { min-width: 220px; }
@media (max-width: 760px) { .preview-bar .subj { flex-basis: 100%; } .preview-bar > .row { flex-wrap: wrap; } }

/* ===== v8: Design Studio ===== */
.st-new { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.st-size, .st-starter { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font: inherit; color: var(--ink); text-align: left; }
.st-size:hover, .st-starter:hover { border-color: var(--accent); }
.st-size .st-shape { margin-bottom: 8px; }
.st-size span:last-child { color: var(--muted); font-size: 12.5px; }
.st-shape { display: block; background: linear-gradient(135deg, #0B1F4D, #4A7DFF); border-radius: 6px; margin-bottom: 6px; }
.st-shape.dashed { background: none; border: 2px dashed var(--line); width: 110px; height: 56px; }
.st-starter canvas { width: 100%; height: auto; border-radius: 6px; background: #EEF1F8; margin-bottom: 4px; }
.st-designs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.st-design { display: flex; flex-direction: column; gap: 3px; color: var(--ink); }
.st-design:hover { text-decoration: none; }
.st-design span { color: var(--muted); font-size: 12.5px; }
.st-thumb { aspect-ratio: 2 / 1; background: #EEF1F8; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; display: grid; place-items: center; margin-bottom: 4px; }
.st-thumb img { max-width: 100%; max-height: 100%; }
.studio { display: flex; flex-direction: column; gap: 10px; height: calc(100vh - 100px); min-height: 600px; }
.st-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.st-name { font-family: var(--head); font-weight: 600; font-size: 16px; border: 1px solid transparent; background: transparent; padding: 5px 8px; border-radius: 6px; min-width: 160px; flex: 1; max-width: 340px; }
.st-name:hover, .st-name:focus { border-color: var(--line); background: var(--surface); }
.st-top-group { display: flex; align-items: center; gap: 4px; }
.st-right { margin-left: auto; }
.st-zoom { min-width: 46px; text-align: center; font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.st-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 76px minmax(0, 1fr) 320px; gap: 10px; }
.st-tools { display: flex; flex-direction: column; gap: 6px; }
.st-tools button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 4px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.st-tools button:hover { border-color: var(--accent); color: var(--accent-ink); }
.st-ic { width: 26px; height: 26px; display: grid; place-items: center; font-family: Georgia, serif; font-size: 20px; font-weight: 700; color: var(--ink); }
.st-ic svg { width: 20px; height: 20px; }
.st-ic .sq { width: 18px; height: 14px; border: 2px solid currentColor; border-radius: 3px; }
.st-ic .ci { width: 18px; height: 18px; border: 2px solid currentColor; border-radius: 50%; }
.st-ic .ln { width: 20px; height: 2px; background: currentColor; transform: rotate(-30deg); }
.st-tools .st-ai, .btn.st-ai { color: #2F5FE0; }
.st-tools .st-ai { background: linear-gradient(180deg, #F3F6FF, #E6EDFF); border-color: #C9D6FF; }
.st-stage-wrap { background-color: #E6EAF2; background-image: radial-gradient(#CED5E3 1px, transparent 1px); background-size: 18px 18px; border-radius: var(--radius); overflow: auto; display: flex; padding: 20px; min-height: 0; }
.st-stage { position: relative; margin: auto; box-shadow: 0 6px 30px rgba(4, 18, 46, .14); line-height: 0; }
.st-stage canvas { display: block; touch-action: none; }
.st-inline { position: absolute; resize: none; border: 1px dashed #4A7DFF; background: rgba(255, 255, 255, .06); outline: none; padding: 0; margin: 0; overflow: hidden; transform-origin: center; white-space: pre-wrap; }
.st-side { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow-y: auto; min-height: 0; }
.st-tabs { width: 100%; margin-bottom: 12px; }
.st-tabs button { flex: 1; }
.st-side .field { margin-bottom: 10px; }
.st-side .field label { font-size: 12px; }
.st-side input[type=number], .st-side select, .st-side textarea { width: 100%; }
.st-sec { border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: 10px; }
.st-sec:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.st-sec > b { display: block; margin-bottom: 8px; font-family: var(--head); font-weight: 600; }
.st-sw { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.st-sw button { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(4, 18, 46, .15); cursor: pointer; padding: 0; }
.st-sw button.on { box-shadow: 0 0 0 2px #FFFFFF, 0 0 0 4px var(--accent); }
.st-sw input[type=color] { width: 30px; height: 26px; padding: 0 2px; border-radius: 6px; }
.st-range { display: flex; align-items: center; gap: 8px; }
.st-range input { flex: 1; }
.st-range span { min-width: 34px; text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.st-btns, .st-align, .st-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }
.st-presets button { border: 1px solid var(--line); background: var(--canvas); border-radius: 14px; padding: 4px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.st-presets button:hover { border-color: var(--accent); }
.st-det { margin: 6px 0 10px; }
.st-det summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.st-tips { margin: 0; padding-left: 18px; color: var(--ink-2); font-size: 13px; line-height: 1.6; }
.st-layers { display: flex; flex-direction: column; gap: 4px; }
.st-layer { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.st-layer.on { border-color: var(--accent); background: var(--accent-soft); }
.st-layer button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 2px 4px; border-radius: 4px; }
.st-layer button:hover { background: var(--line-2); color: var(--ink); }
.st-lname { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; overflow: hidden; }
.st-lname small { display: block; font-weight: 400; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.st-eye { color: var(--accent) !important; }
.st-frames { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.st-frame { position: relative; border: 2px solid var(--line); border-radius: 8px; padding: 0; background: #FFFFFF; cursor: pointer; line-height: 0; flex: none; }
.st-frame.on { border-color: var(--accent); }
.st-frame canvas { width: 120px; height: auto; border-radius: 6px; }
.st-frame span { position: absolute; left: 4px; top: 4px; background: var(--ink); color: #FFFFFF; font-size: 11px; line-height: 1; padding: 3px 5px; border-radius: 4px; }
.ai-img .ai-results { margin-top: 6px; }
.ai-wait { display: flex; align-items: center; gap: 10px; padding: 14px; background: var(--accent-soft); border-radius: var(--radius-sm); color: var(--accent-ink); }
.spin { width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.ai-card { border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: repeating-conic-gradient(#F1F3F8 0 25%, #FFFFFF 0 50%) 0 0 / 16px 16px; }
.ai-card img { display: block; width: 100%; height: auto; }
.ai-card .row { padding: 8px; gap: 6px; background: var(--surface); }
.gif-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; margin-top: 12px; max-height: 52vh; overflow-y: auto; }
.gif-card { position: relative; border: 1px solid var(--line); border-radius: 8px; padding: 0; background: #F4F6FB; cursor: pointer; overflow: hidden; line-height: 0; }
.gif-card img { width: 100%; height: 120px; object-fit: cover; }
.gif-card:hover, .gif-card:focus-visible { border-color: var(--accent); }
.gif-card .pill { position: absolute; right: 4px; top: 4px; line-height: 1.4; }
.giphy-attr { margin-top: 8px; text-align: right; font-size: 12px; font-weight: 700; color: var(--muted); }
@media (max-width: 1100px) {
  .studio { height: auto; }
  .st-main { grid-template-columns: 1fr; }
  .st-tools { flex-direction: row; overflow-x: auto; }
  .st-tools button { min-width: 70px; }
  .st-stage-wrap { height: auto; max-height: 70vh; padding: 16px; }
  .st-right { margin-left: 0; }
}

/* v8.1 flows: paths that meet again */
.branches.rejoin { padding-bottom: 22px; }
.branches.rejoin::before { }
.branches.rejoin > .branch::after { content: ''; position: absolute; bottom: -22px; left: 50%; width: 2px; height: 22px; background: #C9D3E6; transform: translateX(-1px); }
.branches.rejoin { border-bottom: 0; }
.merge-dot { position: relative; display: flex; justify-content: center; width: 100%; }
.merge-dot::before { content: ''; position: absolute; top: 0; left: 25%; right: 25%; height: 2px; background: #C9D3E6; }
.merge-dot span { position: relative; margin-top: 10px; font-size: 11.5px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); border-radius: 20px; padding: 3px 10px; }
.flow-cont { font-size: 11.5px; color: var(--muted); padding: 2px 8px; }
.branches.rejoin { align-items: stretch; }
.flow-fill { flex: 1; width: 2px; min-height: 6px; background: #C9D3E6; }
/* v8.2 link editor */
.link-ed { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface); }
.link-ed summary { cursor: pointer; display: flex; align-items: center; gap: 8px; }
.link-rows { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; max-height: 320px; overflow-y: auto; }
.link-row { display: flex; flex-direction: column; gap: 5px; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }
.link-row:last-child { border-bottom: 0; }
.link-what { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.link-what b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.link-row input { flex: 1; min-width: 0; }
/* v8.3 dark mode previews */
.dark-apple { background: #000 !important; }
.dark-note { margin: 8px 12px 10px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--canvas); font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.paste-stage { display: flex; justify-content: center; border-radius: var(--radius-sm); }
.paste-stage.dark-apple { padding: 10px 0; }
.paste-frame.mobile { width: 390px; max-width: 100%; }
.paste-frame.dark-sim { filter: invert(1) hue-rotate(180deg); }
.pv-stage { display: flex; justify-content: center; }
.pv-stage.dark-apple { padding: 12px 0; }
.img-row { display: grid; grid-template-columns: 56px 1fr; gap: 6px 10px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }
.img-row:last-child { border-bottom: 0; }
.img-row > .row { grid-column: 2; }
.img-mini { grid-row: span 2; width: 56px; height: 42px; border-radius: 6px; background: var(--canvas); border: 1px solid var(--line); overflow: hidden; display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.img-mini img { width: 100%; height: 100%; object-fit: cover; }
.img-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; min-width: 0; }
.img-meta b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paste-grid > div { min-width: 0; }
.seg-ctl button { white-space: nowrap; }

/* ---------- v9: AI assistant panel ---------- */
.ai-btn { margin-left: auto; gap: 6px; border-color: #C9D6FF; background: linear-gradient(180deg, #F4F7FF, #E9F0FF); color: var(--accent-ink); }
.ai-btn svg { color: var(--accent); }
.ai-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.ai-btn.on svg { color: #8FB0FF; }
.ai-btn + .user-menu { margin-left: 8px; }
.ai-panel { position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100vw; z-index: 60; background: var(--canvas); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(4, 18, 46, .10); display: flex; flex-direction: column; }
.ai-panel[hidden] { display: none; }
@media (min-width: 1280px) { html.ai-open .main { margin-right: 440px; } html.ai-open .ai-panel { box-shadow: none; } }
.aip-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px 12px 16px; background: #04122E; color: #fff; }
.aip-title { display: flex; align-items: center; gap: 10px; }
.aip-title svg { width: 22px; height: 22px; color: #8FB0FF; }
.aip-title b { font-family: var(--head); font-size: 15px; display: block; line-height: 1.2; }
.aip-title small { color: #A9B4CF; font-size: 12px; }
.aip-tools { display: flex; align-items: center; gap: 4px; }
.aip-tools select { background: rgba(255,255,255,.08); color: #fff; border: 1px solid rgba(255,255,255,.18); border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 13px; }
.aip-tools select option { color: var(--ink); }
.aip-icon { width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; color: inherit; cursor: pointer; display: grid; place-items: center; font-size: 22px; line-height: 1; }
.aip-icon svg { width: 17px; height: 17px; }
.aip-head .aip-icon:hover { background: rgba(255,255,255,.1); }
.aip-history { background: var(--surface); border-bottom: 1px solid var(--line); max-height: 45vh; overflow: auto; }
.aip-hrow { display: flex; align-items: center; border-bottom: 1px solid var(--line-2); padding-right: 6px; }
.aip-hrow .aip-icon { color: var(--muted); }
.aip-hopen { flex: 1; text-align: left; border: 0; background: none; font: inherit; padding: 10px 16px; cursor: pointer; color: var(--ink); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aip-hopen small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.aip-hopen:hover { background: var(--line-2); }
.aip-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.aip-empty { margin: auto 0; text-align: center; padding: 8px 6px 24px; }
.aip-empty > svg { width: 34px; height: 34px; color: var(--accent); }
.aip-empty h3 { font-size: 18px; margin: 8px 0 6px; }
.aip-empty p { color: var(--ink-2); margin: 0 auto 16px; max-width: 330px; }
.aip-sugg { display: grid; gap: 8px; text-align: left; }
.aip-sugg button { font: inherit; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; cursor: pointer; color: var(--ink); }
.aip-sugg button:hover { border-color: #C9D6FF; background: var(--accent-soft); }
.aip-tip { font-size: 12.5px; color: var(--warn) !important; margin-top: 14px !important; }
.aim { max-width: 92%; padding: 9px 13px; border-radius: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.aim.user { align-self: flex-end; background: var(--ink); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.aim.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.aim.bot p { margin: 0 0 6px; } .aim.bot p:last-child { margin: 0; }
.aim.bot ul { margin: 2px 0 6px; padding-left: 18px; }
.aim-acts { align-self: stretch; display: grid; gap: 4px; padding: 2px 4px; }
.aim-act { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; color: var(--muted); }
.aim-act svg { width: 14px; height: 14px; color: var(--gain); flex: none; margin-top: 2px; }
.aim-act.err { color: var(--warn); }
.aim-act.err::before { content: none; }
.aim-working { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.aim-working .btn { margin-left: auto; }
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: aidot 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes aidot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.aic { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.aic small { display: block; color: var(--muted); font-size: 12.5px; }
.aic-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.aic-top b { display: block; line-height: 1.3; }
.aic-frame { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #EEF1F8; position: relative; height: 520px; }
.aic-frame.mob { width: 260px; margin: 0 auto; border-radius: 22px; border: 6px solid #04122E; }
.aic-frame iframe { border: 0; display: block; transform-origin: 0 0; background: #fff; }
.aic-loading { padding: 20px; font-size: 13px; }
.aic-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.aic-row { display: flex; align-items: center; gap: 10px; }
.aic-row > svg { width: 20px; height: 20px; color: var(--accent); flex: none; }
.aic-row > div { flex: 1; min-width: 0; }
.aic-img img { width: 100%; border-radius: 10px; display: block; }
.aic-dl { display: grid; grid-template-columns: 92px 1fr; gap: 6px 10px; margin: 12px 0 0; font-size: 13px; }
.aic-dl dt { color: var(--muted); } .aic-dl dd { margin: 0; overflow-wrap: anywhere; }
.aic-dl .chip { padding: 2px 9px; font-size: 12px; margin: 0 2px 2px 0; }
.aic-warn { margin: 10px 0 0; padding: 8px 10px 8px 26px; background: var(--warn-soft); color: var(--warn); border-radius: 10px; font-size: 12.5px; }
.aic-ok { margin: 10px 0 0; padding: 8px 10px; background: var(--gain-soft); color: var(--gain); border-radius: 10px; font-size: 12.5px; font-weight: 600; }
.aip-compose { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.aip-compose textarea { flex: 1; resize: none; font: inherit; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; max-height: 160px; min-height: 44px; background: var(--canvas); }
.aip-compose textarea:focus { outline: none; border-color: var(--accent); background: #fff; }
.aip-compose .btn { min-height: 44px; width: 44px; padding: 0; }
.aip-fullbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.aip-fullbar > div:first-child { flex: 1; min-width: 200px; } .aip-fullbar b { display: block; }
.aip-fullwrap { background: #EEF1F8; border-radius: 12px; padding: 16px; overflow: auto; text-align: center; }
.aip-fullwrap iframe { border: 0; height: 70vh; max-width: 100%; background: #fff; border-radius: 8px; transition: width .2s; }
@media (max-width: 760px) {
  .ai-btn span { display: none; }
  .aip-title small { display: none; }
  .ai-btn { padding: 0; width: 36px; }
  .ai-panel { width: 100vw; border-left: 0; }
  html.ai-open, html.ai-open body { overflow: hidden; }
  .aic-frame { height: 440px; }
}

/* ---------- v10: WhatsApp tab ---------- */
:root { --wa-green: #128C7E; --wa-out: #D9FDD3; --wa-bg: #EFEAE2; --wa-in: #FFFFFF; }
.wa-top .page-head { margin-bottom: 10px; }
.wa-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 18px; overflow-x: auto; scrollbar-width: none; }
.wa-tabs a { padding: 9px 14px; font-weight: 600; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; }
.wa-tabs a:hover { color: var(--ink); text-decoration: none; }
.wa-tabs a.on { color: var(--ink); border-bottom-color: var(--wa-green); }
.wa-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 16px; }
.wa-kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.wa-kpi span { color: var(--muted); font-size: 13px; font-weight: 600; }
.wa-kpi b { font-family: var(--head); font-size: 26px; font-variant-numeric: tabular-nums; }
.wa-kpi small { color: var(--muted); font-size: 12px; }
.wa-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.wa-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.wa-chip { display: flex; flex-direction: column; padding: 10px 14px; border-radius: 12px; background: var(--line-2); min-width: 120px; color: var(--ink); text-decoration: none; }
.wa-chip:hover { text-decoration: none; background: var(--accent-soft); }
.wa-chip b { font-family: var(--head); font-size: 22px; }
.wa-chip span { font-size: 12.5px; color: var(--ink-2); }
.wa-chip.amber { background: var(--warn-soft); } .wa-chip.blue { background: var(--accent-soft); }
.wa-steps { list-style: none; margin: 0; padding: 0; }
.wa-steps li { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.wa-steps li:last-child { border-bottom: 0; }
.wa-steps li small { margin-left: auto; color: var(--muted); }
.wa-tick { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; flex: none; font-weight: 700; color: var(--warn); }
.wa-steps li.done .wa-tick { background: var(--gain); border-color: var(--gain); color: #fff; }
.wa-tick svg { width: 13px; height: 13px; }
.wa-edit { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.wa-side .sticky { position: sticky; top: 76px; }
.wa-phone { width: 320px; max-width: 100%; margin: 0 auto 10px; border-radius: 30px; border: 8px solid #04122E; overflow: hidden; background: var(--wa-bg); box-shadow: var(--shadow-lg); }
.wa-ph-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #075E54; color: #fff; }
.wa-ph-bar b { display: block; font-size: 14px; } .wa-ph-bar span { font-size: 11px; opacity: .8; }
.wa-av { width: 34px; height: 34px; border-radius: 50%; background: #DCE3F0; color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.wa-ph-bar .wa-av { background: #fff; color: #075E54; }
.wa-av.web { background: var(--accent-soft); color: var(--accent-ink); }
.wa-av.big { width: 56px; height: 56px; font-size: 20px; }
.wa-ph-chat { min-height: 360px; padding: 14px 10px; }
.wb { background: var(--wa-in); border-radius: 0 10px 10px 10px; max-width: 92%; box-shadow: 0 1px 1px rgba(0,0,0,.08); overflow: hidden; position: relative; font-size: 14px; }
.wb-img { height: 150px; background: #CFD8E6 center/cover no-repeat; display: grid; place-items: center; color: var(--muted); font-size: 12px; text-transform: capitalize; }
.wb-ht { font-weight: 700; padding: 8px 10px 0; }
.wb-body { padding: 8px 10px 4px; line-height: 1.45; overflow-wrap: anywhere; }
.wb-body mark { background: #FFF3C4; padding: 0 2px; border-radius: 3px; } .wb-body mark.v { background: #FDE2E2; }
.wb-foot { padding: 0 10px 2px; font-size: 12px; color: #8696A0; }
.wb-time { text-align: right; font-size: 11px; color: #8696A0; padding: 0 8px 6px; }
.wb-btns { max-width: 92%; display: grid; gap: 4px; margin-top: 4px; }
.wb-btn { background: #fff; border-radius: 8px; padding: 8px; text-align: center; color: #027EB5; font-weight: 600; font-size: 13.5px; box-shadow: 0 1px 1px rgba(0,0,0,.08); display: flex; align-items: center; justify-content: center; gap: 6px; }
.wb-btn svg { width: 14px; height: 14px; }
.wa-fun { display: grid; grid-template-columns: 90px 1fr 70px 80px; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 13.5px; }
.wa-fun > div { height: 12px; background: var(--line-2); border-radius: 6px; overflow: hidden; }
.wa-fun i { display: block; height: 100%; border-radius: 6px; }
.wa-fun b { text-align: right; font-variant-numeric: tabular-nums; } .wa-fun small { color: var(--muted); }
.wa-fun .g0 { background: #B8C4DC; } .wa-fun .g1 { background: #7E9BE0; } .wa-fun .g2 { background: #4A7DFF; } .wa-fun .g3 { background: #2F5FE0; } .wa-fun .g4 { background: var(--gain); } .wa-fun .g5 { background: var(--loss); }
.wa-rt { display: flex; flex-wrap: wrap; gap: 8px; }
.wa-tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; margin-bottom: 16px; }
.wa-tpl { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--ink); display: flex; flex-direction: column; gap: 8px; text-decoration: none; }
a.wa-tpl:hover { border-color: #C9D6FF; text-decoration: none; box-shadow: var(--shadow); }
.wa-tpl-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.wa-tpl-h b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-tpl-meta { display: flex; flex-wrap: wrap; gap: 4px; }
.wa-tpl p { margin: 0; color: var(--ink-2); font-size: 13px; white-space: pre-line; }
.wa-tpl-f { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12.5px; color: var(--muted); margin-top: auto; align-items: center; }
.wa-rej { background: var(--loss-soft); color: var(--loss); border-radius: 8px; padding: 6px 10px; font-size: 12.5px; }
.wa-cmp th .sub { display: block; font-weight: 400; color: var(--muted); }
.wa-times { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.wa-times div { background: var(--line-2); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.wa-times span { color: var(--gain); font-weight: 600; font-size: 13px; } .wa-times small { color: var(--muted); }
.wa-set { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
.wa-set-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 76px; }
.wa-set-nav a { padding: 8px 12px; border-radius: 8px; color: var(--ink-2); font-weight: 600; text-decoration: none; }
.wa-set-nav a.on, .wa-set-nav a:hover { background: var(--surface); color: var(--ink); text-decoration: none; box-shadow: var(--shadow); }
.wa-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.wa-status .seg-ctl button { text-transform: capitalize; }
/* inbox */
.wa-inbox { display: grid; grid-template-columns: 320px minmax(0, 1fr) 290px; height: calc(100vh - 210px); min-height: 520px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.wa-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.wa-list-h { padding: 10px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.wa-list-h input, .wa-list-h select { width: 100%; min-width: 0; }
.wa-views { display: flex; flex-wrap: wrap; gap: 4px; }
.wa-views button { font: inherit; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); background: var(--surface); border-radius: 20px; padding: 3px 10px; cursor: pointer; color: var(--ink-2); }
.wa-views button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
#items { overflow-y: auto; flex: 1; }
.wa-item { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); color: var(--ink); text-decoration: none; position: relative; }
.wa-item:hover { background: var(--line-2); text-decoration: none; }
.wa-item.on { background: var(--accent-soft); }
.wa-item-m { flex: 1; min-width: 0; }
.wa-item-t { display: flex; justify-content: space-between; gap: 6px; } .wa-item-t b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .wa-item-t small { color: var(--muted); flex: none; }
.wa-item-l { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-item.unread .wa-item-l { color: var(--ink); font-weight: 600; }
.wa-item-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; } .wa-item-tags .pill, .wa-item-tags .tag { font-size: 11px; padding: 1px 6px; }
.wa-badge { position: absolute; right: 12px; bottom: 12px; background: var(--wa-green); color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.wa-chat { display: flex; flex-direction: column; min-height: 0; background: var(--wa-bg); }
.wa-chat-h { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.wa-chat-h .grow { min-width: 120px; } .wa-chat-h b { display: block; } .wa-chat-h small { color: var(--muted); font-size: 12px; }
.wa-chat-h select { max-width: 160px; font-size: 13px; }
.wa-back { display: none; }
.wa-more { position: relative; } .wa-more .menu { right: 0; top: 36px; }
.wa-sum { background: #FFF9E6; border-bottom: 1px solid #F3E3B3; padding: 8px 14px; font-size: 13px; } .wa-sum b { display: block; }
.wa-msgs { flex: 1; overflow-y: auto; padding: 14px 18px; display: flex; flex-direction: column; gap: 4px; }
.wa-msg { display: flex; } .wa-msg.out { justify-content: flex-end; }
.wa-bub { max-width: 72%; padding: 6px 9px 4px; border-radius: 8px; font-size: 14px; line-height: 1.45; box-shadow: 0 1px 1px rgba(0,0,0,.08); overflow-wrap: anywhere; position: relative; }
.wa-bub.in { background: var(--wa-in); border-top-left-radius: 0; } .wa-bub.out { background: var(--wa-out); border-top-right-radius: 0; }
.wa-who { display: block; font-size: 11.5px; font-weight: 700; color: var(--wa-green); }
.wa-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 11px; color: #667781; margin-top: 2px; }
.wa-tk { font-size: 11px; letter-spacing: -2px; color: #8696A0; } .wa-tk.read { color: #53BDEB; } .wa-tk.fail { color: var(--loss); font-weight: 700; letter-spacing: 0; }
.wa-fail { display: block; font-size: 11.5px; color: var(--loss); }
.wa-tr { border: 0; background: none; color: #027EB5; font: inherit; font-size: 11px; cursor: pointer; padding: 0 4px 0 0; }
.wa-trans { margin-top: 4px; padding-top: 4px; border-top: 1px dashed #CBD5E1; color: var(--ink-2); font-style: italic; }
.wa-ref { font-size: 11.5px; background: var(--accent-soft); color: var(--accent-ink); border-radius: 6px; padding: 2px 6px; margin-bottom: 4px; }
.wa-media { max-width: 260px; max-height: 260px; border-radius: 6px; display: block; margin-bottom: 4px; }
.wa-sys { align-self: center; background: rgba(255,255,255,.85); color: #54656F; font-size: 12px; border-radius: 8px; padding: 3px 10px; margin: 4px 0; text-align: center; }
.wa-sys small, .wa-note small { color: #8696A0; margin-left: 4px; }
.wa-day { align-self: center; background: #E1F2FB; color: #54656F; font-size: 11.5px; border-radius: 8px; padding: 2px 10px; margin: 8px 0; }
.wa-note { align-self: flex-end; max-width: 72%; background: #FFF4C2; border: 1px dashed #E7C85A; border-radius: 8px; padding: 6px 10px; font-size: 13.5px; } .wa-note b { display: block; font-size: 11.5px; color: #8A6A00; }
.wa-comp { background: var(--surface); border-top: 1px solid var(--line); padding: 8px 12px; position: relative; }
.wa-comp.note textarea { background: #FFFBEA; border-color: #E7C85A; }
.wa-comp textarea { width: 100%; resize: vertical; min-height: 44px; max-height: 200px; font: inherit; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.wa-comp-tabs { display: flex; gap: 4px; align-items: center; margin-bottom: 6px; } .wa-comp-tabs .hint { margin-left: auto; }
.wa-comp-tabs button { border: 0; background: none; font: inherit; font-weight: 600; font-size: 13px; color: var(--muted); padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.wa-comp-tabs button.on { background: var(--line-2); color: var(--ink); }
.wa-comp-b { display: flex; gap: 4px; align-items: center; margin-top: 6px; } .wa-comp-b .grow { flex: 1; }
.wa-closed { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 8px 10px; font-size: 13px; margin-bottom: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; } .wa-closed svg { width: 16px; height: 16px; }
.wa-qr { position: absolute; bottom: 100%; left: 12px; right: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 280px; overflow-y: auto; z-index: 5; }
.wa-qr button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; font: inherit; cursor: pointer; border-bottom: 1px solid var(--line-2); }
.wa-qr button span { display: block; color: var(--muted); font-size: 12.5px; } .wa-qr button.on, .wa-qr button:hover { background: var(--accent-soft); }
.wa-prof { border-left: 1px solid var(--line); overflow-y: auto; padding: 14px; font-size: 13.5px; }
.wa-prof h4 { margin: 14px 0 6px; font-size: 12px; text-transform: none; color: var(--muted); }
.wa-pcard { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; } .wa-pcard small { color: var(--muted); overflow-wrap: anywhere; }
.wa-dl { display: grid; grid-template-columns: 90px 1fr; gap: 4px 8px; margin: 14px 0 0; } .wa-dl dt { color: var(--muted); } .wa-dl dd { margin: 0; overflow-wrap: anywhere; }
.wa-tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; } .wa-tags .chip { font-size: 12px; padding: 2px 4px 2px 8px; } .wa-tags input { width: 90px; font-size: 12.5px; padding: 3px 6px; }
.wa-tasks, .wa-ev { list-style: none; margin: 0; padding: 0; }
.wa-tasks li, .wa-ev li { display: flex; justify-content: space-between; gap: 6px; padding: 4px 0; border-bottom: 1px solid var(--line-2); } .wa-tasks li.done { opacity: .55; text-decoration: line-through; }
.wa-tasks small, .wa-ev small { color: var(--muted); flex: none; }
.wa-pnote { background: #FFF9E6; border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; } .wa-pnote small { display: block; color: var(--muted); }
.wa-empty { margin: auto; text-align: center; color: var(--muted); padding: 30px; } .wa-empty svg { width: 34px; height: 34px; color: var(--wa-green); } .wa-empty.small { padding: 20px; }
.wa-pick { display: grid; gap: 4px; margin-top: 6px; max-height: 220px; overflow-y: auto; }
.wa-pick button { text-align: left; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 6px 10px; font: inherit; cursor: pointer; } .wa-pick button span { display: block; color: var(--muted); font-size: 12px; }
.wa-pick button.on { border-color: var(--accent); background: var(--accent-soft); }
.small { font-size: 12.5px; } td.red, .red { color: var(--loss); }
/* chatbot builder */
.wa-node { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; }
.wa-node.start { border-color: #B9CCFF; box-shadow: 0 0 0 3px var(--accent-soft); }
.wa-node-h { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line-2); }
.wa-node-ic { width: 28px; height: 28px; border-radius: 8px; background: #E7F6F3; color: var(--wa-green); display: grid; place-items: center; flex: none; } .wa-node-ic svg { width: 16px; height: 16px; }
.wa-node-l { border: 0; font-weight: 700; font-size: 14px; background: transparent; padding: 4px; min-width: 0; flex: 1; max-width: 300px; }
.wa-node-l:focus { background: var(--line-2); outline: none; border-radius: 6px; }
.wa-node-h .grow { flex: 1; }
.wa-node-b { padding: 12px 14px; } .wa-node-b textarea { width: 100%; }
.wa-btnrow { margin-bottom: 6px; } .wa-btnrow input { min-width: 0; flex: 1; } .wa-btnrow select { max-width: 200px; }
.wa-go select { width: 100%; }
.wa-add { margin: 0 0 16px; } .wa-add select { width: 100%; padding: 10px; border-style: dashed; }
.wa-sim .wa-phone { width: 320px; } .wa-sim-msgs { height: 380px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; padding: 6px 2px; }
.wa-sim-msgs .wa-bub { max-width: 85%; font-size: 13.5px; }
.wa-sim-in { display: flex; gap: 6px; } .wa-sim-in input { flex: 1; min-width: 0; }
.wa-sim-opts { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-start; margin: 2px 0 6px; }
.wa-sim-opts button { background: #fff; border: 0; border-radius: 16px; padding: 5px 12px; color: #027EB5; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; box-shadow: 0 1px 1px rgba(0,0,0,.1); }
.wa-map { overflow: auto; background: var(--canvas); border-radius: 10px; }
.wa-map-n rect { fill: #fff; stroke: #CBD5E8; stroke-width: 1.5; } .wa-map-n { cursor: pointer; } .wa-map-n:hover rect, .wa-map-n:focus rect { stroke: var(--accent); }
.wa-map-n.start rect { stroke: var(--accent); stroke-width: 2.5; } .wa-map-n.agent rect { fill: #E7F6F3; stroke: var(--wa-green); }
.wa-map-n .t { font: 700 13px var(--body); fill: var(--ink); } .wa-map-n .s { font: 12px var(--body); fill: var(--muted); }
.wa-map-l { font: 11px var(--body); fill: var(--muted); text-anchor: middle; }
@media (max-width: 1280px) { .wa-inbox { grid-template-columns: 290px minmax(0, 1fr); } .wa-prof { display: none; } .wa-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1000px) { .wa-edit { grid-template-columns: 1fr; } .wa-side .sticky { position: static; } .wa-grid2 { grid-template-columns: 1fr; } .wa-set { grid-template-columns: 1fr; } .wa-set-nav { flex-direction: row; overflow-x: auto; position: static; } }
@media (max-width: 760px) {
  .wa-inbox { grid-template-columns: 1fr; height: calc(100vh - 230px); }
  .wa-inbox .wa-chat { display: none; } .wa-inbox.has-chat .wa-list { display: none; } .wa-inbox.has-chat .wa-chat { display: flex; }
  .wa-back { display: inline-flex; } .wa-chat-h select { max-width: 120px; }
  .wa-kpis { grid-template-columns: repeat(2, 1fr); } .wa-bub, .wa-note { max-width: 88%; }
  .wa-fun { grid-template-columns: 76px 1fr 50px; } .wa-fun small { display: none; }
  .wa-status span { display: none; }
}
.seg-ctl a { padding: 5px 12px; border-radius: 5px; color: var(--ink-2); font-weight: 500; text-decoration: none; }
.seg-ctl a.on { background: var(--ink); color: #fff; } .seg-ctl a:hover { text-decoration: none; }
.wa-prof .row input { flex: 1; min-width: 0; }
.wa-prof .row { flex-wrap: nowrap; }
.wa-inbox > * { min-width: 0; }
@media (max-width: 760px) { .wa-chat-h { gap: 6px; } .wa-chat-h select { flex: 1 1 40%; max-width: none; } .wa-chat-h .grow { flex: 1 1 60%; } .wa-msgs { padding: 10px; } .wa-media { max-width: 100%; } }

/* ---------- AI assistant: attachments and voice ---------- */
.aip-compose .aip-icon { color: var(--muted); height: 44px; flex: none; }
.aip-compose .aip-icon:hover { background: var(--canvas); color: var(--ink); }
.aip-mic.on { color: #fff !important; background: #E5484D !important; animation: aipPulse 1.2s ease-in-out infinite; }
@keyframes aipPulse { 50% { box-shadow: 0 0 0 6px rgba(229,72,77,.18); } }
@media (prefers-reduced-motion: reduce) { .aip-mic.on { animation: none; } }
#aipVoice.on { background: #4A7DFF; color: #fff; }
#aipLang { padding: 5px 4px; width: 50px; }
.aip-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; background: var(--surface); border-top: 1px solid var(--line); }
.aip-files + .aip-compose { border-top: 0; }
.aip-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 220px; padding: 4px 6px 4px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--canvas); font-size: 12.5px; color: var(--ink); }
.aip-chip img, .aip-chip svg { width: 28px; height: 28px; border-radius: 6px; object-fit: cover; flex: none; }
.aip-chip svg { padding: 5px; background: #E9EEFB; color: #4A7DFF; }
.aip-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aip-chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; }
.aip-chip.up { opacity: .7; }
.aip-chip .spin { width: 12px; height: 12px; border: 2px solid #C9D4EE; border-top-color: #4A7DFF; border-radius: 50%; animation: aipSpin .8s linear infinite; flex: none; }
@keyframes aipSpin { to { transform: rotate(360deg); } }
.aim.user .aim-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; white-space: normal; }
.aim.user .aip-chip { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); color: #fff; }
.ai-panel.drop { outline: 2px dashed #4A7DFF; outline-offset: -8px; }

/* Start-up screen (never a blank page) */
.boot-wait { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; text-align: center; padding: 24px; color: var(--ink); }
.boot-wait p { margin: 0; color: var(--muted); line-height: 1.6; max-width: 360px; }
.boot-wait b { color: var(--ink); }
.auth-side .brand-mark { width: 48px; height: 48px; border-radius: 12px; padding: 4px; }
.wa-av.logo { background: #fff; padding: 2px; }
.wa-av.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* Website chat name and photo for agents */
.chat-ph{width:36px;height:36px;border-radius:50%;border:1px dashed var(--line,#D5DBE7);background:var(--soft,#EEF2FB);color:var(--accent,#4A7DFF);font-weight:700;cursor:pointer;padding:0;overflow:hidden;flex-shrink:0;display:grid;place-items:center}
.chat-ph img{width:100%;height:100%;object-fit:cover}.chat-ph.lg{width:64px;height:64px;font-size:22px}
.chat-ph-sm{width:20px;height:20px;border-radius:50%;object-fit:cover;margin-right:6px;vertical-align:middle}
/* ---------- Inbox on phones ---------- */
.menu { z-index: 60; }
.wa-chat-h { position: relative; z-index: 6; }
.wa-ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.wa-info, .mob-only { display: none !important; }
.wa-who-t { min-width: 0; }
.wa-who-t small .pill { margin-left: 4px; }
.wa-comp textarea { resize: none; }
.wa-prof.sheet { display: block; border: 0; padding: 0; overflow: visible; }
@media (max-width: 1280px) { .wa-info { display: inline-flex !important; } }
@media (max-width: 760px) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { font-size: 16px !important; }
  .mob-only { display: block !important; }
  .wa-ctl { display: none; }
  html.wa-full, html.wa-full body { overflow: hidden; overscroll-behavior: none; }
  html.wa-full .wa-inbox.has-chat { position: fixed; left: 0; right: 0; top: var(--vvt, 0px); height: var(--vvh, 100dvh); min-height: 0; z-index: 80; border: 0; border-radius: 0; }
  html.wa-full .bottom-nav { display: none; }
  .wa-chat-h { flex-wrap: nowrap; gap: 6px; padding: max(8px, env(safe-area-inset-top)) 6px 8px; }
  .wa-chat-h .wa-av { width: 36px; height: 36px; flex-shrink: 0; }
  .wa-who-t { flex: 1 1 auto; }
  .wa-who-t b, .wa-who-t small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .wa-who-t b { font-size: 15px; }
  .wa-chat-h .btn.sm { min-width: 38px; min-height: 38px; padding: 0 8px; justify-content: center; }
  .wa-more .menu { top: 44px; right: 0; min-width: 250px; }
  .wa-more .menu button, .wa-more .menu a { padding: 13px 12px; font-size: 15px; display: block; }
  .wa-msgs { padding: 10px 8px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
  .wa-bub { font-size: 15px; }
  .wa-comp { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  .wa-comp-tabs { margin-bottom: 4px; } .wa-comp-tabs button { font-size: 12.5px; padding: 3px 9px; }
  .wa-comp textarea { min-height: 42px; max-height: 130px; border-radius: 20px; padding: 9px 14px; line-height: 1.35; }
  .wa-comp-b { margin-top: 4px; gap: 2px; } .wa-comp-b .lbl { display: none; }
  .wa-comp-b .btn { min-width: 40px; min-height: 40px; justify-content: center; }
  .wa-comp-b #sendB { padding: 0 18px; border-radius: 20px; }
  .wa-closed { font-size: 13px; }
  .wa-prof.sheet { font-size: 15px; }
}
.menu a { display: block; padding: 8px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
.menu a:hover { background: var(--line-2); text-decoration: none; }
.wa-chat-h { flex-wrap: nowrap; }
.wa-chat-h .wa-who-t { flex: 1 1 auto; }
.wa-chat-h .wa-who-t b, .wa-chat-h .wa-who-t small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wa-ctl { flex-wrap: nowrap; flex-shrink: 0; } .wa-ctl select { max-width: 150px; }
.kb-pick { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 10px; }
.kb-it { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line-2); cursor: pointer; align-items: flex-start; }
.kb-it:last-child { border-bottom: 0; } .kb-it input { margin-top: 3px; flex-shrink: 0; }
.kb-it b { display: block; font-size: 14px; } .kb-it span span { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 2px; white-space: pre-wrap; }
