/* Drive Now Motors — Leads. Tokens per DESIGN.md (OKLCH, restrained). */

:root {
  --bg: oklch(1 0 0);
  --surface: oklch(0.976 0.004 160);
  --surface-2: oklch(0.956 0.006 160);
  --ink: oklch(0.205 0.015 165);
  --muted: oklch(0.455 0.02 165);
  --faint: oklch(0.52 0.015 165);
  --line: oklch(0.906 0.008 160);
  --line-strong: oklch(0.86 0.01 160);

  --primary: oklch(0.42 0.1 162);
  --primary-hover: oklch(0.36 0.1 162);
  --primary-soft: oklch(0.946 0.028 162);
  --primary-soft-ink: oklch(0.33 0.09 162);

  --amber-soft: oklch(0.945 0.05 80);
  --amber-ink: oklch(0.43 0.11 70);
  --danger: oklch(0.5 0.185 27);
  --danger-hover: oklch(0.44 0.18 27);
  --danger-soft: oklch(0.94 0.032 25);
  --danger-ink: oklch(0.42 0.16 27);

  --blue-soft: oklch(0.945 0.03 250);
  --blue-ink: oklch(0.4 0.1 255);
  --violet-soft: oklch(0.945 0.032 300);
  --violet-ink: oklch(0.4 0.1 300);
  --teal-soft: oklch(0.945 0.035 210);
  --teal-ink: oklch(0.38 0.08 215);
  --gray-soft: oklch(0.945 0.004 160);
  --gray-ink: oklch(0.42 0.015 165);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-pop: 0 4px 12px oklch(0.2 0.02 165 / 0.12);

  --z-dropdown: 30;
  --z-sticky: 40;
  --z-modal-backdrop: 50;
  --z-modal: 51;
  --z-toast: 60;
  --z-tooltip: 70;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 0.875rem;             /* 14px UI base */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; text-wrap: balance; }

.num, time, .due { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
  padding: 0 1.25rem;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--ink);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand small { font-weight: 500; color: var(--muted); }

.topnav { display: flex; align-self: stretch; gap: 0.25rem; }

.topnav a {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  color: var(--muted);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.topnav a:hover { color: var(--ink); text-decoration: none; }
.topnav a[aria-current="page"] {
  color: var(--ink);
  font-weight: 600;
  border-bottom-color: var(--primary);
}

.topbar-spacer { flex: 1; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-weight: 500;
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-soft-ink);
  font-size: 0.75rem;
  font-weight: 600;
}

.mock-switch {
  font: inherit;
  font-size: 0.75rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0.3rem 0.4rem;
  width: auto;
  max-width: 11rem;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ page */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 5.5rem;
}

.page-head { margin-bottom: 0.5rem; }

.page-title {
  font-size: 1.5625rem;   /* 25px */
  font-weight: 700;
  letter-spacing: 0;
}

.page-sub { margin-top: 0.3rem; color: var(--muted); }
.page-sub strong { color: var(--ink); font-weight: 600; }

.section { margin-top: 1.75rem; }

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.section-title { font-size: 1.0625rem; font-weight: 650; }

.focus-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1.25rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.focus-metric {
  min-width: 0;
  padding: 0.85rem 1rem;
  border-left: 1px solid var(--line);
}
.focus-metric:first-child { border-left: none; }
.focus-metric span,
.focus-metric em {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-style: normal;
  font-weight: 600;
}
.focus-metric strong {
  display: block;
  margin: 0.05rem 0;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 700;
}
.focus-metric.primary { box-shadow: inset 4px 0 0 var(--primary); }
.focus-metric.blue { box-shadow: inset 4px 0 0 var(--primary); }
.focus-metric.split { box-shadow: inset 4px 0 0 var(--danger); }

.count-pill {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
}
.count-pill.danger { background: var(--danger-soft); color: var(--danger-ink); }
.count-pill.amber { background: var(--amber-soft); color: var(--amber-ink); }

