/* CivicLine design foundation — token system + shared component contracts (#2649).

   Three layers, in dependency order:
     1. PRIMITIVES — the raw palette and scales. The only place a literal value
        is allowed to live.
     2. SEMANTIC — role names (surface, text, accent, danger, focus ring) built
        from primitives. Surfaces should reach for these, not for a primitive.
     3. COMPONENT — per-component knobs, expressed in semantic tokens.
   The component rules at the bottom consume layers 2 and 3 only, never a
   literal. tests/test_civicline_tokens_2649.py enforces that rule, checks the
   palette's WCAG contrast ratios, and checks that every status variant carries
   a shape as well as a color.

   SINGLE SOURCE. Ships in lg-core-base, the one package every CivicLine web
   app depends on; each app serves it at the relative path `ui/civicline.css`
   through lg_core_base.ui. Never copy it into a product's static directory —
   tests/test_ui_assets_core_base.py fails if a copy appears.

   Additive: every name is namespaced `cl-` / `--cl-`, so linking this file
   changes nothing on a surface until that surface opts in. Migration status
   lives in docs/DESIGN_SYSTEM.md.

   Layout is validated at 375 / 768 / 1024 / 1440 px (scripts/a11y/surfaces.json).
   768px is the one breakpoint here; custom properties cannot be used in media
   queries, so it is written literally and documented in the charter. */

