/*
 * Refractors Vault design system — shared across every page.
 * Direction: a trading desk for graded slabs. The vocabulary of the PSA slab
 * (the red label, the grade box, the big grade number) becomes the UI's own
 * language so a card buyer reads it on sight. Data is the hero: heavy tabular
 * numerals, plain-word verdicts, status color that means one thing.
 */
:root {
  --ink: #12151b;
  --ink-2: #4a515e;
  --muted: #858c99;
  --paper: #eef0f4;      /* cool slate-tinted, deliberately not cream */
  --slab: #ffffff;       /* card/table surface */
  --line: #dde1e8;
  --line-strong: #c4cad4;
  --psa-red: #c8102e;    /* the PSA label — identity accent, used sparingly */
  --buy: #1a7f43;        /* buy / positive */
  --caution: #c67615;    /* watch out */
  --thin: #8a6d3b;
  --ring: rgba(18,21,27,.10);
  /* chart series stay on the validated dataviz palette */
  --c-scarcity: #2a78d6; --c-hit: #1baf7a; --c-value: #eda100;
  --shadow: 0 1px 2px rgba(18,21,27,.06), 0 4px 16px rgba(18,21,27,.05);
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2f4f8; --ink-2: #b3bac7; --muted: #7f879a;
    --paper: #0c0e12; --slab: #171a21; --line: #262b34; --line-strong: #333a45;
    --psa-red: #ff4d64; --buy: #35c46f; --caution: #e0a03e; --thin: #c8a86a;
    --ring: rgba(255,255,255,.10);
    --c-scarcity: #3987e5; --c-hit: #1baf7a; --c-value: #d69b1f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 24px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.wrapper { max-width: 1200px; margin: 0 auto; padding: 18px 20px 56px; }
a { color: var(--psa-red); text-decoration: none; }
a:hover { text-decoration: underline; }
.tnum { font-variant-numeric: tabular-nums; }

/* ── top bar: brand mark echoes a slab label ── */
.topbar { display: flex; align-items: center; gap: 18px; margin-bottom: 6px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -.01em; font-size: 15px; color: var(--ink); }
.brand .tag {
  background: var(--psa-red); color: #fff; font-size: 10px; font-weight: 800;
  letter-spacing: .12em; padding: 3px 6px; border-radius: 4px; text-transform: uppercase;
}
.topnav { display: flex; gap: 4px; }
.topnav a {
  color: var(--ink-2); font-weight: 600; font-size: 13px; padding: 6px 11px;
  border-radius: 8px; text-decoration: none;
}
.topnav a:hover { background: var(--slab); color: var(--ink); text-decoration: none; }
.topnav a.here { background: var(--slab); color: var(--ink); box-shadow: var(--shadow); }
.topbar .spacer { margin-left: auto; }
.who { font-size: 13px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.who input, .who button {
  font: inherit; font-size: 13px; padding: 4px 9px; border: 1px solid var(--line-strong);
  border-radius: 7px; background: var(--slab); color: var(--ink);
}
.who button { cursor: pointer; font-weight: 600; }

/* ── freshness ribbon ── */
.ribbon { font-size: 12.5px; color: var(--ink-2); display: flex; align-items: center; gap: 7px; margin: 4px 0 16px; }
.ribbon .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }

/* ── page heading ── */
.page-h { display: flex; align-items: baseline; gap: 12px; margin: 6px 0 4px; }
.page-h h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0; }
.page-h .count { color: var(--muted); font-size: 13px; font-weight: 600; }
.lede { color: var(--ink-2); font-size: 14px; margin: 0 0 16px; max-width: 70ch; }

