/* -----------------------------------------------------------------------
   HFDL Launcher — Statistics Dashboard
   ----------------------------------------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #30363d;
  --text:      #c9d1d9;
  --muted:     #8b949e;
  --accent:    #58a6ff;
  --green:     #3fb950;
  --red:       #f85149;
  --yellow:    #d29922;
  --row-hover: #1f2937;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --header-h:  52px;
  --tabbar-h:  40px;
}

html, body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* ---- Header ---- */

header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
}

#status-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 13px;
  color: var(--muted);
}

.indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.indicator.connected    { background: var(--green); box-shadow: 0 0 6px var(--green); }
.indicator.disconnected { background: var(--red); }
.indicator.connecting   { background: var(--yellow); }

/* ---- Tab bar ---- */

#tab-bar {
  height: var(--tabbar-h);
  display: flex;
  align-items: stretch;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 12px;
  gap: 4px;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  padding: 0 14px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---- Tab panels ---- */

main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  display: none;
  position: absolute;
  inset: 0;
  overflow: auto;
}

.tab-panel.active {
  display: block;
}

/* Propagation tab uses flex layout — must override the generic active rule */
.prop-tab-panel.active {
  display: flex;
}

/* Map panel — no scroll, Leaflet fills it */
#tab-map {
  overflow: hidden;
}

/* ---- Zoom control — centred horizontally at the top of the MAIN map only ---- */

/* Pull the zoom control out of the topleft corner container and centre it.
   Scoped to #map so the propagation map keeps a normal top-left zoom control. */
#map .leaflet-top.leaflet-left .leaflet-control-zoom {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  /* Lay the + and − buttons side by side */
  display: flex;
  flex-direction: row;
}

/* Remove the vertical border between stacked buttons on the main map; add a vertical one */
#map .leaflet-control-zoom-in,
#map .leaflet-control-zoom-out {
  border-bottom: none !important;
  border-right: 1px solid rgba(255,255,255,0.15) !important;
  border-radius: 0 !important;
  width: 30px !important;
  height: 30px !important;
  line-height: 30px !important;
}

#map .leaflet-control-zoom-in {
  border-radius: 4px 0 0 4px !important;
}

#map .leaflet-control-zoom-out {
  border-right: none !important;
  border-radius: 0 4px 4px 0 !important;
}

/* Stats and feed panels — scrollable with padding */
#tab-stats,
#tab-feed {
  padding: 16px 20px;
}

/* ---- Map ---- */

#map {
  width: 100%;
  height: 100%;
}

/* Aircraft marker */
.ac-marker {
  font-size: 28px;
  line-height: 1;
  text-shadow: 0 0 6px rgba(0,0,0,0.9);
  color: var(--accent);
  cursor: pointer;
  user-select: none;
}

/* Permanent label shown below the aircraft icon */
.ac-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: #fff;
  background: rgba(0,0,0,0.65);
  border-radius: 3px;
  padding: 1px 4px;
  white-space: nowrap;
  pointer-events: none;
}

/* Leaflet popup override for dark theme */
.leaflet-popup-content-wrapper {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.leaflet-popup-tip {
  background: var(--surface);
}

.leaflet-popup-close-button {
  color: var(--muted) !important;
}

.ac-popup {
  font-size: 13px;
  line-height: 1.6;
  min-width: 160px;
}

.ac-popup strong {
  color: var(--accent);
  font-size: 14px;
}

.ac-popup code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green);
}

/* ---- Tables ---- */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

thead th {
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child {
  border-bottom: none;
}

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

tbody td {
  padding: 7px 12px;
  font-size: 13px;
  white-space: nowrap;
}

td.empty {
  color: var(--muted);
  font-style: italic;
  text-align: center;
  padding: 20px;
}

/* ---- Ground stations tab ---- */

#tab-gs {
  padding: 16px 20px;
}

#gs-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  color: var(--muted);
}

.gs-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

#gs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.gs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.gs-card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.gs-card-header__top {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.gs-card-header__badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.gs-id {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  flex-shrink: 0;
}