/* ═══ TYPEFACES ═════════════════════════════════════════════════════════════ */
/* Self-hosted beside this file (served at ui/<name>, same origin — no font CDN,
   so no resident's page view is reported to a third party). Variable weight,
   so --cl-weight-medium (600) is a real weight, not a synthesized one. The
   unicode-range split means a page downloads only the subsets it renders:
   Latin covers English and Spanish; Latin Extended loads only on demand.
   SIL Open Font License 1.1 — texts in ui/assets/licenses/.
   Public Sans (the U.S. Web Design System's typeface) for everything, code and
   reference numbers included: its zero is plain. The owner's rule: no product
   shows a slashed or dotted zero. Reference numbers that need equal-width
   digits get font-variant-numeric: tabular-nums. */
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("public-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}
@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("public-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

/* ═══ LAYER 1: PRIMITIVES ═══════════════════════════════════════════════════ */
:root {
  /* Navy / blue / light-neutral. High contrast, no decorative gradients. */
  --cl-navy-900: #0f172a;
  --cl-navy-800: #1e293b;
  --cl-slate-600: #475569;
  --cl-slate-500: #64748b;
  --cl-slate-300: #cbd5e1;
  --cl-slate-200: #e2e8f0;
  --cl-slate-100: #f1f5f9;
  --cl-slate-50: #f8fafc;
  --cl-white: #ffffff;
  --cl-blue-700: #1d4ed8;
  --cl-blue-600: #2563eb;
  --cl-blue-50: #eff6ff;
  /* State hues. Each text/surface pair is contrast-checked by the test. */
  --cl-green-800: #166534;
  --cl-green-50: #dcfce7;
  --cl-amber-800: #854d0e;
  --cl-amber-50: #fef9c3;
  --cl-red-800: #991b1b;
  --cl-red-50: #fee2e2;
  /* Dark palette. Deep navy, not black; the state hues flip to light text on a
     deep tint. Only the dark semantic blocks in layer 2 use these. */
  --cl-ink-950: #0b1220;
  --cl-ink-900: #121b2e;
  --cl-ink-850: #1a2540;
  --cl-ink-800: #26324a;
  --cl-ink-700: #3a4866;
  --cl-mist-100: #e5ebf3;
  --cl-mist-400: #9aa8bd;
  --cl-blue-300: #93c5fd;
  --cl-blue-400: #60a5fa;
  --cl-blue-950: #0f2140;
  --cl-green-300: #86efac;
  --cl-green-950: #0d2a1b;
  --cl-amber-300: #fcd34d;
  --cl-amber-950: #2d2306;
  --cl-red-300: #fca5a5;
  --cl-red-950: #3a1212;

  --cl-font-sans: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --cl-font-mono: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Type scale */
  --cl-text-1: 0.75rem;
  --cl-text-2: 0.85rem;
  --cl-text-3: 0.95rem;
  --cl-text-4: 1.1rem;
  --cl-text-5: 1.4rem;
  --cl-weight-normal: 400;
  --cl-weight-medium: 600;
  --cl-weight-bold: 700;
  --cl-leading-tight: 1.25;
  --cl-leading-normal: 1.5;
  --cl-tracking-wide: 0.08em;

  /* Spacing scale (4px base) */
  --cl-space-1: 0.25rem;
  --cl-space-2: 0.5rem;
  --cl-space-3: 0.75rem;
  --cl-space-4: 1rem;
  --cl-space-5: 1.5rem;
  --cl-space-6: 2rem;

  --cl-radius-1: 0.3rem;
  --cl-radius-2: 0.6rem;
  --cl-radius-3: 0.9rem;
  --cl-radius-pill: 999px;

  --cl-hairline: 1px;
  --cl-ring-width: 3px;
  --cl-ring-offset: 2px;

  /* Elevation. Flat by default; shadow is for content that floats over other
     content, not for decoration. */
  --cl-shadow-0: none;
  --cl-shadow-1: 0 1px 2px rgba(15, 23, 42, 0.08);
  --cl-shadow-2: 0 6px 16px rgba(15, 23, 42, 0.12);
}

/* ═══ LAYER 2: SEMANTIC ═════════════════════════════════════════════════════ */
:root {
  --cl-color-canvas: var(--cl-slate-50);
  --cl-color-surface: var(--cl-white);
  --cl-color-surface-muted: var(--cl-slate-100);
  --cl-color-text: var(--cl-navy-900);
  --cl-color-text-muted: var(--cl-slate-600);
  --cl-color-text-inverse: var(--cl-white);
  --cl-color-accent: var(--cl-blue-600);
  --cl-color-accent-strong: var(--cl-blue-700);
  --cl-color-accent-hover: var(--cl-blue-700);
  --cl-color-accent-surface: var(--cl-blue-50);
  --cl-color-border: var(--cl-slate-200);
  --cl-color-border-strong: var(--cl-slate-300);

  --cl-color-success-text: var(--cl-green-800);
  --cl-color-success-surface: var(--cl-green-50);
  --cl-color-warning-text: var(--cl-amber-800);
  --cl-color-warning-surface: var(--cl-amber-50);
  --cl-color-danger-text: var(--cl-red-800);
  --cl-color-danger-surface: var(--cl-red-50);
  --cl-color-info-text: var(--cl-blue-700);
  --cl-color-info-surface: var(--cl-blue-50);
  --cl-color-neutral-text: var(--cl-slate-600);
  --cl-color-neutral-surface: var(--cl-slate-100);

  /* Focus. Same blue and geometry as the global ring in a11y.css, named here
     so a component can restate it without re-deciding it. */
  --cl-color-focus-ring: var(--cl-blue-600);
  --cl-focus-ring: var(--cl-ring-width) solid var(--cl-color-focus-ring);
  --cl-focus-ring-offset: var(--cl-ring-offset);

  --cl-font-body: var(--cl-font-sans);
  --cl-font-code: var(--cl-font-mono);

  /* 2.5.5 Target Size: the floor for anything a finger has to hit. */
  --cl-target-min: 2.75rem;

  /* Native controls and scrollbars follow the palette. Restated on the shell
     and on cards, so a card on a page that has its own dark chrome keeps light
     controls until that page opts in to the themes. */
  --cl-scheme: light;
  color-scheme: light;
}

/* Dark. A page opts in by putting `data-cl-themed` on <html> — a page whose own
   CSS is not yet all tokens would turn half dark, so linking this file is not
   enough. On an opted-in page the theme follows the OS unless the person chose
   one: `data-theme="light"` / `"dark"` on <html>, set by civicline.js. Dark is
   for the screen only: printing (a receipt, a letter) always uses the light
   palette, whatever the theme. The two
   blocks below must stay identical; tests/test_civicline_tokens_2649.py checks
   that, and checks every text/surface pair in both palettes. */
@media screen and (prefers-color-scheme: dark) {
  :root[data-cl-themed]:not([data-theme="light"]) {
    --cl-color-canvas: var(--cl-ink-950);
    --cl-color-surface: var(--cl-ink-900);
    --cl-color-surface-muted: var(--cl-ink-850);
    --cl-color-text: var(--cl-mist-100);
    --cl-color-text-muted: var(--cl-mist-400);
    --cl-color-text-inverse: var(--cl-white);
    --cl-color-accent: var(--cl-blue-600);
    --cl-color-accent-strong: var(--cl-blue-300);
    --cl-color-accent-hover: var(--cl-blue-700);
    --cl-color-accent-surface: var(--cl-blue-950);
    --cl-color-border: var(--cl-ink-800);
    --cl-color-border-strong: var(--cl-ink-700);
    --cl-color-success-text: var(--cl-green-300);
    --cl-color-success-surface: var(--cl-green-950);
    --cl-color-warning-text: var(--cl-amber-300);
    --cl-color-warning-surface: var(--cl-amber-950);
    --cl-color-danger-text: var(--cl-red-300);
    --cl-color-danger-surface: var(--cl-red-950);
    --cl-color-info-text: var(--cl-blue-300);
    --cl-color-info-surface: var(--cl-blue-950);
    --cl-color-neutral-text: var(--cl-slate-300);
    --cl-color-neutral-surface: var(--cl-navy-800);
    --cl-color-focus-ring: var(--cl-blue-400);
    --cl-scheme: dark;
    color-scheme: dark;
  }
}
@media screen {
:root[data-cl-themed][data-theme="dark"] {
  --cl-color-canvas: var(--cl-ink-950);
  --cl-color-surface: var(--cl-ink-900);
  --cl-color-surface-muted: var(--cl-ink-850);
  --cl-color-text: var(--cl-mist-100);
  --cl-color-text-muted: var(--cl-mist-400);
  --cl-color-text-inverse: var(--cl-white);
  --cl-color-accent: var(--cl-blue-600);
  --cl-color-accent-strong: var(--cl-blue-300);
  --cl-color-accent-hover: var(--cl-blue-700);
  --cl-color-accent-surface: var(--cl-blue-950);
  --cl-color-border: var(--cl-ink-800);
  --cl-color-border-strong: var(--cl-ink-700);
  --cl-color-success-text: var(--cl-green-300);
  --cl-color-success-surface: var(--cl-green-950);
  --cl-color-warning-text: var(--cl-amber-300);
  --cl-color-warning-surface: var(--cl-amber-950);
  --cl-color-danger-text: var(--cl-red-300);
  --cl-color-danger-surface: var(--cl-red-950);
  --cl-color-info-text: var(--cl-blue-300);
  --cl-color-info-surface: var(--cl-blue-950);
  --cl-color-neutral-text: var(--cl-slate-300);
  --cl-color-neutral-surface: var(--cl-navy-800);
  --cl-color-focus-ring: var(--cl-blue-400);
  --cl-scheme: dark;
  color-scheme: dark;
}
}

/* ═══ LAYER 3: COMPONENT TOKENS ═════════════════════════════════════════════ */
:root {
  --cl-shell-max-width: 60rem;
  --cl-shell-inset: var(--cl-space-5);
  --cl-shell-gap: var(--cl-space-5);

  --cl-header-border: var(--cl-color-border);
  --cl-header-gap: var(--cl-space-2);
  --cl-header-title-size: var(--cl-text-5);
  --cl-eyebrow-color: var(--cl-color-accent-strong);

  --cl-nav-gap: var(--cl-space-2);
  --cl-nav-link-color: var(--cl-color-text-muted);
  --cl-nav-link-inset: var(--cl-space-2);
  --cl-nav-current-color: var(--cl-color-text);
  --cl-nav-current-surface: var(--cl-color-surface-muted);

  --cl-button-bg: var(--cl-color-accent);
  --cl-button-fg: var(--cl-color-text-inverse);
  --cl-button-bg-hover: var(--cl-color-accent-hover);
  --cl-button-border: transparent;
  --cl-button-inset: var(--cl-space-3) var(--cl-space-5);
  --cl-button-radius: var(--cl-radius-1);

  --cl-field-gap: var(--cl-space-2);
  --cl-field-label-color: var(--cl-color-text-muted);
  --cl-field-bg: var(--cl-color-surface);
  --cl-field-fg: var(--cl-color-text);
  --cl-field-border: var(--cl-color-border-strong);
  --cl-field-inset: var(--cl-space-3);
  --cl-field-radius: var(--cl-radius-1);
  --cl-field-error-color: var(--cl-color-danger-text);

  --cl-table-border: var(--cl-color-border);
  --cl-table-head-surface: var(--cl-color-surface-muted);
  --cl-table-cell-inset: var(--cl-space-2) var(--cl-space-3);

  --cl-card-bg: var(--cl-color-surface);
  --cl-card-border: var(--cl-color-border);
  --cl-card-inset: var(--cl-space-4) var(--cl-space-5);
  --cl-card-radius: var(--cl-radius-2);
  --cl-card-shadow: var(--cl-shadow-1);

  --cl-notice-inset: var(--cl-space-3) var(--cl-space-4);
  --cl-notice-radius: var(--cl-radius-1);
  --cl-notice-accent-width: var(--cl-space-1);

  --cl-status-inset: var(--cl-space-1) var(--cl-space-3);
  --cl-status-radius: var(--cl-radius-pill);
  --cl-status-size: var(--cl-text-2);

  --cl-state-inset: var(--cl-space-6) var(--cl-space-4);
  --cl-state-color: var(--cl-color-text-muted);

  /* Shared app bar (#3123): one per page, above everything product-owned. */
  --cl-appbar-bg: var(--cl-color-surface);
  --cl-appbar-border: var(--cl-color-border);
  --cl-appbar-inset: var(--cl-space-2) var(--cl-space-4);
  --cl-appbar-gap: var(--cl-space-3) var(--cl-space-5);
  --cl-appbar-mark-size: var(--cl-space-6);
  --cl-env-bg: var(--cl-color-warning-surface);
  --cl-env-fg: var(--cl-color-warning-text);
  --cl-env-inset: var(--cl-space-1) var(--cl-space-4);

  --cl-theme-inset: 0 var(--cl-space-3);
  --cl-theme-on-bg: var(--cl-color-text);
  --cl-theme-on-fg: var(--cl-color-surface);

  --cl-needs-bg: var(--cl-color-warning-surface);
  --cl-needs-fg: var(--cl-color-text);
  --cl-needs-accent: var(--cl-color-warning-text);
  --cl-needs-inset: var(--cl-space-3) var(--cl-space-4);

  --cl-src-inset: 0 var(--cl-space-1);

  --cl-ref-bg: var(--cl-color-surface-muted);
  --cl-ref-inset: 0 0 0 var(--cl-space-2);

  --cl-row-inset: var(--cl-space-2) var(--cl-space-4);
  --cl-row-gap: var(--cl-space-3);
  --cl-row-min: 3.5rem;
  --cl-row-columns: minmax(0, 8.5rem) minmax(0, 1fr) minmax(0, 4.5rem);
  --cl-row-current-bg: var(--cl-color-accent-surface);
  --cl-row-hover-bg: var(--cl-color-surface-muted);

  --cl-step-mark: var(--cl-space-6);
}

/* ═══ COMPONENTS ════════════════════════════════════════════════════════════
   Rules below use layer-2 / layer-3 tokens only. No literal colors, spacing,
   radii or type sizes past this line — the test fails the build if one appears.
   Every component is keyboard-operable with a visible ring, and every state
   that means something says so in text, not only in color. */

/* ── hidden means hidden ─────────────────────────────────────────────────── */
/* A component that sets its own display (.cl-field is flex) would otherwise
   override the browser's [hidden] rule and show what a page hid — a phone
   field before the resident asked for texts. Two attribute selectors outrank
   any single-class display rule. */
[class^="cl-"][hidden], [class*=" cl-"][hidden] { display: none; }

/* ── App shell, header, navigation ────────────────────────────────────────── */
.cl-shell {
  color-scheme: var(--cl-scheme);
  background: var(--cl-color-canvas);
  color: var(--cl-color-text);
  font-family: var(--cl-font-body);
  line-height: var(--cl-leading-normal);
  display: flex;
  flex-direction: column;
  gap: var(--cl-shell-gap);
  max-width: var(--cl-shell-max-width);
  width: 100%;
  margin: 0 auto;
  padding: var(--cl-shell-inset);
  /* A long unbreakable child (a reference number, a file input) must not widen
     the shell past the viewport on a phone. */
  min-width: 0;
}

.cl-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--cl-header-gap);
  padding: 0 0 var(--cl-space-3);
  border-bottom: var(--cl-hairline) solid var(--cl-header-border);
}
.cl-header__title {
  margin: 0;
  font-size: var(--cl-header-title-size);
  line-height: var(--cl-leading-tight);
  color: var(--cl-color-text);
}
.cl-eyebrow {
  margin: 0;
  font-size: var(--cl-text-1);
  font-weight: var(--cl-weight-medium);
  letter-spacing: var(--cl-tracking-wide);
  text-transform: uppercase;
  color: var(--cl-eyebrow-color);
}

