:root {
  --font: 'Inter', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --bg: #0b0c11; --surface: #13141b; --surface2: #1a1b24; --surface3: #22232e;
  --border: #282a36; --border2: #353846;
  --text: #f1f1f5; --text2: #a0a3b5; --text3: #6b6e80;
  --accent: #6c63ff; --accent2: #8d86ff; --accent-bg: rgba(108, 99, 255, .14);
  --green: #2fbf71; --green-bg: rgba(47, 191, 113, .13);
  --amber: #f2a93b; --amber-bg: rgba(242, 169, 59, .13);
  --red: #ef5a64; --red-bg: rgba(239, 90, 100, .13);
  --blue: #4f9dff; --blue-bg: rgba(79, 157, 255, .13);
  --purple: #b07cff; --purple-bg: rgba(176, 124, 255, .14);
  --slate: #8c90a3; --slate-bg: rgba(140, 144, 163, .14);
  --overlay: rgba(4, 5, 10, .66);
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --radius: 12px;
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f5f6f9; --surface: #ffffff; --surface2: #f1f2f6; --surface3: #e8eaf0;
  --border: #e2e4eb; --border2: #d2d5df;
  --text: #171821; --text2: #585c6f; --text3: #8d91a3;
  --accent: #5b51f0; --accent2: #4a3fdc; --accent-bg: rgba(91, 81, 240, .10);
  --green: #13894b; --green-bg: rgba(19, 137, 75, .10);
  --amber: #b86d00; --amber-bg: rgba(184, 109, 0, .10);
  --red: #d13843; --red-bg: rgba(209, 56, 67, .09);
  --blue: #2268c8; --blue-bg: rgba(34, 104, 200, .09);
  --purple: #7c3aed; --purple-bg: rgba(124, 58, 237, .09);
  --slate: #5f6477; --slate-bg: rgba(95, 100, 119, .10);
  --overlay: rgba(23, 24, 33, .40);
  --shadow: 0 18px 50px rgba(23, 24, 33, .16);
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; background: var(--bg); color: var(--text); font-variant-numeric: tabular-nums; min-height: 100vh; }
a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--text2); }
.dim { color: var(--text3); }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ── Controls ─────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--border2); background: var(--surface2); color: var(--text); font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; transition: border-color .15s, background .15s, opacity .15s; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent2); border-color: var(--accent2); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-green { background: var(--green); border-color: var(--green); color: #fff; }
.icon-btn { border: 1px solid var(--border); background: transparent; color: var(--text2); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:hover { color: var(--text); border-color: var(--border2); }

input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--border2); background: var(--surface); color: var(--text); 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-bg); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
select { cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label { font-size: 12px; font-weight: 600; color: var(--text2); }
.field .hint { font-size: 12px; color: var(--text3); }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Badges ───────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--slate-bg); color: var(--slate); }
.b-green { background: var(--green-bg); color: var(--green); }
.b-amber { background: var(--amber-bg); color: var(--amber); }
.b-red { background: var(--red-bg); color: var(--red); }
.b-blue { background: var(--blue-bg); color: var(--blue); }
.b-purple { background: var(--purple-bg); color: var(--purple); }
.b-accent { background: var(--accent-bg); color: var(--accent2); }

