:root {
  --bg: #071623;
  --surface: #0C2131;
  --surface-2: #102A3C;
  --line: #1D3A4E;
  --line-soft: #162F41;
  --text: #E8EFF4;
  --muted: #A6B8C5;
  --dim: #7F95A6;
  --brass: #C2A15E;
  --brass-soft: #2A2A1E;
  --brass-ink: #12100A;
  --live: #5E9C86;
  --warn: #C97A4A;
  --feed: #091A27;
  --radius: 6px;
  --sidebar: 220px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", monospace;
  --serif: "Spectral", Georgia, serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; }

/* Sidebar */
.sidebar {
  position: sticky; top: 0; height: 100vh; z-index: 20;
  display: flex; flex-direction: column;
  padding: 24px 16px 22px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); padding: 0 8px; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 10px; height: 10px; background: var(--brass); border-radius: 2px; box-shadow: 0 0 0 4px rgba(194,161,94,.07); }
.brand-name { font-family: var(--mono); font-size: 14px; font-weight: 500; letter-spacing: -.2px; }
.site-switch {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; text-align: left;
  margin: 24px 8px 0; padding: 0; border: 0; background: transparent; color: var(--text);
}
.site-kicker, .kicker { font-family: var(--mono); font-size: 8px; letter-spacing: 1.2px; color: var(--dim); }
.site-name { grid-column: 1 / 2; font-family: var(--mono); font-size: 9px; font-weight: 500; letter-spacing: .2px; }
.site-chev { grid-row: 1 / 3; align-self: end; color: var(--dim); font-size: 13px; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 32px; }
.nav a {
  position: relative; display: flex; align-items: center; min-height: 34px;
  padding: 7px 12px 7px 14px; border-radius: 4px;
  color: var(--muted); font-size: 12px; font-weight: 400;
}
.nav a:hover { color: var(--text); background: rgba(255,255,255,.025); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--soft, #182B38); font-weight: 500; }
.nav a.active::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px; width: 2px;
  background: var(--brass); border-radius: 2px;
}
.side-context { margin-top: auto; padding: 0 8px 18px; }
.side-context .kicker { display: block; margin-bottom: 7px; }
.sel-drone { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 10px; color: var(--text); }
.sel-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--brass); flex: none; }
.season { padding: 0 8px; }
.season strong { display: block; margin-top: 4px; font-family: var(--mono); font-size: 11px; font-weight: 500; }
.progress { height: 4px; margin-top: 10px; background: var(--line); border-radius: 2px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brass); border-radius: 2px; }
.season-note { display: block; margin-top: 7px; font-family: var(--mono); font-size: 8px; color: var(--dim); }

/* Shell */
.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 15;
  min-height: 64px; padding: 13px 24px 12px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 18px;
  background: rgba(7,22,35,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 -2px 0 #6E5B36;
}
.topbar h1 { margin: 0; font-family: var(--serif); font-size: 21px; font-weight: 600; line-height: 1.15; letter-spacing: -.2px; }
.topbar .sub { margin: 5px 0 0; font-family: var(--mono); font-size: 8.5px; letter-spacing: .15px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 14px; padding-top: 2px; }
.date { font-family: var(--mono); font-size: 8px; color: var(--dim); white-space: nowrap; }
.status-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 22px; padding: 0 10px;
  border-radius: 4px; background: var(--surface); color: var(--muted);
  font-family: var(--mono); font-size: 8px; white-space: nowrap;
}
.status-pill .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--live); }
.view { padding: 20px 24px 44px; max-width: 1680px; outline: none; }

