/* Dealer app theme and layout. Shared brand tokens are in branding.css. */

:root {
  --font: var(--px-font);
  --font-mono: var(--px-figures);
  --t-label: .75rem;
  --t-xs: .8125rem;
  --t-sm: .9375rem;
  --t-md: 1rem;
  --t-lg: 1.1875rem;
  --t-xl: 1.4375rem;
  --t-2xl: 1.75rem;
  --t-3xl: 2.125rem;
  --t-hero: 2.5rem;
  --t-money-sm: 1.25rem;
  --t-money: 1.625rem;
  --t-money-hero: 3.25rem;
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;
  --r-pill: 999px;
  --touch: 48px;
  --touch-min: 40px;
  --topbar-h: 56px;
  --tabbar-h: 68px;
  --bg: var(--px-paper);
  --surface: #ffffff;
  --surface-2: var(--px-panel);
  --sunken: var(--px-sunken);
  --ink: var(--px-charcoal);
  --ink-2: #2b332e;
  --ink-3: var(--px-quiet);
  --line: var(--px-line);
  --line-strong: var(--px-line-strong);
  --brand: var(--px-action);
  --brand-hover: var(--px-action-hover);
  --brand-ink: #ffffff;
  --brand-soft: var(--px-tint);
  --brand-soft-ink: var(--px-on-tint);
  --link: var(--px-action);
  --hero-bg: var(--px-charcoal);
  --hero-ink: #ffffff;
  --hero-sub: var(--px-on-charcoal);
  --stretch: #b86e00;
  --stretch-ink: #6b3f00;
  --walk: #c62a20;
  --walk-ink: #8f1d16;
  --amber-soft: #fff3df;
  --amber-line: #e5b866;
  --amber-ink: #6b3f00;
  --red-soft: #fdeceb;
  --red-line: #eba49e;
  --red-ink: #8f1d16;
  --ai-soft: #eeecfd;
  --ai-line: #c3bdf5;
  --ai-ink: #3a2fa8;
  --info-soft: #e5effb;
  --info-ink: #17467f;
  --focus: var(--px-focus);
  --shadow-sm: 0 1px 0 #0a0f0c0f;
  --shadow: 0 1px 0 #0a0f0c12, 0 4px 14px #0a0f0c0f;
  --shadow-lg: 0 12px 32px #0a0f0c29;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur-fast: .12s;
  --dur: .22s;
  color-scheme: light;
  --sidebar-w: 248px;
}
/* System preference remains available without JavaScript. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"]):not([data-theme="dark"])) {
    --bg: var(--px-dark-paper);
    --surface: var(--px-dark-surface);
    --surface-2: var(--px-dark-panel);
    --sunken: var(--px-deep);
    --ink: var(--px-dark-ink);
    --ink-2: var(--px-dark-muted);
    --ink-3: var(--px-dark-quiet);
    --line: var(--px-dark-line);
    --line-strong: var(--px-dark-line-strong);
    --brand: var(--px-dark-action);
    --brand-hover: var(--px-dark-hover);
    --brand-ink: var(--px-deep);
    --brand-soft: var(--px-dark-tint);
    --brand-soft-ink: var(--px-dark-on-tint);
    --link: var(--px-dark-on-tint);
    --hero-bg: var(--px-charcoal);
    --hero-ink: #ffffff;
    --hero-sub: var(--px-on-charcoal);
    --stretch: #f2b155;
    --stretch-ink: #f6cf86;
    --walk: #ff8a80;
    --walk-ink: #ffb1a9;
    --amber-soft: #2d2211;
    --amber-line: #6a4f1f;
    --amber-ink: #f6cf86;
    --red-soft: #331816;
    --red-line: #73302a;
    --red-ink: #ffb1a9;
    --ai-soft: #1e1b3d;
    --ai-line: #4a4390;
    --ai-ink: #cac4ff;
    --info-soft: #12243a;
    --info-ink: #a9cdf7;
    --focus: var(--px-dark-focus);
    --shadow-sm: 0 1px 0 #00000059;
    --shadow: 0 1px 0 #00000059, 0 6px 18px #00000047;
    --shadow-lg: 0 12px 36px #0000008c;
    color-scheme: dark;
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
    --bg: var(--px-dark-paper);
    --surface: var(--px-dark-surface);
    --surface-2: var(--px-dark-panel);
    --sunken: var(--px-deep);
    --ink: var(--px-dark-ink);
    --ink-2: var(--px-dark-muted);
    --ink-3: var(--px-dark-quiet);
    --line: var(--px-dark-line);
    --line-strong: var(--px-dark-line-strong);
    --brand: var(--px-dark-action);
    --brand-hover: var(--px-dark-hover);
    --brand-ink: var(--px-deep);
    --brand-soft: var(--px-dark-tint);
    --brand-soft-ink: var(--px-dark-on-tint);
    --link: var(--px-dark-on-tint);
    --hero-bg: var(--px-charcoal);
    --hero-ink: #ffffff;
    --hero-sub: var(--px-on-charcoal);
    --stretch: #f2b155;
    --stretch-ink: #f6cf86;
    --walk: #ff8a80;
    --walk-ink: #ffb1a9;
    --amber-soft: #2d2211;
    --amber-line: #6a4f1f;
    --amber-ink: #f6cf86;
    --red-soft: #331816;
    --red-line: #73302a;
    --red-ink: #ffb1a9;
    --ai-soft: #1e1b3d;
    --ai-line: #4a4390;
    --ai-ink: #cac4ff;
    --info-soft: #12243a;
    --info-ink: #a9cdf7;
    --focus: var(--px-dark-focus);
    --shadow-sm: 0 1px 0 #00000059;
    --shadow: 0 1px 0 #00000059, 0 6px 18px #00000047;
    --shadow-lg: 0 12px 36px #0000008c;
  color-scheme: dark;
}
/* Sunlight always uses the complete light palette, including semantic colours. */
:root[data-contrast="more"] {  --bg: var(--px-paper);
  --surface: #ffffff;
  --surface-2: var(--px-panel);
  --sunken: var(--px-sunken);
  --ink: var(--px-charcoal);
  --ink-2: #2b332e;
  --ink-3: var(--px-quiet);
  --line: var(--px-line);
  --line-strong: var(--px-line-strong);
  --brand: var(--px-action);
  --brand-hover: var(--px-action-hover);
  --brand-ink: #ffffff;
  --brand-soft: var(--px-tint);
  --brand-soft-ink: var(--px-on-tint);
  --link: var(--px-action);
  --hero-bg: var(--px-charcoal);
  --hero-ink: #ffffff;
  --hero-sub: var(--px-on-charcoal);
  --stretch: #b86e00;
  --stretch-ink: #6b3f00;
  --walk: #c62a20;
  --walk-ink: #8f1d16;
  --amber-soft: #fff3df;
  --amber-line: #e5b866;
  --amber-ink: #6b3f00;
  --red-soft: #fdeceb;
  --red-line: #eba49e;
  --red-ink: #8f1d16;
  --ai-soft: #eeecfd;
  --ai-line: #c3bdf5;
  --ai-ink: #3a2fa8;
  --info-soft: #e5effb;
  --info-ink: #17467f;
  --focus: var(--px-focus);
  --shadow-sm: 0 1px 0 #0a0f0c0f;
  --shadow: 0 1px 0 #0a0f0c12, 0 4px 14px #0a0f0c0f;
  --shadow-lg: 0 12px 32px #0a0f0c29;
  --bg: #ffffff;
  --surface-2: #ffffff;
  --sunken: #ffffff;
  --ink: #000000;
  --ink-2: #2b332e;
  --ink-3: #2b332e;
  --line: #6b746f;
  --line-strong: #4a524d;
  color-scheme: light;
}
:root[data-contrast="more"] :is(.card, .stat, input, select, textarea, .secondary, .value-tiles, .value-tiles > div) { border-width: 2px; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--t-md);
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0 0 var(--s3); }
h1 { font-size: var(--t-2xl); line-height: 1.15; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: var(--t-lg); line-height: 1.3; font-weight: 750; letter-spacing: -.005em; }
h3 { font-size: var(--t-md); line-height: 1.35; font-weight: 700; }
a { color: var(--link); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
small { display: block; color: var(--ink-3); font-size: var(--t-xs); font-weight: 500; }
b, strong { font-weight: 700; }
img { max-width: 100%; height: auto; }
blockquote {
  margin: 0 0 var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  border-left: 3px solid var(--line-strong);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  font-size: var(--t-sm);
}
blockquote small { margin-top: var(--s1); text-transform: uppercase; letter-spacing: .05em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; outline-width: 3px; }
::selection { background: var(--brand-soft); }
.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: middle;
}
.icon.lg { width: 24px; height: 24px; }
.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: var(--s3);
  top: 0;
  transform: translateY(calc(-100% - 2rem));
  z-index: 100;
  padding: var(--s2) var(--s4);
  background: var(--surface);
  border-radius: var(--r-sm);
}
.skip-link:focus { top: var(--s3); transform: none; box-shadow: var(--shadow-lg); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); font-size: var(--t-sm); }
.eyebrow {
  margin: 0 0 var(--s2);
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.page-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s5);
}
.page-heading > div:first-child { min-width: 0; }
.page-heading h1 { margin: 0; }
.page-heading p { margin: var(--s2) 0 0; color: var(--ink-2); }
.page-heading .eyebrow { margin: 0 0 var(--s2); }
.lede { color: var(--ink-2); font-size: var(--t-md); max-width: 62ch; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--s1);
  min-height: var(--touch);
  margin-bottom: var(--s2);
  color: var(--ink-2);
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.actions form { margin: 0; }
.r { text-align: right; }
.mono { font-family: var(--font-mono); font-size: .92em; letter-spacing: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-bottom: var(--s4); }
.search { display: flex; flex: 1 1 320px; gap: var(--s2); max-width: 640px; margin: 0; }
.search input { flex: 1; }
.search-field { position: relative; flex: 1; display: flex; }
.search-field .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}
.search-field input { padding-left: 40px; }
.summary-add { color: var(--link); }
.decision { display: inline-flex; align-items: center; gap: var(--s2); }