.gs-location {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.gs-freqs {
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.gs-freq {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent);
  border: 1px solid rgba(88, 166, 255, 0.25);
  border-radius: 3px;
  padding: 1px 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.gs-freq--heard {
  background: rgba(63, 185, 80, 0.15);
  color: #3fb950;
  border-color: rgba(63, 185, 80, 0.45);
}

.gs-freq--dst {
  background: rgba(210, 153, 34, 0.15);
  color: #d29922;
  border-color: rgba(210, 153, 34, 0.45);
}

.gs-freq--disabled {
  background: rgba(248, 81, 73, 0.1);
  color: #f85149;
  border-color: rgba(248, 81, 73, 0.3);
  opacity: 0.7;
}

.gs-slot {
  font-size: 10px;
  background: rgba(163, 113, 247, 0.18);
  color: #a371f7;
  border: 1px solid rgba(163, 113, 247, 0.3);
  border-radius: 2px;
  padding: 0 3px;
  line-height: 1.4;
}

.gs-card--heard {
  border-color: rgba(63, 185, 80, 0.5);
  background: linear-gradient(135deg, rgba(63, 185, 80, 0.06) 0%, var(--surface) 60%);
}

.gs-heard {
  font-size: 11px;
  color: #3fb950;
  margin-left: auto;
  white-space: nowrap;
}

.gs-no-freqs {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* Frequency table — per-GS stat rows */
.freq-cell {
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: nowrap;
  vertical-align: top;
  padding-top: 10px;
}

.gs-stat-cell {
  padding: 4px 8px;
}

.gs-stat-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 8px;
  align-items: baseline;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 12px;
}

.gs-stat-row:last-child {
  border-bottom: none;
}

.gs-stat-name {
  color: var(--text);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gs-stat-msgs {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}

.gs-stat-sig {
  font-family: var(--font-mono);
  font-size: 11px;
  white-space: nowrap;
}

.gs-stat-time {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

/* ---- Frequency table ---- */

#freq-table td:nth-child(1) {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}

#freq-table td:nth-child(2) {
  font-family: var(--font-mono);
}

.sig-good   { color: var(--green); }
.sig-ok     { color: var(--yellow); }
.sig-weak   { color: var(--red); }

/* ---- Planes table ---- */

#planes-table {
  font-size: 12px;
  width: 100%;
}

#planes-table thead th {
  font-size: 11px;
  white-space: nowrap;
}

#planes-table td.mono {
  font-family: var(--font-mono);
}

#planes-table td.dim {
  color: var(--muted);
  font-size: 11px;
}

/* ---- Live feed table ---- */

#feed-table {
  font-family: var(--font-mono);
  font-size: 12px;
}

#feed-table thead th {
  font-size: 11px;
}

#feed-table td {
  padding: 5px 10px;
}

.feed-new {
  animation: flash 0.6s ease-out;
}

@keyframes flash {
  from { background: rgba(88, 166, 255, 0.18); }
  to   { background: transparent; }
}

.slot-s { color: var(--accent); }
.slot-d { color: var(--green); }

/* ---- Ground station map markers ---- */

.gs-marker {
  position: relative;
  text-align: center;
  line-height: 1;
  filter: drop-shadow(0 0 3px rgba(0,0,0,0.7));
}

.gs-marker__label {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  background: rgba(13, 17, 23, 0.75);
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
}

/* ---- Map history panel ---- */

.map-history {
  background: rgba(13, 17, 23, 0.88);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 180px;
  max-width: 240px;
  overflow: hidden;
  font-size: 12px;
  color: var(--text);
  pointer-events: auto;
}

.map-history__title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.map-history__empty {
  color: var(--muted);
  font-style: italic;
}

.map-history__row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.map-history__row--clickable {
  cursor: pointer;
  border-radius: 3px;
  padding: 2px 3px;
  margin: 0 -3px;
  transition: background 0.15s;
}

.map-history__row--clickable:hover {
  background: rgba(88, 166, 255, 0.12);
}

.map-history__dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-history__ac {
  flex: 1;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-history__pos-count {
  color: #7ecfff;
  font-size: 11px;
  font-family: 'Courier New', monospace;
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: 4px;
}

.map-history__age {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---- Map legend ---- */

.map-legend {
  background: rgba(13, 17, 23, 0.88);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 140px;
  max-width: 220px;
  font-size: 12px;
  color: var(--text);
  pointer-events: auto;
}

.map-legend__empty {
  color: var(--muted);
  font-style: italic;
}

.map-legend__row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 0;
}

.map-legend__row--clickable {
  cursor: pointer;
  border-radius: 4px;
  padding: 2px 4px;
  margin: 0 -4px;
  transition: background 0.15s;
}

.map-legend__row--clickable:hover {
  background: rgba(255, 255, 255, 0.08);
}

.map-legend__row--selected {
  background: rgba(255, 255, 255, 0.12);
}

.map-legend__row--active .map-legend__label {
  font-weight: 700;
  color: #fff;
}

.map-legend__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.map-legend__label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Aircraft map markers ---- */

.ac-marker {
  color: var(--accent);
  text-shadow: 0 0 4px rgba(0,0,0,0.8);
  transition: opacity 0.2s;
}

.ac-marker--dim {
  opacity: 0.25;
}

.ac-marker--selected {
  color: #ffa657;
  filter: drop-shadow(0 0 6px rgba(255, 166, 87, 0.7));
}

.ac-marker--pulse {
  animation: ac-pulse 0.6s ease-out forwards;
}

@keyframes ac-pulse {
  0%   { transform: scale(1);    filter: drop-shadow(0 0 0px rgba(88, 166, 255, 0)); }
  30%  { transform: scale(1.55); filter: drop-shadow(0 0 8px rgba(88, 166, 255, 0.9)); }
  100% { transform: scale(1);    filter: drop-shadow(0 0 0px rgba(88, 166, 255, 0)); }
}

.ac-label {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 600;
  color: var(--text);
  background: rgba(13, 17, 23, 0.75);
  padding: 1px 4px;
  border-radius: 3px;
  white-space: nowrap;
  pointer-events: none;
}

/* Hide plane labels when toggled off */
.hide-ac-labels .ac-label {
  display: none;
}

/* Always show the label for the selected aircraft, even when labels are off */
.hide-ac-labels .ac-marker--selected .ac-label {
  display: block;
}

/* ---- Map stats counter (bottom-left) ---- */

.map-stats-ctrl {
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  backdrop-filter: blur(4px);
  white-space: nowrap;
}

.map-stats-ctrl__item strong {
  color: var(--accent);
}

.map-stats-ctrl__sep {
  color: var(--muted);
}

/* ---- Map layer toggle control ---- */

.map-layer-ctrl {
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 148px;
  backdrop-filter: blur(4px);
}

.map-layer-ctrl__title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}

