/* car_price_trends — design tokens and layout.
 *
 * "Glovebox": one component set — dial, lamps, taped photo, handwritten
 * annotation — at two lighting conditions, daylight and night, rather than
 * two different apps. See CLAUDE.md and the design review for the reasoning;
 * in short, a component (the dial) is not a theme, so it exists in both
 * states, and only the *tokens* it draws from change between them.
 *
 * Colours are the validated reference data-viz palette (checked with this
 * project's dataviz skill validator, not eyeballed — see the two categorical
 * pairs below). Every value is defined once on :root (daylight), then
 * redefined for OS-dark and for an explicit data-theme="dark" stamp, so the
 * toggle wins in both directions.
 */

@font-face {
  /* Interface — headings, body, labels. Warm and rounded without losing a
     table. Self-hosted (not linked from Google Fonts): this app's whole
     purpose is tracking what car someone is privately shopping for, and a
     third-party font request on every page view would leak exactly that —
     see CLAUDE.md's identical reasoning for not pulling charts from a CDN. */
  font-family: "Nunito";
  src: url("/static/fonts/nunito.woff2") format("woff2");
  font-weight: 400 800;
  font-style: normal;
  font-display: swap;
}
@font-face {
  /* Readouts only — dial numerals, stat figures, table numbers. Narrow and
     even at any size, which Nunito cannot do. */
  font-family: "Saira Semi Condensed";
  src: url("/static/fonts/saira-semicondensed-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Saira Semi Condensed";
  src: url("/static/fonts/saira-semicondensed-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Saira Semi Condensed";
  src: url("/static/fonts/saira-semicondensed-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  /* Your own marks only — a tracker's notes, a tag-group heading. Never a
     number, a label, or a control: see .hand below. */
  font-family: "Caveat";
  src: url("/static/fonts/caveat.woff2") format("woff2");
  font-weight: 600 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;

  /* surfaces & ink — paper, by daylight */
  --page:            #f1f1ea;
  --surface:         #fcfcf8;
  --surface-sunk:    #eae7db;
  --ink:             #1b1e29;
  --ink-2:           #4a4f61;
  --ink-muted:       #7b8092;
  --grid:            #e4e2d5;
  --axis:            #cac7b7;
  --border:          rgba(27, 30, 41, 0.12);
  --border-strong:   rgba(27, 30, 41, 0.20);
  --shadow:          0 1px 2px rgba(27, 30, 41, .05), 0 8px 24px -12px rgba(27, 30, 41, .18);
  --shadow-hover:    0 2px 4px rgba(27, 30, 41, .07), 0 12px 28px -14px rgba(27, 30, 41, .24);

  /* categorical slots — validated against surface #fcfcf8: run
     node scripts/validate_palette.js "#a9651a,#2f5bc4" --mode light --surface "#fcfcf8"
     from the dataviz skill to re-check before ever changing these. */
  --series-1:        #a9651a;   /* the dial, bars, the median line — ochre */
  --series-2:        #2f5bc4;   /* the fit line, and every handwritten mark — pen blue */
  --series-3:        #3f8f5c;

  /* sequential ramp, reserved for washes/fills (unused today) */
  --blue-100:        #d7e3fb;
  --blue-250:        #9cb8ee;
  --blue-450:        #2f5bc4;
  --blue-600:        #1d3d8a;

  /* status — fixed, never themed, always paired with an icon or label */
  --good:            #0ca30c;
  --warning:         #fab219;
  --serious:         #ec835a;
  --critical:        #d03b3b;
  --good-text:       #006300;

  /* Glovebox-only: tape, mount and the paper the annotation layer writes on. */
  --tape:            rgba(255, 224, 130, 0.85);
  --highlight:       #ffe98a;
  --highlight-ink:   #1b1e29;

  --radius:          14px;
  --radius-sm:       9px;
  --font:        "Nunito", "Helvetica Neue", Arial, sans-serif;
  --font-figure: "Saira Semi Condensed", "Helvetica Neue", Arial, sans-serif;
  --font-hand:   "Caveat", "Bradley Hand", cursive;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    /* the same materials, after dark — an instrument cluster, not a
       different app. Re-validated at this surface, not inverted by eye:
       node scripts/validate_palette.js "#c97a1c,#4d7fe0" --mode dark --surface "#171a21" */
    --page:          #0e1014;
    --surface:       #171a21;
    --surface-sunk:  #12141a;
    --ink:           #f0f2f6;
    --ink-2:         #a9b2c0;
    --ink-muted:     #767f8d;
    --grid:          #262b35;
    --axis:          #333a46;
    --border:        rgba(240, 242, 246, 0.10);
    --border-strong: rgba(240, 242, 246, 0.18);
    --shadow:        0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px -16px rgba(0, 0, 0, .8);
    --shadow-hover:  0 2px 4px rgba(0, 0, 0, .6), 0 16px 36px -16px rgba(0, 0, 0, .85);

    --series-1:      #c97a1c;
    --series-2:      #4d7fe0;
    --series-3:      #4aa876;

    --blue-100:      #17264f;
    --blue-250:      #2a4694;
    --blue-450:      #4d7fe0;
    --blue-600:      #9cb8ee;
    --good-text:     #0ca30c;
    --critical:      #e06666;

    --tape:          rgba(201, 122, 28, 0.28);
    --highlight:      rgba(201, 122, 28, 0.20);
    --highlight-ink:  #dfa257;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page:          #0e1014;
  --surface:       #171a21;
  --surface-sunk:  #12141a;
  --ink:           #f0f2f6;
  --ink-2:         #a9b2c0;
  --ink-muted:     #767f8d;
  --grid:          #262b35;
  --axis:          #333a46;
  --border:        rgba(240, 242, 246, 0.10);
  --border-strong: rgba(240, 242, 246, 0.18);
  --shadow:        0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px -16px rgba(0, 0, 0, .8);
  --shadow-hover:  0 2px 4px rgba(0, 0, 0, .6), 0 16px 36px -16px rgba(0, 0, 0, .85);

  --series-1:      #c97a1c;
  --series-2:      #4d7fe0;
  --series-3:      #4aa876;

  --blue-100:      #17264f;
  --blue-250:      #2a4694;
  --blue-450:      #4d7fe0;
  --blue-600:      #9cb8ee;
  --good-text:     #0ca30c;
  --critical:      #e06666;

  --tape:          rgba(201, 122, 28, 0.28);
  --highlight:      rgba(201, 122, 28, 0.20);
  --highlight-ink:  #dfa257;
}

/* ---------------------------------------------------------------- base */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--series-1); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.06rem; }
h3 { font-size: 0.95rem; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  /* In landscape on a notched iPhone the cutout sits to one side, not the
     top — env(safe-area-inset-*) is 0 unless the viewport meta opts in with
     viewport-fit=cover (see base.html), which is also what makes content
     draw edge-to-edge under the notch in the first place. */
  padding: 0 calc(24px + env(safe-area-inset-right, 0px)) calc(88px + env(safe-area-inset-bottom, 0px))
    calc(24px + env(safe-area-inset-left, 0px));
}

/* ---------------------------------------------------------------- header */

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}

