/* ---------- tokens: light (default) — the ThreatClaw "Industry" system --------
 *
 * Matched to threatclaw.ai's own --tc-* tokens so the two products read as one
 * family: a light steel ground, thin borders, and a single steel accent ramp
 *   100 #eef6ff · 200 #d6ebff · 300 #b5d9fd · 400 #94bce3 · 500 #749dc4
 *   600 #597ea3 · 700 #416180 · 800 #2c455d · 900 #1d2d3d
 *
 * STEEL CHROME, SEMANTIC SEVERITY. ThreatClaw collapses severity onto that one
 * steel ramp so it reads by tonal weight. Argus briefly did the same and it was
 * the wrong call here: this is a triage surface, and the whole job of the Threat
 * Center is answering "what do I look at first" in one glance. Tone is too slow
 * for that — red carries urgency pre-attentively in a way that a darker blue
 * does not.
 *
 * So the ground, borders, accent and geometry stay ThreatClaw's, and severity
 * gets its hues back: critical red, high orange, medium amber, low steel, ok
 * green. Low deliberately stays on the steel accent so the quiet end of the
 * scale still belongs to the palette and only the things worth looking at
 * carry colour.
 *
 * These are tuned against the steel ground, not inherited from the old teal
 * theme — the light values are darkened for contrast on #F2F2F3 and the dark
 * ones brightened for #10171F.
 */
  :root {
    /* Light is the default for everyone; dark is a choice (Appearance or the
       topbar toggle), never inferred from the OS. White surfaces on a cool
       grey page, crisp hairlines, and a steel accent deep enough for white
       text to pass WCAG AA (4.6:1; the earlier #5980A6 was 4.1:1). */
    --bg: #F4F6F8;
    --surface: #FFFFFF;
    --surface-2: #EFF2F5;
    --line: #DDE2E8;
    --ink: #1A2028;
    --ink-muted: #586373;
    --ink-faint: #8A94A1;

    --accent: #4D79A5;
    --accent-soft: rgba(77,121,165,.11);
    --accent-ink: #FFFFFF;

    --sev-critical: #C62130;
    --sev-high: #C25A00;
    --sev-medium: #8A6D0B;
    --sev-low: #4D79A5;   /* steel — the quiet end stays in-palette */
    --ok: #2E7D46;

    /* Warm washes, matching --sev-high / --sev-critical: a tainted span in the
       trace waterfall should read as "touched by something hostile" at a glance,
       which a steel tint did not do. */
    --taint-wash: rgba(194,90,0,.09);
    --taint-influenced: rgba(194,90,0,.045);
    --canary-wash: rgba(198,33,48,.10);

    --u: 5px;                 /* density unit */
    --fs: 13.5px;             /* base font size */
    /* Squared off. The ThreatClaw surfaces are near-rectangular; the softer
       6px this used to default to is the single change that most made the two
       products look unrelated. Still overridable in Appearance. */
    --radius: 3px;
    /* Barlow is the ThreatClaw face, but `font-src 'self' data:` means no CDN
       and self-hosting a family for one visual match is not worth the payload.
       This stack leads with the slightly-narrow grotesks most likely to be
       present, which carries the same tone. */
    --font-ui: "Barlow", "Roboto Condensed", "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
    --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", "Cascadia Code", Menlo, monospace;
    --chart-grid: rgba(77,121,165,.13);
    --shadow-card: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  }
  /* Dark is Argus's own extension of the system — threatclaw.ai ships only the
   * light Industry ground, so it continues the same steel ramp downward past
   * 900 rather than inventing a second palette. It applies only when chosen
   * (data-theme="dark", set by appearance.js), including "System" on a dark
   * OS; it is never inferred by the stylesheet alone.
   *
   * Severity inverts here, and has to. Tonal weight means "furthest from the
   * page"; on a light ground that is the darkest steel, on a dark ground it is
   * the lightest. Reusing the light values would make critical the item that
   * disappears into the background. The range stops short of the body-text
   * white so a severity chip never reads as ordinary text. */
  /* The explicit picks. Light must mirror the :root defaults above exactly, and
     dark must set every token: a value missing from dark silently falls back
     to the light default, which is how a half-updated palette ships looking
     fine until someone chooses dark. */
  :root[data-theme="light"] {
    --bg: #F4F6F8; --surface: #FFFFFF; --surface-2: #EFF2F5; --line: #DDE2E8;
    --ink: #1A2028; --ink-muted: #586373; --ink-faint: #8A94A1;
    --accent: #4D79A5; --accent-soft: rgba(77,121,165,.11); --accent-ink: #FFFFFF;
    --sev-critical: #C62130; --sev-high: #C25A00; --sev-medium: #8A6D0B;
    --sev-low: #4D79A5; --ok: #2E7D46;
    --taint-wash: rgba(194,90,0,.09); --taint-influenced: rgba(194,90,0,.045);
    --canary-wash: rgba(198,33,48,.10); --chart-grid: rgba(77,121,165,.13);
    --shadow-card: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  }
  :root[data-theme="dark"] {
    --bg: #10171F; --surface: #16202B; --surface-2: #1D2A36; --line: #2C3F52;
    --ink: #E8EEF4; --ink-muted: #9FB3C6; --ink-faint: #6D8298;
    --accent: #749DC4; --accent-soft: rgba(116,157,196,.16); --accent-ink: #0D141B;
    --sev-critical: #FF6069; --sev-high: #FF9245; --sev-medium: #E3B341;
    --sev-low: #7FA6C9; --ok: #56D07E;
    --taint-wash: rgba(255,146,69,.10); --taint-influenced: rgba(255,146,69,.05);
    --canary-wash: rgba(255,96,105,.12); --chart-grid: rgba(159,179,198,.14);
    --shadow-card: none;
  }
  /* Accent variants (tenant/user configurable). The default is now the steel
     accent from the Industry palette above, so the old teal survives here as an
     option rather than being deleted — some deployments will have got used to
     it, and it costs one line to keep. */
  :root[data-accent="radar"]   { --accent: #35B5A4; --accent-soft: rgba(53,181,164,.14); --accent-ink:#08211D; }
  :root[data-accent="indigo"]  { --accent: #5B6EE8; --accent-soft: rgba(91,110,232,.13); --accent-ink:#FFFFFF; }
  :root[data-accent="ember"]   { --accent: #D26A3F; --accent-soft: rgba(210,106,63,.13); --accent-ink:#FFFFFF; }
  :root[data-accent="steel"]   { --accent: #4D79A5; --accent-soft: rgba(77,121,165,.12); --accent-ink:#FFFFFF; }
  :root[data-theme="dark"][data-accent="indigo"], :root[data-accent="indigo"]  { }
  /* density */
  :root[data-density="compact"] { --u: 4px; --fs: 12.5px; }
  /* text size — scales the whole interface (see the `zoom` note on body).
   * Steps are deliberately gentle: 90% still fits the tables, 125% is about the
   * largest that keeps the sidebar and a data table side by side on a laptop. */
  :root[data-fontsize="s"]  { --ui-scale: .9; }
  :root[data-fontsize="l"]  { --ui-scale: 1.12; }
  :root[data-fontsize="xl"] { --ui-scale: 1.25; }
  /* radius option */
  :root[data-radius="0"]  { --radius: 0px; }
  :root[data-radius="10"] { --radius: 10px; }

  * { box-sizing: border-box; }
  html, body { margin: 0; padding: 0; }
  body {
    background: var(--bg); color: var(--ink);
    font-family: var(--font-ui); font-size: var(--fs);
    line-height: 1.45; -webkit-font-smoothing: antialiased;
    /* Text size preference.
     *
     * This scales the whole interface rather than only `--fs`. The design system
     * is px-based — 71 of the 79 font-size declarations in this file are literal
     * pixel values — so scaling the token alone would resize about a tenth of
     * the text and look broken. `zoom` scales type, spacing and controls
     * together, which is also what someone means when they ask for bigger text:
     * bigger text in a proportionally bigger frame, not bigger text crammed into
     * the same one.
     *
     * The cost is that viewport units inside a zoomed subtree render scaled, so
     * the two `100vh` rules below divide it back out. That is the entire
     * trade-off, and it is contained to those two rules. */
    zoom: var(--ui-scale, 1);
  }
  .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  .num  { font-variant-numeric: tabular-nums; }

  /* ---------- app shell ---------- */
  /* `100vh` inside the zoomed body would render as 100vh × scale — at 125% the
   * sidebar becomes a quarter taller than the window and scrolls the page.
   * Dividing by the scale gives back a true viewport height. */
  .shell { display: flex; min-height: calc(100vh / var(--ui-scale, 1)); }
  .rail {
    width: 208px; flex: none; background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    padding: calc(var(--u)*3) 0;
    position: sticky; top: 0; height: calc(100vh / var(--ui-scale, 1));
    overflow-y: auto; overscroll-behavior: contain;
    scrollbar-width: thin; scrollbar-color: var(--line) transparent;
  }
  .rail::-webkit-scrollbar { width: 8px; }
  .rail::-webkit-scrollbar-thumb { background: var(--line); border-radius: 8px; }
  .rail::-webkit-scrollbar-track { background: transparent; }
  .brand {
    display: flex; align-items: center; gap: 10px;
    padding: calc(var(--u)*1.5) calc(var(--u)*4) calc(var(--u)*4);
  }
  .brand-mark {
    width: 26px; height: 26px; border-radius: 50%;
    background: radial-gradient(circle at 50% 42%, var(--accent) 0 34%, transparent 36%),
                conic-gradient(from 0deg, var(--accent-soft), var(--accent) 55%, var(--accent-soft));
    border: 1.5px solid var(--accent);
    flex: none;
  }
  .brand-name { font-weight: 600; font-size: 15px; letter-spacing: .02em; }
  .brand-env { font-size: 10.5px; color: var(--ink-faint); letter-spacing: .08em; text-transform: uppercase; }

  .nav-group { padding: calc(var(--u)*2) calc(var(--u)*2.5) 0; }
  .nav-label {
    font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
    color: var(--ink-faint); padding: calc(var(--u)*1.5) calc(var(--u)*1.5) var(--u);
  }
  .nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: calc(var(--u)*1.4) calc(var(--u)*1.5);
    border-radius: var(--radius); color: var(--ink-muted);
    cursor: pointer; border: none; background: none; width: 100%;
    font: inherit; text-align: left; font-size: calc(var(--fs) - .5px);
  }
  .nav-item:hover { background: var(--surface-2); color: var(--ink); }
  .nav-item.active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
  .nav-item.active .nav-ico { color: var(--accent); }
  .nav-ico { width: 16px; text-align: center; color: var(--ink-faint); font-size: 12px; }
  .nav-badge {
    margin-left: auto; font-size: 10.5px; font-weight: 600;
    background: var(--sev-critical); color: #fff;
    border-radius: 99px; padding: 1px 7px;
  }
  .rail-foot { margin-top: auto; padding: 0 calc(var(--u)*2.5); }

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

  /* The top bar and the status banner stick together, so a message such as
   * "Verdict not saved" stays in view however far down a long feed you are.
   * One sticky box needs no measured offset: the bar's height changes with
   * text size and zoom, and the banner always sits directly under it. The
   * background keeps scrolled content from showing beside the banner. */
  .topstack { position: sticky; top: 0; z-index: 5; background: var(--bg); }
  .topbar {
    display: flex; align-items: center; gap: calc(var(--u)*2);
    padding: calc(var(--u)*2) calc(var(--u)*5);
    border-bottom: 1px solid var(--line); background: var(--surface);
    position: relative; z-index: 1;
    /* Deliberately does NOT wrap. The bar was sized to fit exactly on a wide
     * window, so anything that made its contents bigger — a larger text size, a
     * long application name, a narrow laptop — used to spill over and give the
     * whole dashboard a horizontal scrollbar.
     *
     * Wrapping looks like the fix and isn't: flexbox wraps in preference to
     * shrinking, so the decorative tagline stayed full width and pushed the
     * account menu onto a row of its own, which reads as broken rather than
     * tight. Staying on one line and letting the two elastic items below give
     * way keeps it to a single row at every text size. */
  }
  /* The search field is the one element here that can afford to give up space,
     so let it shrink before anything wraps — but not grow, or it pushes the
     items after it onto a second row on a window that had room for one. */
  .topbar .searchbox { flex: 0 1 190px; min-width: 110px; }
  .topbar .searchbox input { width: 100%; }
  /* The tagline is decoration; the account menu is not. Let the tagline
     truncate so the avatar never gets pushed onto a row of its own, which reads
     as a broken layout rather than a tight one. */
  .topbar .cmdk { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar .menu { flex: none; }
  /* Everything else keeps its size and stays on one line. Flex items shrink by
     default, so without this "Refresh" and the updated-at time squeezed and
     wrapped inside themselves before the two elastic items above gave way. */
  .topbar .btn, .topbar .ctx, .topbar #lastUpdated { flex: none; white-space: nowrap; }
  .ctx {
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: calc(var(--u)*1) calc(var(--u)*2.2);
    background: var(--bg); color: var(--ink); cursor: pointer;
    font: inherit; font-size: calc(var(--fs) - 1px);
  }
  .ctx .k { color: var(--ink-faint); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; }
  .ctx .caret { color: var(--ink-faint); font-size: 9px; }
  .cmdk {
    margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: calc(var(--u)*1) calc(var(--u)*2.4);
    color: var(--ink-faint); background: var(--bg); font-size: calc(var(--fs) - 1px);
  }
  .kbd {
    font-family: var(--font-mono); font-size: 10px;
    border: 1px solid var(--line); border-bottom-width: 2px;
    border-radius: 4px; padding: 0 5px; background: var(--surface);
  }
  .avatar {
    width: 26px; height: 26px; border-radius: 50%; flex: none;
    background: var(--accent); color: var(--accent-ink);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
  }

  .content { padding: calc(var(--u)*5); display: grid; gap: calc(var(--u)*4); }
  .page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
  .page-title { font-size: 19px; font-weight: 600; letter-spacing: -.01em; margin: 0; text-wrap: balance; }
  .page-sub { color: var(--ink-muted); font-size: calc(var(--fs) - 1px); }
  .live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); margin-right: 6px; }

  /* ---------- cards & tiles ---------- */
  .card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow-card, none);
  }
  .card-head {
    display: flex; align-items: center; gap: 10px;
    padding: calc(var(--u)*2.4) calc(var(--u)*3.2);
    border-bottom: 1px solid var(--line);
  }
  .card-title { font-weight: 600; font-size: calc(var(--fs) - .5px); }
  .card-hint { color: var(--ink-faint); font-size: calc(var(--fs) - 2px); margin-left: auto; }

  .kpis { display: grid; grid-template-columns: repeat(6, 1fr); gap: calc(var(--u)*2.5); }
  .kpi { padding: calc(var(--u)*2.6) calc(var(--u)*3); display: grid; gap: 2px; }
  .kpi .lab { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
  .kpi .val { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
  .kpi .sub { font-size: 11.5px; color: var(--ink-muted); }
  .delta-up { color: var(--sev-critical); }
  .delta-down { color: var(--ok); }
  .kpi.crit .val { color: var(--sev-critical); }

  .grid-23 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: calc(var(--u)*3); align-items: start; }

  /* ---------- attack feed ---------- */
  .tablewrap { overflow-x: auto; }
  .action-rule-form { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; margin: 18px 0; }
  .action-rule-form label { display: grid; gap: 6px; flex: 1 1 170px; font-size: 12px; color: var(--ink-muted); }
  .action-rule-form input, .action-rule-form select { width: 100%; box-sizing: border-box; padding: 9px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); color: var(--ink); font: inherit; }
  .action-rule-form input:focus, .action-rule-form select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
  #actionControlsCard .tablewrap { margin: 12px 0; }
  #actionControlsNote { display: inline-block; margin-left: 12px; color: var(--ink-muted); font-size: 12px; }
  #actionReviewDetails:not(:empty) { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--line); }
  #actionReviewDetails .payload { max-height: 360px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
  table.feed { width: 100%; border-collapse: collapse; min-width: 780px; }
  .feed th {
    text-align: left; font-size: 10px; letter-spacing: .09em; text-transform: uppercase;
    color: var(--ink-faint); font-weight: 600;
    padding: calc(var(--u)*1.6) calc(var(--u)*2.4);
    border-bottom: 1px solid var(--line); white-space: nowrap;
  }
  .feed td {
    padding: calc(var(--u)*1.8) calc(var(--u)*2.4);
    border-bottom: 1px solid var(--line);
    font-size: calc(var(--fs) - .5px); white-space: nowrap; vertical-align: middle;
  }
  .feed tr.evt { cursor: pointer; }
  .feed tr.evt:hover td { background: var(--surface-2); }
  .feed tr:last-child td { border-bottom: none; }
  td.stripe { padding: 0; width: 3px; }
  .stripe i { display: block; width: 3px; height: 100%; min-height: 30px; }
  .s-critical i { background: var(--sev-critical); width: 4px; }
  .s-high i { background: var(--sev-high); }
  .s-medium i { background: var(--sev-medium); }
  .s-low i { background: var(--sev-low); }
  /* Critical rows carry a faint wash of their own severity colour on top of the
     stripe and the pill. Three weak cues stacked beat one strong one: the row
     you should open first is findable while scrolling a full feed, without
     shouting so loudly that a screen of criticals becomes unreadable. Kept to
     4% so it survives the :hover background rather than fighting it. */
  .feed tr.s-critical td { background: color-mix(in srgb, var(--sev-critical) 4%, transparent); }
  .feed tr.evt.s-critical:hover td { background: color-mix(in srgb, var(--sev-critical) 9%, var(--surface-2)); }

  .pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 10.5px; font-weight: 650; letter-spacing: .03em;
    border-radius: 99px; padding: 2px 9px; text-transform: uppercase;
  }
  /* Critical alone gets a border as well as a tint — at pill size a 12% wash of
     red and a 12% wash of orange are easy to confuse in peripheral vision, and
     this is the one distinction that must never be misread. */
  .pill-critical { color: var(--sev-critical); background: color-mix(in srgb, var(--sev-critical) 14%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sev-critical) 40%, transparent); }
  .pill-high     { color: var(--sev-high);     background: color-mix(in srgb, var(--sev-high) 12%, transparent); }
  .pill-medium   { color: var(--sev-medium);   background: color-mix(in srgb, var(--sev-medium) 14%, transparent); }
  .pill-low      { color: var(--sev-low);      background: color-mix(in srgb, var(--sev-low) 15%, transparent); }
  .pill-ok       { color: var(--ok);           background: color-mix(in srgb, var(--ok) 12%, transparent); }
  .pill-neutral  { color: var(--ink-muted);    background: var(--surface-2); }

  .cat { font-weight: 600; }
  .dim { color: var(--ink-muted); }
  .faint { color: var(--ink-faint); }
  a.tracelink { color: var(--accent); text-decoration: none; font-family: var(--font-mono); font-size: 11.5px; }
  a.tracelink:hover { text-decoration: underline; }

  .layerchips { display: inline-flex; gap: 4px; }
  .lchip {
    font-family: var(--font-mono); font-size: 10px;
    border: 1px solid var(--line); border-radius: 4px;
    padding: 1px 5px; color: var(--ink-muted); background: var(--surface-2);
  }
  .lchip.hot { border-color: color-mix(in srgb, var(--sev-high) 45%, transparent); color: var(--sev-high); background: color-mix(in srgb, var(--sev-high) 8%, transparent); }

  tr.evidence td {
    white-space: normal; background: var(--surface-2);
    padding: calc(var(--u)*2.6) calc(var(--u)*4);
  }
  .ev-label { font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }
  .ev-quote {
    font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 10px 12px; max-width: 72ch; overflow-x: auto;
  }
  .ev-quote mark { background: color-mix(in srgb, var(--sev-high) 22%, transparent); color: inherit; border-radius: 2px; padding: 0 2px; }
  .ev-actions { display: flex; gap: 8px; margin-top: 10px; }
  .btn {
    font: inherit; font-size: calc(var(--fs) - 1.5px); font-weight: 600;
    border-radius: var(--radius); padding: calc(var(--u)*1.1) calc(var(--u)*2.6);
    cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  }
  .btn:hover { background: var(--surface-2); }
  .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
  .btn-primary:hover { filter: brightness(1.06); background: var(--accent); }

  /* ---------- layer health ---------- */
  .stack { display: grid; gap: calc(var(--u)*3); }
  .lh-row { display: grid; grid-template-columns: 84px 1fr 72px; gap: 10px; align-items: center; padding: calc(var(--u)*1.2) 0; }
  .lh-name { font-size: 12px; font-weight: 600; }
  .lh-sub { font-size: 10.5px; color: var(--ink-faint); }
  .bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
  .bar b { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
  .lh-val { text-align: right; font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); }
  .funnel { display: grid; gap: 6px; }
  .fn-row { display: grid; grid-template-columns: 148px 1fr 64px; gap: 10px; align-items: center; }
  .fn-lab { font-size: 11.5px; color: var(--ink-muted); }
  .fn-bar { height: 14px; border-radius: 3px; background: var(--accent-soft); position: relative; }
  .fn-bar b { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; opacity: .85; }
  .fn-val { font-family: var(--font-mono); font-size: 11px; text-align: right; color: var(--ink-muted); }
  .pad { padding: calc(var(--u)*2.6) calc(var(--u)*3.2); }

  /* ---------- chart ---------- */
  .chart-legend { display: flex; gap: 16px; margin-left: auto; font-size: 11px; color: var(--ink-muted); }
  .chart-legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; background: var(--c); }
  .chartwrap { overflow-x: auto; }
  .chart svg { display: block; width: 100%; height: auto; }

  /* ---------- trace explorer ---------- */
  .trace-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr); gap: calc(var(--u)*3); align-items: start; }
  .trace-meta { display: flex; gap: 18px; flex-wrap: wrap; padding: calc(var(--u)*2.4) calc(var(--u)*3.2); border-bottom: 1px solid var(--line); font-size: 12px; color: var(--ink-muted); }
  .trace-meta b { color: var(--ink); font-weight: 600; }
  .wf { padding: calc(var(--u)*1.5) 0; }
  .wf-axis { display: grid; grid-template-columns: minmax(240px, 44%) 1fr; padding: 0 calc(var(--u)*3.2) 6px; }
  .wf-axis .t { font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint); display: flex; justify-content: space-between; }
  .wf-row {
    display: grid; grid-template-columns: minmax(240px, 44%) 1fr;
    align-items: center; padding: calc(var(--u)*0.9) calc(var(--u)*3.2);
    border-left: 3px solid transparent; cursor: pointer;
  }
  .wf-row:hover { background: var(--surface-2); }
  .wf-row.sel { background: var(--accent-soft); border-left-color: var(--accent); }
  .wf-row.taint { background: var(--taint-wash); border-left-color: var(--sev-high); }
  .wf-row.taint:hover, .wf-row.taint.sel { background: color-mix(in srgb, var(--sev-high) 13%, transparent); }
  .wf-row.influenced { background: var(--taint-influenced); }
  .wf-row.canary { background: var(--canary-wash); border-left-color: var(--sev-critical); }
  .wf-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .wf-ind { color: var(--ink-faint); font-family: var(--font-mono); font-size: 11px; flex: none; }
  .tico {
    flex: none; width: 17px; height: 17px; border-radius: 4px;
    font-size: 9.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--ink-muted); border: 1px solid var(--line);
  }
  .tico.g { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); background: var(--accent-soft); }
  .tico.r { color: var(--sev-high); border-color: color-mix(in srgb, var(--sev-high) 40%, transparent); background: color-mix(in srgb, var(--sev-high) 9%, transparent); }
  .wf-label { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wf-flags { display: inline-flex; gap: 4px; flex: none; }
  .wf-track { position: relative; height: 16px; }
  .wf-bar { position: absolute; top: 3px; height: 10px; border-radius: 3px; background: color-mix(in srgb, var(--accent) 55%, transparent); min-width: 3px; }
  .wf-bar.warn { background: color-mix(in srgb, var(--sev-high) 65%, transparent); }
  .wf-bar.crit { background: color-mix(in srgb, var(--sev-critical) 70%, transparent); }
  .wf-dur { position: absolute; top: 0; font-family: var(--font-mono); font-size: 10px; color: var(--ink-faint); line-height: 16px; }
  .taint-legend { display: flex; gap: 14px; padding: calc(var(--u)*2) calc(var(--u)*3.2); border-top: 1px solid var(--line); font-size: 11px; color: var(--ink-muted); flex-wrap: wrap; }
  .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

  .drawer-tabs { display: flex; gap: 2px; padding: 0 calc(var(--u)*2); border-bottom: 1px solid var(--line); }
  .dtab {
    font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-muted);
    background: none; border: none; border-bottom: 2px solid transparent;
    padding: calc(var(--u)*2) calc(var(--u)*2.4); cursor: pointer;
  }
  .dtab.active { color: var(--ink); border-bottom-color: var(--accent); }
  .kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 12px; }
  .kv dt { color: var(--ink-faint); }
  .kv dd { margin: 0; font-family: var(--font-mono); font-size: 11.5px; overflow-wrap: anywhere; }
  .sec-block { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
  .sec-block + .sec-block { margin-top: 10px; }
  .sec-block-head {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; background: var(--surface-2); font-size: 11.5px; font-weight: 600;
  }
  .sec-block-body { padding: 10px 12px; font-size: 12px; color: var(--ink-muted); }
  .judge {
    font-family: var(--font-mono); font-size: 11px; line-height: 1.55;
    background: var(--surface-2); border-radius: 4px; padding: 8px 10px; overflow-x: auto;
  }

  /* ---------- appearance ---------- */
  .settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: calc(var(--u)*3); align-items: start; }
  .set-row { padding: calc(var(--u)*2.6) calc(var(--u)*3.2); display: grid; gap: 10px; }
  .set-row + .set-row { border-top: 1px solid var(--line); }
  .set-name { font-weight: 600; font-size: 13px; }
  .set-desc { color: var(--ink-muted); font-size: 12px; max-width: 52ch; }
  .seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; width: fit-content; }
  .seg button {
    font: inherit; font-size: 12px; font-weight: 600; padding: 6px 14px;
    background: var(--surface); color: var(--ink-muted); border: none; cursor: pointer;
  }
  .seg button + button { border-left: 1px solid var(--line); }
  .seg button.on { background: var(--accent-soft); color: var(--ink); }
  .swatches { display: flex; gap: 10px; }
  .swatch {
    width: 30px; height: 30px; border-radius: 50%; cursor: pointer;
    border: 2px solid transparent; padding: 0; position: relative;
  }
  .swatch.on { border-color: var(--ink); }
  .swatch::after { content: attr(data-name); position: absolute; top: 36px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--ink-faint); }
  .swatches { padding-bottom: 18px; }
  .note {
    border: 1px dashed var(--line); border-radius: var(--radius);
    padding: calc(var(--u)*2.4) calc(var(--u)*3);
    color: var(--ink-muted); font-size: 12px; max-width: 68ch;
  }

  .view { display: none; }
  .view.on { display: grid; gap: calc(var(--u)*4); }

  button:focus-visible, .ctx:focus-visible, a:focus-visible {
    outline: 2px solid var(--accent); outline-offset: 2px;
  }
  @media (prefers-reduced-motion: no-preference) {
    .nav-item, .btn, .dtab, .seg button, .wf-row, .feed tr.evt td { transition: background .13s ease, color .13s ease; }
  }
  @media (max-width: 1100px) {
    .kpis { grid-template-columns: repeat(3, 1fr); }
    .grid-23, .trace-grid { grid-template-columns: 1fr; }
  }
  @media (max-width: 860px) {
    .rail { display: none; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
  }

  /* ---------- plain-English layer: tooltips, explainers, search ---------- */
  /* Shared floating tooltip (positioned by glossary.js so table overflow can't clip it). */
  .tipbubble {
    position: fixed; z-index: 200; display: none;
    background: var(--ink); color: var(--surface);
    font-size: 11.5px; line-height: 1.5; font-weight: 400;
    padding: 7px 10px; border-radius: var(--radius);
    box-shadow: 0 6px 22px rgba(0,0,0,.22); pointer-events: none;
  }
  [data-tip] { cursor: help; }
  /* A dotted underline is the only affordance that says "there's an explanation here". */
  .cat[data-tip], .lchip[data-tip], .kpi .lab[data-tip] {
    text-decoration: underline dotted var(--ink-faint); text-underline-offset: 3px;
  }

  /* "What this means / What to do" panel on every expanded finding. */
  .explain {
    border-left: 2px solid var(--accent); background: var(--accent-soft);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: calc(var(--u)*2.2) calc(var(--u)*2.8); margin-bottom: calc(var(--u)*2.4);
  }
  .explain-head {
    font-size: 9.5px; letter-spacing: .09em; text-transform: uppercase;
    color: var(--accent); font-weight: 700; margin-bottom: 4px;
  }
  .explain-head + .explain-head, .explain-eg + .explain-head { margin-top: 10px; }
  .explain-lead { margin: 0 0 6px; font-size: 12.5px; line-height: 1.6; color: var(--ink); max-width: 78ch; }
  .explain-eg { margin: 0; font-size: 12px; line-height: 1.55; color: var(--ink-muted); max-width: 78ch; }
  .explain-todo { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.65; color: var(--ink-muted); max-width: 78ch; }
  .explain-todo li { margin-bottom: 2px; }

  /* Risk score, with the 0-100 scale made explicit. */
  .scorebar { display: flex; align-items: center; gap: 8px; font-size: 12px; }
  .scorebar-val { font-family: var(--font-mono); font-size: 15px; font-weight: 700; color: var(--ink); }
  .scorebar-scale { color: var(--ink-faint); font-size: 11px; margin-left: -5px; }
  .scorebar-track {
    flex: 1; max-width: 160px; height: 6px; border-radius: 99px;
    background: var(--surface-2); overflow: hidden;
  }
  .scorebar-track b { display: block; height: 100%; }
  .scorebar-track b.s-critical { background: var(--sev-critical); }
  .scorebar-track b.s-high { background: var(--sev-high); }
  .scorebar-track b.s-medium { background: var(--sev-medium); }
  .scorebar-track b.s-low { background: var(--sev-low); }
  .scorebar-word { color: var(--ink-muted); font-size: 11.5px; }

  /* Rule / signal chips expanded into readable lines inside Provenance. */
  .why-list { display: grid; gap: 5px; margin: 2px 0 0; }
  .why-row { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
  .why-row .why-id {
    font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-faint);
    background: var(--surface-2); border-radius: 4px; padding: 1px 6px; flex: none;
  }
  .why-row .why-text { color: var(--ink-muted); line-height: 1.5; }

  /* Global search in the top bar. */
  .searchbox { position: relative; display: flex; align-items: center; }
  .searchbox input {
    font: inherit; font-size: 12px; width: 190px;
    padding: 5px 9px 5px 26px;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); color: var(--ink);
  }
  .searchbox input::placeholder { color: var(--ink-faint); }
  .searchbox input:focus { outline: none; border-color: var(--accent); width: 250px; }
  .searchbox .s-ico { position: absolute; left: 9px; color: var(--ink-faint); font-size: 11px; pointer-events: none; }
  @media (prefers-reduced-motion: no-preference) { .searchbox input { transition: width .15s ease, border-color .13s ease; } }

  /* Richer empty states: tell people how to get data, don't just say there's none. */
  .empty-cta { display: grid; gap: calc(var(--u)*2); justify-items: center; padding: calc(var(--u)*5) calc(var(--u)*4); text-align: center; }
  .empty-cta .big { font-size: 15px; color: var(--ink); }
  .empty-cta p { margin: 0; font-size: 12.5px; color: var(--ink-muted); max-width: 56ch; line-height: 1.65; }
  .empty-steps { text-align: left; display: grid; gap: 7px; margin: 0 auto; max-width: 46ch; }
  .empty-steps .es-row { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--ink-muted); line-height: 1.55; }
  .empty-steps .es-n {
    flex: none; width: 18px; height: 18px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: 700; margin-top: 1px;
  }
  .empty-cta code { font-family: var(--font-mono); font-size: 11.5px; background: var(--surface-2); border-radius: 4px; padding: 1px 5px; }

  /* ---------- incident narrative (trace detail) ---------- */
  .nar-body { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: calc(var(--u)*4); padding: calc(var(--u)*3) calc(var(--u)*3.2); align-items: start; }
  @media (max-width: 1000px) { .nar-body { grid-template-columns: 1fr; } }
  .nar-lead p { margin: 0 0 10px; font-size: 13px; line-height: 1.7; color: var(--ink-muted); max-width: 78ch; }
  .nar-lead p:last-child { margin-bottom: 0; }
  .nar-lead b { color: var(--ink); font-weight: 600; }
  .nar-quote {
    display: block; margin-top: 7px;
    font-family: var(--font-mono); font-size: 11.5px; line-height: 1.6;
    background: color-mix(in srgb, var(--sev-high) 8%, transparent);
    border-left: 2px solid var(--sev-high);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 8px 11px; color: var(--ink); overflow-wrap: anywhere;
  }
  .nar-timeline { border: 1px solid var(--line); border-radius: var(--radius); padding: calc(var(--u)*2) calc(var(--u)*2.2); }
  .nar-tl-head { font-size: 9.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; margin-bottom: 8px; }
  .nar-step { display: grid; grid-template-columns: auto 1fr; gap: 2px 9px; padding: 6px 0; border-top: 1px solid var(--line); }
  .nar-step:first-of-type { border-top: none; }
  .nar-time { font-size: 10.5px; color: var(--ink-faint); grid-row: span 2; padding-top: 1px; }
  .nar-name { font-size: 12.5px; color: var(--ink); font-weight: 600; overflow-wrap: anywhere; }
  .nar-role { font-size: 11.5px; color: var(--ink-muted); }

