:root {
  --bg: #0f1216; --panel: #171b21; --line: #2a313b; --text: #d8dee6; --muted: #8a94a3;
  --sun: #f2c14e; --nadir: #4ea3f2; --trace: #9ad17a; --client: #ff5fb0; --now: #39d0c8;
  --green: #4fbf7a; --amber: #e0a040; --red: #ff5a50;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { display: grid; grid-template-rows: auto 1fr 96px auto; min-height: 640px; }
header, footer { display: flex; gap: 12px; align-items: center; padding: 6px 12px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; }
footer { border-top: 1px solid var(--line); border-bottom: 0; }
.brand { font-weight: 600; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.spacer { flex: 1; }
.clock { white-space: nowrap; }
select, button, a.button { background: #222831; color: var(--text); border: 1px solid var(--line);
  border-radius: 4px; padding: 2px 8px; font: inherit; text-decoration: none; }
button { cursor: pointer; }
#live { border-color: var(--now); color: var(--now); }
#live.on { background: rgba(57, 208, 200, 0.15); }
.note { color: var(--muted); font-size: 11px; max-width: 760px; }
.tabs { display: flex; gap: 2px; }
.tab { border-radius: 4px 4px 0 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); }
.tab.active { color: var(--text); border-bottom-color: var(--now); }
.tab.locked:hover { color: var(--text); }
main { display: grid; gap: 6px; padding: 6px; min-height: 0;
  grid-template-columns: 1.15fr 1.15fr 1fr 300px;
  grid-template-rows: minmax(220px, 1fr) minmax(250px, 1fr);
  grid-template-areas: "orbit ric att side" "charts charts charts side"; }
#view-orbit { grid-area: orbit; }
#view-ric { grid-area: ric; }
#view-att { grid-area: att; }
#charts { grid-area: charts; display: grid; gap: 6px; grid-template-columns: repeat(3, 1fr); grid-template-rows: auto 1fr 1fr; min-height: 0; }
#side { grid-area: side; }
.view, .chart, #side, #timeline-box { position: relative; background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; overflow: hidden; min-height: 0; }
.view canvas, .chart canvas, #timeline canvas { display: block; }
.view-title, .legend { position: absolute; left: 8px; z-index: 1; pointer-events: none; color: var(--muted); font-size: 12px; }
.view-title { top: 6px; }
.legend { bottom: 6px; font-size: 11px; }
.sw { display: inline-block; width: 12px; height: 3px; margin: 0 4px 2px 6px; vertical-align: middle; }
.sw.sun { background: var(--sun); } .sw.nadir { background: var(--nadir); } .sw.trace { background: var(--trace); }
.sw.trace.dash { background: repeating-linear-gradient(90deg, var(--trace) 0 3px, transparent 3px 6px); }
.sw.client { background: var(--client); } .sw.link { background: var(--green); }
.sw.est { background: var(--now); } .sw.cone { background: rgba(224, 96, 90, 0.6); height: 8px; }
.chart { padding: 0; }
.chart > div.plot { position: absolute; inset: 0; }
.chart-head { position: absolute; left: 48px; top: 2px; right: 8px; font-size: 11px; color: var(--muted);
  pointer-events: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-head b { color: var(--text); font-weight: 600; }
.chart-head .k { display: inline-block; width: 8px; height: 3px; vertical-align: middle; margin: 0 3px 2px 6px; }
#side { padding: 8px 10px; display: flex; flex-direction: column; }
#side h3 { margin: 10px 0 4px; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.05em; display: flex; justify-content: space-between; align-items: center; }
#side h3 select { text-transform: none; font-size: 11px; letter-spacing: 0; }
.state-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; }
.badge.recorded { background: #2a3442; color: #c9d2dc; }
.badge.estimated { background: rgba(57, 208, 200, 0.2); color: var(--now); }
.badge.forecast { background: rgba(127, 178, 255, 0.18); color: #9fc3ff; }
#lights { list-style: none; margin: 0; padding: 0; }
#lights li { display: grid; grid-template-columns: 14px 1fr; gap: 2px 6px; padding: 3px 0; border-bottom: 1px solid #20262e; }
#lights .lamp { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; box-shadow: 0 0 6px currentColor; }
#lights .lamp.green { background: var(--green); color: var(--green); }
#lights .lamp.amber { background: var(--amber); color: var(--amber); }
#lights .lamp.red { background: var(--red); color: var(--red); }
#lights .t { font-size: 11px; color: var(--muted); grid-column: 2; }
#events { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; min-height: 80px; font-size: 12px; }
#events li { display: grid; grid-template-columns: 74px 1fr; gap: 6px; padding: 2px 4px; border-radius: 3px; cursor: pointer; }
#events li:hover { background: #20262e; }
#events li .when { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: var(--muted); }
#events li.future { color: #9fb0c4; font-style: italic; }
#events li.next { background: rgba(57, 208, 200, 0.12); }
#events li.burn .what::before { content: "▲ "; color: #b07cff; }
#events li.limit .what::before { content: "● "; color: var(--amber); }
#events li.aos .what::before, #events li.los .what::before { content: "◆ "; color: var(--green); }
#timeline-box { margin: 0 6px; }
#timeline { position: absolute; inset: 0; }
.modal { position: fixed; inset: 0; background: rgba(5, 8, 12, 0.6); display: grid; place-items: center; z-index: 10; }
.modal[hidden] { display: none; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; max-width: 420px; }
.card h2 { margin: 0 0 8px; font-size: 16px; }
.card .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.card a.button { border-color: var(--now); color: var(--now); }
@media (max-width: 1100px) {
  main { grid-template-columns: 1fr 1fr; grid-template-rows: 300px 300px 520px auto;
    grid-template-areas: "orbit ric" "att side" "charts charts" "charts charts"; }
  #charts { grid-template-columns: 1fr 1fr; grid-template-rows: auto repeat(3, 1fr); }
}
.chart canvas, #view-ric canvas, #timeline canvas { position: absolute; left: 0; top: 0; }
.view canvas { width: 100%; height: 100%; }
.chart-legend { grid-column: 1 / -1; font-size: 11px; color: var(--muted); padding: 0 4px; }
.sw.rec { background: #7fb2ff; } .sw.fc { background: repeating-linear-gradient(90deg, #7fb2ff 0 3px, transparent 3px 6px); }
.sw.band { background: rgba(120, 170, 255, 0.4); height: 9px; } .sw.los { background: rgba(140, 150, 165, 0.35); height: 9px; }
.sw.excl { background: rgba(224, 96, 90, 0.35); height: 9px; }
.sw.estdot { width: 7px; height: 7px; border-radius: 50%; background: var(--now); }
.sw.estlos { background: repeating-linear-gradient(90deg, #7fb2ff 0 1px, transparent 1px 3px); }