.masthead-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 13px calc(24px + env(safe-area-inset-right, 0px)) 13px calc(24px + env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  row-gap: 8px;
  gap: 16px;
}

/* Nothing in here should ever be able to force the page itself to scroll
   sideways — the masthead is sticky, so unlike an ordinary too-wide element
   further down the page, this one is on screen at every scroll position.
   `flex-wrap` on both this row and `nav` below is the actual guarantee;
   hiding the wordmark under 480px (kept for screen readers, not `display:
   none`) just makes wrapping the exception instead of the rule on a phone.
*/
@media (max-width: 480px) {
  .brand-text {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand svg { display: block; }

.version-tag {
  font-family: var(--font-figure);
  font-size: 11px;
  color: var(--ink-2);
  opacity: 0.7;
}

.masthead nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

/* Marks every instance that hasn't set CAR_PRICE_TRENDS_PROD — see
   config.IS_PROD. A flat, saturated orange rather than --warning (which is
   tuned to read as a status colour among charts, not to shout "not prod"
   over the header's own blur/saturate backdrop-filter) — this needs to win
   against that, not blend with it. Fixed across both themes on purpose, so
   it needs no dark-mode variant of its own.
*/
.env-dev .masthead {
  background: color-mix(in srgb, #ff7a1a 45%, var(--page) 55%);
  border-bottom: 3px solid #ff7a1a;
  box-shadow: 0 2px 14px -4px rgba(255, 122, 26, 0.55);
}
.dev-badge {
  font-family: var(--font-figure);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #3a1600;
  background: #ff7a1a;
  border: 1px solid rgba(58, 22, 0, 0.35);
  padding: 3px 9px;
  border-radius: 999px;
}

.tabs { display: flex; align-items: center; gap: 14px; margin-right: 8px; }

.tab-link {
  /* More vertical padding than the text alone needs, closer to a real
     touch target's height — added here rather than widened horizontally,
     which would cost the one thing the masthead has least of on a phone. */
  padding: 10px 4px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-muted);
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.tab-link:hover { color: var(--ink); text-decoration: none; }
.tab-link[aria-current="true"] {
  color: var(--ink);
  border-bottom-color: var(--series-1);
}

/* ---------------------------------------------------------------- buttons */

[hidden] { display: none !important; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, transform .14s ease;
}
.btn:hover { background: var(--surface-sunk); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--series-1);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover { background: color-mix(in srgb, var(--series-1) 84%, #000); }

.btn-danger { color: var(--critical); }
.btn-danger:hover { background: color-mix(in srgb, var(--critical) 10%, var(--surface)); }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

.icon-btn {
  width: 38px; height: 38px;
  padding: 0;
  justify-content: center;
}

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  /* Lets a full-bleed cover image sit flush with the card's own rounded
     corners rather than overhanging them. Nothing today relies on a card's
     content overflowing its box — the one element that must escape it, the
     hover tooltip, is `position: fixed` and mounted on <body>, so this
     doesn't touch it. */
  overflow: hidden;
}

/* A themed replacement for window.confirm() -- see static/app.js. <dialog>'s
   own centring (`position: fixed` + auto margins, browser default) is kept;
   only its box and the ::backdrop are restyled to match the app. */
.confirm-dialog {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  max-width: min(420px, calc(100vw - 32px));
}
.confirm-dialog::backdrop { background: rgba(0, 0, 0, .45); }
.confirm-dialog p { margin: 0 0 18px; line-height: 1.5; }

/* A whole card that is itself a link (the dashboard grid) gets its own
   affordance instead of relying on the browser default, which is otherwise
   invisible against a card's own border. */
a.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

.card-pad { padding: 22px 24px; }

/* ------------------------------------------------------------- card cover */

.card-cover {
  position: relative;
  background: var(--surface-sunk);
  border-radius: var(--radius-sm);
}
/* The grid-card variant: full width, top corners only (the card itself
   rounds and clips it), sitting flush above the padded content. */
.card-cover-cover {
  aspect-ratio: 4 / 3;
  border-radius: 0;
  border-bottom: 1px solid var(--border);
}
/* A small fixed-size variant for a page header, which has no card box of its
   own to clip or border it. */
.card-cover-thumb {
  width: 84px;
  height: 84px;
  flex: none;
  border: 1px solid var(--border);
}



.card-cover-placeholder {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 42%;
  height: 42%;
  color: var(--ink-muted);
  opacity: .55;
}

.card-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Sits over the placeholder while it loads and while it is showing; JS
     hides it on error, which is the only way the placeholder becomes visible
     again once an image has been requested. */
  background: var(--surface-sunk);
}
.card-cover img.img-broken { display: none; }

.sold-banner {
  position: absolute;
  top: 14px;
  left: -8px;
  z-index: 1;
  padding: 4px 32px;
  background: var(--critical);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  transform: rotate(-8deg);
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}

.card-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 18px 24px 4px;
}
.card-head h2 { flex: none; }
.card-sub {
  color: var(--ink-2);
  font-size: 0.83rem;
  margin-left: auto;
  text-align: right;
}

/* ---------------------------------------------------------------- grid */

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }

/* The dashboard's own tracker cards — scoped separately from .card-pad's
   other uses (forms, stats tiles, the history page…) so a phone-width
   compaction here doesn't reach them.

   A grid rather than stacked rows so the gauge column's height can be
   reassigned independently of its row: on a phone, the price/chips/tags/
   status stack moves into the gauge's own column instead of running under
   it, filling the vertical space the dial's empty column left unused rather
   than adding a second, taller column of its own. */
.tracker-card-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px 16px;
  grid-template-areas:
    "title  title"
    "price  gauge"
    "chips  chips"
    "tags   tags"
    "status status";
}
.tracker-card-title  { grid-area: title; margin: 0; }
.tracker-card-price  { grid-area: price; align-self: end; }
.tracker-card-gauge  { grid-area: gauge; align-self: end; }
.tracker-card-chips  { grid-area: chips; }
.tracker-card-tags   { grid-area: tags; }
.tracker-card-status { grid-area: status; font-size: .8rem; margin: 0; }

