:root {
  /* Twenty-style palette: light, airy, soft borders, blue accent. */
  --bg:        #ffffff;
  --panel:     #fbfbfb;
  --surface:   #ffffff;
  --surface-2: #f4f4f5;
  --border:    #ececec;
  --line2:     #f0f0f0;
  --text:      #1b1b1b;
  --muted:     #71717a;
  --faint:     #a1a1aa;
  --gold:      #1961ed;   /* legacy var name; now the blue accent (link color) */
  --accent:    #1961ed;
  --blue-soft: #eef3fe;
  --orange:    #c54a03;
  --success:   #16a34a;
  --warning:   #d97706;
  --danger:    #e11d48;
  --radius:    10px;
  --shadow:    0 1px 2px rgba(16,24,40,.04);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
table { font-size: 14px; }
table th { font-size: 12px; }
table td, table th { padding: 5px 10px; }
.nav-brand:hover { text-decoration: none; opacity: 0.85; }

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Twenty-style app shell: left sidebar + main column ── */
.app { display: flex; min-height: 100vh; }

.side {
  width: 200px; flex: 0 0 200px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 8px 8px;
  display: flex; flex-direction: column; gap: 1px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.side .ws { display: flex; align-items: center; gap: 8px; padding: 4px 8px 8px; }
.side .ws .logo {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, #1961ed, #5b8cff);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.side .ws .name { font-weight: 600; font-size: 14px; color: var(--text); }
.side .navlabel {
  font-size: 11px; color: var(--faint); text-transform: uppercase;
  letter-spacing: .06em; padding: 8px 8px 3px; font-weight: 600;
}
.side a.nav {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 9px; border-radius: 6px;
  color: #3f3f46; font-size: 13px; font-weight: 500;
  text-decoration: none; transition: background .12s, color .12s;
}
.side a.nav:hover { background: #f3f3f4; text-decoration: none; }
.side a.nav.active { background: var(--blue-soft); color: var(--accent); font-weight: 600; }
.side .spacer { flex: 1; }
.side .userchip {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 8px 2px; border-top: 1px solid var(--border); margin-top: 6px;
}
.side .userchip .av {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; flex: 0 0 26px;
}
.side .userchip .nm { font-weight: 600; font-size: 13px; color: var(--text); }
.side .userchip form { margin: 0; margin-left: auto; }
.side .userchip button {
  background: none; border: none; color: var(--faint); cursor: pointer;
  font-size: 12px; padding: 2px 4px;
}
.side .userchip button:hover { color: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 52px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 22px; flex: 0 0 52px;
}
.topbar h1 { font-size: 15px; font-weight: 600; margin: 0; }
.topbar .date { color: var(--muted); font-weight: 400; }

.container { max-width: 1180px; margin: 0 auto; padding: 22px; }
main { padding: 22px; box-sizing: border-box; max-width: 1180px; }

/* Responsive: collapse sidebar to a top strip on narrow screens. */
@media (max-width: 720px) {
  .app { flex-direction: column; }
  .side { width: auto; flex: none; height: auto; position: static;
          flex-direction: row; flex-wrap: wrap; align-items: center;
          border-right: none; border-bottom: 1px solid var(--border); }
  .side .navlabel, .side .spacer { display: none; }
  .side .userchip { border-top: none; margin-left: auto; padding: 4px 8px; }
}

/* Whole-row click affordance for .row-link <tr> entries. JS handler in tpl.php. */
tr.row-link { cursor: pointer; transition: background-color 80ms ease, box-shadow 80ms ease; }
tr.row-link:hover {
    background: var(--blue-soft);
    box-shadow: inset 3px 0 0 var(--accent);
}
tr.row-link:hover td { color: var(--text); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-number {
  font-size: 36px;
  font-weight: 700;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(15,23,42,0.02); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s;
  text-decoration: none;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary  { background: var(--gold);    color: #fff; }
.btn-orange   { background: var(--orange);  color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-ghost    { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); opacity: 1; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-ready             { background: #dbeafe; color: #1d4ed8; }
.badge-contacted         { background: #dcfce7; color: #166534; }
.badge-responded         { background: #fef3c7; color: #92400e; }
.badge-due_diligence     { background: #ede9fe; color: #6d28d9; }
.badge-dealership_review { background: #ffe4e6; color: #be123c; }
.badge-won               { background: #d1fae5; color: #15803d; }
.badge-lost              { background: #fee2e2; color: #b91c1c; }
.badge-no_response       { background: #e5e7eb; color: #4b5563; }
.badge-scheduled         { background: #dbeafe; color: #1d4ed8; }
.badge-call              { background: #ccfbf1; color: #115e59; }
.badge-sms               { background: #dbeafe; color: #1e40af; }
.badge-review            { background: #fef3c7; color: #92400e; }
.badge-custom            { background: #e5e7eb; color: #4b5563; }
.badge-open              { background: #dbeafe; color: #1d4ed8; }
.badge-done              { background: #d1fae5; color: #15803d; }
.badge-dismissed         { background: #e5e7eb; color: #6b7280; }

input[type="datetime-local"] {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color-scheme: light;
}

input[type="text"], input[type="password"], textarea, select {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 14px;
  width: 100%;
  font-family: inherit;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(245, 166, 35, 0.15);
}

.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 360px;
}
.login-title { font-size: 20px; font-weight: 700; color: var(--gold); margin-bottom: 24px; }

.alert-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}

.cap-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.cap-bar .cap-count { color: var(--gold); font-weight: 700; }
.cap-bar .cap-label { color: var(--muted); font-size: 12px; }

.timeline { list-style: none; position: relative; padding-left: 20px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 6px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -17px; top: 6px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}
.timeline-time { font-size: 11px; color: var(--muted); }
.timeline-label { font-weight: 600; font-size: 13px; }
.timeline-note  { font-size: 12px; color: var(--muted); }

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

.message-preview-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 8px;
}
.message-preview-box textarea {
  min-height: 120px;
  resize: vertical;
  margin-bottom: 10px;
}

h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
h2 { font-size: 18px; font-weight: 600; margin-bottom: 12px; color: var(--muted); }
h3 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.gap-12 { gap: 12px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.saved-indicator { color: var(--success); font-size: 12px; }

/* iMessage-style thread bubbles. Used for both SMS thread and voice
   transcript. Goal: feel like iOS Messages — blue right (us / Erin),
   gray left (seller), tight stacking, small faded timestamps below. */
.conversation {
  display: flex;
  flex-direction: column;
  padding: 4px 0;
  /* Inherit page font (system-ui from body) so lead detail matches the
   * dashboard. The previous override forced Apple SF Pro Text which
   * looked different on Windows. */
}
.conversation h3 {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 14px;
  text-transform: none;
  letter-spacing: 0;
}
.conversation .muted {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 24px 0;
}
.msg-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 6px;
}
.msg-row-in  { align-items: flex-start; padding-left: 4px; }
.msg-row-out { align-items: flex-end;   padding-right: 4px; }
.msg {
  max-width: 72%;
  padding: 8px 14px;
  font-size: 15px;
  line-height: 1.32;
  word-wrap: break-word;
  position: relative;
}
.msg-out {
  background: #0a84ff;
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}
.msg-in {
  background: #e9eaee;
  color: #1a1d22;
  border-radius: 18px 18px 18px 4px;
}
.msg-ai {
  background: linear-gradient(135deg, #0a84ff 0%, #5e5ce6 100%);
}
.msg-body {
  white-space: pre-wrap;
  color: inherit;
  font-size: 15px;
}
.msg-meta {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  letter-spacing: 0.3px;
}
.tag {
  display: inline-block;
  padding: 0 5px;
  background: var(--surface-2);
  color: var(--muted);
  border-radius: 4px;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 6px;
  font-weight: 600;
}
.error { color: var(--danger); font-size: 13px; }

/* Lead detail page: narrower than the dashboard for readability */
.lead-detail { max-width: 920px; margin: 0 auto; }

/* Collapsible <details> card — matches .card styling, summary clickable */
details.collapse {
  padding: 0;
}
details.collapse > summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
details.collapse > summary::-webkit-details-marker { display: none; }
details.collapse > summary::before {
  content: "▸";
  font-size: 12px;
  color: var(--gold);
  transition: transform 0.15s;
  display: inline-block;
}
details.collapse[open] > summary::before {
  transform: rotate(90deg);
}
details.collapse > summary:hover { color: var(--text); }
details.collapse[open] > summary {
  border-bottom: 1px solid var(--border);
  margin-bottom: 0;
}
details.collapse > div {
  padding: 0 20px 20px;
}
.muted-count {
  color: var(--muted);
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
}

/* Form-style vehicle synopsis card */
.vehicle-form {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 28px;
  margin: 0;
}
.vehicle-form > div {
  display: grid;
  grid-template-columns: 110px 1fr;
  align-items: baseline;
  gap: 12px;
  padding: 7px 4px;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.vehicle-form > div:hover { background: var(--surface-2); }
.vehicle-form dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 500;
  white-space: nowrap;
  text-align: right;
}
.vehicle-form dd {
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  word-break: break-word;
}
/* Tighter variant for the long intake list */
.vehicle-form-tight > div { padding: 6px 4px; }
.vehicle-form-tight dd { font-size: 15px; font-weight: 500; }
@media (max-width: 720px) {
  .vehicle-form { grid-template-columns: 1fr; }
}

/* ============================================================
 * Lead detail page — compact 2-col layout (Layout A)
 * Slim header, SMS thread left, voice transcript right, details below
 * ============================================================ */
/* Lead ribbon (David's mockup 2026-06-12): identity left, two action rows
 * right. Buttons inside are styled HERE (no .btn classes) so the mockup's
 * look is exact; .call-btn keeps its class only for the dialer JS hook. */
.lead-ribbon {
  width: 100%;
  background: linear-gradient(135deg, #0b1426 0%, #14233f 70%, #182a4a 100%);
  border: 1px solid #243558;
  border-radius: 18px;
  box-shadow: 0 14px 36px rgba(7, 17, 31, 0.28);
  padding: 18px 20px;
  display: grid;
  grid-template-columns: minmax(360px, 1fr) auto;
  gap: 28px;
  align-items: center;
  margin-bottom: 14px;
}
.lead-ribbon .vehicle-info { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.lead-ribbon .vehicle-header { display: flex; align-items: center; gap: 12px; min-width: 0; }
.lead-ribbon .lead-id {
  font-size: 20px; font-weight: 850; color: #5ea2ff;
  text-decoration: none; letter-spacing: -0.02em;
  text-shadow: 0 0 18px rgba(94, 162, 255, 0.35);
}
.lead-ribbon .vehicle-title {
  font-size: 17px; font-weight: 800; color: #f4f7fc; letter-spacing: -0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lead-ribbon .badge {
  font-size: 10px; font-weight: 850; text-transform: uppercase;
  letter-spacing: 0.08em; border-radius: 999px; padding: 5px 10px; flex: 0 0 auto;
}
.lead-ribbon .vehicle-meta {
  display: flex; align-items: center; gap: 18px; margin-left: 56px;
  font-size: 13.5px; font-weight: 600; color: #8da3c4;
}
.lead-ribbon .vehicle-meta span { position: relative; white-space: nowrap; }
.lead-ribbon .vehicle-meta span:not(:first-child)::before {
  content: ""; width: 4px; height: 4px; background: #3b4f76; border-radius: 50%;
  position: absolute; left: -11px; top: 50%; transform: translateY(-50%);
}
.lead-ribbon .lead-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.lead-ribbon .action-row,
.lead-ribbon .callback-row { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.lead-ribbon .callback-row {
  width: 100%; justify-content: flex-end; padding-top: 10px;
  border-top: 1px solid rgba(148, 178, 226, 0.14);
}
.lead-ribbon .callback-label { font-size: 12px; font-weight: 700; color: #8da3c4; margin-right: 2px; }
.lead-ribbon .callback-current { font-size: 12px; font-weight: 700; color: #e8eefb; white-space: nowrap; margin-left: 4px; }
.lead-ribbon .callback-current .muted { color: #8da3c4; font-weight: 500; }
.lead-ribbon .link { color: #7db4ff; font-size: 13px; font-weight: 700; text-decoration: none; padding: 7px 4px; }
.lead-ribbon .link:hover { color: #a8ccff; }
.lead-ribbon .phone {
  color: #e8eefb; font-size: 13px; font-weight: 700; text-decoration: none;
  background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(148, 178, 226, 0.22);
  border-radius: 10px; padding: 7px 11px;
  font-variant-numeric: tabular-nums;
}
.lead-ribbon .phone:hover { background: rgba(255, 255, 255, 0.1); }
.lead-ribbon .vehicle-phone { margin-top: 2px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lead-ribbon .vehicle-phone .phone { display: inline-block; }
.lead-ribbon button,
.lead-ribbon input {
  height: 34px; border-radius: 10px;
  border: 1px solid rgba(148, 178, 226, 0.22);
  background: rgba(255, 255, 255, 0.06);
  padding: 0 12px; font-size: 13px; font-weight: 700; color: #dbe6f7; font-family: inherit;
}
.lead-ribbon button { cursor: pointer; transition: background 0.12s ease, border-color 0.12s ease; }
.lead-ribbon button:hover { background: rgba(255, 255, 255, 0.11); border-color: rgba(148, 178, 226, 0.38); }
.lead-ribbon .primary {
  background: linear-gradient(180deg, #2f74ff, #1d5af2);
  border-color: #2f6bff; color: #fff;
  box-shadow: 0 6px 18px rgba(47, 107, 255, 0.45);
}
.lead-ribbon .primary:hover { background: linear-gradient(180deg, #3f80ff, #2a64f5); border-color: #3f80ff; }
.lead-ribbon .soft { background: rgba(255, 255, 255, 0.06); }
.lead-ribbon input[type="date"] { width: 138px; color: #c8d6ee; color-scheme: dark; }
.lead-ribbon .ribbon-status-note { color: #8da3c4; font-size: 11px; white-space: nowrap; }
.lead-ribbon .saved-indicator { color: #4ade80; }
@media (max-width: 900px) {
  .lead-ribbon { grid-template-columns: 1fr; gap: 18px; }
  .lead-ribbon .lead-actions { align-items: flex-start; }
  .lead-ribbon .callback-row { justify-content: flex-start; flex-wrap: wrap; }
  .lead-ribbon .action-row { flex-wrap: wrap; }
  .lead-ribbon .vehicle-meta { margin-left: 0; flex-wrap: wrap; }
}

.needs-human-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(185, 28, 28, 0.06);
  border: 1px solid rgba(185, 28, 28, 0.3);
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 13px;
}
.needs-human-bar strong { color: var(--danger); font-size: 12px; letter-spacing: 0.5px; }
.needs-human-bar .reason { color: var(--text); flex: 1; }
.needs-human-bar .when   { color: var(--muted); font-size: 12px; }

.lead-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}
@media (max-width: 900px) {
  .lead-grid { grid-template-columns: 1fr; }
}

/* Layout A: 3 full-height cols (left = lead info + tasks, middle = SMS, right = voice + intake)
 * Grid is pinned to the viewport so SMS thread + Voice transcript scroll
 * IN PLACE instead of pushing the page tall. Falls back to natural height
 * on narrow screens where the cols wrap. */
.lead-3col {
  display: grid;
  grid-template-columns: 0.85fr 1.5fr 1.1fr;
  gap: 12px;
  margin-bottom: 12px;
  align-items: stretch;
  /* JS in tpl.php render_footer sets --grid-h to the exact pixels
   * available between this element's top edge and the viewport bottom
   * (minus a small footer buffer). Falls back to a conservative calc
   * if JS hasn't run yet. */
  height: var(--grid-h, calc(100vh - 220px));
  min-height: 480px;
}
.lead-3col > * { min-height: 0; }
@media (max-width: 1100px) {
  .lead-3col { grid-template-columns: 1fr 1fr; height: auto; }
  .lead-3col > * { min-height: 380px; }
}
@media (max-width: 760px) {
  /* Mobile: stack everything and let each pane grow to its full content,
   * scrolling the PAGE rather than a finicky nested box. Otherwise the SMS
   * Thread was capped at ~380px with an inner scroll that wouldn't move. */
  .lead-3col { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .lead-3col > * { min-height: 0; }
  .col-stack { height: auto; overflow: visible; }
  .lead-pane { min-height: 0; }
  .lead-pane .body,
  .lead-pane.tight .body { flex: 0 0 auto; max-height: none; overflow: visible; }
}

/* Stack panes vertically inside a 3-col cell. Col-stack itself is the
 * grid cell height; tight panes (Vehicle/Status/Notes) stay their content
 * size, the grow pane (Tasks / Voice / etc.) takes the remainder. */
.col-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  /* If sum of stacked panes > grid row height, scroll the column rather
   * than letting it bleed past the viewport bottom. */
  overflow-y: auto;
}
.col-stack > .lead-pane { flex: 1 1 0; min-height: 0; }
.col-stack > .lead-pane.tight { flex: 0 0 auto; }
/* Tight panes' bodies must size to their content, not flex-grow inside
 * the pane (which would leave header-only stubs collapsing to ~30px). */
.lead-pane.tight .body {
  flex: 0 0 auto;
  min-height: 0;
  max-height: none;
  overflow: visible;
}

/* Compact card body w/ k/v rows (Vehicle box, Intake summary) */
.kv-list { font-size: 14px; }
.kv-list .kv {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  align-items: baseline;
}
.kv-list .kv:last-child { border-bottom: none; }
.kv-list .kv .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.3px; white-space: nowrap; }
.kv-list .kv .v { font-weight: 500; text-align: right; word-break: break-word; }
.kv-list .kv .v.mono { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; }

/* Compact status quick-change inside L col */
.status-quick-stacked {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.status-quick-stacked label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-top: 4px;
}
.status-quick-stacked select,
.status-quick-stacked input { padding: 5px 8px; font-size: 13px; }
.status-quick-stacked .btn { padding: 5px 12px; font-size: 12px; align-self: flex-end; }

.intake-quick {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.intake-quick label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.intake-quick select { padding: 5px 8px; font-size: 13px; }
.intake-quick .btn { padding: 5px 12px; font-size: 12px; align-self: flex-end; }
.intake-quick .saved-indicator { font-size: 11px; }

/* Browser-dialer overlay (WebRTC). Fixed bottom-right corner, dismisses
 * when call ends. */
#dialer {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
  padding: 18px 20px;
  z-index: 1000;
  font-size: 14px;
}
#dialer .dialer-state { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
#dialer .dialer-num   { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 18px; font-weight: 600; margin: 6px 0 14px; }
#dialer .dialer-actions { display: flex; gap: 8px; justify-content: flex-end; }
#dialer .dialer-actions .btn { padding: 5px 14px; font-size: 12px; }

/* Intake form drawer — opens from "Intake form" header button on lead
 * page. Slides in from right; leaves the L col (Vehicle / Status / Notes
 * / Tasks) visible so notes + status can be edited while filling out
 * the call. No scrim — outside clicks don't auto-close. */
#intake-modal {
  position: fixed;
  top: 60px;
  right: 16px;
  bottom: 16px;
  z-index: 1100;
}
#intake-modal[hidden] { display: none; }
.intake-modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.22);
  width: min(640px, calc(100vw - 32px));
  max-height: 100%;
  overflow-y: auto;
  padding: 18px 22px;
}
.intake-modal-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.intake-modal-hdr h2 { font-size: 16px; margin: 0; color: var(--text); }
.intake-modal-hdr .listing-link { color: var(--gold); white-space: nowrap; }
.intake-modal-hdr .listing-link:hover { text-decoration: underline; }

.intake-form { display: block; }
.intake-form-status { min-height: 20px; }
.intake-form input[type="text"],
.intake-form select { padding: 4px 9px; font-size: 14px; min-height: 32px; }
.intake-form input[type="text"]::placeholder {
  color: var(--muted);
  font-style: italic;
  opacity: 0.7;
}
.intake-form label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  color: #374151;
  letter-spacing: 0.02em;
}
.intake-form label small { font-weight: 500; color: var(--muted); }
/* Inline header inside a label (e.g. "VIN  small=Read back to confirm"). */
.intake-form .label-inline {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: nowrap;
}
.intake-form textarea {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  width: 100%;
  resize: vertical;
  min-height: 56px;
}
.intake-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(245, 166, 35, 0.15);
}
.intake-form .full-label { width: 100%; }
.intake-form .sr-hide { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.intake-form .summary-bar {
  padding: 6px 10px;
  background: #eef6ff;
  border: 1px solid #cfe8ff;
  border-radius: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  align-items: center;
  margin-bottom: 10px;
}
.intake-form .summary-bar strong { font-size: 11px; color: #1d4ed8; }
.intake-form .summary-bar span {
  background: #fff;
  border: 1px solid #dbeafe;
  padding: 3px 8px;
  border-radius: 999px;
  color: #1d4ed8;
  font-weight: 700;
}

.intake-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px 12px;
  margin-bottom: 10px;
  background: var(--surface);
}
.intake-section.offer-section {
  background: #fff8e6;
  border-color: #f4c76b;
}
.intake-section h3 {
  margin: 0 0 8px;
  font-size: 14px;
  color: #111827;
  text-transform: none;
  letter-spacing: 0;
}

.intake-form .grid-2,
.intake-form .grid-3,
.intake-form .grid-4 {
  display: grid;
  gap: 8px;
}
.intake-form .grid-2 { grid-template-columns: repeat(2, 1fr); }
.intake-form .grid-3 { grid-template-columns: repeat(3, 1fr); }
.intake-form .grid-4 { grid-template-columns: 90px 1fr 1fr 145px; }
.intake-form .row-space { margin-bottom: 8px; }

.intake-form .checkbox-grid {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 6px 14px;
  margin-bottom: 10px;
  align-items: center;
}
.intake-form .checkbox-grid label {
  flex-direction: row;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
}
.intake-form .checkbox-grid input { width: auto; min-height: auto; }

.intake-form .money-input {
  display: flex;
  align-items: center;
  background: #fff;
  border: 2px solid #d89b19;
  border-radius: 10px;
  padding-left: 12px;
}
.intake-form .money-input span {
  font-size: 19px;
  font-weight: 900;
  color: #92400e;
}
.intake-form .money-input input {
  border: 0;
  box-shadow: none;
  font-size: 19px;
  font-weight: 900;
  min-height: 38px;
  padding-left: 4px;
}
.intake-form .money-input input:focus { box-shadow: none; outline: none; }

/* Save confirmation next to the Save Intake button. Pops in on swap so the
 * eye catches it even mid-scroll. */
.intake-saved-flash {
  font-weight: 700;
  white-space: nowrap;
  animation: intake-saved-pop 0.35s ease;
}
@keyframes intake-saved-pop {
  0% { opacity: 0; transform: scale(0.7); }
  60% { transform: scale(1.15); }
  100% { opacity: 1; transform: scale(1); }
}

.intake-form .footer-actions {
  position: sticky;
  bottom: -18px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 0 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.intake-form .complete-toggle {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.intake-form .complete-toggle input { width: auto; min-height: auto; }
.intake-form .btn-save {
  background: var(--gold);
  color: #fff;
  border: 0;
  border-radius: 9px;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
}
.intake-form .btn-save:hover { opacity: 0.9; }

@media (max-width: 760px) {
  .intake-form .grid-2,
  .intake-form .grid-3,
  .intake-form .grid-4,
  .intake-form .checkbox-grid { grid-template-columns: 1fr; }
  .intake-form .footer-actions { flex-direction: column; gap: 10px; align-items: stretch; }
}

/* Task list inline (no surrounding card chrome) */
.tasks-inline ul { list-style: none; padding: 0; margin: 0; }
.tasks-inline li {
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.tasks-inline li:last-child { border-bottom: none; }
.tasks-inline .meta { color: var(--muted); font-size: 11px; }
.tasks-inline .actions { display: flex; gap: 4px; }
.tasks-inline .actions .btn { padding: 2px 8px; font-size: 11px; }
.tasks-inline .task-add-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.tasks-inline .task-add-form input[type="datetime-local"],
.tasks-inline .task-add-form select,
.tasks-inline .task-add-form input[type="text"] {
  font-size: 12px;
  padding: 5px 8px;
}
.tasks-inline .task-add-form .btn { padding: 5px 12px; font-size: 12px; justify-self: end; }
.lead-pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.lead-pane > header {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.lead-pane > header .count { color: var(--text); font-weight: 700; }
.lead-pane .body {
  padding: 10px 14px;
  overflow-y: auto;
  flex: 1 1 0;
  min-height: 0;
}
.lead-pane .notes-strip {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.lead-pane .notes-strip textarea {
  border: none;
  background: transparent;
  font-size: 13px;
  padding: 4px 0;
  resize: vertical;
  min-height: 28px;
}
.lead-pane .notes-strip textarea:focus { box-shadow: none; }
.lead-pane .sms-send {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.lead-pane .sms-send textarea {
  font-size: 13px;
  min-height: 50px;
  margin-bottom: 6px;
}
.lead-pane .sms-send .row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.lead-pane .sms-send .row .btn { padding: 4px 12px; font-size: 12px; }

/* Tighter conversation bubbles for the compact panes */
.lead-pane .conversation { padding: 0; }
.lead-pane .conversation .msg-row { margin-bottom: 5px; }
.lead-pane .conversation .msg { padding: 8px 12px; font-size: 15px; }
.lead-pane .conversation .msg-meta { font-size: 10px; margin-top: 2px; }

details.collapse {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  box-shadow: var(--shadow);
}
details.collapse > summary { color: var(--muted); }
details.collapse > summary::before { color: var(--accent); }
details.collapse[open] > summary { color: var(--text); }

.intake-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 4px 16px;
  font-size: 13px;
}
.intake-grid .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.intake-grid .row .k { color: var(--muted); }
.intake-grid .row .v { font-weight: 500; text-align: right; word-break: break-word; }

/* ── Dashboard components (Twenty look): cards, lists, pills, activity, feed ── */
/* Three equal-width columns regardless of content — Overdue stays the same
 * width even when empty (David 2026-06-16). min-width:0 lets long rows ellipsis
 * instead of stretching their column. */
.dash-grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.dash-grid3 > .card { min-width: 0; }
@media (max-width: 860px) { .dash-grid3 { grid-template-columns: 1fr; } }

.card-h { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px 9px; }
.card-h h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: #52525b; margin: 0; }
.count { font-size: 12px; color: var(--faint); background: var(--surface-2); border-radius: 20px; padding: 1px 8px; }

.card.pad0 { padding: 0; }
.dlist { padding: 2px 6px 10px; max-height: 300px; overflow-y: auto; }
.dli { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 7px; text-decoration: none; color: var(--text); }
.dli:hover { background: #fafafa; text-decoration: none; }
.dli .veh { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dli .sub { color: var(--faint); font-size: 12px; white-space: nowrap; }
.dempty { padding: 16px; text-align: center; color: var(--faint); font-size: 12px; }

.pill { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 6px; white-space: nowrap; }
.pill.t    { color: var(--accent);  background: var(--blue-soft); }
.pill.over { color: var(--danger);  background: #fef1f3; }
.pill.up   { color: var(--success); background: #effaf2; }

.legend { display: flex; gap: 16px; font-size: 12px; align-items: center; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; color: #52525b; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; }
.chart { padding: 6px 16px 16px; }

.feed .fi { display: flex; gap: 10px; padding: 11px 16px; border-top: 1px solid var(--line2); }
.feed .fi:first-child { border-top: none; }
.feed .fi .fav { flex: 0 0 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; color: #fff; }
.feed .fav.ai  { background: #7c3aed; }
.feed .fav.robert { background: #0ea5a4; }
.feed .fav.david  { background: #1961ed; }
.feed .fav.inbound { background: #16a34a; }
.feed .fav.unknown { background: #71717a; }
.feed .fi .body { font-size: 13px; line-height: 1.45; }
.feed .fi .body .who { font-weight: 600; }
.feed .fi .body .m { color: var(--muted); }
.feed .fi .t { color: var(--faint); font-size: 12px; }

/* ── Mobile lead page (placed LAST so it overrides the unconditional
 *    .lead-pane .body rule above). Panes grow to content; page scrolls;
 *    SMS Thread + Voice Transcript fully viewable. ── */
@media (max-width: 760px) {
  .lead-3col { grid-template-columns: 1fr !important; height: auto !important; min-height: 0 !important; }
  .lead-3col > * { min-height: 0 !important; }
  .col-stack { height: auto !important; overflow: visible !important; }
  .lead-pane { min-height: 0 !important; }
  .lead-pane .body,
  .lead-pane.tight .body { overflow: visible !important; flex: 0 0 auto !important; max-height: none !important; }
}
