/* ==========================================================================
   AEx Lead Desk — design system
   Tokens on :root (light) and [data-theme="dark"]. Inter, 4 px grid,
   10 px card radius, 8 px input radius, shadows only on overlays.
   ========================================================================== */

:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --surface-2: #eceeea;
  --border: #d8dbd5;
  --text: #0b0d0e;
  --muted: #5c6360;
  --accent: #98ff03;
  --accent-ink: #0b0d0e;
  --accent-soft: #e9ffbf;
  --success: #1f8a4c;
  --warning: #b7791f;
  --danger: #c0392b;
  --info: #2563eb;
  --success-soft: #dff5e6;
  --warning-soft: #fdf1d7;
  --danger-soft: #fbe3df;
  --info-soft: #dfe8fb;
  --focus: #2563eb;
  --shadow: 0 12px 32px rgba(11, 13, 14, 0.18);
  --radius: 10px;
  --radius-sm: 8px;
  --sidebar-w: 232px;
  --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;
  --t: 160ms;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b0d0e;
  --surface: #141718;
  --surface-2: #1d2124;
  --border: #2a2f33;
  --text: #f2f4f1;
  --muted: #9aa39e;
  --accent: #98ff03;
  --accent-ink: #0b0d0e;
  --accent-soft: #223300;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --success-soft: #11291b;
  --warning-soft: #30250b;
  --danger-soft: #331716;
  --info-soft: #14223a;
  --focus: #98ff03;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ----- reset and base ----------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 24px; } h2 { font-size: 20px; } h3 { font-size: 16px; } h4 { font-size: 14px; margin: 16px 0 8px; }
