:root {
  --panel-bg: rgba(20, 24, 26, 0.94);
  --panel-border: rgba(255, 255, 255, 0.16);
  --panel-text: #f4f7f8;
  --panel-muted: #9facb2;
  --accent: #20c7b5;
  --accent-strong: #00a28d;
  --warn: #f0b84b;
  --danger: #ee6c4d;
  --row-hover: rgba(255, 255, 255, 0.08);
  --row-selected: rgba(32, 199, 181, 0.2);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html,
body,
.radar-app,
.radar-map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #101415;
  color: var(--panel-text);
}

button {
  font: inherit;
}

.radar-map {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.flight-panel {
  position: fixed;
  top: 5vh;
  left: 16px;
  z-index: 600;
  width: min(380px, calc((100vw - 56px) / 2));
  height: min(90vh, calc(100vh - 32px));
  min-width: min(280px, calc((100vw - 56px) / 2));
  max-width: calc((100vw - 56px) / 2);
  max-height: calc(100vh - 32px);
  resize: both;
  overflow: auto;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.flight-detail-panel {
  position: fixed;
  top: 5vh;
  right: 16px;
  z-index: 610;
  width: min(360px, calc((100vw - 56px) / 2));
  min-width: min(280px, calc((100vw - 56px) / 2));
  max-width: calc((100vw - 56px) / 2);
  max-height: calc(100vh - 32px);
  resize: both;
  overflow: auto;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.flight-detail-panel[hidden] {
  display: none;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 12px 10px 14px;
  cursor: move;
  user-select: none;
  border-bottom: 1px solid var(--panel-border);
}

.panel-header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
}

.panel-header h2 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0;
}

.connection-status {
  margin: 3px 0 0;
  color: var(--panel-muted);
  font-size: 12px;
}

.connection-status[data-state="online"] {
  color: var(--accent);
}

.connection-status[data-state="warning"] {
  color: var(--warn);
}

.connection-status[data-state="offline"] {
  color: var(--danger);
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.panel-actions button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--panel-text);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.panel-actions button:hover {
  border-color: var(--accent);
  background: rgba(32, 199, 181, 0.18);
}

.flight-panel.is-minimised,
.flight-detail-panel.is-minimised {
  resize: none;
  overflow: hidden;
  width: 280px !important;
  height: auto !important;
  min-height: 0;
}

.flight-panel.is-minimised .panel-body {
  display: none;
}

.flight-detail-panel.is-minimised .detail-panel-body {
  display: none;
}

.panel-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
}

.summary-strip {
  display: grid;
  grid-template-columns: 0.7fr 1.2fr 0.8fr;
  gap: 8px;
}

.summary-strip div {
  min-width: 0;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.summary-strip span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  font-weight: 700;
}

