:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --deduct: #e34948;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --good-text: #006300;
  --bad-text: #c03535;
  --focus: #2a78d6;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.06);
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #d95926;
    --deduct: #e66767;
    --good-text: #0ca30c;
    --bad-text: #e66767;
    --focus: #3987e5;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-2: #d95926;
  --deduct: #e66767;
  --good-text: #0ca30c;
  --bad-text: #e66767;
  --focus: #3987e5;
  --shadow: none;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--page);
  color: var(--text);
  font: 14px/1.45 var(--font);
  padding: 0 24px 48px;
  max-width: 1480px;
  margin: 0 auto;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 17px; letter-spacing: -0.01em; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--text-2); text-transform: none; }

a { color: var(--series-1); }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, tr:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

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

.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 0 14px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--series-1);
  position: relative;
}
.logo::after {
  content: ""; position: absolute; left: 5px; right: 5px; bottom: 6px; height: 4px;
  border-radius: 2px; background: var(--surface);
}
.config { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 10px; font-size: 12px; color: var(--text-2); background: var(--surface);
}
.pill .dot, .badge .dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none;
}
.pill.on .dot { background: var(--good); }
.top-actions { display: flex; gap: 8px; }

/* ---------------------------------------------------------------- controls */

.btn {
  font: inherit; font-weight: 500;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text);
  padding: 7px 14px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.primary { background: var(--series-1); border-color: transparent; color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.icon { padding: 7px 10px; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: transparent; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
textarea { width: 100%; resize: vertical; min-height: 84px; }

/* ---------------------------------------------------------------- layout */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.job {
  margin-bottom: 12px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  display: flex; gap: 10px; align-items: center;
}
.job.error { color: var(--bad-text); }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid var(--grid); border-top-color: var(--series-1);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

.kpis {
  display: grid; gap: 12px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-bottom: 12px;
}
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--text-2); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 600; letter-spacing: -0.01em; margin-top: 2px; }
.kpi .sub { color: var(--muted); font-size: 12px; }

.setup {
  margin-bottom: 12px; padding: 12px 16px;
  border: 1px dashed var(--axis); border-radius: 12px; color: var(--text-2);
}
.setup ul { margin: 6px 0 0; padding-left: 18px; }
.setup code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

.add { padding: 16px; margin-bottom: 16px; }
.add .hint { margin: 4px 0 10px; color: var(--text-2); }
.add-row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.add-row input[type="url"] { flex: 2 1 260px; }
.add-row input#add-price { flex: 1 1 120px; }

.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.filters input[type="search"] { flex: 1 1 200px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip {
  font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: 999px; padding: 4px 12px;
}
.chip[aria-pressed="true"] { background: var(--text); color: var(--surface); border-color: transparent; }
.chip .count { color: inherit; opacity: 0.7; margin-left: 4px; font-variant-numeric: tabular-nums; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) {
  body { padding: 0 16px 40px; }
  .kpi .value { font-size: 22px; }
}

/* ---------------------------------------------------------------- table */

.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--text-2);
  padding: 10px 12px; border-bottom: 1px solid var(--grid); white-space: nowrap;
  position: sticky; top: 0; background: var(--surface);
}
td { padding: 10px 12px; border-bottom: 1px solid var(--grid); vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr[aria-selected="true"] { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--series-1); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vehicle { font-weight: 600; }
.meta { color: var(--muted); font-size: 12px; margin-top: 1px; }
.pos { color: var(--good-text); }
.neg { color: var(--bad-text); }
.flags { color: var(--text-2); font-size: 12px; }
.flags .count { font-weight: 600; color: var(--text); }
.empty { color: var(--muted); padding: 24px; margin: 0; text-align: center; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 1px 9px 1px 7px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--surface);
}
.tone-good .dot { background: var(--good); }
.tone-accent .dot { background: var(--series-1); }
.tone-warning .dot { background: var(--warning); }
.tone-critical .dot { background: var(--critical); }
.tone-muted .dot { background: var(--muted); }
.tone-hollow .dot { background: transparent; box-shadow: inset 0 0 0 1.5px var(--muted); }

.track { font-size: 12px; color: var(--text-2); white-space: nowrap; }

/* ---------------------------------------------------------------- detail */