.month-label { color: var(--muted); font-size: 0.8125rem; font-weight: 500; }
.month-performance-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 0.42fr);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.month-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.month-stat { min-width: 0; padding: 0.85rem 1rem; }
.month-stat:nth-child(n + 4) { border-top: 1px solid var(--line); }
.month-stat:not(:nth-child(3n + 1)) { border-left: 1px solid var(--line); }
.month-stat strong { display: block; font-size: 1.125rem; font-weight: 700; }
.month-stat span { color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.performance-tracks {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--surface);
  border-left: 1px solid var(--line);
}
.performance-track-head { display: flex; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.4rem; font-size: 0.78125rem; }
.performance-track-head span { color: var(--muted); }
.performance-track-head strong { font-weight: 650; }
.performance-track-bar { height: 7px; overflow: hidden; border-radius: 4px; background: var(--surface-2); }
.performance-track-bar span { display: block; height: 100%; border-radius: inherit; background: var(--primary); }

/* ------------------------------------------------------------- list rows */

.list-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}

.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  transition: background 150ms ease-out;
}
.row + .row { border-top: 1px solid var(--line); }
.row:hover { background: var(--surface); }

.row-main { flex: 1; min-width: 0; }

.row-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.90625rem;  /* 14.5px */
}

.row-link { color: var(--ink); }
.row-link:hover { text-decoration: none; }
.row-link::after { content: ''; position: absolute; inset: 0; }

.row-sub {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.84375rem;  /* 13.5px */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row-sub .sep { margin: 0 0.35rem; color: var(--line-strong); }

.row-side {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.due { font-size: 0.8125rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.due.danger { color: var(--danger); }

.icon-btn {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--primary);
  cursor: pointer;
  transition: background 150ms ease-out, border-color 150ms ease-out;
}
.icon-btn:hover { background: var(--primary-soft); border-color: var(--primary-soft); text-decoration: none; }
.icon-btn svg { width: 17px; height: 17px; }

/* ----------------------------------------------------------------- pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.14rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78125rem;  /* 12.5px */
  font-weight: 600;
  white-space: nowrap;
}

.pill-website  { background: var(--primary-soft); color: var(--primary-soft-ink); }
.pill-facebook { background: var(--blue-soft); color: var(--blue-ink); }
.pill-csv      { background: var(--gray-soft); color: var(--gray-ink); }
.pill-manual   { background: var(--gray-soft); color: var(--gray-ink); }

.pill-new             { background: var(--primary-soft); color: var(--primary-soft-ink); }
.pill-contacted       { background: var(--blue-soft); color: var(--blue-ink); }
.pill-appointment_set { background: var(--violet-soft); color: var(--violet-ink); }
.pill-test_drive      { background: var(--teal-soft); color: var(--teal-ink); }
.pill-negotiating     { background: var(--amber-soft); color: var(--amber-ink); }
.pill-sold            { background: var(--primary); color: #fff; }
.pill-lost            { background: var(--gray-soft); color: var(--gray-ink); }
.pill-refurbish       { background: var(--amber-soft); color: var(--amber-ink); }

.pill-wait { background: var(--amber-soft); color: var(--amber-ink); }
.pill-wait.hot { background: var(--danger-soft); color: var(--danger-ink); }

.pill-wait .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.pill-wait.fresh .dot { animation: pulse 2s ease-out infinite; }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgb(201 151 28 / 0.35); }
  70% { box-shadow: 0 0 0 5px rgb(201 151 28 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(201 151 28 / 0); }
}

.pill-returning { background: var(--violet-soft); color: var(--violet-ink); }
.pill-unassigned { background: var(--gray-soft); color: var(--gray-ink); }
.pill-target { background: var(--primary-soft); color: var(--primary-soft-ink); }
/* Solid dark, unlike every other (soft-fill) pill — a test lead must never be
   mistaken for a real customer to call. */
.pill-test { background: var(--ink); color: var(--bg); letter-spacing: 0.02em; }
.pill-finance-not_started { background: var(--gray-soft); color: var(--gray-ink); }
.pill-finance-collecting_info, .pill-finance-ready_to_apply { background: var(--amber-soft); color: var(--amber-ink); }
.pill-finance-submitted { background: var(--blue-soft); color: var(--blue-ink); }
.pill-finance-conditional { background: var(--violet-soft); color: var(--violet-ink); }
.pill-finance-approved { background: var(--primary); color: #fff; }
.pill-finance-declined { background: var(--danger-soft); color: var(--danger-ink); }
.pill-finance-withdrawn { background: var(--gray-soft); color: var(--gray-ink); }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease-out, border-color 150ms ease-out, color 150ms ease-out;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--bg); color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--surface); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8125rem; }

