/* Titanium Auto CRM — hand-written design tokens + components (BLUEPRINT §20, §25.5). */
/* Theme matches titaniumauto.ca (Lux site) and the trade-in tool: Saira italic headings, Figtree body,
   ink-black pill buttons, brand red + navy. Owner request 2026-11-12. Red stays reserved for brand + alerts. */
:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #efefec;
  --ink: #0e1015;
  --ink-2: #3f434c; /* 9.9:1 on white */
  --ink-3: #5c616d; /* 6.3:1 on white */
  --line: #e0e0dc;
  --accent: #1f3c88; /* website navy, 10:1 on white: links, info */
  --accent-ink: #ffffff;
  --accent-soft: #e9edf7;
  --brand: #e3242b; /* website red: wordmark, add button, active tab */
  --brand-strong: #c41d24; /* 5.9:1 on white, for small text */
  --brand-ink: #ffffff;
  --danger: #b3261e; /* 6.2:1 on white */
  --danger-soft: #fdecea;
  --warn: #8a5300;
  --warn-soft: #fff4e0;
  --ok: #17733d;
  --ok-soft: #e7f5ec;
  --focus: #0e1015;
  --inverse: #0e1015;
  --inverse-ink: #ffffff;
  --field: #ffffff;
  --field-line: #b4b5b0;
  --info: #1f3c88;
  --info-soft: #e9edf7;
  --violet: #6b21a8;
  --violet-soft: #f3e8ff;
  --danger-line: #f0c2bd;
  --warn-line: #f1d39b;
  --radius: 14px;
  --radius-s: 10px;
  --shadow: 0 1px 2px rgba(14, 16, 21, 0.05), 0 6px 20px rgba(14, 16, 21, 0.05);
  --tap: 44px;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --disp: 'Saira', 'Figtree', system-ui, sans-serif;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

/* Night: follows the phone/tablet/computer's own light-dark setting (owner decision 2026-11-12). */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #14171c;
    --surface-2: #1d2128;
    --ink: #f2f3f5;
    --ink-2: #cfd2d8;
    --ink-3: #a1a6b1; /* 7.2:1 on surface */
    --line: #2b3039;
    --accent: #9db4f2; /* 8.6:1 on surface */
    --accent-ink: #0e1015;
    --accent-soft: #1c2740;
    --brand: #ef3a41;
    --brand-strong: #ff6b70;
    --brand-ink: #ffffff;
    --danger: #ff8f85;
    --danger-soft: #3d1a17;
    --warn: #f0a648;
    --warn-soft: #3a2a10;
    --ok: #4cc27e;
    --ok-soft: #14301f;
    --focus: #f2f3f5;
    --inverse: #f2f3f5;
    --inverse-ink: #0e1015;
    --field: #0f1115;
    --field-line: #4a505c;
    --info: #9db4f2;
    --info-soft: #1c2740;
    --violet: #d1a7f7;
    --violet-soft: #2f1c44;
    --danger-line: #6b2c27;
    --warn-line: #6b4d18;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 6px 20px rgba(0, 0, 0, 0.35);
  }
  /* Signatures are always dark ink on a white pad (they go into the waiver PDF). */
  .sig-canvas { background: #ffffff; border-radius: 8px; }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.45 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5rem; font-family: var(--disp); font-weight: 800; font-style: italic; letter-spacing: -0.005em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 0.75rem; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 0; background: var(--inverse); color: var(--inverse-ink); padding: 0.75rem 1rem; z-index: 100; }
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ---------- layout ---------- */
.app { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr auto; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; background: var(--surface); border-bottom: 1px solid var(--line); min-height: 56px; }
.brand { display: inline-flex; align-items: baseline; gap: 0.45rem; color: var(--ink); text-decoration: none; min-height: var(--tap); align-items: center; }
/* Wordmark: same construction as the website (TITANIUM // AUTO.ca). */
.mark { display: inline-flex; align-items: center; gap: 0.26em; font-family: var(--disp); font-size: 1.15rem; line-height: 1; white-space: nowrap; color: var(--ink); }
.mark-ti { font-weight: 900; font-style: italic; letter-spacing: -0.01em; }
.mark-au { font-weight: 400; font-style: italic; letter-spacing: 0.01em; }
.mark-au em { color: var(--brand); font-weight: 500; }
.mark .slash { display: inline-flex; gap: 0.08em; height: 0.8em; transform: skewX(-18deg); }
.mark .slash i { display: block; width: 0.28em; height: 100%; background: var(--accent); }
.mark .slash i + i { background: var(--brand); }
.brand .tag, .td-brand .tag { font: 700 0.68rem var(--font); letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; }
@media (max-width: 380px) { .mark { font-size: 1rem; } .brand .tag { display: none; } }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--inverse); color: var(--inverse-ink); display: grid; place-items: center; font-size: 0.85rem; font-weight: 800; }
.brand small { display: block; font-weight: 500; font-size: 0.75rem; color: var(--ink-3); }
.topbar .spacer { flex: 1; }
.duty { font-size: 0.8rem; color: var(--ink-2); display: none; }
[hidden] { display: none !important; }
.banner { padding: 0.5rem 0.75rem; font-size: 0.9rem; display: flex; gap: 0.5rem; align-items: center; justify-content: center; }
.banner.offline { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--accent-soft); color: var(--accent); }
main { min-width: 0; padding: 0.75rem; padding-bottom: calc(148px + var(--safe-bottom)); max-width: 1180px; width: 100%; margin: 0 auto; }
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); }
.tabbar a, .tabbar button { flex: 1; min-height: 56px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 0.72rem; color: var(--ink-2); text-decoration: none; background: none; border: 0; font-family: inherit; position: relative; }
.tabbar a[aria-current='page'] { color: var(--ink); font-weight: 700; box-shadow: inset 0 3px 0 var(--brand); }
.tabbar .ico { font-size: 1.25rem; line-height: 1; }
.tabbar .count { position: absolute; top: 6px; left: 55%; background: var(--danger); color: var(--surface); font-size: 0.68rem; font-weight: 700; border-radius: 999px; min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; }
.fab { position: fixed; right: 1rem; bottom: calc(72px + var(--safe-bottom)); z-index: 21; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--brand); color: var(--brand-ink); font-size: 1.8rem; box-shadow: 0 6px 16px rgba(227, 36, 43, 0.35); cursor: pointer; display: grid; place-items: center; text-decoration: none; }
.sidebar { display: none; }

