:root {
  color-scheme: dark;
  --ink: #f6f3ea;
  --muted: #aeb8b0;
  --panel: rgba(11, 16, 18, 0.84);
  --panel-strong: rgba(16, 24, 27, 0.96);
  --line: rgba(255, 255, 255, 0.16);
  --arrival: #66e3ff;
  --departure: #ffcf6a;
  --accent: #8ee0a1;
  --danger: #ff8274;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #111715;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  min-height: 100vh;
}

.map-stage {
  position: sticky;
  top: 0;
  overflow: hidden;
  height: 100vh;
  min-height: 100vh;
  background: #17201c;
}

.map-world {
  position: absolute;
  left: 50%;
  top: 50%;
  transform-origin: center;
  transform: translate(-50%, -50%);
  transition: transform 420ms ease;
}

.map-world.zoomed {
  transform: translate(calc(-50% + var(--map-x, 0%)), calc(-50% + var(--map-y, 0%))) scale(var(--map-scale, 1));
}

.airport-map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: saturate(1.08) contrast(1.03);
}

.map-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(9, 13, 14, 0.08), transparent 35%, rgba(9, 13, 14, 0.28)),
    radial-gradient(circle at 52% 46%, transparent 0 38%, rgba(7, 10, 10, 0.2) 73%, rgba(7, 10, 10, 0.58));
}

.map-topbar,
.selected-flight,
.runway,
.flight-layer,
.parking-hotspots {
  position: absolute;
  z-index: 2;
}

.map-topbar {
  top: 24px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 58px);
  line-height: 0.95;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}

.api-badge {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(7, 11, 12, 0.72);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.api-badge.live {
  color: #dfffe5;
  border-color: rgba(142, 224, 161, 0.5);
}

.runway {
  pointer-events: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 24px rgba(102, 227, 255, 0.18);
  opacity: 0.55;
}

.runway-main {
  width: 3.6%;
  height: 74%;
  left: 59.6%;
  top: 12.5%;
  transform: rotate(2deg);
}

.runway-cross {
  width: 69%;
  height: 3.2%;
  left: 12.8%;
  top: 41%;
  transform: rotate(-37deg);
}

.flight-layer {
  inset: 0;
}

.parking-hotspots {
  inset: 0;
  z-index: 3;
}

.parking-hotspot {
  position: absolute;
  height: auto;
  min-width: 72px;
  border: 1px solid rgba(142, 224, 161, 0.62);
  border-radius: 8px;
  background: rgba(9, 20, 17, 0.28);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), 0 12px 32px rgba(0, 0, 0, 0.22);
}

.parking-hotspot span {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 4px 8px;
  border-radius: 7px;
  background: rgba(4, 9, 10, 0.78);
  font-size: 11px;
  font-weight: 850;
  white-space: nowrap;
}

.parking-hotspot.active {
  border-color: var(--departure);
  background: rgba(255, 207, 106, 0.18);
}

.plane {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--arrival);
  cursor: pointer;
  transform: translate(-50%, -50%) rotate(var(--angle));
  animation: drift var(--duration) linear infinite;
  animation-delay: var(--delay);
}

.plane.departure {
  color: var(--departure);
}

.plane::before {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  background: currentColor;
  clip-path: polygon(50% 0, 59% 40%, 95% 48%, 95% 58%, 61% 56%, 66% 88%, 54% 88%, 50% 64%, 46% 88%, 34% 88%, 39% 56%, 5% 58%, 5% 48%, 41% 40%);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.65));
}

.plane::after {
  content: attr(data-ident);
  position: absolute;
  left: calc(50% + var(--label-x, 0px));
  top: calc(28px + var(--label-y, 0px));
  transform: translateX(-50%) rotate(calc(var(--angle) * -1));
  padding: 3px 7px;
  border-radius: 7px;
  background: rgba(4, 9, 10, 0.78);
  color: var(--ink);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

@keyframes drift {
  from {
    left: var(--from-x);
    top: var(--from-y);
  }
  to {
    left: var(--to-x);
    top: var(--to-y);
  }
}

.selected-flight {
  left: 24px;
  bottom: 24px;
  width: min(390px, calc(100% - 48px));
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.34);
}

