/* RDX A-Spec Tracker: visual design (navy / slate, light + dark) */
:root {
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #8a94a6;
  --line: #e3e7ee;
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --accent: #1e3a5f;
  --accent-dark: #142a46;
  --accent-soft: #e9eff7;
  --link: #1f4f8a;
  --good: #1d7a3a;
  --bad: #b3362b;
  --good-bg: #e8f4ec;
  --bad-bg: #f8ebe9;
  --warn: #8a5a00;
  --warn-bg: #fff4dc;
  --chip-bg: #eef1f5;
  --photo-a: #eef1f5;
  --photo-b: #dde3ea;
  --photo-ph: #94a3b8;
  --kan-bg: #eef1f5;
  --input-border: #d5dbe4;
  --progress-bg: #e6eaf0;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, .10);
  --header-bg: linear-gradient(180deg, #13203a 0%, #0f1a2f 100%);
}

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
body { transition: background-color .2s ease, color .2s ease; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--accent-dark); text-decoration: underline; }
.muted { color: var(--muted); }
.hint { font-size: 12px; color: var(--muted); }
.up { color: var(--bad); }
.down { color: var(--good); }

/* ---------- header ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 32px; color: #fff; position: sticky; top: 0; z-index: 1030;
  background: var(--header-bg); border-bottom: 1px solid rgba(255, 255, 255, .06);
  box-shadow: 0 2px 10px rgba(15, 23, 42, .18);
}
.brand-wrap { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; display: block; box-shadow: 0 2px 8px rgba(0, 0, 0, .3); }
.brand { font-weight: 700; font-size: 18px; letter-spacing: -.1px; }
.brand-sub { font-size: 12px; color: #94a3b8; margin-top: 1px; }
.header-right { display: flex; align-items: center; gap: 12px; }
.header-right .btn-light { border-radius: 8px; font-weight: 600; padding: 6px 14px; color: #0f172a; }

.status-pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500;
  padding: 6px 12px; border-radius: 8px; background: rgba(255, 255, 255, .06); color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, .10);
}
.status-err { background: rgba(179, 54, 43, .22); color: #ffd9d4; border-color: rgba(255, 140, 120, .3); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-live { background: #34c759; box-shadow: 0 0 0 3px rgba(52, 199, 89, .2); }
.dot-snap { background: #f2b230; }

/* light/dark switch */
.theme-toggle { display: flex; align-items: center; gap: 6px; color: #cbd5e1; font-size: 14px; padding: 4px 10px;
  border-radius: 8px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .10); }
.theme-switch { margin: 0; padding-left: 2.5em; min-height: 0; display: flex; align-items: center; }
.theme-switch .form-check-input { width: 2.3em; height: 1.25em; margin-top: 0; cursor: pointer;
  background-color: rgba(255, 255, 255, .18); border-color: rgba(255, 255, 255, .28);
  --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e"); }
.theme-switch .form-check-input:checked { background-color: #4f7fc0; border-color: #4f7fc0; }
.theme-switch .form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(79, 127, 192, .3); }

/* ---------- tabs: classic underline ---------- */
.app-main { padding: 20px 32px 56px; max-width: 1640px; margin: 0 auto; overflow-x: clip; }
.app-tabs.nav-tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-bottom: 20px; padding: 0; background: none;
  border-bottom: 1px solid var(--line); border-radius: 0; }
.app-tabs .nav-item { margin: 0; }
.app-tabs .nav-link, .app-tabs .nav-link:hover, .app-tabs .nav-link:focus {
  border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; margin-bottom: -1px;
  color: var(--ink-2); font-weight: 600; font-size: 13.5px; padding: 10px 14px; text-decoration: none;
  transition: color .15s, border-color .15s;
}
.app-tabs .nav-link:hover { color: var(--ink); border-bottom-color: var(--line); }
.app-tabs .nav-link.active, .app-tabs .nav-link.active:hover {
  color: var(--ink); background: none; border: 0; border-bottom: 2px solid var(--accent);
}