/* ---------- App shell ---------- */
.sidebar { display: none; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) var(--s4) 0;
  background: var(--surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 850;
  letter-spacing: -.04em;
}
.brand:hover { text-decoration: none; }
.topbar .brand { --wordmark-width: 7rem; flex: 0 1 auto; min-width: 0; }
.topbar .product-art--mark { display: none; }
.topbar .product-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .button { min-height: var(--touch-min); padding: 0 var(--s3); }
.main {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--s4) var(--s4) calc(var(--tabbar-h) + var(--s6) + env(safe-area-inset-bottom));
}
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding: 0 var(--s2) env(safe-area-inset-bottom);
  background: var(--surface);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: var(--tabbar-h);
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 700;
  letter-spacing: .01em;
  position: relative;
}
.tabbar a:hover { text-decoration: none; color: var(--ink); }
.tabbar a[aria-current="page"] .icon { stroke-width: 2.4; }
.tabbar .tab-new span:first-child {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-top: -20px;
  border-radius: 16px;
  background: var(--brand);
  color: var(--brand-ink);
  box-shadow: 0 0 0 4px var(--surface), 0 6px 16px color-mix(in srgb, var(--brand) 40%, transparent);
}
.tabbar .tab-new .icon { width: 26px; height: 26px; stroke-width: 2.4; }
.tabbar a[aria-current="page"] { color: var(--ink); }
.tabbar a[aria-current="page"]:not(.tab-new)::before {
  content: "";
  position: absolute;
  top: 0;
  width: 28px;
  height: 3px;
  border-radius: 0 0 3px 3px;
  background: var(--brand);
}

/* ---------- Cards ---------- */
.section-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2) var(--s3);
  margin-bottom: var(--s4);
}
.section-heading h2 { margin: 0; font-size: var(--t-lg); }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4);
  margin: 0 0 var(--s4);
  box-shadow: var(--shadow-sm);
}
.card > :last-child { margin-bottom: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-title { display: flex; align-items: center; gap: var(--s2); }
.card-title .icon { color: var(--ink-3); }

/* ---------- Chips and badges ---------- */
.section-heading > span:not(.badge) { color: var(--ink-3); font-size: var(--t-sm); }
.badge, .chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--t-xs);
  font-weight: 750;
  letter-spacing: .03em;
  line-height: 1.2;
  white-space: nowrap;
  text-transform: none;
}
.chip .icon, .badge .icon { width: 14px; height: 14px; stroke-width: 2.4; }
.chip.lg { min-height: 30px; padding: 4px 12px; font-size: var(--t-sm); }
.badge { text-transform: uppercase; letter-spacing: .06em; font-size: var(--t-label); }
.derived, .chip-ok { color: var(--brand-soft-ink); background: var(--brand-soft); border-color: transparent; }
.chip-stale, .chip-danger { color: var(--red-ink); background: var(--red-soft); border-color: var(--red-line); }
.chip-ai { color: var(--ai-ink); background: var(--ai-soft); border-color: var(--ai-line); }
.chip-info { color: var(--info-ink); background: var(--info-soft); border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }

.topbar-actions { display: flex; align-items: center; gap: var(--s2); }
.sunlight-toggle[hidden] { display: none; }
.sunlight-toggle[aria-pressed="true"] {
  background: var(--brand-soft); color: var(--brand-soft-ink); border-color: var(--brand);
}


/* ---------- Buttons ---------- */
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--touch);
  padding: 0 var(--s4);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  color: var(--brand-ink);
  background: var(--brand);
  border: 1px solid var(--brand);
  border-radius: var(--r);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color var(--dur-fast), border-color var(--dur-fast),
    transform var(--dur-fast) var(--ease);
}
button:hover, .button:hover { background: var(--brand-hover); border-color: var(--brand-hover); text-decoration: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
.button.lg, button.lg { min-height: 52px; padding: 0 var(--s5); font-size: var(--t-md); }
.button.block, button.block { width: 100%; }
.secondary { color: var(--ink); background: var(--surface); border-color: var(--line-strong); border-width: 1.5px; }
.secondary:hover { background: var(--surface-2); border-color: var(--ink-3); color: var(--ink); }
.ghost { color: var(--ink-2); background: transparent; border-color: transparent; }
.ghost:hover { background: var(--surface-2); border-color: transparent; color: var(--ink); }
.danger { color: var(--red-ink); background: var(--red-soft); border-color: var(--red-line); }
.danger:hover { color: var(--red-ink); background: var(--red-soft); border-color: var(--red-ink); }
.small { min-height: var(--touch-min); padding: 0 var(--s3); font-size: var(--t-xs); }
.htmx-request { opacity: .6; transition: opacity .2s; }
.htmx-request button { cursor: progress; }
button:active, .button:active { transform: translateY(1px); }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: var(--t-sm); font-weight: 700; color: var(--ink); }
input, select, textarea {
  width: 100%;
  min-width: 0;
  min-height: var(--touch);
  padding: 10px 12px;
  font: inherit;
  font-size: var(--t-md);
  font-weight: 450;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s;
  border-width: 1.5px;
  border-color: var(--line-strong);
}
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: .85; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 28%, transparent);
}
input[readonly] { background: var(--surface-2); }
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.45; }
input[type="checkbox"], input[type="radio"] {
  width: 22px;
  height: 22px;
  min-height: 0;
  padding: 0;
  accent-color: var(--brand);
  flex: none;
}
input[type="file"] { padding: 9px; font-size: var(--t-sm); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: var(--s4); }
.form-grid.compact { gap: var(--s3); margin: var(--s3) 0 0; }
.full { grid-column: 1 / -1; }
.check {
  flex-direction: row;
  align-items: center;
  gap: var(--s3);
  min-height: var(--touch);
  padding: var(--s2) var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  border-width: 1.5px;
}
.check input { width: 22px; }
.override-field { border-color: var(--amber-line); background: var(--amber-soft); border-left: 4px solid var(--stretch); }
.field-hint { color: var(--ink-3); font-size: var(--t-xs); font-weight: 500; }
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

