:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #080c0f;
  color: #d9e0dc;
  --bg: #080c0f;
  --panel: #10161a;
  --panel-2: #151c21;
  --panel-3: #1b242a;
  --line: rgba(224, 235, 226, 0.1);
  --line-strong: rgba(224, 235, 226, 0.17);
  --text: #d9e0dc;
  --muted: #8f9a92;
  --faint: #626c65;
  --green: #63d889;
  --amber: #e0ad5b;
  --gold: #f5cb62;
  --red: #d36d61;
  --blue: #79d3ef;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

::selection {
  background: rgba(99, 216, 137, 0.28);
}

.shell {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(420px, 1.5fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 56px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #11171b, #0c1114);
}

.brand-block {
  min-width: 0;
}

h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: 18px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.subhead {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.metric {
  min-width: 0;
  min-height: 42px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.metric span {
  display: block;
  color: var(--faint);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-state {
  justify-self: end;
  min-width: 94px;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
}

.connection-connected {
  color: var(--green);
  border-color: rgba(99, 216, 137, 0.35);
}

.connection-error,
.connection-disconnected {
  color: var(--amber);
}

.ops-layout {
  display: grid;
  grid-template-columns: 370px minmax(360px, 1fr) 360px;
  flex: 1;
  min-height: 0;
}

.left-rail,
.right-rail {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.left-rail {
  border-right: 1px solid var(--line-strong);
}

.right-rail {
  border-left: 1px solid var(--line-strong);
  overflow: auto;
}

.center-panel {
  min-width: 0;
  min-height: 0;
  background: #05080a;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

#search {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--text);
  outline: none;
}

#search:focus {
  border-color: rgba(121, 211, 239, 0.55);
}

.segments {
  display: inline-grid;
  grid-auto-flow: column;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
}

.segment {
  min-width: 0;
  height: 34px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.segment:last-child {
  border-right: 0;
}

.segment:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.segment.active {
  color: #10161a;
  background: var(--gold);
}

.segments.compact .segment {
  height: 28px;
  min-width: 54px;
  padding: 0 9px;
  font-size: 11px;
}

.receiver-summary,
.aggregate-summary {
  border-bottom: 1px solid var(--line-strong);
  background: var(--bg);
}

.receiver-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
}

.receiver-summary-head strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
}

.eyebrow {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.receiver-cards {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px;
}

.receiver-row {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 7px 8px;
  background: transparent;
  text-align: left;
}

.receiver-row:hover {
  background: var(--panel);
}

.receiver-row.active {
  border-color: var(--line-strong);
  background: var(--panel-2);
}

.receiver-color {
  width: 9px;
  height: 9px;
  flex: none;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px rgba(99, 216, 137, 0.35);
}

.receiver-color-all {
  background: var(--gold);
  box-shadow: 0 0 8px rgba(245, 203, 98, 0.35);
}

.receiver-row-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.receiver-row-main strong {
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receiver-row-main span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receiver-health {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.receiver-health span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.receiver-health-live {
  color: var(--green);
  border-color: rgba(99, 216, 137, 0.35);
}

.receiver-health-live span {
  background: var(--green);
}

.receiver-health-recent span,
.receiver-health-queued span {
  background: var(--amber);
}

.receiver-health-error span {
  background: var(--red);
}

.receiver-only {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 12px 12px;
  color: var(--muted);
  font-size: 12px;
}

.receiver-only input {
  accent-color: var(--gold);
}

.receiver-only input:disabled + span {
  opacity: 0.42;
}

.empty-card,
.empty {
  color: var(--muted);
}

.scope-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.scope-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 54px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-strong);
  background: rgba(8, 12, 15, 0.94);
}

.scope-head h2 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.05;
}

.scope-summary {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.scope-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.scope-canvas-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 50%, #10191c 0%, #06090b 68%),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(255, 255, 255, 0.018) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(255, 255, 255, 0.018) 39px 40px);
}

.map-base,
.map-fallback,
.map-scrim,
.radar-canvas {
  position: absolute;
  inset: 0;
}

.map-base {
  z-index: 0;
}

.maplibregl-map,
.maplibregl-canvas-container,
.maplibregl-canvas {
  width: 100%;
  height: 100%;
}

.map-fallback {
  z-index: 1;
  background:
    radial-gradient(circle at 50% 50%, rgba(17, 29, 32, 0.95) 0%, rgba(6, 9, 11, 0.98) 70%),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(255, 255, 255, 0.02) 39px 40px),
    repeating-linear-gradient(90deg, transparent 0 39px, rgba(255, 255, 255, 0.02) 39px 40px);
}

.map-scrim {
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(6, 9, 11, 0.06), rgba(6, 9, 11, 0.5));
}

#scope-canvas,
.radar-canvas {
  z-index: 3;
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  cursor: crosshair;
  touch-action: manipulation;
}

.map-badge {
  position: absolute;
  z-index: 4;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 10px;
  border: 1px solid rgba(224, 173, 91, 0.4);
  border-radius: 6px;
  background: rgba(16, 22, 26, 0.92);
  color: var(--amber);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

.scope-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 36px;
  padding: 8px 12px;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.scope-footer span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 0;
  background: var(--bg);
}

table {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  font-family: var(--mono);
}

th,
td {
  height: 30px;
  padding: 0 8px;
  border-bottom: 1px solid rgba(224, 235, 226, 0.055);
  text-align: right;
  font-size: 12px;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 32px;
  background: #0c1114;
  color: var(--faint);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sort {
  min-height: 26px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-transform: inherit;
}

.sort:hover,
.sort.active {
  color: var(--text);
}

.sort.active::after {
  content: " ↑";
}

.sort.active.desc::after {
  content: " ↓";
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: var(--panel);
}

tbody tr.selected {
  background: rgba(245, 203, 98, 0.1);
  box-shadow: inset 2px 0 0 var(--gold);
}

tbody tr.selected td:first-child {
  color: var(--gold);
}

.freshness {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  min-width: 52px;
}

.freshness-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--faint);
}

