@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,700&family=Figtree:wght@400;500;600;700&display=swap');

:root {
  --brand: #0f8a5f;
  --brand-ink: #ffffff;
  --brand-soft: #e2f3eb;
  --bubble-out: #dcf1e6;
  --marigold: #f2a93b;
  --marigold-soft: #fdf1dc;
  --ink: #14211f;
  --muted: #5e6e6a;
  --faint: #8a9a96;
  --line: #e2e7e5;
  --bg: #f4f6f5;
  --surface: #ffffff;
  --side: #0f3a3f;
  --side-ink: #cfe3df;
  --side-active: #1b5258;
  --danger: #c2412d;
  --danger-soft: #fbe9e5;
  --ok: #1f8a5b;
  --chat-bg: #eef2f0;
  --radius-s: 6px;
  --radius: 10px;
  --radius-l: 16px;
  --shadow: 0 1px 2px rgba(15, 58, 63, .06), 0 8px 24px rgba(15, 58, 63, .06);
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand-soft: #123528; --bubble-out: #16402f; --marigold-soft: #3a2a10;
    --ink: #e4ecea; --muted: #9aaba7; --faint: #6f817c; --line: #24312f; --bg: #0e1514; --surface: #151f1d; --side: #0a2326; --side-ink: #a9c4bf; --side-active: #133a3e; --danger-soft: #3b1913; --chat-bg: #0f1816;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -.01em; line-height: 1.2; margin: 0; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; font-family: var(--font); font-weight: 700; }
p { margin: 0 0 10px; }
small, .small { font-size: 13px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
code { background: var(--bg); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; word-break: break-all; }
pre { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; overflow-x: auto; margin: 8px 0; }
pre code { border: 0; padding: 0; background: none; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px; padding: 8px 14px; border-radius: var(--radius-s); border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
label.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
label.field > em { display: block; font-style: normal; font-size: 12.5px; color: var(--faint); margin-top: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 80px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
.check { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 12px; cursor: pointer; }
.check input { margin-top: 4px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 180px; }
.row > .shrink { flex: 0 0 auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stack > * + * { margin-top: 12px; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.pill.ok { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.pill.warn { background: var(--marigold-soft); color: #9a5b00; border-color: transparent; }
.pill.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pill.warn { color: var(--marigold); } }
.tag { display: inline-block; padding: 0 7px; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); font-size: 12px; color: var(--muted); margin: 0 4px 4px 0; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 14px 10px; position: sticky; top: 0; height: 100vh; }
.side .logo { display: flex; align-items: center; gap: 9px; padding: 4px 10px 16px; color: #fff; font-family: var(--display); font-size: 19px; font-weight: 700; text-decoration: none; }
.side .logo i { width: 26px; height: 26px; border-radius: 8px 8px 8px 2px; background: var(--brand); display: inline-block; position: relative; }
.side .logo i::after { content: ''; position: absolute; inset: 8px 6px; border-radius: 2px; border-top: 2px solid #fff; border-bottom: 2px solid #fff; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-s); color: var(--side-ink); text-decoration: none; font-weight: 500; }
.side nav a svg { width: 18px; height: 18px; opacity: .85; flex: none; }
.side nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.side nav a.active { background: var(--side-active); color: #fff; }
.side nav a .count { margin-left: auto; background: var(--marigold); color: #3b2500; font-size: 11.5px; font-weight: 700; border-radius: 99px; padding: 0 7px; }
.side .sep { height: 1px; background: rgba(255,255,255,.08); margin: 10px 6px; }
.side .foot { margin-top: auto; padding: 10px; font-size: 13px; }
.side .foot .who { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side .foot button { background: none; border: 0; color: var(--side-ink); font: inherit; font-size: 13px; padding: 0; cursor: pointer; text-decoration: underline; }
.side select { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); color: #fff; margin: 0 0 12px; font-weight: 600; }
.side select option { color: #000; }

.main { min-width: 0; display: flex; flex-direction: column; }
.banner { padding: 9px 20px; font-size: 14px; display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; text-align: center; }
.banner.trial { background: var(--marigold-soft); color: var(--ink); }
.banner.blocked { background: var(--danger-soft); color: var(--danger); font-weight: 600; }
.banner.imp { background: #2b2f6b; color: #fff; }
.banner .btn { padding: 3px 10px; font-size: 13px; }
.page { padding: 24px 28px 60px; max-width: 1200px; width: 100%; }
.page.full { max-width: none; padding: 0; flex: 1; display: flex; min-height: 0; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.mobile-top { display: none; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel > h2 { margin-bottom: 4px; }
.panel > h2 + p { color: var(--muted); margin-bottom: 14px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a.active { color: var(--ink); border-color: var(--brand); }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--bg); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-family: var(--display); font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 13px; }
.meter { height: 6px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 6px 0 2px; border: 1px solid var(--line); }
.meter i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.meter i.hot { background: var(--marigold); }
.meter i.full { background: var(--danger); }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 10px; }

/* Checklist on the home page (a real sequence, so it is numbered) */
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 30px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.steps li:last-child { border-bottom: 0; }
.steps li::before { content: counter(s); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; border: 1.5px solid var(--line); color: var(--muted); }
.steps li.done::before { content: '✓'; background: var(--brand); border-color: var(--brand); color: #fff; }
.steps li.done b { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }

/* ---------- Inbox ---------- */
.inbox { display: grid; grid-template-columns: 320px 1fr 280px; flex: 1; min-height: 0; height: calc(100vh - var(--banner-h, 0px)); background: var(--surface); }
.inbox.no-panel { grid-template-columns: 320px 1fr; }
.conv-list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.conv-list .tools { padding: 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.conv-list .filters { display: flex; gap: 4px; flex-wrap: wrap; }
.conv-list .filters button { font: inherit; font-size: 12.5px; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--muted); padding: 3px 10px; border-radius: 99px; cursor: pointer; }
.conv-list .filters button.on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.conv-items { overflow-y: auto; flex: 1; }
.conv { display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: center; }
.conv:hover { background: var(--bg); }
.conv.active { background: var(--brand-soft); }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff; flex: none; }
.conv .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .prev { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .meta { text-align: right; font-size: 12px; color: var(--faint); display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.conv .unread { background: var(--marigold); color: #3b2500; font-weight: 700; border-radius: 99px; padding: 0 7px; font-size: 11.5px; }
.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.thread-head { padding: 10px 16px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.thread-head .who { font-weight: 700; }
#backBtn { display: none; }
@media (max-width: 860px) { #backBtn { display: inline-flex; } }
.thread-head .actions { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.thread-head select { width: auto; padding: 5px 8px; font-size: 13px; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 22px; background: var(--chat-bg); display: flex; flex-direction: column; gap: 4px; }
.day { align-self: center; font-size: 12px; color: var(--muted); background: var(--surface); padding: 2px 10px; border-radius: 99px; margin: 10px 0 6px; border: 1px solid var(--line); }
.bubble { max-width: min(72%, 560px); padding: 7px 11px 5px; border-radius: 10px; background: var(--surface); white-space: normal; word-wrap: break-word; align-self: flex-start; border: 1px solid var(--line); }
.bubble .txt, .wa-preview .bubble > div:not(.hdr):not(.ftr) { white-space: pre-wrap; }
.bubble.out { align-self: flex-end; background: var(--bubble-out); border-color: transparent; }
.bubble.auto { border-left: 3px solid var(--marigold); }
.bubble .foot { display: flex; gap: 6px; justify-content: flex-end; font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.bubble .foot .tick.read { color: #3b82f6; }
.bubble.failed { border: 1px solid var(--danger); }
.bubble .err { font-size: 12px; color: var(--danger); }
.composer { border-top: 1px solid var(--line); padding: 10px 12px; background: var(--surface); }
.composer .bar { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { min-height: 42px; max-height: 160px; height: 42px; }
.composer .closed { padding: 10px; background: var(--marigold-soft); border-radius: var(--radius-s); font-size: 14px; display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.side-panel { border-left: 1px solid var(--line); padding: 16px; overflow-y: auto; }
.side-panel h3 { margin: 16px 0 6px; font-size: 13px; color: var(--muted); }
.side-panel .kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13.5px; }
.side-panel .kv dt { color: var(--muted); }
.side-panel .kv dd { margin: 0; word-break: break-word; }
.no-conv { flex: 1; display: grid; place-items: center; color: var(--muted); background: var(--chat-bg); text-align: center; padding: 20px; }

/* ---------- Modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(10, 30, 32, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius-l); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: var(--shadow); }
.modal.wide { width: min(860px, 100%); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal header button { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: 0; background: var(--surface); }
#toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--surface); padding: 10px 14px; border-radius: var(--radius-s); font-weight: 500; max-width: 380px; box-shadow: var(--shadow); animation: toast-in .18s ease-out; }
.toast.bad { background: var(--danger); color: #fff; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* ---------- Flow editor ---------- */
.step { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; background: var(--surface); position: relative; }
.step.first { border-color: var(--brand); }
.step .step-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.step .step-head input { width: 130px; font-weight: 700; }
.step .step-head select { width: 170px; }
.step .opt { display: grid; grid-template-columns: 1fr 200px auto; gap: 8px; margin-bottom: 6px; }
.flow-preview { background: var(--chat-bg); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 6px; min-height: 200px; }
.flow-preview .bubble { max-width: 90%; }
.flow-preview .choices { display: flex; flex-direction: column; gap: 4px; align-self: flex-start; width: 90%; }
.flow-preview .choices button { font: inherit; font-size: 13.5px; padding: 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: #2563eb; cursor: pointer; }

/* Template preview */
.wa-preview { background: var(--chat-bg); border-radius: var(--radius); padding: 18px; }
.wa-preview .bubble { max-width: 100%; }
.wa-preview .hdr { font-weight: 700; margin-bottom: 4px; }
.wa-preview .ftr { color: var(--faint); font-size: 12.5px; margin-top: 4px; }
.wa-preview .wbtn { display: block; text-align: center; color: #2563eb; border-top: 1px solid var(--line); padding: 6px 0 2px; margin-top: 6px; font-size: 14px; }

/* Plans (billing + pricing) */
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.plan { border: 1px solid var(--line); border-radius: var(--radius-l); padding: 20px; background: var(--surface); display: flex; flex-direction: column; }
.plan.current { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.plan .price { font-family: var(--display); font-size: 32px; font-weight: 700; margin: 6px 0 2px; }
.plan .price small { font-family: var(--font); font-size: 14px; font-weight: 500; color: var(--muted); }
.plan ul { list-style: none; padding: 0; margin: 12px 0 18px; flex: 1; }
.plan li { padding: 4px 0 4px 22px; position: relative; font-size: 14px; }
.plan li::before { content: ''; position: absolute; left: 2px; top: 10px; width: 10px; height: 5px; border-left: 2px solid var(--brand); border-bottom: 2px solid var(--brand); transform: rotate(-45deg); }

.chart { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; position: relative; height: 100%; }
.chart .col i { display: block; border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .col i.in { background: var(--brand); }
.chart .col i.out { background: var(--marigold); }
.chart .col span { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--faint); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); margin-top: 26px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .inbox { grid-template-columns: 290px 1fr; }
  .inbox .side-panel { display: none; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-100%); transition: transform .2s; height: 100%; }
  .shell.nav-open .side { transform: none; box-shadow: var(--shadow); }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--side); color: #fff; font-weight: 700; font-family: var(--display); }
  .mobile-top button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 0 4px; }
  .page { padding: 18px 16px 50px; }
  .grid-2 { grid-template-columns: 1fr; }
  .inbox { grid-template-columns: 1fr; height: calc(100dvh - 50px - var(--banner-h, 0px)); }
  .inbox .conv-list, .inbox .thread { min-height: 0; }
  .inbox .conv-list { border-right: 0; }
  .inbox.showing .conv-list { display: none; }
  .inbox:not(.showing) .thread { display: none; }
  .msgs { padding: 12px; }
  .step .opt { grid-template-columns: 1fr; }
}

/* ===================== CRM additions ===================== */
:root {
  --ser-1: #0f8a5f; --ser-2: #b86e0a;               /* validated chart pair (light) */
  --st-new: #2563a8; --st-new-bg: #e6eff9;
  --st-contacted: #6b45b0; --st-contacted-bg: #efe9f8;
  --st-interested: #9a5b00; --st-interested-bg: #fcf0d9;
  --st-converted: #0f7a53; --st-converted-bg: #e0f3ea;
  --st-lost: #66706e; --st-lost-bg: #eceeed;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ser-1: #16a06e; --ser-2: #c4831f;               /* validated chart pair (dark) */
    --st-new: #8fb8ea; --st-new-bg: #17283b;
    --st-contacted: #bea3ec; --st-contacted-bg: #261d38;
    --st-interested: #f0bd62; --st-interested-bg: #352812;
    --st-converted: #6fd3a5; --st-converted-bg: #123224;
    --st-lost: #9aa4a2; --st-lost-bg: #222b29;
  }
}
.ser-1 { background: var(--ser-1); }
.ser-2 { background: var(--ser-2); }
.page.wide { max-width: none; }
button.link { background: none; border: 0; padding: 0; font: inherit; font-size: 12.5px; color: var(--muted); cursor: pointer; text-decoration: underline; }
button.link.danger { color: var(--danger); }

.lead-pill { display: inline-block; padding: 0 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; vertical-align: 1px; white-space: nowrap; }
.lead-pill.s-new, .status-select.s-new { color: var(--st-new); background: var(--st-new-bg); }
.lead-pill.s-contacted, .status-select.s-contacted { color: var(--st-contacted); background: var(--st-contacted-bg); }
.lead-pill.s-interested, .status-select.s-interested { color: var(--st-interested); background: var(--st-interested-bg); }
.lead-pill.s-converted, .status-select.s-converted { color: var(--st-converted); background: var(--st-converted-bg); }
.lead-pill.s-lost, .status-select.s-lost { color: var(--st-lost); background: var(--st-lost-bg); }
.status-select { font-weight: 700; border-color: transparent; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-s); overflow: hidden; background: var(--surface); flex: 0 0 auto !important; }
.seg button { font: inherit; font-size: 13.5px; font-weight: 600; padding: 7px 14px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--ink); color: var(--surface); }
.chips-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { font: inherit; font-size: 13px; font-weight: 600; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 99px; padding: 4px 12px; cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
a.link-stat { color: inherit; text-decoration: none; }
a.link-stat:hover { border-color: var(--faint); }

/* Leads board */
.board { display: grid; grid-template-columns: repeat(5, minmax(196px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.kcol { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 240px; border-top: 3px solid var(--line); }
.kcol.s-new { border-top-color: var(--st-new); }
.kcol.s-contacted { border-top-color: var(--st-contacted); }
.kcol.s-interested { border-top-color: var(--st-interested); }
.kcol.s-converted { border-top-color: var(--st-converted); }
.kcol.s-lost { border-top-color: var(--st-lost); }
.kcol.over { background: var(--brand-soft); border-color: var(--brand); }
.kcol header { display: flex; align-items: baseline; gap: 8px; padding: 2px 4px 10px; flex-wrap: wrap; }
.kcol header h2 { font-size: 15px; }
.count-chip { font-size: 12px; font-weight: 700; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 99px; padding: 0 8px; }
.col-cards { display: flex; flex-direction: column; gap: 8px; }
.col-empty { text-align: center; padding: 18px 0; }
.lead-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px; cursor: grab; display: flex; flex-direction: column; gap: 6px; }
.lead-card:hover { border-color: var(--faint); }
.lead-card.dragging { opacity: .5; }
.lc-top { display: flex; gap: 8px; align-items: center; }
.lc-top b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.lc-value { font-weight: 700; font-size: 13px; white-space: nowrap; }
.lc-msg { font-size: 13px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lc-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lc-meta .unread { background: var(--marigold); color: #3b2500; font-weight: 700; border-radius: 99px; padding: 0 7px; font-size: 11.5px; }
.src { font-size: 11.5px; color: var(--muted); border: 1px dashed var(--line); border-radius: 4px; padding: 0 6px; }
.src-meta_lead_ad, .src-ctwa_ad { color: #3b5bdb; border-color: #c5d0f5; }
.lc-foot { display: flex; justify-content: space-between; gap: 8px; }
.lc-move { display: none; font-size: 13px; padding: 4px 6px; }
@media (max-width: 860px), (pointer: coarse) { .lc-move { display: block; } .board { grid-template-columns: repeat(5, 82vw); } }

/* Inbox side panel + profile */
.side-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.side-grid label { display: block; }
.side-grid label > span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.side-grid select, .side-grid input { padding: 6px 8px; font-size: 13.5px; }
.profile { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
.profile-card { position: sticky; top: 16px; }
.profile-card h3 { margin: 16px 0 6px; font-size: 13px; color: var(--muted); }
.profile-card .kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 13.5px; margin: 0; }
.profile-card .kv dt { color: var(--muted); }
.profile-card .kv dd { margin: 0; word-break: break-word; }
.note { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 9px 11px; margin-bottom: 8px; background: var(--surface); }
.note.pinned { border-color: var(--marigold); background: var(--marigold-soft); }
.note-body { white-space: pre-wrap; font-size: 14px; }
.note-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--faint); margin-top: 4px; flex-wrap: wrap; }
.fu { display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: start; padding: 9px 0; border-bottom: 1px solid var(--line); }
.fu:last-child { border-bottom: 0; }
.fu-check { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--faint); background: var(--surface); cursor: pointer; color: #fff; font-size: 13px; line-height: 1; padding: 0; margin-top: 2px; }
.fu-check:hover { border-color: var(--brand); }
.fu.done .fu-check { background: var(--brand); border-color: var(--brand); }
.fu.done .fu-body > div:not(.faint) { color: var(--muted); text-decoration: line-through; }
.fu-body { font-size: 14px; display: flex; flex-direction: column; gap: 3px; align-items: flex-start; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 14px 6px; font-size: 14px; }
.timeline li::before { content: ''; position: absolute; left: -24px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--faint); }
.timeline li.t-status::before { border-color: var(--st-contacted); }
.timeline li.t-created::before, .timeline li.t-lead_again::before { border-color: var(--st-new); }
.timeline li.t-opt_in::before { border-color: var(--brand); }
.timeline li.t-opt_out::before { border-color: var(--danger); }
.timeline li.t-note::before, .timeline li.t-follow_up::before { border-color: var(--marigold); }

/* Charts (analytics + home) */
.chart .col { flex-direction: row; }
.gbars { display: flex; align-items: flex-end; gap: 2px; height: 100%; width: 100%; }
.gbars i { flex: 1; border-radius: 3px 3px 0 0; min-height: 1px; }
.chart .col .gbars i { display: block; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.gchart { position: relative; display: grid; grid-template-columns: 36px 1fr; height: 180px; margin-top: 8px; }
.gaxis { display: flex; flex-direction: column; justify-content: space-between; font-size: 11px; color: var(--faint); text-align: right; padding: 0 6px 20px 0; }
.gplot { display: flex; align-items: stretch; gap: 3px; border-bottom: 1px solid var(--line); padding-bottom: 0; position: relative;
  background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 50%; background-position: 0 0; }
.gday { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; position: relative; cursor: default; padding-bottom: 20px; margin-bottom: -20px; }
.gday:hover .gbars { background: var(--bg); }
.gday .gbars { height: 100%; }
.glabel { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--faint); white-space: nowrap; }
.gtip { position: absolute; top: 4px; background: var(--ink); color: var(--surface); font-size: 12.5px; padding: 8px 10px; border-radius: var(--radius-s); pointer-events: none; z-index: 2; min-width: 150px; }
.gtip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 90px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 14px; }
.hb-track { height: 14px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.hb-track i { display: block; height: 100%; background: var(--ser-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hb-track i.s-new { background: var(--st-new); } .hb-track i.s-contacted { background: var(--st-contacted); } .hb-track i.s-interested { background: var(--st-interested); }
.hb-track i.s-converted { background: var(--st-converted); } .hb-track i.s-lost { background: var(--st-lost); }
.hb-track i.opt-opted_in { background: var(--brand); } .hb-track i.opt-unknown { background: var(--faint); } .hb-track i.opt-opted_out { background: var(--danger); }
.hb-val { text-align: right; font-variant-numeric: tabular-nums; }

/* Notification toasts */
.toast.notice { display: flex; flex-direction: column; gap: 2px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--marigold); text-decoration: none; }
.toast.notice span { color: var(--muted); font-size: 13.5px; }

@media (max-width: 1000px) { .profile { grid-template-columns: 1fr; } .profile-card { position: static; } }
@media (max-width: 860px) { .hbar { grid-template-columns: 90px 1fr 70px; } }

.page-head .row > * { flex: 0 0 auto; }
.gchart { height: 160px; margin-bottom: 26px; }
.gaxis { padding: 0 6px 0 0; line-height: 1; }
.gaxis span:first-child { transform: translateY(-50%); }
.gaxis span:last-child { transform: translateY(50%); }
.gday { padding-bottom: 0; margin-bottom: 0; }
.glabel { bottom: -20px; }
#profBtn { display: none; }
@media (max-width: 1100px) { #profBtn { display: inline-flex; } }