.map-layer-ctrl__row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 2px 0;
  user-select: none;
}

.map-layer-ctrl__row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 13px;
  height: 13px;
  cursor: pointer;
  flex-shrink: 0;
}

.type-spdu  { color: var(--muted); }
.type-lpdu  { color: var(--text); }

/* ---- Map distance & bearing stats (bottom-left, above plane count) ---- */

.map-dist-stats {
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 190px;
  backdrop-filter: blur(4px);
  font-size: 12px;
  color: var(--text);
  margin-bottom: 6px;
}

.map-dist-stats__title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.map-dist-stats__count {
  font-weight: 400;
  color: var(--accent);
  text-transform: none;
  letter-spacing: 0;
}

.map-dist-stats__row {
  display: flex;
  align-items: baseline;
  gap: 5px;
  padding: 1px 0;
}

.map-dist-stats__row--arc {
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: 3px;
  padding-top: 4px;
}

.map-dist-stats__lbl {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 26px;
  flex-shrink: 0;
}

.map-dist-stats__val {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  flex-shrink: 0;
}

.map-dist-stats__sep {
  font-size: 10px;
  color: var(--muted);
  opacity: 0.5;
  flex-shrink: 0;
}

.map-dist-stats__dir {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.map-dist-stats__ac {
  font-size: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.map-dist-stats__ac--link {
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.map-dist-stats__ac--link:hover {
  color: var(--accent);
}

.map-dist-stats__band {
  font-size: 10px;
  font-family: var(--font-mono);
  color: #d2a8ff;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---- Map live activity overlay ---- */

.map-live-activity-wrap {
  margin-top: 8px;
}

.map-live-activity {
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  min-width: 148px;
  backdrop-filter: blur(4px);
  font-size: 12px;
  color: var(--text);
}

.map-live-activity__title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.map-live-activity__window {
  font-size: 10px;
  font-weight: 400;
  color: rgba(139,148,158,0.6);
  text-transform: none;
  letter-spacing: 0;
}

.map-live-activity__empty {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

.map-live-activity__row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 3px;
}

.map-live-activity__row:last-of-type {
  margin-bottom: 0;
}

.map-live-activity__row--dim .map-live-activity__label,
.map-live-activity__row--dim .map-live-activity__track {
  opacity: 0.35;
}

.map-live-activity__label {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  width: 46px;
  flex-shrink: 0;
  text-align: right;
}

.map-live-activity__track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}

.map-live-activity__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  /* No CSS transition — width is recomputed every 400 ms so it naturally
     steps down as old events age out of the 10-second window. */
}

.map-live-activity__count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent);
  width: 18px;
  flex-shrink: 0;
  text-align: right;
}

.map-live-activity__total {
  margin-top: 5px;
  padding-top: 5px;
  border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 10px;
  color: var(--muted);
  text-align: right;
}

/* ---- Map frequency band filter control ---- */

.map-freqband-ctrl {
  margin-top: 8px;
}

.map-freqband-ctrl__title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.map-freqband-ctrl__live-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  user-select: none;
}

.map-freqband-ctrl__live-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 11px;
  height: 11px;
  cursor: pointer;
  flex-shrink: 0;
}

.map-freqband-ctrl__empty {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

.map-freqband-ctrl__actions {
  display: flex;
  gap: 5px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.map-freqband-ctrl__btn {
  flex: 1;
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.3);
  border-radius: 3px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 0;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.map-freqband-ctrl__btn:hover {
  background: rgba(88, 166, 255, 0.22);
}

/* Colour-mode select row */
.map-freqband-ctrl__color-row {
  margin-bottom: 6px;
  gap: 6px;
}

.map-freqband-ctrl__color-select {
  flex: 1;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 4px;
  color: var(--fg);
  font-size: 11px;
  padding: 2px 4px;
  cursor: pointer;
  outline: none;
}

.map-freqband-ctrl__color-select:focus {
  border-color: var(--accent);
}

/* Push the count badge to the far right inside freq-band rows */
.map-freqband-ctrl .map-layer-ctrl__row {
  justify-content: space-between;
}

.map-freqband-ctrl__count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255,255,255,0.07);
  border-radius: 8px;
  padding: 0 5px;
  min-width: 16px;
  text-align: center;
  line-height: 15px;
  flex-shrink: 0;
}

/* ---- Instances tab ---- */

#instances-toolbar,
#instances-apply-buttons {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  align-items: flex-start;
}

.toolbar-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 260px;
}

.toolbar-desc {
  font-size: 11px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.toolbar-desc code {
  font-family: var(--font-mono);
  color: var(--fg);
  font-size: 10px;
}

.toolbar-btn {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.toolbar-btn:hover {
  background: rgba(88, 166, 255, 0.12);
}

.toolbar-btn--apply {
  color: var(--yellow);
  border-color: var(--yellow);
}

.toolbar-btn--apply:hover {
  background: rgba(210, 153, 34, 0.12);
}

#instances-apply-toolbar {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
  margin-bottom: 20px;
}

.toolbar-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.apply-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  line-height: 1.6;
}

.apply-hint code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  padding: 1px 5px;
}

/* ---- Apply password modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.modal-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.modal-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

.modal-input:focus {
  border-color: var(--accent);
}

.modal-error {
  font-size: 12px;
  color: var(--red);
  margin: 0;
}

.modal-error[hidden] {
  display: none;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 4px;
}

.modal-btn {
  border-radius: 5px;
  padding: 7px 18px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  border: 1px solid transparent;
}

.modal-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-btn--confirm {
  background: var(--accent);
  color: #0d1117;
  border-color: var(--accent);
}

.modal-btn--confirm:hover:not(:disabled) {
  background: #79c0ff;
  border-color: #79c0ff;
}

.modal-btn--cancel {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.modal-btn--cancel:hover:not(:disabled) {
  background: var(--row-hover);
  color: var(--text);
}

#instances-content {
  padding: 20px;
  max-width: 1100px;
}

.instances-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  margin-top: 20px;
}

.instances-section-title:first-child {
  margin-top: 0;
}

.instances-args-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  word-break: break-all;
}

.instances-args-box--empty {
  color: var(--muted);
  font-style: italic;
  font-family: inherit;
}

.instances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.instances-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.instances-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}

.instances-card__centre {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  font-family: var(--font-mono);
}

.instances-card__mode {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.instances-card__freqs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ---- Instance health status ---- */

.instances-card__health {
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.inst-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inst-reconnect-row {
  display: flex;
  align-items: center;
}

.inst-status {
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

.inst-status--running {
  background: rgba(63, 185, 80, 0.15);
  border: 1px solid rgba(63, 185, 80, 0.4);
  color: #3fb950;
}

.inst-status--stopped {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.35);
  color: #f85149;
}

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

.inst-uptime--dim {
  opacity: 0.75;
}

.inst-reconnect-badge {
  font-size: 11px;
  font-weight: 600;
  background: rgba(210, 153, 34, 0.15);
  border: 1px solid rgba(210, 153, 34, 0.4);
  color: #d29922;
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}

.instances-freq {
  background: rgba(88, 166, 255, 0.1);
  border: 1px solid rgba(88, 166, 255, 0.25);
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text);
}

.instances-freq--active {
  background: rgba(63, 185, 80, 0.15);
  border-color: rgba(63, 185, 80, 0.45);
  color: #3fb950;
}

.instances-freq--disabled {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.3);
  color: #f85149;
  opacity: 0.7;
}

.instances-disabled-freqs {
  padding: 8px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* ---- Instances — frequency overview stats ---- */

.freq-overview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 4px;
}

.freq-overview__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  padding: 4px 12px;
  border-radius: 6px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}

.freq-overview__value {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.freq-overview__label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin-top: 2px;
}

.freq-overview__stat--active .freq-overview__value  { color: var(--green); }
.freq-overview__stat--active .freq-overview__label  { color: rgba(63,185,80,0.7); }

.freq-overview__stat--inactive .freq-overview__value { color: var(--muted); }

.freq-overview__stat--disabled .freq-overview__value { color: var(--red); }
.freq-overview__stat--disabled .freq-overview__label { color: rgba(248,81,73,0.7); }

.freq-overview__bar-wrap {
  flex: 1 1 200px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: 8px;
}

.freq-overview__bar-track {
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.freq-overview__bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.freq-overview__bar-label {
  font-size: 11px;
  color: var(--muted);
}

.freq-overview__notice {
  flex: 1 1 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 6px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
}

.freq-overview__notice-icon {
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Info — neutral blue (< 24 h uptime) */
.freq-overview__notice--info {
  background: rgba(88,166,255,0.08);
  border: 1px solid rgba(88,166,255,0.28);
}
.freq-overview__notice--info .freq-overview__notice-icon { color: var(--accent); }
.freq-overview__notice--info .freq-overview__notice-text strong { color: var(--accent); }

/* Warn — amber (> 24 h, < 70% active) */
.freq-overview__notice--warn {
  background: rgba(210,153,34,0.10);
  border: 1px solid rgba(210,153,34,0.35);
}
.freq-overview__notice--warn .freq-overview__notice-icon { color: var(--yellow); }
.freq-overview__notice--warn .freq-overview__notice-text strong { color: var(--yellow); }

/* OK — green (> 24 h, ≥ 70% active) */
.freq-overview__notice--ok {
  background: rgba(63,185,80,0.08);
  border: 1px solid rgba(63,185,80,0.28);
}
.freq-overview__notice--ok .freq-overview__notice-icon { color: var(--green); }
.freq-overview__notice--ok .freq-overview__notice-text strong { color: var(--green); }

/* ---- Instances — per-MHz message count chart ---- */

.freq-overview__mhz-chart-wrap {
  flex: 1 1 100%;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.freq-overview__mhz-chart-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

.freq-overview__mhz-chart {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.freq-overview__mhz-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.freq-overview__mhz-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  width: 46px;
  flex-shrink: 0;
  text-align: right;
}

.freq-overview__mhz-bar-track {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,0.06);
  border-radius: 3px;
  overflow: hidden;
}

.freq-overview__mhz-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.freq-overview__mhz-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  width: 52px;
  flex-shrink: 0;
  text-align: right;
}

/* ---- Signal history tab ---- */

#signal-charts {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Ground-station group */
.sig-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.sig-group__header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.sig-group__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

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

.sig-group__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
  gap: 0;
  background: var(--surface);
}

