: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: 16px;
  left: 16px;
  z-index: 600;
  width: min(720px, calc(100vw - 32px));
  min-width: min(380px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  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);
}

.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;
}

.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 {
  resize: none;
  width: 280px;
}

.flight-panel.is-minimised .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;
  max-height: min(48vh, 420px);
  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 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;
}

.flight-detail {
  min-height: 78px;
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.06);
}

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

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

.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;
}

.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;
  position: relative;
  width: 26px;
  height: 26px;
  transform: rotate(var(--marker-rotation));
  transform-origin: center;
}

.aircraft-marker::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 1px;
  width: 4px;
  height: 24px;
  border-radius: 4px 4px 10px 10px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(4, 17, 18, 0.78), 0 5px 15px rgba(0, 0, 0, 0.32);
}

.aircraft-marker::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 10px;
  width: 20px;
  height: 5px;
  border-radius: 8px;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(4, 17, 18, 0.78);
}

.aircraft-marker.is-selected::before,
.aircraft-marker.is-selected::after {
  background: var(--warn);
}

.aircraft-marker.is-landed::before,
.aircraft-marker.is-landed::after {
  background: #cfd7d9;
}

.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;
}

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

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

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