@media (max-width: 480px) {
  /* 330px's minmax already forces one column below ~700px, so the win on a
     phone isn't more columns of cards — it's a shorter card. A smaller
     gauge, tighter padding, and chips paired with tags on one row instead of
     two cut a good part of what one card claimed on screen. The photo is
     deliberately left at its full 4/3, like the Saved cards: it used to be
     cropped to 2/1 here to save more height, and looked worse than the space
     was worth. */
  .tracker-grid { gap: 10px; }
  .tracker-card .card-pad { padding: 12px 16px; }
  .tracker-card .card-gauge .gauge { width: 76px; }
  .tracker-card-body {
    gap: 6px 12px;
    grid-template-areas:
      "title  title"
      "price  gauge"
      "chips  tags"
      "status status";
  }
  .tracker-card-gauge { align-self: start; justify-self: end; }
}

@media (max-width: 860px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}

.stack { display: grid; gap: 18px; }

/* ------------------------------------------------------------ search tab */

.search-filters { max-width: 480px; margin: 0 auto; }

/* A real <fieldset>/<legend> per group, for a screen reader landmark between
   "Car", "Price, year & mileage", "Specs" and "Where & how" -- display:contents
   drops the fieldset's own box so its .field children still land directly in
   the parent grid below, exactly as if the grouping markup wasn't there. */
.field-group { border: none; margin: 0; padding: 0; display: contents; }
.field-group > legend {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-2);
  padding: 0;
  margin: 20px 0 2px;
}
.field-group:first-of-type > legend { margin-top: 0; }

@media (min-width: 640px) {
  .search-filters { max-width: 760px; }
  .search-filters .card-pad:first-of-type {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 16px;
  }
  .search-filters .card-pad:first-of-type > h2,
  .search-filters .card-pad:first-of-type > .field-group > legend,
  .search-filters .card-pad:first-of-type > .field-group > .field-row,
  .search-filters .card-pad:first-of-type > .field-group > .field-span {
    grid-column: 1 / -1;
  }
  .search-filters .check-grid { grid-template-columns: 1fr 1fr; }
}

/* The search screen's own Sources list is one line per source (no <small>
   description, unlike the tracker edit form's), so it can sit tighter than
   the shared .check default that has to leave room for one. */
.search-filters .check { align-items: center; padding: 7px 10px; }

.back-link {
  font-size: 0.85rem;
  color: var(--ink-muted);
}
.back-link:hover { text-decoration: underline; }

/* Two columns at most: a third made each card too small to read. Sizing the
   minimum to half the row means a wide row never fits a third column, while a
   row under two cards' width falls back to one. Used by search results and a
   tracker's own listings. */
.search-results-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(max(320px, calc((100% - 12px) / 2)), 1fr));
  gap: 12px;
}

.result-card {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius, 10px);
  background: var(--surface);
  border: 1px solid var(--border);
  color: inherit;
}
.result-card-photo {
  /* About 40% of the card, so a wide two-column card gets a proper photo and a
     narrow one keeps room for its text. */
  width: clamp(110px, 38%, 200px); height: auto; aspect-ratio: 4 / 3;
  align-self: flex-start;
  object-fit: cover;
  border-radius: 8px;
  background: var(--surface-sunk);
  flex: none;
}
/* On a phone the photo is what you scan, so it goes on top at full width. */
@media (max-width: 560px) {
  .result-card { flex-direction: column; gap: 10px; }
  .result-card-photo { width: 100%; aspect-ratio: 16 / 10; }
}
.result-card-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.result-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.result-card-price { font-weight: 600; white-space: nowrap; }
.result-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.85rem;
  color: var(--ink-2);
}
.result-card-body > .chip { align-self: flex-start; }

