/* =========================================================================
   NYU Archway - interface stylesheet
   =========================================================================

   Hand-written, no build step, no framework. Every value that varies between
   light and dark is a custom property on :root and is redefined twice below:
   once under prefers-color-scheme for the OS setting, and once under
   [data-theme] for the in-app toggle, which must win either way.

   NYU violet (#57068c) is the accent - it marks the one primary action on a
   screen, the active nav item and the focus ring. It is deliberately NOT a
   chart colour: a hue that means both "NYU" and "the Gemini series" is read
   wrong every time.

   Section map
     1. Tokens
     2. Reset & base
     3. Layout shell
     4. Typography & utilities
     5. Buttons, forms, controls
     6. Cards, stats, meters
     7. Tables
     8. Charts (inline SVG classes emitted by ui_helpers)
     9. Tabs, code blocks, copy
    10. Badges, chips, empty states, flash
    11. HTMX states
    12. Playground (the key test bench at /portal/playground)
    13. Responsive
   ========================================================================= */

/* ----------------------------------------------------------------- 1. Tokens */

:root {
  color-scheme: light;

  /* Brand */
  --nyu-violet: #57068c;
  --accent: #57068c;
  --accent-strong: #440470;
  --accent-soft: #f2e9f8;
  --accent-border: #d9c2ea;
  --accent-ink: #ffffff;

  /* Planes */
  --plane: #f6f5f2;
  --surface-1: #fcfcfb;
  --surface-2: #f2f1ec;
  --surface-3: #e9e8e1;
  --overlay: rgba(11, 11, 11, 0.42);

  /* Ink */
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --ink-invert: #ffffff;

  /* Lines */
  --border: rgba(11, 11, 11, 0.12);
  --border-strong: rgba(11, 11, 11, 0.22);
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --track: #eceae4;

  /* Status - reserved, never reused as a series colour */
  --good: #0ca30c;
  --good-soft: #e4f6e4;
  --warning: #fab219;
  --warning-soft: #fdf1d6;
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-soft: #fbe6e6;
  --good-ink: #006300;
  --warning-ink: #8a5c00;
  --critical-ink: #a72222;

  /* Categorical series - fixed order, never cycled */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --series-other: #898781;

  /* Meters - fill carries severity, track is a lighter step of the same ramp */
  --meter-ok: #2a78d6;
  --meter-ok-track: #d8e7fa;
  --meter-warn: #e09000;
  --meter-warn-track: #f9ecce;
  --meter-over: #d03b3b;
  --meter-over-track: #f6dede;
  --meter-unlimited: #e3e1da;

  /* Focus */
  --focus: #57068c;

  /* Space */
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;
  --sp-7: 3rem;
  --sp-8: 4rem;

  /* Radius */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-full: 999px;

  /* Type */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 0.6875rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;
  --fs-hero: 2.75rem;

  /* Elevation - restrained; the border does most of the separating */
  --shadow-1: 0 1px 2px rgba(11, 11, 11, 0.05);
  --shadow-2: 0 4px 14px rgba(11, 11, 11, 0.08);
  --shadow-3: 0 18px 48px rgba(11, 11, 11, 0.18);

  --sidebar-w: 15.5rem;
  --maxw: 84rem;
}

/* The media block sits under a :not() guard so a light stamp from the toggle
   beats an OS set to dark; :where() keeps its specificity at zero so the
   explicit [data-theme="dark"] block below still wins. */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;

    --accent: #b98ade;
    --accent-strong: #cba7e9;
    --accent-soft: #241033;
    --accent-border: #4a2a66;
    --accent-ink: #1a0a26;

    --plane: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --surface-3: #2c2c2a;
    --overlay: rgba(0, 0, 0, 0.62);

    --ink-1: #ffffff;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --ink-invert: #0b0b0b;

    --border: rgba(255, 255, 255, 0.12);
    --border-strong: rgba(255, 255, 255, 0.24);
    --grid: #2c2c2a;
    --axis: #383835;
    --track: #232322;

    --good-soft: #0d2a0d;
    --warning-soft: #33280a;
    --critical-soft: #331414;
    --good-ink: #0ca30c;
    --warning-ink: #fab219;
    --critical-ink: #e88b8b;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #008300;
    --series-7: #9085e9;
    --series-8: #e66767;
    --series-other: #898781;

    --meter-ok: #3987e5;
    --meter-ok-track: #10305a;
    --meter-warn: #fab219;
    --meter-warn-track: #3d2f08;
    --meter-over: #e66767;
    --meter-over-track: #401919;
    --meter-unlimited: #2c2c2a;

    --focus: #cba7e9;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-2: 0 4px 14px rgba(0, 0, 0, 0.5);
    --shadow-3: 0 18px 48px rgba(0, 0, 0, 0.65);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --accent: #b98ade;
  --accent-strong: #cba7e9;
  --accent-soft: #241033;
  --accent-border: #4a2a66;
  --accent-ink: #1a0a26;

  --plane: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232322;
  --surface-3: #2c2c2a;
  --overlay: rgba(0, 0, 0, 0.62);

  --ink-1: #ffffff;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --ink-invert: #0b0b0b;

  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.24);
  --grid: #2c2c2a;
  --axis: #383835;
  --track: #232322;

  --good-soft: #0d2a0d;
  --warning-soft: #33280a;
  --critical-soft: #331414;
  --good-ink: #0ca30c;
  --warning-ink: #fab219;
  --critical-ink: #e88b8b;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #898781;

  --meter-ok: #3987e5;
  --meter-ok-track: #10305a;
  --meter-warn: #fab219;
  --meter-warn-track: #3d2f08;
  --meter-over: #e66767;
  --meter-over-track: #401919;
  --meter-unlimited: #2c2c2a;

  --focus: #cba7e9;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-2: 0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-3: 0 18px 48px rgba(0, 0, 0, 0.65);
}

/* ------------------------------------------------------- 2. Reset & base */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  /* Explicit background: without it a dark-mode browser paints white behind
     translucent surfaces during load. */
  background: var(--plane);
  color: var(--ink-1);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
p,
figure,
fieldset {
  margin: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--accent);
  text-decoration-color: color-mix(in srgb, var(--accent) 38%, transparent);
  text-underline-offset: 2px;
}

a:hover {
  text-decoration-color: currentColor;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

::selection {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
}

.skip-link {
  position: absolute;
  left: var(--sp-3);
  top: -4rem;
  z-index: 200;
  padding: var(--sp-2) var(--sp-4);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--r-sm);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: var(--sp-3);
}

/* Two names for one thing: `visually-hidden` reads better in prose, `sr-only`
   is what most people reach for out of habit. Both are supported so neither
   spelling silently renders visible text. */
.visually-hidden,
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------- 3. Layout shell */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

.shell--plain {
  grid-template-columns: minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-4);
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  text-decoration: none;
  color: inherit;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
  border-radius: var(--r-md);
  /* Lit from the top left, same two stops as static/img/favicon.svg, so the
     tab icon and the tile in the sidebar are the same object. */
  background: linear-gradient(135deg, #7a16bd, #3c0463);
  color: #fff;
}

/* The glyph fills the tile and inherits its colour; the optical padding is
   inside the 32-unit viewBox, which is what keeps it matching the favicon. */
.brand__glyph {
  width: 100%;
  height: 100%;
}

.brand__name {
  display: block;
  font-weight: 640;
  line-height: 1.2;
}

.brand__sub {
  display: block;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav__heading {
  margin: var(--sp-4) 0 var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.nav__link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}

.nav__link:hover {
  background: var(--surface-2);
  color: var(--ink-1);
}

.nav__link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 620;
}

.nav__link[aria-current="page"] .icon {
  color: var(--accent);
}

.nav__count {
  margin-left: auto;
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--ink-3);
}

.sidebar__foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar__title {
  font-size: var(--fs-md);
  font-weight: 620;
}

.topbar__spacer {
  flex: 1;
}

.content {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sp-4);
}

.page-head__text {
  flex: 1 1 22rem;
  min-width: 0;
}

.page-head h1 {
  font-size: var(--fs-xl);
  font-weight: 660;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.page-head p {
  margin-top: var(--sp-1);
  color: var(--ink-2);
  max-width: 62ch;
}

.page-head__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* Mobile nav lives in a <details> so it opens with no JavaScript at all. */
.mobilenav {
  display: none;
}

.mobilenav > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-1);
  font-size: var(--fs-sm);
  font-weight: 560;
}

.mobilenav > summary::-webkit-details-marker {
  display: none;
}

.mobilenav__panel {
  position: absolute;
  left: var(--sp-3);
  right: var(--sp-3);
  margin-top: var(--sp-2);
  padding: var(--sp-3);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  z-index: 60;
}

/* -------------------------------------------- 4. Typography & utilities */

.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 620;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.muted {
  color: var(--ink-2);
}

.dim {
  color: var(--ink-3);
}

.small {
  font-size: var(--fs-sm);
}

.tiny {
  font-size: var(--fs-xs);
}

.strong {
  font-weight: 620;
}

/* For a short value that must not be broken across lines - an email, a period
   label, a key prefix. A wrapped "2026-W38" reads as two things. */
.nowrap {
  white-space: nowrap;
}

.nums {
  font-variant-numeric: tabular-nums;
}

.mono {
  font-family: var(--mono);
  font-size: 0.9em;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.stack--tight {
  gap: var(--sp-1);
}

/* One collapsed vendor of the key-scope model picker. A full catalogue is
   several screens long, so the groups start shut and the dialog stays the size
   of the decision most people are making - "this whole vendor". */
.scope-group {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.scope-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  cursor: pointer;
  font-size: var(--fs-sm);
}

.scope-group > summary:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.scope-group > .row {
  padding: 0 var(--sp-3) var(--sp-3);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.row--tight {
  gap: var(--sp-1);
}

.push {
  margin-left: auto;
}

.grid {
  display: grid;
  gap: var(--sp-4);
}

.grid--2 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
}

.grid--3 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.grid--4 {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr));
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--sp-4);
  align-items: start;
}

.icon {
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  color: currentColor;
}

.icon--lg {
  width: 1.5rem;
  height: 1.5rem;
}

hr.rule {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--sp-4) 0;
}

/* ------------------------------------ 5. Buttons, forms, controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 0.5rem 0.875rem;
  min-height: 2.25rem;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-1);
  color: var(--ink-1);
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 560;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.5;
  pointer-events: none;
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn--primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn--danger {
  background: var(--critical);
  border-color: var(--critical);
  color: #fff;
}

.btn--danger:hover {
  background: #b93333;
  border-color: #b93333;
}

.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--ink-1);
}

.btn--sm {
  min-height: 1.875rem;
  padding: 0.25rem 0.625rem;
  font-size: var(--fs-xs);
}

.btn--block {
  width: 100%;
}

/* Same stretch problem as `.tabnav`: a lone button inside a card or the page
   column is an action, not a banner. `.btn--block` is the explicit opt-in for
   full width (the sign-in button), so it must survive this. */
.card > .btn:not(.btn--block),
.content > .btn:not(.btn--block),
.stack > .btn:not(.btn--block) {
  align-self: flex-start;
}

.btn-group {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}

.btn-group a,
.btn-group button {
  padding: 0.25rem 0.625rem;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 560;
  text-decoration: none;
  cursor: pointer;
}

.btn-group a[aria-current="true"],
.btn-group button[aria-pressed="true"] {
  background: var(--surface-1);
  color: var(--ink-1);
  box-shadow: var(--shadow-1);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  min-width: 0;
}

/* `.field__label` covers the case where the whole field is wrapped in a <label>
   and the caption is a <span> - `.field > label` cannot match that, and without
   this the caption would render at body size while every other form label is
   small and grey. */
.field > label,
.field__label,
.label {
  font-size: var(--fs-sm);
  font-weight: 560;
  color: var(--ink-2);
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

.field__error {
  font-size: var(--fs-xs);
  color: var(--critical-ink);
}

/* Controls are styled by element so a plain <input> is always right. `.input`
   and `.select` are accepted as explicit spellings of the same thing - some
   templates name the class outright, and a class that matches nothing is a trap
   the next person has to discover by eye. */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"],
input[type="date"],
select,
textarea,
.input,
.select {
  width: 100%;
  padding: 0.5rem 0.625rem;
  min-height: 2.25rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface-1);
  color: var(--ink-1);
  font: inherit;
  font-size: var(--fs-sm);
}

/* Sized to sit on a table row beside a .btn--sm without growing the row. */
.input--sm {
  min-height: 1.875rem;
  padding: 0.25rem 0.5rem;
  font-size: var(--fs-xs);
  width: auto;
  min-width: 0;
  flex: 1 1 8rem;
}

/* A text control sharing a `.row` with its submit button has to share the line.
   The base `width: 100%` claims the whole row instead, and since `.row` wraps,
   the button is pushed onto a line of its own - which reads as two unrelated
   controls rather than one input and its action. */
.row > input[type="text"],
.row > input[type="email"],
.row > input[type="password"],
.row > input[type="search"],
.row > input[type="number"],
.row > input[type="date"],
.row > select,
.row > .input,
.row > .select {
  flex: 1 1 12rem;
  width: auto;
  min-width: 0;
}

.row > .input--sm {
  flex: 1 1 8rem;
}

textarea {
  min-height: 5.5rem;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-3);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
  border-color: transparent;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}

.filters .field {
  flex: 1 1 11rem;
}

.filters .field--wide {
  flex: 2 1 18rem;
}

.search {
  position: relative;
}

.search .icon {
  position: absolute;
  left: 0.6rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-3);
  pointer-events: none;
}

.search input {
  padding-left: 2.1rem;
}

/* ------------------------------------ 6. Cards, stats, meters */

.card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
  min-width: 0;
}

.card--flush {
  padding: 0;
  overflow: hidden;
}

/* A card whose subject is currently wrong - a live freeze, a breached control.
   The left edge carries the weight so the card still reads as a card. */
.card--alert {
  border-color: var(--critical);
  border-left-width: 3px;
  background: var(--critical-soft);
}

.card--flush > .card__head {
  padding: var(--sp-4) var(--sp-4) 0;
}

.card--flush > .card__foot {
  padding: var(--sp-3) var(--sp-4);
}

.card__head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}

.card__title {
  font-size: var(--fs-base);
  font-weight: 620;
}

.card__sub {
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.card__foot {
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  padding: var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-1);
}

.stat__label {
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.stat__value {
  font-size: var(--fs-xl);
  font-weight: 640;
  letter-spacing: -0.02em;
  line-height: 1.05;
  /* Proportional figures on purpose - tabular-nums makes a big "121" look loose. */
}

.stat__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-3);
}

.stat__delta {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: var(--fs-xs);
  font-weight: 600;
}

.stat__delta[data-dir="up"] {
  color: var(--good-ink);
}

.stat__delta[data-dir="down"] {
  color: var(--critical-ink);
}

.stat__delta[data-dir="flat"] {
  color: var(--ink-3);
}

.hero {
  font-size: var(--fs-hero);
  font-weight: 660;
  letter-spacing: -0.03em;
  line-height: 1;
}

.meter {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  min-width: 0;
}

.meter__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
}

.meter__label {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 560;
  min-width: 0;
}

.meter__swatch {
  width: 0.625rem;
  height: 0.625rem;
  flex: none;
  border-radius: 3px;
  background: var(--swatch, var(--series-other));
}

.meter__value {
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
  white-space: nowrap;
}

.meter__bar {
  display: block;
  width: 100%;
}

/* A meter in a table cell. The column heading has already named what is being
   measured, so the label and the percentage line are redundant - and at three
   lines per row they bury the rows. */
.meter--compact {
  gap: 0.25rem;
  min-width: 7rem;
}

.meter--compact .meter__head {
  justify-content: flex-start;
}

.meter--compact .meter__value {
  font-size: var(--fs-xs);
}

.meter__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

.meter__reset {
  margin-left: auto;
}

.meter__over {
  padding: 0 0.375rem;
  border-radius: var(--r-full);
  background: var(--critical-soft);
  color: var(--critical-ink);
  font-weight: 620;
}

.meter-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* A short list of things that happened, newest first: a severity marker in a
   fixed-width gutter so the text starts on one line down the whole list. */
.feed {
  display: flex;
  flex-direction: column;
}

.feed__item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}

.feed__item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.feed__item:first-child {
  padding-top: 0;
}

.feed__mark {
  flex: none;
  width: 5.5rem;
}

.feed__body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

/* Chips that wrap, for a set with no ranking - unassessed vendors, admins
   missing a second factor. */
.pill-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

/* ------------------------------------------------------ 7. Tables */

.table-wrap {
  overflow-x: auto;
  border-top: 1px solid var(--border);
}

table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.table th,
.table td {
  padding: 0.625rem var(--sp-4);
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}

.table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 620;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  z-index: 1;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

/* For a table that sits inside a card as a secondary read rather than being the
   point of the page - recent events, reverted actions. */
.table--tight th,
.table--tight td {
  padding: 0.375rem var(--sp-3);
}

.table--tight thead th {
  background: transparent;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table .shrink {
  width: 1%;
  white-space: nowrap;
}

.table a {
  color: inherit;
  font-weight: 560;
  text-decoration: none;
}

.table a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.identity {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0;
}

.avatar {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  flex: none;
  border-radius: var(--r-full);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.identity__text {
  min-width: 0;
}

.identity__name {
  display: block;
  font-weight: 560;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity__meta {
  display: block;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pagination {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

/* -- Review queue ---------------------------------------------------------
   The access-request queue. Deliberately NOT a table: each row is free text of
   no predictable length, read one at a time and decided on the spot, and a
   column layout gives the justification a narrow ragged well while forcing the
   decision controls into a cell too tight to hold them. A card per request
   gives the prose the full width and the actions their own line. */

.requests {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.request {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-1);
}

/* A pending request is the one that wants attention, so it gets the accent
   edge. Decided ones recede rather than disappear - the queue is also the
   record of what was granted. */
.request[data-status="pending"] {
  border-left: 3px solid var(--accent);
}

.request:not([data-status="pending"]) {
  background: transparent;
}

.request__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.request__status {
  flex: none;
}

/* Label-over-value pairs. A GRID, not a flex row: the columns have to land at
   the same x on every card or the eye cannot run down them, and flex would set
   each card's columns from its own content - one card's "Tier asked for" ending
   up three inches right of the next one's. */
.request__facts {
  display: grid;
  grid-template-columns: 8rem minmax(0, 1fr) 12rem;
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
  /* Capped so the three stay a group. Left to fill a wide console the middle
     column absorbs every spare inch and strands "Tier asked for" against the
     far edge, reading as an unrelated thing rather than the third of three. */
  max-width: 52rem;
}

.request__facts > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.request__facts dt {
  font-size: var(--fs-xs);
  font-weight: 620;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.request__facts dd {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ink-1);
}

/* The applicant's own words, marked as a quotation: it is the only text on the
   card that is not ours, and the rule on the leading edge says so without
   needing quote marks around user input. */
.request__why {
  margin: 0;
  padding: var(--sp-2) 0 var(--sp-2) var(--sp-4);
  border-left: 2px solid var(--border-strong);
  color: var(--ink-1);
  font-size: var(--fs-sm);
  line-height: 1.55;
  /* Free text from a form: a pasted URL or an unbroken string must not widen
     the card and start the page scrolling sideways. */
  overflow-wrap: anywhere;
}

.request__why--empty {
  border-left-color: var(--border);
  color: var(--ink-3);
  font-style: italic;
}

.request__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
}

/* A row, not a stack. `.input--sm` is `flex: 1 1 8rem`, which in a column
   container resolves against the CROSS axis and grows the box to the height of
   the card - so the note must share a horizontal line with its buttons. */
.request__decide {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  width: 100%;
}

.request__decide .input--sm {
  flex: 1 1 12rem;
  max-width: 22rem;
}

.request__actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-left: auto;
}

.request__decision {
  margin: 0;
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

.request__note {
  display: block;
  margin-top: var(--sp-1);
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

/* Narrow: two columns, with the affiliation - the one fact that runs long -
   given the full width rather than squeezed into half of a phone. Keyed on a
   class, not `nth-child`, because the affiliation row is absent entirely when
   the applicant's account has been deleted. */
@media (max-width: 52rem) {
  .request__facts {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .request__fact--wide {
    grid-column: 1 / -1;
  }

  .request__actions {
    margin-left: 0;
    width: 100%;
  }

  .request__actions .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
}

/* ------------------------------------------------------ 8. Charts */

.chart {
  display: block;
  width: 100%;
}

.chart-empty {
  display: grid;
  place-items: center;
  margin: 0;
  padding: var(--sp-4);
  color: var(--ink-3);
  font-size: var(--fs-sm);
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
}

.spark {
  display: block;
  overflow: visible;
}

.barchart,
.donut {
  display: block;
}

/* Each bar is a <g> carrying its own <title>, so the browser shows a native
   tooltip on hover; the lift just confirms which row the tooltip belongs to. */
.bar-row {
  transition: opacity 0.12s ease;
}

.barchart:hover .bar-row:not(:hover) {
  opacity: 0.55;
}

/* Text inside a chart wears text tokens, never the series colour. */
.barchart .chart-label,
.donut-label {
  fill: var(--ink-2);
  font-family: var(--font);
  font-size: 11px;
}

.barchart .chart-value {
  fill: var(--ink-1);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.donut-value {
  fill: var(--ink-1);
  font-family: var(--font);
  font-size: 20px;
  font-weight: 640;
}

.donut-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  font-size: var(--fs-sm);
}

.legend__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.legend__swatch {
  width: 0.625rem;
  height: 0.625rem;
  flex: none;
  border-radius: 3px;
  background: var(--swatch, var(--series-other));
}

.legend__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend__value {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.donut-row {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  flex-wrap: wrap;
}

.donut-row .legend {
  flex: 1 1 12rem;
}

/* ------------------------------ 9. Tabs, code blocks, copy */

.tabs > input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.tabs__list {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow-x: auto;
}

.tabs__list > label {
  padding: 0.3rem 0.75rem;
  border-radius: var(--r-xs);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 560;
  white-space: nowrap;
  cursor: pointer;
}

.tabs__list > label:hover {
  color: var(--ink-1);
}

.tabs__panel {
  display: none;
  margin-top: var(--sp-3);
}

/* :has lets one generic rule drive any tab set, so a template can add a tab
   without touching this stylesheet. */
.tabs:has(> input:nth-of-type(1):checked) > .tabs__panel:nth-of-type(1),
.tabs:has(> input:nth-of-type(2):checked) > .tabs__panel:nth-of-type(2),
.tabs:has(> input:nth-of-type(3):checked) > .tabs__panel:nth-of-type(3),
.tabs:has(> input:nth-of-type(4):checked) > .tabs__panel:nth-of-type(4),
.tabs:has(> input:nth-of-type(5):checked) > .tabs__panel:nth-of-type(5),
.tabs:has(> input:nth-of-type(6):checked) > .tabs__panel:nth-of-type(6) {
  display: block;
}

.tabs:has(> input:nth-of-type(1):checked) .tabs__list > label:nth-child(1),
.tabs:has(> input:nth-of-type(2):checked) .tabs__list > label:nth-child(2),
.tabs:has(> input:nth-of-type(3):checked) .tabs__list > label:nth-child(3),
.tabs:has(> input:nth-of-type(4):checked) .tabs__list > label:nth-child(4),
.tabs:has(> input:nth-of-type(5):checked) .tabs__list > label:nth-child(5),
.tabs:has(> input:nth-of-type(6):checked) .tabs__list > label:nth-child(6) {
  background: var(--surface-1);
  color: var(--ink-1);
  box-shadow: var(--shadow-1);
}

.tabs:has(> input:nth-of-type(1):focus-visible) .tabs__list > label:nth-child(1),
.tabs:has(> input:nth-of-type(2):focus-visible) .tabs__list > label:nth-child(2),
.tabs:has(> input:nth-of-type(3):focus-visible) .tabs__list > label:nth-child(3),
.tabs:has(> input:nth-of-type(4):focus-visible) .tabs__list > label:nth-child(4),
.tabs:has(> input:nth-of-type(5):focus-visible) .tabs__list > label:nth-child(5),
.tabs:has(> input:nth-of-type(6):focus-visible) .tabs__list > label:nth-child(6) {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

/* No :has support: show every panel rather than hide all of them. Each panel
   carries its own heading, so the page stays usable, just longer. */
@supports not selector(:has(*)) {
  .tabs__panel {
    display: block;
  }

  .tabs__list {
    display: none;
  }
}

/* The segmented control above, but built from links instead of radios, for when
   each tab is its own URL and must survive a reload and a shared link. Kept
   separate from `.tabs` on purpose: that set is driven by :has() over radio
   inputs, and mixing the two silently breaks both. */
.tabnav {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow-x: auto;
  max-width: 100%;
  /* `.content` and `.card` are column flex containers, which stretch their
     children edge to edge. A segmented control is sized by its labels, so it
     has to opt out or it spans the whole page. */
  align-self: flex-start;
}

.tab {
  padding: 0.3rem 0.75rem;
  border-radius: var(--r-xs);
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 560;
  text-decoration: none;
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink-1);
}

.tab--on {
  background: var(--surface-1);
  color: var(--ink-1);
  box-shadow: var(--shadow-1);
}

.codeblock {
  position: relative;
  margin: 0;
  padding: var(--sp-4);
  padding-right: 6rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow-x: auto;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  line-height: 1.6;
  color: var(--ink-1);
  tab-size: 2;
}

.codeblock code {
  font: inherit;
  white-space: pre;
}

/* Evidence dumps inside a <details> or a table cell: no copy button to clear,
   so the 6rem right gutter would just be dead space. */
.codeblock--tight {
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-xs);
  line-height: 1.45;
  max-height: 18rem;
  overflow: auto;
}

.copy {
  position: absolute;
  top: var(--sp-2);
  right: var(--sp-2);
}

.copy[data-copied="1"] {
  background: var(--good-soft);
  border-color: var(--good);
  color: var(--good-ink);
}

.inline-code {
  padding: 0.1em 0.35em;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.875em;
  word-break: break-all;
}

.secret {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
}

.secret code {
  flex: 1 1 18rem;
  min-width: 0;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  word-break: break-all;
}

.alarm {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--r-sm);
  border: 1px solid var(--warning);
  background: var(--warning-soft);
  color: var(--ink-1);
}

.alarm--critical {
  border-color: var(--critical);
  background: var(--critical-soft);
}

.alarm__title {
  font-weight: 640;
}

/* ------------------- 10. Badges, chips, empty states, flash */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.5rem;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: currentColor;
}

.badge--plain::before {
  display: none;
}

.badge[data-tone="good"] {
  background: var(--good-soft);
  border-color: transparent;
  color: var(--good-ink);
}

/* Amber on a light surface needs a darker ink to clear AA; on a dark surface
   the token itself already does. One property, themed like every other. */
.badge[data-tone="warn"] {
  background: var(--warning-soft);
  border-color: transparent;
  color: var(--warning-ink);
}

.badge[data-tone="bad"] {
  background: var(--critical-soft);
  border-color: transparent;
  color: var(--critical-ink);
}

.badge[data-tone="accent"] {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.125rem 0.5rem;
  border-radius: var(--r-full);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  font-weight: 560;
  color: var(--ink-2);
}

.chip__dot {
  width: 0.5rem;
  height: 0.5rem;
  flex: none;
  border-radius: 50%;
  background: var(--swatch, var(--series-other));
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-7) var(--sp-4);
  text-align: center;
  color: var(--ink-2);
}

.empty__art {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: var(--r-lg);
  background: var(--accent-soft);
  color: var(--accent);
}

.empty__title {
  font-size: var(--fs-md);
  font-weight: 620;
  color: var(--ink-1);
}

.empty__body {
  max-width: 44ch;
  font-size: var(--fs-sm);
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--surface-1);
  box-shadow: var(--shadow-1);
  font-size: var(--fs-sm);
}

.flash[data-level="ok"] {
  border-color: var(--good);
  background: var(--good-soft);
  color: var(--good-ink);
}

.flash[data-level="warn"] {
  border-color: var(--warning);
  background: var(--warning-soft);
}

.flash[data-level="error"] {
  border-color: var(--critical);
  background: var(--critical-soft);
  color: var(--critical-ink);
}

.flash__close {
  margin-left: auto;
}

/* A flash is transient and reports what just happened; a callout is permanent
   page furniture that says "read this before you carry on". Same anatomy, but
   the accent rule on the leading edge is what stops a reader skimming a
   documentation page straight past it. */
.callout {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--fs-sm);
}

.callout > .icon {
  flex: none;
  margin-top: 0.15em;
  color: var(--accent);
}

.callout p {
  margin: 0;
}

.callout p + p {
  margin-top: var(--sp-2);
}

dialog.modal {
  width: min(38rem, calc(100vw - 2rem));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-1);
  color: var(--ink-1);
  box-shadow: var(--shadow-3);
}

dialog.modal::backdrop {
  background: var(--overlay);
}

/* A form with enough fields to be worth scrolling: the provider form carries
   the whole wire-format config. Capped against the viewport so the footer's
   Save button stays reachable on a laptop rather than running off the bottom. */
dialog.modal--wide {
  width: min(46rem, calc(100vw - 2rem));
}

dialog.modal--wide .modal__body {
  max-height: min(68vh, 44rem);
  overflow-y: auto;
}

.modal__head,
.modal__body,
.modal__foot {
  padding: var(--sp-4);
}

.modal__head {
  border-bottom: 1px solid var(--border);
  font-weight: 640;
}

.modal__foot {
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
}

/* A stored system prompt, shown as written. `pre-wrap` because the text is
   authored with deliberate line breaks and a model reads them, so collapsing
   them here would show something other than what is sent. */
.prompt-body {
  margin: 0 0 var(--sp-3);
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: var(--fs-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 18rem;
  overflow-y: auto;
}

/* Progressive disclosure with no JavaScript, which is what CSP and the
   no-Node rule both want: <details> opens on its own. Used for the provider
   form's wire-format settings, which most vendors never need to touch. */
.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

.disclosure > summary {
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  font-weight: 600;
  font-size: var(--fs-sm);
}

.disclosure > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.disclosure > .stack {
  padding: 0 var(--sp-4) var(--sp-4);
}

.disclosure textarea {
  width: 100%;
  resize: vertical;
}

.dl {
  display: grid;
  grid-template-columns: minmax(7rem, auto) minmax(0, 1fr);
  gap: var(--sp-2) var(--sp-4);
  margin: 0;
  font-size: var(--fs-sm);
}

.dl dt {
  color: var(--ink-3);
}

.dl dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.provider-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  border-top: 3px solid var(--swatch, var(--series-other));
  box-shadow: var(--shadow-1);
}