.cl-nav {
  display: flex;
  flex-wrap: wrap;
  gap: var(--cl-nav-gap);
  align-items: center;
}
.cl-nav__link {
  color: var(--cl-nav-link-color);
  font-size: var(--cl-text-2);
  text-decoration: none;
  padding: var(--cl-nav-link-inset);
  border-radius: var(--cl-radius-1);
}
.cl-nav__link:hover { color: var(--cl-color-accent-strong); }
/* Current page: weight and background, not color alone. A surface that writes
   aria-current="false" on the others must not match here. */
.cl-nav__link[aria-current]:not([aria-current="false"]) {
  color: var(--cl-nav-current-color);
  background: var(--cl-nav-current-surface);
  font-weight: var(--cl-weight-bold);
}

/* ── Buttons and links ───────────────────────────────────────────────────── */
.cl-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--cl-space-2);
  min-height: var(--cl-target-min);
  padding: var(--cl-button-inset);
  border: var(--cl-hairline) solid var(--cl-button-border);
  border-radius: var(--cl-button-radius);
  background: var(--cl-button-bg);
  color: var(--cl-button-fg);
  font: inherit;
  font-size: var(--cl-text-3);
  font-weight: var(--cl-weight-medium);
  cursor: pointer;
}
.cl-button:hover { background: var(--cl-button-bg-hover); }
.cl-button[disabled] { cursor: not-allowed; opacity: 0.6; }
.cl-button--secondary {
  background: var(--cl-color-surface);
  color: var(--cl-color-accent-strong);
  border-color: var(--cl-color-accent);
}
.cl-button--secondary:hover { background: var(--cl-color-accent-surface); }
.cl-button--quiet {
  background: transparent;
  color: var(--cl-color-text-muted);
  border-color: var(--cl-color-border-strong);
}
.cl-button--quiet:hover { background: var(--cl-color-surface-muted); }

