:root {
  color-scheme: dark;
  --ink: #f1f8f7;
  --muted: #9eb8b9;
  --surface: #061315;
  --surface-2: #0a2021;
  --line: #24494b;
  --cyan: #61e6df;
  --cyan-soft: #2aa9a5;
  --amber: #ffb84a;
  --red: #ff7167;
  --shadow: rgba(0, 0, 0, 0.36);
  font-family: "Segoe UI", Arial, sans-serif;
  background: #030c0e;
  color: var(--ink);
}

* { box-sizing: border-box; }
html { background: #030c0e; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 60% 18%, #0b2627 0, #030c0e 38rem); }
button, a { font: inherit; }
a { color: inherit; }

.topbar {
  min-height: 68px;
  padding: 0 4vw;
  display: flex;
  align-items: center;
  gap: 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 12, 14, 0.9);
}
.brand { font-size: 1.3rem; font-weight: 850; letter-spacing: 0.12em; text-decoration: none; }
.mode, .connection, .eyebrow, .run-meta { font: 700 0.72rem/1.2 ui-monospace, "Cascadia Mono", monospace; letter-spacing: 0.12em; text-transform: uppercase; }
.mode { display: flex; align-items: center; gap: 9px; color: var(--cyan); }
.mode span { width: 8px; height: 8px; background: var(--cyan); transform: rotate(45deg); }
.connection { margin-left: auto; color: var(--muted); }
.connection.ready { color: var(--cyan); }
.connection.stale { color: var(--amber); }

main { width: min(1600px, 94vw); margin: 0 auto; padding: clamp(28px, 4vw, 58px) 0; }
.eyebrow { margin: 0 0 12px; color: var(--cyan); }
h2, p { margin-top: 0; }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(310px, 390px); border: 1px solid var(--line); box-shadow: 0 28px 90px var(--shadow); }
.map-panel { position: relative; min-width: 0; padding: clamp(18px, 2.4vw, 36px); background: rgba(6, 19, 21, 0.88); }
.panel-heading, .rail-heading, .run-meta { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.panel-heading h2 { margin-bottom: 0; font-size: clamp(1.5rem, 2.5vw, 2.35rem); }
.run-meta { color: var(--muted); text-align: right; flex-direction: column; gap: 6px; }
.mission-summary { display: flex; flex-wrap: wrap; gap: 14px 28px; margin-top: 20px; padding: 14px; border: 1px solid var(--line); background: var(--surface-2); }
.mission-summary > div { display: flex; flex-direction: column; gap: 6px; min-width: 0; overflow-wrap: anywhere; }
.mission-summary .eyebrow { margin: 0; }
.mission-summary span:not(.eyebrow) { color: var(--muted); font-size: .85rem; }
.symbol-selector { display: flex; width: fit-content; margin: 18px 0 0; padding: 0; border: 1px solid var(--line); color: var(--muted); }
.symbol-selector legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.symbol-selector label { position: relative; cursor: pointer; }
.symbol-selector label + label { border-left: 1px solid var(--line); }
.symbol-selector input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.symbol-selector span { display: block; padding: 7px 10px; font: 700 .68rem ui-monospace, monospace; letter-spacing: .06em; text-transform: uppercase; }
.symbol-selector input:checked + span { color: var(--ink); background: var(--surface-2); box-shadow: inset 0 -2px var(--cyan); }
.symbol-selector input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }

.map { display: none; width: 100%; height: auto; margin-top: 20px; color: var(--cyan-soft); border: 1px solid var(--line); background: #041012; }
.viewer-ready .map-fallback { display: block; }
.viewer-ready .static-fallback { display: none; }
.map-frame { display: none; position: relative; margin-top: 20px; border: 1px solid var(--line); background: #071416; }
.map-initializing .map-frame { display: block; position: absolute; left: clamp(18px, 2.4vw, 36px); right: clamp(18px, 2.4vw, 36px); visibility: hidden; pointer-events: none; }
.operational-map-ready .map-frame { display: block; }
.operational-map-ready .map-fallback { display: none; }
.interactive-map { width: 100%; height: clamp(430px, 62vh, 720px); }
.interactive-map .maplibregl-canvas { outline: none; }
.interactive-map .maplibregl-ctrl-group { border: 1px solid var(--line); border-radius: 0; background: #071719; box-shadow: 0 3px 16px rgba(0,0,0,.4); }
.interactive-map .maplibregl-ctrl-group button { filter: invert(1) hue-rotate(125deg); }
.interactive-map .maplibregl-ctrl-scale { border-color: var(--ink); color: var(--ink); background: rgba(3,12,14,.82); font: 700 .72rem ui-monospace, monospace; }
.interactive-map .maplibregl-ctrl-attrib { color: var(--muted); background: rgba(3,12,14,.86); }
.interactive-map .maplibregl-ctrl-attrib a { color: var(--ink); }
.coordinate-readout { position: absolute; z-index: 2; left: 10px; top: 10px; padding: 7px 9px; border: 1px solid var(--line); color: var(--ink); background: rgba(3,12,14,.86); font: 700 .7rem ui-monospace, monospace; letter-spacing: .08em; pointer-events: none; }
.map-node { display: grid; grid-template-columns: auto auto; align-items: center; gap: 5px 7px; min-width: 34px; min-height: 34px; padding: 5px 7px; border: 2px solid var(--cyan); border-radius: 2px; color: var(--ink); background: rgba(3,12,14,.92); box-shadow: 0 3px 13px rgba(0,0,0,.58); cursor: pointer; }
.map-node::before { content: ""; width: 9px; height: 9px; border: 2px solid currentColor; transform: rotate(45deg); }
.map-node.command-cell::before { display: none; }
.command-cell-symbol { width: 21px; height: 21px; overflow: visible; color: currentColor; }
.command-cell-symbol .symbol-primary { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; }
.command-cell-symbol .symbol-accent { fill: none; stroke: var(--cyan); stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter; }
.command-cell-symbol .symbol-filled { fill: currentColor; }
.command-cell-symbol .symbol-accent.symbol-filled { fill: var(--cyan); }
.map-node strong { grid-column: 1 / -1; font: 750 .67rem ui-monospace, monospace; white-space: nowrap; }
.map-node small { color: var(--muted); font: 700 .62rem ui-monospace, monospace; }
.interactive-map[data-marker-detail="overview"] .map-node:not(.selected):not(.payload-current) strong { display: none; }
.map-node.estimated { border-color: var(--amber); }
.map-node.degraded { color: var(--amber); }
.map-node.offline { border-color: var(--red); color: var(--red); opacity: .72; }
.map-node.payload-current, .map-node.selected { border-color: #d8ff75; box-shadow: 0 0 0 3px rgba(216,255,117,.2), 0 3px 13px rgba(0,0,0,.58); }
.map-node:hover, .map-node:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.map-interferer { display: grid; justify-items: center; min-width: 44px; padding: 5px 7px; border: 2px solid var(--red); color: var(--red); background: rgba(22,5,5,.92); font: 750 .62rem ui-monospace, monospace; letter-spacing: .08em; }
.map-interferer::before { content: ""; width: 14px; height: 14px; border: 3px double currentColor; transform: rotate(45deg); }
.map-interferer small { color: currentColor; }
.map-interferer.scheduled, .map-interferer.complete { opacity: .52; }
.map-place { padding: 3px 5px; color: #b8c6b5; background: rgba(5,16,17,.72); font: 700 .62rem ui-monospace, monospace; letter-spacing: .06em; white-space: nowrap; pointer-events: none; }
.map-place.infrastructure { color: #d9c890; border-left: 3px solid #d9c890; }
.map-base { fill: #041012; }
.map-grid { color: #235052; }
.terrain path { fill: none; stroke: #1d484a; stroke-width: 2; }
.zones path { fill: rgba(255, 184, 74, 0.035); stroke: #6a5a37; stroke-width: 1.5; stroke-dasharray: 8 9; }
.zones text { fill: #7e765d; font: 600 14px ui-monospace, monospace; letter-spacing: 0.16em; }
.fallback-feature { vector-effect: non-scaling-stroke; }
.fallback-feature.land { fill: #0b1a1a; stroke: #365451; stroke-width: 1; }
.fallback-feature.upland { fill: #26322f; stroke: #48544c; stroke-width: 1.2; }
.fallback-feature.water { fill: rgba(45, 113, 137, 0.52); stroke: #3f8da6; stroke-width: 4; }
.fallback-feature.contour { fill: none; stroke: #596253; stroke-width: 1; opacity: 0.65; }
.fallback-feature.road-primary { fill: none; stroke: #c8aa75; stroke-width: 5; }
.fallback-feature.road-secondary { fill: none; stroke: #7d725a; stroke-width: 2.5; stroke-dasharray: 7 5; }
.fallback-feature.boundary { fill: none; stroke: #aa9152; stroke-width: 2; stroke-dasharray: 8 7; }
g.fallback-feature circle { fill: #e7d39a; stroke: #031011; stroke-width: 2; }
g.fallback-feature text { fill: #ddd3b4; font: 600 13px ui-monospace, monospace; paint-order: stroke; stroke: #071313; stroke-width: 5px; }
.fallback-scale path { fill: none; stroke: #e9f4ee; stroke-width: 2; }
.fallback-scale text { fill: #e9f4ee; font: 600 13px ui-monospace, monospace; }
.fallback-map-attribution { margin: -2rem 1rem .75rem auto; width: fit-content; max-width: calc(100% - 2rem); position: relative; z-index: 1; padding: .3rem .45rem; color: var(--muted); background: rgba(3,12,14,.86); font-size: .68rem; }
.uncertainty { fill: rgba(255, 184, 74, 0.08); stroke: var(--amber); stroke-width: 2; stroke-dasharray: 6 6; }
.network-link { fill: none; stroke: var(--cyan); stroke-width: 4; opacity: 0.76; filter: url(#glow); }
.network-link.degraded { stroke: var(--amber); stroke-dasharray: 12 10; opacity: 0.9; }
.network-link.payload-pending { opacity: 0.28; filter: none; }
.network-link.payload-traversed { stroke: #d8ff75; stroke-width: 6; opacity: 0.92; }
.network-link.payload-current { stroke: #fff; stroke-width: 8; stroke-dasharray: 10 8; opacity: 1; }
.node.payload-current .focus-ring { stroke: #d8ff75; stroke-width: 4; opacity: 1; }
.node { cursor: pointer; outline: none; }
.node .hit { fill: transparent; }
.node .mark { fill: #071719; stroke: var(--ink); stroke-width: 4; }
.node.direct .mark { stroke: var(--cyan); }
.node.estimated .mark { stroke: var(--amber); }
.node.degraded .mark { fill: #302315; }
.node .command-cell-mark { color: var(--ink); overflow: visible; }
.node.direct .command-cell-mark { color: var(--cyan); }
.node.estimated .command-cell-mark, .node.degraded .command-cell-mark { color: var(--amber); }
.node.offline .command-cell-mark { color: var(--red); }
.interferer .mark { fill: #210909; stroke: var(--red); stroke-width: 4; }
.interferer.scheduled, .interferer.complete { opacity: .52; }
.node:focus .focus-ring, .node:hover .focus-ring { opacity: 1; }
.focus-ring { fill: none; stroke: var(--ink); stroke-width: 2; opacity: 0; }
.node-label { fill: var(--ink); font: 700 14px ui-monospace, monospace; letter-spacing: 0.04em; paint-order: stroke; stroke: #041012; stroke-width: 5px; }

.static-fallback, .noscript { margin-top: 20px; padding: clamp(24px, 4vw, 54px); border: 1px solid var(--line); color: var(--muted); min-height: 380px; background: radial-gradient(circle at 72% 42%, #124143 0, #071719 32%, #041012 66%); }
.static-fallback strong { color: var(--ink); font-size: 1.35rem; }
.static-fallback p { max-width: 42rem; margin-top: 14px; line-height: 1.6; }
.map-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 16px; color: var(--muted); font: 650 0.75rem ui-monospace, monospace; }
.map-legend span { display: inline-flex; align-items: center; gap: 7px; }
.map-legend i { width: 18px; height: 10px; display: inline-block; border: 2px solid var(--cyan); }
.map-legend .legend-estimated { border-color: var(--amber); border-radius: 50%; border-style: dashed; }
.map-legend .legend-link { height: 0; border: 0; border-top: 2px solid var(--cyan); }
.map-legend .legend-degraded { height: 0; border: 0; border-top: 2px dashed var(--amber); }
.map-legend .legend-interferer { border-color: var(--red); transform: rotate(45deg) scale(.62); }
.map-legend .legend-water { border: 0; background: #24566a; }
.map-legend .legend-road { height: 0; border: 0; border-top: 3px solid #b79d71; }

.state-rail { border-left: 1px solid var(--line); background: rgba(4, 16, 18, 0.96); }
.state-rail section { padding: 25px; border-bottom: 1px solid var(--line); }
.rail-heading span { color: var(--muted); font: 650 0.75rem ui-monospace, monospace; }
.node-list, .service-list { display: grid; gap: 8px; }
.node-list { max-height: min(32vh, 22rem); overflow-y: auto; padding-right: 3px; scrollbar-color: var(--line) transparent; }
.node-button, .service-card { width: 100%; padding: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; }
.node-button { display: grid; grid-template-columns: 9px 1fr auto; gap: 10px; align-items: center; cursor: pointer; }
.node-button:hover, .node-button:focus-visible, .node-button[aria-pressed="true"] { border-color: var(--cyan); background: var(--surface-2); outline: none; }
.node-button .state-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); }
.node-button .state-dot.degraded { background: var(--amber); }
.node-button .state-dot.unknown { background: var(--muted); }
.node-button small { color: var(--muted); }
.selection h2 { font-size: 1.45rem; margin-bottom: 8px; }
.selection p:last-child { color: var(--muted); line-height: 1.5; margin-bottom: 0; }
.detail-list { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; margin: 15px 0 0; font-size: 0.85rem; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; text-align: right; }
.inventory-heading { margin: 22px 0 10px; color: var(--muted); font: 700 0.72rem/1.2 ui-monospace, "Cascadia Mono", monospace; letter-spacing: 0.12em; text-transform: uppercase; }
.equipment-list { display: grid; gap: 7px; margin: 0; padding: 0; list-style: none; }
.equipment-list li { display: grid; grid-template-columns: minmax(5.5rem, auto) 1fr; gap: 10px; padding-top: 7px; border-top: 1px solid rgba(36, 73, 75, 0.62); font-size: 0.78rem; }
.equipment-list strong { color: var(--ink); font-family: ui-monospace, "Cascadia Mono", monospace; }
.equipment-list span { color: var(--muted); text-align: right; }
.service-card { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.service-card strong { font-size: 0.9rem; }
.service-card small { grid-column: 1 / -1; color: var(--muted); font: 600 0.72rem ui-monospace, monospace; }
.service-card span { color: var(--cyan); font: 700 0.7rem ui-monospace, monospace; text-transform: uppercase; }
.service-card .reduced { color: var(--amber); }
.payload-state { display: grid; gap: 8px; }
.payload-state > strong { font-size: 1rem; }
.payload-status { color: var(--muted); font: 700 0.72rem/1.4 ui-monospace, monospace; text-transform: uppercase; }
.payload-status.delivered { color: var(--cyan); }
.payload-status.expired, .payload-status.failed { color: var(--red); }
.payload-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 8px 0 0; font-size: 0.8rem; }
.payload-grid dt { color: var(--muted); }
.payload-grid dd { margin: 0; overflow-wrap: anywhere; text-align: right; }
.change-list { margin: 0; padding-left: 1.2rem; color: var(--muted); font-size: 0.84rem; line-height: 1.5; }
.change-list li + li { margin-top: 8px; }

@media (max-width: 940px) {
  .workspace { grid-template-columns: 1fr; }
  .state-rail { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 560px) {
  .topbar { padding: 0 18px; gap: 12px; }
  .mode { display: none; }
  main { width: calc(100vw - 28px); }
  .map-panel { padding: 13px; }
  .map-initializing .map-frame { left: 13px; right: 13px; }
  .panel-heading { display: block; }
  .run-meta { margin-top: 14px; text-align: left; align-items: flex-start; }
  .map-legend { gap: 12px; }
  .interactive-map { height: 430px; }
  .state-rail section { padding: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
}
.snapshot-loading:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; padding: .6rem 1rem; border-bottom: 1px solid #25474b; font-size: .85rem; }
.snapshot-loading progress { width: 8rem; max-width: 100%; accent-color: #68dfd5; }