.favorite-form { display: contents; }
.favorite-btn {
  border: none;
  background: none;
  padding: 4px;
  margin: 0;
  cursor: pointer;
  color: var(--ink-muted);
  line-height: 0;
  flex: none;
}
.favorite-btn:hover { color: var(--critical); }
.favorite-btn.is-favorited { color: var(--critical); }
/* The boxed variant sits among other .btn buttons in a page header. */
.favorite-btn.btn { border: 1px solid var(--border-strong); background: var(--surface); padding: 0; line-height: normal; }
.favorite-btn.btn:hover { background: var(--surface-sunk); }
/* A live share link, marked the way a saved car's heart is. */
.share-btn.is-shared { background: var(--series-1); border-color: transparent; color: #fff; }
.share-btn.is-shared:hover { background: color-mix(in srgb, var(--series-1) 84%, #000); }

.chip-sold { color: var(--critical); border-color: var(--critical); }

/* ---------------------------------------------------------------- hero */

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 28px 40px;
  padding: 26px 26px 24px;
}

.hero-figure {
  font-family: var(--font-figure);
  font-size: 3.1rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  /* Proportional figures deliberately: tabular-nums makes a big number loose. */
}

.hero-label {
  color: var(--ink-2);
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.listing-photo {
  position: relative;
  flex: 0 0 360px;
  height: 240px;
}
.listing-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain; /* whole photo: a portrait one is not cropped */
  border-radius: 12px;
  background: var(--surface-sunk);
}
@media (max-width: 700px) {
  .listing-photo { flex: 1 1 100%; height: auto; aspect-ratio: 4 / 3; }
}

/* Single-listing chart: no end label, so it needs far less side margin than
   `.chart-wide-margin`; capped so a 640-wide viewBox doesn't balloon on desktop. */
.chart-compact { display: block; max-width: 760px; margin: 0 auto; }
@media (max-width: 640px) {
  /* (A side padding on .chart-compact used to sit here, a leftover of the same HTML-label
     days: the chart is SVG text now, and it only narrowed the plot on a phone.) */
}

.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px 24px;
  margin: 0;
}
.spec-grid dt { color: var(--ink-2); font-size: .8rem; font-weight: 600; }
.spec-grid dd { margin: 2px 0 0; font-weight: 500; }
.compare-card .chart-scatter { display: block; max-width: 560px; margin: 0 auto; }
.compare-lines { display: grid; gap: 6px; }
.chip-drop { color: var(--good-text); border-color: currentColor; }
.swatch-me {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  background: var(--ink); margin-right: 4px; vertical-align: -1px;
}

.listing-remove { margin: 22px 0 8px; text-align: center; }
.listing-refresh { margin: 8px 0 22px; text-align: center; }

.hero-side { display: flex; gap: 34px; flex-wrap: wrap; }
.hero-gauge { flex: none; align-self: center; }
.hero-lamps { flex: none; align-self: center; margin-left: auto; }

@media (max-width: 700px) {
  .hero-lamps { margin-left: 0; }
}

/* ---------------------------------------------------------------- stats */

.stat-label {
  color: var(--ink-2);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}
.stat-value {
  font-family: var(--font-figure);
  font-size: 1.32rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.stat-note { color: var(--ink-muted); font-size: 0.78rem; }

/* Each tile is its own bordered block with real air between them — not a
   hairline-separated spreadsheet grid, which is the single most annual-report
   thing on this page below the fold. */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.tile-gauge { flex: none; }

/* delta — direction is carried by an arrow glyph and a sign, never colour alone */
.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 0.86rem; font-weight: 500; }
.delta-up   { color: var(--critical); }
.delta-down { color: var(--good-text); }
.delta-flat { color: var(--ink-muted); }
.delta-na   { color: var(--ink-muted); font-size: 0.8rem; }

/* ---------------------------------------------------------------- charts */

.chart-card { overflow: hidden; }
.chart-body { padding: 6px 18px 12px; position: relative; }

.chart {
  width: 100%; height: auto; display: block; overflow: visible;
  font-family: var(--font-figure);
}

/* SVG text scales with the whole image -- fine for the plot itself, but it
   means an 11px tick label shrinks well below readable once the chart is
   narrower than its own viewBox (a phone). static/app.js overlays each
   `<text>` with an absolutely-positioned, non-scaling HTML label in
   `.chart-label-layer` instead and hides the SVG original (still present
   for the `role="img"` case where JS never runs). Font sizes below are
   deliberately identical to the `.chart .X` rules they mirror, so a chart
   looks the same as it always did at native (desktop) width and only stops
   shrinking past that on a phone. */
.chart-label-layer { position: absolute; left: 0; top: 0; pointer-events: none; }
.chart-label {
  position: absolute; white-space: nowrap; font-family: var(--font-figure);
  font-variant-numeric: tabular-nums;
}
.chart-label.tick { color: var(--ink-muted); font-size: 11px; }
.chart-label.axis-title {
  color: var(--ink-2); font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
}
.chart-label.bar-label { color: var(--ink-2); font-size: 11px; font-weight: 600; }
.chart-label.end-label {
  color: var(--ink); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.chart-label.tick-projected { color: var(--ink-2); font-size: 10.5px; font-weight: 600; }

.chart .grid   { stroke: var(--grid); stroke-width: 1; }
.chart .axis   { stroke: var(--axis); stroke-width: 1; }
.chart .tick   { fill: var(--ink-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .axis-title { fill: var(--ink-2); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; }

.chart .band { stroke: none; }
.chart .band-outer { fill: var(--series-1); opacity: .09; }
.chart .band-inner { fill: var(--series-1); opacity: .17; }

.chart .series-line {
  fill: none;
  stroke: var(--series-1);
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart .end-dot,
.chart .hover-dot {
  fill: var(--series-1);
  stroke: var(--surface);
  stroke-width: 2;      /* the surface ring */
}

.chart .end-label {
  fill: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chart .bar-label { fill: var(--ink-2); font-size: 11px; font-weight: 600; }

.chart .bar { fill: var(--series-1); }

/* Sub-model price bands. One hue throughout: the rows are categories being
   compared on one scale, not separate series, so colouring them differently
   would encode a distinction that isn't there. */
.chart .band-box { fill: var(--series-1); opacity: .30; }
/* A band too small for percentiles shows its full range instead, at a weight
   that reads as "indicative" rather than measured. */
.chart .band-box-thin { opacity: .13; }
.chart .band-whisker { stroke: var(--series-1); stroke-width: 1; opacity: .45; }
.chart .band-median { stroke: var(--series-1); stroke-width: 2.5; stroke-linecap: round; }
.chart .band-count {
  fill: var(--ink-muted);
  font-size: 11px;
  font-weight: 500;
}
.chart .dot { fill: var(--series-1); fill-opacity: .8; stroke: var(--surface); stroke-width: 2; }
.chart .fit-line { stroke: var(--series-2); stroke-width: 2; stroke-dasharray: none; opacity: .85; }

/* A projected continuation, not measured data — series-2 again (as .fit-line
   already uses it) plus a dash, so it can never be mistaken for the real
   line it extends. */
.chart .series-line-projected {
  fill: none;
  stroke: var(--series-2);
  stroke-width: 2;
  stroke-dasharray: 5 5;
  stroke-linecap: round;
  opacity: .8;
}
.chart .scatter-dot { stroke: none; }
.chart .scatter-dot-me { fill: var(--ink); fill-opacity: 1; stroke: var(--surface); stroke-width: 2; }
.chart .change-dot { fill: var(--surface); stroke: var(--series-1); stroke-width: 2; }  /* smaller, and no surface-coloured ring — it reads as a black border in dark mode */
.chart .dot-projected { fill: var(--series-2); stroke: var(--surface); stroke-width: 2; }
.chart .tick-projected { fill: var(--ink-2); font-size: 10.5px; font-weight: 600; }

.chart .crosshair { stroke: var(--axis); stroke-width: 1; pointer-events: none; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hit:hover ~ .hit { }

.chart-empty {
  display: grid;
  place-items: center;
  padding: 40px 24px;
  color: var(--ink-muted);
  font-size: 0.9rem;
  text-align: center;
}
.chart-empty p { margin: 0; max-width: 34ch; }

.sparkline { width: 132px; height: 34px; overflow: visible; }
.spark-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark-dot  { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }

/* legend / key — always present where a chart shows more than one thing */
.key { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 0 24px 16px; }
.key-item { display: inline-flex; align-items: center; gap: 7px; font-size: 0.8rem; color: var(--ink-2); }
.swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.swatch-line { width: 16px; height: 2px; border-radius: 2px; background: var(--series-1); }
.swatch-inner { background: var(--series-1); opacity: .17; }
.swatch-outer { background: var(--series-1); opacity: .09; }
.swatch-fit { width: 16px; height: 2px; border-radius: 2px; background: var(--series-2); }
.swatch-line-thin { width: 16px; height: 1px; background: var(--series-1); opacity: .45; flex: none; }
.swatch-tick { width: 2.5px; height: 14px; border-radius: 2px; background: var(--series-1); flex: none; }
/* One-listing scatter dot, keyed alongside the best-fit line on the two
   scatter charts — same swatch color, drawn as a dot rather than a bar. */
.swatch-dot { opacity: .8; border-radius: 50%; }

/* Vertical rhythm between this page's top-level sections — was an identical
   `style="margin-bottom:18px"` repeated on every one. */
.section-gap { margin-bottom: 18px; }

/* tooltip */
.tooltip {
  position: fixed;
  z-index: 60;
  min-width: 150px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.82rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .1s ease, transform .1s ease;
}
.tooltip.on { opacity: 1; transform: translateY(0); }
.tooltip-title { font-weight: 600; margin-bottom: 6px; }
.tooltip-row { display: flex; justify-content: space-between; gap: 18px; color: var(--ink-2); }
.tooltip-row b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }

/* the table-view twin every chart carries */
.table-view { border-top: 1px solid var(--border); }
.table-view > summary {
  padding: 10px 24px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--ink-2);
  list-style: none;
}
.table-view > summary::-webkit-details-marker { display: none; }
.table-view > summary::before { content: "▸ "; }
.table-view[open] > summary::before { content: "▾ "; }
.table-view > summary:hover { color: var(--ink); }
.table-scroll { max-height: 320px; overflow: auto; }

/* ---------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  text-align: left;
  font-weight: 500;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 9px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-sunk); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

th.sortable {
  cursor: pointer;
  user-select: none;
}
th.sortable:hover { color: var(--ink); }
th.sortable .sort-arrow {
  display: inline-block;
  width: 10px;
  opacity: 0.35;
}
th.sortable[aria-sort="ascending"] .sort-arrow,
th.sortable[aria-sort="descending"] .sort-arrow {
  opacity: 1;
  color: var(--series-1);
}
th.sortable[aria-sort="descending"] .sort-arrow { transform: scaleY(-1); }

/* ---------------------------------------------------------------- chips */

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--ink-2);
  white-space: nowrap;
}
/* No text-transform here: source names carry their own casing (PistonHeads,
   eBay), and `capitalize` would render the latter as "EBay". */

.status-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.s-ok       { background: var(--good); }
.s-partial  { background: var(--warning); }
.s-failed   { background: var(--critical); }
.s-running  { background: var(--series-1); animation: pulse 1.4s ease-in-out infinite; }
.s-empty    { background: var(--ink-muted); }
.s-blocked, .s-stale { background: var(--serious); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

/* ------------------------------------------------------ pull to refresh */

/* Only ever shown in standalone (Home Screen) launches — see app.js. Sits
   above the sticky masthead (z-index 20) since it has to be visible the
   moment a pull starts, before any scrolling has happened. */
.ptr-indicator {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top, 0px));
  left: 50%;
  width: 36px;
  height: 36px;
  margin-left: -18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  z-index: 30;
  transform: translateY(-70px);
  transition: transform 0.25s ease;
  pointer-events: none;
}
.ptr-indicator.dragging { transition: none; }
.ptr-indicator .ptr-arrow { transition: transform 0.1s linear; }
.ptr-indicator.ready .ptr-arrow { transform: rotate(180deg); }
.ptr-indicator.refreshing .ptr-arrow {
  animation: ptr-spin 0.7s linear infinite;
  transform: none;
}
@keyframes ptr-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ptr-indicator.refreshing .ptr-arrow { animation: none; }
}

/* ---------------------------------------------------------------- filter row */

/* One filter row above everything it scopes — never per-chart controls. */
.filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 18px;
}