/* Links stay underlined: color alone must not be what marks a link. */
.cl-link {
  color: var(--cl-color-accent-strong);
  text-decoration: underline;
}
.cl-link:hover { color: var(--cl-color-text); }

/* ── Focus ───────────────────────────────────────────────────────────────── */
/* a11y.css already rings every interactive element; this restates it for the
   non-element components (cards, rows, states) that can take focus. */
:where([class^="cl-"], [class*=" cl-"]):focus-visible {
  outline: var(--cl-focus-ring);
  outline-offset: var(--cl-focus-ring-offset);
}
@media (forced-colors: active) {
  :where([class^="cl-"], [class*=" cl-"]):focus-visible { outline-color: Highlight; }
}

/* ── Form fields ─────────────────────────────────────────────────────────── */
.cl-field {
  display: flex;
  flex-direction: column;
  gap: var(--cl-field-gap);
  font-size: var(--cl-text-2);
  font-weight: var(--cl-weight-medium);
  color: var(--cl-field-label-color);
  min-width: 0;
}
.cl-field__hint {
  font-weight: var(--cl-weight-normal);
  font-size: var(--cl-text-1);
  color: var(--cl-color-text-muted);
}
.cl-input,
.cl-select,
.cl-textarea {
  width: 100%;
  min-height: var(--cl-target-min);
  padding: var(--cl-field-inset);
  border: var(--cl-hairline) solid var(--cl-field-border);
  border-radius: var(--cl-field-radius);
  background: var(--cl-field-bg);
  color: var(--cl-field-fg);
  font: inherit;
  font-size: var(--cl-text-3);
  font-weight: var(--cl-weight-normal);
}
.cl-textarea { resize: vertical; }
/* Invalid: the ring is the hint a mouse user sees, the message below is the one
   everybody gets. Never the border alone. */
.cl-input[aria-invalid="true"],
.cl-select[aria-invalid="true"],
.cl-textarea[aria-invalid="true"] { border-color: var(--cl-color-danger-text); }
.cl-field__error {
  font-size: var(--cl-text-2);
  font-weight: var(--cl-weight-medium);
  color: var(--cl-field-error-color);
}
.cl-field__error:empty { display: none; }

/* ── Tables ──────────────────────────────────────────────────────────────── */
/* The wrapper scrolls, not the page: a wide table must not push the document
   sideways at 375px (#2651). */
.cl-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  border: var(--cl-hairline) solid var(--cl-table-border);
  border-radius: var(--cl-radius-2);
}
.cl-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--cl-text-2);
  color: var(--cl-color-text);
  background: var(--cl-color-surface);
}
.cl-table th,
.cl-table td {
  padding: var(--cl-table-cell-inset);
  border-bottom: var(--cl-hairline) solid var(--cl-table-border);
  text-align: left;
  vertical-align: top;
}
.cl-table thead th {
  background: var(--cl-table-head-surface);
  font-weight: var(--cl-weight-bold);
  color: var(--cl-color-text);
  white-space: nowrap;
}
.cl-table tbody tr:last-child td { border-bottom: 0; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.cl-card {
  color-scheme: var(--cl-scheme);
  background: var(--cl-card-bg);
  color: var(--cl-color-text);
  border: var(--cl-hairline) solid var(--cl-card-border);
  border-radius: var(--cl-card-radius);
  padding: var(--cl-card-inset);
  box-shadow: var(--cl-card-shadow);
  min-width: 0;
}
.cl-card__title {
  margin: 0 0 var(--cl-space-2);
  font-size: var(--cl-text-4);
  line-height: var(--cl-leading-tight);
}
.cl-card__meta {
  margin: var(--cl-space-2) 0 0;
  font-size: var(--cl-text-2);
  color: var(--cl-color-text-muted);
}
.cl-code {
  font-family: var(--cl-font-code);
  font-size: var(--cl-text-2);
  color: var(--cl-color-text-muted);
  word-break: break-all;
}

/* ── Notices ─────────────────────────────────────────────────────────────── */
/* Tone is carried by the left rule, the label text and the icon a caller puts
   in `.cl-notice__title` — the tint is reinforcement, never the message. */
.cl-notice {
  padding: var(--cl-notice-inset);
  border-radius: var(--cl-notice-radius);
  border-left: var(--cl-notice-accent-width) solid var(--cl-color-neutral-text);
  background: var(--cl-color-neutral-surface);
  color: var(--cl-color-text);
  font-size: var(--cl-text-3);
}
.cl-notice__title {
  display: block;
  margin: 0 0 var(--cl-space-1);
  font-weight: var(--cl-weight-bold);
}
.cl-notice--info {
  border-left-color: var(--cl-color-info-text);
  background: var(--cl-color-info-surface);
}
.cl-notice--info .cl-notice__title { color: var(--cl-color-info-text); }
.cl-notice--success {
  border-left-color: var(--cl-color-success-text);
  background: var(--cl-color-success-surface);
}
.cl-notice--success .cl-notice__title { color: var(--cl-color-success-text); }
.cl-notice--warning {
  border-left-color: var(--cl-color-warning-text);
  background: var(--cl-color-warning-surface);
}
.cl-notice--warning .cl-notice__title { color: var(--cl-color-warning-text); }
.cl-notice--danger {
  border-left-color: var(--cl-color-danger-text);
  background: var(--cl-color-danger-surface);
}
.cl-notice--danger .cl-notice__title { color: var(--cl-color-danger-text); }

/* ── Badges / status ─────────────────────────────────────────────────────── */
/* Contract: `.cl-status` always contains the state's name as text. Each variant
   also carries its own glyph, so the states stay distinguishable in greyscale,
   in forced-colors mode, and to anyone who does not see the tint. The `/ ""`
   alt text keeps the glyph out of the accessibility tree — the visible label is
   what a screen reader should read. */
.cl-status {
  display: inline-flex;
  align-items: center;
  gap: var(--cl-space-1);
  padding: var(--cl-status-inset);
  border-radius: var(--cl-status-radius);
  border: var(--cl-hairline) solid currentColor;
  font-size: var(--cl-status-size);
  font-weight: var(--cl-weight-bold);
  background: var(--cl-color-neutral-surface);
  color: var(--cl-color-neutral-text);
}
.cl-status::before {
  content: var(--cl-status-glyph, "•");
  content: var(--cl-status-glyph, "•") / "";
  font-weight: var(--cl-weight-bold);
}
.cl-status--pending {
  --cl-status-glyph: "◷";
  background: var(--cl-color-warning-surface);
  color: var(--cl-color-warning-text);
}
.cl-status--info {
  --cl-status-glyph: "ℹ";
  background: var(--cl-color-info-surface);
  color: var(--cl-color-info-text);
}
.cl-status--success {
  --cl-status-glyph: "✓";
  background: var(--cl-color-success-surface);
  color: var(--cl-color-success-text);
}
.cl-status--warning {
  --cl-status-glyph: "!";
  background: var(--cl-color-warning-surface);
  color: var(--cl-color-warning-text);
}
.cl-status--danger {
  --cl-status-glyph: "✕";
  background: var(--cl-color-danger-surface);
  color: var(--cl-color-danger-text);
}
.cl-status--neutral {
  --cl-status-glyph: "•";
  background: var(--cl-color-neutral-surface);
  color: var(--cl-color-neutral-text);
}

/* ── Empty / error / loading states ──────────────────────────────────────── */
/* One block, three tones. Each one says what happened in words; a caller that
   can offer a next step puts a `.cl-button` inside it. */
.cl-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--cl-space-3);
  padding: var(--cl-state-inset);
  text-align: center;
  color: var(--cl-state-color);
  font-size: var(--cl-text-3);
}
.cl-state__title {
  margin: 0;
  font-size: var(--cl-text-4);
  font-weight: var(--cl-weight-bold);
  color: var(--cl-color-text);
}
.cl-state--error .cl-state__title { color: var(--cl-color-danger-text); }
/* The spinner is decoration; `.cl-state__title` ("Loading…") is the message,
   and the live region a caller marks up is what announces it. */