/* ----------------------------------------------------------------- forms */

label.field { display: block; margin-bottom: 0.85rem; }

.field-label {
  display: block;
  margin-bottom: 0.3rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink);
}

input[type="text"], input[type="search"], input[type="email"], input[type="tel"],
input[type="number"], input[type="password"], input[type="date"],
input[type="datetime-local"], select, textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  transition: border-color 150ms ease-out;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted); }

textarea { resize: vertical; min-height: 4.5rem; }

.form-error { color: var(--danger); font-weight: 500; margin: 0.5rem 0; }

/* ----------------------------------------------------------- empty state */

.empty {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1.1rem 1rem;
  color: var(--muted);
}
.empty svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }

/* ----------------------------------------------------------------- toast */

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  translate: -50% 0;
  z-index: var(--z-toast);
  padding: 0.65rem 1.1rem;
  background: var(--ink);
  color: var(--bg);
  font-weight: 500;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop);
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.toast.show { opacity: 1; }

/* ------------------------------------------------------------ cards */

.card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}
.card + .card { margin-top: 1.25rem; }

.card-title { font-size: 1rem; font-weight: 650; margin-bottom: 0.75rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.card-head .card-title { margin-bottom: 0; }
.card-sub { color: var(--muted); margin: -0.4rem 0 0.9rem; }
.card-empty { color: var(--muted); }

/* ---------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}
.tb-search { flex: 1 1 15rem; min-width: 0; }
.tb-select {
  width: auto;
  flex: 0 0 auto;
  padding: 0.5rem 0.6rem;
  font-size: 0.84375rem;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
}

/* inline assign control (admin) */
.row-assign {
  width: auto;
  max-width: 12rem;
  padding: 0.35rem 0.5rem;
  font-size: 0.8125rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--ink);
}
.row-assignee { color: var(--muted); font-size: 0.84375rem; font-weight: 500; }

/* ------------------------------------------------- lead detail layout */

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 0.85rem;
}
.back-link:hover { color: var(--ink); text-decoration: none; }
.back-link svg { width: 16px; height: 16px; }

.lead-head { margin-bottom: 1.25rem; }
.head-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }

.contact-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.85rem; }
.contact-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  font-weight: 500;
}
.contact-chip:hover { background: var(--surface); text-decoration: none; }
.contact-chip svg { width: 15px; height: 15px; color: var(--primary); }

.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  gap: 1.25rem;
  align-items: start;
}
.detail-main { min-width: 0; }
.detail-side { display: flex; flex-direction: column; gap: 1.25rem; }
.detail-side .card + .card { margin-top: 0; }