@media (max-width: 640px) {
  /* Plain flex-wrap lets a label land at the ragged end of the previous
     filter's segmented control instead of leading its own — "Gearbox" was
     landing flush against "Unknown" with no separation once several filters
     were active. Forcing each label onto a full-width line pushes its own
     control onto the row below it instead. */
  .filter-row .stat-label { flex: 1 0 100%; }
}

.segmented {
  display: inline-flex;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}
.segmented a {
  padding: 4px 11px;
  border-radius: 7px;
  font-size: 0.82rem;
  color: var(--ink-2);
}
.segmented-wrap { flex-wrap: wrap; }
.segmented a:hover { text-decoration: none; color: var(--ink); }
.segmented a[aria-current="true"] {
  background: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .07);
}

/* ---------------------------------------------------------------- forms */

/* align-content defaults to stretch on a grid container (unlike flexbox,
   where normal means start) — without pinning it, a .field-row pairing a
   field that has a hint line with one that doesn't stretches the shorter
   field's own height to match, and that extra height lands on its input
   (align-self also defaults to stretch), not as trailing whitespace. That's
   what made an unrelated field's select visibly taller than its neighbour. */
.field { display: grid; align-content: start; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 0.83rem; font-weight: 500; color: var(--ink-2); }
.field .hint { font-size: 0.78rem; color: var(--ink-muted); }

input[type="text"], input[type="number"], input[type="url"], input[type="password"], textarea, select {
  width: 100%;
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  /* A <select>'s UA default line-height runs taller than a text input's even
     once appearance:none strips its native chrome, which is what actually
     throws off row alignment next to one -- same padding/border, taller
     box. Pinning it here is what makes the two match exactly. */
  line-height: 1.4;
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--series-1);
  outline-offset: -1px;
  border-color: transparent;
}