.cl-spinner {
  width: var(--cl-space-5);
  height: var(--cl-space-5);
  border: var(--cl-ring-width) solid var(--cl-color-border);
  border-top-color: var(--cl-color-accent);
  border-radius: var(--cl-radius-pill);
  animation: cl-spin 0.9s linear infinite;
}
@keyframes cl-spin { to { transform: rotate(360deg); } }
/* a11y.css already collapses animation durations under reduced-motion; this
   swaps the spin for something that still reads as "busy" when it cannot move. */
@media (prefers-reduced-motion: reduce) {
  .cl-spinner {
    animation: none;
    border-top-color: var(--cl-color-border);
    border-left-color: var(--cl-color-accent);
  }
}

/* ═══ SHARED PAGE PIECES (#3123) ═══════════════════════════════════════════
   The app bar, theme toggle, "needs a person", source tags, reference chip,
   queue rows and steps every product uses. Markup comes from
   lg_core_base.ui (appbar(), ui_head()); behavior from ui/civicline.js. */

/* ── App bar ─────────────────────────────────────────────────────────────── */
.cl-env {
  margin: 0;
  padding: var(--cl-env-inset);
  background: var(--cl-env-bg);
  color: var(--cl-env-fg);
  border-bottom: var(--cl-hairline) solid var(--cl-env-fg);
  font-size: var(--cl-text-2);
  font-weight: var(--cl-weight-bold);
  text-align: center;
}
.cl-appbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cl-appbar-gap);
  padding: var(--cl-appbar-inset);
  background: var(--cl-appbar-bg);
  color: var(--cl-color-text);
  border-bottom: var(--cl-hairline) solid var(--cl-appbar-border);
  font-family: var(--cl-font-body);
  min-width: 0;
}
.cl-appbar__brand {
  display: flex;
  align-items: center;
  gap: var(--cl-space-3);
  margin-right: auto;
  min-width: 0;
}
.cl-appbar__mark {
  width: var(--cl-appbar-mark-size);
  height: var(--cl-appbar-mark-size);
  flex: none;
}
.cl-appbar__mark-bg { fill: var(--cl-color-text); }
.cl-appbar__mark-fg { stroke: var(--cl-color-surface); }
.cl-appbar__names { display: flex; flex-direction: column; min-width: 0; line-height: var(--cl-leading-tight); }
.cl-appbar__product { font-size: var(--cl-text-4); font-weight: var(--cl-weight-bold); }
.cl-appbar__place { font-size: var(--cl-text-2); color: var(--cl-color-text-muted); }
.cl-appbar__tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cl-space-2) var(--cl-space-4);
}
.cl-appbar__switch {
  display: inline-flex;
  align-items: center;
  min-height: var(--cl-target-min);
  color: var(--cl-color-accent-strong);
  font-weight: var(--cl-weight-medium);
  text-underline-offset: var(--cl-space-1);
}
.cl-appbar__person {
  display: inline-flex;
  align-items: center;
  gap: var(--cl-space-2);
  min-height: var(--cl-target-min);
  font-size: var(--cl-text-3);
}
.cl-appbar__role { color: var(--cl-color-text-muted); font-size: var(--cl-text-2); }

/* ── Theme toggle ────────────────────────────────────────────────────────── */
/* System / Light / Dark. The chosen one is marked by aria-pressed, weight and
   fill — not fill alone — and keeps its text label at every width. */
/* No overflow clipping on the group: it would cut off the focus ring, which is
   drawn outside each button. The end buttons round their own corners instead. */
.cl-theme {
  display: inline-flex;
  border: var(--cl-hairline) solid var(--cl-color-border-strong);
  border-radius: var(--cl-radius-1);
}
.cl-theme__option:first-child { border-radius: var(--cl-radius-1) 0 0 var(--cl-radius-1); }
.cl-theme__option:last-child { border-radius: 0 var(--cl-radius-1) var(--cl-radius-1) 0; }
/* Lift the focused option so its ring paints over its neighbors. */
.cl-theme__option:focus-visible { position: relative; z-index: 1; }
.cl-theme__option {
  min-height: var(--cl-target-min);
  padding: var(--cl-theme-inset);
  border: 0;
  background: var(--cl-color-surface);
  color: var(--cl-color-text-muted);
  font: inherit;
  font-size: var(--cl-text-2);
  cursor: pointer;
}
.cl-theme__option + .cl-theme__option { border-left: var(--cl-hairline) solid var(--cl-color-border-strong); }
.cl-theme__option[aria-pressed="true"] {
  background: var(--cl-theme-on-bg);
  color: var(--cl-theme-on-fg);
  font-weight: var(--cl-weight-bold);
}
@media (forced-colors: active) {
  .cl-theme__option[aria-pressed="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; }
}

/* ── Needs a person ──────────────────────────────────────────────────────── */
/* Says that a person must decide, and why — the reasons are the system's own
   (a flag, a confidence, an authority rule), never invented by the page. */
.cl-needs {
  padding: var(--cl-needs-inset);
  border: var(--cl-hairline) solid var(--cl-needs-accent);
  border-left-width: var(--cl-notice-accent-width);
  border-radius: var(--cl-radius-1);
  background: var(--cl-needs-bg);
  color: var(--cl-needs-fg);
  font-size: var(--cl-text-3);
}
.cl-needs__title {
  display: flex;
  align-items: center;
  gap: var(--cl-space-2);
  margin: 0;
  color: var(--cl-needs-accent);
  font-weight: var(--cl-weight-bold);
}
.cl-needs__title::before { content: "!"; content: "!" / ""; font-weight: var(--cl-weight-bold); }
.cl-needs__reasons { margin: var(--cl-space-2) 0 0; padding-left: var(--cl-space-5); display: grid; gap: var(--cl-space-1); }

/* ── Source tags ─────────────────────────────────────────────────────────── */
/* Where a value came from. AI is the one a person must check, so it alone is
   dashed and says so; each tag also has its own glyph. */
.cl-src {
  display: inline-flex;
  align-items: center;
  gap: var(--cl-space-1);
  padding: var(--cl-src-inset);
  border: var(--cl-hairline) solid var(--cl-color-border-strong);
  border-radius: var(--cl-radius-1);
  background: var(--cl-color-surface-muted);
  color: var(--cl-color-text-muted);
  font-size: var(--cl-text-1);
  font-weight: var(--cl-weight-medium);
  vertical-align: middle;
}
.cl-src::before { content: var(--cl-src-glyph); content: var(--cl-src-glyph) / ""; font-family: var(--cl-font-code); }
.cl-src--rules { --cl-src-glyph: "="; }
.cl-src--template { --cl-src-glyph: "¶"; }
.cl-src--ai {
  --cl-src-glyph: "◇";
  border-color: currentColor;
  border-style: dashed;
  background: var(--cl-color-surface);
  color: var(--cl-color-text);
}

/* ── Reference chip ──────────────────────────────────────────────────────── */
.cl-ref {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
  border: var(--cl-hairline) solid var(--cl-color-border);
  border-radius: var(--cl-radius-1);
  background: var(--cl-ref-bg);
  color: var(--cl-color-text);
  font-family: var(--cl-font-code);
  font-size: var(--cl-text-2);
  font-variant-numeric: tabular-nums;
}
.cl-ref__value { padding: var(--cl-ref-inset); overflow-wrap: anywhere; user-select: all; align-self: center; }
.cl-ref__copy {
  min-width: var(--cl-target-min);
  min-height: var(--cl-space-5);
  margin-left: var(--cl-space-2);
  border: 0;
  border-left: var(--cl-hairline) solid var(--cl-color-border);
  background: transparent;
  color: var(--cl-color-text-muted);
  font: inherit;
  font-family: var(--cl-font-body);
  font-size: var(--cl-text-1);
  cursor: pointer;
}
.cl-ref__copy:hover { color: var(--cl-color-accent-strong); }

/* ── Queue rows ──────────────────────────────────────────────────────────── */
/* Dense, scannable work lists. Lead column (priority/status), the item, then
   its age in tabular figures. Worked items stay in place, struck and dimmed. */
.cl-queue { list-style: none; margin: 0; padding: 0; }
.cl-row {
  display: grid;
  grid-template-columns: var(--cl-row-columns);
  gap: var(--cl-row-gap);
  align-items: center;
  width: 100%;
  min-height: var(--cl-row-min);
  padding: var(--cl-row-inset);
  border: 0;
  border-bottom: var(--cl-hairline) solid var(--cl-color-border);
  background: var(--cl-color-surface);
  color: var(--cl-color-text);
  font: inherit;
  text-align: left;
}
button.cl-row, a.cl-row { cursor: pointer; text-decoration: none; }
.cl-row:hover { background: var(--cl-row-hover-bg); }
.cl-row[aria-current]:not([aria-current="false"]) {
  background: var(--cl-row-current-bg);
  box-shadow: inset var(--cl-space-1) 0 0 var(--cl-color-accent);
}
.cl-row > :first-child { justify-self: start; }
.cl-row__main { display: grid; gap: var(--cl-space-1); min-width: 0; }
.cl-row__what { font-weight: var(--cl-weight-medium); overflow-wrap: anywhere; }
.cl-row__where { font-size: var(--cl-text-2); color: var(--cl-color-text-muted); overflow-wrap: anywhere; }
.cl-row__age {
  font-family: var(--cl-font-code);
  font-size: var(--cl-text-2);
  font-variant-numeric: tabular-nums;
  color: var(--cl-color-text-muted);
  text-align: right;
}
.cl-row--worked { color: var(--cl-color-text-muted); }
.cl-row--worked .cl-row__what { text-decoration: line-through; }

/* ── Steps ───────────────────────────────────────────────────────────────── */
/* For a real sequence only (setup, a request's progress). Done steps show a
   check, the rest their number — never color alone. */
.cl-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--cl-space-3); counter-reset: cl-step; }
.cl-steps__step {
  display: grid;
  grid-template-columns: var(--cl-step-mark) minmax(0, 1fr);
  gap: var(--cl-space-3);
  align-items: start;
  counter-increment: cl-step;
}
.cl-steps__step::before {
  content: counter(cl-step);
  display: grid;
  place-items: center;
  width: var(--cl-step-mark);
  height: var(--cl-step-mark);
  border: var(--cl-hairline) solid var(--cl-color-border-strong);
  border-style: dashed;
  border-radius: var(--cl-radius-pill);
  color: var(--cl-color-text-muted);
  font-weight: var(--cl-weight-bold);
}
.cl-steps__step--done::before {
  content: "✓";
  border-style: solid;
  border-color: var(--cl-color-success-text);
  background: var(--cl-color-success-surface);
  color: var(--cl-color-success-text);
}

/* ── The page itself, once themed ────────────────────────────────────────── */
/* Without this the margin around a dark shell stays the browser's white. And
   border-box throughout: the shell and rows are width 100% plus padding, which
   in the default content-box pushes a phone page sideways. */
:root[data-cl-themed] { box-sizing: border-box; }
:root[data-cl-themed] *, :root[data-cl-themed] *::before, :root[data-cl-themed] *::after { box-sizing: inherit; }
:root[data-cl-themed] body {
  margin: 0;
  background: var(--cl-color-canvas);
  color: var(--cl-color-text);
  font-family: var(--cl-font-body);
}

/* ── a11y.css on a themed page ──────────────────────────────────────────── */
/* a11y.css draws these from the same tokens (#2648). On a page that opted in
   to the themes they are restated here at higher specificity, so a surface's
   own focus or error rule cannot pull them off the palette in dark.
   The classes stay a11y.css's — this restates their colors, it adds none. */
:root[data-cl-themed] :where(a, button, input, select, textarea, summary, [tabindex]):focus-visible,
:root[data-cl-themed] .error-summary:focus {
  outline-color: var(--cl-color-focus-ring);
}
:root[data-cl-themed] .skip-link { background: var(--cl-color-accent); color: var(--cl-color-text-inverse); }
:root[data-cl-themed] .error-summary {
  border-color: var(--cl-color-danger-text);
  background: var(--cl-color-danger-surface);
  color: var(--cl-color-text);
}
:root[data-cl-themed] .error-summary a,
:root[data-cl-themed] .field-error { color: var(--cl-color-danger-text); }
/* Each summary entry is a link on its own line, not a link inside running
   text, so it gets the 2.5.8 minimum target rather than the inline exception. */
:root[data-cl-themed] .error-summary a { display: inline-flex; align-items: center; min-height: var(--cl-space-5); }
:root[data-cl-themed] [aria-invalid="true"] { border-color: var(--cl-color-danger-text); }

@media (max-width: 768px) {
  .cl-row { --cl-row-columns: minmax(0, 3.5rem) minmax(0, 1fr) minmax(0, 3.5rem); --cl-row-gap: var(--cl-space-2); }
  .cl-appbar__tools { width: 100%; justify-content: space-between; }
}
