/* ==========================================================================
   Rapax design system v2 (production, /ui/ds/) - docs/rapax-v2-ui-ux-requirements.md
   Copied from mockups/ds/rapax.css; keep the two in step until the mockups retire.
   DS-01 cascade layers, --rx- tokens, .rx- component classes
   THM-01 Dark (default) / Light / Match system; Appendix F contrast-checked values
   SEV-01/02 seven severities, each with shape + label + color
   BRD-03 only brand inputs are brandable; severity/data-viz/contrast are locked
   ========================================================================== */
@layer reset, tokens, base, components, vendor, page;

/* ---------------------------------------------------------------- tokens */
@layer tokens {
  :root {
    /* brand inputs - the ONLY values /api/branding.css (generated from etc/branding.json) overrides */
    --rx-brand: #2D7A6F;                 /* Rapax Teal; interactive tones derived below */
    --rx-brand-mark: #E8450A;            /* Rapax Orange - logo/mark only, never UI state */
    --rx-font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --rx-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --rx-radius: 6px;
    --rx-radius-lg: 10px;

    --rx-text-xs: 12px; --rx-text-sm: 13px; --rx-text-md: 14px; --rx-text-lg: 16px; --rx-text-xl: 20px; --rx-text-2xl: 24px;
    --rx-space-1: 4px; --rx-space-2: 8px; --rx-space-3: 12px; --rx-space-4: 16px; --rx-space-5: 20px; --rx-space-6: 24px; --rx-space-8: 32px;
    --rx-row-height: 32px;               /* DS-08 compact default */
    --rx-header-h: 48px;                 /* SHELL-02 */
    --rx-nav-w: 236px;
  }

  /* DARK = default (THM-01): applies unless data-theme="light", or "system" + OS light */
  :root {
    color-scheme: dark;
    --rx-surface-0: #111822;
    --rx-surface-1: #1A2332;             /* brand Navy */
    --rx-surface-2: #222D3F;
    --rx-surface-3: #2B384D;
    --rx-nav-bg: #0D131B;
    --rx-text: #E6E9EE;
    --rx-text-2: #A7B0BD;
    --rx-text-disabled: #6B7586;
    --rx-border-subtle: #2A3547;
    --rx-border-control: #6B7890;
    --rx-interactive: #4FB3A5;           /* teal tint: 5.5-7.1:1 */
    --rx-on-interactive: #111822;
    --rx-interactive-soft: color-mix(in oklab, var(--rx-interactive) 16%, var(--rx-surface-1));
    --rx-focus: #7FD1C5;
    --rx-shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --rx-shadow-2: 0 12px 32px rgba(0, 0, 0, .5);
    --rx-scrim: rgba(5, 8, 12, .6);

    --rx-sev-critical-fg: #FF6B6B; --rx-sev-major-fg: #FF9A3C; --rx-sev-minor-fg: #F2C94C;
    --rx-sev-warning-fg: #6EA8FF;  --rx-sev-info-fg: #A7B0BD;  --rx-sev-clear-fg: #6FCF7F;
    --rx-sev-unknown-fg: #A7B0BD;  --rx-sev-on: #111822;
    /* chart marks (fills, lines): dark mode reuses the fg tones */
    --rx-sev-critical-mark: var(--rx-sev-critical-fg); --rx-sev-major-mark: var(--rx-sev-major-fg); --rx-sev-minor-mark: var(--rx-sev-minor-fg);
    --rx-sev-warning-mark: var(--rx-sev-warning-fg); --rx-sev-info-mark: #7D8796; --rx-sev-clear-mark: var(--rx-sev-clear-fg); --rx-sev-unknown-mark: #5E6878;

    --rx-viz-cat-1: #3987e5; --rx-viz-cat-2: #d95926; --rx-viz-cat-3: #199e70; --rx-viz-cat-4: #c98500;
    --rx-viz-cat-5: #d55181; --rx-viz-cat-6: #008300; --rx-viz-cat-7: #9085e9; --rx-viz-cat-8: #e66767;
    --rx-viz-grid: #263142; --rx-viz-baseline: #6B7890;
  }
}