/* The browser's own select chrome (native arrow, and — critically — its own
   intrinsic box metrics) differs from a text input's just enough to read as
   a different control and to throw off vertical alignment next to one in
   the same field-row. appearance:none makes it share the exact same box
   model as every input around it; the drawn-on chevron replaces the native
   arrow so it still reads as a dropdown. */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
}

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.check-grid { display: grid; gap: 8px; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.check:hover { background: var(--surface-sunk); }
.check input { margin-top: 3px; flex: none; }
.check-text { font-size: 0.86rem; }
.check-text small { display: block; color: var(--ink-muted); font-size: 0.76rem; }

/* ---------------------------------------------------------------- notices */

.notice {
  display: flex;
  gap: 11px;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.87rem;
  margin-bottom: 18px;
  align-items: flex-start;
}
.notice-icon { flex: none; margin-top: 1px; }
.notice-warn     { border-left: 3px solid var(--warning); }
/* --series-2 (pen blue), not --series-1: the dial's ochre now sits close
   enough to --warning's gold that an info notice would read as a second,
   weaker warning rather than a distinct status. */
.notice-info     { border-left: 3px solid var(--series-2); }
.notice-good     { border-left: 3px solid var(--good); }
.notice-critical { border-left: 3px solid var(--critical); }
.notice p { margin: 0; }
.notice p + p { margin-top: 6px; color: var(--ink-2); }

/* ---------------------------------------------------------------- misc */

.muted { color: var(--ink-muted); }
.dim   { color: var(--ink-2); }
.mono  { font-family: var(--font-figure); font-variant-numeric: tabular-nums; }
.hand  { font-family: var(--font-hand); color: var(--series-2); font-weight: 600; }
.right { margin-left: auto; }
.row   { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sep   { color: var(--border-strong); }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.page-head .right { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb { font-size: 0.82rem; color: var(--ink-muted); margin-bottom: 4px; }

/* ---------------------------------------------------------- tracker banner */

/* Full width of the page's own content column (not edge-to-edge of the
   viewport) — the same width as every chart and card below it. Only the
   image and the scrim are absolutely positioned; the text content is normal
   flow, so the banner's height is whatever the title and chips need rather
   than a fixed crop that could clip a long name or a full row of tags. */
.tracker-banner {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-sunk);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.tracker-banner-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}
/* A fixed dark gradient regardless of the site's own theme: a hotlinked
   photo's brightness is unpredictable, and this is the only way to
   guarantee the overlaid text stays readable against whatever it is. */
.tracker-banner-scrim {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, .82) 0%,
    rgba(0, 0, 0, .5) 45%,
    rgba(0, 0, 0, .05) 100%
  );
}
.tracker-banner-content {
  position: relative;
  z-index: 2;
  padding: 96px 26px 22px;
  color: #fff;
}
.tracker-banner-content h1 { color: #fff; }
.tracker-banner-content .breadcrumb { color: rgba(255, 255, 255, .75); }
.tracker-banner-content .breadcrumb a { color: rgba(255, 255, 255, .92); }
/* Chips get their own glass treatment rather than the ordinary .chip
   surface, which is a light neutral panel that would sit oddly on a photo. */
.tracker-banner-content .chip {
  background: rgba(255, 255, 255, .14);
  border-color: rgba(255, 255, 255, .32);
  color: #fff;
  backdrop-filter: blur(6px);
}
.tracker-banner-content .chip-variant:hover,
.tracker-banner-content a.chip-tag:hover {
  background: rgba(255, 255, 255, .24);
}

.tracker-banner-actions {
  position: absolute;
  top: 14px;
  right: 14px;
  left: 14px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.btn-cover-icon {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(0, 0, 0, .38);
  backdrop-filter: blur(6px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-cover-icon:hover { background: rgba(0, 0, 0, .55); }
.btn-cover-icon:active { transform: translateY(1px); }

@media (max-width: 640px) {
  /* Less top padding on narrow viewports: the generous hero feel costs more
     scroll than it is worth once the title has already wrapped to two lines. */
  .tracker-banner-content { padding: 56px 18px 18px; }

  /* (Charts used to get 84px/92px of side padding here, from when their labels were HTML.
     They are SVG text now and scale with the chart, so that only squeezed the plot to a
     third of the card. Phones get their own narrower drawing instead: .chart-phone.) */
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 14px;
  padding: 72px 24px;
  text-align: center;
}
.empty-state p { margin: 0; color: var(--ink-2); max-width: 46ch; }

.thumb {
  width: 54px; height: 40px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--surface-sunk);
  flex: none;
}

.listing-title { font-weight: 500; }
.listing-meta { font-size: 0.78rem; color: var(--ink-muted); }

.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;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* ------------------------------------------------- card footers & caveats */

/* Where a card admits what it cannot tell you. Sunk rather than bordered, so
   it reads as part of the card it qualifies rather than a second card. */
.card-foot {
  padding: 14px 24px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-sunk);
  border-radius: 0 0 var(--radius) var(--radius);
}
.card-body { padding: 4px 24px 20px; }

.caveats { margin: 0; padding-left: 18px; display: grid; gap: 7px; }
.caveats li { font-size: 0.83rem; color: var(--ink-2); line-height: 1.5; }

/* The unclassified row in a breakdown: present, findable, and visibly not one
   of the answers. */
.row-muted td { color: var(--ink-muted); }
.row-muted td a { color: var(--ink-2); }

/* ------------------------------------------------------------ rule editor */

.rules { display: grid; gap: 8px; }

.rule-head,
.rule-row {
  display: grid;
  grid-template-columns: 1.1fr 0.6fr 0.6fr 1.2fr 1.6fr auto;
  gap: 10px;
  align-items: center;
}

.rule-head {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: .02em;
  padding: 0 2px 2px;
}

.rule-row input { margin: 0; }

.rule-actions { display: flex; gap: 4px; flex: none; }

/* The source link and local match count under an AI-suggested rule. Spans the
   whole grid row, so the inputs above stay aligned with the header. */
.rule-source {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  align-items: baseline;
  margin-top: -4px;
  font-size: 0.8rem;
}
.rule-source a { color: var(--series-1); }

/* Shared small circular button for move-up/move-down/remove. Only remove
   gets the critical-red hover — up/down aren't destructive. */
.rule-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: none;
  padding: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  cursor: pointer;
}
.rule-clear:hover { color: var(--ink); border-color: var(--border-strong); }
.rule-clear[data-clear-rule]:hover { color: var(--critical); border-color: var(--critical); }

/* Below the two-column breakpoint the grid collapses; each field then needs
   its own label, which the header row can no longer provide. */
@media (max-width: 820px) {
  .rule-head { display: none; }
  .rule-row {
    grid-template-columns: 1fr 1fr;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-sunk);
  }
  .rule-row input[name="rule_name"],
  .rule-row input[name="rule_pattern"],
  .rule-row input[name="rule_note"] { grid-column: 1 / -1; }
  .rule-actions { grid-column: 1 / -1; justify-self: end; }
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* A version chip is a link to that version's own trend, so it needs to look
   clickable without becoming a second button. */
.chip-variant { border-color: var(--border-strong); color: var(--ink); font-weight: 500; }
.chip-variant:hover { background: var(--surface-sunk); text-decoration: none; }

/* A tag chip carries a small accent dot so it reads as "user-applied label"
   rather than a search criterion (a plain .chip, no dot) at a glance. Only
   the <a> form (the filter row, the detail page) gets the hover/pointer
   affordance — the <span> form used inside a dashboard card is not itself
   clickable, since the whole card already is. */
.chip-tag { gap: 6px; }
.chip-tag::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--series-1);
  flex: none;
}
a.chip-tag:hover { background: var(--surface-sunk); border-color: var(--border-strong); text-decoration: none; }
a.chip-tag[aria-current="true"] {
  background: var(--surface-sunk);
  border-color: var(--border-strong);
  color: var(--ink);
  font-weight: 500;
}

/* -------------------------------------------------------------------- dial */

/* A value's position within its own recent range, styled as a rev counter:
   fixed tick marks on a rim, a needle pointing at today. Deliberately draws
   no number of its own (see charts.gauge) — the real figure stays HTML text
   beside it, so the dial only ever adds one thing: where today sits. */
.gauge { overflow: visible; display: block; }
.gauge-track { fill: none; stroke: var(--border-strong); stroke-width: 14; stroke-linecap: round; }
.gauge-redline { fill: none; stroke: var(--critical); stroke-opacity: .3; stroke-width: 14; stroke-linecap: round; }
.gauge-tick { stroke: var(--ink-muted); stroke-opacity: .55; stroke-width: 2; }
.gauge-tick-major { stroke-opacity: 1; stroke-width: 3; }
.gauge-hub { fill: var(--series-1); }
.gauge-needle {
  stroke: var(--series-1);
  stroke-width: 3.5;
  stroke-linecap: round;
  /* Swept once per page load, like a real cluster's self-test: out to the
     far end of the dial, then back down to the actual value — never on
     hover or scroll. The blanket prefers-reduced-motion rule at the bottom
     of this file collapses the duration to near-zero, which lands the needle
     at its target instantly rather than swinging or freezing mid-sweep. */
  animation: gauge-needle-sweep 1.6s cubic-bezier(.16, .84, .3, 1) .15s both;
}
@keyframes gauge-needle-sweep {
  0%   { transform: rotate(-135deg); animation-timing-function: cubic-bezier(.4, 0, .7, 1); }
  55%  { transform: rotate(135deg); }
  100% { transform: rotate(var(--target-rot)); }
}
.gauge-scale { fill: var(--ink-muted); font-size: 10px; font-variant-numeric: tabular-nums; }