/* ---- Application settings (detection config) ---- */
#view-settings .card { margin-bottom: calc(var(--u)*3); }
.set-intro { margin-bottom: calc(var(--u)*3); }
.set-row { display: grid; grid-template-columns: 1fr minmax(200px, 300px); gap: calc(var(--u)*2) calc(var(--u)*5); align-items: start; }
@media (max-width: 720px) { .set-row { grid-template-columns: 1fr; } }
.set-label { display: grid; gap: 4px; }
.set-label label { font-size: 13px; font-weight: 600; color: var(--ink); }
.set-hint { font-size: 11.5px; color: var(--ink-faint); line-height: 1.5; }
/* A capability the platform doesn't offer yet: the switch stays, disabled, with this beside it. */
.set-na { display: inline-block; margin-left: 7px; padding: 0 7px; border: 1px solid var(--line); border-radius: 10px; font-size: 11px; font-weight: 500; color: var(--ink-faint); vertical-align: 1px; }
.set-na[hidden] { display: none; }
.set-control { justify-self: stretch; }
.set-select { font: inherit; font-size: 13px; width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.set-check { display: flex; align-items: start; gap: 10px; font-size: 13px; color: var(--ink); cursor: pointer; }
.set-check input { margin-top: 3px; flex: none; width: 15px; height: 15px; accent-color: var(--accent); }
.set-check.set-disabled { cursor: default; opacity: .7; }
.set-check .set-hint { display: block; margin-top: 2px; }

/* Keep reviewed-test controls consistent with the settings forms. */
#rtAssuranceCard input:not([type="checkbox"]), #rtAssuranceCard select,
#rtAssuranceCard textarea, #rtScopeCard input:not([type="checkbox"]),
#rtScopeCard select, #rtScopeCard textarea {
  box-sizing: border-box; width: 100%; min-width: 0;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 13px;
}
#rtAssuranceCard textarea, #rtScopeCard textarea { resize: vertical; }
#rtAssuranceCard code, #rtAssuranceCard .mono { overflow-wrap: anywhere; }
#rtAssuranceCard summary, #rtScopeCard summary { cursor: pointer; }
#rtAssuranceCard label, #rtScopeCard label { line-height: 1.6; }

