/* Governed AI Gateway console. Corey Mathie, 2026. Dark violet identity; no external fonts or libraries. */
:root {
  --bg: #0e0a1d;
  --surface: #161129;
  --surface-2: #1e1838;
  --surface-3: #272047;
  --border: #2f2757;
  --border-strong: #463b7c;
  --fg: #eeebf8;
  --muted: #aaa3c9;
  --faint: #7d76a0;
  --accent: #a78bfa;
  --accent-strong: #8b5cf6;
  --accent-ink: #120d24;
  --accent-soft: rgba(167, 139, 250, 0.14);
  --ok: #4ade80;
  --ok-soft: rgba(74, 222, 128, 0.14);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.15);
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.15);
  --info: #60a5fa;
  --info-soft: rgba(96, 165, 250, 0.15);
  --chart-1: #a78bfa;
  --chart-2: #60a5fa;
  --chart-3: #4ade80;
  --chart-4: #fbbf24;
  --chart-5: #f472b6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  --sidebar: 236px;
  --sidebar-bg: linear-gradient(180deg, #151028, #110d22);
  --topbar-bg: rgba(14, 10, 29, 0.86);
  --empty-bg: rgba(22, 17, 41, 0.6);
  --link-hover: #c4b5fd;
  --primary-hover: #b9a2fc;
  --ic-pass: #1b3b2a;
  --ic-deny: #4a1f28;
  --ic-hit: #2f2459;
  --gutter-bg: #110c22;
  color-scheme: dark;
}
/* Light theme: follows the system unless the header toggle chose one (html[data-theme]). */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f5fb; --surface: #ffffff; --surface-2: #f3f1fa; --surface-3: #e9e6f5; --border: #e2def0; --border-strong: #c9c2e3;
    --fg: #1b1530; --muted: #5d5678; --faint: #847da0; --accent: #6d4bd8; --accent-strong: #5b3cc4; --accent-ink: #ffffff;
    --accent-soft: rgba(109, 75, 216, 0.1); --ok: #15803d; --ok-soft: rgba(22, 163, 74, 0.12); --warn: #a16207; --warn-soft: rgba(234, 179, 8, 0.16);
    --bad: #c2312f; --bad-soft: rgba(220, 38, 38, 0.1); --info: #1d64c8; --info-soft: rgba(37, 99, 235, 0.1);
    --chart-1: #7c5ce0; --chart-2: #3b82f6; --chart-3: #22a55b; --chart-4: #e0a00b; --chart-5: #db4f96;
    --shadow: 0 10px 30px rgba(40, 30, 80, 0.12); --sidebar-bg: #fbfaff; --topbar-bg: rgba(255, 255, 255, 0.9); --empty-bg: #faf9fe;
    --link-hover: #4c2fb0; --primary-hover: #5b3cc4; --ic-pass: #dcfce7; --ic-deny: #fee2e2; --ic-hit: #ede9fe; --gutter-bg: #f3f1fa;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f5fb; --surface: #ffffff; --surface-2: #f3f1fa; --surface-3: #e9e6f5; --border: #e2def0; --border-strong: #c9c2e3;
  --fg: #1b1530; --muted: #5d5678; --faint: #847da0; --accent: #6d4bd8; --accent-strong: #5b3cc4; --accent-ink: #ffffff;
  --accent-soft: rgba(109, 75, 216, 0.1); --ok: #15803d; --ok-soft: rgba(22, 163, 74, 0.12); --warn: #a16207; --warn-soft: rgba(234, 179, 8, 0.16);
  --bad: #c2312f; --bad-soft: rgba(220, 38, 38, 0.1); --info: #1d64c8; --info-soft: rgba(37, 99, 235, 0.1);
  --chart-1: #7c5ce0; --chart-2: #3b82f6; --chart-3: #22a55b; --chart-4: #e0a00b; --chart-5: #db4f96;
  --shadow: 0 10px 30px rgba(40, 30, 80, 0.12); --sidebar-bg: #fbfaff; --topbar-bg: rgba(255, 255, 255, 0.9); --empty-bg: #faf9fe;
  --link-hover: #4c2fb0; --primary-hover: #5b3cc4; --ic-pass: #dcfce7; --ic-deny: #fee2e2; --ic-hit: #ede9fe; --gutter-bg: #f3f1fa;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; font-weight: 620; }
