@font-face{font-family:"PP Neue Montreal";src:url(/static/fonts/PPNeueMontreal-Book.522baf3ae0cb2084.otf) format("opentype");font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:"PP Neue Montreal";src:url(/static/fonts/PPNeueMontreal-Medium.961d500e3e9e9055.otf) format("opentype");font-weight:500;font-style:normal;font-display:swap}
@font-face{font-family:"PP Neue Montreal";src:url(/static/fonts/PPNeueMontreal-Bold.b1845dcd4d8410bb.otf) format("opentype");font-weight:700;font-style:normal;font-display:swap}
/* CompEcho app stylesheet: hand-written, driven by design tokens (no build step).
   Every colour is a custom property in the tokens layer; TestNoHexOutsideTokens fails on a hex
   value anywhere else, and TestTokenContrast checks the accessibility pairs.
   Layers: tokens, base, components, utilities. Every page is built from the components in
   views/ui.templ; docs/design/design-system.md describes them. */

@layer tokens, base, components, utilities;

/* Metric-matched stand-in for PP Neue Montreal while (or when) the brand font is not loaded. */
@font-face {
  font-family: "PP Neue Montreal Fallback";
  src: local("Arial"), local("ArialMT"), local("Liberation Sans"), local("Arimo");
  size-adjust: 94.46%;
}

@layer tokens {
  :root {
    /* Brand */
    --blue: #2660FE;
    --blue-hover: #1E50D0;
    --navy: #042B96;
    --blue-tint: #F5F8FC;
    --blue-soft: #DBEAFE;
    --on-blue: #FFFFFF;
    /* Neutrals */
    --ink: #1A1A1A;
    --text-muted: #6B6B6B;
    --subtle: #989898; /* decoration only: never text a reader needs */
    --border: #E0E0E0;
    --border-control: #8F8F8F;
    --surface: #FFFFFF;
    --surface-muted: #FAFAFA;
    /* Status: fill (dots, charts), text, tint (badge backgrounds) */
    --success: #05D123;
    --success-text: #0A7A22;
    --success-tint: #E4FBE7;
    --warning: #FFA820;
    --warning-text: #8F5200;
    --warning-tint: #FFF3E0;
    --danger: #E43134;
    --danger-text: #B42318;
    --danger-tint: #FBE4E4;
    --danger-button: #D12B2E;
    --danger-button-hover: #B42318;
    --info: #2660FE;
    --info-text: #1E50D0;
    --info-tint: #F5F8FC;
    --neutral: #989898;
    --neutral-text: #6B6B6B;
    --neutral-tint: #FAFAFA;
    /* Depth */
    --shadow-color: #0000001A;
    --shadow-hover: 0 4px 6px -1px var(--shadow-color), 0 2px 4px -2px var(--shadow-color);
    --shadow-menu: 0 10px 15px -3px var(--shadow-color), 0 4px 6px -4px var(--shadow-color);
    /* Type */
    --font-sans: "PP Neue Montreal", "PP Neue Montreal Fallback", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --tracking: -0.02em;
    /* Space */
    --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px;
    --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px; --s16: 64px;
    /* Shape */
    --r-xs: 4px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 40px; --r-full: 999px;
    /* Measures */
    --topbar: 64px;
    --gutter: 24px;
    --w-app: 1120px;
    --w-prose: 720px;
    --w-form: 448px;
    /* Motion */
    --ease: 150ms cubic-bezier(.4, 0, .2, 1);
  }
}

@layer base {
  *, *::before, *::after { box-sizing: border-box; }
  html {
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 20px;
    letter-spacing: var(--tracking);
    color: var(--ink);
    background: var(--surface);
    -webkit-text-size-adjust: 100%;
  }
  body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--surface); }
  h1, h2, h3, h4 { font-weight: 500; margin: 0; }
  h1 { font-size: 28px; line-height: 36px; margin-bottom: var(--s4); }
  h2 { font-size: 22px; line-height: 28px; margin: var(--s8) 0 var(--s3); }
  h3 { font-size: 18px; line-height: 28px; margin: var(--s6) 0 var(--s2); }
  p { margin: 0 0 var(--s3); }
  ul, ol { margin: 0 0 var(--s3); padding-left: var(--s6); }
  li + li { margin-top: var(--s1); }
  strong { font-weight: 500; }
  a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; transition: color var(--ease); }
  a:hover { color: var(--blue-hover); }
  code, kbd, samp, pre { font-family: var(--font-mono); font-size: 13px; letter-spacing: normal; }
  img, svg { vertical-align: middle; }
  hr { border: 0; border-top: 1px solid var(--border); margin: var(--s6) 0; }
  :focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
  :focus:not(:focus-visible) { outline: none; }
  /* Date fields move focus between their parts, which some browsers never mark focus-visible. */
  input[type="date"]:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
  input[type="date"]::-webkit-calendar-picker-indicator:focus-visible { outline: 2px solid var(--blue); border-radius: var(--r-xs); }
  [hidden] { display: none !important; }
  table { border-collapse: collapse; }
  input, select, textarea, button { font: inherit; letter-spacing: inherit; color: inherit; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  }
}