/* Red Team workspace: semantic pastel accents and aligned, connected panels. */
.status-banner[data-tone="success"] { color:var(--ok); background:color-mix(in srgb,var(--ok) 12%,var(--surface)); }
#view-redteam { --rt-blue:#3e6694; --rt-violet:#7553a4; --rt-mint:#287359; --rt-amber:#8a611b; --rt-rose:#a13f58; min-width:0; grid-template-columns:minmax(0,1fr); }
#view-redteam [data-rt-tone="blue"] { --rt-tone:var(--rt-blue); }
#view-redteam [data-rt-tone="violet"] { --rt-tone:var(--rt-violet); }
#view-redteam [data-rt-tone="mint"] { --rt-tone:var(--rt-mint); }
#view-redteam [data-rt-tone="amber"] { --rt-tone:var(--rt-amber); }
#view-redteam [data-rt-tone="rose"] { --rt-tone:var(--rt-rose); }
#view-redteam .rt-page-head { display:flex; justify-content:space-between; align-items:center; gap:20px; margin-bottom:4px; }
.rt-eyebrow { display:block; font-size:10px; letter-spacing:.15em; color:var(--ink-muted); margin-bottom:8px; font-weight:650; }
#view-redteam .page-title { font-size:28px; line-height:1.2; margin:0 0 8px; }
#view-redteam .page-sub { margin:0; font-size:13px; line-height:1.6; }
.rt-workspace-nav { display:flex; gap:6px; flex-wrap:wrap; padding:6px; border:1px solid var(--line); border-radius:14px; background:var(--surface); margin-bottom:4px; }
.rt-jump { border:0; background:transparent; color:var(--ink-muted); cursor:pointer; font:inherit; font-size:12px; padding:10px 14px; border-radius:8px; line-height:1.4; text-align:left; }
.rt-jump:hover { background:color-mix(in srgb,var(--accent) 9%,transparent); color:var(--ink); }
.rt-workspace-nav .rt-jump { flex:1 1 auto; text-align:center; font-weight:600; }
.rt-workspace-nav [aria-current="page"] { background:color-mix(in srgb,var(--rt-tone) 13%,var(--surface)); color:var(--rt-tone); box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--rt-tone) 22%,transparent); }
.rt-workspace-panel[hidden] { display:none !important; }
.rt-section-head { margin-bottom:24px; }
.rt-section-head h2 { margin:0 0 6px; font-size:18px; font-weight:600; }
.rt-section-head p { margin:0; color:var(--ink-muted); font-size:13px; line-height:1.6; }
.rt-overview-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; margin-bottom:24px; }
.rt-overview-tile { position:relative; display:flex; flex-direction:column; align-items:flex-start; gap:10px; min-width:0; min-height:145px; text-align:left; border:1px solid color-mix(in srgb,var(--rt-tone) 25%,var(--line)); border-radius:14px; padding:22px; cursor:pointer; background:color-mix(in srgb,var(--rt-tone) 10%,var(--surface)); color:var(--ink); font:inherit; transition:box-shadow .15s,transform .15s; }
.rt-overview-tile:hover { box-shadow:0 5px 18px #0000000a; transform:translateY(-2px); }
.rt-tile-label { color:var(--rt-tone); font-size:12px; font-weight:600; }
.rt-overview-tile strong { font-size:21px; font-weight:600; text-transform:capitalize; overflow-wrap:anywhere; }
.rt-tile-note { font-size:11px; color:var(--ink-muted); }
.rt-tile-arrow { position:absolute; top:18px; right:18px; color:var(--rt-tone); }
#view-redteam .card { margin-bottom:20px; border-radius:14px; overflow:hidden; min-width:0; }
#view-redteam .card[data-rt-tone] { border-top:3px solid color-mix(in srgb,var(--rt-tone) 45%,var(--surface)); }
#view-redteam .card-head { padding:20px 24px; display:flex; gap:10px 16px; flex-wrap:wrap; align-items:center; background:color-mix(in srgb,var(--rt-tone,var(--accent)) 5%,var(--surface)); }
#view-redteam .card-title { font-size:14px; font-weight:650; }
#view-redteam .card-hint { font-size:11px; }
#view-redteam .pad { padding:22px 24px !important; }
#view-redteam .set-intro { line-height:1.7; margin-bottom:0; }
#view-redteam .card > p { padding:0 24px; font-size:12px; line-height:1.65; }
#view-redteam .set-row { grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:12px 36px; align-items:start; }
#view-redteam .set-row > div:not(.set-label) { width:100% !important; min-width:0; }
#view-redteam .set-hint { color:var(--ink-muted); max-width:60ch; line-height:1.6; }
#view-redteam input:not([type="checkbox"]), #view-redteam select, #view-redteam textarea { box-sizing:border-box; width:100% !important; max-width:100%; min-width:0; padding:10px 12px; border:1px solid var(--line); border-radius:8px; background:var(--bg); color:var(--ink); font:inherit; font-size:12px; }
#view-redteam input[type="number"] { max-width:180px; }
#view-redteam input[type="checkbox"] { accent-color:var(--rt-tone,var(--accent)); width:16px; height:16px; flex-shrink:0; margin-top:3px; }
#view-redteam textarea { resize:vertical; line-height:1.6; }
#view-redteam .btn { border-radius:8px; min-height:34px; white-space:normal; }
#view-redteam :is(button,input,select,textarea,a,summary):focus-visible { outline:2px solid var(--accent); outline-offset:3px; }
.rt-related { display:flex; justify-content:space-between; flex-wrap:wrap; gap:8px; padding:10px 14px; border-top:1px solid var(--line); background:color-mix(in srgb,var(--rt-tone,var(--accent)) 4%,var(--surface)); }
#view-redteam .rt-activity { padding:24px; }
.rt-activity h3 { margin:0 0 10px; font-size:15px; }
.rt-activity p { padding:0 !important; line-height:1.7; font-size:13px; color:var(--ink-muted); overflow-wrap:anywhere; }
.rt-activity progress { display:block; width:100%; height:8px; accent-color:var(--accent); margin:18px 0; }
.rt-activity progress[hidden] { display:none; }
.rt-color-legend { display:flex; flex-wrap:wrap; gap:10px 20px; font-size:11px; color:var(--ink-muted); margin:20px 0; }
.rt-color-legend span::before { content:''; display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--rt-tone); margin-right:7px; }
#view-redteam #rtPacksList { grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px !important; }
.rt-pack-card { display:flex; gap:12px; align-items:flex-start; padding:18px; border:1px solid color-mix(in srgb,var(--rt-tone) 22%,var(--line)); border-radius:12px; background:color-mix(in srgb,var(--rt-tone) 6%,var(--surface)); line-height:1.6; }
.rt-pack-card > div { min-width:0; overflow-wrap:anywhere; }
.rt-pack-card:has(input:checked) { box-shadow:inset 0 0 0 1px var(--rt-tone); background:color-mix(in srgb,var(--rt-tone) 12%,var(--surface)); }
#view-redteam .rt-state { color:var(--rt-tone); background:color-mix(in srgb,var(--rt-tone) 12%,var(--surface)); border:1px solid color-mix(in srgb,var(--rt-tone) 22%,transparent); padding:4px 9px; white-space:nowrap; }
#view-redteam .tablewrap { overflow-x:auto; }
#view-redteam table { width:100%; border-collapse:collapse; text-align:left; }
#view-redteam table th { white-space:nowrap; font-size:10px; letter-spacing:.04em; color:var(--ink-muted); font-weight:600; padding:12px 16px; border-bottom:1px solid var(--line); }
#view-redteam table td { vertical-align:top; padding:15px 16px; font-size:12px; line-height:1.6; border-bottom:1px solid var(--line); overflow-wrap:anywhere; }
#view-redteam table tbody tr:last-child td { border-bottom:0; }
#view-redteam table td.empty { white-space:normal; }
#view-redteam table:has(thead) { min-width:700px; }
#view-redteam #redteamCampaignsTable:has(thead) { min-width:1000px; }
#view-redteam button:disabled { opacity:.5; cursor:not-allowed; }
#view-redteam details { border:1px solid var(--line); border-radius:10px; padding:14px 16px; }
#view-redteam summary { font-size:13px; font-weight:600; cursor:pointer; }
@media (max-width:1100px) { .rt-overview-grid { grid-template-columns:repeat(2,minmax(0,1fr)); } }
/* Keep the shared application controls reachable on narrow screens. */
@media (max-width:860px) {
  .topstack { position:static; }
  .topbar { flex-wrap:wrap; position:relative; gap:8px; padding:14px 20px; }
  .topbar #projMenu { flex:1 1 100%; min-width:0; }
  .topbar #projectCtx { max-width:100%; }
  .topbar #projectLabel { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .topbar .cmdk, .topbar #lastUpdated { display:none; }
  .topbar .searchbox { flex:1 1 180px; }
}
@media (max-width:720px) {
  #view-redteam .rt-page-head { align-items:flex-start; flex-direction:column; }
  #view-redteam .set-row, #view-redteam #rtPacksList { grid-template-columns:minmax(0,1fr); }
  #view-redteam .pad, #view-redteam .card-head { padding:18px !important; }
  .rt-overview-tile { padding:16px; min-height:132px; }
  .rt-overview-tile strong { font-size:18px; }
  .rt-workspace-nav .rt-jump { flex:1 1 40%; }
}
@media (prefers-reduced-motion:reduce) { .rt-overview-tile { transition:none; } .rt-overview-tile:hover { transform:none; } }
:root[data-theme="dark"] #view-redteam { --rt-blue:#9fc7ef; --rt-violet:#c6b0ef; --rt-mint:#95d8bb; --rt-amber:#efd08c; --rt-rose:#efacbd; }

