:root {
  --navy: #0f1a2c;
  --panel: #15233a;
  --panel-2: #1b2c47;
  --line: #2a3d5c;
  --text: #e4ecf7;
  --muted: #8ea0bc;
  --cool: #3fa7d6;
  --ok: #3cc3a0;
  --warm: #f2b33d;
  --hot: #f0643a;
  --crit: #d92d55;
  --future: #7fe3f0;
  --power: #e8b04a;
  --water: #4aa3e8;
  --radius-lg: 14px;
  --radius-sm: 8px;
  --font: "Barlow", system-ui, sans-serif;
  --font-num: "Barlow Condensed", "Barlow", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--navy);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}

button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--future); outline-offset: 2px; }

/* ---------- app frame ---------- */
.app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr) 380px;
  grid-template-areas:
    "top top"
    "map side"
    "time side";
}

/* ---------- top bar ---------- */
.top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 26px; height: 26px; }
.brand-name { font-weight: 700; font-size: 20px; letter-spacing: 0.01em; }
.facility { color: var(--muted); }

.status {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 12px; border-radius: 999px;
  background: rgba(60, 195, 160, 0.12); color: var(--ok); font-weight: 600;
}
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status.incident { background: rgba(217, 45, 85, 0.16); color: #ff7d98; }
.status.incident::before { animation: blink 1s steps(2) infinite; }

.readouts { margin-left: auto; display: flex; gap: 28px; align-items: baseline; }
.readout { display: flex; flex-direction: column; align-items: flex-end; }
.readout .num { font-family: var(--font-num); font-size: 26px; font-weight: 600; line-height: 1; }
.readout .lbl { color: var(--muted); font-size: 13px; }
.readout.risk .num { color: var(--warm); }
.readout.risk.zero .num { color: var(--text); }

.btn {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 8px 14px; cursor: pointer; font-weight: 600;
}
.btn:hover { border-color: #46618c; }
.btn.primary { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }

/* ---------- simulate menu ---------- */
.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 10; width: 280px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 8px; box-shadow: 0 18px 40px rgba(3, 8, 18, 0.55);
}
.menu[hidden] { display: none; }
.menu h3 { margin: 8px 10px 4px; font-size: 13px; color: var(--muted); font-weight: 600; }
.menu button {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 9px 10px; border-radius: 6px; cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: var(--panel-2); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

/* ---------- floor map ---------- */
.map { grid-area: map; position: relative; overflow: hidden; }
.map svg { width: 100%; height: 100%; display: block; }
.legend {
  position: absolute; left: 24px; bottom: 16px; display: flex; gap: 16px; align-items: center;
  color: var(--muted); font-size: 13px;
}
.ramp { width: 140px; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, var(--cool), var(--ok), var(--warm), var(--hot), var(--crit)); }
.key-line { display: inline-block; width: 22px; height: 0; border-top: 2px dashed; vertical-align: middle; margin-right: 6px; }

.floor { fill: none; stroke: #1f3150; stroke-width: 1; }
.row-label { fill: var(--muted); font-size: 13px; font-weight: 600; }
.asset-label { fill: #b9c6da; font-size: 12px; font-weight: 600; pointer-events: none;
  paint-order: stroke; stroke: var(--navy); stroke-width: 4px; stroke-linejoin: round; }

.edge { fill: none; stroke-width: 2; stroke-linecap: round; opacity: 0.75; }
.edge.power { stroke: var(--power); stroke-dasharray: 2 7; animation: flow 1.2s linear infinite; }
.edge.water { stroke: var(--water); stroke-dasharray: 6 6; animation: flow 1.6s linear infinite; }
.edge.dead { stroke: #3a4a66; animation: none; opacity: 0.5; }
.edge.broken { stroke: var(--crit); opacity: 1; stroke-width: 3; }

.asset { cursor: pointer; }
.asset .face { transition: fill 0.6s ease; stroke: rgba(10, 18, 32, 0.6); stroke-width: 0.8; }
.asset:hover .top-face, .asset.selected .top-face { stroke: var(--future); stroke-width: 1.6; }
.asset.failed .top-face { stroke: var(--crit); stroke-width: 2; }

.pulse { fill: none; stroke: var(--crit); stroke-width: 2; animation: pulse 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.tamper { fill: none; stroke: #c58bff; stroke-width: 2; stroke-dasharray: 4 3; }
.ripple { fill: none; stroke: var(--crit); stroke-width: 3; transform-box: fill-box; transform-origin: center; animation: ripple 1.4s ease-out forwards; }

/* ---------- side panel ---------- */
.side {
  grid-area: side; border-left: 1px solid var(--line); padding: 20px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
}
.side h2 { margin: 0; font-size: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px; }
.card p { margin: 6px 0 0; color: var(--muted); }
.card.alert { border-color: rgba(217, 45, 85, 0.55); }
.card.alert h2 { color: #ff8aa2; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin-top: 10px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-family: var(--font-num); font-size: 17px; }
.spark { width: 100%; height: 56px; margin-top: 10px; }
.agent-steps { list-style: none; padding: 0; margin: 10px 0 0; }
.agent-steps li { color: var(--muted); padding: 6px 0; border-top: 1px solid var(--line); }

/* ---------- cascade timeline ---------- */
.time { grid-area: time; min-width: 0; border-top: 1px solid var(--line); padding: 14px 24px 18px; }
.time-head { display: flex; align-items: baseline; gap: 12px; }
.time-head h2 { margin: 0; font-size: 16px; }
.time-head span { color: var(--muted); font-size: 13px; }
.track { position: relative; height: 34px; margin: 10px 0 6px; }
.track::before { content: ""; position: absolute; left: 0; right: 0; top: 16px; border-top: 1px solid var(--line); }
.tick { position: absolute; top: 22px; color: var(--muted); font-size: 12px; transform: translateX(-50%); }
.dot {
  position: absolute; top: 10px; width: 13px; height: 13px; border-radius: 50%;
  transform: translateX(-50%); border: 2px solid var(--navy); transition: left 0.8s ease;
}
.chain { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.link {
  flex: 0 0 auto; min-width: 170px; background: var(--panel); border: 1px solid var(--line);
  border-left: 4px solid var(--warm); border-radius: var(--radius-sm); padding: 8px 12px; cursor: pointer;
}
.link .when { font-family: var(--font-num); font-size: 18px; font-weight: 600; }
.link .what { color: var(--muted); font-size: 13px; }
.link.now { border-left-color: var(--crit); }
.link.tamper-link { border-left-color: #c58bff; }
.empty { color: var(--muted); padding: 8px 0; }

/* ---------- motion ---------- */
@keyframes flow { to { stroke-dashoffset: -18; } }
@keyframes blink { 50% { opacity: 0.25; } }
@keyframes pulse { 0% { transform: scale(0.8); opacity: 1; } 100% { transform: scale(1.8); opacity: 0; } }
@keyframes ripple { 0% { transform: scale(0.4); opacity: 1; } 100% { transform: scale(3.2); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before { animation: none !important; transition: none !important; }
}
body.calm *, body.calm *::before { animation: none !important; transition: none !important; }

@media (max-width: 1100px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "top" "map" "time" "side"; height: auto; }
  .map { height: 60vh; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .readouts { gap: 16px; }
}

.asset:focus { outline: none; }
.asset:focus-visible .top-face { stroke: var(--future); stroke-width: 2; }

/* ---------- 3D map ---------- */
.three { position: absolute; inset: 0; }
.three canvas { display: block; cursor: grab; }
.three canvas:active { cursor: grabbing; }
.labels3d { position: absolute; inset: 0; pointer-events: none; }
.label3d {
  color: #c9d6ea; font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 5px;
  background: rgba(15, 26, 44, 0.72); border: 1px solid rgba(127, 159, 208, 0.25); white-space: nowrap;
}
.label3d.row { color: var(--muted); background: none; border: 0; font-size: 14px; }
.view-tools {
  position: absolute; right: 20px; bottom: 16px; display: flex; gap: 12px; align-items: center;
  color: var(--muted); font-size: 13px;
}
.tip {
  position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 6px 10px; font-size: 13px; color: var(--muted);
  box-shadow: 0 10px 24px rgba(3, 8, 18, 0.5);
}
.tip b { display: block; color: var(--text); }
.tip[hidden] { display: none; }
.three[hidden] { display: none; }
.switch { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.switch button { background: var(--panel); border: 0; padding: 8px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.switch button[aria-pressed="true"] { background: #24406a; color: var(--text); }
.view-tools .btn[hidden] { display: none; }
.legend, .view-tools > span {
  background: rgba(15, 26, 44, 0.78); padding: 6px 10px; border-radius: var(--radius-sm);
  backdrop-filter: blur(4px);
}
.link .why { color: #6f819d; font-size: 12px; margin-top: 2px; }
.facts dd.txt { font-family: var(--font); font-size: 15px; }

/* ---------- agent panel ---------- */
.status.contained { background: rgba(127, 227, 240, 0.12); color: var(--future); }
.card.calm { border-color: rgba(127, 227, 240, 0.35); }
.agent-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.badge.nv { background: rgba(118, 185, 0, 0.16); color: #a6dc4a; }
.badge.sc { background: rgba(242, 179, 61, 0.14); color: var(--warm); }
.agent-status { margin-top: 4px; }
.live { color: var(--future); }
.live::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 8px; border-radius: 50%; background: currentColor; animation: blink 0.9s steps(2) infinite; vertical-align: middle; }
.steps { list-style: none; margin: 12px 0 4px; padding: 0 0 0 14px; border-left: 1px solid var(--line); display: grid; gap: 8px; }
.steps li { position: relative; color: var(--muted); font-size: 14px; line-height: 1.35; }
.steps li::before { content: ""; position: absolute; left: -19px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: #46597a; border: 2px solid var(--panel); }
.steps li.k-think::before { background: #a6dc4a; }
.steps li.k-sim::before { background: var(--future); }
.steps li.k-done::before { background: var(--ok); }
.steps li.k-done { color: var(--text); font-weight: 600; }
.steps li.k-note::before { background: var(--warm); }
.steps li.enter { animation: stepIn 0.45s ease-out both; }
@keyframes stepIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

.plan { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); }
.plan.best { border-color: rgba(127, 227, 240, 0.5); }
.plan.chosen { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }
.plan.faded { opacity: 0.45; }
.plan-tag { font-size: 12px; font-weight: 700; color: var(--future); }
.plan.chosen .plan-tag { color: var(--ok); }
.plan h3 { margin: 2px 0 8px; font-size: 17px; }
.plan p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.compare { display: grid; gap: 5px; }
.compare small { color: var(--muted); font-size: 12px; }
.cmp-row { display: grid; grid-template-columns: 78px 1fr 28px; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.cmp-row b { font-family: var(--font-num); font-size: 17px; color: var(--text); text-align: right; }
.bar { height: 8px; border-radius: 4px; background: #0f1a2c; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; transition: width 0.8s ease; }
.bar i.ok { background: var(--ok); }
.bar i.warn { background: var(--warm); }
.bar i.bad { background: var(--crit); opacity: 0.75; }
.plan-btns { display: flex; gap: 8px; margin-top: 12px; }
.btn.approve { background: var(--ok); border-color: var(--ok); color: #06241c; }
.btn.approve:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { margin-top: 12px; padding: 6px 12px; font-size: 13px; }
.ok-note { color: var(--ok) !important; }
.how { margin-top: 14px; }
.how summary { cursor: pointer; color: var(--muted); font-size: 14px; font-weight: 600; }
.how summary:hover { color: var(--text); }
.muted-note { color: var(--muted); font-size: 13px; margin-top: 8px !important; }

/* control room drama: red flash on failure, red edges while racks are at risk */
.brand { text-decoration: none; color: inherit; }
.screen-flash { position: fixed; inset: 0; z-index: 50; pointer-events: none; opacity: 0; }
.screen-flash.go { animation: screenFlash 0.9s ease-out; }
@keyframes screenFlash { 0% { opacity: 0.6; background: radial-gradient(circle at 40% 55%, rgba(255, 60, 80, 0.55), rgba(120, 0, 20, 0.3)); } 100% { opacity: 0; } }
.map::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 140px 30px rgba(217, 45, 85, var(--danger, 0)); transition: box-shadow 0.8s ease;
}
body.calm .screen-flash { display: none; }
a.btn { color: var(--text); text-decoration: none; display: inline-block; }

/* ---------- time scrubber ---------- */
.future-bar {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 12px; flex-wrap: nowrap; justify-content: center; white-space: nowrap;
  background: rgba(21, 35, 58, 0.88); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 10px 14px; backdrop-filter: blur(6px); max-width: calc(100% - 40px);
  transition: opacity 0.3s, border-color 0.4s;
}
.future-bar.off { opacity: 0.55; }
.future-bar.off::after { content: "Break something to preview its future"; color: var(--muted); font-size: 13px; }
.future-bar.off .fut-plans, .future-bar.off .fut-label { display: none; }
.map.future .future-bar { border-color: rgba(127, 227, 240, 0.7); box-shadow: 0 0 30px rgba(127, 227, 240, 0.18); }
.small-btn { padding: 7px 12px; font-size: 14px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
#fut-play { background: rgba(127, 227, 240, 0.14); border-color: rgba(127, 227, 240, 0.5); color: var(--future); }
.fut-track { display: flex; flex-direction: column; width: 230px; }
.fut-ticks { display: flex; justify-content: space-between; color: var(--muted); font-size: 11px; margin-top: 2px; }
.fut-label { font-family: var(--font-num); font-size: 18px; font-weight: 600; min-width: 112px; color: var(--future); }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--future), #24406a); outline-offset: 6px; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--future); box-shadow: 0 0 12px var(--future); cursor: grab; border: 2px solid var(--navy); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--future); border: 2px solid var(--navy); }
input[type="range"]:disabled::-webkit-slider-thumb { background: #46597a; box-shadow: none; }
.fut-plans { display: flex; gap: 6px; }
.fut-plans button {
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px;
  font-size: 13px; color: var(--muted); cursor: pointer; font-weight: 600;
}
.fut-plans button[aria-pressed="true"] { background: rgba(127, 227, 240, 0.16); border-color: var(--future); color: var(--text); }
.fut-plans button[data-plan=""][aria-pressed="true"] { background: rgba(217, 45, 85, 0.18); border-color: var(--crit); }
#fut-back[hidden] { display: none; }

.fut-badge {
  position: absolute; left: 24px; bottom: 64px; z-index: 6; pointer-events: none; display: none;
  background: rgba(15, 26, 44, 0.86); border: 1px solid rgba(127, 227, 240, 0.6); border-radius: var(--radius-sm);
  padding: 8px 12px; color: var(--future); font-size: 14px; font-weight: 600; max-width: 340px;
}
.fut-badge span { display: block; font-size: 13px; color: var(--future); }
.fut-badge b { display: block; font-family: var(--font-num); font-size: 30px; line-height: 1.1; color: var(--text); }
.map.future .fut-badge { display: block; }
.map.future::before {   /* the future gets a cyan frame and faint scanlines so it never looks like the present */
  content: ""; position: absolute; inset: 0; z-index: 5; pointer-events: none;
  box-shadow: inset 0 0 0 2px rgba(127, 227, 240, 0.55), inset 0 0 120px rgba(127, 227, 240, 0.16);
  background: repeating-linear-gradient(0deg, rgba(127, 227, 240, 0.035) 0 1px, transparent 1px 4px);
}
@media (max-width: 1250px) { .future-bar { flex-wrap: wrap; white-space: normal; } .fut-track { width: 180px; } }

/* ---------- shift handoff ---------- */
.neutral-note { color: var(--muted); }
#handoff-btn { margin-left: 4px; }
.handoff {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px;
  background: rgba(8, 14, 26, 0.72); backdrop-filter: blur(8px); animation: fadeIn 0.3s ease;
}
.handoff[hidden] { display: none; }
.ho-panel {
  width: min(1100px, 100%); max-height: 92vh; overflow: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 18px; padding: 26px 28px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}
.ho-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.ho-top h2 { margin: 0; font-family: var(--font-num); font-size: 38px; }
.ho-top p { margin: 4px 0 0; color: var(--muted); max-width: 60ch; }
.ho-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; margin-top: 22px; }
.ho-head { display: flex; justify-content: space-between; align-items: center; }
.ho-panel h3 { margin: 18px 0 8px; font-size: 15px; color: var(--muted); font-weight: 600; }
.ho-head h3 { margin: 0; }
.ho-timeline { list-style: none; margin: 16px 0 0; padding: 0 0 0 22px; position: relative; display: grid; gap: 14px; }
.ho-timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.ho-timeline li { position: relative; display: grid; grid-template-columns: 54px 1fr; gap: 10px; opacity: 0; transform: translateY(8px); transition: opacity 0.45s ease, transform 0.45s ease; }
.ho-timeline li.shown { opacity: 1; transform: none; }
.ho-timeline li::before { content: ""; position: absolute; left: -22px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: #46597a; border: 2px solid var(--panel); }
.ho-timeline li.k-failure::before { background: var(--crit); box-shadow: 0 0 10px var(--crit); }
.ho-timeline li.k-agent::before { background: #a6dc4a; }
.ho-timeline li.k-action::before { background: var(--ok); box-shadow: 0 0 10px var(--ok); }
.ho-timeline time { font-family: var(--font-num); font-size: 17px; color: var(--muted); }
.ho-timeline li.k-failure span { color: #ff9cb0; }
.ho-brief ul { margin: 0; padding-left: 18px; color: var(--text); display: grid; gap: 4px; }
.ho-status { border-radius: 12px; padding: 14px 16px; display: grid; gap: 2px; }
.ho-status b { font-family: var(--font-num); font-size: 24px; }
.ho-status.stable { background: rgba(60, 195, 160, 0.12); color: var(--ok); }
.ho-status.risk { background: rgba(217, 45, 85, 0.14); color: #ff8aa2; }
.ho-status span { color: var(--text); }
.ho-ack { margin-top: 22px; display: grid; gap: 6px; }
.ho-ack label { color: var(--muted); font-size: 14px; font-weight: 600; }
.ho-ack-row { display: flex; gap: 8px; }
.ho-ack input {
  flex: 1; min-width: 0; background: var(--navy); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 12px; color: var(--text); font: inherit;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@media (max-width: 900px) { .ho-grid { grid-template-columns: 1fr; } }

/* =====================================================================
   Instrument-panel skin: cut corners, hairline frames, condensed readouts
   ===================================================================== */
:root { --cut: 14px; --hair: #2c4366; --panel-hi: #192a45; }

/* cut-corner panel: the frame is the outer layer, the fill sits 1px inside */
.chamfer {
  position: relative; border: 0 !important; background: var(--hair) !important; border-radius: 0 !important;
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.chamfer::before {
  content: ""; position: absolute; inset: 1px; z-index: 0; background: var(--fill, var(--panel));
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, var(--cut) 100%, 0 calc(100% - var(--cut)));
}
.chamfer > * { position: relative; z-index: 1; }
.chamfer::after { /* corner tick on the cut edge */
  content: ""; position: absolute; z-index: 2; top: 3px; right: 3px; width: calc(var(--cut) - 4px); height: 2px;
  background: var(--accent, #4b6a9b); transform-origin: right; transform: rotate(45deg) translate(1px, 0); opacity: 0.9;
}

/* side panel */
.side { background: linear-gradient(180deg, #111d31, #0f1a2c); gap: 14px; }
.card.chamfer { padding: 18px 18px 16px; --fill: linear-gradient(160deg, #182a46 0%, #13223a 60%); }
.card h2 { font-size: 19px; letter-spacing: 0.005em; }

/* incident card: instrument readouts */
.card.incident { --hair: rgba(217, 45, 85, 0.75); --accent: var(--crit); --fill: linear-gradient(160deg, #2a1830 0%, #17213a 70%); }
.card.incident.calm { --hair: rgba(127, 227, 240, 0.55); --accent: var(--future); --fill: linear-gradient(160deg, #15303f 0%, #13223a 70%); }
.inc-head { display: flex; align-items: center; gap: 10px; }
.inc-head h2 { margin: 0; color: #ffd2db; }
.card.incident.calm .inc-head h2 { color: var(--text); }
.inc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--crit); box-shadow: 0 0 0 4px rgba(217, 45, 85, 0.2), 0 0 14px var(--crit); animation: blink 1.1s steps(2) infinite; flex: none; }
.card.incident.calm .inc-dot { background: var(--future); box-shadow: 0 0 0 4px rgba(127, 227, 240, 0.15); animation: none; }
.inc-sub { margin: 4px 0 0 20px !important; font-size: 14px; }
.readouts2 { display: grid; grid-template-columns: auto 1fr; gap: 0; margin-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.readouts2 > div { padding: 12px 16px 2px 0; display: grid; align-content: start; }
.readouts2 > div + div { padding-left: 16px; border-left: 1px solid rgba(255, 255, 255, 0.08); }
.readouts2 b { font-family: var(--font-num); font-size: 44px; line-height: 0.95; font-weight: 600; }
.readouts2 b.hot { color: #ff6b81; text-shadow: 0 0 24px rgba(255, 60, 90, 0.45); }
.readouts2 b small { font-size: 18px; color: var(--muted); font-weight: 500; }
.readouts2 span { color: var(--muted); font-size: 13px; line-height: 1.3; margin-top: 4px; }

/* agent card */
.card.agent { --accent: #76b900; }
.steps li { font-size: 13.5px; }

/* decision cards */
.plan.chamfer { --cut: 12px; --fill: #142339; --hair: #2a3f60; margin-top: 12px; padding: 14px 16px 14px; }
.plan.best { --hair: rgba(127, 227, 240, 0.65); --accent: var(--future); --fill: linear-gradient(150deg, #173149 0%, #142339 70%); }
.plan.chosen { --hair: var(--ok); --accent: var(--ok); --fill: linear-gradient(150deg, #133a35 0%, #142339 70%); box-shadow: none; }
.plan.faded { opacity: 0.5; }
.plan-top { display: flex; align-items: center; gap: 10px; }
.plan-rank { font-family: var(--font-num); font-size: 15px; font-weight: 700; color: var(--muted); border: 1px solid #34507a; padding: 0 6px; line-height: 20px; }
.plan.best .plan-rank, .plan.chosen .plan-rank { color: var(--navy); background: var(--accent); border-color: var(--accent); }
.plan-tag { font-size: 13px; font-weight: 700; color: var(--muted); }
.plan.best .plan-tag { color: var(--future); }
.plan.chosen .plan-tag { color: var(--ok); }
.plan h3 { margin: 8px 0 10px; font-size: 18px; line-height: 1.25; }
.delta { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; padding: 10px 0; border-top: 1px solid rgba(255, 255, 255, 0.07); border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
.delta-nums { display: flex; align-items: center; gap: 10px; font-family: var(--font-num); font-weight: 600; line-height: 1; }
.d-from { font-size: 30px; color: #ff6b81; text-decoration: line-through; text-decoration-thickness: 2px; text-decoration-color: rgba(255, 107, 129, 0.6); }
.d-arrow { width: 22px; height: 2px; background: var(--muted); position: relative; }
.d-arrow::after { content: ""; position: absolute; right: -1px; top: -4px; border: 5px solid transparent; border-left: 7px solid var(--muted); border-right: 0; }
.d-to { font-size: 44px; }
.d-to.ok { color: var(--ok); text-shadow: 0 0 22px rgba(60, 195, 160, 0.45); }
.d-to.warn { color: var(--warm); }
.delta-lbl { font-size: 13px; color: var(--text); line-height: 1.35; }
.delta-lbl span { color: var(--muted); }
.plan p { font-size: 13.5px; line-height: 1.45; }
.plan-btns { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.btn.cut {
  border: 0; border-radius: 0; padding: 10px 18px 10px 16px; font-weight: 700;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 0 100%);
}
.btn.approve.cut { background: linear-gradient(180deg, #4fd9b4, #34b893); color: #052b22; box-shadow: none; }
.btn.approve.cut:hover { filter: brightness(1.08); }
.btn.link-btn { background: none; border: 0; padding: 6px 2px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.btn.link-btn:hover { color: var(--text); }

/* ---------- "What fails next" timeline ---------- */
.time { padding: 12px 24px 14px; background: linear-gradient(180deg, #0f1a2c, #0d1727); }
.tl { display: grid; grid-template-columns: 270px 1fr; gap: 22px; margin-top: 10px; min-height: 128px; }
.tl-now { --cut: 12px; --fill: #131f34; --hair: #2a3f60; padding: 12px 14px; }
.tl-now.hot {
  --hair: rgba(217, 45, 85, 0.8); --accent: var(--crit);
  --fill: repeating-linear-gradient(135deg, rgba(217, 45, 85, 0.10) 0 10px, rgba(217, 45, 85, 0.03) 10px 20px), #1c1a30;
}
.tl-now-head { display: flex; align-items: baseline; justify-content: space-between; }
.tl-now-head b { font-family: var(--font-num); font-size: 26px; line-height: 1; color: #ff6b81; }
.tl-now-head.calm b { color: var(--ok); }
.tl-now-head span { color: var(--muted); font-size: 13px; }
.tl-now ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.tl-now li { font-size: 13px; color: #f3d3da; cursor: pointer; padding-left: 12px; position: relative; line-height: 1.3; }
.tl-now li::before { content: ""; position: absolute; left: 0; top: 6px; width: 5px; height: 5px; background: var(--crit); }
.tl-now li.tam { color: #e3cdfd; }
.tl-now li.tam::before { background: #c58bff; }
.tl-now li:hover { color: #fff; }
.tl-now p { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.tl-more { color: var(--muted); font-size: 12px; margin-top: 4px; }

.tl-track { position: relative; min-height: 128px; }
.tl-axis { position: absolute; left: 0; right: 0; top: 50%; height: 2px; background: linear-gradient(90deg, var(--crit), #f2b33d 25%, #2a3f60 60%); }
.tl-tick { position: absolute; top: 8px; transform: translateX(-50%); color: var(--muted); font-size: 11px; font-family: var(--font-num); }
.tl-tick::before { content: ""; position: absolute; left: 50%; top: -12px; width: 1px; height: 8px; background: #46597a; }
.tl-tick:first-child { transform: none; }
.tl-tick:last-child { transform: translateX(-100%); }
.tl-pin { position: absolute; top: 50%; background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; }
.tl-stem { position: absolute; left: 0; width: 1px; height: 22px; background: var(--warm); }
.tl-pin::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; background: var(--warm); transform: rotate(45deg); box-shadow: 0 0 10px rgba(242, 179, 61, 0.7); }
.tl-pin.high .tl-stem { bottom: 4px; }
.tl-pin.low .tl-stem { top: 4px; }
.tl-tag { --cut: 8px; --fill: #18263f; --hair: rgba(242, 179, 61, 0.55); --accent: var(--warm); position: absolute; left: -2px; display: grid; padding: 5px 12px 6px 9px; min-width: 150px; max-width: 220px; text-align: left; }
.tl-pin.high .tl-tag { bottom: 24px; }
.tl-pin.low .tl-tag { top: 24px; }
.tl-pin:nth-last-of-type(-n+2) .tl-tag { left: auto; right: -2px; }
.tl-tag b { font-family: var(--font-num); font-size: 19px; line-height: 1; color: var(--warm); }
.tl-tag > span { font-size: 12px; color: var(--text); line-height: 1.25; margin-top: 2px; }
.tl-tag em { font-style: normal; color: var(--muted); }
.tl-pin:hover .tl-tag, .tl-pin:focus-visible .tl-tag { --hair: var(--warm); --fill: #1e2f4d; }
.tl-empty { position: absolute; left: 0; top: calc(50% + 14px); color: var(--muted); font-size: 13px; }

/* top bar polish: a hairline glow under the header */
.top { position: relative; background: linear-gradient(180deg, #111e33, #0f1a2c); }
.top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: linear-gradient(90deg, transparent, rgba(127, 227, 240, 0.45), transparent); }
.btn { border-radius: 4px; }
.status { border-radius: 4px; }
.future-bar, .fut-badge { border-radius: 4px; }

@media (max-width: 1100px) { .tl { grid-template-columns: 1fr; } }
.tl { min-height: 150px; }
.tl-track { min-height: 150px; }
.tl-tag { width: 178px; min-width: 0; max-width: none; }
.tl-pin:nth-last-of-type(-n+2) .tl-tag { left: auto; right: auto; }
.tl-pin.high .tl-stem { bottom: 4px; height: 18px; }
.tl-pin.low .tl-stem { top: 4px; height: 18px; }
.tl-pin.high .tl-tag { bottom: 20px; }
.tl-pin.low .tl-tag { top: 20px; }
.tl-tick { top: calc(50% + 8px); }
.tl-tick::before { top: -8px; height: 6px; }
.time-head { position: relative; z-index: 2; }

/* =====================================================================
   NEON PALETTE: deeper ink, electric accents, higher contrast
   ===================================================================== */
:root {
  --navy: #060b16;
  --panel: #0c1526;
  --panel-2: #111d33;
  --line: #1f3252;
  --hair: #24406b;
  --text: #f2f7ff;
  --muted: #8c9dbb;
  --cool: #1fb6ff;
  --ok: #19f5b0;
  --warm: #ffb21e;
  --hot: #ff6a2b;
  --crit: #ff2e63;
  --future: #22e9ff;
  --power: #ffb21e;
  --water: #2f9bff;
}
html, body { background: radial-gradient(1200px 700px at 35% 30%, #0b1630 0%, #060b16 60%) fixed; }
.top { background: linear-gradient(180deg, #0a1324, #060b16); }
.top::after { background: linear-gradient(90deg, transparent, var(--future), transparent); opacity: 0.6; }
.side { background: linear-gradient(180deg, #08101f, #060b16); border-left-color: #16243d; }
.time { background: linear-gradient(180deg, #070d1a, #060b16); border-top-color: #16243d; }
.brand-name { letter-spacing: 0.01em; text-shadow: 0 0 18px rgba(34, 233, 255, 0.25); }

/* status pill + readouts glow */
.status { background: rgba(25, 245, 176, 0.1); color: var(--ok); box-shadow: inset 0 0 0 1px rgba(25, 245, 176, 0.35); }
.status.incident { background: rgba(255, 46, 99, 0.14); color: #ff5c86; box-shadow: inset 0 0 0 1px rgba(255, 46, 99, 0.6), 0 0 22px rgba(255, 46, 99, 0.25); }
.status.contained { box-shadow: inset 0 0 0 1px rgba(34, 233, 255, 0.5); }
.readout.risk .num { color: var(--warm); text-shadow: 0 0 18px rgba(255, 178, 30, 0.5); }
.readout .num { text-shadow: 0 0 14px rgba(242, 247, 255, 0.12); }

/* buttons */
.btn { background: #0f1b31; border-color: #24406b; }
.btn:hover { border-color: var(--future); box-shadow: 0 0 14px rgba(34, 233, 255, 0.25); }
#fut-play { background: rgba(34, 233, 255, 0.12); border-color: var(--future); color: var(--future); box-shadow: 0 0 16px rgba(34, 233, 255, 0.2); }
.btn.approve.cut { background: linear-gradient(180deg, #4dffd0, #12d99a); color: #022419; box-shadow: 0 0 24px rgba(25, 245, 176, 0.35); }
.btn.cta { background: var(--future); border-color: var(--future); color: #021c22; box-shadow: 0 0 40px rgba(34, 233, 255, 0.5); }

/* cards */
.card.chamfer { --fill: linear-gradient(160deg, #0f1c33 0%, #0a1426 70%); --hair: #22395e; }
.card.incident { --hair: var(--crit); --fill: linear-gradient(160deg, #2a0f24 0%, #0d1528 75%); filter: drop-shadow(0 0 14px rgba(255, 46, 99, 0.28)); }
.card.incident.calm { --hair: var(--future); --fill: linear-gradient(160deg, #082a36 0%, #0d1528 75%); filter: drop-shadow(0 0 12px rgba(34, 233, 255, 0.2)); }
.inc-head h2 { color: #ff8fab; }
.readouts2 b.hot { color: var(--crit); text-shadow: 0 0 26px rgba(255, 46, 99, 0.7); }
.plan.chamfer { --fill: #0d182c; --hair: #213656; }
.plan.best { --hair: var(--future); --fill: linear-gradient(150deg, #072b3a 0%, #0d182c 70%); filter: drop-shadow(0 0 12px rgba(34, 233, 255, 0.22)); }
.plan.chosen { --hair: var(--ok); --fill: linear-gradient(150deg, #063326 0%, #0d182c 70%); filter: drop-shadow(0 0 12px rgba(25, 245, 176, 0.25)); }
.d-from { color: var(--crit); text-decoration-color: rgba(255, 46, 99, 0.7); }
.d-to.ok { color: var(--ok); text-shadow: 0 0 26px rgba(25, 245, 176, 0.65); }
.badge.nv { background: rgba(118, 185, 0, 0.18); color: #b6ff3c; box-shadow: inset 0 0 0 1px rgba(182, 255, 60, 0.4); }
.badge.sc { background: rgba(255, 178, 30, 0.14); color: var(--warm); box-shadow: inset 0 0 0 1px rgba(255, 178, 30, 0.4); }

/* timeline */
.tl-now { --fill: #0b1426; }
.tl-now.hot { --hair: var(--crit); --fill: repeating-linear-gradient(135deg, rgba(255, 46, 99, 0.16) 0 10px, rgba(255, 46, 99, 0.04) 10px 20px), #160b1f; filter: drop-shadow(0 0 14px rgba(255, 46, 99, 0.3)); }
.tl-now-head b { color: var(--crit); text-shadow: 0 0 18px rgba(255, 46, 99, 0.6); }
.tl-axis { background: linear-gradient(90deg, var(--crit), var(--warm) 25%, #1f3252 60%); box-shadow: 0 0 10px rgba(255, 178, 30, 0.3); }
.tl-pin::before { background: var(--warm); box-shadow: 0 0 14px var(--warm); }
.tl-tag { --fill: #0e1a30; --hair: rgba(255, 178, 30, 0.7); }
.tl-tag b { color: var(--warm); text-shadow: 0 0 12px rgba(255, 178, 30, 0.45); }

/* legend + floating bars */
.legend, .view-tools > span, .future-bar, .fut-badge { background: rgba(6, 11, 22, 0.82); }
.ramp { background: linear-gradient(90deg, #1fb6ff, #19f5b0, #ffb21e, #ff6a2b, #ff2e63); box-shadow: 0 0 12px rgba(255, 178, 30, 0.25); }
.fut-badge { border-color: var(--future); box-shadow: 0 0 22px rgba(34, 233, 255, 0.25); }
.map.future::before { box-shadow: inset 0 0 0 2px rgba(34, 233, 255, 0.75), inset 0 0 140px rgba(34, 233, 255, 0.2); }
.label3d { background: rgba(6, 11, 22, 0.8); border-color: rgba(34, 233, 255, 0.28); }

/* handoff */
.ho-panel { background: linear-gradient(160deg, #0f1c33, #08101f); border-color: #24406b; box-shadow: 0 0 60px rgba(34, 233, 255, 0.12), 0 30px 80px rgba(0, 0, 0, 0.6); }
.ho-status.stable { background: rgba(25, 245, 176, 0.12); }
.ho-status.risk { background: rgba(255, 46, 99, 0.16); }

/* ---------- clearer plan comparison ---------- */
.delta2 { display: grid; grid-template-columns: auto auto auto 1fr; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid rgba(255,255,255,.07); border-bottom: 1px solid rgba(255,255,255,.07); }
.delta2.flat { grid-template-columns: auto 1fr; }
.dcol { display: grid; justify-items: center; line-height: 1; }
.dnum { font-family: var(--font-num); font-weight: 600; font-size: 42px; }
.dnum.from { color: var(--crit); font-size: 30px; opacity: .9; }
.dnum.ok { color: var(--ok); text-shadow: 0 0 24px rgba(25,245,176,.6); }
.dnum.warn { color: var(--warm); }
.dlbl { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.delta2 .d-arrow { margin-bottom: 14px; }
.dcap { font-size: 12.5px; color: var(--muted); line-height: 1.35; padding-left: 4px; }

/* ---------- head-start race ---------- */
.race { margin-top: 12px; padding: 10px 12px; background: rgba(6, 11, 22, .55); border: 1px solid rgba(255,255,255,.06); display: grid; gap: 6px; }
.race-row { display: grid; grid-template-columns: 66px 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; }
.race-row .who { font-weight: 700; }
.race-row.fz .who { color: var(--future); }
.race-row.al .who { color: var(--muted); }
.lane { height: 6px; background: #121f36; position: relative; overflow: hidden; }
.lane i { display: block; height: 100%; transition: width 1s ease; }
.race-row.fz .lane i { background: linear-gradient(90deg, var(--future), #6ff3ff); box-shadow: 0 0 10px var(--future); }
.race-row.al .lane i { background: repeating-linear-gradient(90deg, #4b5d7e 0 6px, transparent 6px 10px); }
.race.fired .race-row.al .lane i { background: var(--crit); box-shadow: 0 0 10px var(--crit); }
.race.beat .race-row.al .lane i, .race.blind .race-row.al .lane i { background: repeating-linear-gradient(90deg, #2b3954 0 4px, transparent 4px 10px); }
.race-row .when { color: var(--muted); white-space: nowrap; }
.race.fired .race-row.al .when { color: #ff6b81; }
.race-verdict { font-size: 13px; color: var(--text); }
.race-verdict b { font-family: var(--font-num); font-size: 18px; color: var(--future); }
.race.blind .race-verdict { color: #e3cdfd; }
#voice-btn[aria-pressed="false"] { color: var(--muted); }

/* timeline: keep the empty note clear of the axis labels */
.tl-empty { top: auto; bottom: calc(50% + 12px); }

/* ---------- judge QR ---------- */
.judge-btn { border-color: var(--future) !important; color: var(--future); box-shadow: 0 0 16px rgba(34, 233, 255, .2); }
.qr-modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(4, 8, 16, .78); backdrop-filter: blur(8px); animation: fadeIn .25s ease; }
.qr-modal[hidden] { display: none; }
.qr-panel { --cut: 22px; --hair: var(--future); --accent: var(--future); --fill: linear-gradient(160deg, #0b2233, #08101f 70%); padding: 30px 34px 26px; text-align: center; width: min(460px, 92vw); filter: drop-shadow(0 0 30px rgba(34, 233, 255, .25)); }
.qr-panel h2 { margin: 0 0 6px; font-family: var(--font-num); font-size: 38px; }
.qr-panel p { margin: 0 0 18px; color: var(--muted); }
.qr-code { background: #fff; padding: 14px; width: 280px; height: 280px; margin: 0 auto; display: grid; place-items: center; }
.qr-code svg { width: 100%; height: 100%; }
.qr-url { margin-top: 14px; font-family: var(--font-num); font-size: 22px; color: var(--future); text-shadow: 0 0 12px rgba(34, 233, 255, .4); word-break: break-all; }
.qr-warn { margin: 12px 0 0 !important; color: var(--warm) !important; font-size: 13px; }
.qr-close { position: absolute; top: 14px; right: 14px; }
@media (max-width: 1250px) { .judge-btn { display: none; } }
.top { gap: 18px; padding: 12px 20px; }
.top > *, .top .readout .lbl, .status, .facility, .btn { white-space: nowrap; }
.readouts { gap: 20px; }
.readout .num { font-size: 24px; }
@media (max-width: 1400px) { .facility { display: none; } }
@media (max-width: 1250px) { .judge-btn { display: inline-block; } .readout:nth-child(2) { display: none; } }

/* illustrative $ at risk (business/impact.py) */
.money { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 8px 0 2px; font-family: var(--font-num); }
.money .m-from { color: var(--crit); font-size: 15px; font-weight: 600; text-decoration: line-through; text-decoration-color: rgba(255,46,99,.5); }
.money .m-arrow { color: var(--muted); }
.money .m-to { font-size: 19px; font-weight: 700; }
.money .m-to.ok { color: var(--ok); text-shadow: 0 0 18px rgba(25,245,176,.45); }
.money .m-to.warn { color: var(--warm); }
.money .m-lbl { font-family: inherit; font-size: 11.5px; color: var(--muted); }
.money .m-lbl b { color: var(--ok); font-weight: 600; }

/* work order from business/dispatch.py */
.wo { margin-top: 10px; padding: 10px 12px; background: rgba(34,233,255,.05); border: 1px solid rgba(34,233,255,.25); }
.wo-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.wo-id { font-family: var(--font-num); font-weight: 700; color: var(--future); letter-spacing: .04em; }
.wo-status { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.wo-status.ok { color: var(--ok); } .wo-status.warn { color: var(--warm); }
.wo-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 2px 0; color: var(--muted); }
.wo-row b { color: #e6eefc; font-weight: 600; text-align: right; }