.freshness-live .freshness-dot {
  background: var(--green);
  box-shadow: 0 0 7px rgba(99, 216, 137, 0.5);
}

.freshness-recent .freshness-dot {
  background: var(--amber);
}

.freshness-age,
.freshness-stale,
.freshness-expired,
.freshness-unknown {
  color: var(--muted);
}

.details {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.details-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border-bottom: 1px solid var(--line-strong);
}

.details-title {
  min-width: 0;
}

.details-head h2 {
  margin: 4px 0 0;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 20px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.details-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.details-badges .freshness,
.decode-badge {
  justify-content: flex-start;
  min-width: 0;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 11px;
}

.decode-badge {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-weight: 700;
}

.decode-badge-updated {
  color: var(--green);
  border-color: rgba(99, 216, 137, 0.35);
}

.decode-badge-partial {
  color: var(--amber);
  border-color: rgba(224, 173, 91, 0.35);
}

.decode-badge-rejected {
  color: var(--red);
  border-color: rgba(211, 109, 97, 0.35);
}

.close {
  width: 28px;
  height: 28px;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
}

.close:hover {
  color: var(--text);
  background: var(--panel);
}

.coverage-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  padding: 0;
  border-bottom: 1px solid var(--line-strong);
  background: var(--line);
}

.coverage-pill {
  min-width: 0;
  padding: 9px 10px;
  background: var(--panel);
}

.coverage-pill span {
  display: block;
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.coverage-pill strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
}

.coverage-live strong {
  color: var(--green);
}

.coverage-recent strong {
  color: var(--amber);
}

.coverage-stale strong,
.coverage-missing strong {
  color: var(--muted);
}

.details-section {
  border-bottom: 1px solid var(--line-strong);
}

h3 {
  margin: 14px 14px 9px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line);
}

.details-grid div {
  min-width: 0;
  padding: 10px 12px;
  background: var(--panel);
}

.details-grid dt {
  color: var(--faint);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.details-grid dd {
  margin: 4px 0 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.detail-field-missing dd,
.detail-field-stale dd,
.detail-field-recent dd {
  color: var(--muted);
}

.observation-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 0 12px 14px;
}

.observation-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: var(--panel);
}

.observation-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.observation-row-top strong {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.observation-age {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.observation-age-live {
  color: var(--green);
}

.observation-age-recent {
  color: var(--amber);
}

.observation-age-stale,
.observation-age-expired {
  color: var(--red);
}

.observation-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.raw-list {
  margin: 0;
  padding: 0 14px 16px 34px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.aggregate-status-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 10px;
}

.aggregate-status-grid .metric {
  min-height: 54px;
}

.footer {
  display: none;
}

#last-error {
  color: var(--amber);
  text-align: right;
}

@media (max-width: 1180px) {
  .ops-layout {
    grid-template-columns: 340px minmax(320px, 1fr);
  }

  .right-rail {
    position: fixed;
    top: 56px;
    right: 0;
    bottom: 0;
    z-index: 10;
    width: min(390px, 100vw);
    transform: translateX(0);
    box-shadow: -18px 0 40px rgba(0, 0, 0, 0.42);
  }

  .right-rail.summary-open {
    display: none;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .shell {
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  .topbar {
    grid-template-columns: 1fr;
    gap: 9px;
    align-items: stretch;
  }

  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .connection-state {
    justify-self: stretch;
  }

  .ops-layout {
    display: flex;
    flex-direction: column;
    min-height: auto;
  }

  .left-rail,
  .right-rail {
    width: 100%;
    border: 0;
  }

  .center-panel {
    order: -1;
    height: 68vh;
    min-height: 420px;
  }

  .left-rail {
    min-height: 520px;
  }

  .right-rail {
    position: static;
    box-shadow: none;
  }

  .scope-head,
  .scope-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .scope-controls {
    justify-content: stretch;
  }

  .scope-controls .segments {
    width: 100%;
  }
}