/* ---------- Ops Center (ops.js) ----------
   Platform admin → Ops Center. Everything is built from the shared tokens, so
   light, dark and the accent/density preferences apply without overrides.
   Level colours: ok → --ok, warning → --sev-medium, critical → --sev-critical,
   no data → --ink-faint. */
#view-ops { --ops-ok: var(--ok); --ops-warn: var(--sev-medium); --ops-crit: var(--sev-critical); --ops-unknown: var(--ink-faint); }
#view-ops .lvl-ok { --lc: var(--ops-ok); }
#view-ops .lvl-warn { --lc: var(--ops-warn); }
#view-ops .lvl-crit { --lc: var(--ops-crit); }
#view-ops .lvl-unknown { --lc: var(--ops-unknown); }
#view-ops .page-head { align-items: center; }
/* Grid items default to min-width:auto, so one wide child (the data-path map)
   would widen the whole column past the viewport. Let them shrink; wide
   content scrolls inside its own card instead. */
#view-ops, #view-ops > *, .ops-body > *, .ops-grid-2 > * { min-width: 0; }
.ops-head-tools { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ops-seg button { padding: 5px 11px; }

/* live indicator */
.ops-live { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; }
.ops-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.ops-live[data-state="live"] { color: var(--ok); }
.ops-live[data-state="live"] .ops-live-dot { background: var(--ok); animation: ops-pulse 1.8s ease-out infinite; }
.ops-live[data-state="stale"] { color: var(--sev-medium); }
.ops-live[data-state="stale"] .ops-live-dot { background: var(--sev-medium); }
.ops-live[data-state="error"] { color: var(--sev-critical); }
.ops-live[data-state="error"] .ops-live-dot { background: var(--sev-critical); }
@keyframes ops-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); } 100% { box-shadow: 0 0 0 7px transparent; } }