.finance-panel { margin-bottom: 1.25rem; }
.finance-head { margin-bottom: 1rem; }
.finance-title, .finance-head-actions { display: flex; align-items: center; gap: 0.55rem; }
.finance-title-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary-soft-ink);
}
.finance-title-icon svg { width: 17px; height: 17px; }
.finance-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.finance-fact { min-width: 0; padding: 0.75rem 0.85rem; }
.finance-fact:nth-child(n + 4) { border-top: 1px solid var(--line); }
.finance-fact:not(:nth-child(3n + 1)) { border-left: 1px solid var(--line); }
.finance-fact span, .finance-conditions > span {
  display: block;
  margin-bottom: 0.18rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.finance-fact strong { display: block; overflow-wrap: anywhere; font-weight: 650; }
.finance-conditions { grid-column: 1 / -1; padding: 0.75rem 0.85rem; border-top: 1px solid var(--line); }
.finance-conditions p { margin: 0; color: var(--ink); white-space: pre-wrap; }
.finance-empty { display: flex; align-items: center; gap: 0.75rem; padding: 0.15rem 0; }
.finance-empty-icon { color: var(--muted); }
.finance-empty-icon svg { width: 24px; height: 24px; }
.finance-empty strong { display: block; font-weight: 650; }
.finance-empty span { display: block; color: var(--muted); font-size: 0.8125rem; }
.finance-empty .btn { margin-left: auto; }
.finance-dialog { width: min(680px, calc(100vw - 2rem)); }
.tl-finance_update { background: var(--primary-soft); color: var(--primary-soft-ink); }

/* facts list */
.fact {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
}
.fact:first-of-type { border-top: none; padding-top: 0; }
.card-head + .fact { border-top: none; padding-top: 0; }
.fact-label { color: var(--muted); flex-shrink: 0; }
.fact-value { text-align: right; font-weight: 500; }

/* --------------------------------------------------------- stepper */

.stepper { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.step {
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}
.step:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.step:disabled { cursor: default; opacity: 0.7; }
.step.current {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.step.current.step-sold { background: var(--primary); border-color: var(--primary); }
.step.current.step-lost { background: var(--gray-ink); border-color: var(--gray-ink); }
.step.current.step-refurbish { background: var(--amber-soft); border-color: var(--amber-ink); color: var(--amber-ink); }

.lost-picker { margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px solid var(--line); }
.lost-picker-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.lost-picker-row select { width: auto; flex: 1 1 12rem; }
.refurbish-picker input[type="datetime-local"] { width: auto; flex: 0 0 13rem; }
.refurbish-picker input[type="text"] { flex: 1 1 16rem; }
.lost-note { margin: 0.75rem 0 0; color: var(--muted); font-weight: 500; }

/* --------------------------------------------------------- composer */

.composer { padding: 0; overflow: hidden; }
.composer-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
}
.composer-tab {
  flex: 1;
  padding: 0.7rem 0.5rem;
  border: none;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: background 150ms ease-out, color 150ms ease-out;
}
.composer-tab:hover { color: var(--ink); }
.composer-tab.active {
  background: var(--bg);
  color: var(--ink);
  border-bottom-color: var(--primary);
}
.composer-body { padding: 1rem 1.15rem 1.15rem; }
.composer-actions { display: flex; justify-content: flex-end; margin-top: 0.75rem; }

.notice {
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
}

/* --------------------------------------------------------- timeline */

.timeline { display: flex; flex-direction: column; }
.tl-item {
  display: flex;
  gap: 0.75rem;
  padding-bottom: 1.1rem;
  position: relative;
}
.tl-item::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 32px;
  bottom: 0;
  width: 1.5px;
  background: var(--line);
}
.tl-item:last-child { padding-bottom: 0; }
.tl-item:last-child::before { display: none; }

.tl-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
}
.tl-icon svg { width: 15px; height: 15px; }
.tl-call { background: var(--primary-soft); color: var(--primary-soft-ink); }
.tl-status_change { background: var(--violet-soft); color: var(--violet-ink); }
.tl-enquiry { background: var(--blue-soft); color: var(--blue-ink); }
.tl-assignment { background: var(--amber-soft); color: var(--amber-ink); }

.tl-body { flex: 1; min-width: 0; padding-top: 0.35rem; }
.tl-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem;
}
.tl-head strong { font-weight: 600; }
.tl-meta { color: var(--faint); font-size: 0.8125rem; }
.tl-text { margin: 0.3rem 0 0; color: var(--muted); white-space: pre-wrap; }

/* --------------------------------------------------------- tasks */

.task-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--line);
  cursor: pointer;
}
.task-item:first-of-type { border-top: none; padding-top: 0; }
.task-item input { width: auto; flex-shrink: 0; accent-color: var(--primary); }
.task-note { flex: 1; min-width: 0; }
.task-item.done .task-note { color: var(--faint); text-decoration: line-through; }
.task-item .due { margin-left: auto; flex-shrink: 0; }

/* --------------------------------------------------------- enquiries */