/* ---------- Dashboard and lists ---------- */
.override, .chip-warn, .status-draft { color: var(--amber-ink); background: var(--amber-soft); border-color: var(--amber-line); }
.dash-hero {
  display: grid;
  gap: var(--s4);
  align-items: center;
  margin-bottom: var(--s3);
  padding: var(--s2) 0 var(--s4);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  background-image: none;
}
.dash-hero h1 { margin: 0 0 var(--s2); font-size: var(--t-2xl); color: var(--ink); margin-bottom: var(--s1); }
.dash-hero p { margin: 0; color: var(--ink-2); max-width: 58ch; }
.dash-hero .actions { gap: var(--s3); }
.quick-search { display: flex; gap: var(--s2); margin: 0; }
.quick-search input { flex: 1; }
.dash-hero .quick-search input { background: #ffffff; color: #141a17; border-color: transparent; }
.stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin-bottom: var(--s5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.dash-hero .eyebrow { color: var(--ink-3); }
.dash-hero .button { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.stat {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  padding: var(--s3) var(--s4);
  border-radius: 0;
  background: transparent;
  border: 0;
  color: var(--ink);
  box-shadow: none;
}
.dash-hero .button:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
a.stat:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--shadow); background: var(--surface-2); }
.dash-hero .button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.stat-label {
  display: flex;
  align-items: center;
  gap: var(--s2);
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.dash-hero .button.secondary:hover { background: var(--surface-2); }
.stat-value {
  font-size: var(--t-3xl);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.stat-note { color: var(--ink-3); font-size: var(--t-xs); font-weight: 500; }
.stat.attention .stat-label, .stat.attention .stat-note { color: var(--amber-ink); }
.stat.alarm .stat-label, .stat.alarm .stat-note { color: var(--red-ink); }
.stat:first-child { grid-column: 1 / -1; }
.dash-grid { display: grid; gap: var(--s4); align-items: start; }
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) 0;
  border-bottom: 1px solid var(--line);
}
.list li:last-child .list-row, .list > .list-row:last-child { border-bottom: 0; }
a.list-row { color: var(--ink); font-weight: inherit; }
a.list-row:hover { text-decoration: none; }
a.list-row:hover .list-title { color: var(--link); }
.list-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
}
.list-title { display: block; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px var(--s2);
  margin-top: 3px;
  color: var(--ink-3);
  font-size: var(--t-xs);
  align-items: center;
}
.list-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; text-align: right; }
.list-amount { font-size: var(--t-money-sm); font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.list-amount.pending { font-size: var(--t-sm); font-weight: 650; color: var(--ink-3); }
.list-end small { font-size: var(--t-label); text-transform: uppercase; letter-spacing: .06em; font-weight: 750; color: var(--ink-3); }
small, .muted, .field-hint, .stat-note, .list-meta { color: var(--ink-3); }
small, .field-hint, .stat-note, .list-meta { font-size: var(--t-xs); }
.status-final { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.stat.attention, .stat.alarm { background: transparent; border: 0; }
.stat.alarm .stat-label, .stat.alarm .stat-value { color: var(--red-ink); }
.stat.attention::after, .stat.alarm::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--stretch);
}
.stat.alarm::after { background: var(--walk); }
.stat.attention .stat-label, .stat.attention .stat-value { color: var(--amber-ink); }
.stat + .stat { box-shadow: inset 1px 0 0 var(--line); }

/* ---------- Feedback ---------- */
.alert, .warnings, .notice {
  display: block;
  margin: var(--s4) 0;
  padding: var(--s3) var(--s4);
  border: 1px solid var(--amber-line);
  border-radius: var(--r);
  background: var(--amber-soft);
  color: var(--ink);
}
.alert > :last-child, .warnings > :last-child, .notice > :last-child { margin-bottom: 0; }
.alert h1 { font-size: var(--t-xl); }
.alert[role="alert"] {
  border-color: var(--red-line);
  background: var(--red-soft);
  border-width: 1.5px;
  border-left: 6px solid var(--walk);
}
.alert[role="alert"] p { color: var(--ink); }
.warnings p { display: flex; gap: var(--s2); margin-bottom: var(--s2); font-size: var(--t-sm); }
.warnings p::before {
  content: "!";
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--amber-ink);
  color: var(--amber-soft);
  font-size: 12px;
  font-weight: 900;
}
.warnings { border-left: 6px solid var(--stretch); }
.notice.info { border-color: transparent; background: var(--info-soft); }
.notice.ai { border-color: var(--ai-line); background: var(--ai-soft); }
.warning-text { color: var(--amber-ink); font-weight: 600; }
#form-errors:empty { display: none; }
#form-errors { position: sticky; top: calc(var(--topbar-h) + var(--s2)); z-index: 20; }
#form-errors > * { box-shadow: var(--shadow-lg); }
.empty {
  padding: var(--s5);
  text-align: center;
  color: var(--ink-2);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--r);
  background: var(--surface-2);
}
.empty .actions { justify-content: center; }