/* ── controls bar ── */
.controls { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: center;
  background: var(--slab); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.controls label { font-size: 12.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.controls select, .controls input {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--paper);
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 5px 8px;
}
.controls input[type=range] { accent-color: var(--psa-red); width: 84px; padding: 0; }
.btn {
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--slab); color: var(--ink-2);
  border-radius: 8px; padding: 6px 12px;
}
.btn:hover { color: var(--ink); border-color: var(--muted); }
.btn-primary { background: var(--psa-red); border-color: var(--psa-red); color: #fff; }
.btn-primary:hover { color: #fff; filter: brightness(1.06); }

/* ── the signature: Buy Score as a slab-style grade badge ── */
.score {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  width: 58px; min-height: 52px; border-radius: 10px; border: 2px solid var(--grade-c, var(--line-strong));
  background: color-mix(in srgb, var(--grade-c, var(--muted)) 10%, var(--slab)); padding: 4px 2px;
}
.score .n { font-size: 22px; font-weight: 800; line-height: 1; letter-spacing: -.03em; color: var(--grade-c, var(--ink)); font-variant-numeric: tabular-nums; }
.score .verdict { font-size: 8.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--grade-c, var(--ink-2)); margin-top: 3px; }
.v-strong { --grade-c: var(--buy); }
.v-solid  { --grade-c: var(--c-scarcity); }
.v-fair   { --grade-c: var(--caution); }
.v-thin   { --grade-c: var(--thin); }
.v-none   { --grade-c: var(--muted); }

/* grade chip = PSA label */
.grade-chip {
  display: inline-flex; align-items: center; gap: 4px; font-weight: 800; font-size: 12px;
  border: 1.5px solid var(--psa-red); color: var(--psa-red); border-radius: 5px; padding: 1px 6px;
  letter-spacing: .02em; white-space: nowrap;
}

/* ── segmented S/H/V bar ── */
.segbar { display: flex; gap: 2px; height: 7px; width: 130px; margin-top: 5px; }
.segbar span { border-radius: 3px; min-width: 0; }
.seg-s { background: var(--c-scarcity); } .seg-h { background: var(--c-hit); } .seg-v { background: var(--c-value); }
.dot-s, .dot-h, .dot-v { display: inline-block; width: 8px; height: 8px; border-radius: 2px; vertical-align: baseline; }
.dot-s { background: var(--c-scarcity); } .dot-h { background: var(--c-hit); } .dot-v { background: var(--c-value); }

/* ── tables ── */
.tablecard { background: var(--slab); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.scroll-x { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; }
table.data th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); font-weight: 700; padding: 12px 12px 8px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 0; background: var(--slab);
}
table.data th.num, table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th .arr { color: var(--psa-red); }
table.data td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr.row { cursor: pointer; }
table.data tr.row:hover td { background: color-mix(in srgb, var(--psa-red) 5%, transparent); }
.card-name { font-weight: 650; }
.card-sub { color: var(--ink-2); font-size: 12.5px; margin-top: 1px; }

/* ── plain-language flag chips ── */
.chip { font-size: 10.5px; font-weight: 650; border: 1px solid var(--ring); border-radius: 5px;
  padding: 1px 6px; white-space: nowrap; display: inline-block; margin: 1px 2px 1px 0; color: var(--ink-2); }
.chip-bad { color: var(--psa-red); border-color: color-mix(in srgb, var(--psa-red) 40%, var(--ring)); }
.chip-warn { color: var(--caution); border-color: color-mix(in srgb, var(--caution) 40%, var(--ring)); }
.chip-muted { color: var(--muted); }
.pos { color: var(--buy); font-weight: 650; }
.neg { color: var(--psa-red); font-weight: 650; }
.mix { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  border: 1px solid var(--ring); border-radius: 4px; padding: 1px 5px; color: var(--ink-2); white-space: nowrap; }

/* ── decision buttons ── */
.decide { display: inline-flex; gap: 5px; }
.decide button { font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; border-radius: 7px; padding: 4px 9px; border: 1px solid var(--line-strong); background: var(--slab); }
.decide .buy { color: var(--buy); border-color: color-mix(in srgb, var(--buy) 40%, var(--line-strong)); }
.decide .buy:hover { background: color-mix(in srgb, var(--buy) 12%, var(--slab)); }
.decide .pass { color: var(--ink-2); }
.decide .watch { color: var(--c-scarcity); }

/* ── empty states: an invitation to act ── */
.empty { padding: 48px 24px; text-align: center; color: var(--ink-2); }
.empty h3 { font-size: 17px; font-weight: 750; color: var(--ink); margin: 0 0 6px; }
.empty p { margin: 0 auto 16px; max-width: 44ch; }

/* ── the tooltip layer ── */
#tooltip { position: fixed; pointer-events: none; z-index: 30; display: none; max-width: 260px;
  background: var(--slab); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 7px 10px; font-size: 12.5px; box-shadow: var(--shadow); }

/* ── sheet (slide-over for onboarding) ── */
.sheet-back { position: fixed; inset: 0; background: rgba(10,12,16,.45); display: none; z-index: 40; }
.sheet-back.open { display: block; }
.sheet { position: fixed; top: 0; right: 0; height: 100%; width: min(440px, 92vw); background: var(--slab);
  box-shadow: -8px 0 32px rgba(0,0,0,.25); padding: 22px; overflow-y: auto; transform: translateX(100%); transition: transform .18s ease; }
.sheet-back.open .sheet { transform: translateX(0); }
.sheet h2 { font-size: 17px; margin: 0 0 4px; }
.sheet .field { display: block; margin: 14px 0 4px; font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.sheet input, .sheet select { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line-strong);
  border-radius: 9px; background: var(--paper); color: var(--ink); }
.sheet .hint { font-size: 12px; color: var(--muted); margin: 5px 0 0; }
.preview { margin: 16px 0; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.preview .big { font-size: 16px; font-weight: 750; }
.preview .ok { color: var(--buy); font-weight: 700; }
.preview .bad { color: var(--psa-red); font-weight: 700; }

svg text { font: 10px system-ui; fill: var(--muted); }
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }
