/* theme.css — shared design tokens.
   Data-viz roles follow the validated reference palette. Category bars and the
   trend line use ONE sequential hue (bar length / line position carries the
   magnitude). Status colors are reserved for issue severity and always ship with
   a text label + icon — never color alone. */

:root {
  color-scheme: light;

  /* surfaces & ink */
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  /* sequential hue (blue) — the only series color we use */
  --series-1: #2a78d6;
  --series-1-soft: #cde2fb;
  --series-1-mid: #86b6ef;

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

  --radius: 10px;
  --radius-sm: 6px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 1px 2px rgba(11, 11, 11, .06), 0 4px 12px rgba(11, 11, 11, .04);
}

@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;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-1-soft: #184f95;
    --series-1-mid: #256abf;
    --success-text: #0ca30c;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5;
  --series-1-soft: #184f95;
  --series-1-mid: #256abf;
  --success-text: #0ca30c;
  --shadow: none;
}

* { box-sizing: border-box; }

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

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

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h1 { font-size: 2.4rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1rem; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; }
.narrow { max-width: 720px; }

/* ---------- nav ---------- */
.nav {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem; max-width: 1180px; margin: 0 auto;
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text-primary); }
.brand span { color: var(--series-1); }
.nav-spacer { flex: 1; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  font: inherit; font-weight: 600; cursor: pointer;
  padding: .62rem 1.1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--series-1); background: var(--series-1); color: #fff;
  transition: filter .15s ease;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-primary); border-color: var(--border); }
.btn-sm { padding: .4rem .7rem; font-size: .87rem; }
.btn-block { width: 100%; }

/* ---------- cards ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.card-title { font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: .75rem; font-weight: 600; }

/* ---------- forms ---------- */
label.field { display: block; font-size: .85rem; color: var(--text-secondary); margin: .9rem 0 .3rem; font-weight: 500; }
input[type=text], input[type=url], input[type=email], input[type=password], select, textarea {
  width: 100%; font: inherit; padding: .62rem .75rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-1); color: var(--text-primary);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--series-1); outline-offset: 1px; }
textarea { min-height: 90px; resize: vertical; }

/* ---------- stat tiles (KPI row) ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-bottom: .3rem; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.1; }
.stat-sub { font-size: .82rem; color: var(--text-secondary); margin-top: .2rem; }
.delta-up { color: var(--success-text); font-weight: 600; }
.delta-down { color: var(--status-critical); font-weight: 600; }

/* ---------- hero figure (the score) ---------- */
.hero-score { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.hero-figure { font-size: 4.2rem; font-weight: 700; line-height: 1; }
.hero-grade {
  font-size: .95rem; font-weight: 700; padding: .2rem .6rem;
  border-radius: 999px; border: 1px solid currentColor;
}

/* meter — single ratio against a limit, same-ramp track */
.meter { height: 10px; background: var(--gridline); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; background: var(--series-1); border-radius: 999px; transition: width .5s ease; }

/* ---------- severity badges (status color + ICON + LABEL, never color alone) ---------- */
.sev { display: inline-flex; align-items: center; gap: .3rem; font-size: .74rem; font-weight: 700;
       padding: .15rem .5rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em;
       border: 1px solid currentColor; white-space: nowrap; }
.sev-critical { color: var(--status-critical); }
.sev-high     { color: var(--status-serious); }
.sev-medium   { color: var(--status-warning); }
.sev-low      { color: var(--text-secondary); }
.sev-good     { color: var(--status-good); }

/* ---------- category bars ---------- */
.catbar { display: grid; grid-template-columns: 148px 1fr 42px; gap: .75rem; align-items: center; margin-bottom: .6rem; }
.catbar-label { font-size: .87rem; color: var(--text-secondary); }
.catbar-track { height: 12px; background: var(--gridline); border-radius: 4px; overflow: hidden; }
.catbar-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; transition: width .5s ease; }
.catbar-val { font-size: .87rem; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- issue list ---------- */
.issue { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .6rem; background: var(--surface-1); }
.issue-head { display: flex; align-items: flex-start; gap: .7rem; padding: .8rem .9rem; cursor: pointer; }
.issue-title { font-weight: 600; flex: 1; }
.issue-body { padding: 0 .9rem .9rem .9rem; border-top: 1px solid var(--border); }
.issue-body p { margin: .7rem 0; color: var(--text-secondary); font-size: .92rem; }
pre.code {
  background: var(--page); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .8rem; overflow-x: auto; font-size: 12.5px; line-height: 1.5;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; margin: 0;
}
.code-head { display: flex; align-items: center; gap: .5rem; margin: .8rem 0 .35rem; }
.code-head .card-title { margin: 0; }

/* ---------- misc ---------- */
.muted { color: var(--text-muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } h1 { font-size: 1.9rem; } }
.hidden { display: none !important; }
.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.banner { padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 1rem; font-size: .92rem; }
.banner-warn { border-color: var(--status-warning); }
.banner-err { border-color: var(--status-critical); color: var(--status-critical); }
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tab { padding: .6rem .9rem; cursor: pointer; border-bottom: 2px solid transparent; color: var(--text-secondary); font-weight: 500; background: none; border-top: 0; border-left: 0; border-right: 0; font: inherit; }
.tab.active { color: var(--text-primary); border-bottom-color: var(--series-1); font-weight: 600; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); }
table.data th { color: var(--text-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