.error-summary { scroll-margin-top: calc(var(--topbar-h) + var(--s3)); }
.error-summary h2 { margin-bottom: var(--s2); }
.error-summary ul { margin: 0; padding-left: var(--s5); }
.error-summary li + li { margin-top: var(--s2); }
.error-summary a { color: var(--red-ink); text-decoration: underline; }
[aria-invalid="true"] { border-color: var(--walk); }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); text-align: left; }
th {
  padding: 10px 12px;
  color: var(--ink-3);
  background: var(--surface-2);
  font-size: var(--t-label);
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
td:not(:first-child) { font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: 0; }
tr.excluded td {
  color: var(--ink-3);
  background: repeating-linear-gradient(-45deg, transparent 0 8px,
    color-mix(in srgb, var(--line) 45%, transparent) 8px 9px);
}
.rtable-wrap { container-type: inline-size; }

/* ---------- Workspace ---------- */
tr.excluded td:first-child .comp-name { text-decoration: line-through; }
.ws-head { display: grid; gap: var(--s3); margin-bottom: var(--s4); }
.ws-head h1 { margin: 0; overflow-wrap: anywhere; font-size: var(--t-2xl); }
.ws-meta { display: flex; flex-wrap: wrap; gap: 4px var(--s3); color: var(--ink-2); font-size: var(--t-sm); }
.ws-meta span { display: inline-flex; align-items: center; gap: 6px; }
.ws-meta .icon { width: 16px; height: 16px; color: var(--ink-3); }
.ws-meta .mono { font-size: .95em; font-weight: 600; letter-spacing: .04em; }
.ws-actions { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.ws-actions::-webkit-scrollbar { display: none; }
.ws-actions form { margin: 0; flex: none; }
.ws-actions .button, .ws-actions button { flex: none; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); align-items: start; }
.workspace-inputs, .workspace-grid aside { min-width: 0; }
.workspace-grid aside { order: -1; }
.result-panel { padding: var(--s4); border-color: var(--line-strong); }
.acv-hero {
  margin: 0 0 var(--s3);
  padding: var(--s4) var(--s5);
  text-align: left;
  border-radius: var(--r) var(--r) 0 0;
  background: var(--hero-bg);
  color: var(--hero-ink);
  background-image: none;
  margin-bottom: 0;
  position: relative;
}
.acv-hero span {
  display: block;
  color: var(--hero-sub);
  font-size: var(--t-label);
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.acv-hero strong {
  display: block;
  margin: var(--s1) 0;
  font-size: var(--t-money-hero);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  animation: tt-settle var(--dur) var(--ease);
}
.acv-hero small { color: var(--hero-sub); font-size: var(--t-xs); font-weight: 600; }
.value-tiles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 var(--s4);
  margin-bottom: var(--s4);
  border: 1px solid var(--line-strong);
  border-top: 0;
  border-radius: 0 0 var(--r) var(--r);
  overflow: hidden;
}
.value-tiles > div {
  padding: var(--s3) var(--s4);
  border-radius: 0;
  background: var(--surface);
  border: 0;
  text-align: left;
  min-width: 0;
}
.value-tiles > div > span {
  display: block;
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.value-tiles strong {
  display: block;
  font-size: var(--t-xl);
  font-weight: 800;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.value-tiles small { margin-top: 2px; display: block; }
.facts { display: grid; gap: 0; margin: 0 0 var(--s4); }
.facts > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--t-sm);
}
.facts > div:last-child { border-bottom: 0; }
.facts dt, .facts .k { color: var(--ink-2); }
.facts dd, .facts .v { margin: 0; text-align: right; font-weight: 750; font-variant-numeric: tabular-nums; }
.buybox-wrap {
  margin: 0 0 var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  container-type: inline-size;
}
.buybox { font-size: var(--t-sm); }
.buybox td { padding: 9px 12px; }
.buybox td:nth-child(2) { text-align: right; font-weight: 700; white-space: nowrap; }
.buybox td:nth-child(3) { color: var(--ink-3); font-size: var(--t-xs); }
.buybox tr:nth-last-child(3) td { background: var(--brand-soft); color: var(--brand-soft-ink); font-weight: 800; }
.buybox tr:nth-last-child(3) td:nth-child(3) { color: var(--brand-soft-ink); }
.validity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s2);
  margin: 0;
  color: var(--ink-3);
  font-size: var(--t-sm);
}
.ws-section { scroll-margin-top: calc(var(--topbar-h) + 80px); container-type: inline-size; }
.ws-section > .section-heading .icon { color: var(--ink-3); }
.median-strip { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); margin: var(--s4) 0 var(--s2); }
.median-strip > div {
  padding: var(--s3);
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line);
  min-width: 0;
}
.median-strip span {
  display: block;
  color: var(--ink-3);
  font-size: var(--t-label);
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.median-strip strong { font-size: var(--t-lg); font-weight: 800; font-variant-numeric: tabular-nums; }
.comp-name { font-weight: 700; }
.comp-sub { display: flex; flex-wrap: wrap; gap: 4px var(--s2); margin-top: 4px; align-items: center; }
.comp-sub a { font-size: var(--t-xs); }
.cell-adjusted { font-weight: 800; color: var(--ink); font-size: var(--t-md); }
details { border-top: 1px solid var(--line); padding: 0; }
details > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  min-height: 52px;
  padding: var(--s2) 0;
  list-style: none;
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}
details > summary::-webkit-details-marker { display: none; }
details > summary::after {
  content: "";
  flex: none;
  width: 9px;
  height: 9px;
  margin-right: 6px;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg) translateY(-2px);
  transition: transform .15s;
}
details[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
details > summary:hover { color: var(--link); }
details[open] { padding-bottom: var(--s4); }
details[open] > summary { margin-bottom: var(--s2); }
.manage-list { margin-top: var(--s4); }
.manage-list details > summary { font-weight: 600; font-size: var(--t-sm); }
.manage-list .danger { margin-top: var(--s3); }
.group-title {
  margin: var(--s4) 0 var(--s2);
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.recon-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  margin-bottom: var(--s4);
  border-radius: var(--r);
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.recon-total strong { font-size: var(--t-xl); font-weight: 800; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: flex-start; justify-content: flex-end; }
.row-actions form { margin: 0; }
.row-actions details { border: 0; width: 100%; }
.row-actions details > summary { min-height: var(--touch-min); justify-content: flex-end; font-size: var(--t-xs); color: var(--link); }
.row-actions details form { display: grid; gap: var(--s2); text-align: left; padding-top: var(--s2); }
.save-bar {
  position: sticky;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s2));
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  padding-top: var(--s2);
}
.save-bar button { box-shadow: var(--shadow-lg); }
.context-list p { padding: var(--s2) 0; border-bottom: 1px solid var(--line); margin: 0; font-size: var(--t-sm); }
.context-list p:empty { display: none; }
.ws-chips { margin-top: 10px; }
.value-tiles small, .value-tiles small span {
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  display: inline;
}
.value-tiles small .warning-text { color: var(--amber-ink); }
.ws-section .form-grid { grid-template-columns: minmax(0, 1fr); }
details > summary.summary-add { justify-content: flex-start; gap: var(--s2); color: var(--link); }
details > summary.summary-add::after { margin-left: auto; }
.value-tiles .decision-label { font-size: var(--t-sm); letter-spacing: 0; text-transform: none; font-weight: 800; }
.tile-stretch .decision-label { color: var(--stretch-ink); }
.tile-walk .decision-label { color: var(--walk-ink); }
.value-tiles > .decision-tile {
  grid-column: 1 / -1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: var(--s3) var(--s5);
  border-bottom: 1px solid var(--line);
}
.value-tiles > .decision-tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; }
.value-tiles > .tile-stretch::before { background: var(--stretch); }
.value-tiles > .tile-walk::before { background: var(--walk); }
.value-tiles .decision-caption {
  display: block;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0;
  text-transform: none;
}
.value-tiles > .decision-tile strong { font-size: var(--t-money); font-weight: 800; letter-spacing: -.02em; color: var(--ink); }
.value-tiles > .context-tile { background: var(--surface-2); }
.value-tiles > .tile-days { box-shadow: inset 1px 0 0 var(--line); }
.value-tiles > .context-tile > span { font-size: var(--t-label); color: var(--ink-3); }
.median-strip > div:first-child { background: var(--brand-soft); border-color: transparent; }
.value-tiles > .context-tile strong { font-size: var(--t-lg); }
.median-strip > div:first-child span,
.median-strip > div:first-child strong { color: var(--brand-soft-ink); }
.median-strip span, .value-tiles small { font-size: var(--t-label); }

/* ---------- New appraisal ---------- */
.mono, .vin-input, .link-box input { font-family: var(--font-mono); font-feature-settings: "zero" 1; }
.new-layout { display: grid; gap: var(--s4); align-items: start; max-width: 1040px; }
.vin-block {
  padding: var(--s3);
  margin-bottom: var(--s4);
  border-radius: var(--r);
  background: var(--surface);
  border: 1.5px dashed var(--line-strong);
}
.vin-block label { font-size: var(--t-sm); }
.vin-input {
  min-height: 48px;
  font-family: var(--font-mono);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.vin-input::placeholder {
  letter-spacing: .04em;
  text-transform: none;
  font-family: var(--font);
  font-size: var(--t-md);
  font-weight: 450;
}
.divider {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin: var(--s4) 0;
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.km-input { font-size: var(--t-xl); font-weight: 700; min-height: 60px; font-variant-numeric: tabular-nums; }
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: var(--s3);
  padding: var(--s2) 0;
  color: var(--ink-2);
  font-size: var(--t-sm);
}
.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-soft-ink);
  font-weight: 800;
  font-size: var(--t-xs);
}
.steps strong { display: block; color: var(--ink); }
.submit-bar {
  position: sticky;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s2));
  z-index: 10;
  margin-top: var(--s4);
}
.submit-bar button { width: 100%; box-shadow: var(--shadow-lg); }

/* ---------- AI proposals ---------- */
.ai-card { border-color: var(--ai-line); }
.ai-card > .section-heading h2 { display: flex; align-items: center; gap: var(--s2); }
.ai-card > .section-heading .icon { color: var(--ai-ink); }
.ai-proposal {
  margin: var(--s3) 0;
  padding: var(--s4);
  border: 1px solid var(--ai-line);
  border-radius: var(--r);
  background: color-mix(in srgb, var(--ai-soft) 55%, var(--surface));
}
.ai-proposal h3 { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.ai-proposal img {
  display: block;
  width: 160px;
  max-width: 100%;
  border-radius: var(--r-sm);
  margin-bottom: var(--s3);
  border: 1px solid var(--line);
}
.ai-proposal form { display: grid; gap: var(--s3); margin-top: var(--s3); }
.ai-proposal form .form-actions { margin-top: var(--s1); }
.ai-evidence { display: grid; gap: var(--s3); }

/* ---------- Settings ---------- */
.settings-form { max-width: 980px; }
.settings-form .card h2 { margin-bottom: var(--s2); }
.settings-form .card > p { color: var(--ink-2); font-size: var(--t-sm); }
.settings-form table input, .settings-form table select { min-width: 110px; }
.settings-form table td { padding: 8px; }
.settings-save {
  position: sticky;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s2));
  z-index: 5;
  display: flex;
  justify-content: flex-end;
  margin: var(--s4) 0;
}
.settings-save button { box-shadow: var(--shadow-lg); }
.demo-reset { max-width: 980px; margin-top: var(--s6); border-color: var(--red-line); }
.settings-nav { display: flex; gap: var(--s2); overflow-x: auto; margin: 0 0 var(--s4); padding-bottom: 2px; scrollbar-width: none; }
.settings-nav a {
  flex: none;
  display: inline-flex;
  align-items: center;
  min-height: var(--touch-min);
  padding: 0 var(--s3);
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--t-sm);
}
.settings-nav a:hover { text-decoration: none; border-color: var(--line-strong); color: var(--ink); }
.settings-form section { scroll-margin-top: calc(var(--topbar-h) + var(--s4)); }