p { margin: 0 0 8px; }
a { color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
kbd { font-family: inherit; font-size: 11px; padding: 1px 5px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); color: var(--muted); line-height: 1.2; }
.num, .stat-value, .timer, td.num, .table .num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.prose p { margin-bottom: 6px; }
svg.lucide, i[data-lucide] { width: 16px; height: 16px; flex: 0 0 auto; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 100; }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ----- shell ----------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; transition: grid-template-columns var(--t) ease; }
.shell.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--surface); border-right: 1px solid var(--border); overflow: hidden; }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; height: var(--topbar-h); padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); }
.brand-link { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.wordmark { font-weight: 500; white-space: nowrap; font-size: 16px; }
.wordmark strong { font-weight: 700; }
.nav { display: flex; flex-direction: column; padding: 12px 8px; gap: 2px; flex: 1; overflow-y: auto; }
.nav-group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 10px 10px 4px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); text-decoration: none; color: var(--text); background: transparent; border: 0; width: 100%; text-align: left; cursor: pointer; white-space: nowrap; transition: background var(--t); }
.nav-item:hover { background: var(--surface-2); }
.nav-item.is-active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.nav-item.is-active i { color: var(--accent-ink); }
.sidebar-foot { padding: 8px; border-top: 1px solid var(--border); }
.sidebar-collapsed .sidebar .wordmark, .sidebar-collapsed .nav-item span, .sidebar-collapsed .nav-group-label { display: none; }
.sidebar-collapsed .sidebar-brand { padding: 0 8px; justify-content: center; }
.sidebar-collapsed .sidebar-brand .brand-link { display: none; }
.sidebar-collapsed .nav-item { justify-content: center; }
.shell-main { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: var(--topbar-h); padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-title { font-size: 16px; font-weight: 600; flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-menu { display: none; }
.search-trigger { display: flex; align-items: center; gap: 8px; margin-left: auto; padding: 6px 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--muted); cursor: text; min-width: 200px; }
.search-trigger kbd { margin-left: auto; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.content { padding: 20px; display: flex; flex-direction: column; gap: 16px; flex: 1; }
.footer { padding: 12px 20px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); text-align: center; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ----- cards, grids ------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { display: flex; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.stat-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 20px; font-weight: 600; }
.stat-value.big { font-size: 24px; }
.stat.is-warning { background: var(--warning-soft); }
.stat.is-danger { background: var(--danger-soft); }
.stat.is-success { background: var(--success-soft); }
.stat-sub { font-size: 12px; color: var(--muted); }
.chart-wrap { position: relative; width: 100%; min-height: 160px; }

/* ----- buttons ------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 500; cursor: pointer; text-decoration: none; line-height: 1.2; transition: background var(--t), border-color var(--t), transform var(--t); white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: #a9ff33; }
.btn-secondary { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-secondary:hover:not(:disabled) { border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn kbd { margin-left: 4px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--text); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--surface-2); }
.segmented { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 2px; }
.segmented button { border: 0; background: transparent; padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 500; }
.segmented button.is-active { background: var(--surface); color: var(--text); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; background: transparent; padding: 10px 12px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.is-active { color: var(--text); border-bottom-color: var(--accent); }

/* ----- forms ------------------------------------------------------------------------ */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 500; color: var(--muted); }
.field small { font-size: 11px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], input[type="date"], input[type="time"], input[type="datetime-local"], input[type="url"], input:not([type]), select, textarea {
  width: 100%; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); min-height: 36px;
}
textarea { resize: vertical; min-height: 60px; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }
.input-sm { min-height: 30px !important; padding: 4px 8px !important; font-size: 12px; width: auto !important; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 2px; accent-color: #5a9900; }
.check.inline { display: inline-flex; margin-right: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { width: auto; min-width: 140px; }
.filters input[type="search"] { flex: 1 1 220px; }

/* ----- chips and badges --------------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text); line-height: 1.4; white-space: nowrap; }
.chip-status { font-size: 11px; }
.chip-pending_ai { background: var(--surface-2); color: var(--muted); }
.chip-ai_queued { background: var(--info-soft); color: var(--info); }
.chip-ready { background: var(--success-soft); color: var(--success); }
.chip-review { background: var(--warning-soft); color: var(--warning); }
.chip-rejected { background: var(--danger-soft); color: var(--danger); }
.chip-assigned { background: var(--info-soft); color: var(--info); }
.chip-working { background: #e8e4ff; color: #5b43d6; }
[data-theme="dark"] .chip-working { background: #221c45; color: #a99cff; }
.chip-callback { background: #f3e3ff; color: #8e3cc7; }
[data-theme="dark"] .chip-callback { background: #2e1a3c; color: #d7a2ff; }
.chip-demo_booked { background: var(--accent-soft); color: #3f6b00; }
[data-theme="dark"] .chip-demo_booked { color: var(--accent); }
.chip-won { background: var(--success); color: #fff; }
.chip-lost { background: var(--danger-soft); color: var(--danger); }
.chip-not_interested { background: var(--surface-2); color: var(--muted); }
.chip-bad_number { background: var(--danger-soft); color: var(--danger); }
.chip-dnc { background: var(--danger); color: #fff; }
.chip-exhausted { background: var(--surface-2); color: var(--muted); }
.badge-score { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; padding: 2px 6px; border-radius: 6px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; background: var(--surface-2); }
.badge-score.hi { background: var(--accent); color: var(--accent-ink); }
.badge-score.mid { background: var(--warning-soft); color: var(--warning); }
.badge-score.lo { background: var(--surface-2); color: var(--muted); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin: 0 4px 0 6px; }
.dot-good { background: var(--success); } .dot-edge { background: var(--warning); } .dot-outside { background: var(--muted); opacity: .6; }
.presence { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.presence-online { background: var(--success); } .presence-idle { background: var(--warning); } .presence-offline { background: var(--muted); opacity: .5; }

/* ----- banners, toasts, modals, dropdowns ------------------------------------------------ */
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; }
.banner i { margin-top: 2px; }
.banner-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }
.banner-danger { background: var(--danger-soft); color: var(--danger); }
.banner-success { background: var(--success-soft); color: var(--success); }
.banner-info { background: var(--info-soft); color: var(--info); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); animation: toast-in var(--t) ease; }
.toast-success { border-left: 4px solid var(--success); } .toast-error { border-left: 4px solid var(--danger); } .toast-info { border-left: 4px solid var(--info); }
.toast .btn { margin-left: auto; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; display: flex; flex-direction: column; }
.modal-wide { width: min(860px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(520px, 100%); background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow); z-index: 51; overflow: auto; padding: 16px; }
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px; z-index: 30; }
.dropdown-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; border: 0; background: transparent; border-radius: 6px; text-decoration: none; cursor: pointer; text-align: left; color: var(--text); }
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-info { padding: 8px 10px; font-size: 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 4px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.user-btn:hover { background: var(--surface-2); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 12px; }
.notif-badge { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.notif-menu { width: 340px; max-width: calc(100vw - 32px); }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 8px; }
.notif-list { max-height: 360px; overflow: auto; }
.notif-item { display: block; padding: 8px 10px; border-radius: 6px; font-size: 13px; text-decoration: none; color: var(--text); }
.notif-item.unread { background: var(--surface-2); }
.notif-item .muted { display: block; font-size: 11px; }
.tooltip { position: fixed; z-index: 70; background: var(--text); color: var(--bg); padding: 4px 8px; border-radius: 6px; font-size: 12px; pointer-events: none; box-shadow: var(--shadow); }

/* ----- command palette ------------------------------------------------------------------------- */
.palette { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 55; display: flex; align-items: flex-start; justify-content: center; padding: 10vh 16px 16px; }
.palette-box { width: min(620px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.palette-input-wrap { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.palette-input-wrap input { border: 0; background: transparent; font-size: 16px; min-height: 40px; }
.palette-input-wrap input:focus { box-shadow: none; }
.palette-results { max-height: 50vh; overflow: auto; padding: 6px; }
.palette-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; text-decoration: none; color: var(--text); }
.palette-item.is-active, .palette-item:hover { background: var(--surface-2); }
.palette-item .muted { margin-left: auto; font-size: 12px; }
.palette-hint { padding: 6px 12px; border-top: 1px solid var(--border); font-size: 11px; color: var(--muted); display: flex; gap: 6px; align-items: center; }

/* ----- tables ----------------------------------------------------------------------------------- */
.table-card { padding: 0; overflow: hidden; }
.table-card .card-head { padding: 12px 16px 0; }
.table-card > p { padding: 0 16px 12px; }
.table-wrap { overflow: auto; max-height: 70vh; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; z-index: 1; }
.table th[data-sort] { cursor: pointer; }
.table th[data-sort]::after { content: " ↕"; opacity: .4; }
.table th.sorted-asc::after { content: " ↑"; opacity: 1; } .table th.sorted-desc::after { content: " ↓"; opacity: 1; }
.table td { padding: 8px 12px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.table-sm th, .table-sm td { padding: 6px 8px; }
.table .w-check { width: 32px; }
.table a { text-decoration: none; font-weight: 500; }
.table a:hover { text-decoration: underline; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.pagination { display: flex; gap: 4px; flex-wrap: wrap; }
.page-link { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--border); text-decoration: none; cursor: pointer; background: transparent; color: var(--text); font-size: 12px; }
.page-link.is-active { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.bulk-bar { padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); margin: 0 !important; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width var(--t); }
.progress-bar.is-amber { background: var(--warning); }
.mini-progress { display: inline-block; width: 90px; height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.mini-progress > span { display: block; height: 100%; background: var(--accent); }

/* ----- skeletons and empty states -------------------------------------------------------------- */
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite linear; margin: 6px 0; }
.skeleton.tall { height: 60px; }
.skeleton-list { padding: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 32px 16px; color: var(--muted); }
.empty-state i { width: 32px; height: 32px; }
.empty-state.small { padding: 12px; font-size: 12px; }
.page-empty { min-height: 50vh; }
.empty-state h2 { color: var(--text); }

/* ----- Today workspace ------------------------------------------------------------------------------ */
.today { display: flex; flex-direction: column; gap: 16px; }
.today-header { display: flex; flex-direction: column; gap: 12px; }
.today-greeting { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.ring-wrap { position: relative; width: 72px; height: 72px; flex: 0 0 auto; }
.ring { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--surface-2); stroke-width: 8; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 400ms ease; }
.ring-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-text strong { font-size: 18px; } .ring-text span { font-size: 11px; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.stat-row .stat { padding: 8px 10px; }
.stat-row .stat-value { font-size: 18px; }
.due-list { display: flex; flex-direction: column; gap: 6px; }
.due-item { display: grid; grid-template-columns: auto 1fr auto auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; border: 1px solid transparent; }
.due-item:hover { border-color: var(--border); }
.due-item.is-overdue { background: var(--danger-soft); }
.due-item.is-overdue .due-time { color: var(--danger); font-weight: 600; }
.due-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.due-type { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.workspace { display: grid; grid-template-columns: 280px minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.workspace > *, .lead-page-grid > *, .grid-2 > *, .grid-3 > *, .dash-top > *, .queue-item > span { min-width: 0; }
.queue { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; max-height: calc(100vh - var(--topbar-h) - 32px); padding: 12px; }
.queue-legend { margin-bottom: 6px; }
.queue-list { overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.queue-item { display: grid; grid-template-columns: 10px 1fr auto; gap: 8px; align-items: center; padding: 8px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; text-align: left; background: transparent; width: 100%; }
.queue-item:hover { background: var(--surface-2); }
.queue-item.is-active { background: var(--accent-soft); border-color: var(--accent); }
[data-theme="dark"] .queue-item.is-active { background: var(--accent-soft); }
.queue-item .q-name { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item .q-sub { display: block; font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item .q-dot { width: 8px; height: 8px; border-radius: 50%; }
.q-dot.good { background: var(--success); } .q-dot.edge { background: var(--warning); } .q-dot.outside { background: var(--muted); opacity: .5; }
.queue-item.is-done { opacity: .5; }
.queue-foot { padding-top: 8px; }
.tag { display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 4px; background: var(--surface-2); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-left: 4px; vertical-align: middle; }
.leadcard { min-height: 400px; }
.lc-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.lc-title { font-size: 20px; font-weight: 600; }
.lc-sub { color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; font-size: 13px; }
.lc-time { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.lc-phone { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.lc-phone .phone { font-size: 32px; font-weight: 600; letter-spacing: .01em; font-variant-numeric: tabular-nums; }
.lc-phone .ext { font-size: 14px; color: var(--muted); }
.lc-warning { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warning-soft); color: var(--warning); font-size: 13px; margin-bottom: 12px; }
.lc-meta { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.lc-meta a { color: var(--text); }
.ai-block { background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.ai-block .ai-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.ai-block .ai-head h4 { margin: 0; display: flex; align-items: center; gap: 6px; }
.ai-block ul { margin: 0; padding-left: 18px; }
.ai-block li { margin: 2px 0; }
.ai-opener { padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--surface); border-radius: 6px; font-size: 15px; }
.ai-sources { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; }
.ai-sources a { color: var(--muted); text-decoration: none; border: 1px solid var(--border); padding: 1px 6px; border-radius: 999px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tools { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 6px; }
.tool-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
.tool-panel[hidden] { display: none; }
.script-stage { border: 1px solid var(--border); border-radius: var(--radius-sm); }
.script-stage summary { cursor: pointer; padding: 8px 10px; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; }
.script-stage summary::-webkit-details-marker { display: none; }
.script-stage summary::before { content: "▸"; color: var(--muted); }
.script-stage[open] summary::before { content: "▾"; }
.script-body { padding: 0 10px 10px; white-space: pre-wrap; font-size: 15px; line-height: 1.5; }
.discovery-q { display: grid; grid-template-columns: auto 1fr; gap: 8px; align-items: start; padding: 6px 10px; }
.discovery-q .q-text { font-weight: 500; }
.discovery-q .q-hint { font-size: 12px; color: var(--muted); }
.discovery-q input[type="text"] { margin-top: 4px; min-height: 30px; padding: 4px 8px; font-size: 13px; }
.objection-list { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.objection-item { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.objection-item strong { display: block; }
.ai-answer { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 15px; white-space: pre-wrap; }
.calc-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.calc-result { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.history { margin-top: 16px; }
.history-item { display: grid; grid-template-columns: auto 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.history-item .when { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.history-item .notes { white-space: pre-wrap; color: var(--muted); }
.history-item.manager { background: var(--info-soft); padding: 8px; border-radius: var(--radius-sm); border: 0; }
.outcome { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 12px; }
.outcome-buttons { display: grid; grid-template-columns: 1fr; gap: 6px; }
.btn-outcome { justify-content: flex-start; background: var(--surface-2); border-color: var(--border); padding: 7px 10px; }
.btn-outcome:hover:not(:disabled) { border-color: var(--muted); }
.btn-outcome.is-selected { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-outcome.is-selected kbd { color: var(--accent-ink); background: rgba(255, 255, 255, .5); border-color: transparent; }
.btn-outcome-good:not(.is-selected) { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.btn-outcome-bad:not(.is-selected) { color: var(--danger); }
.outcome-extra { display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); }
.outcome-actions { display: flex; flex-direction: column; gap: 8px; }
.timer { font-size: 14px; color: var(--muted); }
.timer.is-running { color: var(--success); font-weight: 600; }
.leaderboard-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.lb-row { display: grid; grid-template-columns: 24px 1fr auto; gap: 8px; align-items: center; padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); }
.lb-rank { font-weight: 700; color: var(--muted); }
.lb-name { font-weight: 500; }
.lb-stats { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.lb-row.is-me { outline: 2px solid var(--accent); }
.badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); font-size: 12px; }
.badge strong { font-weight: 600; }
.celebrate { position: fixed; inset: 0; pointer-events: none; z-index: 65; display: flex; align-items: center; justify-content: center; }
.celebrate .msg { background: var(--accent); color: var(--accent-ink); padding: 16px 24px; border-radius: var(--radius); font-size: 20px; font-weight: 700; box-shadow: var(--shadow); animation: pop 600ms ease; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.05); opacity: 1; } 100% { transform: scale(1); } }
.confetti { position: absolute; width: 8px; height: 12px; top: -20px; animation: fall 1.6s linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); opacity: 0; } }

/* ----- lead page, review, kanban, follow-ups ------------------------------------------------------- */
.lead-page-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.notes-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.note { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; white-space: pre-wrap; }
.note .meta { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.review-list { display: flex; flex-direction: column; gap: 12px; }
.review-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: start; }
.review-item .ai-block { margin-top: 8px; }
.review-actions { display: flex; flex-direction: column; gap: 6px; min-width: 120px; }
.kanban { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.kanban-col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 240px; }
.kanban-col.is-over { outline: 2px dashed var(--accent); }
.kanban-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; cursor: grab; }
.kanban-card:active { cursor: grabbing; }
.kanban-card.is-dragging { opacity: .5; }
.kanban-card .k-name { font-weight: 500; }
.kanban-card .k-sub { font-size: 12px; color: var(--muted); }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(140px, 1fr)); gap: 8px; overflow-x: auto; }
.week-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; min-height: 160px; }
.week-day.is-today { border-color: var(--accent); }
.week-day h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); }
.fu-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--border); font-size: 13px; }
.fu-item.is-overdue .fu-time { color: var(--danger); font-weight: 600; }
.fu-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.fu-mini { font-size: 12px; padding: 4px 6px; border-radius: 6px; background: var(--surface-2); margin-bottom: 4px; cursor: pointer; }
.fu-mini.is-overdue { background: var(--danger-soft); }
.resource-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.resource-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); flex-wrap: wrap; }
.content-list { display: flex; flex-direction: column; gap: 8px; }
.content-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 10px 12px; background: var(--surface-2); border-radius: var(--radius-sm); align-items: start; }
.content-item .body { white-space: pre-wrap; font-size: 13px; color: var(--muted); margin-top: 2px; }
.content-item.is-inactive { opacity: .55; }
.heartbeat { display: flex; align-items: center; gap: 10px; }
.heartbeat .pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--success); }
.heartbeat.is-amber .pulse { background: var(--warning); }
.heartbeat.is-never .pulse { background: var(--danger); }
.ai-status { margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.dash-top { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.steps { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; flex-wrap: wrap; counter-reset: step; }
.steps li { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); font-size: 12px; color: var(--muted); }
.steps li.is-active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.steps li.is-done { color: var(--success); }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); transition: border-color var(--t), background var(--t); }
.dropzone:hover, .dropzone.is-over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.dropzone i { width: 32px; height: 32px; }
.estimate { margin: 8px 0; }
.wizard { display: flex; flex-direction: column; gap: 16px; }
.prompt-editor textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.5; }
.rep-meta { margin-top: 10px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tour { position: fixed; z-index: 58; width: min(360px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.tour-step { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tour h4 { margin: 4px 0 6px; }
.tour-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.tour-target { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: var(--radius); }

/* ----- auth ------------------------------------------------------------------------------------------ */
.auth-body { display: flex; flex-direction: column; min-height: 100vh; }
.auth-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 24px 16px; }
.auth-brand { display: flex; align-items: center; gap: 10px; }
.auth-brand .wordmark { font-size: 20px; }
.auth-card { width: min(400px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.auth-title { font-size: 24px; }

/* ----- responsive --------------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .workspace { grid-template-columns: 240px minmax(0, 1fr); }
  .outcome { grid-column: 1 / -1; position: static; }
  .outcome-buttons { grid-template-columns: repeat(3, 1fr); }
  .stat-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform var(--t) ease; z-index: 40; box-shadow: var(--shadow); }
  .shell.sidebar-open .sidebar { transform: none; }
  .sidebar-toggle { display: none; }
  .topbar-menu { display: inline-flex; }
  .shell.sidebar-collapsed .sidebar .wordmark, .shell.sidebar-collapsed .nav-item span, .shell.sidebar-collapsed .nav-group-label { display: initial; }
  .shell.sidebar-collapsed .sidebar-brand .brand-link { display: flex; }
  .shell.sidebar-collapsed .nav-item { justify-content: flex-start; }
  .workspace { grid-template-columns: 1fr; }
  .queue { position: static; max-height: 320px; }
  .grid-2, .grid-3, .dash-top, .lead-page-grid { grid-template-columns: 1fr; }
  .stat-grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .review-item { grid-template-columns: auto minmax(0, 1fr); }
  .review-actions { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; }
  .content { padding: 16px; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .search-trigger { min-width: 0; padding: 6px; }
}
@media (max-width: 480px) {
  .content { padding: 12px; gap: 12px; }
  .card { padding: 12px; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-grid-6, .stat-grid-4, .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lc-phone .phone { font-size: 24px; }
  .outcome-buttons { grid-template-columns: 1fr 1fr; }
  .btn-outcome { font-size: 12px; padding: 7px 8px; }
  .btn-outcome kbd { display: none; }
  .user-name { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-title { font-size: 14px; }
  .calc-grid { grid-template-columns: 1fr; }
  .filters input, .filters select { min-width: 0; flex: 1 1 45%; }
  .kanban { grid-template-columns: repeat(5, 220px); }
  .week-grid { grid-template-columns: repeat(7, 160px); }
  .due-item { grid-template-columns: 1fr auto; }
  .due-item .due-type { display: none; }
  .modal-foot { flex-wrap: wrap; }
  .toasts { right: 8px; left: 8px; bottom: 8px; max-width: none; }
  .table th, .table td { padding: 6px 8px; }
  .lb-row { grid-template-columns: 20px 1fr auto; }
}
@media print {
  .sidebar, .topbar, .outcome, .toasts, .footer { display: none !important; }
  .shell { display: block; }
}
