/* ==========================================================================
   Buy or Block — app shell + shared components.
   Colours come ONLY from tokens.css (light/dark + 6 presets). Never add a hex value here:
   apps/core/tests_ui.py fails if the number of hard-coded colours in static/css grows.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font-body); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0; color: var(--text); font-family: var(--font-head); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 26px; } h2 { font-size: 19px; } h3 { font-size: 16px; } h4 { font-size: 15px; }
p { margin: 0 0 8px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
[lang="bn"] { font-family: "Hind Siliguri", "Noto Sans Bengali", var(--font-body); line-height: 1.6; }
::selection { background: var(--accent-soft); }
[data-lucide] { width: 18px; height: 18px; stroke-width: 2; vertical-align: middle; flex-shrink: 0; }
.icon-sm[data-lucide], svg.icon-sm { width: 16px; height: 16px; }
.icon-lg[data-lucide], svg.icon-lg { width: 24px; height: 24px; }
.num, .tabular { font-variant-numeric: tabular-nums; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto; background: var(--side); color: var(--side-fg); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; z-index: 40; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: var(--side-fg); font: 600 17px/1.1 var(--font-head); letter-spacing: -.01em; }
.sidebar-brand:hover { color: var(--side-fg); }
.sidebar-brand img { width: 30px; height: 30px; border-radius: 9px; flex: none; }
.biz-switch { margin-bottom: 12px; }
.biz-btn { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-height: 52px; border-radius: 14px; background: var(--surface); color: var(--text); border: 1px solid var(--border); text-align: left; font: inherit; cursor: pointer; }
.biz-btn:hover { border-color: var(--border-strong); }
.biz-btn > [data-lucide], .biz-btn > svg { color: var(--muted); }
.biz-av { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font: 700 15px/1 var(--font-head); flex: none; overflow: hidden; }
.biz-av img { width: 100%; height: 100%; object-fit: cover; }
.biz-av.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }
.biz-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.biz-txt b { font-weight: 700; font-size: 15px; line-height: 1.2; }
.biz-txt small { color: var(--muted); font-size: 13px; line-height: 1.3; }
.biz-menu { left: 0; right: 0; min-width: 0; }
.biz-menu form { margin: 0; }
.biz-menu .dropdown-item small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group { font: 500 12px/1 var(--font-head); color: var(--side-muted); padding: 18px 12px 8px; margin: 0; letter-spacing: .02em; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--side-muted); font-weight: 700; font-size: 15px; transition: background-color .15s, color .15s; }
.nav-link .nav-label { flex: 1; min-width: 0; }
.nav-link:hover { background: var(--side-hover); color: var(--side-fg); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-sub { display: block; font-weight: 400; font-size: 12px; color: var(--side-muted); line-height: 1.2; }
.nav-badge { min-width: 24px; height: 22px; padding: 0 7px; border-radius: 999px; display: inline-grid; place-items: center; font: 600 12px/1 var(--font-head); background: var(--surface-2); color: var(--text); border: 1px solid var(--border); margin-left: auto; }
.nav-badge.is-danger { background: var(--bad); color: var(--on-status); border-color: var(--bad); }
.nav-badge.is-info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
/* status pill (e.g. Channels "2/3", or a warning dot when nothing is connected) */
.nav-pill { margin-left: auto; height: 22px; padding: 0 7px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; font: 600 12px/1 var(--font-head); background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.nav-pill.is-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.nav-pill.is-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); padding: 0 6px; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
/* Hide/show the menu: an icon-only rail (remembered per browser; default on mid-size screens). */
.sidebar-top { display: flex; align-items: center; gap: 4px; }
.sidebar-top .sidebar-brand { flex: 1; min-width: 0; }
.side-toggle { width: 34px; height: 34px; margin: -10px 0 0; border-radius: 10px; display: grid; place-items: center; background: none; border: 0; color: var(--side-muted); cursor: pointer; flex: none; transition: background-color .15s, color .15s; }
.side-toggle:hover { background: var(--side-hover); color: var(--side-fg); }
.side-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.app { transition: grid-template-columns .2s ease; }
:root[data-side="rail"] { --sidebar-w: 76px; }
:root[data-side="rail"] .sidebar { padding: 14px 10px; overflow-x: hidden; }
:root[data-side="rail"] .sidebar-top { flex-direction: column; gap: 6px; }
:root[data-side="rail"] .sidebar-brand { padding: 2px 0 0; justify-content: center; }
:root[data-side="rail"] .sidebar-brand span,
:root[data-side="rail"] .biz-txt, :root[data-side="rail"] .biz-btn > [data-lucide], :root[data-side="rail"] .biz-btn > svg,
:root[data-side="rail"] .nav-label, :root[data-side="rail"] .nav-pill, :root[data-side="rail"] .mini-ring { display: none; }
:root[data-side="rail"] .side-toggle { margin: 0 0 6px; }
:root[data-side="rail"] .biz-btn { justify-content: center; padding: 8px 0; min-height: 50px; }
:root[data-side="rail"] .nav-group { height: 1px; padding: 0; margin: 12px 10px; background: var(--side-border); overflow: hidden; color: transparent; }
:root[data-side="rail"] .nav-link { justify-content: center; padding: 0; position: relative; }
:root[data-side="rail"] .nav-badge { position: absolute; top: 3px; right: 5px; min-width: 18px; height: 18px; padding: 0 4px; font-size: 10px; margin: 0; }
.side-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--side-border); }
.mini-ring { width: 26px; height: 26px; flex: none; }
.mini-ring .trk { stroke: var(--border); fill: none; stroke-width: 3; }
.mini-ring .val { stroke: var(--accent); fill: none; stroke-width: 3; stroke-linecap: round; transform: rotate(-90deg); transform-origin: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 32px; min-height: var(--topbar-h); background: var(--bg); border-bottom: 1px solid var(--border); }
.m-brand { display: none; }
.topbar-search { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px 0 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); margin: 0; }
.topbar-search:focus-within { border-color: var(--accent); outline: 3px solid var(--accent-soft); }
.topbar-search input { flex: 1; min-width: 0; border: 0; background: none; outline: 0; font: inherit; font-size: 15px; color: var(--text); }
.topbar-search input::placeholder { color: var(--muted); }
.kbd { font: 600 11px/1 var(--font-head); padding: 4px 6px; border-radius: 6px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 44px; height: 44px; padding: 0 10px; border-radius: 12px; color: var(--muted); border: 0; background: none; cursor: pointer; position: relative; font: inherit; font-weight: 700; font-size: 14px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot { position: absolute; top: 10px; right: 11px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.only-m { display: none !important; }
.me { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--on-accent); font: 600 14px/1 var(--font-head); margin-left: 4px; border: 0; cursor: pointer; overflow: hidden; padding: 0; }
.me img { width: 100%; height: 100%; object-fit: cover; }
.menu-toggle { display: none; }
.content { padding: 28px 32px 72px; max-width: 1440px; width: 100%; }

/* theme picker */
.theme-pop { width: 312px; padding: 14px; }
.pop-title { font: 500 13px/1.2 var(--font-head); color: var(--muted); margin: 2px 4px 10px; }
.pop-note { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text); background: var(--surface-2); border-radius: 12px; padding: 10px 12px; margin: 0 0 14px; }
.swatches { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 16px; }
.swatch-btn { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; font-size: 14px; text-align: left; cursor: pointer; }
.swatch-btn:hover { border-color: var(--border-strong); }
.swatch-btn[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.sw-dot { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; color: var(--on-brand); }
.sw-dot [data-lucide], .sw-dot svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; }
.swatch-btn[aria-checked="true"] .sw-dot [data-lucide], .swatch-btn[aria-checked="true"] .sw-dot svg { opacity: 1; }
.sw-violet { background: var(--sw-violet); } .sw-ocean { background: var(--sw-ocean); } .sw-teal { background: var(--sw-teal); }
.sw-green { background: var(--sw-green); } .sw-berry { background: var(--sw-berry); } .sw-graphite { background: var(--sw-graphite); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface-2); }
.mode { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 56px; border-radius: 10px; font: inherit; font-weight: 700; font-size: 13px; color: var(--muted); background: none; border: 0; cursor: pointer; }
.mode[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.pop-link { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; margin-top: 10px; padding: 0 10px; border-radius: 10px; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; text-align: left; }
.pop-link:hover { background: var(--accent-tint); }
.pop-status { margin: 6px 4px 0; font-size: 13px; color: var(--muted); min-height: 0; }
.pop-status:empty { display: none; }

/* mobile tab bar, floating Add lead, More sheet */
.tabbar, .btn.fab { display: none; }  /* .btn.fab: plain .fab lost to .btn's display, so a computer showed it under every page */
dialog.sheet .sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 6px 20px 16px; }
dialog.sheet .sheet-grid a { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 14px; border-radius: 14px; background: var(--surface-2); color: var(--text); font-weight: 700; }
dialog.sheet .sheet-grid a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.sheet-biz { padding: 0 20px 22px; margin: 0; }
.sheet-biz-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; }
.chip-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-header p, .page-subtitle { color: var(--muted); margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; font: inherit; font-weight: 700; font-size: 14px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; transition: background-color .15s, border-color .15s, color .15s; white-space: nowrap; text-decoration: none; line-height: 20px; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-success, .btn-call { background: var(--ok); border-color: var(--ok); color: var(--on-status); }
.btn-success:hover, .btn-call:hover { background: color-mix(in oklab, var(--ok) 86%, var(--text)); border-color: var(--ok); color: var(--on-status); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--on-status); }
.btn-danger:hover { background: color-mix(in oklab, var(--bad) 86%, var(--text)); color: var(--on-status); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--text); }
.btn-soft { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.btn-soft:hover { background: var(--accent-line); color: var(--accent); border-color: transparent; }
.btn-sm { min-height: 34px; padding: 5px 12px; font-size: 13px; border-radius: 10px; }
.btn-lg { min-height: 50px; padding: 12px 22px; font-size: 16px; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; }
.btn-whatsapp { background: var(--wa); border-color: var(--wa); color: var(--p-text-l); }
.btn-whatsapp:hover { background: color-mix(in oklab, var(--wa) 85%, var(--p-text-l)); border-color: var(--wa); color: var(--p-text-l); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-line { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-bad { background: var(--bad); border-color: var(--bad); color: var(--on-status); }
.btn-bad:hover { background: color-mix(in oklab, var(--bad) 86%, var(--text)); border-color: var(--bad); color: var(--on-status); }
.link { color: var(--accent); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--muted); font: inherit; font-weight: 700; font-size: 14px; cursor: pointer; }
.link-btn:hover { color: var(--text); }
.ptag { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px; font: 600 12px/1 var(--font-head); white-space: nowrap; }
.ptag-bad { background: var(--bad-soft); color: var(--bad); border: 1px solid var(--bad-line); }
.ptag-warn { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.ptag-ok { background: var(--ok-soft); color: var(--ok); border: 1px solid var(--ok-line); }
.ptag-n { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow); min-width: 0; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-header h3 { font-size: 17px; }
.card-header p { color: var(--muted); margin: 2px 0 0; font-size: 14px; }
.card-body { padding: 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }
.card + .card { margin-top: 16px; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 20px; box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.stat-value { font: 600 30px/1.15 var(--font-head); margin-top: 8px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: 13px; font-weight: 500; margin-top: 4px; }
.stat-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; float: right; }
.stat-icon.blue { background: var(--primary-50); color: var(--primary); }
.stat-icon.green { background: var(--green-50); color: var(--green); }
.stat-icon.red { background: var(--red-50); color: var(--red); }
.stat-icon.amber { background: var(--amber-50); color: var(--amber); }
.stat-icon.purple { background: var(--purple-50); color: var(--purple); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; font-weight: 700; color: var(--muted); background: var(--surface-2); padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .row-link { color: var(--text); font-weight: 700; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; line-height: 20px; white-space: nowrap; background: var(--gray-100); color: var(--text-2); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.red { background: var(--bad-soft); color: var(--bad); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.purple { background: var(--purple-50); color: var(--purple-700); }
.badge.gray { background: var(--gray-100); color: var(--text-2); }
/* "Customer": bought before, whatever stage they are in now (Workspace.keep_customers, 17 Nov 2026) */
.cust-mark { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 0 7px; border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 18px; vertical-align: 1px; white-space: nowrap; background: var(--ok-soft); color: var(--ok); }
.cust-mark svg { width: 11px; height: 11px; }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-group { margin-bottom: 16px; }
.form-group label, .label { display: block; font-size: 14px; font-weight: 700; color: var(--text-2); margin-bottom: 6px; }
.input, .select, .textarea,
.form-group input[type=text], .form-group input[type=email], .form-group input[type=password], .form-group input[type=number],
.form-group input[type=tel], .form-group input[type=url], .form-group input[type=date], .form-group input[type=datetime-local],
.form-group input[type=time], .form-group select, .form-group textarea {
  width: 100%; min-height: 44px; padding: 10px 14px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; transition: border-color .15s, box-shadow .15s; }
.input:focus, .select:focus, .textarea:focus, .form-group input:focus, .form-group select:focus, .form-group textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.form-group textarea, .textarea { min-height: 96px; resize: vertical; }
.form-group .helptext, .help { display: block; font-size: 13px; color: var(--muted); margin-top: 6px; }
.form-group .errorlist, .errorlist { list-style: none; padding: 0; margin: 6px 0 0; color: var(--bad); font-size: 13px; }
.form-group input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); vertical-align: middle; }
input, select, textarea { color-scheme: inherit; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; padding-top: 8px; }
.choice-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-chips label { margin: 0; }
.choice-chips input { display: none; }
.choice-chips span { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: 999px; cursor: pointer; font-weight: 700; background: var(--surface); color: var(--text); }
.choice-chips input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* ---------- Alerts / messages ---------- */
.alert { padding: 12px 16px; border-radius: 14px; border: 1px solid; margin-bottom: 16px; display: flex; gap: 10px; align-items: flex-start; }
.alert-success { background: var(--ok-soft); border-color: var(--ok-line); color: var(--ok); }
.alert-error, .alert-danger { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); }
.alert-warning { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.alert-info { background: var(--accent-tint); border-color: var(--accent-line); color: var(--text); }
.alert a { font-weight: 700; }

/* ---------- Avatar ---------- */
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--primary-50); color: var(--primary-700); font-weight: 700; font-size: 13px; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-xl { width: 72px; height: 72px; font-size: 26px; }
.person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.person-name { font-weight: 700; color: var(--text); }
.person-sub { font-size: 13px; color: var(--muted); }

/* ---------- Tabs ---------- */
/* the baseline is an inset shadow (not a border) so the strip can scroll sideways without a stray vertical scrollbar */
.tabs { display: flex; gap: 4px; box-shadow: inset 0 -1px 0 var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 700; border-bottom: 2px solid transparent; white-space: nowrap; flex: none; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 12px; overflow: hidden; }
.seg a, .seg button { padding: 8px 14px; font-weight: 700; color: var(--text-2); border: 0; border-right: 1px solid var(--border-strong); background: var(--surface); font: inherit; cursor: pointer; }
.seg a:last-child, .seg button:last-child { border-right: 0; }
.seg .active { background: var(--accent-soft); color: var(--accent); }

/* ---------- Kanban (pipeline) ---------- */
.kanban { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; }
.kanban-col { min-width: 288px; max-width: 288px; background: var(--gray-100); border-radius: var(--radius-lg); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.kanban-col-header { padding: 14px 14px 10px; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.kanban-col-header .count { color: var(--muted); font-weight: 500; }
.kanban-col-header .sum { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 500; }
.kanban-col-color { height: 3px; border-radius: 3px; margin: 0 14px 8px; }
.kanban-list { padding: 0 10px 10px; overflow-y: auto; flex: 1; min-height: 60px; }
.kanban-card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: 12px; padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow-xs); cursor: grab; }
.kanban-card:hover { box-shadow: var(--shadow-md); }
.kanban-card.dragging { opacity: .5; }
.kanban-list.drag-over { background: var(--accent-tint); border-radius: var(--radius); }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 17px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 0 0 20px 52px; }
.timeline-icon { position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); display: grid; place-items: center; color: var(--muted); }
.timeline-icon.blue { border-color: var(--accent-line); color: var(--accent); background: var(--accent-tint); }
.timeline-icon.green { border-color: var(--ok-line); color: var(--ok); background: var(--ok-soft); }
.timeline-icon.red { border-color: var(--bad-line); color: var(--bad); background: var(--bad-soft); }
.timeline-icon.amber { border-color: var(--warn-line); color: var(--warn); background: var(--warn-soft); }
.timeline-icon.purple { border-color: var(--purple-50); color: var(--purple); background: var(--purple-50); }
.timeline-title { font-weight: 700; }
.timeline-meta { font-size: 12px; color: var(--muted); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-icon { width: 56px; height: 56px; border-radius: 18px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin: 0 auto 16px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ---------- Dialog / modal ---------- */
dialog.modal { border: 1px solid var(--border); border-radius: 22px; padding: 0; width: min(560px, 94vw); background: var(--surface); color: var(--text); box-shadow: var(--shadow-pop); }
dialog.modal::backdrop { background: var(--scrim); backdrop-filter: blur(3px); }
.modal-header { padding: 20px 24px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Steps (call flow) ---------- */
.steps { display: flex; gap: 8px; margin-bottom: 20px; }
.step { flex: 1; padding: 10px 12px; border-top: 4px solid var(--border); color: var(--muted); font-size: 13px; font-weight: 700; }
.step.done { border-color: var(--ok); color: var(--ok); }
.step.current { border-color: var(--accent); color: var(--accent); }

/* ---------- Dropdown / popover ---------- */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 8px; display: none; z-index: 60; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-head { display: flex; flex-direction: column; padding: 6px 10px 10px; min-width: 0; }
.dropdown-head small { color: var(--muted); font-size: 13px; }
.dropdown-item { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 0 10px; border-radius: 10px; color: var(--text); font-weight: 700; font-size: 14px; width: 100%; background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-item[aria-current="true"] { color: var(--accent); }
.dropdown-divider { height: 1px; background: var(--border); margin: 6px 0; }

/* ---------- Utilities ---------- */
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-sidebar { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 360px; }
.grid-sidebar-left { display: grid; gap: 20px; grid-template-columns: 340px minmax(0, 1fr); }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .wrap { flex-wrap: wrap; }
.ml-auto { margin-left: auto; } .mt-0 { margin-top: 0; } .mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.m-0 { margin: 0; } .d-block { display: block; }
.p-0 { padding: 0 !important; }
.text-muted { color: var(--muted); } .text-sm { font-size: 13px; } .text-xs { font-size: 12px; } .text-lg { font-size: 16px; } .text-2 { color: var(--text-2); }
.text-right { text-align: right; } .text-center { text-align: center; }
.text-red { color: var(--bad); } .text-green { color: var(--ok); } .text-amber { color: var(--warn); } .text-primary { color: var(--accent); }
.fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; color: var(--text); font-weight: 500; word-break: break-word; }
.code, pre.code { font-family: var(--font-mono); font-size: 13px; background: var(--code-bg); color: var(--code-fg); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; }
code { font-family: var(--font-mono); font-size: 0.92em; background: var(--gray-100); padding: 1px 6px; border-radius: 4px; }
pre.code code { background: none; padding: 0; color: inherit; }
.progress { height: 8px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 48px; max-width: 480px; margin: 0 auto; width: 100%; }
.auth-panel .logo { height: 36px; margin-bottom: 40px; color: var(--text); }
.auth-panel h1 { font-size: 30px; margin-bottom: 8px; }
.auth-side { background: linear-gradient(135deg, var(--dark-surface) 0%, color-mix(in oklab, var(--dark-surface) 70%, var(--accent)) 60%, var(--accent) 140%); color: var(--sidebar-strong); padding: 64px; display: flex; flex-direction: column; justify-content: center; }
.auth-side h2 { color: var(--sidebar-strong); font-size: 34px; line-height: 1.2; margin-bottom: 16px; }
.auth-side p { color: var(--sidebar-text); font-size: 16px; }

/* contact photos as avatars in lists, queue rows and pipeline cards */
.q-person { display: inline-flex; align-items: center; gap: 8px; }
.kanban-card .kc-top > .avatar + div { flex: 1; }

/* stage menu (contacts + follow-ups lists): one coloured pill per stage, with its count */
.stage-bar-hint { display: flex; align-items: center; gap: 6px; margin: 0; padding: 8px 16px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.stage-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.stage-bar-biz { font-size: 12px; font-weight: 700; color: var(--c); margin-right: 4px; }
.sb-pill { --c: var(--accent); display: inline-flex; align-items: center; gap: 7px; padding: 7px 8px 7px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; text-decoration: none;
  color: color-mix(in srgb, var(--c) 70%, var(--text)); background: color-mix(in srgb, var(--c) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 28%, var(--surface)); transition: background .15s, transform .15s; }
.sb-pill:hover { background: color-mix(in srgb, var(--c) 18%, var(--surface)); color: color-mix(in srgb, var(--c) 75%, var(--text)); transform: translateY(-1px); }
.sb-pill b { min-width: 24px; padding: 1px 8px; border-radius: 999px; text-align: center; font-size: 12px; background: var(--surface); color: color-mix(in srgb, var(--c) 75%, var(--text)); }
.sb-pill.on { background: var(--c); border-color: var(--c); color: var(--on-brand); box-shadow: 0 2px 8px color-mix(in srgb, var(--c) 35%, transparent); }
.sb-pill.on b { color: color-mix(in srgb, var(--c) 85%, var(--p-text-l)); background: var(--on-brand); }
.sb-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.sb-pill.on .sb-dot { background: var(--on-brand); }
.sb-pill.sb-all.on { color: var(--surface); }

/* Help lives in the sidebar footer now; the help panel still opens with the ? key */
body .hc-fab { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .grid-sidebar, .grid-sidebar-left { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar .lbl { display: none; }
}
@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}
@media (max-width: 760px) {
  :root { --pwa-tabbar-h: 72px; --topbar-h: 60px; }
  body { font-size: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .topbar { padding: 8px 16px; min-height: var(--topbar-h); gap: 6px; }
  .topbar-search, .add-lead, .topbar .lbl, .topbar .kbd { display: none; }
  .only-m { display: inline-flex !important; }
  .m-brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; min-height: 44px; padding: 0 4px; border-radius: 12px; text-align: left; background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; }
  .m-brand img { width: 28px; height: 28px; border-radius: 8px; }
  .m-brand b { font: 600 16px/1.2 var(--font-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .m-brand [data-lucide], .m-brand svg { color: var(--muted); }
  .topbar-actions { margin-left: 0; gap: 0; }
  .me { width: 36px; height: 36px; margin-left: 2px; }
  .theme-pop { position: fixed; top: 64px; left: 16px; right: 16px; width: auto; }
  .content { padding: 18px 16px 150px; }
  .tabbar { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
  .tb-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 56px; border-radius: 12px; font: inherit; font-size: 12px; font-weight: 700; color: var(--muted); position: relative; background: none; border: 0; cursor: pointer; }
  .tb-tab.active { color: var(--accent); background: var(--accent-soft); }
  .tb-tab [data-lucide], .tb-tab svg { width: 22px; height: 22px; }
  .tb-tab .nav-badge { position: absolute; top: 2px; left: calc(50% + 6px); height: 20px; min-width: 20px; padding: 0 5px; font-size: 11px; margin: 0; }
  .btn.fab { display: inline-flex; position: fixed; z-index: 41; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); box-shadow: var(--shadow-pop); border-radius: 16px; min-height: 52px; }
  .page-inbox .content { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .page-inbox .btn.fab { display: none; }
  dialog.modal.sheet { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 22px 22px 0 0; border-bottom: 0; }
  .form-group input, .form-group select, .form-group textarea, .input, .select, .textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
/* phone: the pipeline stages are one row you swipe sideways (like Messenger's filter row), not five rows of pills */
@media (max-width: 760px) {
  .stage-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding: 10px 14px; gap: 6px; scroll-snap-type: x proximity; }
  .stage-bar::-webkit-scrollbar { display: none; }
  .stage-bar > * { flex: none; scroll-snap-align: start; }
  .sb-pill { padding: 5px 6px 5px 10px; font-size: 12.5px; }
}
@media (max-width: 760px) {
  .stage-bar-hint { display: block; padding: 6px 14px; line-height: 1.45; }
  .stage-bar-hint svg { display: inline-block; vertical-align: -2px; margin-right: 4px; }
}

/* "Open in which WhatsApp?" on an Android phone (app.js; owner, 15 Nov 2026) */
.wa-pick { position: fixed; inset: 0; z-index: 200; display: flex; align-items: flex-end; justify-content: center; background: var(--scrim); }
.wa-pick-box { width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 10px; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 20px 20px 0 0; background: var(--surface); box-shadow: var(--shadow-md); }
.wa-pick-box > b { font-size: 16px; padding: 0 4px 2px; }
.wa-pick-btn { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 14px; background: var(--wa); color: var(--on-brand); text-decoration: none; }
.wa-pick-btn + .wa-pick-btn { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.wa-pick-btn span { font-size: 16px; font-weight: 700; }
.wa-pick-btn small { font-size: 12.5px; opacity: .85; }
.wa-pick-cancel { height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font-size: 15px; }