/* All three carry visible lo/hi labels (see charts.gauge), so the smaller
   two are sized a little larger than their old semicircle equivalents —
   the full circle now spends part of its height on the bottom gap those
   labels sit in, not just on the dial itself. */
.hero-gauge .gauge { width: 128px; }
.card-gauge .gauge { width: 104px; }
.tile-gauge .gauge { width: 96px; }

/* ------------------------------------------------------------------ lamps */

/* The tracker's own sources as fixed-position tell-tales — the dashboard
   status dot's vocabulary (ok/blocked/stale/failed), given the same shape a
   real dashboard already uses for exactly this: a small lit or unlit bulb. */
.lamp-row { display: flex; gap: 5px; align-items: center; }
.lamp {
  width: 25px; height: 17px;
  border-radius: 3px;
  display: grid; place-items: center;
  font-family: var(--font-figure);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  background: transparent;
  color: var(--ink-muted);
  border: 1px solid var(--border);
}
.lamp.lit-ok {
  background: color-mix(in srgb, var(--good) 16%, transparent);
  color: var(--good-text);
  border-color: color-mix(in srgb, var(--good) 45%, transparent);
}
.lamp.lit-warn {
  background: color-mix(in srgb, var(--series-1) 18%, transparent);
  color: var(--series-1);
  border-color: color-mix(in srgb, var(--series-1) 45%, transparent);
}

/* ---------------------------------------------------------- taped photo */

/* The dashboard grid only (see macros.card_cover) — a photo tucked into the
   card's own padding, tilted, with a strip of tape. `.card` keeps its normal
   overflow:hidden; the tilt stays inside this slot's padding on purpose so
   nothing needs to escape the card's own clip. */
.card-photo-slot { padding: 16px 18px 0; }
/* A Polaroid's frame is real paper — white in daylight or in a dark room —
   not a themed surface, the same reasoning the tracker banner's scrim uses
   for its own fixed colours. Themed here would put a dark card-coloured
   border around the photo in dark mode, reading as a rendering bug rather
   than a mount. */
.polaroid {
  position: relative;
  margin: 0;
  transform: rotate(-1.1deg);
  background: #fcfcf8;
  padding: 7px 7px 26px;
  border-radius: 3px;
  border: 1px solid rgba(27, 30, 41, 0.12);
  box-shadow: 0 1px 2px rgba(27, 30, 41, .05), 0 8px 24px -12px rgba(27, 30, 41, .18);
}
/* A row of identically-tilted photos reads as a template, not a pile of
   prints — cycled by grid position rather than at random so the layout is
   stable across reloads (no hydration mismatch, nothing for a screenshot
   diff to flag). Small angles only: `.card-photo-slot`'s padding is sized
   for the base rotation, and each of these stays close enough to it that
   the frame and tape still land inside it rather than brushing the card's
   own clip. */
.grid-cards > .card:nth-child(5n+1) .polaroid { transform: rotate(-1.6deg); }
.grid-cards > .card:nth-child(5n+2) .polaroid { transform: rotate(0.9deg); }
.grid-cards > .card:nth-child(5n+3) .polaroid { transform: rotate(-0.4deg); }
.grid-cards > .card:nth-child(5n+4) .polaroid { transform: rotate(1.7deg); }
.grid-cards > .card:nth-child(5n)   .polaroid { transform: rotate(-1deg); }
.polaroid .card-cover-cover {
  border-radius: 2px;
  border-bottom: none;
}
/* Two strips pinning the top corners, rather than one centred on the top
   edge — mirrored angles so they read as pressed down from each side. */
.polaroid::before,
.polaroid::after {
  content: "";
  position: absolute;
  top: -7px;
  width: 34px; height: 15px;
  background: var(--tape);
  border-left: 1px dashed var(--border-strong);
  border-right: 1px dashed var(--border-strong);
}
.polaroid::before { left: -6px; transform: rotate(-40deg); }
.polaroid::after   { right: -6px; transform: rotate(40deg); }

/* ------------------------------------------------------------ annotation */

/* Your own marks — never a number, a label, or a control (see CLAUDE.md's
   reasoning for the whole Glovebox concept). `.hand` alone (defined above,
   near .mono) covers a short mark like a tag-group name; these two carry the
   longer ones. */
.tag-group-title { display: flex; align-items: baseline; gap: 8px; }
.tag-group-title .hand { font-size: 1.3em; }

.hand-note {
  margin: 0;
  padding: 14px 26px 20px;
  border-top: 1px dashed var(--border);
}
.hand-note .hand { font-size: 1.1rem; line-height: 1.3; }

/* Per-source model names -- collapsed by default, most cars need none. */
.source-models { margin-top: 16px; }
.source-models > summary { cursor: pointer; font-size: 0.83rem; font-weight: 500; color: var(--ink-2); }
.source-models > .hint { font-size: 0.78rem; color: var(--ink-muted); margin: 8px 0 12px; }
.source-model-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* A saved car's card (macros.saved_card): the taped photo, then a short
   stack. Reuses .result-card-head/-meta for the title row and facts. */
.saved-card-body { display: flex; flex-direction: column; gap: 8px; }
.saved-card-body h2 { margin: 0; font-size: 1.05rem; }
.saved-card-price { font-size: 1.35rem; font-weight: 600; }

/* Account → API tokens: label and dates on the left, Revoke on the right; the
   info shrinks and wraps first so the button never leaves the card. */
.token-list { list-style: none; margin: 0 0 8px; padding: 0; }
.token-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 0; border-top: 1px solid var(--border);
}
.token-info { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; font-size: 0.86rem; }
.token-row form { flex: none; }

.add-by-url { display: grid; gap: 6px; margin-bottom: 18px; max-width: 720px; }
.add-by-url label { font-size: 0.83rem; font-weight: 500; color: var(--ink-2); }
.add-by-url .hint { font-size: 0.78rem; color: var(--ink-muted); }
.add-by-url-row { display: flex; gap: 10px; }
.add-by-url-row input { flex: 1; min-width: 0; }

/* Every photo from the advert: one swipeable row, never wider than the page. */
.photo-strip {
  flex: 1 1 100%; display: flex; gap: 6px; overflow-x: auto;
  scroll-snap-type: x proximity; padding-bottom: 4px;
}
.photo-strip a { flex: 0 0 auto; scroll-snap-align: start; }
.photo-strip img { height: 64px; width: auto; border-radius: 6px; display: block; }

