:root {
  --bg: #0b0d10;
  --surface: #12161b;
  --raised: #171c23;
  --border: #232a33;
  --text: #e6e9ee;
  --muted: #8b95a3;
  --ok: #3ddc97;
  --bad: #ff6b6b;
  --warn: #f5a524;
  --info: #5aa9ff;
  --accent: #5aa9ff;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --r: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--sans);
}
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
code, .mono, pre, td.num, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
code { font-size: 0.86em; color: var(--text); }
a { color: var(--accent); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
main:focus { outline: none; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.skip {
  position: absolute; left: 8px; top: -48px; z-index: 10;
  background: var(--accent); color: #0b0d10; padding: 8px 16px; border-radius: 6px; font-weight: 600;
}
.skip:focus { top: 8px; }
.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* Header */
.top { border-bottom: 1px solid var(--border); background: var(--surface); }
.top-inner {
  display: flex; gap: 16px; align-items: center; justify-content: space-between;
  padding-top: 24px; padding-bottom: 16px; flex-wrap: wrap;
}
.top h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.tagline { color: var(--muted); margin-top: 4px; }
.badge {
  border: 1px solid var(--accent); color: var(--accent); border-radius: 999px;
  padding: 4px 12px; font-size: 13px; white-space: nowrap;
}
.jump ul { display: flex; gap: 4px 24px; flex-wrap: wrap; padding-bottom: 12px; }
.jump a { color: var(--muted); text-decoration: none; font-size: 14px; padding: 4px 0; display: inline-block; }
.jump a:hover { color: var(--text); text-decoration: underline; }

main { padding-top: 32px; padding-bottom: 48px; }
section { padding: 32px 0; border-top: 1px solid var(--border); }
section:first-of-type { border-top: 0; padding-top: 16px; }
.status { color: var(--muted); }
.status.err { color: var(--bad); }
.status:empty { display: none; }

.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 16px; margin-bottom: 24px; }
h2 { font-size: 20px; font-weight: 600; }
h3 { font-size: 16px; font-weight: 600; }
.sec-note { color: var(--muted); font-size: 14px; max-width: 72ch; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }

/* Environments */
.env-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.env { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.env-name { font-family: var(--mono); font-size: 18px; }
.gate { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border-radius: 8px; background: var(--raised); border-left: 3px solid var(--ok); }
.gate.manual { border-left-color: var(--info); }
.gate.reviewed { border-left-color: var(--warn); }
.gate-main { font-weight: 600; }
.gate-sub { color: var(--muted); font-size: 13px; }
.env-summary { color: var(--muted); font-size: 14px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { font-family: var(--mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kv-wide { grid-template-columns: minmax(120px, max-content) 1fr; }
.src { color: var(--muted); font-size: 12px; font-family: var(--mono); }

.units { margin-top: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.units-h { font-size: 14px; color: var(--muted); font-weight: 400; }
.waves { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wave { display: flex; gap: 8px; flex-wrap: wrap; }
.unit {
  font-family: var(--mono); font-size: 13px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--raised);
}
.then { color: var(--muted); font-size: 13px; }

/* Costs */
.cost-layout { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.chart { padding: 16px; }
.chart-cap { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; color: var(--muted); font-size: 13px; margin-bottom: 12px; flex-wrap: wrap; }
.toggle {
  font: inherit; font-size: 13px; color: var(--text); background: var(--raised);
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px; cursor: pointer; min-height: 32px;
}
.toggle:hover { border-color: var(--muted); }
.toggle[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.lg::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; border-radius: 2px; }
.lg-base::before { background: #1b2027; border: 1px solid var(--border); }
.lg-flag::before { background: var(--bad); border-radius: 50%; }

.row { display: grid; grid-template-columns: 168px minmax(0, 1fr) 64px; gap: 12px; align-items: center; padding: 6px 0; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row-name { font-size: 13px; line-height: 1.3; }
.row-name small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.row-max { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px; color: var(--muted); text-align: right; }
.row svg { display: block; width: 100%; height: 44px; overflow: visible; }
.row.flagged .row-name { color: var(--text); font-weight: 600; }
.svg-base { fill: var(--border); opacity: 0.55; }
.svg-area { fill: var(--accent); opacity: 0.08; }
.svg-line { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.svg-tick { stroke: var(--bad); stroke-width: 1; vector-effect: non-scaling-stroke; stroke-dasharray: 2 2; }
.plot { position: relative; }
.dot {
  position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
  background: var(--bad); box-shadow: 0 0 0 2px var(--surface);
}

.axis { position: relative; height: 20px; margin-left: 180px; margin-right: 76px; font-size: 11px; color: var(--muted); font-family: var(--mono); }
.axis span { position: absolute; top: 4px; transform: translateX(-50%); white-space: nowrap; }
.axis span:first-child { transform: none; }
.axis span:last-child { transform: translateX(-100%); }

.table-wrap { margin-top: 16px; max-height: 420px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
caption { text-align: left; padding: 8px 12px; color: var(--muted); }
th, td { padding: 4px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 500; background: var(--raised); position: sticky; top: 0; }
th[scope="row"] { text-align: left; position: static; background: transparent; color: var(--text); font-family: var(--mono); }
td.flag { color: var(--bad); font-weight: 600; }
tr.unchecked th[scope="row"] { color: var(--muted); }

.col-h { margin-bottom: 12px; }
.anom { padding: 16px; margin-bottom: 16px; border-left: 3px solid var(--bad); }
.anom h4 { font-size: 15px; font-weight: 600; }
.anom-date { color: var(--muted); font-weight: 400; font-family: var(--mono); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.stat { background: var(--raised); border-radius: 8px; padding: 8px; }
.stat dt { font-size: 12px; color: var(--muted); }
.stat dd { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 15px; }
.stat dd.bad { color: var(--bad); }
.anom-line { font-size: 13px; color: var(--muted); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-top: 12px; }
.tab {
  font: inherit; font-size: 13px; color: var(--muted); background: none; border: 0;
  border-bottom: 2px solid transparent; padding: 8px 10px; cursor: pointer; margin-bottom: -1px; min-height: 36px;
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.panel { padding-top: 12px; }
.panel-label { font-size: 12px; color: var(--warn); margin-bottom: 6px; }
.panel-label.fb { color: var(--muted); }
.msg p { margin: 0 0 6px; }
.msg p:last-child { margin: 0; }
.msg strong { color: var(--text); }
.msg code { font-size: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.msg {
  overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; color: var(--muted);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px;
}
.fallback-note { font-size: 13px; color: var(--muted); }
.empty { color: var(--muted); font-size: 14px; }

/* Supply chain: a real sequence, so it is numbered */
.pipeline { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; counter-reset: step; }
.step { padding: 12px; display: flex; flex-direction: column; gap: 8px; position: relative; counter-increment: step; }
.step-n { font-family: var(--mono); font-size: 12px; color: var(--accent); }
.step-n::before { content: counter(step); }
.step h3 { font-size: 14px; line-height: 1.35; }
.step code { font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.when { margin-top: auto; font-size: 12px; color: var(--muted); }
.when.main { color: var(--warn); }
.pipe-note { color: var(--muted); font-size: 13px; margin-top: 12px; max-width: 80ch; }
.kyverno { margin-top: 32px; }
.kyverno h3 { margin-bottom: 4px; }
.kyverno .sec-note { margin-bottom: 16px; }
.kyverno .kv { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; }

/* Guardrails */
.guards { display: grid; gap: 8px; }
.guard { padding: 12px 16px; display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 4px 12px; }
.guard-mark { color: var(--ok); font-family: var(--mono); grid-row: span 3; }
.guard h3 { font-size: 15px; }
.guard p { color: var(--muted); font-size: 14px; }
.evidence { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: baseline; font-size: 12px; }
.evidence code { color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; overflow-wrap: anywhere; }

.foot { color: var(--muted); font-size: 13px; padding-bottom: 32px; border-top: 1px solid var(--border); padding-top: 16px; }

/* One orchestrated moment: the cost lines draw in once. */
@media (prefers-reduced-motion: no-preference) {
  .svg-line.draw { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 900ms ease-out forwards; }
  @keyframes draw { to { stroke-dashoffset: 0; } }
}

@media (max-width: 1000px) {
  .cost-layout { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .wrap { padding: 0 16px; }
  .env-grid { grid-template-columns: 1fr; }
  .pipeline { grid-template-columns: 1fr; }
  .row { grid-template-columns: minmax(0, 1fr) 56px; gap: 4px 8px; }
  .row-name { grid-column: 1 / -1; }
  .row svg { height: 40px; }
  .axis { margin-left: 0; margin-right: 64px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .guard { grid-template-columns: 1fr; }
  .guard-mark { grid-row: auto; }
}