@layer components {
  /* ---------- Skip link ---------- */
  .skip {
    position: absolute; left: var(--s4); top: -100px; z-index: 20;
    padding: var(--s2) var(--s4); border-radius: var(--r-full);
    background: var(--ink); color: var(--surface); font-weight: 500; text-decoration: none;
  }
  .skip:focus { top: var(--s3); color: var(--surface); }

  /* ---------- System banner ---------- */
  .banner {
    display: flex; gap: var(--s2); align-items: center; justify-content: center;
    padding: var(--s2) var(--gutter); background: var(--ink); color: var(--surface); font-weight: 500; text-align: center;
  }
  .banner a { color: var(--surface); }

  /* ---------- Top bar, tabs, account menu ---------- */
  .topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: relative; z-index: 5; }
  .topbar-in {
    min-height: var(--topbar); max-width: 1280px; margin: 0 auto; padding: var(--s2) var(--gutter);
    display: flex; align-items: center; gap: var(--s3) var(--s6);
  }
  .logo { display: inline-flex; align-items: center; flex: 0 0 auto; }
  .logo { color: var(--blue); }
  .logo:hover { color: var(--blue-hover); }
  .logo-svg { display: block; height: 32px; width: auto; }
  .tabs { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; }
  .tabs ul { display: flex; gap: var(--s1); list-style: none; margin: 0; padding: 0; overflow-x: auto; scrollbar-width: none; }
  .tabs li + li { margin: 0; }
  .tab {
    display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4);
    border-radius: var(--r-full); color: var(--text-muted); font-size: 16px; line-height: 20px; font-weight: 500;
    text-decoration: none; white-space: nowrap; transition: color var(--ease), background-color var(--ease);
  }
  .tab:hover { color: var(--ink); }
  .tab:focus-visible { outline-offset: -2px; }
  .tab[aria-current="page"] { color: var(--ink); background: var(--surface-muted); }
  .tabs-menu { display: none; }
  .bar-end { margin-left: auto; display: flex; align-items: center; gap: var(--s3); flex: 0 0 auto; }
  .bar-org { font-weight: 500; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
  .back { display: inline-flex; align-items: center; gap: var(--s2); color: var(--text-muted); font-weight: 500; text-decoration: none; }
  .back:hover { color: var(--ink); }

  .menu { position: relative; }
  .menu > summary { list-style: none; cursor: pointer; }
  .menu > summary::-webkit-details-marker { display: none; }
  .menu-btn {
    display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s3) 0 var(--s4);
    border: 1px solid var(--border); border-radius: var(--r-full); background: var(--surface); font-weight: 500;
    transition: border-color var(--ease);
  }
  .menu-btn:hover { border-color: var(--border-control); }
  .menu[open] .menu-btn .icon-chev { transform: rotate(180deg); }
  .menu-panel {
    position: absolute; right: 0; top: calc(100% + var(--s2)); z-index: 10; width: 280px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-menu);
    padding: var(--s2);
  }
  .menu-panel ul { list-style: none; margin: 0; padding: 0; }
  .menu-panel li + li { margin: 0; }
  .menu-head { padding: var(--s2) var(--s3); color: var(--text-muted); font-size: 12px; line-height: 16px; overflow-wrap: anywhere; }
  .menu-sep { border-top: 1px solid var(--border); margin: var(--s2) 0; }
  .menu-item, .menu-panel button.menu-item {
    display: flex; align-items: center; gap: var(--s2); width: 100%; min-height: 40px; padding: 0 var(--s3);
    border: 0; border-radius: var(--r-sm); background: none; color: var(--ink); text-align: left;
    text-decoration: none; font-weight: 400; cursor: pointer; margin: 0;
  }
  .menu-item:hover { background: var(--surface-muted); color: var(--ink); }
  .menu-item[aria-current="page"] { font-weight: 500; background: var(--surface-muted); }
  .menu-item .badge { margin-left: auto; }

  /* ---------- Page frames ---------- */
  .page { flex: 1 0 auto; width: 100%; margin: 0 auto; padding: var(--s10) var(--gutter) var(--s16); }
  .page-app { max-width: calc(var(--w-app) + 2 * var(--gutter)); }
  .page-account { max-width: calc(var(--w-prose) + 2 * var(--gutter)); }
  .footer {
    padding: var(--s4) var(--gutter); background: var(--surface-muted); border-top: 1px solid var(--border);
    color: var(--text-muted); font-size: 12px; line-height: 16px;
  }
  .footer code { font-size: 12px; }

  /* Sign-in layout */
  .signin { flex: 1 0 auto; display: flex; min-height: 100vh; }
  .signin-side { flex: 1 1 50%; min-width: 0; display: flex; flex-direction: column; gap: var(--s8); padding: var(--s8) var(--gutter) var(--s6); }
  .signin-main { flex: 1 0 auto; width: 100%; max-width: var(--w-form); margin: 0 auto; display: flex; flex-direction: column; justify-content: center; }
  .signin-main h1 { font-size: 40px; line-height: 48px; color: var(--navy); margin-bottom: var(--s6); }
  .signin-side .footer { background: none; border: 0; padding: 0; }
  .signin-panel { flex: 1 1 50%; display: flex; padding: var(--s4); }
  .signin-panel-in {
    flex: 1 1 auto; border-radius: var(--r-xl); background: var(--blue); color: var(--on-blue);
    padding: var(--s16) 56px; display: flex; flex-direction: column; justify-content: center;
  }
  .signin-panel-in { gap: var(--s10); }
  .signin-panel-in .mark-svg { color: var(--on-blue); }
  .signin-panel p { margin: 0; max-width: 520px; font-size: 40px; line-height: 48px; font-weight: 500; }

  /* ---------- Page header, breadcrumb ---------- */
  .page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4) var(--s6); margin-bottom: var(--s8); }
  .page-head h1 { margin: 0; }
  .page-head-text { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; flex: 1 1 400px; }
  .page-head .intro { margin: 0; font-size: 16px; line-height: 24px; color: var(--text-muted); max-width: var(--w-prose); }
  .page-head-actions { display: flex; flex-wrap: wrap; gap: var(--s3); }
  .crumbs ol { display: flex; flex-wrap: wrap; gap: var(--s2); list-style: none; margin: 0; padding: 0; color: var(--text-muted); }
  .crumbs li + li { margin: 0; }
  .crumbs li + li::before { content: "/"; margin-right: var(--s2); color: var(--subtle); }
  .crumbs a { color: var(--text-muted); text-decoration: none; }
  .crumbs a:hover { color: var(--ink); text-decoration: underline; }

  /* ---------- Buttons and links ---------- */
  .btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
    min-height: 44px; padding: 0 var(--s6); margin: 0; border: 1px solid transparent; border-radius: var(--r-full);
    font-size: 14px; line-height: 20px; font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background-color var(--ease), border-color var(--ease), color var(--ease);
  }
  .btn-primary { background: var(--blue); color: var(--on-blue); }
  .btn-primary:hover { background: var(--blue-hover); color: var(--on-blue); }
  .btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border); }
  .btn-secondary:hover { border-color: var(--border-control); color: var(--ink); }
  .btn-ghost { background: none; color: var(--blue); padding: 0 var(--s2); }
  .btn-ghost:hover { color: var(--blue-hover); background: var(--blue-tint); }
  .btn-danger { background: var(--danger-button); color: var(--on-blue); }
  .btn-danger:hover { background: var(--danger-button-hover); color: var(--on-blue); }
  .btn-sm { min-height: 32px; padding: 0 14px; }
  .btn-block { width: 100%; }
  .btn:disabled, .btn[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
  .link-arrow { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 500; text-decoration: none; min-height: 32px; }
  .link-arrow:hover { text-decoration: underline; }
  .button-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin-top: var(--s6); }

  /* ---------- Form fields ---------- */
  .form { display: flex; flex-direction: column; gap: var(--s5); max-width: var(--w-form); }
  .field { display: flex; flex-direction: column; gap: 6px; }
  .field-label { font-weight: 500; }
  .field-hint { color: var(--text-muted); font-size: 12px; line-height: 16px; margin: 0; }
  .field-error { display: flex; gap: var(--s1); align-items: center; color: var(--danger-text); font-size: 12px; line-height: 16px; font-weight: 500; margin: 0; }
  .input, .select, .textarea {
    width: 100%; min-height: 44px; padding: 0 var(--s4); border: 1px solid var(--border-control); border-radius: var(--r-md);
    background: var(--surface-muted); color: var(--ink); transition: border-color var(--ease), background-color var(--ease);
  }
  .textarea { padding: var(--s3) var(--s4); min-height: 112px; resize: vertical; }
  .input:hover, .select:hover, .textarea:hover { border-color: var(--ink); }
  .input:focus, .select:focus, .textarea:focus { background: var(--surface); }
  .input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border: 2px solid var(--danger-text); }
  .input:disabled { opacity: .6; cursor: not-allowed; }
  .input-code { width: 9rem; font-family: var(--font-mono); font-size: 16px; letter-spacing: .1em; }
  .select {
    appearance: none; padding-right: var(--s10);
    background-image: url(/static/chevron-down.5e5301a9ac2788ab.svg); background-repeat: no-repeat; background-position: right var(--s3) center; background-size: 16px;
  }
  .select-sm { min-height: 32px; width: auto; padding-left: var(--s3); border-radius: var(--r-sm); }
  .check { display: grid; grid-template-columns: 20px 1fr; gap: 2px var(--s3); align-items: start; }
  .check input {
    appearance: none; width: 20px; height: 20px; margin: 0; border: 1px solid var(--border-control); border-radius: var(--r-xs);
    background: var(--surface); display: grid; place-content: center; cursor: pointer;
  }
  .check input::before { content: ""; width: 10px; height: 6px; border: 2px solid var(--on-blue); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px, -1px); opacity: 0; }
  .check input:checked { background: var(--blue); border-color: var(--blue); }
  .check input:checked::before { opacity: 1; }
  .check label { font-weight: 500; cursor: pointer; }
  .check .field-hint, .check .field-error { grid-column: 2; }
  .file input[type="file"] { font-size: 14px; color: var(--text-muted); max-width: 100%; }
  .file input[type="file"]::file-selector-button {
    margin-right: var(--s3); min-height: 40px; padding: 0 var(--s5); border: 1px solid var(--border); border-radius: var(--r-full);
    background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer;
  }
  .file input[type="file"]::file-selector-button:hover { border-color: var(--border-control); }

  /* ---------- Alerts and badges ---------- */
  .alert { display: flex; gap: 10px; align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-md); font-weight: 500; margin: 0 0 var(--s4); }
  .alert svg { flex: 0 0 auto; margin-top: 2px; }
  .alert-success { background: var(--success-tint); color: var(--success-text); }
  .alert-error { background: var(--danger-tint); color: var(--danger-text); }
  .alert-warning { background: var(--warning-tint); color: var(--warning-text); }
  .alert-info { background: var(--info-tint); color: var(--info-text); }
  .badge {
    display: inline-flex; align-items: center; gap: 6px; padding: var(--s1) 10px; border-radius: var(--r-full);
    font-size: 12px; line-height: 16px; font-weight: 500; white-space: nowrap; letter-spacing: normal;
  }
  .badge-success { background: var(--success-tint); color: var(--success-text); }
  .badge-warning { background: var(--warning-tint); color: var(--warning-text); }
  .badge-danger { background: var(--danger-tint); color: var(--danger-text); }
  .badge-info { background: var(--info-tint); color: var(--info-text); }
  .badge-neutral { background: var(--neutral-tint); color: var(--neutral-text); border: 1px solid var(--border); padding: 3px 9px; }

  /* ---------- Cards ---------- */
  .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s6); }
  .card-flush { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
  .card-head {
    display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
    padding: var(--s4) var(--s6); border-bottom: 1px solid var(--border);
  }
  .card-head h2, .card-head h3 { margin: 0; font-size: 16px; line-height: 24px; }
  .card-body { padding: var(--s6); flex: 1 0 auto; }
  .card-body > :last-child { margin-bottom: 0; }
  .card-foot {
    display: flex; align-items: center; justify-content: flex-end; gap: var(--s3);
    padding: var(--s3) var(--s6); background: var(--surface-muted); border-top: 1px solid var(--border);
    color: var(--text-muted); font-size: 12px; line-height: 16px;
  }
  .card-foot .link-arrow { font-size: 14px; line-height: 20px; }
  .card-link { display: block; color: inherit; text-decoration: none; transition: box-shadow var(--ease), border-color var(--ease); }
  .card-link:hover { color: inherit; box-shadow: var(--shadow-hover); border-color: var(--border-control); }
  .card-title { font-size: 18px; line-height: 28px; font-weight: 500; margin: 0 0 var(--s2); }
  .grid { display: grid; gap: var(--s6); grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
  .grid-stats { grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); }
  .stack { display: flex; flex-direction: column; gap: var(--s6); }

  /* Status card */
  .stat-top { padding: var(--s5) var(--s6); display: flex; flex-direction: column; gap: var(--s3); flex: 1 0 auto; }
  .stat-label { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-weight: 500; }
  .stat .card-foot { justify-content: flex-start; }
  .stat-n { font-size: 32px; line-height: 40px; font-weight: 500; }
  .tile { width: 32px; height: 32px; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
  .tile-lg { width: 44px; height: 44px; border-radius: var(--r-md); }
  .tile-success { background: var(--success-tint); color: var(--success-text); }
  .tile-warning { background: var(--warning-tint); color: var(--warning-text); }
  .tile-danger { background: var(--danger-tint); color: var(--danger-text); }
  .tile-info { background: var(--info-tint); color: var(--info-text); }
  .tile-neutral { background: var(--neutral-tint); color: var(--neutral-text); }
  .tile-blue { background: var(--blue-tint); color: var(--blue); }

  /* Empty state */
  .empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); padding: var(--s8) var(--s6); }
  .empty-title { font-size: 18px; line-height: 28px; font-weight: 500; margin: 0; }
  .empty p { margin: 0; color: var(--text-muted); max-width: 400px; }
  .empty .btn { margin-top: var(--s2); }

  /* Danger zone */
  .danger-zone { border-color: var(--danger-text); }
  .danger-zone .card-title { color: var(--ink); }
  .danger-zone p { color: var(--text-muted); }

  /* ---------- Tables ---------- */
  .table-wrap { overflow-x: auto; min-width: 0; max-width: 100%; position: relative; }
  .card-flush { min-width: 0; }
  .table .row-actions { flex-wrap: nowrap; }
  .table-wrap:focus-visible { outline-offset: -2px; }
  .table { width: 100%; border-collapse: collapse; }
  .table th, .table td { text-align: left; padding: var(--s3) var(--s6); border-bottom: 1px solid var(--border); vertical-align: middle; height: 52px; }
  .table th { background: var(--surface-muted); color: var(--text-muted); font-weight: 500; white-space: nowrap; height: 44px; }
  .table tbody tr:last-child td { border-bottom: 0; }
  .table .num { text-align: right; font-variant-numeric: tabular-nums; }
  .row-actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

  /* ---------- Detail list, code ---------- */
  .details { margin: 0; display: grid; gap: var(--s4); }
  .details div { min-width: 0; }
  .details dt { color: var(--text-muted); font-size: 12px; line-height: 16px; margin-bottom: 2px; }
  .details dd { margin: 0; overflow-wrap: anywhere; }
  .details-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: var(--s4) var(--s6); }
  .mono { font-family: var(--font-mono); font-size: 13px; line-height: 20px; letter-spacing: normal; }
  .code-block {
    display: block; padding: var(--s3) var(--s4); border: 1px solid var(--border); border-radius: var(--r-md);
    background: var(--surface-muted); font-family: var(--font-mono); font-size: 13px; line-height: 20px; letter-spacing: normal;
    overflow-wrap: anywhere; margin: 0 0 var(--s3);
  }
  .select-all { user-select: all; cursor: text; }
  ul.code-block, ul.codes {
    list-style: none; padding: var(--s3) var(--s4); columns: 2; column-gap: var(--s8);
  }

  /* ---------- Charts ---------- */
  .chart { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s8); }
  .chart svg { flex: 0 0 auto; }
  .donut-track { stroke: var(--border); }
  .grid-chart { overflow: visible; }
  .donut-total { font-size: 24px; font-weight: 500; fill: var(--ink); }
  .donut-unit { font-size: 12px; fill: var(--text-muted); }
  .fill-success { stroke: var(--success); fill: var(--success); }
  .fill-warning { stroke: var(--warning); fill: var(--warning); }
  .fill-danger { stroke: var(--danger); fill: var(--danger); }
  .fill-info { stroke: var(--info); fill: var(--info); }
  .fill-neutral { stroke: var(--neutral); fill: var(--neutral); }
  .donut circle[class^="fill-"] { fill: none; }
  .cell-on { fill: var(--success); }
  .cell-off { fill: var(--success-tint); stroke: var(--success-text); stroke-width: 1; }
  .legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); flex: 1 1 180px; }
  .legend li { display: flex; align-items: center; gap: 10px; margin: 0; }
  .legend .key-dot { width: 12px; height: 12px; border-radius: var(--r-xs); flex: 0 0 auto; }
  .legend .label { flex: 1 1 auto; }
  .legend .n { font-weight: 500; }
  .legend .of { color: var(--text-muted); }
  .dot-success { background: var(--success); }
  .dot-warning { background: var(--warning); }
  .dot-danger { background: var(--danger); }
  .dot-info { background: var(--info); }
  .dot-neutral { background: var(--neutral); }
  .chart-caption { margin: var(--s4) 0 0; font-size: 16px; line-height: 24px; }
  .chart-caption .n { font-weight: 500; color: var(--success-text); }

  /* ---------- Sign-in pages ---------- */
  .signin-top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
  .signin-top .logo { margin-right: auto; }
  .signin-plain .signin-side { flex-basis: 100%; }
  .form-card { display: flex; flex-direction: column; gap: var(--s5); margin: 0 0 var(--s6); }
  .signin-main .form-card, .signin-main .invite-card { border-radius: var(--r-lg); }
  .form-card > .alert { margin: 0; }
  .stack > .form-card { margin: 0; }
  .form-card > .error { margin: 0; }
  .google-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin: 0; }
  .divider { display: flex; align-items: center; gap: var(--s3); color: var(--text-muted); font-size: 12px; line-height: 16px; }
  .divider::before, .divider::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--border); }
  .signin-links { text-align: center; }
  .intro { font-size: 16px; line-height: 24px; color: var(--text-muted); max-width: var(--w-prose); margin-bottom: var(--s6); }
  .fold > summary {
    display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; cursor: pointer; list-style: none;
    color: var(--blue); font-weight: 500;
  }
  .fold > summary::-webkit-details-marker { display: none; }
  .fold > summary:hover { color: var(--blue-hover); }
  .fold[open] .fold-chev { transform: rotate(90deg); }
  .fold .fold-chev { transition: transform var(--ease); }
  .fold > .form-card { margin-top: var(--s2); }
  .steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s4); counter-reset: step; }
  .steps > li { margin: 0; counter-increment: step; }
  .step.card { display: flex; flex-direction: column; gap: var(--s4); border-radius: var(--r-lg); }
  .steps > li::before {
    content: counter(step); width: 24px; height: 24px; border-radius: var(--r-full); background: var(--blue-tint); color: var(--blue);
    display: grid; place-content: center; font-size: 12px; font-weight: 500;
  }
  .step .form-card { margin: 0; }
  .qr-tile { align-self: center; border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s3); background: var(--surface); }
  .qr-tile .qr { margin: 0; border: 0; padding: 0; }
  div.code-block .key { border: 0; background: none; padding: 0; margin: 0; font-size: 13px; }
  .step .code-block { width: 100%; text-align: center; margin: 0; }
  .message { max-width: 520px; margin: var(--s8) auto; display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s3); padding: var(--s10) var(--s8); }
  .message h1 { margin: 0; }
  .message p { margin: 0; color: var(--text-muted); }
  .message .btn { margin-top: var(--s2); }
  .signin-main .message { margin: 0; }
  .invite-card { display: flex; align-items: center; gap: var(--s4); margin: 0 0 var(--s6); }

  /* ---------- Overview and controls ---------- */
  .stack-sm { display: flex; flex-direction: column; gap: var(--s4); }
  .stack-sm > * { margin: 0; }
  .subhead { font-size: 14px; line-height: 20px; margin: var(--s5) 0 var(--s1); }
  .attention { list-style: none; margin: 0; padding: 0; }
  .attention li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); padding: var(--s4) var(--s6); border-bottom: 1px solid var(--border); margin: 0; }
  .attention li:last-child { border-bottom: 0; }
  .attention-calm { margin: 0; padding: var(--s5) var(--s6); color: var(--text-muted); }
  .page-links { margin-top: var(--s8); }
  .count-line { color: var(--text-muted); margin: calc(-1 * var(--s4)) 0 var(--s3); }
  .status-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: var(--s1) 0 0; font-weight: 500; }
  .detail-grid { display: grid; gap: var(--s6); grid-template-columns: minmax(0, 1fr) minmax(0, 340px); align-items: start; }
  .detail-main, .detail-side { min-width: 0; }
  .statement { font-size: 16px; line-height: 24px; margin: 0; }
  .ceiling { background: var(--warning-tint); border-color: transparent; }
  .ceiling .card-title { font-size: 16px; line-height: 24px; color: var(--warning-text); }
  blockquote { margin: 0; padding: var(--s3) var(--s4); border-left: 3px solid var(--border); color: var(--ink); background: var(--surface-muted); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
  .citations li code, .checks code { overflow-wrap: anywhere; }
  .uploads { list-style: none; padding: 0; margin: 0; }
  .uploads li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2) var(--s4); padding: var(--s3) 0; border-bottom: 1px solid var(--border); margin: 0; }
  .uploads li:last-child { border-bottom: 0; }
  .uploads li > div { display: flex; flex-direction: column; min-width: 0; }
  .upload, .decision { padding-top: var(--s4); border-top: 1px solid var(--border); margin: 0; }
  .checks { list-style: none; margin: 0; padding: 0; }
  .checks li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); padding: var(--s4) var(--s6); border-bottom: 1px solid var(--border); margin: 0; }
  .checks li:last-child { border-bottom: 0; }
  .scope-form { flex: 1 0 100%; display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); }
  .scope-form .field { flex: 1 1 260px; }
  .detail-side .card-title { font-size: 16px; line-height: 24px; }
  .card-body h3 { font-size: 14px; line-height: 20px; margin: var(--s2) 0 0; }
  .section-gap { margin-top: var(--s6); }
  .chart { height: 100%; align-content: center; }
  .chain-head { padding: var(--s4) var(--s5) var(--s3); border-bottom: 1px solid var(--border); }
  .chain-title { font-size: 16px; line-height: 24px; margin: 0; }
  .chain-summary { margin: 0; color: var(--text-muted); }
  .chain-note { margin: 0; padding: var(--s3) var(--s5); color: var(--text-muted); border-bottom: 1px solid var(--border); }
  .chain-list { list-style: none; margin: 0; padding: 0; }
  .chain-list li { padding: var(--s3) var(--s5); border-bottom: 1px solid var(--border); margin: 0; }
  .chain-list li:last-child { border-bottom: 0; }
  .chain-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2); }
  .chain-label { min-width: 0; overflow-wrap: anywhere; }
  .chain-code { margin: var(--s1) 0 0; font-size: 12px; line-height: 16px; color: var(--text-muted); overflow-wrap: anywhere; }
  .chain-note:last-child { border-bottom: 0; }
  .chain-reason { margin: var(--s1) 0 0; font-size: 12px; line-height: 16px; color: var(--text-muted); }
  .bucket { border-bottom: 1px solid var(--border); }
  .bucket:last-child { border-bottom: 0; }
  .bucket-title { display: flex; align-items: center; gap: var(--s2); font-size: 14px; line-height: 20px; margin: 0; padding: var(--s4) var(--s6) 0; }
  .bucket-n { color: var(--text-muted); font-weight: 400; }
  .bucket .attention li { padding: var(--s2) var(--s6); border-bottom: 0; }
  .bucket .attention li:last-child { padding-bottom: var(--s4); }
  .due { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
  .due-how { display: block; margin-top: var(--s1); font-size: 12px; line-height: 16px; color: var(--text-muted); }
  .plan-form { display: flex; flex-direction: column; gap: var(--s3); padding-top: var(--s4); margin-top: var(--s4); border-top: 1px solid var(--border); }
  .inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3); margin-top: var(--s4); }
  .inline-form .field { flex: 0 1 240px; }
  .resources, .runs { list-style: none; margin: 0; padding: 0; }
  .resources li { display: flex; flex-direction: column; gap: var(--s2); padding: var(--s3) var(--s6); border-bottom: 1px solid var(--border); margin: 0; }
  .resources li:last-child, .runs li:last-child { border-bottom: 0; }
  .resources .chain-reason { margin: 0; }
  .runs li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s3) var(--s6); border-bottom: 1px solid var(--border); margin: 0; }
  .stages { list-style: none; margin: 0; padding: 0; }
  .stage { padding: var(--s4) var(--s6); border-bottom: 1px solid var(--border); margin: 0; }
  .stage:last-child { border-bottom: 0; }
  .stage-head, .stage summary { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
  .stage summary { cursor: pointer; }
  .stage-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: var(--r-full); background: var(--blue-tint); color: var(--blue); font-size: 12px; font-weight: 500; }
  .stage-done .stage-n { background: var(--success-tint); color: var(--success-text); }
  .stage-title { font-weight: 500; }
  .stage-by { color: var(--text-muted); }
  .stage-why, .stage-progress { margin: var(--s2) 0 0; }
  .stage-why { color: var(--text-muted); }
  .stage-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--s2) var(--s4); margin-top: var(--s3); }
  .requests { margin: 0; padding-left: var(--s5); }
  .requests li { margin: 0 0 var(--s2); }
  .requests .muted { display: block; font-size: 12px; line-height: 16px; }
  .policy-list li { flex-wrap: wrap; }
  .policy-meta { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-left: auto; }
  .filter-line { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); color: var(--text-muted); margin: calc(-1 * var(--s4)) 0 var(--s3); }

  /* ---------- Integrations, policies, exports, members, account ---------- */
  .link-list { list-style: none; margin: 0; padding: 0; }
  .link-list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s6); border-bottom: 1px solid var(--border); margin: 0; color: var(--text-muted); }
  .link-list li:last-child { border-bottom: 0; }
  .link-list a { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 500; }
  .connect-grid { margin-top: var(--s6); }
  .connect-grid .card-body { display: flex; flex-direction: column; }
  .templates { list-style: none; padding: 0; margin: 0 0 var(--s4); }
  .templates li { padding: var(--s2) 0; overflow-wrap: anywhere; margin: 0; }
  dd.dd-error { color: var(--danger-text); font-weight: 500; }
  .danger-gap { height: var(--s8); }
  .narrow { max-width: var(--w-prose); }
  .hash { font-size: 12px; overflow-wrap: anywhere; word-break: break-all; }
  .factors { list-style: none; padding: 0; margin: 0; }
  .factors li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--border); margin: 0; }
  .factors li:last-child { border-bottom: 0; }
  .factor-name { display: inline-flex; align-items: center; gap: var(--s2); font-weight: 500; }
  .add-passkey { padding-top: var(--s4); border-top: 1px solid var(--border); }
  .step-up { border-color: var(--blue); background: var(--blue-tint); }
  .invite-form { max-width: var(--w-form); }
  form.step-up.card { max-width: none; }
  .card-body ul.factors { padding: 0; }
  .stack > dl.card { margin: 0; }
  .org-delete p { color: var(--ink); }
  table .row-actions .field { gap: 0; }

  /* ---------- Gallery (dev only) ---------- */
  .gallery-section { margin-bottom: var(--s12); }
  .gallery-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; margin-bottom: var(--s4); }
  .swatch { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
  .swatch-chip { height: 56px; }
  .swatch div:last-child { padding: var(--s2) var(--s3); font-size: 12px; line-height: 16px; }
  .sw-blue { background: var(--blue); } .sw-blue-hover { background: var(--blue-hover); } .sw-navy { background: var(--navy); }
  .sw-blue-tint { background: var(--blue-tint); } .sw-blue-soft { background: var(--blue-soft); } .sw-ink { background: var(--ink); }
  .sw-text-muted { background: var(--text-muted); } .sw-subtle { background: var(--subtle); } .sw-border { background: var(--border); }
  .sw-border-control { background: var(--border-control); } .sw-surface-muted { background: var(--surface-muted); }
  .sw-success { background: var(--success); } .sw-warning { background: var(--warning); } .sw-danger { background: var(--danger); }
  .sw-danger-button { background: var(--danger-button); }
  .type-display { font-size: 40px; line-height: 48px; font-weight: 500; color: var(--navy); }
  .type-title1 { font-size: 28px; line-height: 36px; font-weight: 500; }
  .type-title2 { font-size: 22px; line-height: 28px; font-weight: 500; }
  .type-title3 { font-size: 18px; line-height: 28px; font-weight: 500; }

  /* ---------- Page-level patterns kept from the first stylesheet ---------- */
  :where(main) > h1:first-child { margin-bottom: var(--s4); }
  :where(.page-app, .page-account) form.card { max-width: var(--w-form); }
  form.inline { display: inline; }
  .muted { color: var(--text-muted); }
  /* The passkey script's message line: hidden until it has something to say. */
  .error {
    display: block; padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--danger-tint); color: var(--danger-text);
    font-weight: 500; margin: 0;
  }
  .error[hidden] { display: none; }
  /* A text-styled submit button (Log out beside the address while signing in). */
  button.link {
    background: none; border: 0; padding: 0; margin: 0; color: var(--blue); font-weight: 400;
    text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
  }
  button.link:hover { color: var(--blue-hover); }
  /* The authenticator code in a table row (two-factor resets). */
  input.code {
    width: 9rem; min-height: 32px; padding: 0 var(--s3); font-family: var(--font-mono); letter-spacing: .1em;
    border: 1px solid var(--border-control); border-radius: var(--r-sm); background: var(--surface-muted);
  }
  dl.card { display: grid; gap: 0; margin: 0 0 var(--s6); }
  dl.card dt { color: var(--text-muted); font-size: 12px; line-height: 16px; margin-top: var(--s3); }
  dl.card dt:first-child { margin-top: 0; }
  dl.card dd { margin: 0; overflow-wrap: anywhere; }
  ul.orgs { list-style: none; padding: 0; margin: 0 0 var(--s4); }
  ul.orgs li { padding: var(--s2) 0; border-bottom: 1px solid var(--border); margin: 0; }
  ul.orgs li:last-child { border-bottom: 0; }
  .codes {
    font-family: var(--font-mono); font-size: 16px; line-height: 28px; letter-spacing: normal;
    background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--r-md); margin: 0 0 var(--s4);
  }
  .codes li { margin: 0; }
  .qr { display: block; margin: var(--s4) auto; width: 200px; height: 200px; image-rendering: pixelated; border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s2); background: var(--surface); }
  .key:not(.code-block) {
    font-family: var(--font-mono); font-size: 13px; letter-spacing: normal; overflow-wrap: anywhere;
    background: var(--surface-muted); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 2px 6px;
  }
}