/* hero */
.ops-hero { display: flex; align-items: center; gap: calc(var(--u)*3.4); padding: calc(var(--u)*3.4) calc(var(--u)*4); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); position: relative; overflow: hidden; }
.ops-hero::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 5px; background: var(--hc, var(--ink-faint)); }
.ops-hero[data-level="ok"] { --hc: var(--ok); }
.ops-hero[data-level="warn"] { --hc: var(--sev-medium); background: color-mix(in srgb, var(--sev-medium) 6%, var(--surface)); }
.ops-hero[data-level="crit"] { --hc: var(--sev-critical); background: color-mix(in srgb, var(--sev-critical) 7%, var(--surface)); }
.ops-hero-mark { width: 38px; height: 38px; border-radius: 50%; flex: none; background: color-mix(in srgb, var(--hc, var(--ink-faint)) 18%, transparent); box-shadow: inset 0 0 0 2px var(--hc, var(--ink-faint)); position: relative; }
.ops-hero-mark::after { content: ""; position: absolute; inset: 11px; border-radius: 50%; background: var(--hc, var(--ink-faint)); }
.ops-hero-title { font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.ops-hero-sub { color: var(--ink-muted); font-size: 12.5px; margin-top: 2px; }
.ops-hero-counts { margin-left: auto; display: flex; gap: calc(var(--u)*3); }
.ops-count { display: grid; text-align: center; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); }
.ops-count b { font-size: 22px; font-weight: 650; letter-spacing: -.02em; color: var(--lc); font-variant-numeric: tabular-nums; line-height: 1.1; }
.ops-count.lvl-ok b { color: var(--ink); }

