/* Base: reset, typography, page chrome (rail, top bar, content grid). Uses only tokens. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg-0);
  color: var(--text);
  font: 400 var(--fs-md) / 1.55 var(--font);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
/* a restrained glow, not a gradient mesh: one soft accent light from the top left */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 520px at 8% -8%, rgba(58, 174, 255, 0.10), transparent 60%),
    radial-gradient(700px 480px at 100% 0%, rgba(255, 155, 80, 0.045), transparent 60%);
}
:root[data-theme="light"] body::before { display: none; }

h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent-soft); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.mono { font-family: var(--mono); font-size: var(--fs-sm); }
.eyebrow { font-size: var(--fs-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; font-weight: 700; }

/* ---- layout ---- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow: auto;
  padding: var(--s-5) var(--s-3);
  background: linear-gradient(180deg, var(--bg-1), var(--bg-0));
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: var(--s-4);
}
.brand { display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-2); font-weight: 700; letter-spacing: -0.01em; }
.brand img { border-radius: 8px; box-shadow: 0 0 0 1px var(--line-strong), 0 6px 18px rgba(58, 174, 255, 0.25); }
.brand small { display: block; font-weight: 500; color: var(--text-3); font-size: var(--fs-xs); letter-spacing: 0; }
.nav { display: grid; gap: 2px; }
.nav .group { font-size: var(--fs-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-3); margin: var(--s-4) var(--s-3) var(--s-1); font-weight: 600; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2);
  padding: 9px var(--s-3); border-radius: var(--r-sm);
  color: var(--text-2); text-decoration: none; font-weight: 500;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav a:hover { background: var(--bg-3); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 2px 0 0 var(--accent); }
.rail-foot { margin-top: auto; display: grid; gap: var(--s-2); padding: var(--s-2); }

.main { padding: var(--s-5) clamp(var(--s-4), 3vw, var(--s-7)) var(--s-8); max-width: 1320px; width: 100%; }
.top { display: flex; flex-wrap: wrap; gap: var(--s-4); justify-content: space-between; align-items: flex-end; margin-bottom: var(--s-5); }
.top .actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.crumb { font-size: var(--fs-sm); color: var(--text-3); margin-bottom: var(--s-1); }
.crumb a { color: var(--text-2); text-decoration: none; }
.crumb a:hover { color: var(--accent); }

.grid { display: grid; gap: var(--s-4); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.row { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); align-content: start; }
section.block { margin-top: var(--s-7); }
section.block > .head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }

.banner { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); margin-bottom: var(--s-4); border: 1px solid transparent; }
.banner.bad { background: var(--bad-soft); color: var(--bad); border-color: rgba(255, 111, 111, 0.25); }
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(255, 194, 92, 0.25); }
.empty { padding: var(--s-6); text-align: center; color: var(--text-3); border: 1px dashed var(--line-strong); border-radius: var(--r-lg); }

#toast { position: fixed; bottom: var(--s-5); left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: var(--s-2); }
#toast div { background: var(--bg-4); color: var(--text); border: 1px solid var(--line-strong); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); box-shadow: var(--shadow-2); max-width: 90vw; animation: rise var(--t-med) var(--ease) both; }

@media (max-width: 880px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .main { min-width: 0; }
  .side { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: var(--s-3); border-right: 0; border-bottom: 1px solid var(--line); gap: var(--s-3); }
  .side .nav { grid-auto-flow: column; grid-auto-columns: max-content; }
  .side .nav .group, .side .rail-foot, .brand small { display: none; }
  .main { padding: var(--s-4) var(--s-4) var(--s-8); }
}
@media (max-width: 480px) {
  /* three menu items fit a phone once the brand shows only its mark */
  .side .brand > div { display: none; }
}