@layer utilities {
  .visually-hidden {
    position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
  .text-muted { color: var(--text-muted); }
  .text-sm { font-size: 12px; line-height: 16px; }
  .text-lg { font-size: 16px; line-height: 24px; }
  .mt-0 { margin-top: 0; }
  .mb-0 { margin-bottom: 0; }
  .mb-6 { margin-bottom: var(--s6); }
  .nowrap { white-space: nowrap; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1023px) {
  .signin-panel { display: none; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar-in { flex-wrap: wrap; }
  .tabs { order: 3; flex: 1 0 100%; justify-content: flex-start; margin-left: calc(-1 * var(--s4)); }
}
@media (max-width: 767px) {
  :root { --gutter: 16px; }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .stat-top { padding: var(--s4); }
  .stat .card-foot { padding: var(--s2) var(--s4); }
  .topbar-in { flex-wrap: wrap; }
  .tabs { display: none; }
  .tabs-menu { display: block; order: 3; flex: 1 0 100%; }
  .tabs-menu > summary { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; font-weight: 500; }
  .tabs-menu .menu-panel { position: static; width: 100%; box-shadow: none; margin-top: var(--s2); }
  .bar-org, .bar-end > .badge { display: none; }
  .page { padding-top: var(--s6); }
  .signin-main h1 { font-size: 32px; line-height: 40px; }
  ul.code-block, ul.codes { columns: 1; }
}

@media print {
  /* Auditors print a control's page and the policies list: content only, black on white, the
     organisation and the version line kept, external link addresses written out. */
  .tabs, .tabs-menu, .menu, .back, .skip, .banner, .signin-panel, .signin-top, .crumbs, .page-head-actions,
  button, .btn, .form-card, .scope-form, .alert svg, .icon, .tile { display: none !important; }
  body, .muted, .intro, .statement, .card-foot, dl.card dt, .footer, .alert { color: black !important; background: white !important; }
  .topbar, .footer { border-color: black; }
  .page { padding: 0; max-width: none; }
  .detail-grid { display: block; }
  .detail-side { margin-top: var(--s6); }
  .card, .ceiling, .alert { border: 1px solid black; background: white; break-inside: avoid; }
  .badge { border: 1px solid black; background: white; color: black; }
  .codes { columns: 2; border-color: black; }
  a { color: black; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 12px; }
}