/* MOT history: one expandable row per test, so nothing needs a wide table. */
.mot-summary { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.mot-test { border-top: 1px solid var(--border); padding: 8px 0; }
.mot-test > summary {
  display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; cursor: pointer;
}
.mot-date { font-variant-numeric: tabular-nums; font-weight: 600; }
.mot-result { font-weight: 600; }
.mot-failed { color: var(--critical); }
.mot-miles, .mot-count { color: var(--muted); font-variant-numeric: tabular-nums; }
.mot-defect { margin: 4px 0; overflow-wrap: anywhere; }
.mot-older > summary { cursor: pointer; padding: 10px 0; color: var(--ink-2); }

/* Registration card: the plate, one primary action, status and helpers below. */
.reg-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.reg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.reg-head label { font-weight: 600; }
.reg-row { display: flex; gap: 10px; align-items: stretch; }
.plate-input {
  flex: 1 1 auto; min-width: 0; text-align: center; text-transform: uppercase;
  font: 700 1.5rem/1 var(--font-figure, inherit); letter-spacing: 0.08em;
  padding: 10px 12px; border-radius: 8px; border: 2px solid #1a1a1a;
  background: #f7d51d; color: #1a1a1a;
}
.plate-input::placeholder { color: rgba(26, 26, 26, 0.4); }
.reg-note { margin: 0; color: var(--ink-2); font-size: 0.85rem; }
.reg-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.reg-actions .btn { flex: 1 1 auto; justify-content: center; }

/* Gallery: the thumbnail you pick replaces the large photo. */
.photo-strip a { border-radius: 6px; outline-offset: 2px; opacity: 0.7; }
.photo-strip a[aria-current="true"] { opacity: 1; outline: 2px solid var(--series-1); }
.seen-row { display: flex; flex-wrap: wrap; gap: 2px 12px; align-items: baseline; margin: 8px 0; border-top: 1px solid var(--border); padding-top: 8px; }


/* A car's own history on a real time axis (charts.timeline). */
.chart .tl-s1 { --c: var(--series-1); }
.chart .tl-s2 { --c: var(--series-2); }
.chart .tl-s3 { --c: var(--series-3); }
.chart .tl-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.tl-dot-solid { fill: var(--c); stroke: var(--surface); stroke-width: 2; }
.tl-dot-hollow { fill: var(--surface); stroke: var(--c); stroke-width: 2; }
.tl-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 0 4px 6px; font-size: 0.82rem; color: var(--ink-2); }
.tl-legend .tl-s1 { --c: var(--series-1); } .tl-legend .tl-s2 { --c: var(--series-2); } .tl-legend .tl-s3 { --c: var(--series-3); }
.tl-key { display: inline-flex; align-items: center; gap: 5px; }

/* A count on a control: the sign-up requests waiting on an admin. */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.35em; height: 1.35em; padding: 0 0.4em; border-radius: 999px;
  background: var(--critical); color: #fff; font-size: 0.72rem; font-weight: 700; line-height: 1;
}
.has-badge { position: relative; }
.badge-dot { position: absolute; top: -5px; right: -5px; box-shadow: 0 0 0 2px var(--surface); }
.access-request { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }

/* Usage rows: a name and its figures, wrapping on a phone instead of a table. */
.activity-list { display: grid; }
.activity-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 14px; padding: 8px 0; border-top: 1px solid var(--border); overflow-wrap: anywhere; }
.activity-row:first-child { border-top: 0; }

/* What a gauge means, in words: the needle alone explained nothing. */
.gauge-caption { font-size: 0.68rem; color: var(--ink-muted); text-align: center; line-height: 1.2; margin-top: 2px; max-width: 120px; }
.gauge-scale { font-size: 11px; }
@media (max-width: 640px) {
  .tracker-card .card-gauge .gauge { width: 92px; }
  /* The mini-gauge squeezes its text to a word a line; the figure says it already. */
  .tile-gauge { display: none; }
}

/* Wide charts are drawn twice: a wide one, and a narrower, taller one for a phone, so
   the text stays readable instead of being scaled down with a 960-unit-wide drawing. */
.chart-phone { display: none; }
@media (max-width: 640px) {
  .chart-desktop { display: none; }
  .chart-phone { display: block !important; }  /* the inline display:none is a fallback for a stale stylesheet */
}

/* A wide table as stacked rows on a phone: first cell and any `stack-full` cell take a
   line, the rest sit side by side with their own label. Needs data-label on those cells. */
@media (max-width: 640px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody { display: block; width: 100%; }
  .table-stack tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 14px; padding: 10px 16px; border-top: 1px solid var(--border); }
  .table-stack tbody tr:first-child { border-top: 0; }
  .table-stack td { padding: 0; border: 0; width: auto; text-align: left; }
  .table-stack td.num { text-align: left; }
  .table-stack td.stack-full { flex-basis: 100%; }
  .table-stack td[data-label]::before { content: attr(data-label) " "; color: var(--ink-muted); font-size: 0.78em; }
}

/* A card left alone in its row (an odd one out) takes the full width rather than leaving
   half the row empty. */
.grid-2 > .card:last-child:nth-child(odd) { grid-column: 1 / -1; }

.notice-row { display: block; padding: 14px 18px; color: inherit; text-decoration: none;
  border-bottom: 1px solid var(--border, rgba(128,128,128,.25)); }
.notice-row:last-child { border-bottom: 0; }
.notice-row:hover { background: rgba(128,128,128,.07); }
.notice-title { font-weight: 500; line-height: 1.35; }
.notice-row.unread .notice-title { font-weight: 700; }
.notice-body { margin-top: 2px; font-size: 14px; }
.notice-when { margin-top: 4px; font-size: 12px; }

/* Photo lightbox (static/app.js): a <dialog> filling most of the screen. */
.lightbox {
  border: 0; padding: 0; background: transparent; color: #fff;
  width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; overflow: hidden;
}
.lightbox::backdrop { background: rgba(0, 0, 0, .88); }
.lightbox img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; cursor: zoom-out; }
.lightbox-btn {
  position: absolute; border: 0; border-radius: 999px; width: 44px; height: 44px;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 28px; line-height: 1; cursor: pointer;
}
.lightbox-btn:hover, .lightbox-btn:focus-visible { background: rgba(0, 0, 0, .8); outline: 2px solid #fff; }
.lightbox-close { top: 14px; right: 14px; }
.lightbox-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 14px; top: 50%; transform: translateY(-50%); }
.lightbox-count { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(0, 0, 0, .55); padding: 3px 10px; border-radius: 999px; font-size: 13px; }
.lightbox-single .lightbox-prev, .lightbox-single .lightbox-next, .lightbox-single .lightbox-count { display: none; }
