/* Kallikrates CRM panel.
   Direction: the firm's front desk and its docket files. Graphite neutral surfaces (people work here
   for hours), off-white/ink primary actions, one warm amber accent for high intent, the current week
   and focus. Signature: the hairline route with dot ends, plus mono for phones, times and references. */

@font-face { font-family: "Instrument Sans"; src: url("/static/fonts/instrument-sans.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/static/fonts/ibm-plex-mono-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/static/fonts/ibm-plex-mono-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  /* Graphite ramp, light */
  --deep: #f4f4f5;          /* sidebar */
  --bg: #fafafa;            /* page */
  --surface: #ffffff;       /* card */
  --surface-2: #f4f4f5;     /* raised: active row, input fill, header */
  --text: #171717;
  --text-2: #525252;
  --muted: #737373;
  --border: rgba(23, 23, 23, .09);
  --border-strong: #b5b5b5;  /* control borders, 3:1 on white */
  --accent: #a16207;         /* warm amber, text-safe on light */
  --accent-dot: #d08a1c;
  --primary-bg: #171717;
  --primary-fg: #fafafa;
  --primary-hover: #2b2b2b;
  --danger: #c0362c;
  --danger-soft: #fdf1f0;
  --ok: #16794a;
  --ok-soft: #eef7f2;
  --chart: #c7c7c9;
  --track: #ededee;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, .08);
  --radius: 12px;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  /* Practice markers (identity only) */
  --kcs: #1f4e79; --kcpee: #6b2c5a; --startlex: #1d5c4a;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --deep: #0f0f10;
    --bg: #141415;
    --surface: #19191b;
    --surface-2: #232325;
    --text: #ededed;
    --text-2: #a1a1a6;
    --muted: #85858b;
    --border: rgba(237, 237, 237, .08);
    --border-strong: #4a4a4f;
    --accent: #e0a54c;
    --accent-dot: #e0a54c;
    --primary-bg: #ededed;
    --primary-fg: #141415;
    --primary-hover: #d6d6d6;
    --danger: #e5675f;
    --danger-soft: #2a1716;
    --ok: #4cc38a;
    --ok-soft: #12241b;
    --chart: #3d3d41;
    --track: #232325;
    --shadow: none;
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);
    --kcs: #8fb8e0; --kcpee: #d9a6cb; --startlex: #86c9b0;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
body.no-scroll { overflow: hidden; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
h1 { font-size: 24px; font-weight: 500; line-height: 1.25; margin: 0; }
h2 { font-size: 15px; font-weight: 500; margin: 0; }
h3 { font-size: 14px; font-weight: 500; margin: 0; }
p { margin: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .strong { font-weight: 500; } .warn { color: var(--accent); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px; }
.break { word-break: break-all; } .grow { flex: 1; min-width: 0; } .right { text-align: right; display: grid; gap: 4px; justify-items: end; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pre { white-space: pre-wrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.icon { flex: none; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

/* ---------- layout ---------- */
.panel { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--deep); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 16px 12px; gap: 16px; }
.brandmark { display: flex; align-items: baseline; gap: 8px; padding: 4px 8px; }
.logo-mark { display: none; }
.logo-name { font-size: 16px; font-weight: 600; color: var(--text); }
.logo-sub { font-size: 13px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-section { font-size: 12px; color: var(--muted); padding: 24px 8px 8px; }
.nav-section:first-child { padding-top: 8px; }
.nav a { display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 8px; border-radius: 8px; color: var(--text-2); text-decoration: none; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.nav a .icon { color: var(--muted); }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border), var(--shadow); }
.nav a.active .icon { color: var(--text); }
.nav-text { flex: 1; }
.nav .count { font-family: var(--mono); font-size: 12px; color: var(--muted); background: none; padding: 0; }
.nav .count.danger { color: var(--danger); }
.sidebar-foot { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.me { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-decoration: none; color: inherit; padding: 4px; border-radius: 8px; }
.me:hover { background: var(--surface-2); }
.me-name { font-weight: 500; font-size: 14px; }
.me-role { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.me-role::first-letter { text-transform: uppercase; }
.sidebar .icon-btn { border-color: transparent; background: transparent; }
.sidebar .icon-btn:hover { background: var(--surface-2); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 60px; padding: 0 32px; background: var(--bg); border-bottom: 1px solid var(--border); }
.topbar .menu-btn { display: none; }
.search { position: relative; display: flex; align-items: center; gap: 8px; flex: 1; max-width: 520px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0 12px; color: var(--muted); transition: border-color 150ms var(--ease); }
.search:focus-within { border-color: var(--border-strong); }
.search input:not([type=checkbox]):not([type=radio]) { border: 0; background: transparent; box-shadow: none; padding: 0; height: 36px; flex: 1; min-width: 0; outline: none; color: var(--text); min-height: 36px; }
.search.inline { flex: 1 1 280px; max-width: none; }
.search-results { position: absolute; top: calc(100% + 8px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 4px; z-index: 30; }
.search-item { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 8px 12px; border-radius: 8px; color: var(--text); cursor: pointer; }
.search-item:hover, .search-item:focus { background: var(--surface-2); }
.search-empty { padding: 8px 12px; }
.view { padding: 32px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; align-content: start; max-width: 1520px; width: 100%; outline: none; }
.scrim { display: none; }

/* ---------- controls ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 12px; min-height: 36px; width: 100%; color: var(--text);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--text-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
textarea { resize: vertical; }
select.active { border-color: var(--text-2); background: var(--surface-2); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 0 16px; height: 36px; cursor: pointer; font-weight: 500; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow);
  transition: background-color 150ms var(--ease), border-color 150ms var(--ease), color 150ms var(--ease), transform 120ms var(--ease);
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn .icon { color: inherit; }
.btn.primary { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary-soft { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.primary-soft:hover { background: var(--surface-2); }
.btn.ghost-danger { border-color: var(--border); color: var(--danger); background: transparent; box-shadow: none; }
.btn.ghost-danger:hover { background: var(--danger-soft); }
.btn.small { padding: 0 12px; height: 28px; font-size: 13px; }
.btn.block { width: 100%; height: 40px; }
.btn.link, button.link { border: 0; background: none; box-shadow: none; color: var(--text); padding: 0; height: auto; min-height: 0; cursor: pointer; font-weight: 500; text-align: left; text-decoration: underline; text-decoration-color: var(--border-strong); }
.btn.link:hover, button.link:hover { text-decoration-color: currentColor; background: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text-2); transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row input, .row select { width: auto; }
.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check input { margin-top: 2px; width: 16px; height: 16px; accent-color: var(--text); flex: none; }

/* ---------- page furniture ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; }
.page-head p { margin-top: 4px; max-width: 760px; font-size: 14px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-actions input[type=month] { width: auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; display: grid; gap: 16px; align-content: start; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-actions { display: flex; justify-content: flex-end; gap: 8px; }
.card.narrow { max-width: 520px; }
.notice { background: var(--surface); border: 1px solid var(--border); color: var(--text-2); border-radius: 8px; padding: 12px 16px; display: flex; gap: 8px; align-items: baseline; }
.notice::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-dot); flex: none; transform: translateY(-1px); }
.notice.subtle::before { background: var(--border-strong); }
.alert { background: var(--danger-soft); color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent); border-radius: 8px; padding: 12px 16px; }
.alert[hidden] { display: none; }
.empty { text-align: center; padding: 32px 12px; }
.empty-title { font-weight: 500; margin-bottom: 4px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.span2 { grid-column: span 2; }

/* stats: numbers only */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; text-align: left; box-shadow: var(--shadow); display: grid; gap: 4px; color: var(--text); font: inherit; transition: background-color 150ms var(--ease); }
button.kpi { cursor: pointer; }
button.kpi:hover { background: var(--surface-2); }
.kpi-label { color: var(--text-2); font-size: 13px; }
.kpi-value { font-size: 28px; font-weight: 500; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-sub { color: var(--muted); font-size: 12px; }
.kpi.danger .kpi-value { color: var(--danger); }
.kpi.warn .kpi-sub { color: var(--accent); }
.count { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filters select { width: auto; max-width: 220px; }
.segmented { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 2px; width: max-content; max-width: 100%; overflow-x: auto; }
.segmented button { border: 0; background: none; height: 30px; padding: 0 12px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 500; white-space: nowrap; transition: background-color 150ms var(--ease), color 150ms var(--ease); }
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border), var(--shadow); }

/* ---------- table ---------- */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { position: sticky; top: 0; background: var(--surface); text-align: left; font-size: 12px; color: var(--muted); font-weight: 400; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact td, .table.compact th { padding: 8px 12px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
/* Leads table: give the document's fields room instead of wrapping every word */
.table .who .strong { white-space: nowrap; }
.table td:nth-child(1) { min-width: 200px; }
.table td:nth-child(3) { min-width: 200px; }
.table td:nth-child(4) { min-width: 220px; }
tr.clickable { cursor: pointer; }
tr.clickable td { transition: background-color 120ms var(--ease); }
tr.clickable:hover td { background: var(--surface-2); }
tr.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.who { display: flex; align-items: center; gap: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 500; background: var(--surface-2); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); flex: none; }
.avatar.sm { width: 20px; height: 20px; font-size: 10px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; color: var(--muted); }

/* ---------- badges: dot + text, no pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; color: var(--text-2); }
.badge.intent::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; box-sizing: border-box; }
.intent-high_intent { color: var(--text); }
.intent-high_intent::before { background: var(--accent-dot); }
.intent-considering::before { border: 2px solid var(--accent-dot); }
.intent-future_unclear::before { border: 1px solid var(--border-strong); }
.intent-general::before { background: var(--border-strong); }
.badge.status { color: var(--text-2); }
.status-won { color: var(--ok) !important; }
.status-lost { color: var(--muted) !important; text-decoration: line-through; }
.status-qualified, .status-proposal_enrolment { color: var(--text) !important; }
.badge.flag { color: var(--danger); }
.badge.flag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok { color: var(--ok); }
.badges { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.pill { font-size: 13px; color: var(--accent); }
.pill.ok { color: var(--ok); }
.due { font-family: var(--mono); font-size: 12px; white-space: nowrap; color: var(--text-2); }
.due.overdue { color: var(--danger); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { stroke: var(--border-strong); stroke-width: 1; opacity: .5; }
.chart .tick { fill: var(--muted); font-family: var(--mono); font-size: 11px; }
.chart .value { fill: var(--text); font-family: var(--mono); font-size: 12px; font-weight: 500; }
.chart .mark { fill: var(--chart); }
.chart .col.current .mark { fill: var(--accent-dot); }
.chart .hit { fill: transparent; }
.chart .col:hover .mark { fill: var(--text-2); }
.chart .col.current:hover .mark { fill: var(--accent-dot); }
.barlist { display: grid; gap: 12px; }
.barlist-row { display: grid; gap: 4px; border-radius: 8px; padding: 4px 8px; margin: 0 -8px; transition: background-color 120ms var(--ease); }
.barlist-row.clickable { cursor: pointer; }
.barlist-row.clickable:hover { background: var(--surface-2); }
.barlist-label { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-2); }
.barlist-value { font-family: var(--mono); font-size: 12px; color: var(--text); }
.barlist-bar { width: 100%; height: 4px; display: block; }
.barlist-bar .track { fill: var(--track); }
.barlist-bar .mark { fill: var(--text-2); }
.funnel-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.funnel-table td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.funnel-table tr:last-child td { border-bottom: 0; }
.funnel-table td:nth-child(2), .funnel-table td:nth-child(3) { text-align: right; font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.funnel-table td:nth-child(3) { color: var(--muted); width: 72px; }
.chart-tip { position: fixed; display: none; pointer-events: none; z-index: 200; background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 8px 12px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-lg); }
.tip-title { color: var(--text-2); }
.tip-value { font-family: var(--mono); font-size: 12px; }

/* dashboard layout */
.dash-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.dash-meta { display: flex; gap: 16px; color: var(--text-2); font-size: 14px; margin-top: 4px; }
.dash-meta .mono { color: var(--text); }
.breakdowns { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
.breakdowns h3 { font-size: 13px; font-weight: 400; color: var(--text-2); margin-bottom: 12px; }
.main-chart .chart-wrap { min-height: 240px; }

/* ---------- lists ---------- */
.queue, .feed, .related { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.queue-item { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 8px; margin: 0 -8px; width: calc(100% + 16px); border-radius: 8px; cursor: pointer; color: var(--text); font: inherit; transition: background-color 120ms var(--ease); }
.queue-item:hover { background: var(--surface-2); }
.queue-item .right .badge { justify-content: flex-end; }
.feed li { padding: 12px 0; border-bottom: 1px solid var(--border); display: grid; gap: 2px; }
.feed li:last-child { border-bottom: 0; }
.related li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 4px 0; }
.fu { position: relative; }
.fu.danger .card-head h2::before, .fu.warn .card-head h2::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; transform: translateY(-1px); }
.fu.danger .card-head h2::before { background: var(--danger); }
.fu.warn .card-head h2::before { background: var(--accent-dot); }
.fu-grid { align-items: start; }

/* ---------- pipeline board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(264px, 1fr); gap: 16px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
.col { background: var(--deep); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; max-height: calc(100vh - 240px); min-height: 200px; transition: border-color 150ms var(--ease), background-color 150ms var(--ease); }
.col.over { border-color: var(--border-strong); background: var(--surface-2); }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font-weight: 500; border-bottom: 1px solid var(--border); }
.col-body { padding: 8px; display: grid; gap: 8px; overflow-y: auto; align-content: start; }
.col-empty { text-align: center; padding: 20px 0; border: 1px dashed var(--border-strong); border-radius: 8px; }
.deal { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; display: grid; gap: 4px; cursor: grab; box-shadow: var(--shadow); transition: border-color 150ms var(--ease); }
.deal:hover { border-color: var(--border-strong); }
.deal.dragging { opacity: .5; }
.deal-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.deal-foot { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 4px; }
.card-move { margin-top: 4px; font-size: 13px; min-height: 28px !important; padding: 4px 8px !important; }

/* ---------- overlays ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .4); display: flex; justify-content: flex-end; animation: fade 200ms var(--ease); }
.drawer { width: min(760px, 100%); height: 100%; background: var(--bg); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg); overflow-y: auto; outline: none; animation: slide 300ms var(--ease); }
.modal { margin: auto; width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); outline: none; animation: rise 200ms var(--ease); }
.modal.wide { width: min(760px, calc(100% - 24px)); }
.backdrop:has(.modal) { justify-content: center; align-items: center; }
.modal-body { padding: 24px; display: grid; gap: 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: -24px; background: var(--surface); padding: 12px 0 4px; }
.modal hr { border: 0; border-top: 1px solid var(--border); margin: 0; width: 100%; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(12px); opacity: 0; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }

.drawer-body { display: grid; gap: 16px; padding: 0 0 32px; }
.drawer-body > * { margin: 0 24px; }
.drawer-body .pad { padding: 24px; }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; padding: 24px 24px 0; margin: 0 !important; }
.drawer-title { display: flex; gap: 16px; align-items: flex-start; }
.drawer-title h2 { font-size: 20px; }
.drawer-title .badges { margin-top: 8px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quick-actions .pref { margin-left: auto; }

/* status stepper: the route signature */
.stepper-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; display: grid; gap: 16px; }
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.stepper li { font-size: 12px; color: var(--muted); display: grid; gap: 8px; justify-items: center; text-align: center; position: relative; }
.stepper li:not(:last-child)::after { content: ""; position: absolute; top: 5px; left: calc(50% + 10px); right: calc(-50% + 10px); height: 1px; background: var(--border-strong); opacity: .6; }
.stepper .dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--border-strong); background: var(--surface); position: relative; z-index: 1; }
.stepper li.done .dot { background: var(--text-2); border-color: var(--text-2); }
.stepper li.done:not(:last-child)::after { background: var(--text-2); opacity: 1; }
.stepper li.current { color: var(--text); font-weight: 500; }
.stepper li.current .dot { background: var(--text); border-color: var(--text); box-shadow: 0 0 0 4px var(--surface-2); }
.status-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status-actions input { width: auto; flex: 1 1 220px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--text-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: color 150ms var(--ease), border-color 150ms var(--ease); }
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--text); border-bottom-color: var(--text); }
.tabpanel { display: grid; gap: 16px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.ff { display: grid; gap: 4px; align-content: start; min-width: 0; }
.ff.span2 { grid-column: 1 / -1; }
.lbl { font-size: 13px; font-weight: 500; color: var(--text-2); display: flex; gap: 8px; align-items: baseline; }
.fnum { font-family: var(--mono); font-size: 12px; font-weight: 400; color: var(--muted); width: 12px; text-align: right; flex: none; }
.ro { padding: 8px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; min-height: 36px; }
.hint { font-size: 12px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--danger); }
.field-error:empty { display: none; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choice { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 12px; cursor: pointer; transition: background-color 120ms var(--ease), border-color 120ms var(--ease); }
.choice:hover { background: var(--surface-2); }
.choice:has(input:checked) { border-color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--text); }
.choice input { margin-top: 3px; accent-color: var(--text); }
.checklist { border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; display: grid; gap: 8px; margin: 0; }
.checklist legend { font-weight: 500; font-size: 13px; padding: 0 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.touches { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.timeline li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.tl-icon { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.tl-call, .tl-whatsapp, .tl-email, .tl-meeting { color: var(--text-2); }
.tl-status_change { color: var(--text); }
.tl-meta { font-size: 12px; color: var(--muted); }
.tl-meta strong { color: var(--text-2); font-weight: 500; }
.tl-meta strong::first-letter { text-transform: uppercase; }
.tl-body { white-space: pre-wrap; }
.composer textarea { min-height: 72px; }
.danger-zone { border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); }
.danger-zone .row input { max-width: 160px; }

/* match review */
.compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.cmp { border: 1px solid var(--border); border-radius: 8px; padding: 12px; display: grid; gap: 12px; align-content: start; }
.cmp.new { background: var(--surface-2); }
.cmp .match { color: var(--ok); }
.cmp .diff { color: var(--accent); }

/* toasts */
.toasts { position: fixed; bottom: 24px; right: 24px; display: grid; gap: 8px; z-index: 300; }
.toast { padding: 12px 16px; border-radius: 8px; background: var(--primary-bg); color: var(--primary-fg); max-width: 420px; box-shadow: var(--shadow-lg); animation: rise 200ms var(--ease); }
.toast.err { background: var(--danger); color: #fff; }

/* sign-in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px; display: grid; gap: 16px; box-shadow: var(--shadow-lg); }
.login-card h1 { font-size: 24px; }
.login-card .brandmark { padding: 0; }
.loading { padding: 64px; text-align: center; color: var(--muted); }

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

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > .span2 { grid-column: auto; }
  .grid-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .dash-main { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .panel { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 40; transform: translateX(-100%); transition: transform 300ms var(--ease); }
  .panel.nav-open .sidebar { transform: none; }
  .panel.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .4); }
  .topbar .menu-btn { display: inline-grid; }
  .topbar { padding: 0 16px; }
  .topbar .btn span { display: none; }
  .view { padding: 16px; gap: 16px; }
  .grid-2, .grid-3, .breakdowns { grid-template-columns: 1fr; }
  .form-grid, .choices, .touches { grid-template-columns: 1fr; }
  .stepper { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 16px; }
  .stepper li:nth-child(3)::after { display: none; }
  .drawer-body > * { margin: 0 16px; }
}