/* LIGHT values, applied for data-theme=light, or data-theme=system with an OS light preference */
@layer tokens {
  :root[data-theme="light"] {
    color-scheme: light;
    --rx-surface-0: #F5F4EE; --rx-surface-1: #FFFFFF; --rx-surface-2: #ECEBE4; --rx-surface-3: #E2E1D9;
    --rx-nav-bg: #1A2332;
    --rx-text: #1A2332; --rx-text-2: #4B5563; --rx-text-disabled: #8B93A0;
    --rx-border-subtle: #DEDCD3; --rx-border-control: #6F7888;
    --rx-interactive: #276B61; --rx-on-interactive: #FFFFFF; --rx-focus: #276B61;
    --rx-interactive-soft: color-mix(in oklab, var(--rx-interactive) 12%, white);
    --rx-shadow-1: 0 1px 2px rgba(26, 35, 50, .08), 0 1px 3px rgba(26, 35, 50, .06);
    --rx-shadow-2: 0 12px 32px rgba(26, 35, 50, .18);
    --rx-scrim: rgba(26, 35, 50, .45);
    --rx-sev-critical-fg: #B71C1C; --rx-sev-major-fg: #A34100; --rx-sev-minor-fg: #7A5E00;
    --rx-sev-warning-fg: #1B56BA;  --rx-sev-info-fg: #4B5563;  --rx-sev-clear-fg: #1B6E34;
    --rx-sev-unknown-fg: #4B5563;  --rx-sev-on: #FFFFFF;
    --rx-sev-critical-mark: #E5484D; --rx-sev-major-mark: #F07A1A; --rx-sev-minor-mark: #E2B203;
    --rx-sev-warning-mark: #3B82F6; --rx-sev-info-mark: #9AA3AF; --rx-sev-clear-mark: #2FA556; --rx-sev-unknown-mark: #C3C8CF;
    --rx-viz-cat-1: #2a78d6; --rx-viz-cat-2: #eb6834; --rx-viz-cat-3: #1baf7a; --rx-viz-cat-4: #eda100;
    --rx-viz-cat-5: #e87ba4; --rx-viz-cat-6: #008300; --rx-viz-cat-7: #4a3aa7; --rx-viz-cat-8: #e34948;
    --rx-viz-grid: #E4E2DA; --rx-viz-baseline: #6F7888;
  }
  @media (prefers-color-scheme: light) {
    :root[data-theme="system"] {
      color-scheme: light;
      --rx-surface-0: #F5F4EE; --rx-surface-1: #FFFFFF; --rx-surface-2: #ECEBE4; --rx-surface-3: #E2E1D9;
      --rx-nav-bg: #1A2332;
      --rx-text: #1A2332; --rx-text-2: #4B5563; --rx-text-disabled: #8B93A0;
      --rx-border-subtle: #DEDCD3; --rx-border-control: #6F7888;
      --rx-interactive: #276B61; --rx-on-interactive: #FFFFFF; --rx-focus: #276B61;
      --rx-interactive-soft: color-mix(in oklab, var(--rx-interactive) 12%, white);
      --rx-shadow-1: 0 1px 2px rgba(26, 35, 50, .08), 0 1px 3px rgba(26, 35, 50, .06);
      --rx-shadow-2: 0 12px 32px rgba(26, 35, 50, .18);
      --rx-scrim: rgba(26, 35, 50, .45);
      --rx-sev-critical-fg: #B71C1C; --rx-sev-major-fg: #A34100; --rx-sev-minor-fg: #7A5E00;
      --rx-sev-warning-fg: #1B56BA;  --rx-sev-info-fg: #4B5563;  --rx-sev-clear-fg: #1B6E34;
      --rx-sev-unknown-fg: #4B5563;  --rx-sev-on: #FFFFFF;
    --rx-sev-critical-mark: #E5484D; --rx-sev-major-mark: #F07A1A; --rx-sev-minor-mark: #E2B203;
    --rx-sev-warning-mark: #3B82F6; --rx-sev-info-mark: #9AA3AF; --rx-sev-clear-mark: #2FA556; --rx-sev-unknown-mark: #C3C8CF;
      --rx-viz-cat-1: #2a78d6; --rx-viz-cat-2: #eb6834; --rx-viz-cat-3: #1baf7a; --rx-viz-cat-4: #eda100;
      --rx-viz-cat-5: #e87ba4; --rx-viz-cat-6: #008300; --rx-viz-cat-7: #4a3aa7; --rx-viz-cat-8: #e34948;
      --rx-viz-grid: #E4E2DA; --rx-viz-baseline: #6F7888;
    }
  }
  :root[data-density="comfortable"] { --rx-row-height: 40px; }
}