/* Primitives */
.kicker { font-family: var(--mono); font-size: 8px; letter-spacing: 1.1px; color: var(--dim); }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.serif { font-family: var(--serif); }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 30px; padding: 0 12px; border: 1px solid transparent; border-radius: var(--radius);
  background: transparent; color: var(--muted); font-family: var(--mono); font-size: 9px; font-weight: 500;
  white-space: nowrap;
}
.btn:hover { color: var(--text); border-color: var(--line); text-decoration: none; }
.btn.primary { background: var(--brass); color: var(--brass-ink); }
.btn.primary:hover { background: #D1B16E; border-color: transparent; }
.btn.secondary { background: var(--surface-2); color: var(--text); border-color: var(--line); }
.btn.secondary:hover { background: #163449; }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.btn.small { min-height: 26px; padding: 0 9px; font-size: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px;
  border-radius: 3px; background: var(--surface-2); color: var(--muted);
  font-family: var(--mono); font-size: 8px; font-weight: 500; letter-spacing: .4px; text-transform: uppercase;
  white-space: nowrap;
}
.tag.live { color: var(--live); background: #132E2A; }
.tag.warn { color: var(--warn); background: #2A211B; }
.tag.brass { color: var(--brass); background: #2A2A1E; }
.tag.ghost { color: var(--dim); background: var(--surface-2); }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px 10px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 11px; font-weight: 500; }
.card-head .meta { font-family: var(--mono); font-size: 8px; color: var(--dim); }
.card-body { padding: 14px; }
.divider { height: 1px; background: var(--line); }

/* Wall */
.wall-toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-bottom: 14px; }
.wall-toolbar h2 { margin: 0; font-family: var(--serif); font-size: 17px; font-weight: 600; }
.wall-toolbar .sub { margin-top: 3px; font-family: var(--mono); font-size: 8px; color: var(--dim); }
.alert-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 36px; margin-bottom: 14px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px;
  font-size: 10px;
}
.alert-strip .left { display: flex; align-items: center; gap: 9px; min-width: 0; }
.alert-strip .left span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-strip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warn); flex: none; }
.alert-strip a { font-family: var(--mono); font-size: 8px; white-space: nowrap; }
.wall-layout { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 16px; align-items: start; }
.tile-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile-grid.all { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tile {
  position: relative; display: block; width: 100%; aspect-ratio: 1.85; padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  background: var(--feed); color: var(--text); text-align: left; cursor: pointer;
  isolation: isolate;
}
.tile:hover { border-color: #2B526B; }
.tile .feed-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.tile::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.34) 0, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 68%, rgba(0,0,0,.46) 100%);
}
.tile-top, .tile-bottom { position: absolute; z-index: 2; left: 12px; right: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tile-top { top: 9px; }
.tile-bottom { bottom: 8px; align-items: flex-end; }
.tile-id { font-family: var(--mono); font-size: 11px; font-weight: 500; }
.tile-role { margin-left: 6px; font-family: var(--mono); font-size: 7px; color: #B9C6CF; letter-spacing: .7px; }
.tile-state { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 7px; letter-spacing: .5px; }
.tile-state .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--live); }
.tile-state.degraded { color: var(--warn); }
.tile-state.degraded .dot { background: var(--warn); }
.tile-state.offline { color: var(--dim); }
.tile-state.offline .dot { background: var(--dim); }
.tile-state.grounded { color: var(--dim); }
.tile-state.grounded .dot { background: var(--dim); }
.tile-bottom .bitrate, .tile-bottom .battery { font-family: var(--mono); font-size: 8px; color: #D6DEE5; }
.tile.paused::before {
  content: "PAUSED"; position: absolute; z-index: 3; left: 50%; top: 50%; transform: translate(-50%,-50%);
  padding: 4px 7px; border: 1px solid var(--line); background: rgba(7,22,35,.82);
  font-family: var(--mono); font-size: 8px; letter-spacing: .8px; color: var(--muted);
}
.tile-pause {
  position: absolute; z-index: 4; right: 8px; bottom: 30px; width: 22px; height: 20px;
  border: 1px solid var(--line); border-radius: 3px; background: rgba(7,22,35,.7);
  color: var(--muted); font-family: var(--mono); font-size: 8px; opacity: 0; transition: opacity .15s;
}
.tile:hover .tile-pause, .tile:focus-within .tile-pause { opacity: 1; }
.feed-world { animation: fpvSway 10s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes fpvSway {
  0%, 100% { transform: scale(1.02) translate(-2px, 2px) rotate(-.3deg); }
  50% { transform: scale(1.06) translate(3px, -2px) rotate(.3deg); }
}
.fpv-road { animation: roadFlow 10s linear infinite; }
@keyframes roadFlow { to { stroke-dashoffset: -46; } }
.tile.paused .feed-world, .tile.paused .fpv-road,
.tile.offline .feed-world, .tile.offline .fpv-road,
.tile.grounded .feed-world, .tile.grounded .fpv-road { animation-play-state: paused; }
.tile.offline .feed-svg { opacity: 1; }
.tile.offline .feed-world { opacity: .48; filter: grayscale(1); }
.tile.grounded .feed-world { opacity: .62; filter: saturate(.5); }
.tile.offline .feed-world, .tile.grounded .feed-world { animation-play-state: paused; }
@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
.tile-state.live .dot, .status-pill .dot, .map-live .dot, .video-state .dot { animation: livePulse 1.8s ease-in-out infinite; }
@keyframes trailFlow { to { stroke-dashoffset: -24; } }
.map-stage .trail { animation: trailFlow 1.4s linear infinite; }
.rail { display: flex; flex-direction: column; gap: 12px; }
.rail .card-body { padding: 12px 14px; }
.mini-map { display: block; width: 100%; height: auto; border-radius: 4px; background: #081926; }
.map-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 9px; font-family: var(--mono); font-size: 8px; color: var(--dim); }
.jobs-mini { display: flex; flex-direction: column; }
.job-mini {
  display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 10px 0;
  border-top: 1px solid var(--line); text-align: left; background: transparent; border-left: 0; border-right: 0; border-bottom: 0;
}
.job-mini:first-child { border-top: 0; padding-top: 0; }
.job-mini:hover .field { color: var(--brass); }
.job-mini .field { font-size: 10px; font-weight: 500; }
.job-mini .product { grid-column: 1; font-size: 9px; color: var(--muted); }
.job-mini .sorties { grid-row: 1 / 3; align-self: center; font-family: var(--mono); font-size: 8px; color: var(--dim); }

/* Focus */
.focus-layout { display: grid; grid-template-columns: minmax(0, 1fr) 316px; gap: 16px; align-items: start; }
.focus-main { min-width: 0; }
.drone-alert {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 34px; margin-bottom: 12px; padding: 0 12px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; font-size: 9px;
}
.drone-alert .left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.drone-alert .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--warn); flex: none; }
.camera-tabs { display: flex; align-items: center; gap: 20px; min-height: 36px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; }
.camera-tab { position: relative; height: 36px; padding: 0; border: 0; background: transparent; color: var(--muted); font-family: var(--mono); font-size: 9px; }
.camera-tab.active { color: var(--text); font-weight: 500; }
.camera-tab.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--brass); }
.camera-tabs .stream-tag { margin-left: auto; font-family: var(--mono); font-size: 8px; color: var(--dim); }
.video-stage { position: relative; aspect-ratio: 16 / 9; overflow: hidden; border: 1px solid var(--line); border-radius: 0 0 var(--radius) var(--radius); background: var(--feed); }
.video-stage .feed-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.video-stage.offline .feed-world, .video-stage.grounded .feed-world { opacity: .48; filter: grayscale(1); }
.video-stage.offline .feed-world, .video-stage.grounded .feed-world,
.video-stage.offline .fpv-road, .video-stage.grounded .fpv-road { animation-play-state: paused; }
.video-stage::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.32), transparent 18%, transparent 72%, rgba(0,0,0,.46)); pointer-events: none; }
.video-top, .video-bottom { position: absolute; z-index: 2; left: 16px; right: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.video-top { top: 12px; }
.video-bottom { bottom: 11px; }
.video-id { font-family: var(--mono); font-size: 12px; font-weight: 500; }
.video-role { margin-left: 8px; font-family: var(--mono); font-size: 7px; color: #B9C6CF; letter-spacing: .7px; }
.video-state { display: flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 8px; color: var(--live); }
.video-state .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--live); }
.video-state.grounded { color: var(--dim); }
.video-state.grounded .dot { background: var(--dim); }
.video-meta { font-family: var(--mono); font-size: 8px; color: #D6DEE5; }
.telemetry { display: grid; grid-template-columns: repeat(7, 1fr); margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.telemetry div { min-width: 0; padding: 11px 12px 10px; border-left: 1px solid var(--line); }
.telemetry div:first-child { border-left: 0; }
.telemetry .k { display: block; font-family: var(--mono); font-size: 7px; letter-spacing: .7px; color: var(--dim); }
.telemetry .v { display: block; margin-top: 4px; font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--text); white-space: nowrap; }
.telemetry .u { margin-left: 2px; font-size: 7px; color: var(--dim); }
.events { margin-top: 12px; }
.event-row { display: grid; grid-template-columns: 48px 44px minmax(0,1fr); align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); }
.event-row:first-child { border-top: 0; }
.event-time { font-family: var(--mono); font-size: 8px; color: var(--dim); }
.event-text { font-size: 9px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.focus-rail .card-body { padding: 12px 14px; }
.inset-map { display: block; width: 100%; height: auto; border-radius: 4px; background: #081926; }
.config-list { display: flex; flex-direction: column; }
.config-row { display: grid; grid-template-columns: 92px minmax(0,1fr); gap: 8px; padding: 8px 0; border-top: 1px solid var(--line); }
.config-row:first-child { border-top: 0; }
.config-row .k { font-family: var(--mono); font-size: 7px; color: var(--dim); }
.config-row .v { font-size: 9px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.config-row .v.warn { color: var(--warn); }
.link { border: 0; background: transparent; padding: 0; color: var(--brass); font-family: var(--mono); font-size: 8px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.action-row { display: flex; gap: 6px; flex-wrap: wrap; }
.action-row .btn { flex: 1; min-width: 80px; }
.focus-note { margin-top: 9px; font-family: var(--mono); font-size: 7px; color: var(--dim); }
.job-now { padding: 2px 0 0; }
.job-now strong { display: block; font-size: 11px; font-weight: 500; }
.job-now .meta { margin-top: 4px; font-family: var(--mono); font-size: 8px; color: var(--muted); }

/* Map */
.map-view { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 336px; gap: 16px; align-items: start; }
.map-stage { position: relative; height: calc(100vh - 112px); min-height: 620px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: #081926; }
.map-scroll { position: absolute; inset: 0; overflow: hidden; }
.map-scroll > svg.map-svg { display: block; width: 100%; height: 100%; transition: transform .2s ease; transform: scale(var(--zoom, 1)); transform-origin: center; }
.camera-tab:disabled { opacity: .35; cursor: not-allowed; }
.history-focus { outline: 1px solid var(--brass); outline-offset: 5px; border-radius: 4px; }
.map-stage .map-svg .field-poly { transition: opacity .15s; }
.map-stage.hide-fields .field-poly { opacity: 0; }
.map-stage .trail { opacity: 0; transition: opacity .2s; }
.map-stage.show-trails .trail { opacity: 1; }
.map-controls { position: absolute; z-index: 3; left: 14px; top: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 4px; background: rgba(12,33,49,.9); color: var(--muted);
  font-family: var(--mono); font-size: 8px; letter-spacing: .2px;
}
.chip.on { background: #1B2D3A; color: var(--text); border-color: #31536A; }
.chip:hover { color: var(--text); }
.map-live { position: absolute; z-index: 3; left: 50%; top: 14px; transform: translateX(-50%); display: flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 4px; background: rgba(12,33,49,.9); font-family: var(--mono); font-size: 8px; color: var(--live); }
.map-live .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--live); }
.map-actions { position: absolute; z-index: 3; right: 14px; top: 14px; display: flex; gap: 6px; }
.map-rail { position: static; width: auto; max-height: calc(100vh - 112px); overflow: auto; }
.map-rail .card { background: rgba(12,33,49,.97); backdrop-filter: blur(6px); }
.map-legend { position: absolute; z-index: 3; left: 14px; bottom: 14px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 4px; background: rgba(12,33,49,.92); }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 18px; margin-top: 7px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 7px; color: var(--muted); }
.legend-item .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--live); }
.legend-item .dot.stale { background: var(--warn); }
.legend-item .dot.lost { background: transparent; border: 1px solid var(--dim); }
.legend-item .dot.grounded { background: transparent; border: 1px solid var(--dim); }
.scale { position: absolute; z-index: 3; right: 18px; bottom: 18px; display: flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: 7px; color: var(--dim); }
.scale .line { width: 80px; height: 1px; background: var(--dim); position: relative; }
.scale .line::before, .scale .line::after { content: ""; position: absolute; top: -3px; width: 1px; height: 7px; background: var(--dim); }
.scale .line::before { left: 0; } .scale .line::after { right: 0; }
.map-dot { cursor: pointer; }
.map-dot .dot-core { fill: var(--live); }
.map-dot.stale .dot-core { fill: var(--warn); }
.map-dot.lost .dot-core, .map-dot.grounded .dot-core { fill: none; stroke: var(--dim); stroke-width: 1.5; }
.map-dot .dot-ring { fill: none; stroke: var(--brass); stroke-width: 1.5; opacity: 0; }
.map-dot.selected .dot-ring { opacity: 1; }
.map-dot .dot-label { fill: var(--text); font-family: var(--mono); font-size: 8px; }
.map-dot.stale .dot-label { fill: var(--warn); }
.map-dot.lost .dot-label, .map-dot.grounded .dot-label { fill: var(--muted); }
.map-dot:hover .dot-core { filter: brightness(1.2); }
.map-zoom { position: absolute; z-index: 3; right: 108px; top: 14px; display: flex; gap: 4px; }
.map-zoom button { width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 4px; background: rgba(12,33,49,.9); color: var(--muted); font-family: var(--mono); font-size: 12px; }
.map-zoom button:hover { color: var(--text); }
.rail-drone-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.rail-drone-head h2 { margin: 0; font-size: 14px; font-weight: 500; }
.rail-drone-head .meta { margin-top: 3px; font-family: var(--mono); font-size: 8px; color: var(--dim); }
.rail-thumb { position: relative; aspect-ratio: 2.05; margin: 10px 0 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: var(--feed); }
.rail-thumb .feed-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.rail-thumb::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.3), transparent 25%, transparent 70%, rgba(0,0,0,.45)); }
.rail-thumb .thumb-top, .rail-thumb .thumb-bottom { position: absolute; z-index: 2; left: 9px; right: 9px; display: flex; justify-content: space-between; gap: 8px; font-family: var(--mono); font-size: 7px; }
.rail-thumb .thumb-top { top: 7px; } .rail-thumb .thumb-bottom { bottom: 6px; color: #D6DEE5; }
.telemetry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 4px 0 12px; }
.telemetry-grid .k { display: block; font-family: var(--mono); font-size: 7px; color: var(--dim); letter-spacing: .6px; }
.telemetry-grid .v { display: block; margin-top: 3px; font-family: var(--mono); font-size: 10px; color: var(--text); }
.telemetry-grid .u { margin-left: 2px; font-size: 7px; color: var(--dim); }
.rail-job { padding-top: 12px; border-top: 1px solid var(--line); }
.rail-job .k { font-family: var(--mono); font-size: 7px; color: var(--dim); letter-spacing: .8px; }
.rail-job strong { display: block; margin-top: 5px; font-size: 10px; font-weight: 500; }
.rail-job .meta { margin-top: 3px; font-family: var(--mono); font-size: 8px; color: var(--muted); }
.rail-actions { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.rail-actions .btn { width: 100%; }
.rail-note { margin-top: 8px; font-family: var(--mono); font-size: 7px; color: var(--dim); }
.rail-clear { margin-top: 10px; text-align: left; }

/* Jobs */
.jobs-layout { display: grid; grid-template-columns: minmax(0, 620px) minmax(0, 1fr); gap: 16px; align-items: start; }
.jobs-layout > * { min-width: 0; }
.jobs-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.filters { display: flex; align-items: center; gap: 16px; min-height: 30px; }
.filter { position: relative; padding: 0; border: 0; background: transparent; color: var(--muted); font-family: var(--mono); font-size: 9px; }
.filter.active { color: var(--text); }
.filter.active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 2px; background: var(--brass); }
.search { width: 240px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface); color: var(--text); font-family: var(--mono); font-size: 8px; }
.search::placeholder { color: var(--dim); }
.jobs-table { width: 100%; border-collapse: collapse; }
.jobs-table th { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; font-family: var(--mono); font-size: 7px; font-weight: 400; letter-spacing: .6px; color: var(--dim); }
.jobs-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); font-size: 9px; color: var(--muted); vertical-align: middle; }
.jobs-table tr { cursor: pointer; }
.jobs-table tbody tr:hover td { background: rgba(255,255,255,.025); }
.jobs-table tr.selected td { background: var(--soft); color: var(--text); }
.jobs-table tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--brass); }
.jobs-table .field { color: var(--text); font-weight: 500; }
.jobs-table .num { font-family: var(--mono); }
.jobs-table .status { text-align: right; }
.inbox { margin-top: 14px; }
.inbox-row { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 9px 0; border-top: 1px solid var(--line); align-items: center; }
.inbox-row:first-child { border-top: 0; }
.inbox-row .id { font-family: var(--mono); font-size: 9px; color: var(--text); }
.inbox-row .meta { grid-column: 1; font-family: var(--mono); font-size: 8px; color: var(--dim); }
.inbox-row .link { grid-row: 1 / 3; }
.landing { margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 16px; align-items: center; }
.landing .k, .landing h3, .landing .meta { grid-column: 1; }
.landing .actions { grid-column: 2; grid-row: 1 / span 3; margin-top: 0; justify-content: flex-end; }
.jobs-detail { min-width: 0; }
.job-head .kicker { color: var(--brass); }
.job-head h2 { margin: 4px 0 6px; font-family: var(--serif); font-size: 23px; font-weight: 600; line-height: 1.15; }
.job-head .meta { font-family: var(--mono); font-size: 8px; color: var(--muted); }
.job-head .tags { display: flex; gap: 6px; margin-top: 7px; }
.sorties { margin-top: 14px; }
.sorties table { width: 100%; border-collapse: collapse; }
.sorties th { padding: 6px 7px; border-bottom: 1px solid var(--line); text-align: left; font-family: var(--mono); font-size: 7px; font-weight: 400; color: var(--dim); letter-spacing: .5px; }
.sorties td { padding: 7px; border-bottom: 1px solid var(--line); font-size: 9px; color: var(--muted); }
.sorties tr { cursor: pointer; }
.sorties tr.selected td { background: var(--soft); color: var(--text); }
.sorties tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--brass); }
.sorties .id { font-family: var(--mono); color: var(--text); }
.playback { margin-top: 14px; }
.playback-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 12px; }
.track-box, .chart-box { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: #081926; }
.track-box svg, .chart-box svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 12px; margin-top: 7px; font-family: var(--mono); font-size: 7px; color: var(--muted); }
.chart-legend .alt { color: var(--brass); } .chart-legend .spd { color: var(--muted); } .chart-legend .bat { color: var(--live); }
.playback-events { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; }
.playback-event { padding: 0; border: 0; background: transparent; font-family: var(--mono); font-size: 7px; color: var(--muted); }
.playback-event:hover { color: var(--text); }
.playback-event .t { color: var(--dim); margin-right: 3px; }
.scrub { margin-top: 12px; }
.scrub input[type="range"] { width: 100%; accent-color: var(--brass); height: 4px; }
.scrub-labels { display: flex; justify-content: space-between; margin-top: 2px; font-family: var(--mono); font-size: 7px; color: var(--dim); }
.transport { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.transport button { border: 0; background: transparent; color: var(--muted); font-family: var(--mono); font-size: 8px; padding: 0; }
.transport button:hover { color: var(--text); }
.playback-note { margin-top: 9px; font-family: var(--mono); font-size: 7px; color: var(--dim); }
.playback-gap { margin-top: 4px; font-family: var(--mono); font-size: 7px; color: var(--warn); }

/* Config */
.config-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr) 310px; gap: 16px; align-items: start; }
.config-layout > *, .config-layout section, .config-layout aside { min-width: 0; }
.detail-actions .btn { width: 100%; }
.config-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.config-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.domain-rail { padding: 12px; }
.domain-rail .kicker { display: block; margin: 0 4px 8px; }
.domain { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); text-align: left; font-size: 9px; }
.domain:hover { color: var(--text); background: rgba(255,255,255,.025); }
.domain.active { color: var(--text); background: var(--soft); font-weight: 500; box-shadow: inset 2px 0 0 var(--brass); }
.domain-meta { margin-top: 12px; padding: 12px 10px 0; border-top: 1px solid var(--line); }
.domain-meta .tpl { font-family: var(--mono); font-size: 9px; color: var(--text); }
.domain-meta .note { margin-top: 8px; font-size: 8px; color: var(--dim); line-height: 1.5; }
.template-banner { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 11px 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.template-banner .left { display: flex; gap: 9px; }
.template-banner .dot { width: 6px; height: 6px; margin-top: 4px; border-radius: 50%; background: var(--brass); flex: none; }
.template-banner strong { display: block; font-size: 9px; font-weight: 500; }
.template-banner .meta { margin-top: 3px; font-family: var(--mono); font-size: 7px; color: var(--dim); }
.config-table-card { overflow: hidden; }
.config-table { width: 100%; border-collapse: collapse; }
.config-table th { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; font-family: var(--mono); font-size: 7px; font-weight: 400; letter-spacing: .5px; color: var(--dim); }
.config-table td { padding: 10px; border-bottom: 1px solid var(--line); font-size: 9px; color: var(--muted); vertical-align: middle; }
.config-table tr { cursor: pointer; }
.config-table tbody tr:hover td { background: rgba(255,255,255,.025); }
.config-table tr.selected td { background: var(--soft); }
.config-table tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--brass); }
.config-table .field { color: var(--text); font-weight: 500; }
.config-table .field small { display: block; margin-top: 2px; font-family: var(--mono); font-size: 7px; font-weight: 400; color: var(--dim); }
.config-table .value { color: var(--text); font-family: var(--mono); }
.config-table .reported.drift { color: var(--warn); }
.config-note { margin-top: 10px; font-family: var(--mono); font-size: 7px; color: var(--dim); line-height: 1.7; }
.config-note strong { color: var(--brass); font-weight: 500; }
.detail-panel { padding: 14px; }
.detail-panel h2 { margin: 4px 0 2px; font-family: var(--serif); font-size: 20px; font-weight: 600; }
.detail-panel .domain-name { font-family: var(--mono); font-size: 8px; color: var(--dim); }
.detail-kv { margin-top: 12px; }
.detail-kv .row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); }
.detail-kv .row:first-child { border-top: 0; }
.detail-kv .k { font-family: var(--mono); font-size: 7px; color: var(--dim); }
.detail-kv .v { font-size: 9px; color: var(--text); text-align: right; }
.detail-kv .v.warn { color: var(--warn); }
.drift-box { margin-top: 10px; padding: 9px 10px; border: 1px solid #3A2A1F; border-radius: 4px; background: #211B16; }
.drift-box .tag { margin-bottom: 6px; }
.drift-box p { margin: 0; font-size: 8px; color: var(--muted); line-height: 1.5; }
.detail-actions { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.history { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.history-row { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); }
.history-row:first-child { border-top: 0; }
.history-row .date { font-family: var(--mono); font-size: 7px; color: var(--dim); }
.history-row .what { font-size: 8px; color: var(--text); }
.history-row .who { grid-column: 2; font-family: var(--mono); font-size: 7px; color: var(--dim); }
.detail-foot { margin-top: 12px; font-family: var(--mono); font-size: 7px; color: var(--brass); line-height: 1.6; }
.detail-foot span { display: block; color: var(--dim); }

/* Modal + toast */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(3,10,16,.7); backdrop-filter: blur(3px); }
.modal { width: min(420px, 100%); border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 24px 80px rgba(0,0,0,.45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.modal-body { padding: 16px; }
.modal-body p { margin: 0 0 12px; color: var(--muted); font-size: 9px; }
.modal-body label { display: block; margin-bottom: 6px; font-family: var(--mono); font-size: 7px; color: var(--dim); letter-spacing: .6px; }
.modal-body select { width: 100%; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 4px; background: var(--surface-2); color: var(--text); font-family: var(--mono); font-size: 9px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 7px; padding: 12px 16px; border-top: 1px solid var(--line); }
.close-x { width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 4px; background: transparent; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: 22px; transform: translate(-50%, 16px);
  max-width: min(420px, calc(100vw - 32px)); padding: 10px 14px; border: 1px solid #31536A; border-radius: 6px;
  background: #102A3C; color: var(--text); font-family: var(--mono); font-size: 8px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Empty states */
.empty-state { padding: 28px 18px; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-state h3 { margin: 0 0 5px; font-family: var(--serif); font-size: 17px; font-weight: 600; }
.empty-state p { margin: 0 auto 14px; max-width: 380px; color: var(--muted); font-size: 9px; }

/* Responsive */
@media (max-width: 1380px) {
  .wall-layout, .focus-layout { grid-template-columns: minmax(0, 1fr) 290px; }
  .tile-grid.all { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1180px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky; top: 0; height: auto; flex-direction: row; align-items: center; gap: 18px;
    padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto;
  }
  .brand { flex: none; padding: 0; }
  .site-switch { margin: 0; display: none; }
  .nav { flex-direction: row; gap: 4px; margin: 0; }
  .nav a { min-height: 30px; padding: 6px 10px; white-space: nowrap; }
  .nav a.active::before { top: auto; bottom: 0; left: 10px; right: 10px; width: auto; height: 2px; }
  .side-context, .season { display: none; }
  .topbar { top: 55px; }
  .wall-layout, .focus-layout, .jobs-layout, .config-layout { grid-template-columns: 1fr; }
  .rail, .focus-rail { display: grid; grid-template-columns: 1fr 1fr; }
  .config-layout .domain-rail { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px; }
  .domain-rail .kicker, .domain-meta { display: none; }
  .domain { width: auto; }
  .map-stage { height: 70vh; min-height: 520px; }
  .map-rail { position: static; width: auto; max-height: none; margin-top: 12px; }
  .map-stage { overflow: visible; }
  .map-view { display: flex; flex-direction: column; align-items: stretch; }
  .map-stage { order: 1; }
  .map-rail { order: 2; }
  .scale, .map-zoom { display: none; }
}
@media (max-width: 820px) {
  .view { padding: 14px 14px 36px; }
  .topbar { padding: 11px 14px; }
  .topbar h1 { font-size: 18px; }
  .topbar-right .date { display: none; }
  .wall-toolbar { align-items: flex-start; }
  .tile-grid, .tile-grid.all { grid-template-columns: 1fr; }
  .rail, .focus-rail { grid-template-columns: 1fr; }
  .telemetry { grid-template-columns: repeat(4, 1fr); }
  .telemetry div:nth-child(5) { border-left: 0; border-top: 1px solid var(--line); }
  .telemetry div:nth-child(n+5) { border-top: 1px solid var(--line); }
  .jobs-toolbar { flex-direction: column; align-items: flex-start; }
  .search { width: 100%; }
  .jobs-table { min-width: 560px; }
  .jobs-table-wrap { overflow-x: auto; }
  .jobs-layout { gap: 18px; }
  .landing { display: block; }
  .landing .actions { margin-top: 10px; justify-content: flex-start; }
  .playback-grid { grid-template-columns: 1fr; }
  .config-head { flex-direction: column; }
  .config-actions { width: 100%; }
  .config-table { min-width: 680px; }
  .config-table-wrap { overflow-x: auto; }
  .detail-panel { position: static; }
  .map-controls { right: 14px; }
  .map-actions { top: 50px; }
  .map-live { display: none; }
  .map-stage::after { content: ""; position: absolute; z-index: 2; top: 0; right: 0; bottom: 0; width: 24px; background: linear-gradient(90deg, rgba(7,22,35,0), rgba(7,22,35,.85)); pointer-events: none; }
  .map-rail { margin-top: 10px; }
  .map-scroll { overflow: auto; }
  .map-scroll > svg.map-svg { width: 1000px; height: 700px; transform-origin: top left; }
  .sorties .card-body { overflow-x: auto; }
  .sorties table { min-width: 620px; }
  .camera-tabs .stream-tag { display: none; }
}
@media (max-width: 480px) {
  .sidebar { gap: 12px; padding: 10px 12px; }
  .brand-name { font-size: 13px; }
  .nav { gap: 0; }
  .nav a { padding: 6px 8px; font-size: 11px; }
  .topbar { min-height: 58px; }
  .topbar .sub { font-size: 7px; }
  .topbar-right { display: none; }
  .alert-strip { font-size: 9px; }
  .alert-strip a { display: none; }
  .alert-strip { align-items: flex-start; }
  .alert-strip .left span:last-child { white-space: normal; overflow: visible; text-overflow: clip; line-height: 1.4; }
  .drone-alert { align-items: flex-start; padding: 8px 12px; }
  .drone-alert a { display: none; }
  .drone-alert .left span:last-child { line-height: 1.4; }
  .telemetry > div:last-child { grid-column: 1 / -1; }
  .telemetry { grid-template-columns: repeat(3, 1fr); }
  .telemetry div:nth-child(4) { border-left: 0; }
  .telemetry div:nth-child(n+4) { border-top: 1px solid var(--line); }
  .action-row .btn { flex: 1 1 100%; }
  .job-head h2 { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