.reset-lot-button {
  position: absolute;
  left: 24px;
  bottom: 24px;
  z-index: 4;
  width: 132px;
  background: rgba(7, 11, 12, 0.82);
}

.selected-flight strong {
  display: block;
  font-size: 26px;
}

.selected-flight span {
  color: var(--muted);
  font-size: 14px;
}

.control-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
  padding: 24px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.lot-workspace {
  display: grid;
  gap: 14px;
}

.lot-workspace[hidden],
#trafficPanel[hidden],
.reset-lot-button[hidden] {
  display: none;
}

.lot-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.lot-header h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1;
}

.lot-header button {
  width: 74px;
}

.lot-description {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.lot-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.lot-stats div {
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.lot-stats strong,
.lot-stats span {
  display: block;
}

.lot-stats strong {
  font-size: 22px;
}

.lot-stats span {
  color: var(--muted);
  font-size: 12px;
}

.spot-grid {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.spot-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
}

.spot-card.occupied {
  border-color: rgba(255, 207, 106, 0.42);
  background: rgba(255, 207, 106, 0.08);
}

.spot-card strong,
.spot-card span {
  display: block;
}

.spot-card span {
  color: var(--muted);
}

.spot-card dl {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 5px 10px;
  margin: 0;
  font-size: 12px;
}

.spot-card dt {
  color: var(--muted);
}

.spot-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.airport-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.storage-link {
  display: block;
  padding: 12px;
  border: 1px solid rgba(255, 207, 106, 0.45);
  border-radius: 8px;
  background: rgba(255, 207, 106, 0.1);
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 8px;
}

input {
  min-width: 0;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--ink);
  text-transform: uppercase;
  outline: none;
}

.source-status {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(255, 130, 116, 0.42);
  border-radius: 8px;
  background: rgba(255, 130, 116, 0.1);
  color: #ffd6d1;
  font-size: 13px;
  line-height: 1.35;
}

.source-status.live {
  border-color: rgba(142, 224, 161, 0.45);
  background: rgba(142, 224, 161, 0.1);
  color: #dcffe3;
}

.source-status strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.source-status code {
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.12);
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

.tab {
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: rgba(255, 255, 255, 0.14);
  color: var(--ink);
}

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

.status-grid div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.status-grid span {
  display: block;
  overflow-wrap: anywhere;
  font-size: 22px;
  font-weight: 850;
}

.status-grid small {
  color: var(--muted);
}

.panel-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-button {
  flex: 1;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}

.toggle input {
  width: 16px;
  height: 16px;
}

.flight-list {
  display: grid;
  gap: 10px;
  overflow: auto;
  padding-right: 2px;
}

.flight-card {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  height: auto;
  min-height: 78px;
  padding: 12px;
  text-align: left;
  border-radius: 8px;
}

.flight-card .stripe {
  width: 9px;
  height: 100%;
  min-height: 48px;
  border-radius: 999px;
  background: var(--arrival);
}

.flight-card.departure .stripe {
  background: var(--departure);
}

.flight-ident {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}

.flight-ident strong {
  font-size: 18px;
}

.flight-ident span,
.route,
.meta {
  color: var(--muted);
  font-size: 13px;
}

.route {
  margin-top: 3px;
}

.time {
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.message {
  min-height: 20px;
  margin: auto 0 0;
  color: var(--muted);
  font-size: 13px;
}

.message.error {
  color: var(--danger);
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .map-stage {
    position: relative;
    height: 72vh;
    min-height: 72vh;
  }

  .control-panel {
    min-height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 560px) {
  .map-topbar {
    top: 16px;
    left: 16px;
    right: 16px;
  }

  h1 {
    font-size: 32px;
  }

  .api-badge {
    max-width: 120px;
    text-align: right;
  }

  .control-panel {
    padding: 16px;
  }
}