@media (min-width: 768px) {
  .app { grid-template-columns: 232px minmax(0, 1fr); grid-template-rows: auto auto 1fr; }
  .topbar { grid-column: 1 / -1; }
  .banner { grid-column: 1 / -1; }
  .sidebar { display: flex; flex-direction: column; gap: 2px; padding: 0.75rem 0.5rem; border-right: 1px solid var(--line); background: var(--surface); position: sticky; top: 56px; height: calc(100vh - 56px); overflow-y: auto; }
  .sidebar a { display: flex; align-items: center; gap: 0.6rem; min-height: var(--tap); padding: 0 0.75rem; border-radius: var(--radius-s); color: var(--ink); text-decoration: none; }
  .sidebar a:hover { background: var(--surface-2); }
  .sidebar a[aria-current='page'] { background: var(--surface-2); color: var(--ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--brand); }
  .sidebar .count { margin-left: auto; background: var(--danger); color: var(--surface); font-size: 0.72rem; font-weight: 700; border-radius: 999px; padding: 0 7px; }
  .tabbar { display: none; }
  .fab { bottom: 1.5rem; right: 1.5rem; }
  main { padding: 1.25rem 1.5rem calc(56px + 3rem); }
  .duty { display: block; }
}

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: 0.75rem; }
.card.act { border-left: 4px solid var(--danger); }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin: 1.1rem 0 0.5rem; }
.section-title h2 { margin: 0; }
.muted { color: var(--ink-3); }
.small { font-size: 0.85rem; }
.row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 0.5rem; }
.grid2 { display: grid; gap: 0.75rem; }
@media (min-width: 900px) { .grid2 { grid-template-columns: 1fr 1fr; } .two-pane { display: grid; grid-template-columns: 380px 1fr; gap: 1rem; align-items: start; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: var(--tap); min-width: var(--tap); padding: 0 1.1rem; border-radius: 999px; border: 1px solid var(--field-line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--inverse); border-color: var(--inverse); color: var(--inverse-ink); }
.btn.primary:hover { background: var(--inverse); opacity: 0.88; }
.btn.danger { color: var(--danger); border-color: var(--danger-line); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { min-height: 36px; padding: 0 0.7rem; font-size: 0.9rem; }
.btn[disabled], .btn[aria-disabled='true'] { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; }
.icon-btn { min-width: var(--tap); min-height: var(--tap); border: 0; background: transparent; border-radius: 50%; font-size: 1.25rem; cursor: pointer; color: var(--ink-2); position: relative; display: inline-grid; place-items: center; text-decoration: none; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .dot { position: absolute; top: 8px; right: 8px; min-width: 16px; height: 16px; border-radius: 999px; background: var(--danger); color: var(--surface); font-size: 0.65rem; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }

label.field { display: block; margin-bottom: 0.75rem; }
label.field > span { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--ink-2); }
input, select, textarea { font: inherit; color: var(--ink); width: 100%; min-height: var(--tap); padding: 0.55rem 0.7rem; border: 1px solid var(--field-line); border-radius: var(--radius-s); background: var(--field); }
textarea { min-height: 88px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--ink); }
input[type='checkbox'], input[type='radio'] { width: 22px; min-height: 22px; height: 22px; accent-color: var(--ink); }
.check { display: flex; gap: 0.6rem; align-items: flex-start; min-height: var(--tap); padding: 0.5rem 0; }
.check input { margin-top: 2px; flex: none; }
.err { color: var(--danger); font-size: 0.88rem; margin-top: 0.25rem; }
.hint { font-size: 0.85rem; color: var(--ink-3); margin-top: 0.25rem; }

.chip { display: inline-flex; align-items: center; gap: 0.3rem; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.chip.new { background: var(--accent-soft); color: var(--accent); }
.chip.contacted { background: var(--info-soft); color: var(--info); }
.chip.appointment_set { background: var(--violet-soft); color: var(--violet); }
.chip.showed { background: var(--warn-soft); color: var(--warn); }
.chip.sold { background: var(--ok-soft); color: var(--ok); }
.chip.lost { background: var(--surface-2); color: var(--ink-3); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

.list { list-style: none; padding: 0; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > li + li { border-top: 1px solid var(--line); }
.list-item { display: flex; gap: 0.75rem; align-items: center; padding: 0.75rem 0.9rem; min-height: 64px; color: inherit; text-decoration: none; }
a.list-item:hover { background: var(--surface-2); }
.list-item .actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 599px) {
  .list-item.wrap-actions { flex-wrap: wrap; }
  .list-item.wrap-actions > .grow { flex: 1 1 calc(100% - 60px); min-width: 0; }
  .list-item.wrap-actions > .actions { flex: 1 1 100%; justify-content: flex-start; }
}
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 0.85rem; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2); font-weight: 700; font-size: 0.8rem; flex: none; }
.overdue { color: var(--danger); font-weight: 600; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--ink-3); }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--line); margin: 0.75rem 0; overflow-x: auto; }
.tabs button { min-height: var(--tap); border: 0; background: none; padding: 0 0.9rem; font: inherit; font-weight: 600; color: var(--ink-3); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--brand); }