/* tabs */
.ops-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.ops-tab { font: inherit; font-size: 12.5px; font-weight: 600; color: var(--ink-muted); background: none; border: none; border-bottom: 2px solid transparent; padding: calc(var(--u)*2) calc(var(--u)*2.8); cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 7px; }
.ops-tab:hover { color: var(--ink); }
.ops-tab.on { color: var(--ink); border-bottom-color: var(--accent); }
.ops-tab[data-level]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: transparent; }
.ops-tab[data-level="ok"]::before { background: var(--ok); }
.ops-tab[data-level="warn"]::before { background: var(--sev-medium); }
.ops-tab[data-level="crit"]::before { background: var(--sev-critical); }
.ops-tab[data-level="unknown"]::before { background: var(--ink-faint); }
.ops-body { display: grid; gap: calc(var(--u)*3.4); }
.ops-body > .card > .pad, .ops-body .pad { padding: calc(var(--u)*3) calc(var(--u)*3.2); }

/* status dots */
.ops-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--lc, var(--ink-faint)); margin-right: 7px; vertical-align: 1px; flex: none; }
.ops-dot.lvl-crit { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ops-crit) 22%, transparent); }

/* category summary cards (Live tab) */
.ops-cats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: calc(var(--u)*2.5); }
.ops-cat { font: inherit; color: inherit; text-align: left; cursor: pointer; display: grid; gap: 5px; align-content: start; padding: calc(var(--u)*2.6) calc(var(--u)*3); background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--lc); border-radius: var(--radius); }
.ops-cat:hover { background: var(--surface-2); }
.ops-cat:focus-visible, .ops-node:focus-visible, .ops-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.ops-cat-top { display: flex; align-items: center; gap: 4px; }
.ops-cat-name { font-weight: 650; font-size: 13.5px; margin-right: auto; }
.ops-cat-counts { font-size: 11.5px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.ops-cat-why { font-size: 11.5px; color: var(--ink-faint); line-height: 1.45; }
.ops-cat.lvl-warn .ops-cat-why, .ops-cat.lvl-crit .ops-cat-why { color: var(--ink); }
.ops-cat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: calc(var(--u)*2.4) calc(var(--u)*3.2); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--lc, var(--line)); border-radius: var(--radius); font-size: 13px; }
.ops-cat-head .dim { font-size: 12px; color: var(--ink-muted); }