/* ---------- Dealer intake pages ---------- */
.create-intake { display: grid; gap: var(--s3); margin: 0; }
.link-box { display: flex; gap: var(--s2); }
.link-box input { flex: 1; font-family: var(--font-mono); font-size: var(--t-sm); }
.intake-photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.intake-photo-grid figure { margin: 0; min-width: 0; }
.intake-photo-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--r-sm);
  background: var(--sunken);
  border: 1px solid var(--line);
}
.intake-photo-grid figcaption { margin-top: 6px; font-size: var(--t-xs); color: var(--ink-2); text-transform: capitalize; }
.intake-photo-grid figcaption p { margin: 2px 0 0; text-transform: none; color: var(--ink-3); }
.kv { display: grid; grid-template-columns: minmax(110px, 40%) 1fr; gap: 0; margin: 0; font-size: var(--t-sm); }
.kv dt { padding: 8px 0; color: var(--ink-3); border-bottom: 1px solid var(--line); }
.kv dd { margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); font-weight: 600; overflow-wrap: anywhere; }
.qa p { margin: 0; padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--t-sm); }
.qa p strong { display: block; color: var(--ink-3); font-weight: 650; font-size: var(--t-xs); }
.split { display: grid; gap: var(--s4); align-items: start; }

/* ---------- Customer summary ---------- */
.customer-summary {
  max-width: 520px;
  margin: var(--s6) auto;
  padding: var(--s6) var(--s5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  text-align: center;
}
.customer-summary h1 { font-size: var(--t-2xl); margin-bottom: var(--s5); }
.customer-summary p {
  margin: 0;
  color: var(--ink-3);
  font-size: var(--t-xs);
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.customer-summary strong {
  display: block;
  margin: var(--s1) 0 var(--s5);
  font-size: var(--t-hero);
  font-weight: 850;
  letter-spacing: -.035em;
  font-variant-numeric: tabular-nums;
}
.customer-summary strong.summary-hero {
  margin-bottom: 0;
  padding: var(--s4);
  border-radius: var(--r);
  background: var(--hero-bg);
  color: var(--hero-ink);
}
.customer-summary .summary-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--s4);
  margin-top: var(--s5);
}
.customer-summary .summary-breakdown strong {
  margin-bottom: 0;
  font-size: var(--t-2xl);
  color: var(--brand);
  background: none;
  border: 0;
  padding: 0;
}
.customer-body { min-height: 100vh; padding: var(--s4); }

/* ---------- Workspace feedback ---------- */
body:has(#workspace .htmx-request) #result-panel {
  opacity: .5;
  transition: opacity var(--dur);
}
body:has(#workspace .htmx-request) .acv-hero::after {
  content: "Recalculating…";
  position: absolute;
  bottom: var(--s4);
  right: var(--s4);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--t-xs);
  font-weight: 750;
}

/* ---------- Responsive layouts and accessibility preferences ---------- */
@media (prefers-contrast: more) {
  :root:not([data-contrast="normal"]) {  --bg: var(--px-paper);
  --surface: #ffffff;
  --surface-2: var(--px-panel);
  --sunken: var(--px-sunken);
  --ink: var(--px-charcoal);
  --ink-2: #2b332e;
  --ink-3: var(--px-quiet);
  --line: var(--px-line);
  --line-strong: var(--px-line-strong);
  --brand: var(--px-action);
  --brand-hover: var(--px-action-hover);
  --brand-ink: #ffffff;
  --brand-soft: var(--px-tint);
  --brand-soft-ink: var(--px-on-tint);
  --link: var(--px-action);
  --hero-bg: var(--px-charcoal);
  --hero-ink: #ffffff;
  --hero-sub: var(--px-on-charcoal);
  --stretch: #b86e00;
  --stretch-ink: #6b3f00;
  --walk: #c62a20;
  --walk-ink: #8f1d16;
  --amber-soft: #fff3df;
  --amber-line: #e5b866;
  --amber-ink: #6b3f00;
  --red-soft: #fdeceb;
  --red-line: #eba49e;
  --red-ink: #8f1d16;
  --ai-soft: #eeecfd;
  --ai-line: #c3bdf5;
  --ai-ink: #3a2fa8;
  --info-soft: #e5effb;
  --info-ink: #17467f;
  --focus: var(--px-focus);
  --shadow-sm: 0 1px 0 #0a0f0c0f;
  --shadow: 0 1px 0 #0a0f0c12, 0 4px 14px #0a0f0c0f;
  --shadow-lg: 0 12px 32px #0a0f0c29;
  --bg: #ffffff;
  --surface-2: #ffffff;
  --sunken: #ffffff;
  --ink: #000000;
  --ink-2: #2b332e;
  --ink-3: #2b332e;
  --line: #6b746f;
  --line-strong: #4a524d;
  color-scheme: light;
  }
  :root:not([data-contrast="normal"]) :is(.card, .stat, input, select, textarea, .secondary, .value-tiles, .value-tiles > div) { border-width: 2px; }
}
@media (min-width: 1100px) {
  .topbar, .tabbar { display: none; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: var(--s5);
    width: var(--sidebar-w);
    padding: var(--s5) var(--s4);
    background: var(--surface);
    border-right: 1px solid var(--line);
  }
  .sidebar .brand { padding: 0 var(--s2); }
  .sidebar nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar nav a {
    display: flex;
    align-items: center;
    gap: var(--s3);
    min-height: var(--touch);
    padding: 0 var(--s3);
    border-radius: var(--r-sm);
    color: var(--ink-2);
    font-weight: 650;
  }
  .sidebar nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
  .sidebar nav a[aria-current="page"] {
    background: var(--surface-2);
    color: var(--ink);
    box-shadow: inset 3px 0 0 var(--brand);
    border-radius: 0 var(--r-sm) var(--r-sm) 0;
  }
  .sidebar .button { width: 100%; }
  .sidebar-foot {
    margin-top: auto;
    padding: var(--s3);
    border-radius: var(--r);
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: var(--t-xs);
    line-height: 1.45;
    border: 1px solid var(--line);
  }
  .sidebar-foot strong { display: block; color: var(--ink-2); font-size: var(--t-sm); margin-bottom: 2px; }
  .main { padding: var(--s6) var(--s6) var(--s7) calc(var(--sidebar-w) + var(--s6)); max-width: none; }
  .main > * { max-width: 1280px; margin-left: auto; margin-right: auto; }
  .submit-bar { position: static; }
  .submit-bar button { width: auto; box-shadow: none; }
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 400px; gap: var(--s5); }
  .save-bar { bottom: var(--s4); }
  .settings-save { bottom: var(--s4); }
  .sidebar .button.lg { border-radius: var(--r); }
}
@media (min-width: 760px) {
  h1 { font-size: var(--t-3xl); }
  .card { padding: var(--s5); }
  .dash-hero { display: flex; flex-wrap: wrap; padding: 0 0 var(--s5); }
  .dash-hero > :first-child { flex: 1 1 20rem; }
  .dash-hero h1 { font-size: var(--t-3xl); }
  .stats { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; }
  .stat:first-child { grid-column: auto; }
  .workspace-grid aside {
    order: 0;
    position: sticky;
    top: var(--s4);
    max-height: calc(100vh - var(--s4) * 2);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    border-radius: var(--r-lg);
  }
  .result-panel { padding: var(--s5); }
  .workspace-grid aside > .card:last-child { margin-bottom: 0; }
  .stat-value { font-size: var(--t-3xl); }
  .ws-head h1 { font-size: var(--t-3xl); }
}
@media (min-width: 640px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .median-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .ai-proposal form { grid-template-columns: 1fr 1fr; }
  .ai-proposal form .form-actions { grid-column: 1 / -1; }
  .create-intake { grid-template-columns: 1fr auto; align-items: end; }
  .intake-photo-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}
