:root {
  color-scheme: light;
  --text: #172033;
  --muted: #64748b;
  --line: rgba(23, 32, 51, 0.12);
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --surface: rgba(23, 32, 51, 0.055);
  --accent: #0ea5e9;
  --czvg-blue: #017bbd;
  --green: #14b981;
  --cyan: #0ea5e9;
  --gold: #f2be3d;
  --shadow: 0 18px 54px rgba(23, 32, 51, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: #edf3f6;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.map-shell,
#map {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
  background: #edf3f6;
}

.map-status {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  display: flex;
  gap: 8px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.map-status div {
  min-width: 104px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 8px;
}

.map-status span,
.section-label,
.metric-strip span,
.pilot-strip span,
.route-track span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.map-status strong {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--text);
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flight-panel {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 6;
  width: min(400px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

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

.flight-panel-header {
  position: relative;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px 14px;
  padding: 14px 58px 12px 14px;
  border-bottom: 1px solid var(--line);
}

.match-badge {
  align-self: start;
  width: fit-content;
  padding: 5px 8px;
  color: #071018;
  background: var(--accent);
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 900;
  text-transform: uppercase;
}

.flight-panel h1 {
  grid-column: 1 / -1;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: clamp(1.55rem, 3.4vw, 2.15rem);
  line-height: 0.98;
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--line);
  border-radius: 50%;
  cursor: pointer;
}

.flight-panel-body {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.pilot-strip,
.route-strip,
.metric-strip,
.aircraft-strip,
.plan-strip {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.pilot-strip strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 1.25rem;
  line-height: 1.05;
}

.pilot-strip small,
.aircraft-strip span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.route-track {
  display: grid;
  grid-template-columns: minmax(68px, auto) 1fr minmax(68px, auto);
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.route-track strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 1.1rem;
}

.route-track div:last-child {
  text-align: right;
}

.route-bar {
  height: 3px;
  background: linear-gradient(90deg, var(--green), var(--cyan), #8b8cff);
  border-radius: 999px;
  opacity: 0.95;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metric-strip div {
  min-width: 0;
}

.metric-strip strong {
  display: block;
  overflow-wrap: anywhere;
  margin-top: 4px;
  font-size: 1.08rem;
  line-height: 1;
}

.aircraft-strip strong {
  display: block;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 1.08rem;
}

.plan-strip pre {
  margin: 9px 0 0;
  max-height: 104px;
  overflow: auto;
  padding: 9px 10px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.52);
  border: 1px solid rgba(23, 32, 51, 0.08);
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 700 0.86rem/1.45 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.toast {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 7;
  max-width: min(520px, calc(100% - 32px));
  padding: 12px 14px;
  color: var(--text);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.plane-marker {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--czvg-blue);
  cursor: pointer;
  transform: rotate(var(--heading, 0deg));
  transform-origin: center;
}

.plane-marker svg {
  width: 34px;
  height: 34px;
  fill: currentColor;
  filter: drop-shadow(0 2px 3px rgba(23, 32, 51, 0.36)) drop-shadow(0 0 2px rgba(255, 255, 255, 0.9));
  transform: translateY(-1px);
}

.plane-marker.reason-vg {
  color: var(--czvg-blue);
}

.plane-marker.reason-cz {
  color: var(--czvg-blue);
}

.leaflet-container {
  overflow: hidden;
  background: #edf3f6;
}

.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  border: 0;
  max-width: none;
}

.leaflet-control {
  position: relative;
  z-index: 800;
  pointer-events: auto;
}

.leaflet-top,
.leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.leaflet-top {
  top: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 14px;
}

.leaflet-left .leaflet-control {
  float: left;
  clear: both;
}

.leaflet-right .leaflet-control {
  float: right;
  clear: both;
}

.leaflet-right .leaflet-control {
  margin-right: 14px;
}

.leaflet-left .leaflet-control {
  margin-left: 14px;
}

.leaflet-bottom.leaflet-left {
  max-width: calc(100vw - 28px);
}

.leaflet-control-zoom {
  display: grid;
  gap: 6px;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.leaflet-control-zoom a {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(23, 32, 51, 0.18);
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
}

.leaflet-control-zoom a:first-child,
.leaflet-control-zoom a:last-child {
  border-radius: 8px;
}

.leaflet-control-zoom a:hover,
.leaflet-control-zoom a:focus {
  color: #ffffff;
  background: var(--cyan);
}

.leaflet-control-attribution {
  max-width: min(440px, calc(100vw - 28px));
  padding: 5px 8px;
  color: rgba(23, 32, 51, 0.7);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(23, 32, 51, 0.1);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(23, 32, 51, 0.14);
  font-size: 0.72rem;
  line-height: 1.25;
  backdrop-filter: blur(12px);
}

.leaflet-control-attribution a {
  color: #0369a1;
  text-decoration: none;
}

.leaflet-control-attribution a:hover {
  color: #0f172a;
  text-decoration: underline;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .map-shell {
    min-height: 100vh;
    height: auto;
    overflow: visible;
  }

  #map {
    position: fixed;
    min-height: 100vh;
  }

  .map-status {
    right: 10px;
    left: 10px;
    overflow-x: auto;
  }

  .flight-panel {
    position: relative;
    left: auto;
    right: auto;
    bottom: auto;
    width: calc(100% - 20px);
    max-height: none;
    margin: 98px 10px 10px;
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }

  .route-track {
    grid-template-columns: 1fr;
  }

  .route-track div:last-child {
    text-align: left;
  }
}