.filters { display: flex; gap: 0.4rem; overflow-x: auto; padding-bottom: 0.25rem; margin-bottom: 0.5rem; }
.filters .btn { flex: none; min-height: 38px; font-size: 0.9rem; border-radius: 999px; }
.filters .btn[aria-pressed='true'] { background: var(--inverse); border-color: var(--inverse); color: var(--inverse-ink); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
.timeline li.in { background: var(--accent-soft); padding-left: 0.75rem; padding-right: 0.75rem; border-radius: var(--radius-s); }
.timeline .when { font-size: 0.8rem; color: var(--ink-3); }
.timeline .body { white-space: pre-wrap; overflow-wrap: anywhere; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; }
.kv dt { color: var(--ink-3); font-size: 0.9rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(15, 20, 25, 0.45); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 1rem 1rem calc(1rem + var(--safe-bottom)); box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2); }
@media (min-width: 768px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 16px; } }
.sheet header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }

.toast-region { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + var(--safe-bottom)); z-index: 60; display: flex; flex-direction: column; gap: 0.5rem; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--inverse); color: var(--inverse-ink); padding: 0.75rem 1rem; border-radius: var(--radius-s); box-shadow: var(--shadow); pointer-events: auto; }
.toast.error { background: var(--danger); }

.login { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login .card { width: min(420px, 100%); padding: 1.5rem; }
.login .brand { margin-bottom: 1.25rem; font-size: 1.15rem; }
.code-input { font-size: 1.6rem; letter-spacing: 0.35em; text-align: center; font-variant-numeric: tabular-nums; }

.upnext { display: flex; align-items: center; gap: 0.5rem; background: var(--surface); border: 1px dashed var(--field-line); color: var(--ink); border-radius: var(--radius); padding: 0.6rem 0.9rem; margin-bottom: 0.75rem; font-size: 0.95rem; }
.upnext strong { color: var(--ink); font-weight: 800; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 700; }
.dup { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--radius-s); padding: 0.6rem 0.8rem; margin-bottom: 0.75rem; }
.loading { padding: 2rem; text-align: center; color: var(--ink-3); }

/* Inbound message detail (review fix pass) */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 0.35rem 1rem; margin: 0 0 1rem; }
.facts dt { color: var(--ink-3); font-size: 0.9rem; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.actions-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
pre.raw { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); padding: 0.75rem; border-radius: 8px; max-height: 60vh; overflow: auto; font-size: 0.85rem; }

/* Lead header contact line (U1) */
.contact-line { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; margin-top: 0.5rem; }
.contact-line .contact { display: inline-flex; align-items: center; min-height: var(--tap); color: var(--accent); text-decoration: none; font-weight: 600; overflow-wrap: anywhere; }
.contact-line span.contact { color: var(--ink-2); }
/* Lead tabs never truncate on phones (U1): equal-width tabs that may wrap to two lines */
@media (max-width: 599px) {
  .tabs { overflow-x: visible; gap: 0; }
  .tabs button { flex: 1 1 0; min-width: 0; padding: 0.25rem 0.2rem; white-space: normal; line-height: 1.15; font-size: 0.86rem; text-align: center; }
}
/* No FAB on the Add walk-in form itself (U2) */
body[data-route='add'] .fab { display: none; }
/* "Someone else changed this deal": pinned under the top bar while it is unresolved (QA review L4). */
.deal-conflict:not(:empty) { position: sticky; top: 60px; z-index: 6; }
.deal-conflict .banner { box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18); }
/* One container per screen render (QA review M4): invisible to layout. */
main > .view { display: contents; }
main:focus { outline: none; } /* programmatic focus target for screen readers, not interactive (U5) */
input[aria-invalid='true'] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
/* Settings sections wrap instead of scrolling off-screen on phones; compact hours rows */
.filters[aria-label='Settings sections'] { flex-wrap: wrap; overflow-x: visible; }
.actions input[type='time'] { width: 8.5rem; flex: none; }

