/* Huracan Watch / Gallardo Watch. Palette roles from the dataviz reference instance:
   light/dark are both selected, never an automatic flip. */
:root {
  color-scheme: light;
  --page:           #f9f9f7;
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --series-1:       #2a78d6;
  --series-2:       #eb6834;
  --series-3:       #1baf7a;
  /* diverging: cheap (blue) <-> dear (red), neutral gray midpoint */
  --div-low:        #184f95;
  --div-low-soft:   #86b6ef;
  --div-mid:        #f0efec;
  --div-high-soft:  #ec835a;
  --div-high:       #d03b3b;
  --good:           #0ca30c;
  --critical:       #d03b3b;
  --shadow:         0 1px 2px rgba(11, 11, 11, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page:           #0d0d0d;
    --surface-1:      #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --axis:           #383835;
    --border:         rgba(255, 255, 255, 0.10);
    --series-1:       #3987e5;
    --series-2:       #d95926;
    --series-3:       #199e70;
    --div-low:        #86b6ef;
    --div-low-soft:   #2a78d6;
    --div-mid:        #383835;
    --div-high-soft:  #ec835a;
    --div-high:       #e66767;
    --shadow:         0 1px 2px rgba(0, 0, 0, 0.4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page:           #0d0d0d;
  --surface-1:      #1a1a19;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --border:         rgba(255, 255, 255, 0.10);
  --series-1:       #3987e5;
  --series-2:       #d95926;
  --series-3:       #199e70;
  --div-low:        #86b6ef;
  --div-low-soft:   #2a78d6;
  --div-mid:        #383835;
  --div-high-soft:  #ec835a;
  --div-high:       #e66767;
  --shadow:         0 1px 2px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1240px; margin: 0 auto; padding: 28px 20px 80px; }

header.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 4px; }
header.top h1 { font-size: 22px; margin: 0; letter-spacing: -0.01em; }
header.top .sub { color: var(--text-secondary); font-size: 13px; }
header.top .spacer { flex: 1; }

button.ghost {
  background: none; border: 1px solid var(--border); color: var(--text-secondary);
  border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 13px; cursor: pointer;
}
button.ghost:hover { background: var(--surface-1); }

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  margin-top: 18px;
}
.card > h2 {
  font-size: 14px; margin: 0 0 2px; letter-spacing: 0.01em;
}
.card > .note { color: var(--text-secondary); font-size: 12.5px; margin: 0 0 14px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 18px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.tile .label { font-size: 12px; color: var(--text-secondary); }
.tile .value { font-size: 26px; font-weight: 620; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .foot { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* estimator */
.estimator { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; }
@media (max-width: 800px) { .estimator { grid-template-columns: 1fr; } }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; }
.field select, .field input {
  width: 100%; padding: 7px 9px; border-radius: 8px; font: inherit; font-size: 14px;
  border: 1px solid var(--border); background: var(--page); color: var(--text-primary);
}
.checks { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.checks label { font-size: 13px; color: var(--text-secondary); display: flex; gap: 6px; align-items: center; }
.result { border-left: 3px solid var(--series-1); padding-left: 16px; align-self: center; }
.result .hero { font-size: 38px; font-weight: 660; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.result .range { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }
.result .caveat { color: var(--text-muted); font-size: 12px; margin-top: 10px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 8px; }
.filters .field { min-width: 130px; }

/* charts */
.charts { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .charts { grid-template-columns: 1fr; } }
svg.chart { width: 100%; height: auto; display: block; overflow: visible; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin-top: 8px; align-items: center; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.legend .ramp { width: 120px; height: 10px; border-radius: 3px; display: inline-block; vertical-align: -1px;
  background: linear-gradient(90deg, var(--div-low), var(--div-mid), var(--div-high)); }

.tooltip {
  position: fixed; z-index: 40; pointer-events: none; opacity: 0;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border); border-radius: 9px; padding: 9px 11px;
  font-size: 12.5px; line-height: 1.45; box-shadow: 0 4px 14px rgba(0,0,0,0.18);
  max-width: 300px; transition: opacity 0.08s;
}
.tooltip .t-title { font-weight: 600; margin-bottom: 3px; }
.tooltip .t-row { color: var(--text-secondary); }
.tooltip .t-delta { font-weight: 600; }

/* tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--grid); }
th { color: var(--text-secondary); font-weight: 560; font-size: 12px; white-space: nowrap; cursor: pointer; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* "LP560-4" must not break at the hyphen on a phone */
td:nth-child(5) { white-space: nowrap; }
tbody tr:hover { background: var(--page); }
td a { color: var(--text-primary); text-decoration: none; border-bottom: 1px solid var(--border); }
td a:hover { border-bottom-color: var(--series-1); }
.table-scroll { overflow-x: auto; }
.pill { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11.5px; border: 1px solid var(--border); color: var(--text-secondary); }
.deal { color: var(--good); font-weight: 620; }
.dear { color: var(--critical); font-weight: 620; }

/* equation */
.eq { font-size: 13.5px; line-height: 1.9; overflow-x: auto; }
.eq code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; }
.coefs { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 4px 22px; margin-top: 12px; }
.coef { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; border-bottom: 1px solid var(--grid); font-size: 13px; }
.coef .n { font-variant-numeric: tabular-nums; }
.warnbox { border-left: 3px solid var(--div-high-soft); padding: 2px 0 2px 14px; margin-top: 14px; color: var(--text-secondary); font-size: 13px; }
.warnbox ul { margin: 6px 0 0; padding-left: 18px; }
footer.foot { color: var(--text-muted); font-size: 12px; margin-top: 26px; text-align: center; }

/* On a phone the eleven-column deal table is a wall of numbers with the
   listing link pushed off-screen, so the secondary columns drop out. */
@media (max-width: 640px) {
  .opt-col { display: none; }
  th, td { padding: 8px 6px; }
  .wrap { padding: 20px 12px 60px; }
  .result { border-left: none; border-top: 3px solid var(--series-1); padding: 14px 0 0; }
}

/* header switch between the tracked cars: one segment per car, the current one filled */
.carnav { display: inline-flex; border: 1px solid var(--border); border-radius: 8px;
          overflow: hidden; align-self: center; }
.carnav a { color: var(--text-secondary); text-decoration: none; font-size: 13px; line-height: 1;
            padding: 7px 12px; white-space: nowrap; }
.carnav a + a { border-left: 1px solid var(--border); }
.carnav a:hover { color: var(--text-primary); background: var(--surface-1); }
.carnav a.on { color: var(--page); background: var(--text-primary); font-weight: 600; }
.carnav a.on:hover { color: var(--page); background: var(--text-primary); }

/* the deal table's own filter row */
.tfilters { margin-bottom: 12px; }
.tfilters .field { min-width: 118px; flex: 0 1 140px; }
.tfilters .check { font-size: 13px; color: var(--text-secondary); display: flex; gap: 6px;
                   align-items: center; padding-bottom: 8px; }
.tfilters button.ghost { margin-bottom: 1px; }
.tfilters .count { font-size: 12.5px; color: var(--text-secondary); padding-bottom: 8px;
                   font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 640px) {
  .tfilters .field { flex: 1 1 calc(50% - 5px); min-width: 0; }
}