.sig-chart-card {
  background: var(--surface);
  padding: 14px 16px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.sig-chart-card:last-child {
  border-right: none;
}

.sig-chart-card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.sig-chart-card canvas {
  width: 100% !important;
  height: 180px !important;
}

#signal-empty {
  padding: 40px 20px;
  color: var(--muted);
  font-style: italic;
}

/* ---- Receiver marker (SDR location) ---- */

.rx-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.rx-marker__icon {
  font-size: 20px;
  line-height: 1;
  filter: drop-shadow(0 0 3px rgba(88, 166, 255, 0.7));
}

.rx-marker__label {
  margin-top: 1px;
  font-size: 10px;
  font-weight: 700;
  color: #58a6ff;
  background: rgba(13, 17, 23, 0.82);
  border: 1px solid rgba(88, 166, 255, 0.5);
  border-radius: 3px;
  padding: 0px 3px;
  white-space: nowrap;
  letter-spacing: 0.03em;
  pointer-events: none;
}

.rx-popup {
  font-size: 13px;
  line-height: 1.6;
  min-width: 160px;
}

.rx-popup strong {
  font-size: 14px;
  color: #58a6ff;
}

.rx-popup__name {
  color: #c9d1d9;
  font-style: italic;
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    height: auto;
    padding: 8px 12px;
  }

  #status-bar {
    flex-wrap: wrap;
    gap: 10px;
  }

  #feed-table th:nth-child(n+6),
  #feed-table td:nth-child(n+6) {
    display: none;
  }
}

/* ==========================================================================
   Phase 1 additions
   ========================================================================== */

/* ---- Tab toolbar (filter bar shared by Messages and Events tabs) ---- */

.tab-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.filter-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  padding: 4px 8px;
  width: 140px;
}

.filter-input:focus {
  outline: none;
  border-color: var(--accent);
}

.filter-select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  padding: 4px 8px;
}

.filter-count {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
}

/* ---- Live Feed — message text column ---- */

.feed-msg-cell {
  max-width: 300px;
  overflow: hidden;
}

.feed-msg-text {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  cursor: default;
}

/* ---- Messages tab ---- */

#messages-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#messages-table th,
#messages-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

#messages-table th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

#messages-table tbody tr:hover {
  background: var(--row-hover);
}

.msg-text-col {
  width: 50%;
}

.msg-text-cell {
  max-width: 0; /* forces text-overflow to work in table cell */
}

.msg-text-content {
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  display: block;
  max-height: 4.5em;
  overflow: hidden;
  cursor: default;
}

.msg-label {
  font-weight: 600;
  color: var(--accent);
}

/* Human-readable label cell in Messages tab */
.msg-label-cell {
  font-size: 12px;
  white-space: nowrap;
  min-width: 140px;
  color: var(--accent);
  font-weight: 600;
}

/* Sublabel cell — slightly narrower, muted for unknown codes */
.msg-sublabel-cell {
  font-size: 12px;
  white-space: nowrap;
  min-width: 110px;
}

/* Weather rows — label H1 / sublabel WX */
.msg-row--weather {
  background: rgba(88, 166, 255, 0.06);
}

.msg-row--weather .msg-label {
  color: #79c0ff;
}

/* ---- Events tab ---- */

#events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#events-table th,
#events-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

#events-table th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

#events-table tbody tr:hover {
  background: var(--row-hover);
}

.evt-row--logon  { background: rgba(63, 185, 80, 0.07); }
.evt-row--logoff { background: rgba(248, 81, 73, 0.07); }
.evt-row--gs     { background: rgba(210, 153, 34, 0.10); }

/* ---- Toast notification system ---- */

#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 420px;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--yellow);
  border-radius: 6px;
  padding: 10px 14px;
  color: var(--text);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: all;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  animation: toast-slide-in 0.25s ease;
}

.toast--new {
  animation: none;
  opacity: 0;
  transform: translateX(20px);
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast-msg {
  flex: 1;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

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

/* ==========================================================================
   Phase 3 additions
   ========================================================================== */

/* ---- Planes tab — link quality error rate ---- */

.err-rate {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 1px 4px;
  border-radius: 3px;
}

.err-low  { color: var(--green); }
.err-mid  { color: var(--yellow); }
.err-high { color: var(--red); }

/* ---- Map top bar (view toggle + search, centred) ---- */

#map-top-bar {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: all;
}

/* View toggle button */
.map-view-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  transition: border-color 0.15s, color 0.15s;
  line-height: 1.4;
}