/* Phase 2: inventory (§16.6) */
.inv-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.75rem; }
.inv-filters .grow { flex: 1 1 100%; }
.inv-filters select, .inv-filters input { min-height: var(--tap); }
@media (min-width: 900px) { .inv-filters .grow { flex: 1 1 280px; } }
.list.vehicles { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
@media (min-width: 900px) { .list.vehicles { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); } }
.vehicle-card { display: flex; gap: 0.75rem; align-items: center; padding: 0.6rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; min-height: 64px; }
.vehicle-card:hover { border-color: var(--ink); }
.vehicle-card img, .photo-ph { color: transparent; font-size: 0; width: 120px; height: 90px; flex: none; border-radius: var(--radius-s); object-fit: cover; background: var(--surface-2); }
.photo-ph { display: grid; place-items: center; font-size: 2rem; color: var(--ink-3); }
.vehicle-card .grow { min-width: 0; }
.vehicle-card .title { font-weight: 600; overflow-wrap: anywhere; }
.price { font-weight: 700; font-size: 1.05rem; }
.photo-strip { display: flex; gap: 0.5rem; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 0.25rem; margin-bottom: 0.75rem; }
.photo-strip img { height: 150px; width: 200px; object-fit: cover; background: var(--surface-2); color: transparent; font-size: 0; border-radius: var(--radius-s); scroll-snap-align: start; flex: none; }
/* Phase 2: merge (§8.4) */
.table-wrap { overflow-x: auto; }
table.compare { width: 100%; border-collapse: collapse; }
table.compare th, table.compare td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
table.compare th[scope='row'] { font-weight: 600; color: var(--ink-2); white-space: nowrap; }
label.radio { display: flex; align-items: center; gap: 0.4rem; min-height: var(--tap); cursor: pointer; }
label.radio input { width: 20px; height: 20px; flex: none; margin: 0; }
ul.plain { list-style: none; padding: 0; margin: 0 0 0.5rem; }
ul.plain li { padding: 0.15rem 0; overflow-wrap: anywhere; }
fieldset.card legend { font-weight: 700; padding: 0 0.3rem; }
@media (max-width: 599px) {
  /* Merge values stack on phones: field name on its own line, the two choices side by side below it. */
  table.compare thead { display: none; }
  table.compare tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0 0.5rem; border-bottom: 1px solid var(--line); padding: 0.35rem 0; }
  table.compare th, table.compare td { border-bottom: 0; padding: 0.15rem 0.25rem; }
  table.compare th[scope='row'] { grid-column: 1 / -1; }
}
/* Reconciliation report banners */
main .banner { border-radius: var(--radius-s); margin-bottom: 0.75rem; justify-content: flex-start; }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
/* Phase 2 review: sheet submit always reachable on phones (code M11); review reasons wrap (code L13) */
.sheet-footer { position: sticky; bottom: calc(-1rem - var(--safe-bottom)); background: var(--surface); padding: 0.75rem 0 calc(0.25rem + var(--safe-bottom)); margin-top: 0.5rem; border-top: 1px solid var(--line); }
.meta.wrap { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
/* Merge on phones: each choice says which record it is (code M12); duplicate clusters (code L13) */
@media (max-width: 599px) {
  table.compare td[data-label]::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--ink-3); font-weight: 600; }
}
.list.nested { margin: 0 0 0.5rem 1rem; border-left: 2px solid var(--line); }
/* Inventory: foldable filters on phones (code L12) */
details.inv-more { margin-bottom: 0.5rem; }
details.inv-more > summary { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 600; color: var(--accent); }
.banner.warn .btn { margin-left: 0.25rem; }
main .banner { flex-wrap: wrap; }