.enquiry-card .card-title { margin-bottom: 0.65rem; }
.related-leads {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 0.75rem;
}
.related-lead-link {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.25rem 0.6rem;
  align-items: center;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink);
}
.related-lead-link:hover { background: var(--surface); text-decoration: none; }
.related-lead-link span:first-child { font-weight: 650; }
.related-lead-link span:nth-child(2) {
  grid-column: 1;
  color: var(--muted);
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.related-lead-link svg { grid-column: 2; grid-row: 1 / span 2; width: 16px; height: 16px; color: var(--muted); }

.enquiry-list { display: flex; flex-direction: column; gap: 0.65rem; }
.enquiry-item {
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}
.enquiry-item:first-child { padding-top: 0; border-top: none; }
.enquiry-item-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.enquiry-item p { margin: 0.35rem 0 0; color: var(--muted); white-space: pre-wrap; }
.enquiry-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin-top: 0.45rem;
}
.enquiry-facts span {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.18rem 0.45rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.75rem;
}
.enquiry-facts strong { color: var(--ink); font-weight: 650; }

/* --------------------------------------------------------- staff */

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.75rem;
  align-items: end;
}
.form-row .field { margin-bottom: 0; }
.form-row .btn { height: fit-content; }
.staff-account-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 8rem auto; }
.staff-create-card { margin-bottom: 1.25rem; }

.temp-pass {
  margin-top: 0.9rem;
  padding: 0.75rem 0.9rem;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  color: var(--primary-soft-ink);
}
.temp-pass code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  background: var(--bg);
  padding: 0.1rem 0.4rem;
  border-radius: 5px;
  color: var(--ink);
  font-weight: 600;
}
.row-disabled { opacity: 0.65; }
.staff-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 0.48fr);
  gap: 1.25rem;
  align-items: start;
}
.staff-list { align-self: start; }
.staff-row { cursor: pointer; }
.staff-row:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.staff-row.row-selected {
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}
.avatar-lg {
  width: 40px;
  height: 40px;
  font-size: 0.875rem;
}
.staff-detail-card {
  position: sticky;
  top: 72px;
}
.staff-detail-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: start;
  margin-bottom: 1rem;
}
.staff-detail-actions {
  display: flex;
  align-items: end;
  gap: 0.5rem;
}
.staff-detail-actions .role-field { margin-bottom: 0; }
.staff-role-select { min-width: 7rem; }
.staff-target-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.staff-target-empty {
  grid-template-columns: 1fr;
}
.staff-target-empty strong,
.staff-target-empty span {
  display: block;
}
.staff-target-empty span { color: var(--muted); font-size: 0.8125rem; }
.target-ring {
  display: grid;
  place-items: center;
  width: 94px;
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--surface) 0 58%, transparent 59%),
    conic-gradient(var(--primary) var(--target-progress), var(--surface-2) 0);
}
.target-ring strong {
  grid-area: 1 / 1;
  align-self: center;
  font-size: 1.05rem;
  font-weight: 700;
}
.target-ring span {
  grid-area: 1 / 1;
  align-self: end;
  margin-bottom: 1.35rem;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
}
.target-summary { min-width: 0; }
.target-line {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.22rem 0;
}
.target-line span {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 500;
}
.target-line strong { font-weight: 700; }
.target-edit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  margin-top: 0.55rem;
}
.staff-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.staff-metric {
  min-width: 0;
  padding: 0.75rem 0.85rem;
}
.staff-metric:nth-child(n + 3) { border-top: 1px solid var(--line); }
.staff-metric:nth-child(even) { border-left: 1px solid var(--line); }
.staff-metric strong { display: block; font-size: 1.0625rem; font-weight: 700; }
.staff-metric span { color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.staff-move-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* --------------------------------------------------------- tables */

.table-scroll { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84375rem;
}
.table th, .table td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78125rem;
  background: var(--surface);
}
.table td { font-variant-numeric: tabular-nums; }
.table tbody tr:last-child td { border-bottom: none; }

/* --------------------------------------------------------- import map */

.map-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.75rem 1rem;
}
.map-field { margin-bottom: 0; }

/* --------------------------------------------------------- dialog */

