:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --surface-2: #f1f1f4;
  --border: #e3e3e8;
  --border-strong: #cfcfd8;
  --text: #1b1b22;
  --muted: #676776;
  --accent: #5b5bd6;
  --accent-ink: #ffffff;
  --accent-soft: #ececfc;
  --ok: #18794e;
  --ok-soft: #e6f6ee;
  --warn: #a35200;
  --warn-soft: #fff3e0;
  --danger: #c4314b;
  --danger-soft: #fdecef;
  --ig: #d6287a;
  --fb: #1877f2;
  --tt: #111111;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .06), 0 4px 16px rgba(20, 20, 40, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111116;
    --surface: #1a1a21;
    --surface-2: #22222b;
    --border: #2d2d38;
    --border-strong: #3c3c4a;
    --text: #ececf1;
    --muted: #9a9aab;
    --accent: #8b8bf5;
    --accent-ink: #111116;
    --accent-soft: #26264a;
    --ok: #4cc38a;
    --ok-soft: #13291f;
    --warn: #f0a442;
    --warn-soft: #2e2213;
    --danger: #f2708a;
    --danger-soft: #331820;
    --tt: #e8e8e8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.boot { padding: 40px; color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 18px; height: 18px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--muted); font-weight: 520; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
.sidebar-foot { margin-top: auto; padding: 10px; font-size: 12.5px; color: var(--muted); display: grid; gap: 6px; }
.main { min-width: 0; }
.page { padding: 28px 32px 60px; max-width: 1240px; }
.page.wide { max-width: none; padding: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head p { margin-top: 4px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.callout { border-radius: var(--radius); padding: 12px 14px; border: 1px solid var(--border); background: var(--surface-2); display: grid; gap: 4px; }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.callout.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.callout.info { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.callout ul { margin: 2px 0 0; padding-left: 18px; }

/* ---------- controls ---------- */
.btn { appearance: none; border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 560; padding: 8px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.subtle { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn.link { background: none; color: var(--accent); padding: 0; border: 0; }
label.field { display: grid; gap: 6px; font-weight: 550; font-size: 13px; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input, textarea, select { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 76px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; font: inherit; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 540; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px; background: var(--surface); }
.chips:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chips input { border: 0; padding: 4px; flex: 1; min-width: 140px; box-shadow: none !important; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent); border-radius: 6px; padding: 3px 4px 3px 9px; font-weight: 600; font-size: 13px; }
.chip button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 4px; }
.copy-field { display: flex; gap: 6px; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.badge.live { background: var(--ok-soft); color: var(--ok); }
.badge.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.paused { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.pbadge { display: inline-grid; place-items: center; min-width: 24px; height: 20px; padding: 0 5px; border-radius: 5px; font-size: 10.5px; font-weight: 750; color: #fff; letter-spacing: .02em; }
.p-instagram { background: var(--ig); }
.p-facebook { background: var(--fb); }
.p-tiktok { background: var(--tt); color: var(--surface); }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); margin: 1px 3px 1px 0; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 8px 12px; border-bottom: 1px solid var(--border); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable:hover { background: var(--surface-2); cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.kpi .value { font-size: 26px; font-weight: 680; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.funnel { display: grid; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 130px 1fr 80px; align-items: center; gap: 12px; font-size: 13px; }
.funnel-bar { height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.funnel-bar span { display: block; height: 100%; background: var(--accent); border-radius: 6px; min-width: 2px; }
.chart svg { width: 100%; height: 190px; display: block; }
.chart .axis { stroke: var(--border); }
.chart text { fill: var(--muted); font-size: 11px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.activity { display: grid; gap: 0; }
.activity-item { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity-item:last-child { border-bottom: 0; }
.activity-item .when { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.checklist { display: grid; gap: 10px; }
.checklist .step { display: flex; gap: 12px; align-items: center; }
.checklist .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; font-size: 12px; flex: none; }
.checklist .done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }

/* ---------- accounts ---------- */
.platform-card { display: grid; gap: 12px; align-content: start; }
.platform-card .head { display: flex; align-items: center; gap: 10px; }
.platform-logo { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800; }
.cap-table td:not(:first-child), .cap-table th:not(:first-child) { text-align: center; }
.yes { color: var(--ok); font-weight: 600; }
.no { color: var(--muted); }
.maybe { color: var(--warn); font-weight: 600; }
.account-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.account-row:last-child { border-bottom: 0; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; color: var(--muted); flex: none; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- wizard ---------- */
.wizard { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.steps button { border: 1px solid var(--border); background: var(--surface); color: var(--muted); font: inherit; font-weight: 560; font-size: 13px; padding: 6px 12px; border-radius: 99px; cursor: pointer; display: flex; gap: 7px; align-items: center; }
.steps button .n { width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-size: 11.5px; }
.steps button.on { border-color: var(--accent); color: var(--accent); }
.steps button.on .n { background: var(--accent); color: var(--accent-ink); }
.steps button.done .n { background: var(--ok); color: #fff; }
.wizard-foot { display: flex; justify-content: space-between; margin-top: 18px; }
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.post { border: 2px solid var(--border); border-radius: 10px; padding: 10px; cursor: pointer; background: var(--surface); display: grid; gap: 6px; text-align: left; font: inherit; color: inherit; }
.post.on { border-color: var(--accent); background: var(--accent-soft); }
.post .thumb { aspect-ratio: 4/5; border-radius: 6px; background: linear-gradient(135deg, var(--accent-soft), var(--surface-2)); display: grid; place-items: center; color: var(--muted); font-size: 11px; font-weight: 700; overflow: hidden; }
.post .thumb img { width: 100%; height: 100%; object-fit: cover; }
.post .cap { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.option-card { border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: grid; gap: 10px; background: var(--surface-2); }
.choice { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.choice button { text-align: left; border: 2px solid var(--border); background: var(--surface); border-radius: 10px; padding: 12px 14px; cursor: pointer; font: inherit; color: inherit; display: grid; gap: 3px; }
.choice button.on { border-color: var(--accent); background: var(--accent-soft); }
.choice button b { font-weight: 620; }
.choice button span { color: var(--muted); font-size: 12.5px; }

/* ---------- phone preview ---------- */
.phone { border: 1px solid var(--border-strong); border-radius: 28px; background: var(--surface); padding: 14px 12px; box-shadow: var(--shadow); position: sticky; top: 20px; }
.phone-head { display: flex; align-items: center; gap: 8px; padding: 0 4px 10px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.thread { display: flex; flex-direction: column; gap: 8px; padding: 12px 4px; min-height: 280px; max-height: 520px; overflow-y: auto; }
.bubble { max-width: 82%; padding: 8px 12px; border-radius: 16px; font-size: 13.5px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.in { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 5px; }
.bubble.out { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 5px; }
.bubble.comment { align-self: stretch; max-width: none; background: transparent; border: 1px dashed var(--border-strong); border-radius: 10px; font-size: 12.5px; }
.bubble.blocked, .bubble.failed { background: var(--danger-soft); color: var(--danger); }
.bubble .btns { display: grid; gap: 5px; margin-top: 8px; }
.bubble .btns button, .bubble .btns a { background: var(--surface); color: var(--accent); border: 0; border-radius: 9px; padding: 7px; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; text-align: center; }
.bubble.out .btns button:disabled { cursor: default; opacity: .9; }
.bubble .meta { font-size: 11px; opacity: .75; margin-top: 4px; }
.qrs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.qrs button { border: 1px solid var(--accent); color: var(--accent); background: var(--surface); border-radius: 99px; padding: 5px 12px; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.sysline { align-self: center; font-size: 11.5px; color: var(--muted); text-align: center; max-width: 90%; }
.composer { display: flex; gap: 6px; border-top: 1px solid var(--border); padding-top: 10px; }

/* ---------- inbox ---------- */
.inbox { display: grid; grid-template-columns: 320px 1fr 280px; height: 100vh; }
.inbox-list { border-right: 1px solid var(--border); overflow-y: auto; background: var(--surface); }
.inbox-list .search { padding: 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.convo { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; width: 100%; text-align: left; border-left: 3px solid transparent; background: none; font: inherit; color: inherit; border-top: 0; border-right: 0; }
.convo:hover { background: var(--surface-2); }
.convo.on { background: var(--accent-soft); border-left-color: var(--accent); }
.convo .preview { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo-body { min-width: 0; flex: 1; }
.inbox-thread { display: flex; flex-direction: column; min-width: 0; }
.inbox-thread .thread { flex: 1; max-height: none; padding: 20px; }
.inbox-thread .composer { padding: 12px 20px; background: var(--surface); }
.inbox-head { padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--surface); display: flex; align-items: center; gap: 10px; }
.inbox-side { border-left: 1px solid var(--border); background: var(--surface); padding: 18px; overflow-y: auto; display: grid; gap: 16px; align-content: start; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- flow builder ---------- */
.builder { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.builder-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex-wrap: wrap; }
.builder-bar input.name { width: 260px; font-weight: 600; }
.builder-body { display: grid; grid-template-columns: 1fr 340px; min-height: 0; }
.canvas-wrap { overflow: auto; position: relative; background-color: var(--bg); background-image: radial-gradient(var(--border-strong) 1px, transparent 1px); background-size: 22px 22px; }
.canvas { position: relative; width: 2600px; height: 1800px; }
.canvas svg.edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.edges path { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .75; }
.edges path.draft { stroke-dasharray: 6 5; opacity: 1; }
.node { position: absolute; width: 250px; background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); user-select: none; }
.node.sel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.node.drop { border-color: var(--ok); }
.node-head { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: grab; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.node-head .ico { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; color: #fff; font-size: 12px; }
.node-head .start { margin-left: auto; text-transform: none; letter-spacing: 0; }
.node-body { padding: 10px; font-size: 13px; display: grid; gap: 6px; }
.node-text { white-space: pre-wrap; word-break: break-word; max-height: 90px; overflow: hidden; color: var(--text); }
.node-text.empty { color: var(--muted); font-style: italic; }
.port-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5px 8px; border-radius: 7px; background: var(--surface-2); font-size: 12.5px; font-weight: 560; }
.port-row.url { color: var(--muted); }
.port { position: absolute; right: -17px; top: 50%; translate: 0 -50%; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--accent); cursor: crosshair; }
.port.linked { background: var(--accent); }
.port-in { position: absolute; left: -8px; top: 18px; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--border-strong); }
.inspector { border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; padding: 18px; display: grid; gap: 14px; align-content: start; }
.inspector .sub-list { display: grid; gap: 8px; }
.inspector .sub-item { border: 1px solid var(--border); border-radius: 9px; padding: 10px; display: grid; gap: 8px; background: var(--surface-2); }
.issues { position: absolute; left: 16px; bottom: 16px; max-width: 520px; display: grid; gap: 8px; z-index: 5; }

/* ---------- simulator ---------- */
.sim { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }
.log { font-family: var(--mono); font-size: 12px; background: var(--surface-2); border-radius: 8px; padding: 10px; max-height: 260px; overflow: auto; white-space: pre-wrap; }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; display: grid; gap: 16px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 10, 20, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; padding: 22px; width: 100%; max-width: 480px; display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 9px; font-weight: 550; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; max-width: 380px; }
.toast-error { background: var(--danger); color: #fff; }
.toast-ok { background: var(--ok); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
.empty { text-align: center; padding: 48px 20px; display: grid; gap: 8px; justify-items: center; }
.empty p { color: var(--muted); max-width: 420px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .wizard, .sim { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 280px 1fr; }
  .inbox-side { display: none; }
  .builder-body { grid-template-columns: 1fr 300px; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; overflow-x: auto; padding: 8px; align-items: center; }
  .brand { padding: 0 8px; }
  .nav { display: flex; }
  .nav a span { display: none; }
  .sidebar-foot { display: none; }
  .page { padding: 18px 16px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .inbox { grid-template-columns: 1fr; height: auto; }
  .builder-body { grid-template-columns: 1fr; }
  .inspector { border-left: 0; border-top: 1px solid var(--border); }
}