/* ---------- Phase 3: open late, calendar, dashboard ---------- */
.banner.late { background: #1f2a44; color: #fff; }
.banner.late .btn { min-height: 32px; color: var(--ink); }
.late-btn { white-space: nowrap; }
@media (max-width: 420px) { .late-btn { min-width: 44px; min-height: 44px; padding: 0; font-size: 1.2rem; } .late-btn .late-text { display: none; } }
.seg { display: inline-flex; gap: 0.25rem; flex: none; }
.seg .btn[aria-pressed='true'] { background: var(--inverse); border-color: var(--inverse); color: var(--inverse-ink); }
.cal-tools { flex-wrap: wrap; align-items: center; overflow-x: visible; }
.cal-tools select { width: auto; flex: none; min-height: 38px; border-radius: 999px; border: 1px solid var(--line); padding: 0 0.75rem; background: var(--surface); font: inherit; font-size: 0.9rem; }
.agenda-day { font-size: 0.95rem; color: var(--ink-2); margin: 1rem 0 0.4rem; }
button.list-item, .appt-row { width: 100%; border: 0; background: none; font: inherit; text-align: left; cursor: pointer; }
.appt { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; padding: 0.5rem 0.75rem; min-height: var(--tap); border: 1px solid var(--line); border-left: 4px solid var(--ink); border-radius: var(--radius-s); background: var(--surface); font: inherit; text-align: left; cursor: pointer; overflow: hidden; color: var(--ink); }
.appt.test_drive { border-left-color: var(--brand); }
.appt.trade_appraisal { border-left-color: var(--warn); }
.appt.delivery { border-left-color: var(--ok); }
.appt.callback { border-left-color: var(--violet); }
.appt.confirmed { background: var(--ok-soft); }
.appt.needs { border-color: var(--danger); }
.appt.busy { background: repeating-linear-gradient(135deg, var(--surface-2), var(--surface-2) 6px, var(--surface) 6px, var(--surface) 12px); border-left-color: var(--ink-3); cursor: default; color: var(--ink-2); }
.appt-time { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); }
.appt-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.appt-meta { font-size: 0.78rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cal-grid { --cols: 1; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.cal-head, .cal-body { display: grid; grid-template-columns: 52px repeat(var(--cols), minmax(150px, 1fr)); min-width: calc(52px + var(--cols) * 150px); }
.cal-head { position: sticky; top: 0; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cal-col-head { padding: 0.5rem; font-weight: 700; font-size: 0.85rem; border-left: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-body { position: relative; }
.cal-hours { position: relative; }
.cal-hour { position: absolute; left: 0; right: 0; font-size: 0.72rem; color: var(--ink-3); padding: 2px 4px; border-top: 1px solid var(--line); }
.cal-col { position: relative; border-left: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 90px; }
.cal-col .appt { position: absolute; left: 3px; right: 3px; width: auto; min-height: 0; padding: 0.2rem 0.4rem; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; margin-bottom: 0.75rem; }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile { margin: 0; text-decoration: none; color: inherit; display: block; }
.tile.warn { border-left: 4px solid var(--danger); }
.tile-value { font-size: 1.7rem; font-weight: 800; }
.health-strip { display: grid; gap: 0.75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.gate { list-style: none; padding: 0; margin: 0 0 0.75rem; }
.gate-row { display: flex; gap: 0.6rem; align-items: center; padding: 0.35rem 0; }

/* ---------- Phase 3 review: one-tap contact rows, vehicle picker ---------- */
.row-with-actions { display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap; }
.row-with-actions > .list-item, .row-with-actions > .appt { flex: 1 1 220px; min-width: 0; }
.contact-actions { display: flex; gap: 0.35rem; padding: 0 0.6rem 0.6rem; flex: 0 0 auto; }
.contact-actions .btn { min-height: var(--tap); min-width: var(--tap); padding: 0 0.6rem; }
.contact-actions .act-label { font-size: 0.85rem; }
@media (max-width: 420px) { .contact-actions { width: 100%; padding-top: 0; } .contact-actions .btn { flex: 1; } }
.vehicle-results .btn { justify-content: flex-start; text-align: left; }
.agenda .appt { min-height: 56px; }

/* ---------- UI polish (C.9): time badge, two-line task titles, stacked actions on phones ---------- */
.time-badge { flex: none; min-width: 64px; padding: 0.35rem 0.4rem; border-radius: var(--radius-s); background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 0.8rem; text-align: center; line-height: 1.2; white-space: nowrap; }
.list-item .title.wrap2 { white-space: normal; display: -webkit-box !important; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-row .task-actions { display: flex; gap: 0.4rem; flex: none; }
@media (max-width: 480px) {
  .task-row { flex-wrap: wrap; }
  .task-row > .grow { flex: 1 1 100%; }
  .task-row .task-actions { width: 100%; }
  .task-row .task-actions .btn { flex: 1; }
}

/* ---------- Phase 4: phone / texting ---------- */
main .banner { border-radius: var(--radius-s); justify-content: flex-start; margin-bottom: 0.75rem; flex-wrap: wrap; text-align: left; }
main .banner.warn { background: var(--warn-soft); color: var(--warn); }
main .banner.danger { background: var(--danger-soft, var(--warn-soft)); color: var(--danger, var(--warn)); }
.sms-preview { white-space: pre-wrap; background: var(--surface-2); border-radius: var(--radius-s); padding: 0.6rem 0.75rem; margin: 0.25rem 0 0.5rem; font-size: 0.95rem; min-height: 2.5rem; }
.screen-pop { position: fixed; right: 1rem; bottom: 1rem; z-index: 60; display: flex; gap: 0.5rem; align-items: center; background: var(--surface); color: var(--ink); border: 1px solid var(--line, #ddd); border-radius: var(--radius-s); padding: 0.75rem 1rem; box-shadow: 0 6px 24px rgba(0,0,0,.18); max-width: min(28rem, calc(100vw - 2rem)); }
.screen-pop a { font-weight: 700; }
label.check { display: flex; gap: 0.5rem; align-items: center; margin: 0.5rem 0 0.75rem; min-height: 44px; }
/* Code U5 (v1.9): with the RingCentral widget's badge bottom-right on desktop, the FAB moves up, clear of it. */
@media (min-width: 768px) { body.rc-widget .fab { bottom: 6.5rem; } }
.seg-count { font-variant-numeric: tabular-nums; }

/* Phase 5 — reports: plain CSS bars (no chart library), readable on phones (cards stack) and desktops. */
.report-period { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; align-items: flex-end; margin-bottom: 0.75rem; }
.report-period .field { margin: 0; min-width: 140px; }
.report-period .check { display: flex; gap: 0.4rem; align-items: center; min-height: 44px; }
.bar-row { display: grid; grid-template-columns: minmax(84px, 34%) 1fr auto; gap: 0.5rem; align-items: center; margin: 0.3rem 0; font-size: 0.9rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; background: var(--line, #e3e6ea); border-radius: 999px; overflow: hidden; min-width: 40px; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--ink); }
.bar-fill.ok { background: var(--ok); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.danger { background: var(--danger); }
.bar-value { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; font-size: 0.85rem; }
@media (max-width: 520px) {
  .bar-row { grid-template-columns: 1fr auto; }
  .bar-row .bar-track { grid-column: 1 / -1; grid-row: 2; }
}
.funnel .bar-track { height: 18px; }
.report-card h3 { margin: 0; font-size: 1.05rem; }
.kv.compact { margin-top: 0.6rem; font-size: 0.88rem; }
.kv dd.overdue { color: var(--danger); font-weight: 600; }
.inv-row { padding: 0.35rem 0; border-bottom: 1px solid var(--line, #e3e6ea); }
.inv-row:last-child { border-bottom: 0; }
.cost-grid { display: grid; gap: 0.5rem 0.75rem; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); margin-bottom: 0.75rem; }
.alt-list { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.88rem; }
.chip.vehicle-gone { background: var(--danger-soft); color: var(--danger); font-weight: 700; }

/* ---------- Phase 5 review (v1.11): compact report table with a sticky source column (U2) ---------- */
table.report-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.9rem; }
table.report-table th, table.report-table td { padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.report-table .num { text-align: right; font-variant-numeric: tabular-nums; }
table.report-table .src { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; max-width: 9rem; overflow: hidden; text-overflow: ellipsis; }
table.report-table thead th { font-size: 0.8rem; color: var(--ink-3); font-weight: 600; }
@media (max-width: 599px) { .desktop-only { display: none !important; } }
/* U3: lead "Next steps" — task titles wrap to two lines, the heading wraps above its buttons, room for the FAB */
.section-title.wrap { flex-wrap: wrap; gap: 0.5rem; }
@media (max-width: 899px) { .fab-pad { padding-bottom: calc(88px + var(--safe-bottom)); } }
/* U6: lead tabs on phones stay on one line each and scroll sideways if they must */
@media (max-width: 599px) {
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs button { flex: 1 0 auto; white-space: nowrap; padding: 0.25rem 0.55rem; }
}

/* ---------- Phase 6: Test Drive tablet (/td) ---------- */
body[data-route='td'] { background: var(--bg, #f4f5f7); }
.td { max-width: 980px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }
.td-top { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.td-brand { flex: 1; font-size: 1.05rem; display: flex; align-items: center; gap: 0.5rem; }
.td-who { font-weight: 600; color: var(--ink-2); }
.td-main { padding: 1rem; display: flex; flex-direction: column; gap: 0.85rem; }
.td-main h1 { margin: 0.25rem 0; font-size: 1.6rem; }
.td-big { min-height: 64px; font-size: 1.2rem; }
.td-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.td-staff { min-height: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.25rem; font-size: 1.1rem; }
.td-dots { font-size: 2rem; letter-spacing: 0.6rem; text-align: center; }
.td-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; max-width: 360px; margin: 0 auto; width: 100%; }
.td-key { min-height: 72px; font-size: 1.6rem; }
.td-two { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
@media (min-width: 700px) { .td-two { grid-template-columns: 1fr 1fr; } }
.td-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.td-chips .btn { min-height: 52px; min-width: 88px; }
.td-cars { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.td-car { width: 100%; text-align: left; border: 1px solid var(--line); border-radius: var(--radius-s, 10px); background: var(--surface); padding: 0.5rem; display: flex; flex-direction: column; gap: 0.25rem; cursor: pointer; min-height: 44px; }
.td-car.on { outline: 3px solid var(--accent); }
.td-car img, .td-nophoto { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--line); display: grid; place-items: center; font-size: 2rem; }
.td-car[disabled] { opacity: 0.55; cursor: not-allowed; }
.td-pill { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0.4rem 0.9rem; align-self: flex-start; }
.td-video { width: 100%; max-height: 300px; background: #000; border-radius: 8px; object-fit: cover; }
.td-photo img { max-width: 260px; border-radius: 6px; }
.td-waiver { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 0.75rem 1rem; max-height: 46vh; overflow: auto; line-height: 1.45; }
.td-waiver p { margin: 0 0 0.6rem; }
.td-agree { font-size: 1.1rem; min-height: 52px; }
.td-agree input { width: 28px; height: 28px; }
.sig-wrap { background: var(--surface); border: 2px dashed var(--line); border-radius: 8px; padding: 0.25rem; }
.sig-canvas { width: 100%; height: 200px; display: block; touch-action: none; cursor: crosshair; }
.sig-line { display: flex; justify-content: space-between; align-items: center; color: var(--ink-3); padding: 0 0.5rem; }
.td-done { font-size: 2rem; font-weight: 700; color: var(--ok); }
.td-out.overdue { border-left: 4px solid var(--danger, #b42318); }
.td-pair { max-width: 460px; }
.pair-code { font-size: 2.2rem; font-weight: 700; letter-spacing: 0.3rem; font-family: ui-monospace, monospace; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* C.14: in-app PIN modal on the test-drive tablet (never a browser prompt). */
.td-modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.td-modal-card { width: min(420px, 100%); max-height: 100%; overflow: auto; }
.td-modal .td-pad { margin-top: .5rem; }

/* ---------- inventory dropdown (search + Undecided) ---------- */
div.field { display: block; margin-bottom: 0.75rem; }
div.field > .field-label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 0.25rem; color: var(--ink-2); }
.vp-toggle { justify-content: space-between; border-radius: var(--radius-s); font-weight: 600; text-align: left; background: var(--field); border-color: var(--field-line); }
.vp-current { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.vp-panel { margin-top: 0.4rem; border: 1px solid var(--field-line); border-radius: var(--radius-s); background: var(--surface); padding: 0.5rem; box-shadow: var(--shadow); }
.vp-panel input[type='search'] { width: 100%; margin-bottom: 0.35rem; }
.vp-list { max-height: 260px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin-top: 0.35rem; overscroll-behavior: contain; }
.vp-option { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; min-height: var(--tap); padding: 0.4rem 0.6rem; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.vp-option:hover, .vp-option:focus-visible { background: var(--surface-2); }
.vp-option[aria-selected='true'] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--brand); }
button.contact-btn { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; text-align: left; }
button.contact-btn[disabled] { cursor: default; opacity: 0.7; }

/* ---------- Inventory v1.3: photo cards, gallery, spec grid ---------- */
.vgrid { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
@media (max-width: 560px) { .vgrid { grid-template-columns: 1fr; } }
.vcard { display: flex; flex-direction: column; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: inherit; text-decoration: none; }
.vcard:hover { border-color: var(--ink); }
.vcard-photo, .gallery-main { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.vcard-photo img, .vcard-photo .photo-ph, .gallery-main img, .gallery-main .photo-ph { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.vcard-photo .photo-ph, .gallery-main .photo-ph { display: grid; place-items: center; font-size: 2.5rem; color: var(--ink-3); }
.vcard-count { position: absolute; right: 0.5rem; bottom: 0.5rem; padding: 0.15rem 0.5rem; border-radius: 999px; background: rgba(14, 16, 21, 0.72); color: #fff; font-size: 0.72rem; font-weight: 600; }
.vcard-body { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.75rem 0.85rem 0.9rem; min-width: 0; }
.vcard-name { font-weight: 800; font-size: 1.05rem; line-height: 1.2; overflow-wrap: anywhere; }
.vcard-trim { color: var(--ink-2); font-size: 0.88rem; }
.vcard-price { font-size: 1.15rem; font-weight: 800; margin-top: 0.15rem; }
.vcard-meta { color: var(--ink-3); font-size: 0.82rem; }
.vcard-tags { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-top: 0.3rem; }
.tag { padding: 0.15rem 0.55rem; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.75rem; color: var(--ink-2); white-space: nowrap; }
.tag.more { background: none; }
.gallery { margin: -0.25rem 0 0.9rem; }
.gallery-main { border-radius: var(--radius-s); overflow: hidden; max-height: 70vh; }
@media (min-width: 900px) { .gallery-main { aspect-ratio: 16 / 9; } .gallery-main img { object-fit: contain; background: #0e1015; } }
.gallery-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 999px; border: 0; background: rgba(14, 16, 21, 0.6); color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer; }
.gallery-nav.prev { left: 0.5rem; }
.gallery-nav.next { right: 0.5rem; }
.gallery-thumbs { display: flex; gap: 0.4rem; overflow-x: auto; padding: 0.5rem 0 0.25rem; }
.gallery-thumb { flex: none; width: 84px; height: 63px; padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--surface-2); cursor: pointer; }
.gallery-thumb[aria-pressed='true'] { border-color: var(--brand); }
.gallery-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vdetail-head { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: flex-start; }
.vdetail-price { font-size: 1.5rem; font-weight: 800; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.6rem 1rem; margin: 1rem 0; }
.spec-grid > div { min-width: 0; }
.spec-grid dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); }
.spec-grid dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.vdesc { white-space: pre-line; margin: 0; font-size: 0.92rem; color: var(--ink-2); }
.feat-sum { min-height: var(--tap); display: flex; align-items: center; cursor: pointer; font-weight: 700; }
.feat-list { columns: 220px; column-gap: 1.5rem; margin: 0.5rem 0 0; padding-left: 1.1rem; font-size: 0.88rem; color: var(--ink-2); }

/* ---------- Calendar v1.3: month grid, week strip, clear range header ---------- */
.cal-bar { display: flex; flex-wrap: wrap; gap: 0.6rem 1rem; align-items: center; justify-content: space-between; margin-bottom: 0.6rem; }
.cal-nav { display: flex; align-items: center; gap: 0.35rem; }
.cal-range { min-width: 9.5rem; text-align: center; font-size: 1.05rem; }
@media (max-width: 700px) { .cal-views { width: 100%; } .cal-views .btn { flex: 1; } .cal-nav { width: 100%; } .cal-range { flex: 1; } }
.mcal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 0.5rem; }
.mcal-head { padding: 0.4rem 0; text-align: center; font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); background: var(--surface-2); border-bottom: 1px solid var(--line); }
.mcal-day { display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-height: 104px; padding: 0.35rem; border: 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); background: none; font: inherit; color: var(--ink); text-align: left; cursor: pointer; min-width: 0; }
.mcal-day:nth-child(7n + 1) { border-left: 0; }
.mcal-day:hover { background: var(--surface-2); }
.mcal-day.other { color: var(--ink-3); background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.mcal-day.selected { box-shadow: inset 0 0 0 2px var(--ink); }
.mcal-num { align-self: flex-start; min-width: 1.7rem; height: 1.7rem; display: grid; place-items: center; border-radius: 999px; font-weight: 700; font-size: 0.9rem; }
.mcal-day.today .mcal-num { background: var(--brand); color: #fff; }
.mcal-pills { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mcal-pill { padding: 1px 5px; border-radius: 5px; border-left: 3px solid var(--ink); background: var(--surface-2); font-size: 0.72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mcal-pill.test_drive, .dot.test_drive { border-color: var(--brand); }
.mcal-pill.trade_appraisal { border-color: var(--warn); }
.mcal-pill.delivery { border-color: var(--ok); }
.mcal-pill.callback { border-color: var(--violet); }
.mcal-pill.busy { border-color: var(--ink-3); color: var(--ink-3); }
.mcal-more { font-size: 0.7rem; color: var(--ink-3); }
.mcal-dots { display: none; align-items: center; justify-content: center; gap: 3px; font-size: 0.65rem; color: var(--ink-3); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }
.dot.test_drive { background: var(--brand); }
.dot.trade_appraisal { background: var(--warn); }
.dot.delivery { background: var(--ok); }
.dot.callback { background: var(--violet); }
.dot.busy { background: var(--ink-3); }
@media (max-width: 700px) {
  .mcal-day { min-height: 56px; align-items: center; padding: 0.3rem 0; }
  .mcal-num { align-self: center; }
  .mcal-pills { display: none; }
  .mcal-dots { display: flex; }
}
.gallery-main img.broken { visibility: hidden; }

/* ---------- Deals / bill of sale (v1.4) ---------- */
.deal-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 1000px) { .deal-layout { grid-template-columns: minmax(0, 1fr) 320px; } .deal-side { position: sticky; top: 1rem; } }
.deal-card h2 { margin-top: 0; }
.dgrid { display: grid; gap: 0.6rem 0.75rem; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 0.6rem; }
.dgrid[hidden] { display: none; }
.dfield { grid-column: span 2; display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.dfield.narrow { grid-column: span 1; }
.dfield.wide, .dgrid > .wide { grid-column: 1 / -1; }
.dfield > span, .dfield > label > span { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); }
.dfield > label { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }
.dfield > span.char-count { font-weight: 400; align-self: flex-end; font-variant-numeric: tabular-nums; }
.dfield > span.char-count.err { color: var(--danger, #b42318); font-weight: 600; }
.dfield input, .dfield select, .dfield textarea { width: 100%; min-height: var(--tap); }
@media (max-width: 700px) { .dgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dfield { grid-column: 1 / -1; } .dfield.narrow { grid-column: span 1; } }
.dcheck { display: flex; align-items: center; gap: 0.5rem; min-height: var(--tap); font-weight: 600; }
.dcheck input { width: 20px; height: 20px; flex: none; }
.deal-extra { display: grid; grid-template-columns: minmax(0, 1fr) 110px auto; gap: 0.5rem; margin-bottom: 0.5rem; }
.deal-extra input { min-height: var(--tap); }
.deal-line { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-bottom: 1px solid var(--line); font-size: 0.92rem; font-variant-numeric: tabular-nums; }
.deal-line.total { font-weight: 800; }
.deal-line.deduct { color: var(--ink-2); }
.deal-line.grand { font-size: 1.15rem; border-bottom: 0; border-top: 2px solid var(--ink); margin-top: 0.25rem; padding-top: 0.6rem; }
.deal-label { font-size: 0.78rem; letter-spacing: 0.02em; }
.deal-line.grand .deal-label { font-size: 0.95rem; }

/* DMS package 1 (v1.5): add-vehicle form, disclosures, documents, deal archive and closing */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 0.75rem; }
.disc-editor { display: grid; gap: 0.5rem; }
.disc-group { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0.4rem 0.75rem 0.6rem; margin: 0; min-width: 0; }
.disc-group > legend { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-3); padding: 0 0.35rem; }
.disc-flags { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 1rem; }
.disc-list { margin: 0 0 0.5rem; padding-left: 1.2rem; }
.disc-list li { margin: 0.15rem 0; }
.doc-upload { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-top: 0.75rem; }
.doc-upload select, .doc-upload input[type='file'] { min-height: var(--tap); max-width: 100%; }
.deal-filters { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; }
.deal-filters input[type='search'] { flex: 1 1 220px; min-height: var(--tap); }
.deal-filters select { min-height: var(--tap); }
.deal-filters .seg { flex-wrap: wrap; }
.chip.draft { background: var(--accent-soft); color: var(--accent); }
.chip.final { background: var(--ok-soft); color: var(--ok); }
.chip.void { background: var(--surface-2); color: var(--ink-3); text-decoration: line-through; }
.deal-link { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.75rem; padding: 0.6rem 0.75rem; border: 1px dashed var(--line); border-radius: var(--radius-s); }
.deal-link .grow { min-width: 0; flex: 1 1 200px; }
.deal-choice { display: grid; gap: 0.6rem; }
.deal-choice .btn { height: auto; min-height: 64px; padding: 0.6rem 0.9rem; flex-direction: column; align-items: flex-start; text-align: left; white-space: normal; }
.deal-choice .btn span { font-weight: 400; font-size: 0.85rem; color: var(--ink-3); }
.pick-list { display: grid; gap: 0.25rem; max-height: 50vh; overflow-y: auto; margin-top: 0.5rem; }
.pick-list .btn { height: auto; min-height: var(--tap); padding: 0.45rem 0.7rem; flex-direction: column; align-items: flex-start; text-align: left; white-space: normal; }
.deal-readonly input:disabled, .deal-readonly select:disabled, .deal-readonly textarea:disabled { color: var(--ink); -webkit-text-fill-color: var(--ink); opacity: 0.85; background: var(--surface-2); }

/* DMS package 2 (v1.5): reviews, purchases, DMS reports */
.review-form { display: grid; gap: 0 0.75rem; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; }
.review-form .err { grid-column: 1 / -1; }
.review-form .btn { justify-self: start; margin-bottom: 0.75rem; }
@media (max-width: 700px) { .review-form { grid-template-columns: minmax(0, 1fr); } }
.review-row .title, .review-row .meta { white-space: normal; overflow-wrap: anywhere; }
.review-feedback { margin: 0.35rem 0 0; padding: 0.5rem 0.6rem; background: var(--warn-soft); border-radius: var(--radius-s); white-space: pre-line; overflow-wrap: anywhere; font-size: 0.92rem; }
.lien-row { padding: 0.5rem 0 0; border-top: 1px solid var(--line); }
table.report { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 0.92rem; }
table.report th, table.report td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
table.report th.num, table.report td.num { text-align: right; white-space: nowrap; }
table.report thead th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--ink-3); }

/* v1.6 item 7: "Add vehicle from documents" — the review table (field · value · where it comes from). */
.intake-form { display: grid; gap: 0.6rem; max-width: 34rem; }
.intake-stock { max-width: 16rem; }
.intake-head, .intake-row { display: grid; grid-template-columns: minmax(9rem, 1fr) minmax(0, 1.4fr) minmax(0, 1.4fr); gap: 0.4rem 0.75rem; align-items: center; }
.intake-head { padding-bottom: 0.3rem; border-bottom: 1px solid var(--line); }
.intake-row { padding: 0.4rem 0; border-bottom: 1px solid var(--line); }
.intake-row:last-child { border-bottom: 0; }
.intake-label { font-weight: 600; }
.intake-value input:not([type='checkbox']), .intake-value select, .intake-value textarea { width: 100%; }
.intake-value input[type='checkbox'] { width: 1.3rem; height: 1.3rem; }
.intake-source { color: var(--ink-2); overflow-wrap: anywhere; }
.intake-origin.typed { font-weight: 600; }
.intake-origin.empty { color: var(--ink-3); }
.vin-check { display: grid; gap: 0.4rem; margin: 0.4rem 0; }
.vin-check .banner, .stock-unit-banner { justify-content: flex-start; text-align: left; border-radius: 8px; }
.review-flag { justify-content: flex-start; flex-wrap: wrap; text-align: left; border-radius: 8px; margin-top: 0.4rem; }
@media (max-width: 700px) {
  .intake-head { display: none; }
  .intake-row { grid-template-columns: 1fr; gap: 0.2rem; }
  .intake-row.check { grid-template-columns: 1fr auto; }
  .intake-row.check .intake-source { grid-column: 1 / -1; }
}

.intake-conf.high { color: var(--ok); }
.intake-conf.low { color: var(--warn); }
.intake-mismatch, .intake-checks li { color: var(--danger); font-weight: 600; }
.intake-checks { border: 2px solid var(--danger); }
.intake-checks ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.intake-value .mismatch { border-color: var(--danger); outline: 1px solid var(--danger); }