.detail { padding: 18px; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; }
@media (max-width: 1100px) { .detail { position: static; max-height: none; } }
.detail-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.detail-head h2 { font-size: 18px; letter-spacing: -0.01em; }
.summary { color: var(--text-2); margin: 6px 0 12px; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.section { border-top: 1px solid var(--grid); padding-top: 14px; margin-top: 14px; }
.section > h3 { margin-bottom: 8px; }

.hero-label { color: var(--text-2); font-size: 12px; }
.hero { font-size: 48px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; }
.verdict { margin: 6px 0 4px; }
.facts-inline { color: var(--text-2); font-size: 13px; display: flex; gap: 4px 14px; flex-wrap: wrap; }

.chart { width: 100%; display: block; margin-top: 10px; overflow: visible; }
.chart text { font: 12px var(--font); fill: var(--text-2); }
.chart .value-label { fill: var(--text); font-variant-numeric: tabular-nums; }
.chart .marker-label { fill: var(--text); font-weight: 600; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:focus { outline: none; }
.chart g.row:hover .bar, .chart g.row:focus-within .bar { filter: brightness(1.08); }

details.table-view { margin-top: 8px; font-size: 13px; }
details.table-view summary { cursor: pointer; color: var(--text-2); }
details.table-view table td, details.table-view table th { padding: 4px 6px; position: static; }

ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 4px 0; }
.flag-name { font-weight: 600; }
.evidence { color: var(--text-2); }
.comp { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.comp .desc { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comp a { white-space: nowrap; }

dl.facts { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }

.note { color: var(--text-2); font-size: 13px; }

/* ---------------------------------------------------------------- photos */

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
label.btn { display: inline-flex; align-items: center; }
#add-photos:focus-visible + .btn, label.btn:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.photo-count { margin: 8px 0 0; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; margin-bottom: 10px; }
.thumbs a { display: block; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--surface-2); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }
.findings { display: grid; gap: 6px; font-size: 13px; }
.findings .label { color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }

/* ---------------------------------------------------------------- seller messages */

.message { margin-top: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--page); }
.message-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.message-head .label, .subsection .label { color: var(--text-2); font-size: 12px; font-weight: 600; }
.message-text { margin: 6px 0 2px; white-space: pre-wrap; }
.subsection { margin-top: 12px; }
ul.bullets { list-style: disc; padding-left: 18px; font-size: 13px; }
ul.bullets li { padding: 2px 0; }
.note.warn { color: var(--bad-text); }

/* ---------------------------------------------------------------- my flips */

.views { display: flex; gap: 4px; margin: -4px 0 14px; border-bottom: 1px solid var(--grid); }
.view-tab {
  font: inherit; font-weight: 500; cursor: pointer; background: none; border: none;
  color: var(--text-2); padding: 8px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.view-tab[aria-pressed="true"] { color: var(--text); border-bottom-color: var(--series-1); }
.chart-card, .learned { padding: 16px; margin-bottom: 16px; }
.learned { margin-top: 16px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; }
.swatch.bar { width: 10px; height: 10px; border-radius: 2px; background: var(--series-1); }
.swatch.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--series-2); box-shadow: 0 0 0 2px var(--surface); }
.field { display: grid; gap: 2px; }
.field > .label { color: var(--text-2); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid input, .form-grid select { width: 100%; }
.cost-row { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 4px 0; border-bottom: 1px solid var(--grid); }
.cost-row .what { color: var(--text-2); }
.btn.link { border: none; background: none; color: var(--text-2); padding: 0 4px; cursor: pointer; }
.btn.link:hover { color: var(--bad-text); background: none; }
table.compare { width: 100%; font-size: 13px; }
table.compare th, table.compare td { padding: 4px 6px; position: static; border-bottom: 1px solid var(--grid); }
.status-sold .dot { background: var(--good); }
.status-holding .dot { background: var(--series-1); }

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

.login { min-height: 80vh; display: grid; place-items: center; }
.login-card { width: min(360px, 100%); padding: 24px; display: grid; gap: 14px; }
.login-card input { width: 100%; }

/* ---------------------------------------------------------------- feeds */

.section-head.padded { padding: 14px 16px 6px; margin: 0; }
.feeds-note { margin: 12px 4px; }
.share { display: inline-block; height: 6px; border-radius: 3px; background: var(--series-1); vertical-align: middle; margin-left: 8px; }

/* ---------------------------------------------------------------- tooltip */

.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  max-width: 260px;
}
.tooltip strong { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.tooltip span { color: var(--text-2); }
