/*
 * StockPilot.
 *
 * Deliberately restrained: slate chrome, one deep-blue accent, and colour
 * reserved almost entirely for the three buy tiers. This gets read on a phone
 * in daylight at a sale, so contrast matters more than personality, and the
 * recommendation should be the only thing on the page that shouts.
 */

:root {
  /* Read back by a tiny inline script so the pages can notice they are being
     styled by a cached copy of an older release and say so, rather than just
     looking broken. Bump alongside Assets::CSS_VERSION. */
  --sp-css: 7;

  --ink: #0f172a;
  --ink-soft: #334155;
  --ink-faint: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --page: #f8fafc;
  --panel: #ffffff;

  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --accent-wash: #eff6ff;

  /* The buy tiers. These are the only strong colours in the product. */
  --strong-buy: #047857;
  --strong-buy-wash: #ecfdf5;
  --worth-a-look: #b45309;
  --worth-a-look-wash: #fffbeb;
  --avoid: #b91c1c;
  --avoid-wash: #fef2f2;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e2e8f0;
    --ink-soft: #cbd5e1;
    --ink-faint: #94a3b8;
    --line: #1e293b;
    --line-strong: #334155;
    --page: #0b1220;
    --panel: #111a2b;
    --accent: #60a5fa;
    --accent-dark: #93c5fd;
    --accent-wash: #16233c;
    --strong-buy: #34d399;
    --strong-buy-wash: #0d2a22;
    --worth-a-look: #fbbf24;
    --worth-a-look-wash: #2b2110;
    --avoid: #f87171;
    --avoid-wash: #2c1414;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.wrap { max-width: 780px; margin: 0 auto; padding: 32px 20px 64px; }
.wrap--wide { max-width: 1180px; }

.brand { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.brand h1 { font-size: 24px; margin: 0; letter-spacing: -.02em; }
.brand span { color: var(--ink-faint); font-size: 14px; }

.lede { color: var(--ink-soft); margin: 0 0 28px; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.panel h2 { font-size: 17px; margin: 0 0 4px; }
.panel h2 + p { margin-top: 0; color: var(--ink-faint); font-size: 14px; }

.steps { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 24px; }
.steps li {
  font-size: 13px; color: var(--ink-faint);
  border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; background: var(--panel);
}
.steps li[data-state="done"] { color: var(--strong-buy); border-color: var(--strong-buy); }
.steps li[data-state="current"] { color: var(--panel); background: var(--accent); border-color: var(--accent); }

label { display: block; font-weight: 600; font-size: 14px; margin: 16px 0 6px; }
label .hint { display: block; font-weight: 400; color: var(--ink-faint); font-size: 13px; margin-top: 2px; }

input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: 8px;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}

.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > * { flex: 1 1 220px; }

button, .button {
  display: inline-block; margin-top: 22px; padding: 11px 20px;
  font: inherit; font-weight: 600; color: #fff; text-decoration: none;
  background: var(--accent); border: 1px solid var(--accent); border-radius: 8px; cursor: pointer;
}
button:hover, .button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button--quiet { background: transparent; color: var(--accent); }
.button--quiet:hover { background: var(--accent-wash); }

.note { border-radius: 8px; padding: 12px 14px; font-size: 14px; margin: 0 0 18px; border: 1px solid; }
.note--bad { background: var(--avoid-wash); border-color: var(--avoid); color: var(--avoid); }
.note--warn { background: var(--worth-a-look-wash); border-color: var(--worth-a-look); color: var(--worth-a-look); }
.note--good { background: var(--strong-buy-wash); border-color: var(--strong-buy); color: var(--strong-buy); }
.note--info { background: var(--accent-wash); border-color: var(--accent); color: var(--accent-dark); }
.note strong { display: block; margin-bottom: 2px; }

.checks { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks .mark { flex: none; width: 20px; font-weight: 700; }
.checks .ok .mark { color: var(--strong-buy); }
.checks .warn .mark { color: var(--worth-a-look); }
.checks .bad .mark { color: var(--avoid); }
.checks .name { font-weight: 600; font-size: 14px; }
.checks .detail, .checks .fix { font-size: 13px; color: var(--ink-faint); margin-top: 2px; }
.checks .fix { color: var(--ink-soft); }

pre {
  background: var(--page); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px; overflow-x: auto; font-size: 13px; line-height: 1.5;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.tier { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .02em;
        padding: 3px 9px; border-radius: 99px; border: 1px solid; }
.tier--strong { color: var(--strong-buy); background: var(--strong-buy-wash); border-color: var(--strong-buy); }
.tier--look { color: var(--worth-a-look); background: var(--worth-a-look-wash); border-color: var(--worth-a-look); }
.tier--avoid { color: var(--avoid); background: var(--avoid-wash); border-color: var(--avoid); }

.foot { color: var(--ink-faint); font-size: 13px; margin-top: 28px; }

/* The column-mapping table. */
table.map { width: 100%; border-collapse: collapse; }
table.map th {
  text-align: left; font-size: 14px; font-weight: 600; vertical-align: top;
  padding: 12px 14px 12px 0; width: 46%; border-bottom: 1px solid var(--line);
}
table.map td { padding: 10px 0; border-bottom: 1px solid var(--line); }
table.map select { width: 100%; }
table.map .hint { display: block; font-weight: 400; color: var(--ink-faint); font-size: 13px; margin-top: 3px; }

/* Wide content scrolls inside its own box; the page never scrolls sideways. */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.preview { border-collapse: collapse; font-size: 13px; white-space: nowrap; }
table.preview th, table.preview td {
  padding: 7px 12px; border-bottom: 1px solid var(--line); text-align: left;
}
table.preview th { font-weight: 600; color: var(--ink-faint); background: var(--page); position: sticky; top: 0; }

label input[type=radio], label input[type=checkbox] { margin-right: 8px; }
input[type=file] {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--ink);
  background: var(--panel); border: 1px dashed var(--line-strong); border-radius: 8px;
}

/* A card that leads somewhere, used for the dashboard's next steps. */
.cta { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; justify-content: space-between; }
.cta p { margin: 0; }
.cta .button { margin-top: 0; }

/* Headline figures. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 22px; }
.stat-value { display: block; font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.stat-label { display: block; font-size: 14px; font-weight: 600; color: var(--ink-soft); margin-top: 2px; }
.stat-note { display: block; font-size: 13px; color: var(--ink-faint); margin-top: 6px; }

.sweet { font-size: 18px; font-weight: 600; margin: 0 0 22px; color: var(--ink); }

.band-heading { font-size: 14px; font-weight: 600; color: var(--ink-soft); margin: 22px 0 10px; }
.bands { display: grid; gap: 7px; }
.band { display: grid; grid-template-columns: minmax(120px, 26%) 1fr minmax(84px, auto); gap: 12px; align-items: center; }
.band-label { font-size: 13px; color: var(--ink-soft); }
.band-track { background: var(--page); border-radius: 99px; height: 20px; overflow: hidden; }
.bar { display: block; height: 100%; border-radius: 99px; background: var(--line-strong); }
/* The dealer's best band is the only bar that gets a colour. */
.bar--best { background: var(--strong-buy); }
.bar--thin { background: repeating-linear-gradient(45deg, var(--line-strong) 0 5px, transparent 5px 10px); }
.band-value { font-size: 13px; font-weight: 600; text-align: right; }
.band-units { display: block; font-weight: 400; color: var(--ink-faint); font-size: 12px; }
.thin-note { font-size: 11px; color: var(--ink-faint); font-weight: 400; }

.panel-sub { margin: -2px 0 16px; color: var(--ink-faint); font-size: 14px; }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 20px; }
.tab {
  font-size: 13px; line-height: 1.2; text-decoration: none; color: var(--ink-soft);
  border: 1px solid var(--line-strong); border-radius: 99px; padding: 7px 14px;
  background: var(--panel); white-space: nowrap;
}
.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab--on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.tab--on:hover { color: #fff; }

table.league {
  width: 100%; border-collapse: collapse; font-size: 14px;
  /* Digits line up in columns, which is the whole point of a table of money. */
  font-variant-numeric: tabular-nums;
}
table.league th, table.league td {
  padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line);
}
table.league thead th {
  vertical-align: bottom; border-bottom: 2px solid var(--line-strong);
  padding-bottom: 9px; font-weight: 600;
}
table.league .col-label { display: block; font-size: 13px; color: var(--ink); }
table.league .col-note { display: block; font-size: 11px; font-weight: 400; color: var(--ink-faint); margin-top: 2px; }
table.league td.num, table.league th.num { text-align: right; white-space: nowrap; }
table.league th.rank, table.league td.rank {
  width: 34px; padding-right: 0; color: var(--ink-faint); font-size: 12px; text-align: right;
}
table.league td.model { font-weight: 600; white-space: nowrap; }
/* The column the table is sorted by, so the order is never a mystery. */
table.league .col--on { background: var(--accent-wash); font-weight: 700; }
table.league thead .col--on { color: var(--accent-dark); }
table.league tbody tr:hover td { background: var(--page); }
table.league tbody tr:hover td.col--on { background: var(--accent-wash); }
table.league tbody tr:last-child td { border-bottom: 0; }

/* --- The buy list ---------------------------------------------------------
   The tier is the only thing allowed to shout. Everything else stays quiet so
   the recommendation reads first. */

.wrap--buylist { max-width: 1000px; }

.buylist-head { display: flex; gap: 18px; align-items: flex-end; justify-content: space-between;
                flex-wrap: wrap; margin-bottom: 18px; }
.buylist-title { font-size: 20px; margin: 0; }
.switcher label { margin: 0; font-size: 13px; color: var(--ink-faint); }
.switcher select { min-width: 220px; margin-top: 4px; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin: 0 0 6px; }
.filters label { margin: 0; flex: 1 1 150px; font-size: 13px; }
.filters input { margin-top: 4px; }
.filters button { margin-top: 0; flex: 0 0 auto; }

.choices { display: grid; gap: 10px; margin: 8px 0 4px; }
.choice { display: block; margin: 0; padding: 12px 14px; border: 1px solid var(--line-strong);
          border-radius: 8px; font-weight: 400; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.choice strong { font-weight: 700; }
.choice .hint { display: block; margin-top: 4px; }

.lots { display: grid; gap: 14px; }

.lot { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line-strong);
       border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.lot--strong { border-left-color: var(--strong-buy); }
.lot--look { border-left-color: var(--worth-a-look); }
.lot--avoid { border-left-color: var(--avoid); opacity: .82; }

.lot-head { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.lot-id h3 { margin: 7px 0 3px; font-size: 17px; }
.derivative { font-weight: 400; color: var(--ink-faint); font-size: 14px; }
.lot-facts { margin: 0; font-size: 13px; color: var(--ink-faint); }

.lot-score { text-align: right; flex: none; }
.score { display: block; font-size: 27px; font-weight: 700; line-height: 1; letter-spacing: -.02em;
         font-variant-numeric: tabular-nums; }
.score-label { display: block; font-size: 11px; color: var(--ink-faint); margin-top: 3px; }

.lot-headline { margin: 13px 0; font-size: 14px; color: var(--ink-soft); }

.lot-money { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px;
             padding: 13px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.money-label { display: block; font-size: 12px; color: var(--ink-faint); }
.money { display: block; font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 1px; }
.money--good { color: var(--strong-buy); }
.money--bad { color: var(--avoid); }
.money-note { display: block; font-size: 11px; color: var(--ink-faint); margin-top: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }
.chip { font-size: 12px; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--line-strong);
        color: var(--ink-soft); background: var(--page); }
.chip--warn { border-color: var(--worth-a-look); color: var(--worth-a-look); background: var(--worth-a-look-wash); }
.chip--bad { border-color: var(--avoid); color: var(--avoid); background: var(--avoid-wash); }

.lot-why { margin-top: 13px; }
.lot-why summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--accent); }
.lot-why ul { margin: 11px 0 0; padding-left: 20px; font-size: 14px; color: var(--ink-soft); }
.lot-why li { margin-bottom: 5px; }
.lot-why .foot { margin-top: 11px; }

.lot-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
               margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 0; }

.mini { margin-top: 0; padding: 6px 13px; font-size: 13px; font-weight: 600; border-radius: 7px; }
.mini--quiet { background: transparent; color: var(--ink-faint); border-color: var(--line-strong); }
.mini--quiet:hover { background: var(--page); color: var(--ink); border-color: var(--line-strong); }
.mini--buy, .button--buy { background: var(--strong-buy); border-color: var(--strong-buy); }
.mini--buy:hover, .button--buy:hover { background: #036349; border-color: #036349; }

.decided { font-size: 13px; font-weight: 700; padding: 5px 12px; border-radius: 99px; border: 1px solid; }
.decided--shortlisted { color: var(--accent); background: var(--accent-wash); border-color: var(--accent); }
.decided--bought { color: var(--strong-buy); background: var(--strong-buy-wash); border-color: var(--strong-buy); }
.decided--hidden { color: var(--ink-faint); background: var(--page); border-color: var(--line-strong); }

/* The lot detail page. */
table.ledger { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.ledger th { text-align: left; font-weight: 600; font-size: 14px; padding: 10px 0; }
table.ledger td { padding: 10px 0; }
table.ledger td.num { text-align: right; font-weight: 700; font-size: 16px; white-space: nowrap; }
table.ledger td.why { padding-left: 16px; font-size: 13px; color: var(--ink-faint); font-weight: 400;
                      text-align: right; width: 45%; }
table.ledger tr.subtotal th, table.ledger tr.subtotal td { border-top: 1px solid var(--line); }
table.ledger tr.total th, table.ledger tr.total td { border-top: 2px solid var(--line-strong); font-size: 17px; }
table.ledger tr.total td.num { font-size: 20px; }

ul.reasons { margin: 0; padding-left: 20px; font-size: 14px; color: var(--ink-soft); }
ul.reasons li { margin-bottom: 7px; }

.decision-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.decision-buttons button { margin-top: 0; }