.dn-dialog {
  width: min(560px, calc(100vw - 2rem));
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-pop);
  color: var(--ink);
}
.dn-dialog::backdrop { background: oklch(0.2 0.02 165 / 0.4); }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}
.form-grid .field:first-child { grid-column: 1 / -1; }
.checkbox-field {
  display: flex;
  flex-direction: row-reverse;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}
.checkbox-field input { width: auto; accent-color: var(--primary); }
.checkbox-field .field-label { margin-bottom: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; }

/* --------------------------------------------------------- reports */

.reports-grid { display: flex; flex-direction: column; gap: 1.25rem; margin-top: 1.25rem; }
.reports-page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.report-month-select { min-width: 9rem; }
.owner-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.owner-metric { min-width: 0; padding: 0.85rem 1rem; }
.owner-metric:nth-child(n + 5) { border-top: 1px solid var(--line); }
.owner-metric:not(:nth-child(4n + 1)) { border-left: 1px solid var(--line); }
.owner-metric span { display: block; color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.owner-metric strong { display: block; margin-top: 0.1rem; overflow-wrap: anywhere; font-size: 1.0625rem; font-weight: 700; }

.finance-pipeline { display: flex; flex-direction: column; gap: 0.65rem; }
.finance-pipeline-row { display: grid; grid-template-columns: 8.5rem minmax(0, 1fr) 2rem; gap: 0.7rem; align-items: center; }
.finance-pipeline-label { color: var(--muted); font-size: 0.8125rem; font-weight: 500; }
.finance-pipeline-track { height: 10px; overflow: hidden; border-radius: 5px; background: var(--surface-2); }
.finance-pipeline-bar { display: block; min-width: 0; height: 100%; border-radius: inherit; background: var(--gray-ink); }
.finance-pipeline-collecting_info, .finance-pipeline-ready_to_apply { background: #b77b00; }
.finance-pipeline-submitted { background: #2a78d6; }
.finance-pipeline-conditional { background: #4a3aa7; }
.finance-pipeline-approved { background: #0c7a4f; }
.finance-pipeline-declined { background: #b33131; }
.finance-pipeline-row strong { text-align: right; font-size: 0.8125rem; }

.chart { width: 100%; height: auto; overflow: visible; }
.grid-line { stroke: var(--line); stroke-width: 1; }
.axis-line { stroke: var(--line-strong); stroke-width: 1; }
.axis-text { fill: var(--faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.funnel-label { fill: var(--ink); font-size: 12px; font-weight: 500; }
.value-text { fill: var(--muted); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; dominant-baseline: middle; }

.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; margin-bottom: 0.75rem; }
.legend-item { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.8125rem; font-weight: 500; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex-shrink: 0; }

.chart-table { margin-top: 0.85rem; }
.chart-table summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.84375rem;
  list-style-position: inside;
}
.chart-table[open] summary { margin-bottom: 0.6rem; }

.chart-tip {
  position: fixed;
  z-index: var(--z-tooltip, 60);
  display: none;
  pointer-events: none;
  padding: 0.55rem 0.7rem;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.5;
  box-shadow: var(--shadow-pop);
  max-width: 15rem;
}
.chart-tip strong { font-weight: 650; }
.chart-tip .tip-swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 2px;
  margin-right: 0.35rem;
}
.chart-tip .tip-total { margin-top: 0.3rem; padding-top: 0.3rem; border-top: 1px solid oklch(1 0 0 / 0.2); opacity: 0.85; }

/* --------------------------------------------------------- login */

.login-screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(120% 80% at 50% -10%, var(--primary-soft), transparent 60%),
    var(--surface);
}
.login-card {
  width: min(400px, 100%);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2rem 1.75rem;
  box-shadow: var(--shadow-pop);
}
.login-brand { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 1.5rem; }
.login-mark { width: 34px; height: 34px; font-size: 0.8125rem; border-radius: 9px; }
.login-brand-text { font-weight: 700; font-size: 1.0625rem; }
.login-brand-text small { font-weight: 500; color: var(--muted); }
.login-title { font-size: 1.375rem; font-weight: 700; }
.login-sub { margin: 0.25rem 0 1.5rem; color: var(--muted); }
.login-submit { width: 100%; margin-top: 0.35rem; padding: 0.6rem; }
.login-foot { margin: 1.1rem 0 0; text-align: center; color: var(--faint); font-size: 0.8125rem; }
.login-link {
  display: block;
  width: 100%;
  margin-top: 1rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  font-size: 0.84375rem;
  text-align: center;
  cursor: pointer;
}
.login-link:hover { text-decoration: underline; }
.login-ok {
  margin: 0.5rem 0;
  padding: 0.6rem 0.75rem;
  background: var(--primary-soft);
  color: var(--primary-soft-ink);
  border-radius: var(--radius-sm);
  font-weight: 500;
}

/* --------------------------------------------------------- user menu */

.user-chip-btn {
  font: inherit;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 999px;
}
.user-chip-btn:disabled { cursor: default; }
.user-chip-btn:not(:disabled):hover { background: var(--surface-2); }

.user-menu-wrap { position: relative; }
.user-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-dropdown);
  min-width: 13rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.user-popover-head { padding: 0.75rem 0.85rem; border-bottom: 1px solid var(--line); }
.user-popover-head strong { display: block; font-weight: 600; }
.user-popover-email { color: var(--muted); font-size: 0.8125rem; }
.user-popover-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.85rem;
  border: none;
  background: transparent;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}
.user-popover-item:hover { background: var(--surface); }

/* ------------------------------------------------------- mobile tab bar */

.tabbar { display: none; }

@media (max-width: 820px) {
  .topnav, .user-chip .user-name, .btn-newlead .btn-text { display: none; }

  .topbar { gap: 0.6rem; padding: 0 0.85rem; }
  .brand small { display: none; }
  .mock-switch { max-width: 7.5rem; }
  .btn-newlead { padding: 0.3rem 0.45rem; }

  .page { padding: 1.25rem 1rem 5.5rem; }
  .focus-strip { grid-template-columns: 1fr; }
  .focus-metric { border-left: none; border-top: 1px solid var(--line); }
  .focus-metric:first-child { border-top: none; }

  .tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: var(--z-sticky);
    display: flex;
    background: var(--bg);
    border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.5rem 0 0.55rem;
    color: var(--muted);
    font-size: 0.6875rem;
    font-weight: 500;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a svg { width: 21px; height: 21px; }
  .tabbar a[aria-current="page"] { color: var(--primary); font-weight: 600; }

  .row { padding: 0.75rem 0.85rem; }
  .row-side { flex-direction: column; align-items: flex-end; gap: 0.35rem; }
  .due { font-size: 0.75rem; }

  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { order: -1; }
  .finance-facts { grid-template-columns: 1fr 1fr; }
  .finance-fact:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .finance-fact:not(:nth-child(3n + 1)) { border-left: 0; }
  .finance-fact:nth-child(even) { border-left: 1px solid var(--line); }
  .finance-empty { align-items: flex-start; flex-wrap: wrap; }
  .finance-empty .btn { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .staff-account-form { grid-template-columns: 1fr; }
  .staff-layout { grid-template-columns: 1fr; }
  .staff-detail-card { position: static; }
  .staff-detail-head { grid-template-columns: auto minmax(0, 1fr); }
  .staff-detail-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .tb-select { flex: 1 1 calc(50% - 0.25rem); }
  .month-performance-body { grid-template-columns: 1fr; }
  .performance-tracks { border-left: 0; border-top: 1px solid var(--line); }
  .reports-page-head { align-items: flex-start; }
  .report-month-select { flex: 0 0 auto; min-width: 7.5rem; max-width: 8.5rem; }
  .owner-metrics { grid-template-columns: 1fr 1fr; }
  .owner-metric:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .owner-metric:not(:nth-child(4n + 1)) { border-left: 0; }
  .owner-metric:nth-child(even) { border-left: 1px solid var(--line); }
  .finance-pipeline-row { grid-template-columns: 7.5rem minmax(0, 1fr) 1.5rem; gap: 0.5rem; }
}

@media (min-width: 821px) {
  .tabbar { display: none !important; }
}

/* ---------------------------------------------------------------- motion */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