.provider-card__head {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.provider-card__name {
  font-weight: 620;
}

.result {
  padding: var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.result[data-ok="1"] {
  border-color: var(--good);
  background: var(--good-soft);
  color: var(--good-ink);
}

.result[data-ok="0"] {
  border-color: var(--critical);
  background: var(--critical-soft);
  color: var(--critical-ink);
}

/* ------------------------------------------------ 11. HTMX states */

.htmx-indicator {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
}

/* Hold the previous render at reduced opacity instead of flashing a skeleton. */
.htmx-request[data-live] {
  opacity: 0.55;
  transition: opacity 0.12s ease;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ------------------------------------------------- 12. Playground */

/* The transcript scrolls inside itself rather than growing the page, so the
   composer and the key field stay put while a long reply streams in. */
.pg-log {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-height: 26rem;
  min-height: 8rem;
  overflow-y: auto;
  padding: var(--sp-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  scroll-behavior: smooth;
}

.pg-log__empty {
  margin: auto;
  color: var(--ink-3);
  font-size: var(--fs-sm);
}

.pg-turn {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  max-width: 44rem;
}

.pg-turn[data-role="user"] {
  align-self: flex-end;
  align-items: flex-end;
}

.pg-turn__role {
  font-size: var(--fs-xs);
  font-weight: 620;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* `pre-wrap` because a model's own line breaks are part of what you are
   testing, and `break-word` because one long token must not widen the page. */
.pg-turn__body {
  margin: 0;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-1);
  font-size: var(--fs-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.pg-turn[data-role="user"] .pg-turn__body {
  background: var(--accent-soft);
  border-color: var(--accent-border);
}

.pg-turn[data-role="error"] .pg-turn__body {
  background: var(--critical-soft);
  border-color: var(--critical);
  color: var(--critical-ink);
}

.pg-turn[data-pending] .pg-turn__body {
  color: var(--ink-3);
}

/* A dozen short pairs read better paired up than as one tall column. */
@media (min-width: 48rem) {
  [data-pg-meta] {
    grid-template-columns: minmax(7rem, auto) minmax(0, 1fr) minmax(7rem, auto) minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pg-log {
    scroll-behavior: auto;
  }
}

/* ------------------------------------------------- 13. Responsive */

@media (max-width: 60rem) {
  .split {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 52rem) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    display: none;
  }

  .mobilenav {
    display: block;
  }

  .content {
    /* 16px gutter, and nothing inside may scroll the page sideways. */
    padding: var(--sp-4) var(--sp-4);
    gap: var(--sp-4);
  }

  .topbar {
    padding: var(--sp-3) var(--sp-4);
  }

  .page-head h1 {
    font-size: var(--fs-lg);
  }

  .hero {
    font-size: 2.25rem;
  }

  .table th,
  .table td {
    padding: 0.5rem var(--sp-3);
  }

  .codeblock {
    padding-right: var(--sp-4);
    padding-top: 2.75rem;
  }

  .copy {
    top: var(--sp-2);
    right: var(--sp-2);
  }
}

@media (max-width: 30rem) {
  .btn-group {
    width: 100%;
    justify-content: space-between;
  }

  .page-head__actions {
    width: 100%;
  }

  .page-head__actions .btn {
    flex: 1 1 auto;
  }
}

@media print {
  .sidebar,
  .topbar,
  .page-head__actions,
  .filters,
  .copy {
    display: none !important;
  }

  .card,
  .stat {
    box-shadow: none;
    break-inside: avoid;
  }
}

/* ------------------------------------------------- 14. Timeline & log rows */
/* Shared by /admin/timeline and /admin/logs. One row is a fixed-width time
   gutter plus a body, so the timestamps form a readable column at any zoom and
   a long message wraps under itself rather than pushing the clock off-screen. */

.tl {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.tl__row {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-2);
  border-top: 1px solid var(--border);
  /* The severity stripe. Transparent by default so an ordinary row is quiet
     and a bad one is findable by scrolling rather than by reading. */
  box-shadow: inset 3px 0 0 transparent;
}

.tl__row:first-child { border-top: 0; }

.tl__row--warning,
.tl__row--warn { box-shadow: inset 3px 0 0 var(--warning); }

.tl__row--error,
.tl__row--critical { box-shadow: inset 3px 0 0 var(--critical); }

.tl__time {
  font-size: var(--fs-xs);
  color: var(--ink-2);
  line-height: 1.5;
  white-space: nowrap;
}

.tl__date {
  display: block;
  color: var(--ink-3);
}

.tl__body { min-width: 0; }

.tl__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.tl__title {
  font-size: var(--fs-sm);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.tl__link { color: var(--ink-3); line-height: 1; }
.tl__link:hover { color: var(--accent); }

.tl__detail {
  margin: var(--sp-1) 0 0;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.tl__meta {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-1);
  font-size: var(--fs-xs);
  color: var(--ink-3);
}

.tl__more { margin-top: var(--sp-2); }
.tl__more summary { cursor: pointer; font-size: var(--fs-xs); color: var(--ink-3); }
.tl__more summary:hover { color: var(--ink-1); }

.tl__pre {
  margin: var(--sp-2) 0 0;
  padding: var(--sp-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 24rem;
}

/* Source toggles on the timeline filter form. */
.timeline-sources {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin: var(--sp-4) 0 0;
  padding: 0;
  border: 0;
}

.timeline-sources legend { padding: 0; }

.chip-check {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  cursor: pointer;
  user-select: none;
}

.chip-check:hover { background: var(--surface-2); }
.chip-check input { margin: 0; }

@media (max-width: 40rem) {
  .tl__row { grid-template-columns: 1fr; gap: var(--sp-1); }
  .tl__date { display: inline; margin-left: var(--sp-2); }
}