/* ---------------------------------------------------------------- reset + base */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html, body { height: 100%; margin: 0; }
  button, input, select, textarea { font: inherit; color: inherit; }
}
@layer base {
  /* body is a column so anything injected above the shell (license banner) takes its
     height from the app instead of pushing it off-screen */
  body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; background: var(--rx-surface-0); color: var(--rx-text); font: var(--rx-text-md)/1.45 var(--rx-font-sans); -webkit-font-smoothing: antialiased; }
  a { color: var(--rx-interactive); text-decoration: none; }
  a:hover { text-decoration: underline; }
  /* a link inside running text is underlined, not told apart by colour alone (WCAG 1.4.1) */
  :is(p, dd, .rx-note) > a:not([class]) { text-decoration: underline; text-underline-offset: 2px; }
  h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; }
  h1 { font-size: var(--rx-text-xl); } h2 { font-size: var(--rx-text-lg); } h3 { font-size: var(--rx-text-md); }
  p { margin: 0 0 8px; }
  code, kbd, .rx-mono { font-family: var(--rx-font-mono); font-size: 12.5px; }
  kbd { border: 1px solid var(--rx-border-control); border-radius: 4px; padding: 0 5px; color: var(--rx-text-2); }
  :focus-visible { outline: 2px solid var(--rx-focus); outline-offset: 2px; }
  hr { border: 0; border-top: 1px solid var(--rx-border-subtle); margin: 16px 0; }
  .rx-muted { color: var(--rx-text-2); }
  .rx-num { font-variant-numeric: tabular-nums; }
  .rx-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  svg.rx-i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
}

