:root {
  --canvas-base: #031334;
  --canvas-mid: #061b42;
  --panel-bg: rgba(5, 28, 68, 0.78);
  --panel-highlight: rgba(21, 78, 145, 0.3);
  --accent-arrivals: #168bff;
  --accent-arrivals-bright: #20a7ff;
  --accent-departures: #00c8c8;
  --accent-departures-bright: #22d6c8;
  --text-primary: #f4f8ff;
  --text-secondary: #b7c9e6;
  --divider: rgba(110, 166, 230, 0.2);
  --severity-high: #ff365b;
  --severity-medium: #ff941f;
  --severity-low: #ffc928;
  --panel-radius: 20px;
  --page-pad: clamp(20px, 2.4vw, 42px);
  --panel-gap: clamp(16px, 1.6vw, 26px);
  --font: "Segoe UI Variable", "Segoe UI", "Helvetica Neue", sans-serif;
  --table-fs: clamp(15px, 1.05vw, 20px);
  --iata-fs: clamp(20px, 1.5vw, 28px);
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--canvas-base);
  overflow: hidden;
}

.bg-layer {
  position: fixed;
  inset: 0;
  background: url("/static/assets/aviation-world-background.png") center / cover no-repeat;
  z-index: 0;
}

.bg-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(ellipse 55% 45% at 72% 18%, rgba(32, 167, 255, 0.18), transparent 60%),
    radial-gradient(ellipse 40% 35% at 18% 70%, rgba(34, 214, 200, 0.08), transparent 55%),
    linear-gradient(180deg, rgba(3, 19, 52, 0.55) 0%, rgba(3, 19, 52, 0.72) 45%, rgba(3, 19, 52, 0.88) 100%);
  pointer-events: none;
}

.app {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  padding: var(--page-pad);
  gap: clamp(12px, 1.2vh, 20px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand h1 {
  margin: 0;
  font-size: clamp(22px, 2vw, 34px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-block {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 28px);
  flex-shrink: 0;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(32, 167, 255, 0.35);
  background: rgba(8, 36, 80, 0.65);
  font-size: clamp(12px, 0.9vw, 14px);
  font-weight: 700;
  letter-spacing: 0.12em;
}

.live-pill[data-state="live"] {
  border-color: rgba(34, 214, 200, 0.45);
  color: #9dffef;
}

.live-pill[data-state="stale"] {
  border-color: rgba(255, 148, 31, 0.55);
  color: #ffd19a;
}

.live-pill[data-state="error"],
.live-pill[data-state="empty"] {
  border-color: rgba(255, 54, 91, 0.5);
  color: #ffb3c2;
}

.live-pill[data-state="loading"] {
  color: var(--text-secondary);
}

.live-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.live-pill[data-state="live"] .live-dot {
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.updated {
  text-align: right;
  line-height: 1.25;
}

.updated-label {
  display: block;
  font-size: clamp(10px, 0.75vw, 12px);
  letter-spacing: 0.14em;
  color: var(--text-secondary);
  font-weight: 600;
}

#updated-at {
  font-size: clamp(14px, 1.1vw, 18px);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.banner {
  flex-shrink: 0;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(255, 148, 31, 0.4);
  background: rgba(80, 40, 10, 0.55);
  color: #ffe0b8;
  font-size: clamp(13px, 0.95vw, 16px);
}

.banner[data-tone="error"] {
  border-color: rgba(255, 54, 91, 0.45);
  background: rgba(70, 12, 28, 0.55);
  color: #ffd0da;
}

.panels {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--panel-gap);
}

.panel {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-radius: var(--panel-radius);
  padding: clamp(14px, 1.4vw, 22px);
  background:
    linear-gradient(160deg, var(--panel-highlight), transparent 42%),
    var(--panel-bg);
  border: 1px solid var(--divider);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 18px 40px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.55;
}

.panel-arrivals {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(22, 139, 255, 0.18),
    0 0 28px rgba(22, 139, 255, 0.12),
    0 18px 40px rgba(0, 0, 0, 0.28);
}

.panel-departures {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(0, 200, 200, 0.18),
    0 0 28px rgba(0, 200, 200, 0.12),
    0 18px 40px rgba(0, 0, 0, 0.28);
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: clamp(10px, 1.2vh, 18px);
  flex-shrink: 0;
}

.panel-head h2 {
  margin: 0;
  font-size: clamp(18px, 1.35vw, 24px);
  letter-spacing: 0.1em;
  font-weight: 700;
}

.panel-accent {
  margin-top: 6px;
  height: 3px;
  width: 72px;
  border-radius: 999px;
}

.panel-arrivals .panel-icon,
.panel-arrivals .panel-accent {
  color: var(--accent-arrivals-bright);
}

.panel-arrivals .panel-accent {
  background: linear-gradient(90deg, var(--accent-arrivals-bright), transparent);
}

.panel-departures .panel-icon,
.panel-departures .panel-accent {
  color: var(--accent-departures-bright);
}

.panel-departures .panel-accent {
  background: linear-gradient(90deg, var(--accent-departures-bright), transparent);
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.rank-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: var(--table-fs);
}

.rank-table th,
.rank-table td {
  padding: clamp(8px, 1.1vh, 14px) 8px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--divider);
}

.rank-table th {
  color: var(--text-secondary);
  font-size: clamp(11px, 0.8vw, 13px);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: normal;
  line-height: 1.25;
  overflow: hidden;
  hyphens: manual;
}

.rank-table th:nth-child(1),
.rank-table td:nth-child(1) {
  width: 6%;
}

.rank-table th:nth-child(2),
.rank-table td:nth-child(2) {
  width: 28%;
}

.rank-table th:nth-child(3),
.rank-table td:nth-child(3) {
  width: 22%;
}

.rank-table th:nth-child(4),
.rank-table td:nth-child(4),
.rank-table th:nth-child(5),
.rank-table td:nth-child(5) {
  width: 14%;
}

.rank-table th:nth-child(6),
.rank-table td:nth-child(6) {
  width: 16%;
}

.rank-table tbody tr {
  transition: background 0.35s ease;
}

.rank-table tbody tr:last-child td {
  border-bottom: none;
}

.rank {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.airport-iata {
  display: block;
  font-size: var(--iata-fs);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
}

.airport-meta {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: clamp(11px, 0.8vw, 14px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-main {
  display: block;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.metric-sub {
  display: block;
  color: var(--text-secondary);
  font-size: 0.82em;
  font-variant-numeric: tabular-nums;
}

.severity-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.2em;
  padding: 5px 10px;
  border-radius: 999px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.25);
}

.severity-pill[data-band="high"] {
  color: #ffd6de;
  border-color: rgba(255, 54, 91, 0.55);
  background: rgba(255, 54, 91, 0.18);
  box-shadow: 0 0 12px rgba(255, 54, 91, 0.2);
}

.severity-pill[data-band="medium"] {
  color: #ffe0c2;
  border-color: rgba(255, 148, 31, 0.55);
  background: rgba(255, 148, 31, 0.16);
}

.severity-pill[data-band="low"] {
  color: #fff0c2;
  border-color: rgba(255, 201, 40, 0.5);
  background: rgba(255, 201, 40, 0.14);
}

.severity-pill .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.skeleton-row td,
.empty-row td {
  color: var(--text-secondary);
  font-style: italic;
  text-align: center;
  padding: 28px 12px;
}

@media (max-width: 900px) and (orientation: portrait) {
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .panels {
    grid-template-columns: 1fr;
  }

  .brand h1 {
    white-space: normal;
  }
}
