/* Light/dark tokens: data-viz reference palette (validated: series-1/2 pass all checks in both modes). */
: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;
  --link: #1c5cab;
  --st-good: #0ca30c; --st-warning: #fab219; --st-serious: #ec835a; --st-critical: #d03b3b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0d0d0d; --surface-1: #1a1a19;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
    --series-1: #3987e5; --series-2: #d95926; --link: #86b6ef;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface-1: #1a1a19;
  --text-primary: #f0efec; --text-secondary: #c3c2b7; --text-muted: #898781;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
  --series-1: #3987e5; --series-2: #d95926; --link: #86b6ef;
}

* { 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; }
a { color: var(--link); }
main { max-width: 1400px; margin: 0 auto; padding: 16px 24px 40px; }
h1 { font-size: 26px; margin: 8px 0 4px; }
h2 { font-size: 16px; margin: 0 0 4px; }
.lede, .meta, .muted { color: var(--text-secondary); }
.muted { font-size: 13px; }
.mono { font-family: ui-monospace, monospace; font-size: 13px; }

.top { display: flex; gap: 24px; align-items: center; padding: 10px 24px;
  border-bottom: 1px solid var(--border); background: var(--surface-1); }
.brand { font-weight: 700; color: var(--text-primary); text-decoration: none; }
.top nav { display: flex; gap: 16px; flex: 1; }
.top nav a { color: var(--text-secondary); text-decoration: none; }
.top nav a[aria-current="page"] { color: var(--text-primary); font-weight: 600; }
.theme { background: none; border: 1px solid var(--border); color: var(--text-primary);
  border-radius: 6px; padding: 2px 10px; cursor: pointer; font-size: 16px; }
.foot { max-width: 1400px; margin: 0 auto; padding: 16px 24px 32px; color: var(--text-muted); font-size: 12px; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin: 16px 0; }
.tile, .card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; }
.tile { padding: 12px 14px; }
.tile .label { color: var(--text-secondary); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 600; line-height: 1.2; }
.tile .sub { color: var(--text-muted); font-size: 12px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.grid .wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
.card { padding: 16px; margin: 0 0 16px; }
figure.card { margin: 0; }
figcaption p { margin: 0 0 8px; color: var(--text-secondary); font-size: 13px; }
.chart { width: 100%; height: 300px; }
.chart.tall { height: 420px; }
details summary { cursor: pointer; color: var(--text-secondary); font-size: 13px; }
details .data { margin-top: 8px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: end; margin: 8px 0 12px; }
.filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--text-secondary); gap: 2px; }
.filters label.check { flex-direction: row; align-items: center; gap: 6px; padding-bottom: 6px; }
.filters input, .filters select { font: inherit; font-size: 14px; padding: 4px 6px; color: var(--text-primary);
  background: var(--page); border: 1px solid var(--border); border-radius: 6px; }
.filters input[type=number] { width: 80px; }
.filters .reset { font-size: 13px; padding-bottom: 6px; }

.tablewrap { overflow-x: auto; transition: opacity .15s; }
.htmx-request .tablewrap, .tablewrap.htmx-request { opacity: .55; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th, table.data td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
table.data th { color: var(--text-secondary); font-weight: 600; white-space: nowrap; position: sticky; top: 0; background: var(--surface-1); }
table.data th a { color: inherit; }
table.data th[aria-sort="ascending"] a::after { content: " ▲"; }
table.data th[aria-sort="descending"] a::after { content: " ▼"; }
table.data td.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data td.id { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data td.desc { max-width: 520px; color: var(--text-secondary); }
table.data td.name { max-width: 320px; }
table.data td.empty { color: var(--text-muted); text-align: center; padding: 24px; }
table.data.small { width: auto; min-width: 260px; }
.pager { display: flex; gap: 16px; align-items: center; padding: 10px 2px 0; font-size: 13px; color: var(--text-secondary); }

/* Severity: label in ink, colored dot carries the cue (never color alone). */
.sev { font-size: 11px; color: var(--text-secondary); white-space: nowrap; }
.sev::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; background: var(--text-muted); }
.sev-critical::before { background: var(--st-critical); }
.sev-high::before { background: var(--st-serious); }
.sev-medium::before { background: var(--st-warning); }
.flag { font-size: 11px; border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; color: var(--text-primary); }
.st-ok { color: var(--st-good); } .st-fail { color: var(--st-critical); } .st-run { color: var(--text-muted); }
.refs { padding-left: 18px; word-break: break-all; font-size: 13px; }

/* Advisories */
.tabs { display: flex; gap: 4px; margin: 12px 0; border-bottom: 1px solid var(--border); }
.tabs a { padding: 6px 14px; color: var(--text-secondary); text-decoration: none; border: 1px solid transparent;
  border-bottom: none; border-radius: 6px 6px 0 0; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--text-primary); font-weight: 600; background: var(--surface-1); border-color: var(--border); }