.summary-strip small {
  color: var(--panel-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.table-wrap {
  min-height: 160px;
  flex: 1 1 auto;
  max-height: none;
  overflow: auto;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.flight-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.flight-table th,
.flight-table td {
  padding: 8px 9px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  white-space: nowrap;
}

.flight-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--panel-muted);
  background: #151a1c;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.flight-table th button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-transform: inherit;
}

.flight-table th button:hover {
  color: var(--panel-text);
}

.flight-table tbody tr {
  cursor: pointer;
}

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

.flight-table tbody tr.is-selected {
  background: var(--row-selected);
}

.flight-table .empty-row td {
  color: var(--panel-muted);
  text-align: center;
  cursor: default;
}

.detail-panel-body {
  padding: 10px;
}

.flight-detail {
  display: grid;
  gap: 8px;
}

.detail-empty {
  color: var(--panel-muted);
  font-size: 13px;
}

.detail-section {
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.detail-section summary {
  padding: 8px 10px;
  cursor: pointer;
  color: var(--panel-text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  user-select: none;
}

.detail-section summary::marker {
  color: var(--accent);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 0 10px 10px;
}

.detail-grid div {
  min-width: 0;
}

.detail-grid span {
  display: block;
  color: var(--panel-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.detail-grid strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.detail-grid .wind-value {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  color: var(--panel-text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  text-transform: none;
  vertical-align: top;
}

.detail-grid .wind-direction,
.detail-grid .wind-arrow,
.detail-grid .wind-speed {
  display: inline-block;
  color: inherit;
  font-size: inherit;
  text-transform: none;
}

.wind-arrow {
  transform: rotate(var(--wind-arrow-rotation));
  transform-origin: center;
}

.wind-arrow.is-missing {
  color: var(--panel-muted);
}

.route-context,
.route-context-empty {
  margin: 0;
}

.route-context-empty {
  padding: 0 10px 10px;
  color: var(--panel-muted);
  font-size: 13px;
}

.route-context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 10px 8px;
}

.route-context-header strong,
.route-context-header span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-context-header strong {
  font-size: 13px;
}

.route-context-header span {
  color: var(--panel-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.route-detail-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.route-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 10px 10px;
}

.route-badges span {
  max-width: 100%;
  overflow: hidden;
  border: 1px solid rgba(240, 184, 75, 0.42);
  border-radius: 6px;
  padding: 3px 6px;
  color: #ffe4a3;
  background: rgba(240, 184, 75, 0.12);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.map-message {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 650;
  max-width: min(440px, calc(100vw - 32px));
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  color: var(--panel-text);
  font-size: 13px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.map-message.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.aircraft-marker {
  --marker-rotation: 0deg;
  --marker-fill: var(--accent);
  --marker-outline: rgba(4, 17, 18, 0.82);
  --marker-glow: rgba(0, 0, 0, 0.34);
  position: relative;
  width: 26px;
  height: 26px;
  transform: rotate(var(--marker-rotation));
  transform-origin: center;
}

.aircraft-marker::before {
  content: "";
  position: absolute;
  inset: -4px;
  border: 2px solid transparent;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 120ms ease;
}

.aircraft-marker-glyph {
  display: block;
  width: 26px;
  height: 26px;
  filter: drop-shadow(0 5px 10px var(--marker-glow));
}

.aircraft-marker-halo {
  fill: none;
  stroke: var(--marker-outline);
  stroke-linejoin: round;
  stroke-width: 4px;
}

.aircraft-marker-body {
  fill: var(--marker-fill);
  stroke: rgba(255, 255, 255, 0.55);
  stroke-linejoin: round;
  stroke-width: 0.7px;
}

.aircraft-marker.is-selected {
  --marker-fill: var(--warn);
}

.aircraft-marker.is-selected::before {
  border-color: rgba(240, 184, 75, 0.9);
  box-shadow: 0 0 0 2px rgba(4, 17, 18, 0.68);
  opacity: 1;
}

.aircraft-marker.is-landed {
  --marker-fill: #cfd7d9;
  opacity: 0.7;
}

.aircraft-marker.is-stale {
  --marker-fill: #9facb2;
  opacity: 0.58;
}

.aircraft-marker.is-stale::before {
  border-color: rgba(159, 172, 178, 0.82);
  border-style: dashed;
  opacity: 1;
}

.leaflet-tooltip.aircraft-label {
  border: 1px solid rgba(0, 0, 0, 0.25);
  border-radius: 4px;
  background: rgba(20, 24, 26, 0.9);
  color: #fff;
  box-shadow: none;
  font-size: 11px;
  font-weight: 700;
}

.aircraft-tooltip {
  display: grid;
  gap: 2px;
  white-space: pre-line;
}

@media (max-width: 760px) {
  .flight-panel {
    top: auto;
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    height: auto;
    min-width: 0;
    max-width: none;
    max-height: 54vh;
  }

  .flight-detail-panel {
    top: 8px;
    right: 8px;
    left: 8px;
    width: auto;
    min-width: 0;
    max-width: none;
    max-height: 38vh;
  }

  .flight-panel.is-minimised,
  .flight-detail-panel.is-minimised {
    width: auto !important;
  }

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

  .flight-table th,
  .flight-table td {
    padding: 7px;
  }
}

.panel-actions button.airspace-toggle {
  width: 44px;
  font-size: 12px;
}

.airspace-toggle[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--row-selected);
}

.airspace-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.airspace-status {
  margin: 3px 0 0;
  color: var(--panel-muted);
  font-size: 11px;
}