@container (max-width: 559px) {
  .rtable, .rtable tbody, .rtable tr, .rtable td { display: block; width: 100%; }
  .rtable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .rtable tr {
    margin: 0 0 var(--s3);
    padding: var(--s3) var(--s4);
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
  }
  .rtable tr.excluded { background: var(--surface-2); }
  .rtable tr:last-child { margin-bottom: 0; }
  .rtable td {
    display: flex;
    justify-content: flex-start;
    align-items: baseline;
    gap: var(--s3);
    padding: 6px 0;
    border: 0;
    text-align: right;
  }
  .rtable td > small { display: inline; margin-left: var(--s2); order: 1; margin: 0 0 0 var(--s2); }
  .rtable td::before {
    content: attr(data-label);
    color: var(--ink-3);
    font-size: var(--t-xs);
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    text-align: left;
    flex: none;
    margin-right: auto;
  }
  .rtable td.cell-main {
    display: block;
    padding: 0 0 var(--s2);
    margin-bottom: var(--s1);
    border-bottom: 1px solid var(--line);
    text-align: left;
    font-size: var(--t-md);
  }
  .rtable td.cell-main > small { display: block; margin: 2px 0 0; order: 0; }
  .rtable td.cell-main::before { display: none; }
  .rtable td.cell-strong { font-weight: 800; font-size: var(--t-md); }
  .rtable td:empty { display: none; }
  .rtable .row-actions { justify-content: flex-start; width: 100%; flex-wrap: wrap; }
  .rtable td[data-label="Action"]::before { display: none; }
  .rtable td[data-label="Action"] { padding-top: var(--s2); }
  .rtable .row-actions details { width: auto; }
  .rtable .row-actions details[open] { width: 100%; }
}
@container (min-width: 560px) {
  /* Match the actual comps table breakpoint; narrow card rows keep page scrolling. */
  #comps > .rtable-wrap {
    max-height: min(52vh, 520px);
    overflow: auto;
    overscroll-behavior: contain;
    border-radius: var(--r);
  }
  #comps .rtable { overflow: visible; }
  #comps .rtable th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2);
    box-shadow: 0 1px 0 var(--line);
  }

  .rtable { border: 1px solid var(--line); border-radius: var(--r); border-collapse: separate; border-spacing: 0; overflow: hidden; }
  .rtable td > small { margin-top: 2px; }
}
@media (min-width: 1000px) {
  .dash-grid { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
  .new-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (min-width: 900px) {
  .ws-head { grid-template-columns: minmax(18rem, 1fr) minmax(0, 1fr); align-items: end; }
  .ws-actions { overflow: visible; flex-wrap: wrap; justify-content: flex-end; }
  .split { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}
@media (min-width: 760px) and (max-width: 1099px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr) minmax(300px, 340px); gap: var(--s4); }
  .workspace-grid aside {
    top: calc(var(--topbar-h) + var(--s3));
    max-height: calc(100vh - var(--topbar-h) - var(--tabbar-h) - var(--s5));
  }
}
@media (max-width: 639px) {
  .save-bar button { width: 100%; }
  .settings-save button { width: 100%; }
}
@media (min-width: 560px) {
  .ai-evidence.has-photo { grid-template-columns: 160px 1fr; }
}
@media print {
  .sidebar, .topbar, .tabbar, .skip-link { display: none !important; }
  body, .customer-body { background: #fff; color: #000; }
  .main { padding: 0; }
  .customer-summary { margin: 0; padding: 1cm; box-shadow: none; border: 0; }
  .customer-summary strong.summary-hero { background: none; color: #000; border: 2px solid #000; }
  .customer-summary .summary-breakdown strong { color: #000; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .acv-hero strong { animation: none; }
  button:active, .button:active { transform: none; }
}
@container (max-width: 420px) {
  .buybox thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .buybox, .buybox tbody { display: block; }
  .buybox tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-bottom: 1px solid var(--line); }
  .buybox tbody tr:last-child { border-bottom: 0; }
  .buybox td { border: 0; }
  .buybox td:nth-child(3) { grid-column: 1 / -1; padding-top: 0; }
  .buybox td:nth-child(3):empty { display: none; }
  .buybox tr:nth-last-child(3) { background: var(--brand-soft); }
}
@media (max-width: 759px) {
  .topbar .button[href="/appraisals/new"] { display: none; }
  .ws-actions { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
  .ws-actions form { grid-column: 1 / -1; }
  .ws-actions form button { width: 100%; }
  .ws-actions .button { padding: 0 var(--s3); }
  .dash-hero { padding: 0 0 var(--s3); }
  .dash-hero .actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
  .dash-hero .actions .button { width: 100%; }
  .stats { gap: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: var(--s3); }
  .stat-value { font-size: var(--t-xl); }
  .stat:first-child {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    column-gap: var(--s4);
    align-items: center;
  }
  .stat:first-child .stat-value { grid-row: 1 / span 2; grid-column: 1; font-size: var(--t-3xl); }
  .stat:first-child .stat-label, .stat:first-child .stat-note { grid-column: 2; }
  .dash-lede { display: none; }
  .dash-hero .actions .button.lg { min-height: 52px; padding: 0 var(--s3); }
  .stat + .stat { box-shadow: none; border-top: 1px solid var(--line); }
  .stat:nth-child(3), .stat:nth-child(5) { box-shadow: inset 1px 0 0 var(--line); }
}
@container (min-width: 520px) {
  .ws-section .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@keyframes tt-settle {
  from { opacity: .35; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}
@media (max-width: 559px) {
  .list-title { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.25; }
  .list-amount.pending { font-size: var(--t-xs); max-width: 8ch; text-align: right; line-height: 1.2; }
  .list-row { grid-template-columns: 40px minmax(0, 1fr) auto; gap: var(--s3); }
  .list-icon { width: 40px; height: 40px; }
}

/* Dealer-only evidence marks. The server supplies all percentages. */
.damage-photo { min-width:0; }
.damage-surface { position:relative; width:100%; margin:0; padding:0; border:0; line-height:0; }
.damage-enlarge { display:block; padding:0; margin:0; width:100%; min-height:0; border:0; background:transparent; line-height:0; }
.damage-surface img, .intake-photo-grid .damage-surface img { display:block; width:100%; height:auto; aspect-ratio:auto; max-height:none; margin:0; padding:0; border:0; object-fit:contain; border-radius:var(--r-sm); }
.damage-box { position:absolute; min-width:0; min-height:0; margin:0; padding:0; border:3px solid var(--amber-ink); background:transparent; border-radius:3px; color:var(--ink); line-height:1.2; overflow:visible; }
.damage-box span { position:absolute; top:0; left:0; padding:2px 4px; background:var(--surface); color:var(--ink); font-size:.625rem; line-height:1.1; white-space:nowrap; border:1px solid currentColor; }
.damage-box.label-end span { left:auto; right:0; }
.damage-box.severity-minor { border-color:var(--brand); }
.damage-box.severity-severe { border-color:var(--red-ink); }
.damage-box.severity-unrated { border-style:dashed; border-color:var(--ink); }
.damage-box.is-selected { outline:4px solid var(--ink); outline-offset:3px; z-index:2; }
.damage-finding.is-selected { outline:3px solid var(--brand); outline-offset:3px; }
.damage-dialog { width:min(94vw,1100px); max-height:94vh; padding:1rem; background:var(--surface); color:var(--ink); border:1px solid var(--line); }
.damage-dialog::backdrop { background:rgb(0 0 0 / .75); }
.damage-dialog > button { margin-bottom:1rem; }
.damage-capture, .intake-photo-grid .damage-capture { display:block; width:100%; height:auto; aspect-ratio:auto; max-height:none; margin:0; object-fit:contain; touch-action:none; cursor:crosshair; border:0; padding:0; }
.missed-damage { margin-top:.75rem; }
.ai-evidence.has-photo { grid-template-columns:minmax(160px, 40%) 1fr; }
@media(max-width:600px) { .ai-evidence.has-photo { grid-template-columns:1fr; } }

/* Display controls are hidden until JavaScript attaches their behaviour. */
[data-display-controls][hidden], .appearance-menu[hidden] { display: none; }
.display-controls { display: flex; align-items: center; gap: var(--s2); }
.sidebar-foot .display-controls { margin: var(--s2) 0 var(--s3); }
.sidebar-foot .display-label { margin-right: auto; color: var(--ink-2); font-size: var(--t-xs); }
.display-controls .display-icon { width: 40px; height: 40px; min-height: 40px; padding: 0; flex: 0 0 40px; border-width: 2px; }
.sunlight-toggle[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--brand); }
.appearance-control { position: relative; }
.appearance-menu { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; min-width: 180px; padding: var(--s2); background: var(--surface); border: 2px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow-lg); }
.sidebar-foot .appearance-menu { top: auto; bottom: calc(100% + 8px); }
.appearance-menu :is([role="menuitemradio"], [role="menuitemcheckbox"]) { display: flex; justify-content: flex-start; width: 100%; min-height: 48px; padding: 0 var(--s3); color: var(--ink); background: var(--surface); border: 2px solid transparent; }
.appearance-menu [aria-checked="true"] { background: var(--brand-soft); color: var(--brand-soft-ink); border-color: var(--brand); }
.appearance-menu .choice-check { margin-left: auto; visibility: hidden; }
.appearance-menu [aria-checked="true"] .choice-check { visibility: visible; }

.dealership-switcher, .dealership-switcher[open] { position: relative; min-width: 0; border: 0; padding: 0; }
.dealership-switcher > summary { justify-content: space-between; gap: var(--s2); min-width: 0; padding-inline: var(--s3); font-size: var(--t-xs); }
.dealership-switcher[open] > summary { margin-bottom: 0; }
.dealership-switcher > summary::after { width: 7px; height: 7px; margin-right: 2px; }
.dealership-current { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; white-space: normal; line-height: 1.15; }
.dealership-options { position: absolute; z-index: 60; top: calc(100% + 8px); right: 0; width: max-content; min-width: 100%; max-width: min(260px, 62vw); max-height: 45vh; overflow: auto; padding: var(--s2); background: var(--surface); border: 2px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow-lg); }
.dealership-options button { display: flex; justify-content: space-between; gap: var(--s2); width: 100%; min-height: 44px; white-space: normal; text-align: left; overflow-wrap: anywhere; background: var(--surface); color: var(--ink); }
.dealership-options button:hover { background: var(--surface-2); }
.dealership-options [aria-current] { background: var(--brand-soft); color: var(--brand-soft-ink); }
.sidebar-foot .dealership-options { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; }
.topbar-actions { min-width: 0; }
.topbar-actions > :not(.dealership-switcher) { flex-shrink: 0; }
.staff-intake-toolbar .dealership-switcher { margin-left: auto; }
@media (max-width: 480px) {
  .topbar:has(.dealership-switcher) .display-menu-toggle { width: var(--touch-min); padding: 0; }
  .topbar:has(.dealership-switcher) .display-menu-toggle > span { display: none; }
}

/* Robust text and accessible feedback across workspace replacements. */
h1, h2, h3, .comp-name, .manage-list summary, .rtable .cell-main,
.card, .section-heading, .appraisal-row, .appraisal-title { overflow-wrap: anywhere; min-width: 0; }
.card a, .comp-sub, .ws-head > div { overflow-wrap: anywhere; min-width: 0; }
#comps .rtable { table-layout: fixed; width: 100%; }
.section-heading > a { display: inline-flex; align-items: center; min-height: 40px; }
.median-strip .chip { display: inline-flex; width: fit-content; letter-spacing: normal; }
@media (max-width: 1099px) {
  html { scroll-padding-bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); }
}
@media (max-width: 639px) {
  .dash-hero .actions { grid-template-columns: minmax(0, 1fr); }
  .dash-hero .actions .button { min-width: 0; white-space: normal; }
}
#comps .rtable .tablet-km, #comps .rtable .tablet-adjustment { display: none; }
/* Tablet comps retain three compact columns even in the narrow input pane. */
@media (min-width: 760px) and (max-width: 1099px) {
  #comps > .rtable-wrap { max-height: min(52vh, 520px); overflow: auto; overscroll-behavior: contain; }
  #comps .rtable { display: table; border-collapse: separate; border-spacing: 0; }
  #comps .rtable thead { display: table-header-group; position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  #comps .rtable tbody { display: table-row-group; }
  #comps .rtable tr { display: table-row; padding: 0; margin: 0; }
  #comps .rtable :is(td, th) { display: table-cell; width: auto; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: var(--t-xs); }
  #comps .rtable th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); }
  #comps .rtable :is(td, th):nth-child(2), #comps .rtable :is(td, th):nth-child(4) { display: none; }
  #comps .rtable :is(td, th):first-child { width: 44%; text-align: left; }
  #comps .rtable td::before { display: none; }
  #comps .rtable .comp-name { font-size: var(--t-sm); }
  #comps .rtable .comp-sub { display: flex; flex-wrap: wrap; }
  #comps .rtable .tablet-km, #comps .rtable .tablet-adjustment { display: block; margin: 4px 0 0; color: var(--ink-2); }
}

/* Staff capture shares Theme A and the compact guided-photo layout. */
.staff-intake .i-header { background: var(--hero-bg); }
.staff-intake .i-header-inner, .staff-intake-toolbar { max-width: 640px; margin: 0 auto; }
.staff-intake-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px 12px; }
.staff-intake-toolbar > a { color: var(--hero-ink); display: inline-flex; align-items: center; min-height: 44px; gap: 6px; }
.staff-intake-toolbar button { margin: 0; }
.staff-intake .appearance-menu button { width: 100%; }
.staff-intake main { max-width: 640px; margin: 0 auto; padding: 16px 16px 32px; }
.staff-intake .i-form > button, .staff-intake .next-bar > button { width: 100%; min-height: 52px; white-space: normal; }
.staff-intake .staff-segments { grid-template-columns: repeat(7, 1fr); }
.staff-step-nav { margin-bottom: 16px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--surface); }
.staff-step-nav summary { min-height: 48px; padding: 12px; cursor: pointer; font-weight: 650; }
.staff-step-nav nav { display: grid; grid-template-columns: 1fr 1fr; padding: 0 12px 12px; gap: 4px 12px; }
.staff-step-nav a { display: flex; align-items: center; min-height: 44px; padding: 4px 8px; border-radius: var(--r-sm); }
.staff-step-nav a[aria-current] { background: var(--brand-soft); color: var(--brand-soft-ink); }
.staff-intake .tile { flex-direction: column; gap: 6px; }
.staff-intake .tile-input { min-height: 0; padding: 0; }
.staff-intake fieldset { min-width: 0; }
.staff-intake legend { padding: 0 6px; font-weight: 700; }
.staff-intake .check { flex-direction: row; }
.staff-intake .check input { margin-top: 0; }
.staff-intake .next-bar { background: var(--bg); }
.staff-intake .photo-grid img, .staff-intake .tile .thumb { height: 100%; }
.intake-source { white-space: nowrap; }
@media (max-width: 599px) {
  .intake-entry-actions { flex-direction: column; align-items: stretch; }
  .intake-entry-actions .button { width: 100%; }
}