table.data td.adv { min-width: 280px; max-width: 560px; }
table.data td.adv .desc { color: var(--text-secondary); font-size: 12px; margin-top: 2px; }

/* CVE map (/map). Sequential and ordinal steps are the reference blue ramp; each theme has its own
   steps (validated with --ordinal against that theme's surface), not a flip of the other. */
:root {
  --map-base: #c3c2b7;
  --sev-1: #86b6ef; --sev-2: #3987e5; --sev-3: #1c5cab; --sev-4: #0d366b;
  --seq-1: #cde2fb; --seq-2: #86b6ef; --seq-3: #3987e5; --seq-4: #1c5cab; --seq-5: #0d366b;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --map-base: #55544f;
    --sev-1: #184f95; --sev-2: #2a78d6; --sev-3: #6da7ec; --sev-4: #cde2fb;
    --seq-1: #0d366b; --seq-2: #184f95; --seq-3: #2a78d6; --seq-4: #6da7ec; --seq-5: #cde2fb;
  }
}
:root[data-theme="dark"] {
  --map-base: #55544f;
  --sev-1: #184f95; --sev-2: #2a78d6; --sev-3: #6da7ec; --sev-4: #cde2fb;
  --seq-1: #0d366b; --seq-2: #184f95; --seq-3: #2a78d6; --seq-4: #6da7ec; --seq-5: #cde2fb;
}
.filters button { font: inherit; font-size: 14px; padding: 4px 10px; color: var(--text-primary);
  background: var(--surface-1); border: 1px solid var(--axis); border-radius: 6px; cursor: pointer; }
.filters .maptime { flex: 1 1 260px; }
.filters .maptime input { width: 100%; padding: 0; }
.filters .maptime output { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.mapcard { padding: 0; overflow: hidden; }
.mapcard > .muted { margin: 0; padding: 0 16px 12px; }
.map { position: relative; height: min(72vh, 820px); min-height: 420px; overflow: hidden;
  cursor: grab; touch-action: none; user-select: none; outline-offset: -2px; }
.map.dragging { cursor: grabbing; }
.map.onpoint { cursor: pointer; }
.map canvas { display: block; width: 100%; height: 100%; }
.maplabels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.maplabel { position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 12px; font-weight: 600;
  color: var(--text-primary); padding: 0 4px; border-radius: 4px;
  background: color-mix(in srgb, var(--surface-1) 78%, transparent); will-change: transform; }
.mapring { position: absolute; left: 0; top: 0; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border: 2px solid var(--text-primary); border-radius: 50%; pointer-events: none; }
.maptip { position: absolute; left: 0; top: 0; width: 320px; max-width: calc(100% - 16px); padding: 10px 12px;
  background: var(--surface-1); border: 1px solid var(--axis); border-radius: 8px; font-size: 13px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18); pointer-events: none; user-select: text; cursor: auto; }
.maptip.pinned { pointer-events: auto; }
.maptip h3 { margin: 0 0 2px; font-size: 14px; }
.maptip dl { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; margin: 4px 0; }
.maptip dt { color: var(--text-secondary); }
.maptip dd { margin: 0; }
.maptip p { margin: 6px 0 0; color: var(--text-secondary); }
.mapmsg { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; padding: 24px;
  text-align: center; color: var(--text-secondary); pointer-events: none; }
.maplegend { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; padding: 10px 16px 6px;
  font-size: 13px; color: var(--text-secondary); }
.maplegend .key { display: inline-flex; align-items: center; gap: 6px; }
.maplegend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.maplegend .dot.big { width: 12px; height: 12px; box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 3px var(--axis); margin: 0 3px; }
.maplegend .rampwrap { display: inline-flex; flex-direction: column; gap: 2px; }
.maplegend .ramp { display: block; width: 220px; height: 10px; border-radius: 4px; }
.maplegend .ticks { display: flex; justify-content: space-between; width: 220px; font-size: 11px; color: var(--text-muted); }
.map [hidden] { display: none; }

/* advisory detail page */
.advtext { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100ch; line-height: 1.5; }
table.data.small th[scope="row"] { position: static; white-space: normal; }
.card h3 { font-size: 14px; margin: 16px 0 6px; }

/* sign-in, account and admin */
.authbox { max-width: 30rem; margin: 3rem auto; }
.btn { font: inherit; padding: .35rem .8rem; border: 1px solid currentColor; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
.btn.primary { background: #1f6feb; border-color: #1f6feb; color: #fff; }
.btn.danger { color: #c62828; }
.btn:disabled { opacity: .5; cursor: default; }
.notice { padding: .5rem .75rem; border-radius: 6px; border: 1px solid currentColor; }
.notice.err { color: #c62828; }
.notice.ok { color: #2e7d32; }
.who { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.who form, .actions form { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-start; }
.linkbox { overflow-wrap: anywhere; user-select: all; padding: .6rem; border: 1px dashed currentColor; border-radius: 6px; }
.authbox input[type=text], .card > p input[type=text] { font: inherit; padding: .3rem .5rem; }