.map-view-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Globe sub-controls — below the top bar, centred, hidden by default */
#globe-controls {
  position: absolute;
  top: 54px; /* 12px top + ~34px bar height + 8px gap */
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  display: none;
  align-items: center;
  gap: 6px;
  pointer-events: all;
}

#globe-controls.globe-controls--visible {
  display: flex;
}

/* Spin button active state */
.toolbar-btn.spin-active {
  box-shadow: 0 0 0 1px var(--accent);
  color: var(--accent);
  border-color: var(--accent);
}

/* Globe container — same footprint as #map, hidden by default.
   isolation:isolate creates a new stacking context so the Three.js canvas
   inside cannot escape and cover sibling overlay elements.
   z-index:1 keeps the container below the overlay controls (z-index:1002). */
#globe-container {
  position: absolute;
  inset: 0;
  display: none;
  background: #000;
  z-index: 1;
  isolation: isolate;
}

#globe-container.globe-visible {
  display: block;
}

/* ---- Globe hover tooltip ---- */

.globe-tooltip {
  position: fixed;
  z-index: 9000;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  max-width: 280px;
  white-space: normal;
}

.globe-tooltip strong {
  color: var(--accent);
  font-size: 14px;
}

.globe-tooltip code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green);
}

/* ---- Map search bar overlay ---- */

#map-search-bar {
  /* positioning now handled by #map-top-bar parent */
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  pointer-events: all;
}

.map-search-input {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 13px;
  width: 200px;
  outline: none;
}

.map-search-input::placeholder {
  color: var(--muted);
}

.map-search-clear {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
}

.map-search-clear:hover {
  color: var(--text);
}

/* ---- Map RA alert box ---- */

#map-ra-alert {
  position: absolute;
  top: 58px; /* below the search bar (12px top + ~34px height + 12px gap) */
  left: 50%;
  transform: translateX(-50%);
  z-index: 1002;
  min-width: 320px;
  max-width: 520px;
  background: rgba(13, 17, 23, 0.95);
  border: 2px dashed var(--red);
  border-radius: 6px;
  padding: 10px 36px 10px 14px;
  box-shadow: 0 2px 12px rgba(248, 81, 73, 0.35);
  pointer-events: all;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

#map-ra-alert-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 2px 4px;
}

#map-ra-alert-close:hover {
  color: var(--red);
}

.map-ra-alert__title {
  font-weight: 600;
  color: var(--red);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-ra-alert__row {
  color: var(--muted);
  font-size: 12px;
}

.map-ra-alert__row span {
  color: var(--text);
}

.map-ra-alert__msg {
  margin-top: 5px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  word-break: break-word;
}

/* ---- Live Feed — row colour coding by LPDU type (Section 7.1) ---- */

.feed-row--logon  { background: rgba(63, 185, 80, 0.07); }
.feed-row--logoff { background: rgba(248, 81, 73, 0.07); }

/* ---- Ground Stations tab — active slots row (Section 7.3) ---- */

.gs-active-slots {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid var(--border);
}

.gs-active-slots__label {
  font-size: 10px;
  color: var(--muted);
  margin-right: 2px;
  flex-shrink: 0;
}

.gs-freq--active-slot {
  background: rgba(63, 185, 80, 0.12);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.35);
  font-weight: 600;
}

/* ---- Link Quality tab ---- */

#lq-content {
  overflow: auto;
  padding: 0;
}

.lq-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.lq-table th,
.lq-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.lq-table th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.lq-table tbody tr:hover {
  background: var(--row-hover);
}

.lq-spark {
  min-width: 84px;
  padding: 2px 4px !important;
}

.lq-sparkline {
  display: block;
  vertical-align: middle;
}

.lq-spark-empty {
  color: var(--muted);
  font-size: 12px;
}

/* ---- Propagation line tooltip ---- */

.prop-line-tooltip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 4px;
}

/* ==========================================================================
   Phase 4 additions
   ========================================================================== */

/* ---- Ground Stations tab — heard-by badge ---- */

.gs-heardby-badge {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  color: var(--accent);
  border: 1px solid rgba(88, 166, 255, 0.3);
}

/* ---- Propagation tab ---- */

.prop-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.prop-summary__stat {
  font-size: 13px;
  color: var(--muted);
}

.prop-summary__updated {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}

.prop-matrix-wrap {
  overflow-x: auto;
}

.prop-matrix {
  border-collapse: collapse;
  font-size: 12px;
  min-width: 400px;
}

.prop-matrix th,
.prop-matrix td {
  border: 1px solid var(--border);
  padding: 4px 8px;
  text-align: center;
  vertical-align: middle;
}

