:root {
  --void: #05060c;
  --panel: #0c1020;
  --panel-raised: #121830;
  --line: #232c4a;
  --line-soft: #171e38;
  --text: #e9ecf6;
  --text-dim: #8b93b0;
  --text-faint: #5a6283;
  --accent: #f5b942;
  --accent-glow: #ffcf6e;

  /* categorical slots, dark steps (validated on --panel) */
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  --other: #7b84a3;

  --font-display: 'Manrope', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--void); color: var(--text); font-family: var(--font-display); }
body { min-height: 100vh; display: flex; flex-direction: column; }
a { color: #86b6ef; }

.starfield {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10% 20%, #ffffff55 0%, transparent 60%),
    radial-gradient(1px 1px at 80% 10%, #ffffff40 0%, transparent 60%),
    radial-gradient(1.5px 1.5px at 30% 65%, #ffffff50 0%, transparent 60%),
    radial-gradient(1px 1px at 60% 80%, #ffffff35 0%, transparent 60%),
    radial-gradient(1px 1px at 90% 55%, #ffffff45 0%, transparent 60%),
    radial-gradient(1.5px 1.5px at 45% 30%, #ffffff40 0%, transparent 60%),
    radial-gradient(1px 1px at 20% 90%, #ffffff35 0%, transparent 60%),
    radial-gradient(1px 1px at 70% 40%, #ffffff30 0%, transparent 60%);
  background-size: 600px 600px; opacity: 0.8;
}

/* ---------- header ---------- */
.topbar {
  position: relative; z-index: 3; display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(180deg, #08091380, transparent);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { filter: drop-shadow(0 0 10px #3987e566); }
.brand-text h1 { margin: 0; font-size: 18px; font-weight: 800; letter-spacing: 0.01em; }
.brand-sub { margin: 2px 0 0; font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.sister-links { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.sister-links a {
  font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); text-decoration: none;
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; background: var(--panel);
}
.sister-links a:hover { color: var(--text); border-color: #3a4a7a; }

.toggle-btn {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); background: var(--panel);
  border: 1px solid var(--line); padding: 7px 12px; border-radius: 6px; cursor: pointer; transition: all .15s ease;
}
.toggle-btn:hover { color: var(--text); border-color: #3a4a7a; }
.toggle-btn.active { color: #1a1204; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.toggle-btn.primary { color: var(--text); border-color: var(--accent); }
.toggle-btn.small { padding: 5px 9px; font-size: 10.5px; }
.toggle-btn:disabled { opacity: .45; cursor: default; }

.control-label {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint);
}
.select {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text); background: var(--panel);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
.select.num { width: 110px; }
input[type="datetime-local"].select { color-scheme: dark; }
.count-note { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.hint { font-size: 12px; color: var(--text-dim); line-height: 1.55; }

/* ---------- time bar ---------- */
.timebar {
  position: relative; z-index: 3; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 8px 24px; border-bottom: 1px solid var(--line-soft); background: #070912cc;
}
.time-readout { display: flex; flex-direction: column; min-width: 250px; }
.time-main { font-family: var(--font-mono); font-size: 14px; font-weight: 500; }
.time-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); }
.time-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#btn-live.is-live { color: #8fe28f; border-color: #2f6b2f; }
.data-status { margin-left: auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); max-width: 520px; text-align: right; }
.data-status .warn { color: #fab219; }

/* ---------- main layout ---------- */
main { position: relative; z-index: 1; flex: 1; display: flex; min-height: 0; }
.view { display: none; flex: 1; min-width: 0; }
.view.active { display: flex; }
.view-split { height: calc(100vh - 118px); min-height: 520px; }

.side {
  width: 270px; flex-shrink: 0; overflow-y: auto; padding: 14px 14px 20px; border-right: 1px solid var(--line-soft);
  background: #080b16d9;
}
.side-block { margin-bottom: 18px; display: flex; flex-direction: column; gap: 7px; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; }
.side-note { font-size: 11.5px; color: var(--text-faint); line-height: 1.5; }

.search-wrap { position: relative; }
.search-wrap input { width: 100%; }
.search-results {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin-top: 4px; max-height: 320px; overflow-y: auto;
  background: var(--panel-raised); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 30px #0008;
}
.search-results button {
  display: flex; width: 100%; justify-content: space-between; gap: 8px; text-align: left; background: none; border: 0;
  color: var(--text); padding: 7px 10px; font-size: 12.5px; cursor: pointer; font-family: var(--font-display);
}
.search-results button:hover, .search-results button.hl { background: #1b2445; }
.search-results .meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); white-space: nowrap; }

.cat-list { display: flex; flex-direction: column; gap: 3px; }
.cat-row { display: grid; grid-template-columns: 16px 12px 1fr auto; align-items: center; gap: 7px; font-size: 12.5px; padding: 3px 2px; border-radius: 5px; cursor: pointer; }
.cat-row:hover { background: #121a33; }
.cat-row input { margin: 0; accent-color: var(--accent); }
.cat-row .n { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-dim); }
.cat-row .sub { display: block; font-size: 10.5px; color: var(--text-faint); }
.cat-sub { margin-left: 35px; display: flex; flex-direction: column; gap: 2px; }
.cat-sub label { font-size: 11.5px; color: var(--text-dim); display: flex; gap: 6px; align-items: center; }
.cat-sub label .n { margin-left: auto; font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); }
.swatch { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.filter-chip {
  font-size: 11.5px; color: var(--text); background: #1b2445; border: 1px solid #2c3a6b; border-radius: 8px; padding: 7px 9px;
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
}
.filter-chip button { background: none; border: 0; color: var(--text-dim); cursor: pointer; font-size: 14px; }

.seg { display: flex; gap: 10px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); }
.seg label { display: flex; gap: 4px; align-items: center; cursor: pointer; }
.seg input, .check input { accent-color: var(--accent); }
.check { font-size: 12px; color: var(--text-dim); display: flex; gap: 7px; align-items: center; cursor: pointer; }
.check.inline { align-self: flex-end; padding-bottom: 7px; }

.legend { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--text-dim); }
.legend.row { flex-direction: row; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 8px; }
.legend .item { display: flex; align-items: center; gap: 6px; }
.legend .ramp { height: 8px; border-radius: 4px; margin: 2px 0; }
.legend .ramp-labels { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 10px; }

/* ---------- stage ---------- */
.stage { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#globe-canvas { cursor: grab; touch-action: none; }
#map-canvas { cursor: crosshair; }
.hover-tip, .sel-label {
  position: absolute; z-index: 5; pointer-events: none; transform: translate(12px, -50%);
  font-family: var(--font-mono); font-size: 11px; color: var(--text); white-space: nowrap;
  background: #0c1020e6; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px;
}
.hover-tip .k { color: var(--text-dim); }
.sel-label { border-color: #c9850099; }
.stage-caption {
  position: absolute; left: 14px; bottom: 12px; z-index: 4; max-width: 60%;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); pointer-events: none;
}
.stage-tools { position: absolute; right: 12px; bottom: 10px; z-index: 4; display: flex; gap: 6px; }

/* ---------- info panel ---------- */
.info-panel {
  width: 330px; flex-shrink: 0; overflow-y: auto; padding: 16px 16px 24px; border-left: 1px solid var(--line-soft);
  background: #080b16d9;
}
.info-type { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-dim); margin: 0 0 8px; }
.info-title { margin: 0 0 2px; font-size: 19px; font-weight: 800; line-height: 1.2; }
.info-sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); margin: 0 0 10px; }
.tag { display: inline-flex; gap: 6px; align-items: center; font-family: var(--font-mono); font-size: 10.5px; color: var(--text); border: 1px solid var(--line); border-radius: 20px; padding: 2px 8px; margin: 0 4px 4px 0; }
.tag.warn { border-color: #6b5320; color: #fab219; }
.stat-section { margin-top: 14px; }
.stat-section h4 { margin: 0 0 4px; font-family: var(--font-mono); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint); }
.stat-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 4px 0; border-bottom: 1px solid var(--line-soft); }
.stat-row .k { color: var(--text-dim); white-space: nowrap; }
.stat-row .v { font-family: var(--font-mono); color: var(--text); text-align: right; }
.info-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 11px; text-decoration: none;
  color: var(--text); background: var(--panel-raised); border: 1px solid #2c3a6b; border-radius: 6px; padding: 6px 9px; cursor: pointer;
}
.link-btn:hover { border-color: var(--accent); }
.about { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }
.mini-list { font-size: 12px; color: var(--text-dim); display: flex; flex-direction: column; gap: 2px; max-height: 180px; overflow-y: auto; }
.mini-list button { background: none; border: 0; padding: 2px 0; text-align: left; color: #86b6ef; cursor: pointer; font-size: 12px; font-family: var(--font-display); }
.overview { margin-top: 12px; }

/* ---------- pages (passes, debris, shells, history) ---------- */
.page { flex: 1; max-width: 1180px; margin: 0 auto; padding: 22px 24px 40px; min-width: 0; }
.page-head h2 { margin: 0 0 6px; font-size: 22px; font-weight: 800; }
.lede { margin: 0 0 18px; color: var(--text-dim); font-size: 13.5px; line-height: 1.6; max-width: 820px; }
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; }

.passes-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; margin-top: 8px; }
.skyplot-wrap { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px; align-self: start; position: sticky; top: 12px; }
#skyplot { width: 100%; height: auto; display: block; margin: 6px 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
.data-table th { text-align: left; font-family: var(--font-mono); font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); padding: 6px 8px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 7px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.data-table td.num, .data-table th.num { text-align: right; font-family: var(--font-mono); }
.data-table tbody tr { cursor: pointer; }
.data-table tbody tr:hover, .data-table tbody tr.sel { background: #121a33; }
.data-table .day-row td { background: #0a0e1c; color: var(--text-dim); font-family: var(--font-mono); font-size: 11px; cursor: default; }
.vis-yes { color: #8fe28f; } .vis-no { color: var(--text-faint); }

.event-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.event-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; }
.chart-card { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; position: relative; }
.chart-title { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; }
.chart-sub { font-size: 11.5px; color: var(--text-dim); margin-bottom: 6px; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.tile { background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; padding: 12px 14px; }
.tile .big { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.tile .lbl { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
#shell-canvas { width: 100%; height: 460px; display: block; }
svg text { font-family: var(--font-mono); }
.axis text { fill: var(--text-faint); font-size: 10px; }
.axis line, .axis path { stroke: var(--line); }
.gridline { stroke: var(--line-soft); }
.chart-tip {
  position: fixed; z-index: 50; pointer-events: none; background: #0c1020f2; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; color: var(--text); min-width: 150px; box-shadow: 0 10px 30px #0009;
}
.chart-tip .t { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); margin-bottom: 4px; }
.chart-tip .r { display: flex; justify-content: space-between; gap: 14px; font-family: var(--font-mono); font-size: 11px; }
.chart-tip .r span:first-child { display: flex; align-items: center; gap: 6px; color: var(--text-dim); }
.owner-table .bars { display: flex; gap: 2px; align-items: center; height: 14px; }
.owner-table .bar { height: 8px; flex: none; }
.owner-table .bar:last-child { border-radius: 0 4px 4px 0; }

.footer { position: relative; z-index: 1; padding: 10px 24px; font-size: 11px; color: var(--text-faint); border-top: 1px solid var(--line-soft); }

@media (max-width: 1100px) {
  .info-panel { width: 280px; }
  .side { width: 230px; }
  .passes-layout, .event-grid { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .view-split { flex-direction: column; height: auto; }
  .side, .info-panel { width: auto; border: 0; max-height: none; }
  .stage { height: 70vh; flex: none; }
  .data-status { margin-left: 0; text-align: left; }
}