/* Cited comp proposals use generous phone targets without altering market math. */
.comp-search { margin-bottom:1.25rem }
.comp-search button,.comp-proposals button { min-height:48px }
.comp-search-progress { padding:1rem; border:1px solid var(--line); border-radius:8px }
.comp-search-stop { margin-top:1rem }
.comp-search-stop button { width:100%; max-width:24rem; white-space:normal }
.comp-search-stop p { margin:.5rem 0; overflow-wrap:anywhere }
.comp-proposal { padding:.75rem 0; border-top:1px solid var(--line); overflow-wrap:anywhere }
.comp-proposal-select { display:flex; flex-direction:row; align-items:flex-start; text-align:left; gap:.75rem; min-height:48px; cursor:pointer }
.comp-proposal-select input[type="checkbox"] { width:24px; height:24px; flex-shrink:0; margin:0 }
.comp-proposal-details { padding-left:36px }
.comp-proposal-details p { margin:.35rem 0 }
.comp-proposal-details a { display:inline-flex; align-items:center; min-height:48px }

.comp-search-title { min-height:48px; margin-bottom:.5rem }

.technical-details:not(:has([data-technical-present])) { display:none }
.technical-details > summary { font-weight:700 }
.technical-details h3 { margin-top:var(--s4) }
.comp-search-stage { border-top:1px solid var(--line); padding:.75rem 0; overflow-wrap:anywhere }
.comp-search-stage h4,.comp-search-stage p { margin:.35rem 0 }