/* pipeline map */
.ops-map { display: flex; align-items: stretch; gap: 6px; padding: calc(var(--u)*3) calc(var(--u)*3.2); overflow-x: auto; }
.ops-node { font: inherit; color: inherit; text-align: left; cursor: pointer; flex: 1 1 0; min-width: 104px; display: grid; gap: 3px; align-content: start; padding: 10px 12px; background: var(--bg); border: 1px solid var(--line); border-bottom: 3px solid var(--lc); border-radius: var(--radius); }
.ops-node:hover { background: var(--surface-2); }
.ops-node-name { font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); line-height: 1.3; }
.ops-node-main { font-size: 17px; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ops-node-main small { font-size: 10.5px; font-weight: 500; color: var(--ink-faint); letter-spacing: 0; }
.ops-node-sub { font-size: 11px; color: var(--ink-faint); white-space: nowrap; }
.ops-node.lvl-crit { background: color-mix(in srgb, var(--ops-crit) 7%, var(--bg)); }
.ops-node.lvl-warn { background: color-mix(in srgb, var(--ops-warn) 7%, var(--bg)); }
.ops-arrow { align-self: center; color: var(--ink-faint); font-size: 14px; flex: none; }

.ops-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: calc(var(--u)*3.4); align-items: start; }

/* needs-attention list */
.ops-attn { list-style: none; margin: 0; padding: calc(var(--u)*1.4) 0; }
.ops-attn li { display: flex; align-items: baseline; gap: 2px; padding: 7px calc(var(--u)*3.2); font-size: 12.5px; line-height: 1.45; border-left: 3px solid transparent; }
.ops-attn li.lvl-crit { border-left-color: var(--ops-crit); background: color-mix(in srgb, var(--ops-crit) 5%, transparent); }
.ops-attn li.lvl-warn { border-left-color: var(--ops-warn); }
.ops-attn li + li { border-top: 1px solid var(--line); }
.ops-attn a { color: var(--ink); font-weight: 600; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 2px; }
.ops-attn .dim { color: var(--ink-muted); }
.ops-allclear { padding: calc(var(--u)*5) calc(var(--u)*3.2); color: var(--ok); font-weight: 600; font-size: 13px; }

