:root {
  --bg-color: #121212;
  --text-color: #f1f5f9;
  --text-muted: #94a3b8;
  --panel-bg: rgba(30, 41, 59, 0.88);
  --border-color: #334155;
  --header-bg: rgba(15, 23, 42, 0.85);
}

body.light-mode {
  --bg-color: #f1f5f9;
  --text-color: #0f172a;
  --text-muted: #475569;
  --panel-bg: rgba(255, 255, 255, 0.90);
  --border-color: #cbd5e1;
  --header-bg: rgba(255, 255, 255, 0.90);
}

body, html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  overflow: hidden;
}

#map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

body:not(.light-mode) .dark-tiles {
  filter: brightness(0.6) invert(1) contrast(3) hue-rotate(200deg) saturate(0.3) brightness(0.7);
}

.app-header {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  max-width: 700px;
  margin: 0 auto;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 8px 14px;
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-title h1 {
  font-size: 0.95rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-color);
}

.filter-overlay {
  position: absolute;
  bottom: 24px;
  left: 12px;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 10px 14px;
  z-index: 1000;
  max-width: 260px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  font-size: 0.8rem;
}

.filter-overlay summary {
  cursor: pointer;
  font-weight: bold;
  color: var(--text-color);
  outline: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-overlay summary::-webkit-details-marker {
  display: none;
}

.filter-group {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  color: var(--text-color);
}

.mode-toggle-group {
  margin-top: 8px;
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.theme-btn {
  background: var(--border-color);
  color: var(--text-color);
  border: none;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
}

.filter-disclaimer {
  margin-top: 8px;
  border-top: 1px solid var(--border-color);
  padding-top: 6px;
  font-size: 0.68rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.map-controls-right {
  position: absolute;
  bottom: 24px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1000;
}

.map-ctrl-btn {
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: bold;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 5px;
}

.map-ctrl-btn.active {
  background: #38ef7d;
  color: #050505;
  border-color: #38ef7d;
}

.custom-zoom-container {
  position: absolute;
  top: 70px;
  right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  overflow: hidden;
}

.zoom-btn {
  background: transparent;
  color: var(--text-color);
  border: none;
  width: 34px;
  height: 34px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.zoom-btn:not(:last-child) {
  border-bottom: 1px solid var(--border-color);
}

.zoom-btn:active {
  background: var(--border-color);
}

@media (max-width: 768px) {
  .custom-zoom-container {
    display: none;
  }
  .custom-zoom-mobile-left, .custom-zoom-mobile-right {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    background: var(--panel-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .custom-zoom-mobile-left { left: 10px; }
  .custom-zoom-mobile-right { right: 10px; }

  .bottom-sheet {
    background: rgba(30, 41, 59, 0.75) !important;
  }
  body.light-mode .bottom-sheet {
    background: rgba(255, 255, 255, 0.78) !important;
  }
}

@media (min-width: 769px) {
  .custom-zoom-mobile-left, .custom-zoom-mobile-right {
    display: none;
  }
}

.bottom-sheet {
  position: absolute;
  bottom: -100%;
  left: 12px;
  right: 12px;
  max-width: 380px;
  margin: 0 auto;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 14px 14px 0 0;
  padding: 12px 14px;
  z-index: 1500;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
  transition: bottom 0.3s ease-in-out;
  max-height: 65vh;
  overflow-y: auto;
}

@media (min-width: 768px) {
  .bottom-sheet {
    left: auto;
    right: 24px;
    width: 360px;
    border-radius: 14px;
    bottom: -100%;
  }
  .bottom-sheet.open {
    bottom: 24px;
  }
}

.bottom-sheet.open {
  bottom: 0;
}

.sheet-close-top {
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
}

.sheet-close-btn {
  width: 100%;
  background: var(--border-color);
  color: var(--text-color);
  border: none;
  padding: 8px;
  border-radius: 6px;
  font-weight: bold;
  font-size: 0.8rem;
  margin-top: 10px;
  cursor: pointer;
}

.airline-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.airline-logo {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  background: var(--bg-color);
  object-fit: contain;
  padding: 3px;
  border: 1px solid var(--border-color);
}

.info-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
}

.info-card .row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
  border-bottom: 1px solid var(--border-color);
}

.info-card .label {
  color: var(--text-muted);
}

.plane-marker-icon {
  background: transparent;
  border: none;
}

.icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(18, 18, 18, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: transform 0.1s linear;
}

body.light-mode .icon-wrapper {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.selected-plane-glow {
  box-shadow: 0 0 10px #eab308;
  border-color: #eab308 !important;
}

.lifeliner-glow {
  box-shadow: 0 0 8px #FF2A4D;
}

.emergency-flash {
  animation: flashRed 0.8s infinite alternate;
}

@keyframes flashRed {
  from { box-shadow: 0 0 4px #ef4444; }
  to { box-shadow: 0 0 14px #ef4444, 0 0 20px #ef4444; }
}

.plane-label-tag {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  backdrop-filter: blur(6px);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.65rem;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  z-index: 1000;
}

.airport-badge-major {
  background: rgba(217, 119, 6, 0.25);
  border: 1px solid #d97706;
  color: #d97706;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.airport-badge-regional {
  background: rgba(59, 130, 246, 0.25);
  border: 1px solid #3b82f6;
  color: #3b82f6;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.58rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.airport-badge-military {
  background: rgba(22, 163, 74, 0.25);
  border: 1px solid #16a34a;
  color: #16a34a;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.speed-btn {
  background: var(--border-color);
  color: var(--text-color);
  border: none;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.68rem;
  cursor: pointer;
}

.speed-btn.active {
  background: #38ef7d;
  color: #050505;
  font-weight: bold;
}

.leaflet-popup-content-wrapper, 
.leaflet-popup-tip {
  background: var(--panel-bg) !important;
  color: var(--text-color) !important;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
}

.leaflet-popup-content {
  color: var(--text-color) !important;
  font-size: 0.85rem;
  margin: 10px 14px;
}

.leaflet-container a.leaflet-popup-close-button {
  color: var(--text-muted) !important;
}

.leaflet-container a.leaflet-popup-close-button:hover {
  color: var(--text-color) !important;
}