/* ── Admin layout ─────────────────────────── */
.app { display: grid; grid-template-columns: 224px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.logo { padding: 22px 20px 18px; border-bottom: 1px solid var(--border); }
.logo-text { font-size: 17px; font-weight: 800; letter-spacing: -.4px; }
.logo-text span { color: var(--accent2); }
.logo-sub { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 1.2px; margin-top: 3px; }
.nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 8px; border: 0; background: none; color: var(--text2); font-size: 13.5px; font-weight: 500; cursor: pointer; text-align: left; margin-bottom: 2px; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent2); font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex: none; }
.side-foot { padding: 14px 14px 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.me strong { display: block; font-size: 13px; }
.credit { font-size: 10.5px; color: var(--text3); letter-spacing: .2px; }
.main { padding: 26px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.page-sub { font-size: 13px; color: var(--text2); margin-top: 3px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type=search] { max-width: 280px; }
.toolbar select { width: auto; min-width: 150px; }

/* ── Range picker ─────────────────────────── */
.range { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range select { width: auto; min-width: 150px; }
.range input[type=date] { width: 150px; }

/* ── Tiles ────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 22px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; }
.tile-label { font-size: 11.5px; font-weight: 600; color: var(--text2); text-transform: uppercase; letter-spacing: .6px; }
.tile-value { font-size: 26px; font-weight: 800; letter-spacing: -.6px; margin-top: 6px; }
.tile-sub { font-size: 12px; color: var(--text3); margin-top: 3px; }
.tile.hero .tile-value { color: var(--accent2); }

/* ── Panels + tables ──────────────────────── */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-title { font-size: 15px; font-weight: 700; }
.panel-body { padding: 16px 18px; }
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .6px; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover td { background: var(--surface2); }
.table .num { text-align: right; white-space: nowrap; }
.table .strong { font-weight: 700; }
.table tfoot td { font-weight: 700; border-top: 1px solid var(--border2); }
.load-more { display: flex; justify-content: center; padding: 14px; }

/* Funnel ladder */
.ladder td.bar-cell { width: 38%; }
.bar { height: 8px; border-radius: 99px; background: var(--surface3); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
.ladder tr.sep td { border-top: 1px dashed var(--border2); }

/* VSL cards (collapsible) */
.vsl-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.vsl-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.vsl-head { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 14px 18px; cursor: pointer; list-style: none; user-select: none; }
.vsl-head::-webkit-details-marker { display: none; }
.vsl-head:hover { background: var(--surface2); }
.vsl-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.vsl-card[open] > .vsl-head { border-bottom: 1px solid var(--border); }
.chev { display: inline-flex; flex: none; color: var(--text3); transition: transform .15s; }
.chev svg { width: 18px; height: 18px; }
.vsl-card[open] > .vsl-head .chev { transform: rotate(90deg); }
.vsl-id { flex: 1 1 220px; min-width: 0; }
.vsl-url { font-size: 12.5px; color: var(--text3); margin-top: 3px; }
.vsl-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.vsl-nums { display: flex; gap: 20px; }
.vsl-nums div { text-align: right; min-width: 50px; }
.vsl-nums strong { display: block; font-size: 16px; font-weight: 800; letter-spacing: -.3px; }
.vsl-nums span { white-space: nowrap; font-size: 10.5px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .5px; }
.vsl-body > .panel-sub:first-child { border-top: 0; }
.vsl-add { background: transparent; border-style: dashed; }
.vsl-add .vsl-body { padding: 16px 18px 2px; }
.snippet { display: block; margin-top: 6px; padding: 8px 10px; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; color: var(--text); white-space: nowrap; overflow-x: auto; }

/* Pages & A/B */
.panel-sub { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 18px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface2); }
.file-path { margin-top: 2px; word-break: break-all; }
.todo { margin-top: 5px; font-size: 12px; color: var(--amber); line-height: 1.5; }
.ab-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ab-controls input[type=number] { width: 80px; }
.verdict { padding: 12px 18px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text2); }
.verdict strong { color: var(--text); }
.win { color: var(--green); font-weight: 700; }

/* ── Sales workspace ──────────────────────── */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; padding: 0 24px; height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .logo-text { font-size: 16px; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--text2); padding: 6px 12px; border-radius: 6px; cursor: pointer; font-weight: 600; font-size: 12.5px; }
.seg button.active { background: var(--accent); color: #fff; }
.search-box { position: relative; width: 260px; }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border2); border-radius: 10px; box-shadow: var(--shadow); max-height: 360px; overflow: auto; z-index: 40; }
.search-results button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.search-results button:hover { background: var(--surface2); }
.shell { max-width: 1180px; margin: 0 auto; padding: 0 24px 60px; }
.tabs { display: flex; gap: 26px; border-bottom: 1px solid var(--border); overflow-x: auto; margin-bottom: 18px; }
.tab { border: 0; background: none; color: var(--text2); padding: 18px 2px 14px; font-weight: 700; white-space: nowrap; cursor: pointer; border-bottom: 3px solid transparent; font-size: 14px; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.count { font-size: 11px; background: var(--surface2); color: var(--text2); padding: 2px 7px; border-radius: 99px; margin-left: 6px; }
.group { margin: 22px 0 8px; }
.group-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text2); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.group-title.red { color: var(--red); }
.lead { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) 210px; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 13px 16px; margin-bottom: 8px; }
.lead.alert { border-color: var(--red); }
.lead-name { font-weight: 700; font-size: 14.5px; cursor: pointer; }
.lead-name:hover { color: var(--accent2); }
.lead-phone { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; margin-top: 2px; }
.lead-meta { font-size: 12px; color: var(--text3); margin-top: 3px; }
.lead-status { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; font-size: 12px; color: var(--text2); }
.lead-action select { width: 100%; }
.empty { text-align: center; padding: 46px 20px; color: var(--text3); border: 1px dashed var(--border2); border-radius: var(--radius); }