/* ---------------------------------------------------------------- components */
@layer components {
  /* shell (SHELL-01/02, NAV-01) */
  .rx-app { display: grid; grid-template-columns: var(--rx-nav-w) 1fr; grid-template-rows: var(--rx-header-h) auto 1fr; flex: 1 1 auto; min-height: 0; }
  .rx-app.nav-collapsed { --rx-nav-w: 60px; }
  .rx-nav { grid-row: 1 / span 3; background: var(--rx-nav-bg); color: #DCE3EA; display: flex; flex-direction: column; overflow: hidden auto; }
  .rx-logo { display: flex; align-items: center; gap: 10px; height: var(--rx-header-h); padding: 0 14px; font-weight: 700; color: #fff; white-space: nowrap; text-decoration: none !important; flex: none; }
  .rx-logo .mark { width: 26px; height: 26px; border-radius: 6px; background: var(--rx-brand-mark); color: #fff; display: grid; place-items: center; font-size: 14px; flex: none; }
  .rx-nav-group { padding: 8px 8px 2px; }
  .rx-nav-group > h4 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: #8C99A8; padding: 6px 8px; white-space: nowrap; }
  .rx-nav-item { display: flex; align-items: center; gap: 10px; padding: 6px 10px; margin: 1px 0; border-radius: var(--rx-radius); color: #DCE3EA; white-space: nowrap; text-decoration: none !important; font-size: var(--rx-text-sm); }
  .rx-nav-item:hover { background: rgba(255, 255, 255, .06); }
  .rx-nav-item[aria-current="page"] { background: rgba(79, 179, 165, .16); color: #fff; box-shadow: inset 3px 0 0 #4FB3A5; }
  .rx-nav-item.disabled { opacity: .5; }
  .rx-nav-item .badge { margin-left: auto; font-size: 11px; font-weight: 700; border-radius: 9px; padding: 0 6px; background: #FF6B6B; color: #111822; }
  .rx-app.nav-collapsed .rx-nav-item span, .rx-app.nav-collapsed .rx-nav-group > h4, .rx-app.nav-collapsed .rx-logo .name, .rx-app.nav-collapsed .rx-nav-item .badge { display: none; }
  .rx-nav .spacer { flex: 1; }
  .rx-nav .foot { padding: 8px; border-top: 1px solid rgba(255, 255, 255, .08); }
  .rx-header { grid-column: 2; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px; background: var(--rx-surface-1); border-bottom: 1px solid var(--rx-border-subtle); min-width: 0; }
  .rx-header .title { font-weight: 600; white-space: nowrap; }
  .rx-header .crumbs { color: var(--rx-text-2); font-size: var(--rx-text-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rx-banner-slot { grid-column: 2; }
  .rx-main { grid-column: 2; overflow: auto; min-width: 0; min-height: 0; }
  .rx-page { padding: 20px 24px 48px; max-width: 1680px; }
  .rx-page.full { padding: 0; max-width: none; height: 100%; }
  .rx-page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
  .rx-grow { flex: 1; }
  .rx-cmd { flex: 1 1 320px; max-width: 460px; min-width: 0; overflow: hidden; white-space: nowrap; display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border: 1px solid var(--rx-border-subtle); border-radius: var(--rx-radius); background: var(--rx-surface-0); color: var(--rx-text-2); }
  .rx-cmd > span { overflow: hidden; text-overflow: ellipsis; text-align: left; }
  .rx-cmd kbd { white-space: nowrap; }
  .rx-cmd input { border: 0; background: none; outline: none; flex: 1; min-width: 0; color: var(--rx-text); }
  .rx-tenant { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 10px; border: 1px solid var(--rx-border-subtle); border-radius: 999px; background: var(--rx-surface-2); font-size: var(--rx-text-sm); white-space: nowrap; cursor: pointer; }
  .rx-tenant .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--rx-interactive); }
  .rx-health { display: inline-flex; align-items: center; gap: 6px; font-size: var(--rx-text-sm); color: var(--rx-text-2); white-space: nowrap; }
  .rx-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--rx-interactive-soft); color: var(--rx-interactive); border: 0; cursor: pointer; flex: none; }
  .rx-footer { padding: 16px 24px; color: var(--rx-text-2); font-size: var(--rx-text-xs); border-top: 1px solid var(--rx-border-subtle); }

  /* buttons (DS-09) - danger is for destructive actions only */
  .rx-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 30px; min-width: 24px; padding: 0 12px; border-radius: var(--rx-radius); border: 1px solid var(--rx-border-control); background: var(--rx-surface-1); color: var(--rx-text); font-weight: 500; font-size: var(--rx-text-sm); cursor: pointer; white-space: nowrap; text-decoration: none !important; }
  .rx-btn:hover { background: var(--rx-surface-2); }
  .rx-btn.primary { background: var(--rx-interactive); border-color: var(--rx-interactive); color: var(--rx-on-interactive); }
  .rx-btn.primary:hover { background: color-mix(in oklab, var(--rx-interactive) 88%, var(--rx-text)); }
  .rx-btn.ghost { border-color: transparent; background: none; color: var(--rx-text-2); }
  .rx-btn.ghost:hover { background: var(--rx-surface-2); color: var(--rx-text); }
  .rx-btn.danger { border-color: var(--rx-sev-critical-fg); color: var(--rx-sev-critical-fg); }
  .rx-btn.sm { min-height: 26px; padding: 0 8px; font-size: var(--rx-text-xs); }
  .rx-btn.icon { padding: 0; width: 30px; }
  .rx-btn.sm.icon { width: 26px; }
  .rx-btn[aria-pressed="true"] { background: var(--rx-interactive-soft); border-color: var(--rx-interactive); color: var(--rx-interactive); }
  .rx-btn:disabled { opacity: .5; cursor: not-allowed; }
  /* working: set aria-busy="true" (and disabled) on the button the moment it is clicked - a ring
     before its label; reduced motion keeps the ring still, the label says what is happening */
  .rx-btn[aria-busy="true"] { cursor: progress; opacity: .85; }
  .rx-btn[aria-busy="true"]::before { content: ''; flex: none; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rx-spin .7s linear infinite; }
  @keyframes rx-spin { to { transform: rotate(360deg); } }
  .rx-btn-group { display: inline-flex; }
  .rx-btn-group > .rx-btn { border-radius: 0; margin-left: -1px; }
  .rx-btn-group > .rx-btn:first-child { border-radius: var(--rx-radius) 0 0 var(--rx-radius); margin-left: 0; }
  .rx-btn-group > .rx-btn:last-child { border-radius: 0 var(--rx-radius) var(--rx-radius) 0; }

  /* forms */
  .rx-field { display: grid; gap: 4px; margin-bottom: 12px; }
  .rx-field > label, .rx-label { font-size: var(--rx-text-xs); font-weight: 600; color: var(--rx-text-2); }
  .rx-field .hint { font-size: var(--rx-text-xs); color: var(--rx-text-2); }
  .rx-input { height: 32px; padding: 0 10px; border: 1px solid var(--rx-border-control); border-radius: var(--rx-radius); background: var(--rx-surface-0); color: var(--rx-text); width: 100%; }
  textarea.rx-input { height: auto; padding: 8px 10px; resize: vertical; min-height: 84px; }
  .rx-input:focus { outline: none; border-color: var(--rx-focus); box-shadow: 0 0 0 2px color-mix(in oklab, var(--rx-focus) 35%, transparent); }
  .rx-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; font-size: var(--rx-text-sm); }
  .rx-check input { accent-color: var(--rx-interactive); width: 15px; height: 15px; }
  .rx-switch { position: relative; width: 34px; height: 20px; flex: none; display: inline-block; }
  .rx-switch input { opacity: 0; width: 0; height: 0; }
  .rx-switch span { position: absolute; inset: 0; background: var(--rx-border-control); border-radius: 20px; cursor: pointer; transition: .15s; }
  .rx-switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: .15s; }
  .rx-switch input:checked + span { background: var(--rx-interactive); }
  .rx-switch input:checked + span::before { transform: translateX(14px); }
  .rx-row { display: flex; align-items: center; gap: 8px; }
  .rx-row.wrap { flex-wrap: wrap; }
  .rx-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .rx-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .rx-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

  /* cards, tiles */
  .rx-card { background: var(--rx-surface-1); border: 1px solid var(--rx-border-subtle); border-radius: var(--rx-radius-lg); box-shadow: var(--rx-shadow-1); min-width: 0; }
  .rx-card > header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--rx-border-subtle); min-height: 44px; }
  .rx-card > header h2, .rx-card > header h3 { flex: 1; font-size: var(--rx-text-md); }
  .rx-card > .body { padding: 14px; }
  .rx-card > .body.flush { padding: 0; }
  .rx-tile { display: block; padding: 12px 14px; color: var(--rx-text); text-decoration: none !important; border: 1px solid var(--rx-border-subtle); border-radius: var(--rx-radius-lg); background: var(--rx-surface-1); text-align: left; cursor: pointer; width: 100%; }
  .rx-tile:hover { border-color: var(--rx-border-control); }
  .rx-tile[aria-pressed="true"] { border-color: var(--rx-interactive); box-shadow: inset 0 0 0 1px var(--rx-interactive); }
  .rx-tile .k { font-size: var(--rx-text-xs); color: var(--rx-text-2); font-weight: 600; }
  .rx-tile .v { font-size: var(--rx-text-2xl); font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
  .rx-tile .d { font-size: var(--rx-text-xs); color: var(--rx-text-2); }

  /* severity (SEV-01/02): shape + label + color, never color alone */
  .rx-sev { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: var(--rx-text-sm); white-space: nowrap; color: var(--sev); }
  .rx-sev::before { content: ""; width: 12px; height: 12px; flex: none; background: var(--sev); }
  .rx-sev.critical { --sev: var(--rx-sev-critical-fg); } .rx-sev.critical::before { clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
  .rx-sev.major    { --sev: var(--rx-sev-major-fg); }    .rx-sev.major::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
  .rx-sev.minor    { --sev: var(--rx-sev-minor-fg); }    .rx-sev.minor::before { clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%); width: 11px; height: 11px; }
  .rx-sev.warning  { --sev: var(--rx-sev-warning-fg); }  .rx-sev.warning::before { border-radius: 50%; mask: radial-gradient(circle, transparent 0 1.5px, #000 2px); }
  .rx-sev.info     { --sev: var(--rx-sev-info-fg); }     .rx-sev.info::before { border-radius: 50%; width: 10px; height: 10px; }
  .rx-sev.clear    { --sev: var(--rx-sev-clear-fg); }    .rx-sev.clear::before { clip-path: polygon(14% 52%, 0 66%, 38% 100%, 100% 20%, 86% 6%, 38% 72%); }
  .rx-sev.unknown  { --sev: var(--rx-sev-unknown-fg); }  .rx-sev.unknown::before { background: none; border: 2px dashed var(--sev); border-radius: 50%; width: 11px; height: 11px; }
  .rx-sev.solid { padding: 1px 8px 1px 6px; border-radius: 999px; background: var(--sev); color: var(--rx-sev-on); }
  .rx-sev.solid::before { background: var(--rx-sev-on); }
  .rx-sev.solid.unknown::before { background: none; border-color: var(--rx-sev-on); }
  .rx-sev.icon-only { font-size: 0; gap: 0; }
  .rx-stripe { box-shadow: inset 4px 0 0 var(--sev, transparent); }
  /* operational states (SEV-05) - not severities */
  .rx-status { display: inline-flex; align-items: center; gap: 5px; font-size: var(--rx-text-xs); font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--rx-border-subtle); color: var(--rx-text-2); white-space: nowrap; }
  .rx-status.ack::before { content: "\2713"; }
  .rx-status.stale { border-style: dashed; }
  .rx-status.maint::before { content: "\23F8"; }
  .rx-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--rx-sev-unknown-fg); }
  .rx-dot.up { background: var(--rx-sev-clear-fg); } .rx-dot.down { background: var(--rx-sev-critical-fg); } .rx-dot.degraded { background: var(--rx-sev-minor-fg); }

  /* badges, chips (filter bar) */
  .rx-badge { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 999px; font-size: var(--rx-text-xs); font-weight: 600; background: var(--rx-surface-2); color: var(--rx-text-2); white-space: nowrap; line-height: 20px; }
  .rx-badge.brand { background: var(--rx-interactive-soft); color: var(--rx-interactive); }
  .rx-chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 10px; border: 1px solid var(--rx-border-control); border-radius: 999px; background: var(--rx-surface-1); font-size: var(--rx-text-xs); white-space: nowrap; }
  .rx-chip b { font-weight: 600; }
  .rx-chip .x { border: 0; background: none; color: var(--rx-text-2); cursor: pointer; width: 20px; height: 20px; border-radius: 50%; }
  .rx-chip .x:hover { background: var(--rx-surface-2); }
  .rx-chip.add { border-style: dashed; color: var(--rx-text-2); padding: 0 10px; cursor: pointer; }

  /* tabs, segmented */
  .rx-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--rx-border-subtle); padding: 0 8px; overflow-x: auto; background: var(--rx-surface-1); }
  .rx-tabs [role="tab"] { display: flex; align-items: center; gap: 6px; padding: 9px 12px; border: 0; background: none; color: var(--rx-text-2); font-weight: 500; font-size: var(--rx-text-sm); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
  .rx-tabs [role="tab"]:hover { color: var(--rx-text); }
  .rx-tabs [role="tab"][aria-selected="true"] { color: var(--rx-text); border-bottom-color: var(--rx-interactive); }
  .rx-seg { display: inline-flex; padding: 2px; background: var(--rx-surface-2); border-radius: calc(var(--rx-radius) + 2px); gap: 2px; }
  .rx-seg button { border: 0; background: none; padding: 4px 10px; border-radius: var(--rx-radius); font-weight: 500; font-size: var(--rx-text-xs); color: var(--rx-text-2); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
  .rx-seg button[aria-pressed="true"] { background: var(--rx-surface-1); color: var(--rx-text); box-shadow: var(--rx-shadow-1); }

  /* grid (stands in for <rapax-grid> over ag-Grid) */
  /* position: the containing block of absolute children (.rx-sr labels in cells) - else they
     escape the scroll box and widen the page */
  .rx-table-wrap { overflow: auto; position: relative; }
  table.rx-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--rx-text-sm); }
  table.rx-table th { position: sticky; top: 0; z-index: 1; text-align: left; font-weight: 600; font-size: var(--rx-text-xs); color: var(--rx-text-2); background: var(--rx-surface-2); height: var(--rx-row-height); padding: 0 10px; border-bottom: 1px solid var(--rx-border-subtle); white-space: nowrap; }
  table.rx-table td { height: var(--rx-row-height); padding: 0 10px; border-bottom: 1px solid var(--rx-border-subtle); white-space: nowrap; }
  table.rx-table tbody tr:hover td { background: color-mix(in oklab, var(--rx-surface-2) 70%, transparent); }
  table.rx-table tr[aria-selected="true"] td { background: var(--rx-interactive-soft); }
  table.rx-table td.num, table.rx-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
  table.rx-table td.wrap { white-space: normal; }

  /* drawer (peek), modal, menu, toast, banner */
  .rx-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--rx-surface-1); box-shadow: var(--rx-shadow-2); border-left: 1px solid var(--rx-border-subtle); display: flex; flex-direction: column; z-index: 40; transform: translateX(105%); transition: transform .18s; }
  .rx-drawer.open { transform: none; }
  .rx-drawer > header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--rx-border-subtle); }
  .rx-drawer > header h2 { flex: 1; }
  .rx-drawer > .body { flex: 1; overflow: auto; padding: 16px; }
  .rx-modal-back { position: fixed; inset: 0; background: var(--rx-scrim); display: none; place-items: center; z-index: 50; }
  .rx-modal-back.open { display: grid; }
  .rx-modal { width: min(560px, calc(100vw - 32px)); background: var(--rx-surface-1); border: 1px solid var(--rx-border-subtle); border-radius: 12px; box-shadow: var(--rx-shadow-2); }
  .rx-modal > header { padding: 14px 16px; border-bottom: 1px solid var(--rx-border-subtle); }
  .rx-modal > .body { padding: 16px; }
  .rx-modal > footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--rx-border-subtle); }
  .rx-menu { position: fixed; min-width: 210px; background: var(--rx-surface-1); border: 1px solid var(--rx-border-subtle); border-radius: var(--rx-radius-lg); box-shadow: var(--rx-shadow-2); padding: 4px; z-index: 45; display: none; }
  .rx-menu.open { display: block; }
  .rx-menu [role^="menuitem"] { display: flex; width: 100%; align-items: center; gap: 8px; padding: 7px 10px; border: 0; background: none; border-radius: var(--rx-radius); color: var(--rx-text); font-size: var(--rx-text-sm); cursor: pointer; text-align: left; text-decoration: none !important; }
  .rx-menu [role^="menuitem"]:hover, .rx-menu [role^="menuitem"]:focus { background: var(--rx-surface-2); outline: none; }
  .rx-menu .group { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--rx-text-2); padding: 6px 10px 2px; }
  .rx-menu hr { margin: 4px 0; }
  .rx-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--rx-text); color: var(--rx-surface-0); padding: 10px 14px; border-radius: var(--rx-radius-lg); box-shadow: var(--rx-shadow-2); z-index: 60; font-size: var(--rx-text-sm); display: none; align-items: center; gap: 12px; }
  .rx-toast.show { display: flex; }
  .rx-toast button { background: none; border: 0; color: var(--rx-surface-0); font-weight: 700; text-decoration: underline; cursor: pointer; }
  .rx-banner { display: flex; align-items: center; gap: 10px; padding: 8px 16px; font-size: var(--rx-text-sm); border-bottom: 1px solid var(--rx-border-subtle); background: color-mix(in oklab, var(--rx-sev-minor-fg) 14%, var(--rx-surface-1)); }
  .rx-banner.stale { background: color-mix(in oklab, var(--rx-sev-warning-fg) 14%, var(--rx-surface-1)); }

  /* states (STATE-*) */
  .rx-empty { padding: 32px; text-align: center; color: var(--rx-text-2); }
  .rx-skel { background: linear-gradient(90deg, var(--rx-surface-2), var(--rx-surface-3), var(--rx-surface-2)); background-size: 200% 100%; animation: rx-shimmer 1.4s infinite; border-radius: 4px; height: 12px; }
  @keyframes rx-shimmer { to { background-position: -200% 0; } }
  .rx-note { border-left: 3px solid var(--rx-interactive); background: var(--rx-interactive-soft); padding: 10px 12px; border-radius: 0 var(--rx-radius) var(--rx-radius) 0; font-size: var(--rx-text-sm); color: var(--rx-text); }
  .rx-kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: var(--rx-text-sm); }
  .rx-kv dt { color: var(--rx-text-2); }
  .rx-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }


  /* command palette (SHELL-04) */
  .rx-palette { width: min(640px, calc(100vw - 32px)); align-self: start; margin-top: 12vh; overflow: hidden; }
  .rx-cmd.big { max-width: none; height: 48px; border: 0; border-bottom: 1px solid var(--rx-border-subtle); border-radius: 0; background: none; font-size: var(--rx-text-lg); }
  .rx-palette-list { max-height: 50vh; overflow: auto; padding: 4px; }
  .rx-palette-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--rx-radius); cursor: pointer; font-size: var(--rx-text-sm); }
  .rx-palette-item[aria-selected="true"], .rx-palette-item:hover { background: var(--rx-surface-2); }
  .rx-palette > footer { display: flex; gap: 14px; padding: 8px 12px; border-top: 1px solid var(--rx-border-subtle); font-size: var(--rx-text-xs); }
  .rx-menu [aria-checked="true"] { color: var(--rx-interactive); font-weight: 600; }
  .rx-menu [aria-checked="true"]::after { content: "\2713"; margin-left: 6px; }
  .rx-nav .foot .rx-btn.rx-nav-item { width: 100%; justify-content: flex-start; border: 0; color: #DCE3EA; min-height: 0; font-weight: 400; }

  /* assistant identity colors: categorical slots, fixed order (never cycled) */
  .rx-a-oscar { --a: var(--rx-viz-cat-1); } .rx-a-nora { --a: var(--rx-viz-cat-3); } .rx-a-wade { --a: var(--rx-viz-cat-7); }
  .rx-a-grace { --a: var(--rx-viz-cat-5); } .rx-a-bruce { --a: var(--rx-viz-cat-2); } .rx-a-frank { --a: var(--rx-viz-cat-4); }
  .rx-av { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; background: var(--a, var(--rx-surface-3)); color: #fff; }
  .rx-av.sm { width: 18px; height: 18px; font-size: 10px; } .rx-av.xs { width: 10px; height: 10px; font-size: 0; } .rx-av.lg { width: 56px; height: 56px; font-size: 22px; }

  /* filter bar (FLT-01): chips + editable query, one row above the data */
  .rx-filterbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 8px 12px; border-bottom: 1px solid var(--rx-border-subtle); background: var(--rx-surface-1); }
  .rx-filterbar .q { flex: 1; min-width: 220px; font-family: var(--rx-font-mono); font-size: 12.5px; }
  .rx-spark { width: 100%; height: 34px; display: block; }
  .rx-spark path.l { fill: none; stroke: var(--rx-interactive); stroke-width: 2; }
  .rx-spark path.a { fill: color-mix(in oklab, var(--rx-interactive) 18%, transparent); stroke: none; }
  .rx-subnav { display: grid; align-content: start; gap: 1px; padding: 12px 8px; border-right: 1px solid var(--rx-border-subtle); background: var(--rx-surface-1); overflow: auto; }
  .rx-subnav h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--rx-text-2); padding: 12px 10px 4px; font-weight: 600; }
  .rx-subnav a { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: var(--rx-radius); color: var(--rx-text); font-size: var(--rx-text-sm); text-decoration: none !important; }
  .rx-subnav a:hover { background: var(--rx-surface-2); }
  .rx-subnav a[aria-current="page"] { background: var(--rx-interactive-soft); color: var(--rx-interactive); font-weight: 600; }
  .rx-split { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100%; min-height: 0; }
  .rx-split > section { overflow: auto; min-width: 0; }

  /* production shell additions */
  /* locked SOC filter chip (span of control): set by an administrator, never removable */
  .rx-chip.locked { gap: 5px; padding: 0 10px 0 8px; background: var(--rx-surface-2); border-color: var(--rx-border-subtle); color: var(--rx-text-2); cursor: help; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
  .rx-chip.locked b { color: var(--rx-text); }
  .rx-chip.locked .rx-i { width: 13px; height: 13px; }
  .rx-chip.locked .rx-mono { font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
  .rx-chip.locked:focus-visible { outline: 2px solid var(--rx-focus); outline-offset: 1px; }
  .rx-health { border: 0; background: none; padding: 0 4px; cursor: help; }
  .rx-health .rx-dot.unknown { background: var(--rx-sev-unknown-fg); }
  [hidden] { display: none !important; }
}

/* responsive tiers (RSP) */
@media (max-width: 1024px) {
  .rx-app { --rx-nav-w: 60px; }
  .rx-app .rx-nav-item span, .rx-app .rx-nav-group > h4, .rx-app .rx-logo .name, .rx-app .rx-nav-item .badge { display: none; }
  .rx-grid-3, .rx-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .rx-app { grid-template-columns: 1fr; grid-template-rows: var(--rx-header-h) auto 1fr 56px; }
  .rx-nav { grid-row: 4; grid-column: 1; flex-direction: row; overflow: hidden; }
  .rx-nav .rx-logo, .rx-nav .rx-nav-group > h4, .rx-nav .foot, .rx-nav .spacer { display: none; }
  .rx-nav .rx-nav-group { display: contents; }
  .rx-nav .rx-nav-item:not([data-phone]) { display: none; }
  .rx-nav .rx-nav-item { flex: 1; flex-direction: column; gap: 2px; justify-content: center; font-size: 11px; margin: 0; border-radius: 0; }
  .rx-nav .rx-nav-item span { display: block !important; }
  .rx-header, .rx-banner-slot, .rx-main { grid-column: 1; }
  .rx-header .rx-cmd, .rx-header .crumbs, .rx-header .hide-phone { display: none; }
  .rx-grid-2, .rx-grid-3, .rx-grid-4 { grid-template-columns: 1fr; }
  .rx-page { padding: 14px; }
  .rx-page.full { padding: 0; }
  .rx-btn, .rx-nav-item { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (forced-colors: active) { .rx-sev::before { forced-color-adjust: none; } }