h3 { font-size: 13px; font-weight: 600; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; font-weight: 600; }
.skip-link:focus { top: 8px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--sidebar-bg);
  border-right: 1px solid var(--border); padding: 16px 12px; display: flex; flex-direction: column; gap: 14px;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 6px 10px; }
.brand-mark { width: 32px; height: 32px; flex: none; }
.brand-name { font-weight: 680; font-size: 14.5px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 9px; color: var(--muted);
  text-decoration: none; font-weight: 520; font-size: 13.5px;
}
.nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.9; }
.nav a:hover { background: var(--surface-2); color: var(--fg); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--fg); box-shadow: inset 2px 0 0 var(--accent); }
.nav-foot { margin-top: auto; font-size: 12px; color: var(--faint); padding: 8px 6px; display: grid; gap: 6px; }
.nav-foot a { color: var(--muted); }
.menu-btn { display: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: var(--topbar-bg); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.topbar .title { font-weight: 620; font-size: 15px; }
.topbar .spacer { flex: 1; }
.mode-badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px; border-radius: 999px; font-size: 12px;
  font-weight: 560; border: 1px solid var(--border-strong); background: var(--surface-2); white-space: nowrap;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis;
}
.mode-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.mode-badge.live .dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.mode-badge.err .dot { background: var(--bad); }
.content { padding: 24px 28px 48px; max-width: 1320px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head p { color: var(--muted); margin: 4px 0 0; max-width: 760px; }
.boot { padding: 10px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); color: var(--muted); font-size: 13px; margin-bottom: 16px; display: flex; gap: 10px; align-items: center; }
.boot.err { color: var(--bad); border-color: var(--bad); }

/* ---------- building blocks ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; min-width: 0; }
.card + .card { margin-top: 16px; }
.grid > .card + .card, .stack > .card + .card, .prov-grid > .card + .card, .grid > .stack { margin-top: 0; }
#view:focus { outline: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }
.right { text-align: right; }
.nw { white-space: nowrap; }
.hr { height: 1px; background: var(--border); margin: 14px 0; }

.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.kpi .l { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .v { font-size: 24px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .s { font-size: 11.5px; color: var(--faint); margin-top: 2px; overflow-wrap: anywhere; }
.kpi.warn .v { color: var(--warn); }
.kpi.bad .v { color: var(--bad); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  white-space: nowrap; border: 1px solid transparent; line-height: 1.6;
}
.tag.sim { background: var(--warn-soft); color: var(--warn); border-color: rgba(251, 191, 36, 0.35); }
.tag.real { background: var(--accent-soft); color: var(--accent); border-color: rgba(167, 139, 250, 0.35); }
.tag.measured { background: var(--info-soft); color: var(--info); border-color: rgba(96, 165, 250, 0.35); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.pill.ok, .pill.pass, .pill.closed { background: var(--ok-soft); color: var(--ok); }
.pill.warn, .pill.flagged, .pill.half_open, .pill.override { background: var(--warn-soft); color: var(--warn); }
.pill.bad, .pill.deny, .pill.error, .pill.open, .pill.pause, .pill.paused, .pill.rejected { background: var(--bad-soft); color: var(--bad); }
.pill.hit, .pill.cache_hit, .pill.info { background: var(--accent-soft); color: var(--accent); }
.pill.skip, .pill.neutral, .pill.miss { background: var(--surface-3); color: var(--muted); }

button, .btn {
  font: inherit; font-size: 13px; font-weight: 560; color: var(--fg); background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 9px; padding: 7px 13px; cursor: pointer; display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  line-height: 1.35; min-height: 34px;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--accent); background: var(--surface-3); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
button.primary:hover:not(:disabled) { background: var(--primary-hover); }
button.danger { color: var(--bad); border-color: rgba(248, 113, 113, 0.5); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover:not(:disabled) { color: var(--fg); background: var(--surface-2); border-color: var(--border); }
button.sm { padding: 4px 9px; font-size: 12px; min-height: 28px; }
.spin { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

label.field { display: grid; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 520; min-width: 0; }
input[type="text"], input[type="number"], input[type="password"], input[type="search"], select, textarea {
  font: inherit; font-size: 13px; color: var(--fg); background: var(--bg); border: 1px solid var(--border-strong); border-radius: 9px;
  padding: 7px 10px; min-height: 34px; width: 100%; min-width: 0;
}
textarea { resize: vertical; line-height: 1.5; }
select { cursor: pointer; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .wide { grid-column: span 2; }
.form-grid .full { grid-column: 1 / -1; }
.switch { vertical-align: middle; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; cursor: pointer; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: transform 0.15s; }
.switch input:checked { background: var(--accent-strong); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(14px); background: #fff; }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 9px 12px; min-height: 0; white-space: nowrap; }
.tabs button:hover:not(:disabled) { background: transparent; color: var(--fg); border-color: transparent; border-bottom-color: var(--border-strong); }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; min-height: 30px; padding: 5px 11px; background: transparent; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 560; background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap.scroll { max-height: 320px; overflow: auto; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.click:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
td .sub { display: block; font-size: 11.5px; color: var(--faint); }
td select { width: auto; min-width: 104px; }

/* ---------- states ---------- */
.empty, .loading, .error-state {
  display: grid; place-items: center; text-align: center; gap: 8px; padding: 36px 16px; color: var(--muted);
  border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--empty-bg);
}
.empty h3, .error-state h3 { color: var(--fg); font-size: 14px; }
.error-state { border-color: rgba(248, 113, 113, 0.5); }
.error-state h3 { color: var(--bad); }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; height: 14px; }
@keyframes shimmer { to { background-position: -200% 0; } }
.note { border-left: 3px solid var(--accent); background: var(--accent-soft); padding: 9px 12px; border-radius: 0 8px 8px 0; font-size: 12.5px; color: var(--fg); }
.note.warn { border-color: var(--warn); background: var(--warn-soft); }
.note.bad { border-color: var(--bad); background: var(--bad-soft); }