/* ---------- cards ---------- */
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.panel-head {
  background: transparent; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between;
  align-items: center; padding: 13px 18px; border-radius: var(--radius) var(--radius) 0 0 !important;
}
.panel .card-body { padding: 16px 18px; }
.panel-title { font-weight: 650; font-size: 14.5px; letter-spacing: -.05px; }
.panel-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------- search summary ---------- */
.hero {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 13px 18px; margin-bottom: 16px; border-radius: var(--radius); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); background: var(--surface); box-shadow: var(--shadow);
}
.hero-kicker { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .9px; color: var(--ink-2); margin-bottom: 6px; }
.hero-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.hero-chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.hero-links { display: flex; gap: 16px; align-items: center; }
.hero-link { font-size: 13px; font-weight: 600; }
.hero-btn { background: none; border: none; padding: 0; color: var(--link); }
.hero-btn:hover { color: var(--accent-dark); text-decoration: underline; }

/* ---------- KPI tiles ---------- */
.kpi-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: center; gap: 8px; }
.kpi-icon { width: 26px; height: 26px; border-radius: 6px; display: inline-grid; place-items: center; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; }
.kpi-label { font-size: 11.5px; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: -.5px; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--ink-2); margin-top: 4px; line-height: 1.4; }

/* ---------- badges & chips ---------- */
.vs { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px;
  border-radius: 6px; white-space: normal; max-width: 100%; line-height: 1.35; }
.vs-good { color: var(--good); background: var(--good-bg); }
.vs-bad { color: var(--bad); background: var(--bad-bg); }
.vs-mid, .vs-na { color: var(--ink-2); background: var(--chip-bg); }
.vs-warn { color: var(--warn); background: var(--warn-bg); }
.vs-sm { font-size: 11px; padding: 2px 7px; }
.chip { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 6px; background: var(--chip-bg); color: var(--ink-2); margin-right: 4px; }
.chip-lg { font-size: 13px; padding: 5px 12px; margin-right: 6px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.in-pipe { display: inline-flex; align-items: center; font-size: 12px; color: var(--good); font-weight: 700; white-space: nowrap; }

/* days on market */
.dom-chip { display: inline-flex; align-items: center; flex-wrap: wrap; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.dom-chip.dom-long { color: var(--warn); }
.dom-note { font-weight: 500; }

/* ---------- photos ---------- */
.photo { position: relative; overflow: hidden; background: linear-gradient(135deg, var(--photo-a), var(--photo-b)); }
.photo-ph { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--photo-ph); font-size: 11.5px; font-weight: 500; }
.photo-ph i { font-size: 30px; }
.car-photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.img-failed { display: none !important; }
.photo-badge { position: absolute; top: 8px; left: 8px; z-index: 2; font-size: 11px; font-weight: 600; color: #fff;
  background: rgba(15, 23, 42, .78); backdrop-filter: blur(4px); padding: 3px 8px; border-radius: 6px; }
.photo-badge-right { left: auto; right: 8px; }
.photo-badge.dom-long { background: rgba(138, 90, 0, .9); }
.photo-count { left: auto; right: 8px; top: auto; bottom: 8px; }

/* Best-value photo cards */
.card-strip { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 14px;
  overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x proximity; }
.pcard { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--surface); scroll-snap-align: start; transition: box-shadow .18s ease, border-color .18s ease; }
.pcard:hover { box-shadow: var(--shadow-lg); border-color: #cfd6e0; }
.pcard:hover .car-photo { transform: scale(1.03); }
.pcard > a:hover, .pick a:hover { text-decoration: none; }
.pcard-photo { aspect-ratio: 16 / 10; }
.pcard-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 3px; flex-grow: 1; }
.pcard-title { font-weight: 650; font-size: 13.5px; }
.pcard-price { font-weight: 700; font-size: 20px; letter-spacing: -.3px; }
.pcard-meta { font-size: 12px; color: var(--ink-2); }
.pcard-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.pcard-action { margin-top: auto; padding-top: 10px; }