.prop-matrix th {
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.prop-ac-col {
  text-align: left !important;
  min-width: 120px;
}

.prop-gs-col {
  min-width: 60px;
}

.prop-gs-name {
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}

.prop-ac-cell {
  text-align: left !important;
  color: var(--text);
  white-space: nowrap;
}

.prop-cell {
  font-size: 11px;
  font-weight: 600;
}

.prop-cell--strong { background: rgba(63, 185, 80, 0.20); color: var(--green); }
.prop-cell--ok     { background: rgba(63, 185, 80, 0.08); color: var(--green); }
.prop-cell--weak   { background: rgba(210, 153, 34, 0.10); color: var(--yellow); }
.prop-cell--none   { background: transparent; color: transparent; }

.prop-sig {
  font-size: 9px;
  font-weight: 400;
  color: var(--muted);
  line-height: 1;
}

/* ==========================================================================
   Phase 2 additions
   ========================================================================== */

/* ---- Ground Stations tab — SPDU badges ---- */

.gs-spdu-badge {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  font-weight: 600;
}

.gs-spdu-badge--active {
  background: rgba(63, 185, 80, 0.15);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.4);
}

.gs-sync-badge {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
}

.gs-sync-badge--ok {
  color: var(--green);
}

.gs-sync-badge--bad {
  color: var(--red);
}

.gs-card--spdu {
  border-color: rgba(63, 185, 80, 0.3);
}

.gs-freq-net-dot {
  color: var(--green);
  font-size: 16px;
  line-height: 0;
  vertical-align: middle;
  margin: 0 1px;
}

/* ---- dumphfdl version label in status bar ---- */

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

/* ---- Network tab ---- */

#network-grid {
  padding: 12px 16px;
  overflow-y: auto;
}

.net-summary {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.net-summary__stat {
  font-size: 13px;
  color: var(--muted);
}

.net-summary__stat--active {
  color: var(--green);
  font-weight: 600;
}

.net-summary__updated {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}

.net-gs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.net-gs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  opacity: 0.65;
  transition: opacity 0.2s;
}

.net-gs-card--active {
  opacity: 1;
  border-color: rgba(63, 185, 80, 0.35);
}

.net-gs-card__header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.net-gs-id {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  flex-shrink: 0;
}

.net-gs-loc {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.net-gs-card__badges {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.net-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 600;
}

.net-badge--active {
  background: rgba(63, 185, 80, 0.15);
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.4);
}

.net-badge--inactive {
  background: rgba(139, 148, 158, 0.1);
  color: var(--muted);
  border: 1px solid var(--border);
}

.net-badge--sync {
  color: var(--green);
  border: 1px solid rgba(63, 185, 80, 0.3);
}