/* metric tiles */
.ops-groups { display: grid; gap: calc(var(--u)*3.4); padding: calc(var(--u)*3) calc(var(--u)*3.2); }
.ops-group-head { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); font-weight: 650; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.ops-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: calc(var(--u)*2.2); }
.ops-tiles-big { padding: calc(var(--u)*3) calc(var(--u)*3.2); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.ops-tile { display: grid; gap: 3px; align-content: start; padding: 10px 12px 9px; background: var(--bg); border: 1px solid var(--line); border-left: 3px solid var(--lc); border-radius: var(--radius); min-width: 0; }
.ops-tile.lvl-crit { background: color-mix(in srgb, var(--ops-crit) 6%, var(--bg)); }
.ops-tile.lvl-warn { background: color-mix(in srgb, var(--ops-warn) 6%, var(--bg)); }
.ops-tile-top { display: flex; align-items: flex-start; gap: 6px; }
.ops-tile-lab { font-size: 10.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-muted); font-weight: 600; margin-right: auto; cursor: help; line-height: 1.35; }
.ops-tile-acts { display: inline-flex; gap: 3px; opacity: 0; transition: opacity .12s ease; }
.ops-tile:hover .ops-tile-acts, .ops-tile:focus-within .ops-tile-acts { opacity: 1; }
@media (hover: none) { .ops-tile-acts { opacity: 1; } }
.ops-tile-val { font-size: 22px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; cursor: pointer; line-height: 1.15; }
.ops-tile.lvl-crit .ops-tile-val { color: var(--ops-crit); }
.ops-tile.big .ops-tile-val { font-size: 26px; }
.ops-unit { font-size: 12px; font-weight: 500; color: var(--ink-faint); margin-left: 3px; letter-spacing: 0; }
.ops-tile-sub { font-size: 10.5px; color: var(--ink-faint); }
.ops-spark { width: 100%; height: 30px; display: block; }
.ops-tile.big .ops-spark { height: 46px; }
.ops-spark-line { fill: none; stroke: var(--lc, var(--accent)); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.ops-spark.lvl-ok .ops-spark-line, .ops-spark.lvl-unknown .ops-spark-line { stroke: var(--accent); }
.ops-spark-area { fill: color-mix(in srgb, var(--lc, var(--accent)) 12%, transparent); stroke: none; }
.ops-spark.lvl-ok .ops-spark-area, .ops-spark.lvl-unknown .ops-spark-area { fill: color-mix(in srgb, var(--accent) 10%, transparent); }
.ops-mini { font: inherit; font-size: 10.5px; font-weight: 600; padding: 2px 7px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink-muted); cursor: pointer; white-space: nowrap; }
.ops-mini:hover { color: var(--ink); background: var(--surface-2); }
.ops-mini.danger:hover { color: var(--sev-critical); border-color: color-mix(in srgb, var(--sev-critical) 40%, var(--line)); }
.ops-mini:disabled { opacity: .5; cursor: progress; }

/* tables */
.ops-table td.dim, .ops-table td .faint { white-space: normal; }
.ops-table td.dim { color: var(--ink-muted); max-width: 46ch; }
.ops-table .faint { color: var(--ink-faint); font-size: 11px; }
.ops-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ops-table .mono { font-family: var(--font-mono); font-size: 11.5px; }
.ops-table tr.ops-row-firing td { background: color-mix(in srgb, var(--ops-crit) 5%, transparent); }
.ops-actions { display: flex; gap: 4px; flex-wrap: nowrap; justify-content: flex-end; }
.ops-note { max-width: 40ch; white-space: normal; }
.ops-sources .tablewrap { max-height: 320px; overflow: auto; }

/* known issues */
.ops-issues { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: calc(var(--u)*3); align-items: start; }
.ops-issue { border-top: 3px solid var(--lc); }
.ops-issue .card-head { flex-wrap: wrap; }
.ops-issue-body { display: grid; gap: 10px; font-size: 12.5px; }
.ops-story { margin: 0; color: var(--ink-muted); line-height: 1.55; }
.ops-evidence { list-style: none; margin: 0; padding: 8px 10px; border-radius: var(--radius); background: color-mix(in srgb, var(--lc, var(--ops-warn)) 7%, transparent); }
.ops-evidence li { padding: 2px 0; }
.ops-evidence-none { font-size: 12px; }
.ops-sigs { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; font-size: 11px; }
.ops-sig { font-family: var(--font-mono); font-size: 10.5px; padding: 2px 7px; border: 1px solid var(--line); border-radius: 99px; color: var(--ink-muted); cursor: pointer; }
.ops-sig:hover { color: var(--ink); background: var(--surface-2); }
.ops-issue details { border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 11px; background: var(--bg); }
.ops-issue summary { font-weight: 600; cursor: pointer; font-size: 12px; }
.ops-issue ol { margin: 8px 0 2px; padding-left: 20px; display: grid; gap: 5px; line-height: 1.5; color: var(--ink-muted); }
.ops-ref { font-size: 11px; }

/* modal + forms */
.ops-modal { position: fixed; inset: 0; z-index: 60; background: color-mix(in srgb, #000 42%, transparent); display: grid; place-items: start center; padding: 6vh 16px 16px; overflow-y: auto; }
.ops-modal[hidden] { display: none; }
.ops-modal-card { width: min(820px, 100%); background: var(--surface); box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.ops-modal-body { padding: calc(var(--u)*3.4) calc(var(--u)*3.6); }
.ops-x { margin-left: auto; font: inherit; font-size: 20px; line-height: 1; background: none; border: none; color: var(--ink-muted); cursor: pointer; padding: 0 4px; }
.ops-x:hover { color: var(--ink); }
.ops-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.ops-form .wide { grid-column: 1 / -1; }
.ops-field { display: grid; gap: 4px; font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--ink-muted); }
.ops-field input, .ops-field select, .ops-field textarea { font: inherit; font-size: 13px; font-weight: 400; letter-spacing: 0; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px; width: 100%; box-sizing: border-box; }
.ops-field input:focus, .ops-field select:focus, .ops-field textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
.ops-check { display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.ops-hint { font-size: 12px; color: var(--ink-muted); line-height: 1.5; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; }
.ops-form-err { color: var(--sev-critical); font-size: 12.5px; min-height: 1em; }
.ops-form-err:empty { display: none; }
.ops-form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.ops-trend { display: grid; gap: 12px; }
.ops-trend-top { display: flex; align-items: flex-start; gap: 14px; justify-content: space-between; }
.ops-trend-top .dim { font-size: 12px; color: var(--ink-muted); max-width: 70ch; margin-top: 4px; }
.ops-trend-foot { font-size: 11px; }
.ops-chart { width: 100%; height: auto; display: block; }
.ops-grid { stroke: var(--chart-grid); stroke-width: 1; }
.ops-axis { fill: var(--ink-faint); font-size: 9.5px; font-family: var(--font-ui); }
.ops-line { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.ops-band { fill: color-mix(in srgb, var(--accent) 14%, transparent); stroke: none; }
.ops-hit { fill: transparent; }
.ops-hit:hover { fill: color-mix(in srgb, var(--accent) 10%, transparent); }
.ops-mark { stroke-width: 1; stroke-dasharray: 4 4; }
.ops-mark.warn { stroke: var(--sev-medium); }
.ops-mark.crit { stroke: var(--sev-critical); }
.ops-mark-lab { font-size: 9.5px; font-weight: 600; }
.ops-mark-lab.warn { fill: var(--sev-medium); }
.ops-mark-lab.crit { fill: var(--sev-critical); }

@media (max-width: 1200px) { .ops-cats { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ops-grid-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .ops-hero { flex-wrap: wrap; }
  .ops-hero-counts { margin-left: 0; width: 100%; justify-content: space-between; }
  .ops-head-tools { margin-left: 0; }
  .ops-map { flex-wrap: wrap; }
  .ops-arrow { display: none; }
  .ops-node { flex: 1 1 40%; }
  .ops-issues { grid-template-columns: minmax(0, 1fr); }
  .ops-form { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 560px) { .ops-cats { grid-template-columns: minmax(0, 1fr); } }
@media (prefers-reduced-motion: reduce) { .ops-live[data-state="live"] .ops-live-dot { animation: none; } .ops-tile-acts { transition: none; } }