/* Detail views */
.pick-photo { aspect-ratio: 4 / 3; border-radius: 8px; }
.pick-price { font-size: 21px; font-weight: 700; letter-spacing: -.3px; margin-top: 2px; }
.pick-thumb { width: 150px; aspect-ratio: 4 / 3; border-radius: 8px; flex-shrink: 0; }
.pick { display: flex; align-items: center; gap: 14px; margin-top: 10px; padding: 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface-2); }
.gallery { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory; border-radius: var(--radius); }
.gallery-item { flex: 0 0 100%; aspect-ratio: 16 / 10; scroll-snap-align: center; border-radius: var(--radius); }
.gallery-hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; }
.photo-hero { aspect-ratio: 16 / 10; border-radius: var(--radius); }

/* Listings table thumbnails */
.grid-thumb { width: 76px; height: 50px; object-fit: cover; border-radius: 6px; display: block; margin-top: 4px; background: var(--photo-b); }
.grid-thumb-ph { display: grid; place-items: center; color: var(--photo-ph); font-size: 18px; }

/* ---------- overview lists ---------- */
.value-meta { font-size: 12px; color: var(--ink-2); }
.process-list .form-check { padding: 7px 0 7px 1.9em; border-bottom: 1px solid var(--line); margin: 0; }
.process-list .form-check:last-child { border-bottom: none; }
.process-list .form-check-input:checked + .form-check-label { color: var(--muted); text-decoration: line-through; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-check-input:focus { box-shadow: 0 0 0 .2rem rgba(30, 58, 95, .15); border-color: var(--accent); }
.form-switch .form-check-input:checked { background-color: var(--accent); }

.activity { max-height: 320px; overflow-y: auto; }
.act { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.act:last-child { border-bottom: none; }
.act-icon { font-size: 16px; color: var(--ink-2); margin-top: 1px; }
.act-price .bi-graph-down-arrow { color: var(--good); }
.act-price .bi-graph-up-arrow, .act-status .act-icon { color: var(--bad); }
.act-time { font-size: 11px; color: var(--muted); }

/* ---------- pipeline board ---------- */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(230px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.kan-col { background: var(--kan-bg); border-radius: var(--radius); padding: 12px; min-height: 420px; border-top: 3px solid #cbd5e1; }
.kan-col:nth-child(2) { border-top-color: #94a3b8; }
.kan-col:nth-child(3) { border-top-color: #64748b; }
.kan-col:nth-child(4) { border-top-color: #3f5878; }
.kan-col:nth-child(5) { border-top-color: var(--accent); }
.kan-head { display: flex; justify-content: space-between; align-items: center; }
.kan-title { font-weight: 650; }
.kan-count { font-size: 12px; font-weight: 700; background: var(--surface); border-radius: 6px; padding: 1px 8px; color: var(--ink-2); }
.kan-hint { font-size: 11.5px; color: var(--muted); margin: 2px 0 12px; }
.car-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 3px; box-shadow: var(--shadow-sm); transition: box-shadow .15s, border-color .15s; }
.car-card:hover { box-shadow: var(--shadow-lg); border-color: #cfd6e0; }
.kcard-photo { aspect-ratio: 16 / 9; border-radius: 6px; margin-bottom: 6px; }
.car-title { font-weight: 650; font-size: 13px; }
.car-price { font-weight: 700; font-size: 18px; letter-spacing: -.2px; }
.car-price + span { font-size: 11px; font-weight: 600; }
.car-meta { font-size: 12px; color: var(--ink-2); }
.stars { color: #b7791f; font-size: 12px; letter-spacing: 1px; }
.chips { margin-top: 3px; }
.flag { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.flag-bad { color: var(--bad); }
.car-actions { display: flex; gap: 6px; margin-top: 8px; }
.closed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.summary-strip { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- car panel & forms ---------- */
.offcanvas, .toast { background: var(--surface); color: var(--ink); }
.offcanvas { border-left: none !important; box-shadow: -12px 0 40px rgba(15, 23, 42, .18); }
.offcanvas-header { border-bottom: 1px solid var(--line); }
.offcanvas-header .btn-close { opacity: .7; }
.offcanvas-title { font-weight: 650; }
.field-label { font-size: 12px; font-weight: 650; color: var(--ink-2); margin-bottom: 4px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 18px; }
.facts > div { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 5px 0; font-size: 13px; }
.facts-1 { grid-template-columns: 1fr; }
.fact-k { color: var(--muted); margin-right: 8px; }
.fact-v { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.rating { flex-wrap: nowrap; }
.rating .form-check { padding-left: 0; margin: 0; }
.rating .btn { font-size: 12px; padding: 3px 9px; }
.rating .btn.active { background: #b7791f; border-color: #b7791f; color: #fff; }
.car-checks .form-check { margin-bottom: 3px; }
.form-control, .form-select, .input-group-text { border-radius: 7px; border-color: var(--input-border); }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem rgba(30, 58, 95, .12); }
.table { --bs-table-bg: transparent; }

/* ---------- buttons ---------- */
.btn { border-radius: 7px; font-weight: 600; }
.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent-dark);
  --bs-btn-hover-border-color: var(--accent-dark); --bs-btn-active-bg: var(--accent-dark); --bs-btn-active-border-color: var(--accent-dark);
  --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); }
.btn-outline-primary { --bs-btn-color: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent); --bs-btn-active-bg: var(--accent); }
.btn-dark { background: #1e293b; border-color: #1e293b; }
.btn-dark:hover { background: #0f172a; border-color: #0f172a; }
.progress { background: var(--progress-bg); border-radius: 4px; }
.progress-bar.bg-primary { background: var(--accent) !important; }

/* ---------- budget ---------- */
.big-num { font-size: 28px; font-weight: 700; letter-spacing: -.5px; }
.small-big { font-size: 21px; }
.breakdown .bd-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.compare td, .compare th { vertical-align: middle; }
.compare th { font-size: 12px; color: var(--ink-2); font-weight: 650; }
.setup { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }

/* ---------- map ---------- */
.map-controls { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: flex-end; margin-bottom: 12px; }
.map-controls .form-check-inline { margin-right: 10px; margin-bottom: 4px; }
.map-controls .field-label { margin-bottom: 3px; }
.map-ctl-select { width: 136px; }
.map-ctl-years { width: 170px; }
.map-ctl-price { width: 124px; }

/* Map tab: price pins, numbered circles, and the panels floating over the map */
.map-wrap { position: relative; height: max(560px, calc(100vh - 300px)); border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.map-wrap .leaflet-container { background: var(--surface-2); font-family: inherit; }
.pin-host { width: 0 !important; height: 0 !important; background: none; border: none; }
.price-pin, .pin-count { position: absolute; transform: translate(-50%, -50%); font-weight: 650; white-space: nowrap; cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .35); transition: transform .12s ease; }
.price-pin { display: inline-flex; align-items: center; gap: 3px; padding: 3px 8px; border-radius: 999px; font-size: 12px; line-height: 16px; }
.price-pin i { font-size: 10px; }
.pin-other { background: #ffffff; color: #0f172a; border: 1px solid #b6bfcc; }
.pin-deal { background: #1f5fbf; color: #ffffff; border: 1px solid #1f5fbf; }
.pin-check { background: #fff4dc; color: #6b4600; border: 1px solid #8a5a00; }
.pin-count { display: flex; align-items: center; justify-content: center; border-radius: 50%; background: #1e3a5f; color: #ffffff;
  border: 2px solid #ffffff; font-size: 12px; }
.pin-count-sm { width: 30px; height: 30px; }
.pin-count-md { width: 38px; height: 38px; font-size: 13px; }
.pin-count-lg { width: 46px; height: 46px; font-size: 14px; }
.pin-tracked { outline: 2px solid #0f172a; outline-offset: 1px; }
.price-pin:hover, .pin-count:hover { transform: translate(-50%, -50%) scale(1.1); }
.is-selected { transform: translate(-50%, -50%) scale(1.15); outline: 3px solid #f59e0b; outline-offset: 1px; }
.pin-sample { position: static; transform: none !important; box-shadow: none; cursor: default; margin-right: 5px; }
.pin-sample.pin-count-sm { width: 22px; height: 22px; font-size: 11px; display: inline-flex; border-width: 1px; }
.pin-tip { font-size: 12px; line-height: 1.45; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow-lg); }
.pin-tip.leaflet-tooltip-top::before { border-top-color: var(--surface); }
.map-legend { position: absolute; left: 10px; bottom: 10px; z-index: 900; display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; max-width: calc(100% - 200px);
  padding: 6px 10px; font-size: 12px; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); pointer-events: none; }
.legend-item { display: inline-flex; align-items: center; white-space: nowrap; }
.map-empty { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 900; padding: 6px 12px; font-weight: 600; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-sm); }
.map-panel { position: absolute; top: 10px; right: 10px; bottom: 10px; z-index: 1000; width: min(340px, calc(100% - 20px)); padding: 14px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); }
.map-panel-close { position: sticky; top: 0; float: right; z-index: 3; margin: -4px -4px 4px 8px; background: var(--surface); }
.map-dealer-name { padding-right: 30px; }
.map-car-row { display: flex; gap: 10px; width: 100%; padding: 10px 0; text-align: left; color: var(--ink); background: none; border: none; border-top: 1px solid var(--line); cursor: pointer; }
.map-car-row:hover { background: var(--surface-2); }
.map-car-thumb { width: 84px; aspect-ratio: 4 / 3; border-radius: 6px; flex-shrink: 0; }
.link-btn { padding: 0; font-size: 12.5px; color: var(--link); background: none; border: none; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---------- sold comps ---------- */
.comps-mini { font-size: 13px; line-height: 1.5; }
.comps-table td, .comps-table th { font-size: 12px; padding: 4px 6px; }

/* ---------- AG Grid ---------- */
.ag-root-wrapper { border-radius: 8px; border-color: var(--line) !important; }

.app-toast { position: fixed; bottom: 24px; left: 24px; z-index: 2000; min-width: 320px; border-radius: var(--radius); box-shadow: var(--shadow-lg); }

@media (max-width: 992px) {
  .app-main { padding: 14px; }
  .app-header { padding: 10px 14px; }
  .brand-sub { display: none; }
  .pick { flex-direction: column; align-items: stretch; }
  .pick-thumb { width: 100%; }
}

/* ======================================================================
   Dark mode: same layout, deep slate surfaces, lighter ink, steel-blue accent
   ====================================================================== */
html[data-bs-theme="dark"] {
  --ink: #e8ecf2;
  --ink-2: #b4bdca;
  --muted: #7f8a9b;
  --line: #253041;
  --bg: #0b111c;
  --surface: #121a27;
  --surface-2: #182233;
  --accent: #5b8fd6;
  --accent-dark: #4a7cc0;
  --accent-soft: rgba(91, 143, 214, .16);
  --link: #8db6ec;
  --good: #5cc98a;
  --bad: #ff8a7a;
  --good-bg: rgba(92, 201, 138, .13);
  --bad-bg: rgba(255, 138, 122, .13);
  --warn: #f2c35b;
  --warn-bg: rgba(242, 178, 48, .14);
  --chip-bg: #1e293b;
  --photo-a: #1a2332;
  --photo-b: #121a27;
  --photo-ph: #5c6b80;
  --kan-bg: #0f1622;
  --input-border: #2c3a4f;
  --progress-bg: #1e293b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 1px 2px rgba(0, 0, 0, .45), 0 1px 4px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .55);
  --header-bg: linear-gradient(180deg, #0a1120 0%, #070c17 100%);
  --bs-body-bg: #0b111c;
  --bs-body-color: #e8ecf2;
  --bs-border-color: #253041;
  /* Dash 4 dropdowns, date pickers, tooltips */
  --Dash-Fill-Inverse-Strong: #182233;
  --Dash-Fill-Interactive-Strong: #5b8fd6;
  --Dash-Fill-Interactive-Weak: rgba(255, 255, 255, .04);
  --Dash-Fill-Primary-Hover: rgba(255, 255, 255, .06);
  --Dash-Fill-Primary-Active: rgba(255, 255, 255, .10);
  --Dash-Fill-Disabled: rgba(255, 255, 255, .08);
  --Dash-Stroke-Strong: rgba(255, 255, 255, .28);
  --Dash-Stroke-Weak: rgba(255, 255, 255, .10);
  --Dash-Text-Strong: #e8ecf2;
  --Dash-Text-Primary: rgba(232, 236, 242, .87);
  --Dash-Text-Weak: rgba(232, 236, 242, .62);
  --Dash-Text-Disabled: rgba(232, 236, 242, .4);
  --Dash-Shading-Strong: rgba(0, 0, 0, .6);
  --Dash-Shading-Weak: rgba(0, 0, 0, .4);
  --Dash-Tooltip-Background-Color: #182233;
  --Dash-Tooltip-Border-Color: #2c3a4f;
}
html[data-bs-theme="dark"] .form-control, html[data-bs-theme="dark"] .form-select,
html[data-bs-theme="dark"] .input-group-text { background-color: var(--surface-2); color: var(--ink); }
html[data-bs-theme="dark"] .form-control::placeholder { color: var(--muted); }
html[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #0b111c; --bs-btn-hover-color: #0b111c; --bs-btn-active-color: #0b111c; }
html[data-bs-theme="dark"] .btn-dark { background: #e8ecf2; border-color: #e8ecf2; color: #0f172a; }
html[data-bs-theme="dark"] .btn-dark:hover { background: #ffffff; border-color: #ffffff; }
html[data-bs-theme="dark"] .btn-outline-secondary { color: var(--ink-2); border-color: #33415a; }
html[data-bs-theme="dark"] .btn-outline-secondary:hover { background: #1e293b; color: var(--ink); }
html[data-bs-theme="dark"] .pcard:hover, html[data-bs-theme="dark"] .car-card:hover { border-color: #33415a; }
html[data-bs-theme="dark"] .kan-col { border-top-color: #33415a; }
html[data-bs-theme="dark"] .kan-col:nth-child(2) { border-top-color: #475569; }
html[data-bs-theme="dark"] .kan-col:nth-child(3) { border-top-color: #64748b; }
html[data-bs-theme="dark"] .kan-col:nth-child(4) { border-top-color: #4a6c99; }
html[data-bs-theme="dark"] .kan-col:nth-child(5) { border-top-color: var(--accent); }
html[data-bs-theme="dark"] .alert-light { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
html[data-bs-theme="dark"] .photo-badge { background: rgba(0, 0, 0, .72); }
html[data-bs-theme="dark"] .photo-badge.dom-long { background: rgba(138, 90, 0, .92); }
html[data-bs-theme="dark"] .rating .btn.active { background: #d69e2e; border-color: #d69e2e; color: #0b111c; }
html[data-bs-theme="dark"] .stars { color: #e0a93b; }

/* AG Grid: its theme declares --ag-* variables with :where() (zero specificity), so these win */
[class*="ag-theme-params-"] { --ag-accent-color: #1e3a5f; --ag-selected-row-background-color: rgba(30, 58, 95, .10); }
html[data-bs-theme="dark"] [class*="ag-theme-params-"] {
  --ag-browser-color-scheme: dark;
  --ag-background-color: #121a27;
  --ag-data-background-color: #121a27;
  --ag-foreground-color: #e8ecf2;
  --ag-text-color: #e8ecf2;
  --ag-cell-text-color: #e8ecf2;
  --ag-border-color: #253041;
  --ag-row-border-color: #1c2638;
  --ag-header-background-color: #182233;
  --ag-header-text-color: #b4bdca;
  --ag-chrome-background-color: #182233;
  --ag-odd-row-background-color: #141d2b;
  --ag-row-hover-color: #1b2638;
  --ag-selected-row-background-color: rgba(91, 143, 214, .2);
  --ag-accent-color: #5b8fd6;
  --ag-input-background-color: #182233;
  --ag-input-border-color: #2c3a4f;
}

/* ---------- suggested offer ---------- */
.plan-box { border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: var(--radius);
  background: var(--surface-2); padding: 12px 14px; }
.plan-title { font-weight: 650; font-size: 13.5px; margin-bottom: 8px; display: flex; align-items: center; }
.plan-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.plan-tile { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.plan-tile.plan-1 { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.plan-label { font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-2); }
.plan-value { font-size: 20px; font-weight: 700; letter-spacing: -.3px; margin-top: 2px; }
.plan-value-sm { font-size: 17px; }
.plan-otd { font-size: 11.5px; color: var(--ink-2); margin-top: 1px; }
.plan-note { font-size: 11px; color: var(--muted); }
.plan-reasons { margin: 10px 0 6px; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); }
.plan-reasons li { margin-bottom: 3px; }
.email-summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--link); }
.email-wrap { position: relative; }
.email-box { font-size: 12.5px; line-height: 1.45; padding-right: 36px; }
.email-copy { position: absolute; top: 6px; right: 8px; cursor: pointer; color: var(--ink-2); font-size: 16px; }
.email-copy:hover { color: var(--accent); }

/* ---------- price cuts & follow-ups ---------- */
.cut-list { max-height: 420px; overflow-y: auto; }
.cut-row, .fu-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cut-row:last-child, .fu-row:last-child { border-bottom: none; }
.cut-thumb { width: 96px; aspect-ratio: 4 / 3; border-radius: 6px; flex-shrink: 0; }
.was { text-decoration: line-through; color: var(--muted); }
.fu-chip { display: inline-flex; align-items: center; font-size: 11.5px; font-weight: 600; padding: 2px 8px;
  border-radius: 6px; margin-top: 4px; background: var(--chip-bg); color: var(--ink-2); width: fit-content; }
.fu-chip.fu-overdue { background: var(--bad-bg); color: var(--bad); }
.fu-chip.fu-today { background: var(--warn-bg); color: var(--warn); }
.fu-chip.fu-soon { background: var(--accent-soft); color: var(--accent); }

/* ---------- model-year guide ---------- */
.year-table td { font-size: 13px; vertical-align: top; }
.year-table .yg-notes { max-width: 440px; color: var(--ink-2); }
.phone-url { font-size: 12.5px; padding: 6px 8px; border-radius: 6px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--ink); word-break: break-all; }

/* ---------- phones ---------- */
@media (max-width: 576px) {
  .app-header { padding: 8px 12px; gap: 8px; }
  .brand { font-size: 15px; }
  .brand-mark { width: 32px; height: 32px; }
  .header-right { gap: 6px; }
  .status-pill { font-size: 0; padding: 6px; gap: 0; }
  .status-pill .dot { margin: 0; }
  .header-right .btn-light { padding: 5px 9px; font-size: 0; }
  .header-right .btn-light i { font-size: 15px; margin: 0 !important; }
  .app-main { padding: 10px 10px 40px; }
  .app-tabs.nav-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .app-tabs .nav-link { white-space: nowrap; padding: 9px 10px; }
  .hero { padding: 10px 12px; }
  .kpi-value { font-size: 21px; }
  .card-strip { grid-auto-columns: 82%; }
  .kanban { grid-template-columns: repeat(5, 82%); }
  .plan-tiles { grid-template-columns: 1fr 1fr 1fr; }
  .plan-value { font-size: 16px; }
  .cut-thumb { width: 72px; }
  .facts { grid-template-columns: 1fr; }
}

/* ---------- search builder ---------- */
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px 16px; }
.fgrid-core { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.fctl { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fctl-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
.mode-select { width: auto; min-width: 74px; padding-top: 1px; padding-bottom: 1px; font-size: 11.5px; }
.range-row { display: flex; align-items: center; gap: 6px; }
.range-row .input-group { flex: 1 1 0; min-width: 0; }
.range-dash { color: var(--muted); }
.fdd { font-size: 13px; }
.filter-accordion .accordion-button { padding: 10px 14px; font-weight: 600; font-size: 13.5px; background: var(--surface-2); color: var(--ink); }
.filter-accordion .accordion-button:not(.collapsed) { background: var(--accent-soft); color: var(--ink); box-shadow: none; }
.filter-accordion .accordion-button:focus { box-shadow: 0 0 0 .2rem rgba(30, 58, 95, .12); }
.filter-accordion .accordion-item { border-color: var(--line); background: var(--surface); }
.filter-accordion .accordion-body { padding: 14px; }
.sticky-col { position: sticky; top: 84px; }
@media (max-width: 992px) { .sticky-col { position: static; } }

/* ---------- report card ---------- */
.grade { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.grade.vs-sm { font-size: 11px; padding: 2px 7px; }
.grade-clean { color: var(--good); background: var(--good-bg); }
.grade-check { color: var(--warn); background: var(--warn-bg); }
.grade-avoid { color: #fff; background: var(--bad); }
.rc-box { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.rc-item { font-size: 12.5px; color: var(--ink-2); padding: 2px 0; display: flex; align-items: baseline; }
.rc-summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--link); }
.rc-recall { border-top: 1px solid var(--line); padding: 6px 0; }
.rc-urgent { font-size: 12px; font-weight: 700; color: var(--bad); }
.lv-ok { color: var(--good); } .lv-info { color: var(--muted); } .lv-warn { color: var(--warn); } .lv-bad { color: var(--bad); }

/* ---------- market gauge ---------- */
.gauge-label { font-size: 21px; font-weight: 700; letter-spacing: -.3px; margin-bottom: 12px; }
.gauge-track { position: relative; height: 8px; border-radius: 4px; background: var(--progress-bg); }
.gauge-mark { position: absolute; top: 50%; width: 18px; height: 18px; border-radius: 50%; background: var(--accent);
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--accent); transform: translate(-50%, -50%); }
.gauge-scale { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 8px; }
.gauge-signals { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px 18px; }
.gauge-signal { display: flex; gap: 8px; font-size: 13px; }
.gauge-lean { color: var(--ink-2); margin-top: 1px; }

/* ---------- side by side ---------- */
.cmp-table th, .cmp-table td { font-size: 13px; vertical-align: top; }
.cmp-table { table-layout: fixed; }
.cmp-table thead th:first-child { width: 170px; }
.cmp-head { font-weight: 400; }
.nowrap-cells td:not(:first-child) { white-space: nowrap; }
.quote-table td { white-space: nowrap; }
.quote-table .chip { display: block; width: fit-content; margin: 2px 0 0; }
.quote-table td:first-child { white-space: normal; min-width: 200px; }
.quote-table details[open] { white-space: normal; min-width: 280px; }
.cmp-photo { aspect-ratio: 16 / 10; border-radius: 6px; }
.cmp-section { background: var(--surface-2) !important; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--ink-2) !important; }
.cmp-label { color: var(--muted) !important; min-width: 170px; }
.cmp-best { font-weight: 700; }
.cmp-same td { color: var(--muted); }
.cmp-options { margin: 0; padding-left: 16px; font-size: 12px; }

/* ---------- quotes ---------- */
.icon-btn { background: none; border: none; color: var(--muted); padding: 2px 6px; cursor: pointer; }
.icon-btn:hover { color: var(--bad); }

html[data-bs-theme="dark"] .pin-deal { background: #2a6fd0; border-color: #2a6fd0; }
html[data-bs-theme="dark"] .pin-other { background: #182233; color: #e8ecf2; border-color: #4a5a70; }
html[data-bs-theme="dark"] .pin-check { background: #3a2c10; color: #f5d48a; border-color: #b58a2c; }
html[data-bs-theme="dark"] .pin-count { background: #5b8fd6; color: #0b111c; border-color: #0b111c; }
html[data-bs-theme="dark"] .pin-tracked { outline-color: #e8ecf2; }

/* Keep the legend clear of the map credit on smaller screens */
@media (max-width: 1199px) {
  .map-legend { bottom: 30px; max-width: calc(100% - 20px); }
}
@media (max-width: 767px) {
  .map-legend { left: 6px; right: 6px; bottom: 46px; gap: 4px 10px; padding: 4px 8px; font-size: 11px; }
  .map-legend .price-pin { padding: 1px 6px; font-size: 11px; }
  .map-legend .pin-count-sm { width: 18px; height: 18px; font-size: 10px; }
}