.net-badge--nosync {
  color: var(--red);
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.net-badge--stale {
  color: var(--muted);
  border: 1px solid rgba(139, 148, 158, 0.25);
}

.net-last-seen {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
}

.net-gs-card__freqs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.net-freq {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(139, 148, 158, 0.1);
  color: var(--muted);
  border: 1px solid var(--border);
}

.net-freq--active {
  background: rgba(63, 185, 80, 0.12);
  color: var(--green);
  border-color: rgba(63, 185, 80, 0.35);
  font-weight: 600;
}

.net-slot {
  font-size: 9px;
  color: var(--muted);
  margin-left: 2px;
}

.net-no-freqs {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* ==========================================================================
   Aircraft change notification (bottom-centre of map)
   ========================================================================== */

.map-ac-notif {
  /* Direct child of the map container (position:relative), so centering works */
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  /* Appearance */
  background: rgba(22, 27, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  pointer-events: none;
  /* Hidden by default */
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 1000;
}

.map-ac-notif--visible {
  opacity: 1;
}

.map-ac-notif--new     { border-color: #3fb950; }
.map-ac-notif--update  { border-color: #58a6ff; }
.map-ac-notif--removed { border-color: #f78166; }

.map-ac-notif--new     .map-ac-notif__icon { color: #3fb950; }
.map-ac-notif--update  .map-ac-notif__icon { color: #58a6ff; }
.map-ac-notif--removed .map-ac-notif__icon { color: #f78166; }

.map-ac-notif__icon  { font-size: 11px; font-weight: 600; }
.map-ac-notif__label { font-family: var(--font-mono); font-size: 12px; }

/* ==========================================================================
   Planes tab — aircraft activity chart
   ========================================================================== */

/* Clickable rows in the Planes tab */
.planes-row--clickable {
  cursor: pointer;
  transition: background 0.1s;
}
.planes-row--clickable:hover {
  background: rgba(88, 166, 255, 0.08);
}

.planes-activity-chart {
  width: 100%;
  height: 96px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 6px 8px 4px;
  box-sizing: border-box;
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
}

/* Left Y-axis column */
.planes-activity-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  width: 28px;
  flex-shrink: 0;
  padding-right: 4px;
  padding-bottom: 0;
}

.planes-activity-tick {
  font-size: 9px;
  color: var(--muted, #8b949e);
  line-height: 1;
  user-select: none;
}

/* Bars area — positioned relative so guide lines can be absolute */
.planes-activity-bars-wrap {
  flex: 1;
  position: relative;
  height: 100%;
}

/* Faint horizontal guide lines at 50% and 100% */
.planes-activity-guide {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(139,148,158,0.18);
  pointer-events: none;
}

.planes-activity-bars {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 100%;
  width: 100%;
}

.planes-activity-bar {
  flex: 1;
  min-width: 2px;
  border-radius: 1px 1px 0 0;
  cursor: default;
  transition: opacity 0.15s;
}

.planes-activity-bar:hover {
  opacity: 0.75;
}

/* -----------------------------------------------------------------------
   Aircraft detail side panel
   ----------------------------------------------------------------------- */

.ac-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  pointer-events: none;
}

.ac-panel--open {
  transform: translateX(0);
  pointer-events: auto;
}

/* Header */
.ac-panel__header {
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.ac-panel__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ac-panel__callsign {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ac-panel__close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
}

.ac-panel__close:hover {
  background: var(--border);
  color: var(--text);
}

.ac-panel__subtitle {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  min-height: 14px;
}

/* Photo */
.ac-panel__photo-wrap {
  flex-shrink: 0;
  position: relative;
}

.ac-panel__photo-link {
  display: block;
}

.ac-panel__photo {
  width: 100%;
  display: block;
  object-fit: cover;
  max-height: 160px;
}

.ac-panel__photo-credit {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.6);
  color: #c9d1d9;
  font-size: 10px;
  padding: 3px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Photo loading skeleton */
.ac-panel__photo-skeleton {
  width: 100%;
  height: 120px;
  background: linear-gradient(90deg, var(--border) 25%, #21262d 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: ac-panel-shimmer 1.4s infinite;
  flex-shrink: 0;
}

.ac-panel__photo-skeleton[hidden] {
  display: none;
}

@keyframes ac-panel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Enrichment row (operator / type from Hexdb) */
.ac-panel__enrich {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex-shrink: 0;
}

.ac-panel__enrich[hidden] {
  display: none;
}

.ac-panel__enrich-operator {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ac-panel__enrich-type {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Data grid */
.ac-panel__data {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0;
  padding: 8px 0;
  flex-shrink: 0;
}

.ac-panel__data dt,
.ac-panel__data dd {
  padding: 3px 12px;
  font-size: 12px;
  line-height: 1.4;
  border-bottom: 1px solid rgba(48,54,61,0.5);
}

.ac-panel__data dt {
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}

.ac-panel__data dd {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Hide rows whose dd is "—" (empty/unknown) */
.ac-panel__data dt.ac-panel--hidden,
.ac-panel__data dd.ac-panel--hidden {
  display: none;
}

/* ==========================================================================
   Propagation tab — visual map rewrite
   ========================================================================== */

/* ---- Tab panel layout ---- */

.prop-tab-panel {
  /* display is controlled by .tab-panel (none) / .prop-tab-panel.active (flex) */
  flex-direction: column;
  overflow-y: auto;   /* allow the whole tab to scroll so the matrix is reachable */
}

/* ---- Map toolbar ---- */

.prop-map-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.prop-toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.prop-toolbar-group--right {
  margin-left: auto;
  gap: 10px;
}

.prop-toolbar-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Mode buttons */
.prop-mode-btns {
  display: flex;
  gap: 2px;
}

.prop-mode-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.prop-mode-btn:hover {
  background: var(--row-hover);
  color: var(--text);
}

.prop-mode-btn--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Band / GS selects */
.prop-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
}

.prop-select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Layer toggles */
.prop-layer-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}

.prop-layer-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

/* Updated timestamp */
.prop-map-updated {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---- Propagation map ---- */

#prop-map {
  height: 420px;
  flex-shrink: 0;
  background: #0d1117;
  z-index: 0;
}

/* ---- Map tooltip ---- */

.prop-map-tooltip {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  font-size: 12px !important;
  padding: 4px 8px !important;
  border-radius: 4px !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4) !important;
}

/* ---- Legend control ---- */

.prop-legend {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 11px;
  min-width: 160px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
}

.prop-legend__title {
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 5px;
}

.prop-legend__divider {
  border-top: 1px solid var(--border);
  margin: 6px 0;
}

.prop-legend__row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  margin-bottom: 3px;
  font-size: 11px;
}

.prop-legend__row--click:hover {
  background: var(--hover, rgba(255,255,255,0.06));
  border-radius: 3px;
}

.prop-legend__hint {
  font-size: 9px;
  font-weight: 400;
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
  opacity: 0.7;
}

.prop-legend__swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  flex-shrink: 0;
}

.prop-legend__line {
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: 1px;
  flex-shrink: 0;
}

/* ---- Sample count control ---- */

.prop-sample-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--muted);
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* ---- GS markers on prop map ---- */

.prop-gs-marker {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 18px;
  line-height: 1;
  cursor: default;
}

.prop-gs-marker__label {
  font-size: 9px;
  color: var(--text);
  background: rgba(13,17,23,0.75);
  border-radius: 2px;
  padding: 1px 3px;
  white-space: nowrap;
  margin-top: 1px;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Matrix section below map ---- */

.prop-matrix-section {
  /* No overflow:auto here — the parent .prop-tab-panel scrolls instead */
  border-top: 1px solid var(--border);
}

.prop-matrix-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.prop-matrix-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.prop-matrix-filter-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

#propagation-grid {
  padding: 10px 14px;
  overflow: auto;
}