/* ---------- charts ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart.compact text { font-size: 13px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 40%) minmax(0, 1fr) 84px; gap: 10px; align-items: center; font-size: 12.5px; padding: 5px 0; }
.hbar .track { height: 10px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 999px; background: var(--chart-1); }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card:has(> .hbar) { container-type: inline-size; }
@container (max-width: 420px) {
  .hbar { grid-template-columns: minmax(0, 1fr) 70px; row-gap: 4px; }
  .hbar .name { grid-column: 1 / -1; }
}
.meter { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.25s; }
.meter > i.warn { background: var(--warn); }
.meter > i.bad { background: var(--bad); }

/* ---------- guided cards ---------- */
.try-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.try { display: grid; gap: 6px; align-content: start; padding: 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); text-decoration: none; color: var(--fg); }
.try:hover { border-color: var(--accent); color: var(--fg); background: var(--surface-3); }
.try b { font-size: 13.5px; }
.try span { color: var(--muted); font-size: 12.5px; }
.try .go { color: var(--accent); font-size: 12px; font-weight: 600; }

/* ---------- playground ---------- */
.result { display: grid; gap: 12px; container-type: inline-size; }
.result-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.result-meta div { background: var(--surface-2); border-radius: 9px; padding: 8px 10px; min-width: 0; }
.result-meta b { display: block; font-size: 14px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result-meta span { font-size: 11.5px; color: var(--muted); }
pre.box { white-space: pre-wrap; word-break: break-word; font: 12.5px/1.55 var(--mono); background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; margin: 0; max-height: 280px; overflow: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.chip.pass { background: var(--ok-soft); color: var(--ok); }
.chip.deny, .chip.error { background: var(--bad-soft); color: var(--bad); }
.chip.hit { background: var(--accent-soft); color: var(--accent); }
.prov-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.prov { border-top: 3px solid var(--ok); }
.prov.down { border-top-color: var(--bad); }
.prov.degraded { border-top-color: var(--warn); }
.prov h3 { font-size: 14px; }
.dep { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 12px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.dep:last-child { border-bottom: 0; }
.dep code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knob { display: grid; grid-template-columns: 80px minmax(0, 1fr) 58px; gap: 8px; align-items: center; font-size: 12px; margin: 8px 0; }
.knob output { font-family: var(--mono); text-align: right; font-size: 11.5px; }
.compare-col { display: grid; gap: 10px; align-content: start; container-type: inline-size; }
@container (max-width: 460px) { .result-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.timeline-mini { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.timeline-mini .arrow { color: var(--faint); font-size: 11px; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(5, 3, 12, 0.6); z-index: 40; opacity: 0; pointer-events: none; transition: opacity 0.15s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(620px, 100vw); z-index: 50; background: var(--surface);
  border-left: 1px solid var(--border-strong); box-shadow: var(--shadow); transform: translateX(102%); transition: transform 0.2s ease;
  display: flex; flex-direction: column; visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { padding: 16px 18px; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; }
.drawer-body { padding: 16px 18px 28px; overflow-y: auto; flex: 1; }
.tl { list-style: none; margin: 0; padding: 0; position: relative; }
.tl::before { content: ""; position: absolute; left: 11px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl li { position: relative; padding: 0 0 14px 34px; }
.tl .ic { position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--surface-3); color: var(--muted); border: 2px solid var(--surface); }
.tl .ic.pass { background: var(--ic-pass); color: var(--ok); }
.tl .ic.deny, .tl .ic.error { background: var(--ic-deny); color: var(--bad); }
.tl .ic.hit { background: var(--ic-hit); color: var(--accent); }
.tl .ic.miss { background: var(--surface-3); color: var(--fg); }
.tl .st { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.tl .st b { font-size: 13px; }
.tl .sm { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.tl details { margin-top: 4px; }
.tl summary { cursor: pointer; font-size: 11.5px; color: var(--faint); }
.attempts { display: grid; gap: 4px; margin-top: 6px; }
.attempt { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: center; font-size: 12px; background: var(--surface-2); border-radius: 8px; padding: 6px 8px; }
.attempt code { overflow-wrap: anywhere; }

/* ---------- policies editor ---------- */
.editor { display: grid; grid-template-columns: 44px minmax(0, 1fr); border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; background: var(--bg); }
.editor .gutter { font: 12.5px/1.6 var(--mono); color: var(--faint); text-align: right; padding: 10px 8px 10px 0; user-select: none; overflow: hidden; background: var(--gutter-bg); border-right: 1px solid var(--border); white-space: pre; }
.editor .gutter .bad { color: var(--bad); font-weight: 700; }
.editor textarea { border: 0; border-radius: 0; font: 12.5px/1.6 var(--mono); min-height: 460px; padding: 10px 12px; white-space: pre; overflow: auto; tab-size: 2; resize: vertical; background: transparent; box-shadow: none; }
.editor textarea:focus { box-shadow: none; }
.errors { display: grid; gap: 6px; }
.errors button { justify-content: flex-start; text-align: left; width: 100%; font-weight: 500; color: var(--bad); border-color: rgba(248, 113, 113, 0.45); background: var(--bad-soft); white-space: normal; }
.matrix td.cell, .matrix th + th { text-align: center; }
.matrix td.changed { outline: 2px solid var(--warn); outline-offset: -3px; }

/* ---------- tour / toast ---------- */
.tour { position: fixed; z-index: 60; inset: 0; display: none; }
.tour.open { display: block; }
.tour .scrim2 { position: absolute; inset: 0; background: rgba(5, 3, 12, 0.55); }
.tour .bubble {
  position: absolute; width: min(360px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--accent);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: grid; gap: 10px;
}
.tour .step { font-size: 11.5px; color: var(--accent); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em; }
/* The sidebar is sticky (its own stacking context), so lift it above the tour scrim and dim the rest of it with the
   target's spread shadow, which the sidebar's overflow clips to the sidebar. */
.sidebar:has(.tour-target) { z-index: 61; }
.nav a.tour-target { position: relative; z-index: 1; color: var(--fg); background: var(--surface-2); border-radius: 10px; box-shadow: 0 0 0 3px var(--accent), 0 0 0 100vmax rgba(5, 3, 12, 0.55); }
.toasts { position: fixed; bottom: 16px; right: 16px; z-index: 70; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface-3); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 9px; font-size: 13px; box-shadow: var(--shadow); }
.toast.bad { border-left-color: var(--bad); }
.toast.ok { border-left-color: var(--ok); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g2.stack-md { grid-template-columns: minmax(0, 1fr); }
  table.dense th, table.dense td { padding-left: 6px; padding-right: 6px; }
  .prov-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .g2, .g3, .try-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky; top: 0; z-index: 30; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    padding: 10px 16px; gap: 8px; border-right: 0; border-bottom: 1px solid var(--border); overflow: visible;
  }
  .brand { padding: 0; flex: 1; min-width: 0; }
  .brand-sub { display: none; }
  .menu-btn { display: inline-flex; }
  .nav { display: none; width: 100%; padding-top: 6px; }
  .sidebar.open .nav { display: flex; }
  .nav-foot { display: none; }
  .topbar { position: static; padding: 10px 16px; flex-wrap: wrap; }
  .content { padding: 16px 16px 40px; }
  .result-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi .v { font-size: 20px; }
  .prov-grid, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .wide { grid-column: auto; }
  .tabs button { padding: 9px 8px; font-size: 12.5px; }
  .seg { display: flex; width: 100%; }
  .seg button { flex: 1 1 auto; justify-content: center; padding: 5px 8px; font-size: 12px; white-space: nowrap; }
  .page-head { align-items: flex-start; }
  .editor { grid-template-columns: 34px minmax(0, 1fr); }
  .editor textarea { min-height: 360px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- navigation shell (demo/shell.js) ---------- */
.nav { gap: 12px; }
.nav-group { display: grid; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 0 10px 2px; }
.nav-items { display: grid; gap: 2px; }
.nav a span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav a.in-section { color: var(--fg); }
.nav .sub { padding-left: 28px; display: grid; gap: 1px; margin-top: 1px; }
.nav .sub a { font-size: 13px; font-weight: 500; padding: 6px 10px; position: relative; box-shadow: none; }
.nav .sub a::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 2px; border-radius: 2px; background: var(--border); }
.nav .sub a[aria-current="page"] { box-shadow: none; }
.nav .sub a[aria-current="page"]::before { background: var(--accent); }
.nav-tools { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: auto; padding: 10px 4px 4px; border-top: 1px solid var(--border); }
.nav-tools + .nav-foot { margin-top: 0; }
.nav-tools .icon { padding: 6px; min-height: 0; }
kbd { font-family: var(--font); font-size: 11px; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; line-height: 18px; white-space: nowrap; }
.nav-tools kbd { margin-right: 4px; }
@media (min-width: 861px) {
  body.nav-collapsed { --sidebar: 68px; }
  body.nav-collapsed .shell { grid-template-columns: 68px minmax(0, 1fr); }
  body.nav-collapsed .sidebar { padding-left: 8px; padding-right: 8px; }
  body.nav-collapsed .brand > div, body.nav-collapsed .nav a span, body.nav-collapsed .nav .sub,
  body.nav-collapsed .nav-foot, body.nav-collapsed #keys-btn { display: none; }
  body.nav-collapsed .brand { justify-content: center; }
  body.nav-collapsed .nav a { justify-content: center; padding-left: 0; padding-right: 0; }
  body.nav-collapsed .nav-label { font-size: 0; padding: 0; height: 1px; background: var(--border); margin: 4px 8px; }
  body.nav-collapsed .nav-tools { justify-content: center; }
  body.nav-collapsed #nav-collapse svg { transform: rotate(180deg); }
}
@media (max-width: 860px) { .nav-tools { display: none; } }

.crumbs { display: flex; flex-wrap: nowrap; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; color: var(--faint); min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs a { color: var(--muted); }
.crumbs i { font-style: normal; color: var(--border-strong); }
.crumbs [aria-current] { color: var(--fg); font-weight: 620; }
.topbar .title { flex: 1 1 auto; min-width: 0; }

.workspace { position: relative; flex: none; }
.workspace summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px 4px 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); font-weight: 600; font-size: 13px; white-space: nowrap; }
.workspace summary::-webkit-details-marker { display: none; }
.workspace summary:hover { border-color: var(--border-strong); }
.ws-mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--info); color: var(--accent-ink); font-size: 11px; font-weight: 800; }
.chev { color: var(--faint); }
.ws-pop { position: absolute; top: calc(100% + 8px); right: 0; z-index: 60; width: min(360px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 12px; box-shadow: var(--shadow); padding: 14px; display: grid; gap: 8px; font-size: 13px; }
.ws-pop p, .ws-pop h2 { margin: 0; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.tag.sample { background: var(--info-soft); color: var(--info); border-color: rgba(96, 165, 250, 0.35); }
.search-btn { display: flex; align-items: center; gap: 8px; flex: 0 1 280px; min-width: 0; min-height: 0; padding: 6px 8px 6px 10px; border: 1px solid var(--border); background: var(--surface); color: var(--faint); font-weight: 500; font-size: 13px; border-radius: 10px; }
.search-btn:hover:not(:disabled) { border-color: var(--border-strong); color: var(--muted); background: var(--surface); }
.search-btn svg { flex: none; }
.search-text { flex: 1 1 auto; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1360px) { .search-btn { flex: none; } .search-btn .search-text { display: none; } .workspace .ws-name { display: none; } }
@media (max-width: 1060px) { .search-btn kbd { display: none; } }
@media (max-width: 560px) { .workspace .tag, .workspace .chev, #tourBtn { display: none; } }

.palette, .keys { position: fixed; inset: 0; z-index: 80; background: rgba(5, 3, 12, 0.6); display: grid; justify-items: center; align-items: start; padding: 10vh 16px 16px; }
.palette[hidden], .keys[hidden] { display: none; }
.palette-panel, .keys-panel { width: min(620px, 100%); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); overflow: hidden; }
.palette-search { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--faint); }
.palette-search input { flex: 1; border: 0; background: transparent; padding: 4px 0; font: inherit; font-size: 16px; color: var(--fg); outline: none; min-width: 0; }
.palette-list { list-style: none; margin: 0; padding: 6px; max-height: min(420px, 55vh); overflow-y: auto; }
.palette-list li[role=option] { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.palette-list li[aria-selected="true"] { background: var(--accent-soft); }
.pal-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.pal-hint { color: var(--faint); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.pal-section { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); padding: 10px 10px 4px; }
.pal-empty { padding: 18px 10px; color: var(--muted); text-align: center; }
.palette-foot { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 9px 14px; margin: 0; border-top: 1px solid var(--border); font-size: 12px; color: var(--faint); background: var(--surface-2); }
.palette-foot kbd { margin-right: 3px; }
.keys-panel { padding: 16px; display: grid; gap: 10px; }
.keys-panel td { padding: 7px 8px; border-bottom: 1px solid var(--border); }
.keys-panel td:first-child { width: 110px; }

/* ---------- Overview › Business impact ---------- */
.tabs a { padding: 9px 12px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs a:hover { color: var(--fg); }
.tabs a[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.note.sample { border-color: var(--info); background: var(--info-soft); }
.note.sample a { color: var(--info); font-weight: 650; }
.period { margin: 10px 0 12px; }
.kpis.biz { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi.sample { border-top: 3px solid var(--info); }
.kpi.sample.warn { border-top-color: var(--warn); }
.kpi.sample.warn .v { color: var(--warn); }
.kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 2px; min-height: 26px; }
.spark { flex: 0 1 110px; max-width: 50%; height: 26px; }
.delta { font-size: 11.5px; font-weight: 700; white-space: nowrap; border-radius: 999px; padding: 1px 7px; }
.delta.good { background: var(--ok-soft); color: var(--ok); }
.delta.bad { background: var(--bad-soft); color: var(--bad); }
.delta.flat { background: var(--surface-3); color: var(--faint); font-weight: 600; }
.card-head > .tag { margin-left: auto; }
.meter { display: inline-block; vertical-align: middle; width: 90px; max-width: 30vw; height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 4px; background: var(--ok); }
.meter.warn i { background: var(--warn); }
.meter.bad i { background: var(--bad); }
.nw { white-space: nowrap; }
.checklist { list-style: none; margin: 0; padding: 0; display: grid; }
.checklist li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .ck { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); font-size: 12px; font-weight: 800; }
.checklist b { display: block; }
.checklist .small { display: block; }
.checklist .cv { font-weight: 700; font-variant-numeric: tabular-nums; }
.events { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.events li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 10px; }
.events p { margin: 0; color: var(--muted); font-size: 13px; }
.events h3 { margin: 1px 0 2px; font-size: 14px; }
.ev-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; background: var(--faint); }
.ev-risk .ev-dot { background: var(--bad); }
.ev-reliability .ev-dot { background: var(--info); }
.ev-policy .ev-dot { background: var(--accent); }
.ev-finops .ev-dot { background: var(--ok); }
.ev-meta { font-size: 12px; color: var(--faint); font-weight: 600; }
@media (max-width: 1180px) { .kpis.biz { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .kpis.biz { grid-template-columns: minmax(0, 1fr); } }
.card-head:has(> .tag.sample) { flex-wrap: nowrap; align-items: flex-start; }
.card-head:has(> .tag.sample) > div { flex: 1 1 auto; min-width: 0; }
@media (max-width: 1500px) { .workspace .ws-name, .search-btn .search-text, #tourBtn { display: none; } .search-btn { flex: none; } }

/* ---------- business / technical view, theme, tour invite, engine wait ---------- */
body:not(.tech) .tech-only { display: none !important; }
body.tech .biz-only { display: none !important; }
.view-switch button { padding: 4px 10px; font-size: 12px; min-height: 28px; }
.topbar > .view-switch, .topbar > .mode-badge, .topbar > button { flex: none; }
.topbar .icon { padding: 6px; min-height: 0; }
@media (max-width: 1180px) { .view-switch { display: none; } }
@media (max-width: 640px) { .hide-sm { display: none; } }
.mode-badge.starting .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.engine-wait { max-width: 620px; margin: 6vh auto; text-align: center; display: grid; justify-items: center; gap: 10px; padding: 28px; }
.engine-wait.error { text-align: left; justify-items: start; }
.engine-wait .spin { width: 26px; height: 26px; }
.tour-invite { position: fixed; right: 18px; bottom: 18px; z-index: 70; width: min(340px, calc(100vw - 32px)); display: grid; gap: 10px; box-shadow: var(--shadow); }
.tour-invite p { margin: 0; }
.tour-invite[hidden] { display: none; }

/* ---------- requests ---------- */
.rq-filters { grid-template-columns: minmax(200px, 2fr) repeat(4, minmax(130px, 1fr)); }
.form-grid.rq-filters .wide { grid-column: auto; }
@media (max-width: 1100px) { .rq-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-grid.rq-filters .wide { grid-column: 1 / -1; } }
.rq-summary { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0 2px 10px; font-size: 13px; color: var(--muted); }
.rq-summary b { color: var(--fg); font-variant-numeric: tabular-nums; }
.rq-table td { vertical-align: top; }
.rq-table .row-link { color: var(--fg); font-weight: 600; text-decoration: none; }
.rq-table tr.click:hover .row-link { color: var(--accent); }
@media (max-width: 760px) { .hide-narrow { display: none; } }
.rq-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.rq-nav .back { font-size: 13px; text-decoration: none; }
.rq-head h1 { margin-top: 2px; }
.rq-story { margin-bottom: 16px; }
.rq-story p { font-size: 14.5px; line-height: 1.6; max-width: 80ch; }
.rq-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .rq-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi .v.sm { font-size: 17px; line-height: 1.35; padding-top: 4px; }
.kpi .meter { width: 100%; display: block; margin: 6px 0 4px; }
.rq-tl .attempts { margin-top: 6px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 7px 14px; margin: 10px 0 0; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.rq-related { list-style: none; margin: 10px 0; padding: 0; display: grid; gap: 8px; }
.rq-related li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; font-size: 13px; }
.month-card .meter { width: 100%; }
.forecast { position: relative; }
.meter .fc { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--fg); opacity: 0.55; border-radius: 1px; }
.meter { position: relative; }
.latest li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px; }
.latest li:first-child { border-top: 0; }
.latest { list-style: none; margin: 0; padding: 0; }
.latest .t { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev-link { font-size: 12.5px; }
.meter.has-fc { overflow: visible; }
.meter.has-fc .fc { top: -3px; bottom: -3px; }
.month-top { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 4px 0 8px; }
.month-top .big { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.warn-text { color: var(--warn); }
.month-card table .meter { width: 120px; }
.page-head + .note, .rq-head + .note { margin-bottom: 14px; }
table.sources td { vertical-align: top; }
table.sources td:first-child { min-width: 140px; }
table.sources td:last-child { min-width: 240px; }
