    /* ─── tokens ─────────────────────────────────────────────────────── */
    :root {
      /* palette — "chalk & coral": mint court paper, ink linework, coral fire */
      --bg:      oklch(95.5% 0.035 188);
      --surface: oklch(99.5% 0.005 190);
      --fg:      oklch(17% 0.03 255);
      --muted:   oklch(48% 0.03 250);
      --border:  oklch(82% 0.03 188);
      --accent:  oklch(72% 0.16 35);
      --accent-strong: oklch(43% 0.15 28);

      --accent-soft: color-mix(in oklch, var(--accent) 18%, transparent);
      --fg-soft:     color-mix(in oklch, var(--fg) 7%, transparent);

      /* ink-surface text (sidebar, toast) */
      --on-dark:       oklch(95.5% 0.035 188);
      --on-dark-muted: oklch(72% 0.03 250);

      /* pops — highlighter fills, never body text */
      --pop-lime: oklch(84% 0.16 135);
      --pop-sun:  oklch(85% 0.15 88);
      --pop-blue: oklch(50% 0.15 245);

      /* status colors */
      --ok:      oklch(45% 0.12 155);
      --ok-soft: color-mix(in oklch, var(--ok) 16%, transparent);
      --warn:      oklch(44% 0.11 62);
      --warn-soft: color-mix(in oklch, var(--warn) 20%, transparent);
      --danger:      oklch(48% 0.17 25);
      --danger-soft: color-mix(in oklch, var(--danger) 15%, transparent);

      /* the flourish: hard sticker shadow, always paired with an ink outline */
      --shadow-hard:    4px 4px 0 var(--fg);
      --shadow-hard-sm: 2px 2px 0 var(--fg);
      --shadow-deep:    3px 3px 0 oklch(11% 0.03 255);

      --font-display: 'Iowan Old Style', 'Charter', Georgia, 'Times New Roman', serif;
      --font-body:    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', system-ui, sans-serif;
      --font-mono:    ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;

      --fs-h1: clamp(30px, 3.4vw, 42px);
      --fs-h2: clamp(22px, 2.4vw, 28px);
      --fs-h3: 17px;
      --fs-lead: 15px;
      --fs-body: 14px;
      --fs-meta: 12px;

      --gap-xs: 6px; --gap-sm: 10px; --gap-md: 16px; --gap-lg: 24px; --gap-xl: 36px; --gap-2xl: 56px;
      --container: 1240px;
      --container-wide: 1680px;
      --gutter: 24px;
      --radius: 10px;
      --radius-lg: 16px;
    }

    *, *::before, *::after { box-sizing: border-box; }
    html { -webkit-text-size-adjust: 100%; }
    body {
      margin: 0;
      background: var(--bg);
      color: var(--fg);
      font-family: var(--font-body);
      font-size: var(--fs-body);
      line-height: 1.5;
      text-rendering: optimizeLegibility;
      -webkit-font-smoothing: antialiased;
    }
    img, svg { display: block; max-width: 100%; }
    a { color: inherit; text-decoration: none; }
    button { font: inherit; cursor: pointer; color: inherit; }
    h1, h2, h3, h4 { text-wrap: balance; font-family: var(--font-display); }
    p { text-wrap: pretty; }
    h1, h2, h3, h4, p { margin: 0; }

    /* ─── buttons ───────────────────────────────────────────────────── */
    .btn {
      display: inline-flex; align-items: center; gap: 8px;
      padding: 11px 18px;
      border-radius: var(--radius);
      border: 2px solid var(--fg);
      background: var(--surface);
      font-size: 14px; font-weight: 700;
      letter-spacing: -0.005em;
      box-shadow: var(--shadow-hard-sm);
      transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease, color 0.15s ease;
    }
    .btn:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-hard); }
    .btn:active { transform: translate(1px, 1px); box-shadow: 0 0 0 var(--fg); }
    .btn-primary { background: var(--accent); color: var(--fg); }
    .btn-primary:hover { background: var(--fg); color: var(--accent); }
    .btn-secondary { background: var(--surface); color: var(--fg); }
    .btn-secondary:hover { background: color-mix(in oklch, var(--pop-lime) 60%, var(--surface)); }
    .btn-ghost { background: transparent; color: var(--fg); border-color: transparent; box-shadow: none; padding-inline: 10px; }
    .btn-ghost:hover { background: var(--fg-soft); transform: none; box-shadow: none; }
    .btn-sm { padding: 7px 12px; font-size: 13px; }
    .btn-danger { background: transparent; border-color: transparent; box-shadow: none; color: var(--danger); }
    .btn-danger:hover { background: var(--danger-soft); color: var(--danger); transform: none; box-shadow: none; }
    .btn-danger-solid { background: var(--danger); color: #fff; }
    .btn-danger-solid:hover { background: color-mix(in oklch, var(--danger) 82%, var(--fg)); color: #fff; }
    .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: var(--shadow-hard-sm); }
    button:focus-visible, a:focus-visible, .nav-item:focus-visible, input:focus-visible, select:focus-visible {
      outline: 3px solid var(--accent-strong); outline-offset: 2px;
    }
    .sidebar button:focus-visible, .sidebar select:focus-visible { outline-color: var(--pop-lime); }

    /* ─── app shell ─────────────────────────────────────────────────── */
    .app-shell { display: flex; min-height: 100vh; }

    .sidebar {
      width: 236px; flex-shrink: 0;
      background: var(--fg);
      color: var(--on-dark);
      border-right: 3px solid var(--fg);
      padding: 18px 14px 18px;
      display: flex; flex-direction: column;
      position: sticky; top: 0; height: 100vh;
      overflow-y: auto;
    }
    .sidebar .muted { color: var(--on-dark-muted); }
    .brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 18px; }
    .brand-mark { width: 34px; height: 34px; flex-shrink: 0; display: block; }
    .brand-name { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--on-dark); }

    .nav-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--on-dark-muted); padding: 16px 12px 7px; }
    .nav-item {
      display: flex; align-items: center; gap: 11px;
      padding: 10px 12px; margin-bottom: 3px;
      border-radius: var(--radius); color: var(--on-dark-muted);
      font-size: 14px; font-weight: 600; border: 0; background: transparent; width: 100%; text-align: left;
      transition: background 0.14s ease, color 0.14s ease, transform 0.12s ease, box-shadow 0.12s ease;
    }
    .nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
    .nav-item:hover { color: var(--on-dark); background: color-mix(in oklch, var(--surface) 14%, transparent); }
    .nav-item.active {
      color: var(--fg); background: var(--pop-lime); font-weight: 800;
      box-shadow: var(--shadow-deep); transform: translate(-1px, -1px);
    }
    .nav-item.active svg { color: var(--fg); }
    .sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid color-mix(in oklch, var(--surface) 22%, transparent); }
    .nav-back { color: var(--on-dark); border: 1.5px solid color-mix(in oklch, var(--surface) 28%, transparent); margin-bottom: 6px; }

    /* User row + account menu: the row toggles a sticker card above it. */
    .user-menu { position: relative; margin-top: 8px; }
    .user-row {
      width: 100%; display: flex; align-items: center; gap: 10px;
      padding: 8px 10px; border: 0; border-radius: var(--radius);
      background: transparent; color: var(--on-dark); font: inherit; text-align: left; cursor: pointer;
    }
    .user-row:hover, .user-row[aria-expanded="true"] { background: color-mix(in oklch, var(--surface) 10%, transparent); }
    .user-row-meta { min-width: 0; flex: 1; }
    .user-row-name { display: block; font-weight: 600; font-size: 13.5px; }
    .user-row-email { display: block; font-size: 11.5px; color: var(--on-dark-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .user-row-chev { width: 16px; height: 16px; flex-shrink: 0; color: var(--on-dark-muted); }
    .user-menu-pop {
      position: absolute; left: 0; right: 0; bottom: calc(100% + 8px); z-index: 30;
      display: flex; flex-direction: column; gap: 2px; padding: 6px;
      background: var(--surface); color: var(--fg);
      border: 2px solid var(--on-dark); border-radius: 12px; box-shadow: 3px 3px 0 var(--on-dark);
    }
    .user-menu-pop[hidden] { display: none; }
    .user-menu-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--fg); }
    .user-menu-item svg { width: 18px; height: 18px; flex-shrink: 0; }
    .user-menu-item:hover, .user-menu-item:focus-visible { background: var(--pop-lime); }
    .user-menu-sep { height: 1px; background: var(--border); margin: 2px 6px; }

    .main { flex: 1; min-width: 0; padding: 26px 32px 60px; }
    .main-inner { max-width: var(--container); margin-inline: auto; }
    .main-inner.main-inner--wide { max-width: var(--container-wide); }

    .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
    .page-title { font-family: var(--font-display); font-size: var(--fs-h1); font-weight: 700; letter-spacing: -0.025em; line-height: 1.02; }
    .page-sub { color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0.01em; margin-top: 8px; }
    .page-actions { display: flex; gap: 10px; align-items: center; }

    /* ─── cards / panels ────────────────────────────────────────────── */
    .panel { background: var(--surface); border: 2px solid var(--fg); border-radius: var(--radius-lg); box-shadow: var(--shadow-hard); }
    .panel-pad { padding: 20px; }
    .panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 2px solid var(--fg); }
    .panel-head h3 { font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: -0.015em; }
    .panel-head .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
    .muted { color: var(--muted); }

    /* ─── badges / pills ────────────────────────────────────────────── */
    .badge {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 3px 9px; border-radius: 999px;
      border: 1.5px solid var(--fg); box-shadow: var(--shadow-hard-sm);
      font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
      letter-spacing: 0.05em; text-transform: uppercase;
      line-height: 1.6; white-space: nowrap;
    }
    .badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
    .badge-ok     { background: var(--ok-soft); color: var(--ok); }
    .badge-warn   { background: var(--warn-soft); color: var(--warn); }
    .badge-danger { background: var(--danger-soft); color: var(--danger); }
    .badge-neutral{ background: var(--fg-soft); color: var(--muted); }

    /* ─── avatar ────────────────────────────────────────────────────── */
    .avatar {
      width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0;
      display: grid; place-items: center;
      background: color-mix(in oklch, var(--accent) 40%, var(--surface));
      border: 2px solid var(--fg);
      color: var(--fg); font-family: var(--font-mono); font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
    }
    .avatar-sm { width: 27px; height: 27px; font-size: 10.5px; border-radius: 8px; border-width: 1.5px; }

    /* ─── table ─────────────────────────────────────────────────────── */
    .tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
    .tbl th, .tbl td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
    .tbl th { color: var(--fg); font-weight: 700; font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; border-bottom: 2px solid var(--fg); padding-top: 14px; padding-bottom: 12px; }
    .tbl tbody tr { transition: background 0.12s ease; }
    .tbl tbody tr:last-child td { border-bottom: 0; }
    .tbl tbody tr:hover { background: color-mix(in oklch, var(--accent) 13%, transparent); }
    .tbl .num-col { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; }
    .table-scroll { overflow-x: auto; }
    .table-scroll .tbl { min-width: 640px; }
    .cell-person { display: flex; align-items: center; gap: 11px; }
    .cell-person .n { font-family: var(--font-display); font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
    .cell-person .e { color: var(--muted); font-size: 12.5px; }
    .empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; }

    /* ─── layout grids ──────────────────────────────────────────────── */
    .stack { display: flex; flex-direction: column; gap: 16px; }
    .row { display: flex; align-items: center; gap: 12px; }
    .row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

    /* ─── forms ─────────────────────────────────────────────────────── */
    .field { display: flex; flex-direction: column; gap: 6px; }
    .field label { font-family: var(--font-mono); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
    .field .hint { font-size: 11.5px; color: var(--muted); }
    .input, .select {
      width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius);
      background: var(--surface); color: var(--fg); font: inherit; font-size: 14px;
      transition: border-color 0.12s ease, box-shadow 0.12s ease;
    }
    .input:hover, .select:hover { border-color: var(--fg); }
    .input:focus, .select:focus { outline: none; border-color: var(--fg); box-shadow: 2px 2px 0 var(--fg); }
    .select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23808080' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
    .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
    .form-grid .full { grid-column: 1 / -1; }
    @media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

    /* ─── roles & identity ──────────────────────────────────────────── */
    .switch { position: relative; display: inline-block; width: 40px; height: 22px; vertical-align: middle; }
    .switch input { opacity: 0; width: 0; height: 0; }
    .switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--border); transition: background 0.15s ease; cursor: pointer; }
    .switch span::before { content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); top: 2px; left: 2px; transition: transform 0.15s ease; box-shadow: 0 1px 2px color-mix(in oklch, var(--fg) 35%, transparent); }
    .switch input:checked + span { background: var(--accent-strong); }
    .switch input:checked + span::before { transform: translateX(18px); }
    .switch input:focus-visible + span { outline: 3px solid var(--accent-strong); outline-offset: 2px; }

    /* ─── toast ─────────────────────────────────────────────────────── */
    .toast {
      position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px);
      background: var(--fg); color: var(--pop-lime); padding: 12px 18px; border-radius: 10px;
      font-family: var(--font-mono); font-size: 13.5px; font-weight: 700; letter-spacing: 0.01em;
      z-index: 60; box-shadow: 4px 4px 0 color-mix(in oklch, var(--fg) 55%, transparent);
      border: 2px solid var(--on-dark-muted);
      opacity: 0; pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease;
    }
    .toast.show { opacity: 1; transform: translate(-50%, 0); }
    /* Undo the UA popover box (inset: 0, auto margins) so the toast keeps its spot. */
    .toast[popover] { inset: auto auto 24px 50%; margin: 0; overflow: visible; }

    /* ─── gateway admin (M4) ────────────────────────────────────────── */
    .gw-filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
    .gw-filters .field { min-width: 158px; flex: 0 0 auto; }
    .gw-filters .btn { margin-bottom: 1px; }
    .gw-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 14px; }
    .gw-kpi {
      background: var(--surface); border: 2px solid var(--fg); border-radius: var(--radius);
      box-shadow: var(--shadow-hard-sm); padding: 13px 15px;
    }
    .gw-kpi .k { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
    .gw-kpi .v { font-family: var(--font-display); font-size: 25px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin-top: 5px; }
    .gw-kpi .s { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
    .link-btn { font: inherit; font-weight: 700; padding: 0; border: 0; background: none; color: var(--accent-strong); text-decoration: underline; cursor: pointer; }
    .link-btn:hover { color: var(--fg); }
    .gw-chart { display: flex; align-items: flex-end; gap: 3px; height: 148px; }
    .gw-bar { flex: 1; min-width: 3px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; border-radius: 3px 3px 0 0; overflow: hidden; }
    .gw-bar-ok { background: var(--accent); }
    .gw-bar-fail { background: var(--danger); }
    .gw-chart-legend { display: flex; gap: 14px; margin-top: 10px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
    .gw-chart-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; border: 1px solid var(--fg); }
    .gw-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
    @media (max-width: 860px) { .gw-two { grid-template-columns: 1fr; } }
    .gw-once { background: var(--warn-soft); border: 2px solid var(--warn); border-radius: var(--radius-lg); box-shadow: var(--shadow-hard); padding: 16px 20px; }
    .gw-once h3 { color: var(--warn); }
    .gw-key {
      font-family: var(--font-mono); font-size: 14px; word-break: break-all; user-select: all;
      background: var(--surface); border: 1.5px solid var(--fg); border-radius: 8px; padding: 11px 13px; margin-top: 10px;
    }
    .chip {
      display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; margin: 2px 4px 2px 0;
      border: 1.5px solid var(--border); border-radius: 999px; background: var(--fg-soft);
      font-family: var(--font-mono); font-size: 11px; font-weight: 600;
    }
    .chip button { border: 0; background: transparent; padding: 0; font-size: 13px; line-height: 1; color: var(--muted); }
    .chip button:hover { color: var(--danger); }
    .gw-detail td { background: color-mix(in oklch, var(--fg) 4%, var(--surface)); }
    .gw-caps { display: flex; flex-wrap: wrap; gap: 8px 16px; }
    .gw-inline { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
    .gw-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
    .gw-mono { font-family: var(--font-mono); font-size: 12px; }

    /* ─── organisation gateway (SAH-721 Phase 3) ──────────────────────────── */
    .tg-code {
      font-family: var(--font-mono); font-size: 12.5px; line-height: 1.55;
      background: color-mix(in oklch, var(--fg) 6%, var(--surface));
      border: 1.5px solid var(--border); border-radius: var(--radius);
      padding: 12px 14px; margin: 0; overflow-x: auto; white-space: pre;
    }

    /* ─── impersonation banner ──────────────────────────────────────── */
    .imp-banner {
      position: fixed; top: 0; left: 0; right: 0; z-index: 70;
      display: none; align-items: center; justify-content: center; gap: 10px;
      padding: 9px 16px; background: var(--warn-soft); color: var(--warn);
      font-weight: 700; font-size: 13.5px; letter-spacing: 0.01em;
      border-bottom: 2px solid color-mix(in oklch, var(--warn) 45%, transparent);
    }
    .imp-banner.show { display: flex; }
    body.imp-active .app-shell { margin-top: 43px; }
    body.imp-active .sidebar { top: 43px; }

    @media (max-width: 920px) {
      .app-shell { flex-direction: column; }
      .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 12px; overflow-x: auto; }
      .sidebar .brand { padding: 0; margin-right: 8px; }
      .nav-label, .nav-item span { display: none; }
      /* The foot collapses to icon-only Settings + the avatar, pinned right;
         the menu goes fixed so the scrolling bar cannot clip it. */
      .sidebar-foot { display: flex; align-items: center; gap: 4px; margin: 0 0 0 auto; padding: 0; border: 0; }
      .user-menu { margin: 0; position: static; }
      .user-row { padding: 4px; width: auto; }
      .user-row-meta, .user-row-chev { display: none; }
      .user-menu-pop { position: fixed; top: 60px; right: 12px; left: auto; bottom: auto; width: 220px; }
      body.imp-active .user-menu-pop { top: 103px; }
      .nav-item { width: auto; padding: 9px; margin: 0; }
      .main { padding: 18px 16px 48px; }
      .page-head { flex-direction: column; align-items: flex-start; }
    }

    /* ─── modals (SAH-1366) ─────────────────────────────────────────── */
    dialog.modal {
      position: fixed;
      inset: 0;
      margin: auto;
      padding: 0;
      width: min(560px, calc(100vw - 32px));
      min-width: min(320px, calc(100vw - 32px));
      max-width: min(680px, calc(100vw - 32px));
      max-height: min(85vh, 720px);
      overflow: hidden;
      background: var(--surface);
      color: var(--fg);
      border: 2px solid var(--fg);
      border-radius: var(--radius-lg);
      box-shadow: var(--shadow-hard);
    }
    dialog.modal[open] { display: flex; flex-direction: column; }
    dialog.modal::backdrop {
      background: color-mix(in oklch, var(--fg) 55%, transparent);
      backdrop-filter: blur(2px);
    }
    .modal-head {
      display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
      padding: 16px 20px;
      border-bottom: 2px solid var(--fg);
      flex-shrink: 0;
    }
    .modal-head h2, .modal-head h3 {
      font-family: var(--font-display); font-size: 19px; font-weight: 700;
      letter-spacing: -0.015em; line-height: 1.15;
    }
    .modal-head .sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
    .modal-body {
      flex: 1 1 auto; min-height: 0;
      padding: 18px 20px;
      overflow-y: auto; overscroll-behavior: contain;
    }
    .modal-actions {
      display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 10px;
      padding: 14px 20px;
      border-top: 2px solid var(--fg);
      background: var(--surface);
      position: sticky; bottom: 0; flex-shrink: 0;
    }
    .modal-close {
      display: inline-grid; place-items: center; flex-shrink: 0;
      width: 32px; height: 32px; padding: 0;
      border: 1.5px solid transparent; border-radius: 8px;
      background: transparent; color: var(--muted);
      font-size: 20px; line-height: 1;
    }
    .modal-close:hover { background: var(--fg-soft); color: var(--fg); }

    /* ─── health dashboard (SAH-1366) ───────────────────────────────── */
    .health-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
      gap: 14px;
    }
    .health-card {
      display: flex; flex-direction: column; gap: 10px; min-width: 0;
      padding: 14px 16px;
      background: var(--surface);
      border: 2px solid var(--fg);
      border-radius: var(--radius);
      box-shadow: var(--shadow-hard-sm);
    }
    .health-card-head {
      display: flex; align-items: center; justify-content: space-between; gap: 10px;
      flex-wrap: wrap;
    }
    .health-card-head h2, .health-card-head h3, .health-card-head .name {
      font-family: var(--font-display); font-size: 16px; font-weight: 700;
      letter-spacing: -0.01em; line-height: 1.2;
    }
    .health-status {
      display: inline-flex; align-items: center; gap: 5px;
      padding: 3px 9px; border-radius: 999px;
      border: 1.5px solid currentColor;
      background: var(--fg-soft); color: var(--muted);
      font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
      letter-spacing: 0.05em; text-transform: uppercase;
      line-height: 1.6; white-space: nowrap;
    }
    .health-status::before {
      content: ''; width: 6px; height: 6px; border-radius: 50%;
      background: currentColor; flex-shrink: 0;
    }
    .health-status-up { background: var(--ok-soft); color: var(--ok); }
    .health-status-down { background: var(--danger-soft); color: var(--danger); }
    .health-status-warn { background: var(--warn-soft); color: var(--warn); }
    .health-status-unknown { background: var(--fg-soft); color: var(--muted); }
    .health-status-checking {
      background: var(--fg-soft); color: var(--muted);
      animation: health-checking-pulse 1.8s ease-in-out infinite;
    }
    @keyframes health-checking-pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.55; }
    }
    @media (prefers-reduced-motion: reduce) {
      .health-status-checking { animation: none; }
    }

    /* Overall summary: status disc + headline, then a dot-keyed count strip. */
    .health-summary {
      display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
      gap: 20px 32px; padding: 22px 24px;
    }
    .health-summary-lead { display: flex; align-items: center; gap: 16px; min-width: 0; }
    .health-summary-disc {
      width: 52px; height: 52px; flex-shrink: 0; border-radius: 50%;
      border: 2px solid var(--fg); box-shadow: var(--shadow-hard-sm);
      display: flex; align-items: center; justify-content: center;
      background: var(--fg-soft); color: var(--muted);
    }
    .health-summary-disc-up { background: var(--ok); color: var(--surface); }
    .health-summary-disc-down { background: var(--danger); color: var(--surface); }
    .health-summary-disc-checking { animation: health-checking-pulse 1.8s ease-in-out infinite; }
    .health-summary-kicker {
      font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
      letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
    }
    .health-summary-up .health-summary-kicker { color: var(--ok); }
    .health-summary-down .health-summary-kicker { color: var(--danger); }
    .health-summary-title {
      margin: 3px 0 0; font-size: 26px; font-weight: 700;
      letter-spacing: -0.02em; line-height: 1.15;
    }
    .health-summary-meta { font-size: 12.5px; margin-top: 4px; }
    .health-counts { display: flex; flex-wrap: wrap; margin: 0; }
    .health-counts > div { padding: 2px 20px; border-left: 2px solid var(--border); }
    .health-counts dt {
      display: flex; align-items: center; gap: 6px;
      font-family: var(--font-mono); font-size: 10.5px; font-weight: 700;
      letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
    }
    .health-counts dd {
      margin: 4px 0 0; font-family: var(--font-display);
      font-size: 24px; font-weight: 700; line-height: 1.1;
    }
    .health-counts dd.is-zero { color: var(--muted); }
    .health-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
    .health-dot-up { background: var(--ok); }
    .health-dot-down { background: var(--danger); }
    .health-dot-unknown { border: 1.5px solid var(--muted); }
    .health-dot-checking { border: 1.5px dashed var(--muted); }
    @media (prefers-reduced-motion: reduce) {
      .health-summary-disc-checking { animation: none; }
    }

    /* ─── detail pages / breadcrumbs (SAH-1366) ─────────────────────── */
    .detail-grid {
      display: grid;
      grid-template-columns: minmax(130px, max-content) minmax(0, 1fr);
      gap: 10px 20px;
      align-items: baseline;
    }
    .detail-grid > dt,
    .detail-grid > .detail-label,
    .detail-grid > :nth-child(odd) {
      color: var(--muted);
      font-family: var(--font-mono); font-size: 11px; font-weight: 700;
      letter-spacing: 0.06em; text-transform: uppercase;
    }
    .detail-grid > dd,
    .detail-grid > .detail-value {
      margin: 0; min-width: 0; overflow-wrap: anywhere;
    }
    .detail-actions {
      display: flex; align-items: center; justify-content: flex-end;
      flex-wrap: wrap; gap: 10px;
    }
    .breadcrumbs {
      display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
      min-width: 0;
      margin: 0; padding: 0;
      list-style: none;
      color: var(--muted);
      font-family: var(--font-mono); font-size: 11.5px;
    }
    .breadcrumbs li { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
    .breadcrumbs a { color: var(--muted); text-decoration: none; }
    .breadcrumbs a:hover { color: var(--fg); text-decoration: underline; text-underline-offset: 2px; }
    .breadcrumbs li + li::before {
      content: '/';
      color: var(--border); font-weight: 700;
    }
    .breadcrumbs [aria-current='page'] { color: var(--fg); font-weight: 700; }
    .page-title-group {
      display: flex; flex-direction: column; gap: 6px;
      min-width: 0;
    }

    /* anchors in button/nav roles inherit no underline */
    a.btn, a.nav-item { text-decoration: none; }

    @media (max-width: 560px) {
      dialog.modal {
        width: calc(100vw - 24px);
        min-width: 0;
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
      }
      .modal-head, .modal-body, .modal-actions { padding-inline: 14px; }
      .detail-grid { grid-template-columns: 1fr; gap: 2px 0; }
      .detail-grid > :nth-child(odd) { margin-top: 10px; }
      .detail-grid > :nth-child(odd):first-child { margin-top: 0; }
    }

    /* Spend meter (team members' monthly spend against their limit). */
    .meter { height: 6px; max-width: 140px; border: 1px solid var(--border); border-radius: 3px; background: var(--surface); overflow: hidden; }
    .meter > span { display: block; height: 100%; background: var(--accent); }

    /* Radio choices inside a modal (remove member: keep or revoke keys). */
    .choice-list { border: 0; padding: 0; margin: 0; display: grid; gap: var(--gap-xs); }
    .choice { display: flex; gap: var(--gap-sm); align-items: flex-start; padding: var(--gap-sm); border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-size: var(--fs-meta); }
    .choice:has(input:checked) { border-color: var(--fg); background: var(--fg-soft); }
    .choice input { margin-top: 2px; }

    /* The platform console reads as a different place from an organisation's
       console: the same light, low-chroma page background, shifted from blue-cyan
       (hue 188) to green. */
    .page-platform { --bg: oklch(95.5% 0.035 150); }

    /* ─── chat (SAH-2159) ────────────────────────────────────────────────
       A two-pane surface that fills the console viewport: the history rail
       scrolls on its own, the transcript on its own, and the composer sits at
       the bottom — the page itself never scrolls. Below 920px the rail becomes
       an off-canvas drawer opened from the chat header. */
    .main.main-chat { padding: 0; height: 100vh; overflow: hidden; }
    body.imp-active .main.main-chat { height: calc(100vh - 43px); }
    .chat-shell { display: flex; height: 100%; min-height: 0; min-width: 0; }
    .chat-rail {
      width: 286px; flex: 0 0 286px; min-height: 0;
      display: flex; flex-direction: column;
      background: var(--surface); border-right: 2px solid var(--fg);
    }
    .chat-rail-head { padding: 14px 14px 0; }
    .chat-new-btn { width: 100%; justify-content: center; }
    .chat-new-btn svg { width: 16px; height: 16px; }
    .chat-rail-search { position: relative; padding: 12px 14px; }
    .chat-rail-search svg {
      position: absolute; left: 26px; top: 50%; width: 15px; height: 15px;
      transform: translateY(-50%); color: var(--muted); pointer-events: none;
    }
    .chat-rail-search .input { padding-left: 34px; font-size: 13px; }
    .chat-rail-list { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 14px; }
    .chat-rail-group {
      padding: 14px 8px 6px; font-family: var(--font-mono); font-size: 10px;
      font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; color: var(--muted);
    }
    .chat-rail-empty { padding: 26px 14px; text-align: center; color: var(--muted); font-size: 13px; line-height: 1.5; }
    .chat-row {
      position: relative; display: flex; align-items: stretch;
      border: 1.5px solid transparent; border-radius: var(--radius); margin-bottom: 2px;
    }
    .chat-row:hover { background: var(--fg-soft); }
    .chat-row.active {
      background: color-mix(in oklch, var(--accent) 16%, var(--surface));
      border-color: var(--fg); box-shadow: var(--shadow-hard-sm);
    }
    .chat-row-main { flex: 1; min-width: 0; display: block; padding: 9px 4px 9px 10px; }
    .chat-row-top { display: flex; align-items: baseline; gap: 8px; }
    .chat-row-title { flex: 1; min-width: 0; font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .chat-row-time { flex-shrink: 0; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
    .chat-row-preview { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .chat-row-del {
      flex-shrink: 0; width: 30px; padding: 0 6px; border: 0; background: transparent;
      color: var(--muted); opacity: 0; border-radius: 8px;
    }
    .chat-row-del svg { width: 15px; height: 15px; margin-inline: auto; }
    .chat-row:hover .chat-row-del, .chat-row.active .chat-row-del, .chat-row-del:focus-visible { opacity: 1; }
    .chat-row-del:hover { color: var(--danger); background: var(--danger-soft); }

    .chat-main { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }
    .chat-head {
      flex-shrink: 0; display: flex; align-items: center; gap: 12px;
      min-height: 64px; padding: 11px 20px; background: var(--surface);
      border-bottom: 2px solid var(--fg);
    }
    .chat-head-main { min-width: 0; flex: 1; }
    .chat-title { font-family: var(--font-display); font-size: 18px; font-weight: 700; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .chat-head-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 3px; min-height: 18px; }
    .chat-model-chip {
      display: inline-flex; align-items: center; padding: 2px 9px;
      border: 1.5px solid var(--border); border-radius: 999px; background: var(--fg-soft);
      font-family: var(--font-mono); font-size: 10.5px; font-weight: 600; color: var(--muted);
    }
    .chat-warn-inline { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; color: var(--warn); }
    .chat-head-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
    .chat-delete:hover { color: var(--danger); background: var(--danger-soft); }
    .chat-drawer-btn {
      display: none; width: 38px; height: 38px; flex-shrink: 0; padding: 0;
      align-items: center; justify-content: center;
      border: 2px solid var(--fg); border-radius: var(--radius); background: var(--surface);
      box-shadow: var(--shadow-hard-sm);
    }
    .chat-drawer-btn svg { width: 19px; height: 19px; }
    .chat-drawer-btn:hover { background: var(--pop-lime); }

    .chat-thread { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
    .chat-transcript { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
    .chat-thread-inner {
      max-width: 840px; margin-inline: auto; padding: 26px 22px 18px;
      display: flex; flex-direction: column; gap: 20px;
    }
    .chat-msg { display: flex; gap: 12px; min-width: 0; }
    .chat-msg-user { justify-content: flex-end; }
    .chat-msg-body {
      min-width: 0; max-width: min(680px, 86%); overflow-wrap: anywhere;
      font-size: 14px; line-height: 1.6;
    }
    .chat-msg-user .chat-msg-body {
      padding: 10px 14px; background: color-mix(in oklch, var(--accent) 22%, var(--surface));
      border: 1.5px solid var(--fg); border-radius: 14px 14px 4px 14px;
      box-shadow: var(--shadow-hard-sm);
    }
    .chat-msg-assistant .chat-msg-main { min-width: 0; max-width: calc(100% - 42px); }
    .chat-msg-assistant .chat-msg-body {
      padding: 11px 14px; background: var(--surface);
      border: 1.5px solid var(--border); border-radius: 4px 14px 14px 14px;
    }
    .chat-msg-avatar {
      width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center;
      background: var(--accent); border: 2px solid var(--fg); border-radius: 9px;
      box-shadow: 2px 2px 0 var(--fg); transform: rotate(-6deg);
      font-family: var(--font-display); font-weight: 800; font-size: 13px;
    }
    .chat-md p { margin: 0 0 10px; }
    .chat-md p:last-child { margin-bottom: 0; }
    .chat-md ul { margin: 4px 0 10px; padding-left: 20px; }
    .chat-md li + li { margin-top: 3px; }
    .chat-md code {
      font-family: var(--font-mono); font-size: 12.5px;
      background: var(--fg-soft); border-radius: 5px; padding: 1px 5px;
    }
    .chat-md pre.chat-code {
      margin: 10px 0; padding: 12px 14px; max-width: 100%; overflow-x: auto;
      background: color-mix(in oklch, var(--fg) 6%, var(--surface));
      border: 1.5px solid var(--border); border-radius: var(--radius);
    }
    .chat-md pre.chat-code code { display: block; padding: 0; background: none; white-space: pre; font-size: 12.5px; line-height: 1.55; }
    .chat-caret {
      display: inline-block; width: 8px; height: 15px; margin-left: 2px;
      background: var(--accent-strong); vertical-align: -2px;
      animation: chatBlink 1s steps(2) infinite;
    }
    @keyframes chatBlink { 0%, 45% { opacity: 1; } 50%, 100% { opacity: 0; } }
    .chat-msg-meta {
      display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
      margin-top: 6px; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted);
    }
    .chat-copy { padding: 0; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }
    .chat-copy:hover { color: var(--fg); }
    .chat-stopped { color: var(--warn); font-weight: 700; }

    .chat-hero { text-align: center; padding: 48px 20px 32px; }
    .chat-hero-mark {
      width: 46px; height: 46px; margin: 0 auto 18px; display: grid; place-items: center;
      background: var(--accent); border: 2px solid var(--fg); border-radius: 13px;
      box-shadow: var(--shadow-hard-sm); transform: rotate(-6deg);
      font-family: var(--font-display); font-weight: 800; font-size: 20px;
    }
    .chat-hero h1 { font-size: clamp(26px, 3vw, 34px); letter-spacing: -0.02em; }
    .chat-hero p { max-width: 520px; margin: 10px auto 0; color: var(--muted); font-size: 14px; }
    .chat-hero-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 20px; }
    .chat-models { display: flex; flex-direction: column; align-items: center; gap: 7px; max-width: 360px; margin: 24px auto 0; }
    .chat-model-label { font-family: var(--font-mono); font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
    .chat-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 22px; }
    .chat-chip {
      padding: 7px 13px; border: 1.5px solid var(--border); border-radius: 999px;
      background: var(--surface); font-size: 12.5px; font-weight: 600;
    }
    .chat-chip:hover { border-color: var(--fg); background: var(--pop-lime); }
    .chat-state { text-align: center; padding: 48px 20px; color: var(--muted); }
    .chat-state h2 { font-family: var(--font-display); font-size: 24px; color: var(--fg); margin-bottom: 8px; }
    .chat-state p { max-width: 480px; margin: 0 auto; font-size: 14px; }
    .chat-state-mark {
      width: 42px; height: 42px; margin: 0 auto 14px; display: grid; place-items: center;
      border: 2px solid var(--fg); border-radius: 12px; background: var(--warn-soft);
      color: var(--warn); font-family: var(--font-display); font-weight: 800; font-size: 20px;
    }
    .chat-loading { color: var(--muted); font-family: var(--font-mono); font-size: 12.5px; }
    .chat-warning {
      display: flex; align-items: center; justify-content: space-between; gap: 14px;
      padding: 12px 14px; border: 2px solid var(--warn); border-radius: var(--radius);
      background: var(--warn-soft); font-size: 13px;
    }
    .chat-warning strong { display: block; color: var(--warn); }

    .chat-jump {
      position: absolute; left: 50%; bottom: 124px; z-index: 5;
      transform: translateX(-50%);
      padding: 6px 13px; border: 1.5px solid var(--fg); border-radius: 999px;
      background: var(--surface); box-shadow: var(--shadow-hard-sm);
      font-family: var(--font-mono); font-size: 11px; font-weight: 700;
    }
    .chat-jump[hidden] { display: none; }
    .chat-jump:hover { background: var(--pop-lime); }

    .chat-composer-wrap { flex-shrink: 0; padding: 10px 20px 16px; background: var(--bg); }
    .chat-composer { max-width: 840px; margin-inline: auto; }
    .chat-error-bar {
      margin-bottom: 8px; padding: 9px 12px; border: 1.5px solid var(--danger);
      border-radius: var(--radius); background: var(--danger-soft);
      color: var(--danger); font-size: 13px; font-weight: 600;
    }
    .chat-hint-warn { margin-bottom: 8px; color: var(--warn); font-weight: 600; }
    .chat-compose-box {
      display: flex; align-items: flex-end; gap: 8px;
      padding: 8px 8px 8px 14px; background: var(--surface);
      border: 2px solid var(--fg); border-radius: var(--radius-lg);
      box-shadow: var(--shadow-hard-sm); transition: box-shadow 0.12s ease;
    }
    .chat-compose-box:focus-within { box-shadow: var(--shadow-hard); }
    .chat-input {
      flex: 1; min-width: 0; min-height: 24px; max-height: 200px; resize: none;
      padding: 6px 0; border: 0; outline: none; background: transparent;
      color: var(--fg); font: inherit; font-size: 14px; line-height: 1.5;
    }
    .chat-input::placeholder { color: var(--muted); }
    .chat-input:disabled { cursor: not-allowed; opacity: .6; }
    .chat-send, .chat-stop { flex-shrink: 0; padding: 8px 14px; border-radius: 10px; }
    .chat-compose-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 7px; }
    .chat-compose-foot .chat-hint { color: var(--muted); font-size: 11px; }
    .chat-count { margin-left: auto; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
    .chat-count.over { color: var(--danger); font-weight: 700; }
    .chat-scrim { display: none; }

    @media (max-width: 920px) {
      .main.main-chat { height: calc(100dvh - 56px); min-height: 380px; }
      body.imp-active .main.main-chat { height: calc(100dvh - 99px); }
      .chat-rail {
        position: fixed; top: 0; bottom: 0; left: 0; z-index: 80;
        width: min(312px, 86vw); flex-basis: auto;
        border-right: 2px solid var(--fg); box-shadow: 7px 0 0 color-mix(in oklch, var(--fg) 18%, transparent);
        transform: translateX(-104%); transition: transform 0.18s ease;
      }
      .chat-rail.open { transform: translateX(0); }
      .chat-scrim { display: block; position: fixed; inset: 0; z-index: 75; background: color-mix(in oklch, var(--fg) 38%, transparent); }
      .chat-scrim[hidden] { display: none; }
      .chat-drawer-btn { display: inline-flex; }
      .chat-head { padding: 9px 12px; min-height: 58px; }
      .chat-title { font-size: 16px; }
      .chat-thread-inner { padding: 18px 14px 14px; gap: 16px; }
      .chat-composer-wrap { padding: 8px 12px 12px; }
      .chat-jump { bottom: 116px; }
      .chat-msg-body { max-width: 88%; }
      .chat-msg-assistant .chat-msg-main { max-width: calc(100% - 40px); }
      .chat-hero { padding: 30px 14px 18px; }
    }
    @media (max-width: 420px) {
      .chat-compose-foot .chat-hint { display: none; }
      .chat-msg-avatar { width: 26px; height: 26px; font-size: 11px; }
      .chat-msg-assistant .chat-msg-main { max-width: calc(100% - 36px); }
    }
    @media (prefers-reduced-motion: reduce) {
      .chat-caret { animation: none; }
      .chat-rail { transition: none; }
    }