/* ── Drawer (contact card) ────────────────── */
.drawer-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 60; display: flex; justify-content: flex-end; }
.drawer { width: min(620px, 100%); height: 100%; background: var(--bg); border-left: 1px solid var(--border); overflow-y: auto; box-shadow: var(--shadow); animation: slide-in .18s ease-out; }
@keyframes slide-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { position: sticky; top: 0; z-index: 2; background: var(--surface); border-bottom: 1px solid var(--border); padding: 18px 22px; display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; }
.drawer-head h2 { font-size: 20px; font-weight: 800; letter-spacing: -.4px; }
.drawer-head .contact-line { margin-top: 5px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text2); }
.drawer-head .badges { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 6px; }
.drawer-body { padding: 16px 22px 40px; }
.section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px 16px; margin-bottom: 14px; }
.section-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; color: var(--text2); margin-bottom: 11px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 7px 14px; font-size: 13px; }
.kv dt { color: var(--text3); }
.kv dd { color: var(--text); word-break: break-word; }
.status-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.action-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.action-row select { flex: 1; min-width: 200px; }
.qa { margin-bottom: 12px; }
.qa:last-child { margin-bottom: 0; }
.qa-q { font-size: 12.5px; color: var(--text2); font-weight: 600; }
.qa-a { margin-top: 3px; white-space: pre-wrap; }
.pay-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.pay-row:last-child { border-bottom: 0; }
.money-line { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--text2); }
.money-line strong { color: var(--text); }
.timeline { list-style: none; }
.timeline li { display: grid; grid-template-columns: 118px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--text3); font-size: 12px; }
.timeline .who { color: var(--text3); font-size: 12px; }

/* ── Modal ────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: min(460px, 100%); background: var(--surface); border: 1px solid var(--border2); border-radius: 16px; box-shadow: var(--shadow); padding: 22px; max-height: 90vh; overflow-y: auto; }
.modal h3 { font-size: 17px; font-weight: 800; margin-bottom: 16px; letter-spacing: -.3px; }
.modal p { color: var(--text2); margin-bottom: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.modal-error { color: var(--red); font-size: 13px; margin: -4px 0 10px; }
.steps { list-style: none; counter-reset: s; margin-bottom: 14px; }
.steps li { counter-increment: s; position: relative; padding: 0 0 12px 32px; color: var(--text2); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: -1px; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-bg); color: var(--accent2); font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }

/* ── Toast ────────────────────────────────── */
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--surface); border: 1px solid var(--border2); border-left: 4px solid var(--accent); border-radius: 10px; padding: 11px 15px; box-shadow: var(--shadow); max-width: 360px; font-size: 13px; animation: slide-in .18s ease-out; }
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }

/* ── Login ────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(ellipse at 50% 0%, var(--accent-bg), transparent 60%), var(--bg); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 30px 28px; box-shadow: var(--shadow); }
.login-card .logo-text { font-size: 22px; text-align: center; }
.login-card .logo-sub { text-align: center; margin-bottom: 24px; }
.login-card .btn { width: 100%; padding: 11px; margin-top: 4px; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-top: 10px; text-align: center; }
.login-wrap .credit { margin-top: 22px; }

.loading { padding: 40px; text-align: center; color: var(--text3); }

@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; }
  .nav { display: flex; overflow-x: auto; padding: 8px; gap: 4px; }
  .nav-item { width: auto; white-space: nowrap; margin: 0; }
  .side-foot { flex-direction: row; justify-content: space-between; align-items: center; flex-wrap: wrap; }
  .main { padding: 20px 16px 50px; }
  .lead { grid-template-columns: 1fr; gap: 10px; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 10px; }
  .top-actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .search-box { width: 100%; order: 5; }
  .shell { padding: 0 16px 50px; }
  .row-2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .timeline li { grid-template-columns: 1fr; gap: 2px; }
  .table th, .table td { padding-left: 10px; padding-right: 10px; }
  .vsl-head { padding: 12px 14px; }
  .vsl-chips, .vsl-nums { width: 100%; padding-left: 32px; }
  .vsl-nums { flex-wrap: wrap; gap: 6px 22px; }
  .vsl-nums div { text-align: left; min-width: 0; }
}

/* Funnel: the per-question rows folded under "Left their details". */
.ladder .ladder-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 0;
  font: inherit; color: inherit; cursor: pointer;
}
.ladder .ladder-toggle .caret { font-size: 10px; opacity: .55; transition: transform .15s; }
.ladder .ladder-toggle[aria-expanded="true"] .caret { transform: rotate(180deg); }
.ladder tr.qrow td { background: var(--bg2, rgba(0, 0, 0, .02)); }
.ladder tr.qrow .q-label { padding-left: 26px; font-size: 12.5px; opacity: .8; }