.comp-search-progress progress { width:100%; max-width:32rem; height:1rem; accent-color:var(--brand) }
@keyframes comp-search-spin { to { transform:rotate(360deg) } }

.comp-trim-group { min-width:0; margin:1rem 0; padding:.75rem; border:1px solid var(--line); border-radius:8px }
.comp-trim-group legend { max-width:100%; padding:0 .4rem; font-weight:700; overflow-wrap:anywhere }
.comp-trim-select { max-width:100%; white-space:normal }
.comp-trim-selection-status:empty { display:none }
@media (max-width:480px) {
  .comp-trim-group { padding:.5rem }
}

/* Keep amounts intact; narrow result panels grow rows instead of splitting digits. */
.recon-total strong, .value-tiles strong, .median-strip strong,
.comp-proposal-details strong, .facts .v, #comps td.r, #recon td.r { white-space: nowrap; }
.median-strip { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); }
.value-tiles { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); }
.median-strip span, .value-tiles > div > span { overflow-wrap: normal; }
.median-strip > div > span { white-space: nowrap; }
.facts > div, .recon-total { flex-wrap: wrap; }
.comp-evidence { margin: .5rem 0; }
.comp-evidence summary { min-height: 44px; }
.comp-proposal-actions {
  position: sticky;
  bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 28px);
  z-index: 6;
  display: flex;
  justify-content: flex-end;
  padding: var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
@media (min-width: 1100px) {
  .comp-proposal-actions { bottom: var(--s4); }
}
@media (max-width: 759px) {
  #details .save-bar { position: static; padding-top: var(--s4); }
  #details .save-bar button { box-shadow: none; }
  .ws-section, #comp-search-panel { scroll-margin-top: calc(var(--topbar-h) + 16px + env(safe-area-inset-top)); }
  .vin-input { font-size: clamp(1rem, 4vw, 1.25rem); letter-spacing: .04em; }
  .comp-proposal-actions button { width: 100%; white-space: normal; }
}

/* Review polish: page scrolling and readable, reachable controls. */
#comps > .rtable-wrap { max-height:none; overflow:visible; overscroll-behavior:auto; }
@container (min-width:560px) { #comps .rtable td:first-child { min-width:14rem; } }
@media (pointer:coarse), (max-width:650px) { :root { --touch-min:44px; } }
.settings-nav a { min-height:44px; display:inline-flex; align-items:center; }
@media (max-width:600px) {
  .settings-form .table-scroll { overflow:visible; }
  .settings-form table, .settings-form tbody, .settings-form tr, .settings-form td { display:block; width:100%; }
  .settings-form thead { display:none; }
  .settings-form tr { padding:12px; margin-bottom:12px; border:1px solid var(--line); border-radius:var(--r); }
  .settings-form td { border:0; padding:4px 0; }
  .settings-form td::before { content:attr(data-label); display:block; font-size:var(--t-xs); color:var(--ink-2); margin-bottom:4px; }
  .settings-form td input, .settings-form td select { width:100%; }
}
.summary-tools { display:flex; flex-wrap:wrap; gap:12px; margin-bottom:24px; }
@media print { .summary-tools { display:none!important; } }

/* Compact evidence review and an unobstructed phone form action region. */
.included-comps { list-style: none; padding: 0; margin: var(--s3) 0; }
.included-comps li { display: grid; gap: 2px; padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.included-comps strong { font-size: var(--t-sm); }
.included-comps small { color: var(--ink-2); }
.included-comps li.included-comp { grid-template-columns: minmax(0, 1fr) auto; column-gap: var(--s3); }
.included-comps li.included-comp > :not(.comp-row-actions) { grid-column: 1; }
.included-comps .comp-row-actions { grid-column: 2; grid-row: 1 / span 4; align-self: end; display: flex; gap: var(--s2); align-items: center; }
.included-comps .comp-row-actions form { margin: 0; }
.included-comps .comp-listing-link { width: 32px; min-height: 32px; height: 32px; padding: 0; justify-content: center; }
.included-comps .comp-remove { min-height: 32px; height: 32px; padding: 0 var(--s3); font-size: var(--t-xs); }
.comp-proposal-select { min-height: 32px; margin-bottom: 2px; }
.comp-proposal-facts { font-size: var(--t-sm); }
.comp-proposal-facts .chip { margin-top: 4px; }
.comp-evidence { margin: 0; }
.comp-counts { font-weight: 700; }
.comp-remaining > summary { min-height: 48px; }
.comp-proposals > .muted { font-size: var(--t-sm); }
[data-valuation-next] .button, [data-valuation-next] button { width: 100%; }
html:has(.submit-bar, .settings-save, .comp-proposal-actions, .save-bar) {
  scroll-padding-bottom: calc(var(--tabbar-h) + var(--form-action-height, 84px) + 28px + env(safe-area-inset-bottom));
}
@media (max-width: 1099px) {
  .submit-bar, .settings-save {
    padding: var(--s3);
    border: 1px solid var(--line-strong);
    border-radius: var(--r);
    background: var(--surface);
  }
  .new-appraisal-page .tabbar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 759px) {
}

.result-finalize { margin: var(--s3) 0 var(--s4); }
.result-finalize button { width: 100%; }
[data-valuation-next] .comp-search-title { max-width: 26rem; white-space: normal; font-size: var(--t-sm); }

.topbar .display-menu-toggle { min-height:40px; white-space:nowrap; }

.ws-next { margin-bottom: var(--s4); padding: var(--s3); border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.ws-next > button, .ws-next > .button { max-width: 26rem; }

@media (max-width: 759px) {
  .intake-photo-grid { grid-template-columns: minmax(0, 1fr); }
}

.ws-next .comp-search-progress { padding: 0; border: 0; color: var(--ink); }
.ws-next .comp-search-progress p { margin: 0 0 var(--s2); }
.ws-next .comp-search-stop { margin-top: var(--s2); }
.ws-next .comp-search-stop button { max-width: 26rem; }
.ws-next .comp-search-progress > .muted:last-child { margin-bottom: 0; }

.comp-proposal-label { min-width: 0; }
.comp-proposal-name, .comp-proposal-facts { display: block; }
.comp-proposal-facts { margin-top: 2px; }
.comp-proposal { padding: var(--s2) 0; }
@media (min-width: 760px) { .comp-evidence summary { min-height: 36px; } }

#result-panel { scroll-margin-top: calc(var(--topbar-h) + 16px + env(safe-area-inset-top)); }

/* Account actions stay together in each responsive shell. */
.account-menu { position: relative; padding: 0; border: 0; }
.account-menu[open] > summary { margin-bottom: 0; }
.account-options { position: absolute; z-index: 60; right: 0; top: calc(100% + 8px); min-width: 160px; padding: var(--s2); background: var(--surface); border: 2px solid var(--line-strong); border-radius: var(--r); box-shadow: var(--shadow-lg); }
.account-options a, .account-options button { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 0 var(--s3); background: var(--surface); color: var(--ink); border: 0; text-align: left; font: inherit; }
.account-options :is(a, button):hover { background: var(--surface-2); }
.sidebar-foot .account-menu { margin-top: var(--s2); }
.sidebar-foot .account-options { top: auto; bottom: calc(100% + 8px); left: 0; right: auto; }
@media (max-width: 480px) {
  .topbar .brand { font-size: .875rem; }
  .topbar .product-art--wordmark { display: none; }
  .topbar .product-art--mark { display: inline-flex; }
  .topbar .brand:has(.product-art--mark) { flex-shrink: 0; }
  .topbar-actions { flex: 1; }
  .topbar-actions .dealership-switcher { flex: 1; }
}
