:root{
  --bg:#0a1628;
  --bg-gradient:linear-gradient(135deg, #0a1628 0%, #1a2f4a 50%, #0a1628 100%);
  --card:rgba(30, 41, 59, 0.6);
  --chip:rgba(30, 41, 59, 0.8);
  --text:#e0e7ff;
  --muted:#94a3b8;
  --primary:#60a5fa;
  --primary-hover:#3b82f6;
  --border:rgba(96, 165, 250, 0.2);
  --glow:rgba(96, 165, 250, 0.4);
}

/* Gradient text effect */
.gradient-text {
  background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 50%, #2563eb 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
  animation: gradientShift 8s ease infinite;
  background-size: 200% 200%;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Smooth fade-in animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Pulse animation for stats */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Smooth plane marker transitions */
.leaflet-marker-icon {
  transition: transform 0.3s linear !important;
}
.rotated-plane-icon img {
  transition: transform 0.15s linear;
}
/* Leaflet marker pane smooth transitions */
.leaflet-marker-pane .leaflet-marker-icon {
  will-change: transform;
}

html,body{
  height:100%;
  margin:0;
  background:var(--bg);
  background-image:var(--bg-gradient);
  background-attachment:fixed;
  color:var(--text);
  font:14px/1.45 system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif
}

.map{
  position:fixed;
  inset:0;
  /* Ensure map container is properly sized */
  width: 100%;
  height: 100%;
}

/* Top bar */
.topbar{
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  width:75%;
  top:8px;
  display:flex;
  gap:20px;
  align-items:center;
  background:rgba(10, 22, 40, 0.85);
  backdrop-filter:saturate(1.2) blur(12px);
  padding:8px 10px;
  border-radius:12px;
  border:1px solid var(--border);
  z-index:10;
  box-shadow:0 4px 20px rgba(0, 0, 0, 0.3), 0 0 40px rgba(96, 165, 250, 0.1);
  color:var(--text);
  animation:fadeIn 0.6s ease-out;
  transition:all 0.3s ease;
}

.topbar:hover {
  box-shadow:0 6px 30px rgba(0, 0, 0, 0.4), 0 0 60px rgba(96, 165, 250, 0.2);
  border-color:rgba(96, 165, 250, 0.3);
}

/* New Top bar layout */
.topbar-new{
  position:fixed;
  left:0;
  right:0;
  top:0;
  display:grid;
  grid-template-columns:1fr auto 1fr;
  gap:20px;
  align-items:center;
  background:rgba(10, 22, 40, 0.95);
  backdrop-filter:saturate(1.2) blur(12px);
  padding:12px 24px;
  z-index:1000;
  color:var(--text);
}

.topbar-left {
  display:flex;
  justify-content:flex-start;
  align-items:center;
}

.topbar-center {
  display:flex;
  justify-content:center;
  align-items:center;
}

.topbar-right {
  display:flex;
  justify-content:flex-end;
  align-items:center;
  gap:8px;
}

/* Stats Bar */
.stats-bar {
  position:fixed;
  left:0;
  right:0;
  top:48px;
  background:rgba(10, 22, 40, 0.95);
  backdrop-filter:saturate(1.2) blur(12px);
  border-top:1px solid var(--border);
  border-bottom:1px solid var(--border);
  z-index:999;
}

.toggle-stats-btn {
  width:100%;
  background:rgba(30, 41, 59, 0.6);
  border:none;
  color:var(--text);
  padding:12px 24px;
  font-size:15px;
  font-weight:600;
  cursor:pointer;
  display:flex;
  align-items:center;
  gap:12px;
  transition:all 0.3s ease;
}

.toggle-stats-btn:hover {
  background:rgba(30, 41, 59, 0.8);
  color:var(--primary);
}

#toggleStatsIcon {
  transition:transform 0.3s ease;
  font-size:12px;
}

#toggleStatsIcon.rotated {
  transform:rotate(-90deg);
}

.stats-content {
  max-height:200px;
  overflow:hidden;
  transition:max-height 0.4s ease;
}

.stats-content.collapsed {
  max-height:0;
}

.stats-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(140px, 1fr));
  gap:16px;
  padding:20px 24px;
}

.stat-card {
  background:rgba(30, 41, 59, 0.6);
  backdrop-filter:blur(10px);
  border:1px solid rgba(96, 165, 250, 0.2);
  border-radius:12px;
  padding:16px;
  text-align:center;
  transition:all 0.3s ease;
}

.stat-card:hover {
  transform:translateY(-2px);
  border-color:rgba(96, 165, 250, 0.5);
  box-shadow:0 10px 25px rgba(0, 0, 0, 0.2);
}

.stat-card.clickable {
  cursor:pointer;
}

.stat-card.clickable:hover .stat-value {
  color:var(--primary);
  transform:scale(1.05);
}

.stat-card.active {
  background:rgba(96, 165, 250, 0.2);
  border-color:rgba(96, 165, 250, 0.8);
  box-shadow:0 0 20px rgba(96, 165, 250, 0.3);
}

.stat-label {
  font-size:10px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:1px;
  margin-bottom:8px;
  font-weight:600;
}

.stat-value {
  font-size:28px;
  font-weight:700;
  color:var(--text);
  transition:all 0.3s ease;
}

.stat-value-small {
  font-size:20px;
  font-weight:700;
  color:var(--primary);
}

.stat-ts {
  font-size:11px;
  color:var(--muted);
  margin-top:4px;
}

.stat-hint {
  font-size:11px;
  color:var(--muted);
  margin-top:4px;
}

/* Aircraft Detail Panel */
.detail-panel {
  position:fixed;
  left:10px;
  top:250px;
  width:400px;
  max-width:30vw;
  max-height:calc(100vh - 260px);
  z-index:1001;
  background:rgba(9, 13, 18, 0.88);
  backdrop-filter:blur(10px);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:0 20px 50px rgba(0, 0, 0, 0.45);
  transform:translateX(-120%);
  transition:transform 0.3s ease;
  display:grid;
  grid-template-rows:auto 1fr;
  overflow:hidden;
}

.detail-panel.open {
  transform:translateX(0);
}

.detail-hero {
  position:relative;
  padding:14px;
  border-bottom:1px solid var(--border);
  background: radial-gradient(900px 220px at 0% -20%, rgba(255,212,0,0.12), transparent),
              radial-gradient(700px 200px at 100% -20%, rgba(120,170,255,0.10), transparent);
}

.detail-title {
  font-size:18px;
  font-weight:900;
  letter-spacing:0.3px;
  color:var(--text);
}

.detail-badges {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-top:6px;
}

.detail-badge {
  background:rgba(96, 165, 250, 0.1);
  color:#60a5fa;
  border:1px solid rgba(96, 165, 250, 0.3);
  padding:3px 8px;
  border-radius:999px;
  font-size:12px;
  font-weight:600;
}

.detail-close {
  position:absolute;
  top:10px;
  right:10px;
  border:1px solid var(--border);
  background:#16202b;
  color:#9fc7ff;
  padding:6px 12px;
  border-radius:8px;
  cursor:pointer;
  font-size:18px;
  font-weight:700;
  transition:all 0.2s ease;
}

.detail-close:hover {
  background:#1e2f42;
  color:#60a5fa;
}

.detail-subtitle {
  margin-top:4px;
  font-size:12px;
  color:#94a3b8;
  font-weight:500;
}

.detail-body {
  overflow:auto;
  padding:12px;
  display:grid;
  gap:10px;
}

.detail-section {
  background:rgba(15, 20, 28, 0.6);
  border:1px solid var(--border);
  border-radius:12px;
  padding:12px;
}

.detail-section-title {
  font-size:13px;
  color:#94a3b8;
  text-transform:uppercase;
  letter-spacing:0.5px;
  font-weight:700;
  margin-bottom:10px;
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.detail-row {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(120px, 1fr));
  gap:10px;
  margin-bottom:8px;
}

.detail-row:last-child {
  margin-bottom:0;
}

.detail-item {
  background:rgba(10, 15, 22, 0.6);
  border:1px solid rgba(96, 165, 250, 0.1);
  border-radius:8px;
  padding:8px;
}

.detail-label {
  font-size:10px;
  color:#64748b;
  text-transform:uppercase;
  letter-spacing:0.5px;
  font-weight:700;
  margin-bottom:4px;
}

.detail-value {
  font-size:15px;
  color:#e0e7ff;
  font-weight:600;
}

.graph-container {
  display:grid;
  gap:12px;
  margin-top:10px;
}

.graph-container canvas {
  width:100%;
  height:auto;
  border:1px solid var(--border);
  border-radius:8px;
  background:rgba(15, 20, 28, 0.8);
}

.graph-status {
  font-size:12px;
  color:#64748b;
  text-align:center;
  margin-top:8px;
}

.refresh-btn {
  background:rgba(96, 165, 250, 0.1);
  border:1px solid rgba(96, 165, 250, 0.3);
  color:#60a5fa;
  padding:4px 10px;
  border-radius:6px;
  font-size:14px;
  cursor:pointer;
  transition:all 0.2s ease;
}

.refresh-btn:hover {
  background:rgba(96, 165, 250, 0.2);
  border-color:rgba(96, 165, 250, 0.5);
}

.detail-grid {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}

.detail-kv {
  background:#0f141a;
  border:1px solid var(--border);
  border-radius:12px;
  padding:10px;
}

.detail-kv h6 {
  margin:0 0 2px;
  font-size:11px;
  color:#9fb0c2;
  text-transform:uppercase;
  letter-spacing:0.5px;
  font-weight:800;
}

.detail-kv .v {
  font-weight:850;
  font-size:16px;
  color:var(--text);
}

@media (max-width: 768px) {
  .detail-panel {
    left:5px;
    right:5px;
    top:180px;
    width:auto;
    max-width:none;
    max-height:calc(100vh - 190px);
  }

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

  .detail-row {
    grid-template-columns:1fr;
  }
}

.brand{
  display:flex;
  align-items:center;
  gap:8px;
  font-weight:700;
  cursor:pointer;
  transition:transform 0.3s ease;
}

.brand:hover {
  transform:scale(1.05);
}

.brand-icon {
  transition:transform 0.5s ease;
}

.brand:hover .brand-icon {
  transform:rotate(360deg);
}

.brand-text{
  font-weight:700;
  letter-spacing:.2px;
  font-size:16px;
}

.search{
  display:flex;
  gap:8px;
  width:25%;
  align-items:center;
  justify-content:center;
  margin:0 auto;
  position:relative;
}

.search input{
  flex:1;
  min-width:260px
}

/* Bottom bar for filters and labels */
.bottom-bar{
  position:fixed;
  left:8px;
  right:8px;
  bottom:8px;
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:center;
  background:rgba(10, 22, 40, 0.85);
  backdrop-filter:saturate(1.2) blur(12px);
  padding:8px 10px;
  border-radius:10px;
  border:1px solid var(--border);
  z-index:10;
  box-shadow:0 4px 20px rgba(0, 0, 0, 0.3);
  color:var(--text);
}

.map-controls{
  display:flex;
  gap:8px;
  align-items:center
}

.topbar input,.topbar select,.topbar button{
  height:34px;
  border-radius:8px;
  border:1px solid var(--border);
  background:rgba(30, 41, 59, 0.7);
  color:var(--text);
  padding:0 10px;
  transition:all 0.2s ease;
}

.topbar input:focus,.topbar select:focus{
  outline:none;
  border-color:var(--primary);
  background:rgba(30, 41, 59, 0.9);
}

.topbar input::placeholder{
  color:var(--muted);
}

.bottom-bar input,.bottom-bar select,.bottom-bar button{
  height:34px;
  border-radius:8px;
  border:1px solid var(--border);
  background:rgba(30, 41, 59, 0.7);
  color:var(--text);
  padding:0 10px;
  transition:all 0.2s ease;
}

.topbar button {
  transition:all 0.3s ease;
  position:relative;
}

.topbar button:hover {
  background:rgba(96, 165, 250, 0.2);
  border-color:var(--primary);
  cursor:pointer;
  box-shadow:0 0 20px rgba(96, 165, 250, 0.3), 0 4px 10px rgba(0, 0, 0, 0.2);
  transform:translateY(-1px);
}

.topbar button:active {
  transform:translateY(0);
  box-shadow:0 0 10px rgba(96, 165, 250, 0.2);
}

.bottom-bar button:hover {
  background:rgba(96, 165, 250, 0.2);
  border-color:var(--primary);
  cursor:pointer;
}

.ghost{
  background:transparent;
  border-color:var(--border);
  color:var(--text);
}

.ghost:hover{
  background:rgba(96, 165, 250, 0.15);
  border-color:var(--primary);
}

/* Panels */
.card{
  position:fixed;
  top:70px;
  left:12px;
  width:233px;
  max-height:calc(100vh - 82px);
  overflow:auto;
  background:var(--card);
  backdrop-filter:blur(10px);
  border:1px solid var(--border);
  border-radius:12px;
  box-shadow:0 18px 40px rgba(0,0,0,.35), 0 0 40px rgba(96, 165, 250, 0.08);
  padding:14px;
  z-index:9;
  animation:fadeIn 0.5s ease-out;
  transition:all 0.3s ease;
}

.card:hover {
  box-shadow:0 20px 50px rgba(0,0,0,.45), 0 0 60px rgba(96, 165, 250, 0.12);
  border-color:rgba(96, 165, 250, 0.3);
}

.card.hidden{
  display:none
}

/* Compact Panel Styles */
.compact-panel {
  width: 210px !important;
  padding: 12px !important;
}

.compact-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.aircraft-id .callsign {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  color: #4ade80;
}

.aircraft-id .hex-code {
  font-size: 11px;
  color: var(--muted);
  font-family: monospace;
  margin-top: 2px;
}

.stats-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.stat-item {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.08);
}

.stat-icon {
  font-size: 14px;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 14px;
  font-weight: 600;
  color: #60a5fa;
  line-height: 1;
}

.stat-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

.info-section {
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
  padding: 8px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
  font-size: 12px;
}

.info-row:not(:last-child) {
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.info-label {
  color: var(--muted);
  font-weight: 500;
}

.info-value {
  color: var(--text);
  font-weight: 600;
  font-family: monospace;
  font-size: 11px;
}

.muted{
  color:#a9b0bb;
  letter-spacing:.6px;
  margin:6px 0 10px
}

.stat{
  background:linear-gradient(135deg, rgba(15, 20, 28, 0.9) 0%, rgba(30, 41, 59, 0.7) 100%);
  border:1px solid rgba(96, 165, 250, 0.15);
  border-radius:10px;
  padding:12px;
  margin:10px 0;
  transition:all 0.3s ease;
  position:relative;
  overflow:hidden;
}

.stat::before {
  content:'';
  position:absolute;
  top:0;
  left:-100%;
  width:100%;
  height:100%;
  background:linear-gradient(90deg, transparent, rgba(96, 165, 250, 0.1), transparent);
  transition:left 0.5s ease;
}

.stat:hover::before {
  left:100%;
}

.stat:hover {
  border-color:rgba(96, 165, 250, 0.3);
  box-shadow:0 4px 15px rgba(96, 165, 250, 0.2);
  transform:translateY(-2px);
}

.stat .label{
  color:var(--muted);
  font-size:12px;
  margin-bottom:8px;
  font-weight:600;
  letter-spacing:0.5px;
}

.stat .value{
  font-size:24px;
  font-weight:700;
  color:var(--primary);
  transition:all 0.3s ease;
}

.stat:hover .value {
  color:#3b82f6;
  transform:scale(1.05);
}

.stat .row{
  display:flex;
  justify-content:space-between;
  align-items:baseline
}

.list{
  display:flex;
  flex-direction:column;
  gap:8px
}

.list .chip{
  display:flex;
  align-items:center;
  justify-content:center;
  height:34px;
  background:#0f141c;
  border:1px solid #2b3240;
  border-radius:10px;
  color:#dfe6f3;
  cursor:pointer
}

.list .chip:hover{
  filter:brightness(1.08)
}

.list .chip.active{
  background: #8b5cf6;
  color: white;
  box-shadow: 0 2px 4px rgba(139, 92, 246, 0.3);
}

.list .chip.active:hover{
  background: #7c3aed;
}

.hint{
  color:#8892a0;
  font-size:12px;
  margin-top:6px
}

.toast{
  position:fixed;
  left:50%;
  top:82px;
  transform:translateX(-50%);
  background:#0b1320;
  border:1px solid #26405a;
  border-radius:10px;
  padding:10px 14px;
  z-index:999
}

.toast.hidden{
  display:none !important;
  visibility:hidden;
  opacity:0;
}

/* Detail panel specific styles */
.detailHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.detailHeader h2 {
  margin: 0;
  font-size: 18px;
}

.detailHeader button {
  background: transparent;
  border: 1px solid #2b3240;
  color: var(--muted);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 16px;
}

.detailHeader button:hover {
  background: #1a1f28;
  color: var(--text);
}

.detailGrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.detailGrid > div {
  background: #0f141c;
  border: 1px solid #232a36;
  border-radius: 8px;
  padding: 10px;
}

.detailGrid .k {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detailGrid .v {
  font-weight: 600;
  font-size: 16px;
}

/* Aircraft Image Section */
.image-section {
  margin-bottom: 20px;
  border: 1px solid #232a36;
  border-radius: 12px;
  overflow: hidden;
  background: #0f141c;
  position: relative;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

.image-section.hidden {
  display: none;
}

.aircraft-image {
  width: 100%;
  height: 220px;
  object-fit: cover;
  display: block;
  background: linear-gradient(135deg, #1a1f28 0%, #0f141c 100%);
  transition: transform 0.3s ease;
}

.aircraft-image:hover {
  transform: scale(1.02);
  cursor: pointer;
}

.image-info {
  padding: 16px;
  background: linear-gradient(to bottom, rgba(15,20,28,0.95), rgba(15,20,28,1));
}

.image-source-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.8);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  backdrop-filter: blur(4px);
}

.photographer {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.photographer::before {
  content: "📷";
  font-size: 10px;
}

.aircraft-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  font-size: 12px;
}

.aircraft-info-item {
  display: flex;
  flex-direction: column;
}

.aircraft-info-label {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.aircraft-info-value {
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
}

/* Image gallery styles for multiple images */
.image-gallery {
  position: relative;
}

.image-nav {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 2;
}

.image-nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: background 0.2s ease;
}

.image-nav-dot.active {
  background: rgba(255,255,255,0.9);
}

.image-nav-dot:hover {
  background: rgba(255,255,255,0.7);
}

/* Tooltip styles */
.tooltip {
  position: relative;
  cursor: help;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1f28;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
  z-index: 1000;
  border: 1px solid #2b3240;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  pointer-events: none;
  max-width: 200px;
  white-space: normal;
}

.tooltip::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(1px);
  border: 4px solid transparent;
  border-top-color: #1a1f28;
  z-index: 1001;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.tooltip:hover::after,
.tooltip:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Special positioning for different contexts */
.detail-section .tooltip::after {
  bottom: auto;
  top: 100%;
  margin-top: 4px;
}

.detail-section .tooltip::before {
  bottom: auto;
  top: 100%;
  transform: translateX(-50%) translateY(-1px);
  border-top-color: transparent;
  border-bottom-color: #1a1f28;
}

/* Hoverable elements */
.hoverable {
  transition: background-color 0.2s ease, transform 0.1s ease;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
}

.hoverable:hover {
  background-color: rgba(255,255,255,0.05);
  transform: translateY(-1px);
}

.close-btn {
  background: transparent;
  border: 1px solid #2b3240;
  color: var(--muted);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
}

.close-btn:hover {
  background: #1a1f28;
  color: var(--text);
}

/* Detail panel sections */
.detail-section {
  margin-bottom: 20px;
}

.section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px 0;
  padding-bottom: 6px;
  border-bottom: 1px solid #232a36;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Debug panel styles */
.debug-panel {
  position: fixed;
  bottom: 10px;
  right: 10px;
  background: rgba(20, 24, 30, 0.95);
  border: 1px solid #2b3240;
  border-radius: 8px;
  padding: 12px;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 12px;
  color: #a9b0bb;
  max-width: 320px;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.debug-panel h4 {
  margin: 0 0 10px 0;
  color: #e6e9ee;
  font-size: 13px;
  font-weight: 600;
}

.debug-panel .status {
  margin: 6px 0;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 11px;
  border-left: 3px solid #2b3240;
  background: rgba(0, 0, 0, 0.2);
}

.debug-panel .status.ok {
  color: #4ade80;
  border-left-color: #4ade80;
  background: rgba(74, 222, 128, 0.1);
}

.debug-panel .status.error {
  color: #f87171;
  border-left-color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

.debug-panel .status.warn {
  color: #fbbf24;
  border-left-color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
}

.debug-toggle {
  position: fixed;
  bottom: 10px;
  right: 345px;
  background: rgba(20, 24, 30, 0.9);
  border: 1px solid #2b3240;
  border-radius: 6px;
  color: #e6e9ee;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  z-index: 101;
  backdrop-filter: blur(6px);
  font-family: inherit;
}

.debug-toggle:hover {
  background: rgba(30, 34, 40, 0.9);
  border-color: #3b4250;
}

/* Advanced Filters Panel */
.filter-toggle {
  background: #f8f9fa;
  border: 1px solid #ccc;
  color: #333;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  margin-left: 8px;
  transition: all 0.2s ease;
}

.filter-toggle:hover {
  background: #f0f0f0;
}

.filter-toggle.active {
  background: #dc3545;
  border-color: #dc3545;
  color: white;
  box-shadow: 0 2px 4px rgba(220, 53, 69, 0.3);
}

.filter-toggle.active:hover {
  background: #c82333;
  border-color: #c82333;
}

.filters-panel {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  max-width: 90vw;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 40px rgba(0,0,0,.35);
  z-index: 20;
  backdrop-filter: blur(10px);
}

.filters-panel.hidden {
  display: none;
}

.filters-content {
  padding: 20px;
}

.filters-content h3 {
  margin: 0 0 16px 0;
  color: var(--text);
  font-size: 16px;
  text-align: center;
  border-bottom: 1px solid #232a36;
  padding-bottom: 12px;
}

.filter-group {
  margin-bottom: 16px;
}

.filter-group label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-group select {
  width: 100%;
  height: 36px;
  border-radius: 6px;
  border: 1px solid #2b3240;
  background: #0f141c;
  color: var(--text);
  padding: 0 12px;
  font-size: 14px;
}

.filter-group select:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.filter-actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #232a36;
}

.apply-filters {
  flex: 1;
  background: #22c55e;
  border: none;
  color: white;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease;
}

.apply-filters:hover {
  background: #16a34a;
}

.clear-filters {
  background: #ef4444;
  border: none;
  color: white;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease;
}

.clear-filters:hover {
  background: #dc2626;
}

.close-filters {
  background: var(--chip);
  border: 1px solid #2b3240;
  color: var(--text);
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease;
}

.close-filters:hover {
  background: #252a33;
}

/* Flight History Search Styles */
.filter-section {
  margin-bottom: 24px;
  border-bottom: 1px solid #232a36;
  padding-bottom: 20px;
}

.filter-section:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.filter-section h4 {
  margin: 0 0 16px 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.airport-search-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.airport-search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.airport-input {
  flex: 1;
  height: 36px;
  border-radius: 6px;
  border: 1px solid #2b3240;
  background: #0f141c;
  color: var(--text);
  padding: 0 12px;
  font-size: 14px;
  text-transform: uppercase;
}

.airport-input:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.airport-input::placeholder {
  text-transform: none;
  color: var(--muted);
}

.search-history-btn {
  background: #3b82f6;
  border: none;
  color: white;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s ease;
  white-space: nowrap;
}

.search-history-btn:hover {
  background: #2563eb;
}

.search-options {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 12px;
}

.search-options label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  cursor: pointer;
}

.search-options input[type="checkbox"] {
  margin: 0;
}

.search-options select {
  height: 32px;
  border-radius: 4px;
  border: 1px solid #2b3240;
  background: #0f141c;
  color: var(--text);
  padding: 0 8px;
  font-size: 12px;
}

.route-filter-status {
  margin-top: 8px;
}

.filter-status {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.flight-history-results {
  margin-top: 16px;
  background: #0f141c;
  border-radius: 6px;
  border: 1px solid #232a36;
  max-height: 300px;
  overflow-y: auto;
}

.flight-history-results.hidden {
  display: none;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #232a36;
  background: #151a22;
  border-radius: 6px 6px 0 0;
}

.results-header h5 {
  margin: 0;
  font-size: 14px;
  color: var(--text);
}

.close-results-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 4px;
}

.close-results-btn:hover {
  color: var(--text);
}

.results-content {
  padding: 0;
}

.flight-result-item {
  padding: 12px 16px;
  border-bottom: 1px solid #232a36;
  cursor: pointer;
  transition: background 0.2s ease;
}

.flight-result-item:hover {
  background: #1a1f28;
}

.flight-result-item:last-child {
  border-bottom: none;
}

.flight-result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.flight-callsign {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.flight-date {
  font-size: 12px;
  color: var(--muted);
}

.flight-route {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.flight-details {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

.flight-duration {
  color: #22c55e;
}

.no-results {
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* Historical Flight Data */
.history-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: #0f141c;
  border-radius: 6px;
  border: 1px solid #232a36;
}

.history-status {
  font-size: 11px;
  color: var(--muted);
}

.history-content {
  background: #0f141c;
  border: 1px solid #232a36;
  border-radius: 6px;
  overflow: hidden;
}

.history-summary {
  display: flex;
  justify-content: space-between;
  padding: 12px;
  background: #151a22;
  border-bottom: 1px solid #232a36;
}

.summary-item {
  text-align: center;
  flex: 1;
}

.summary-label {
  display: block;
  font-size: 10px;
  color: var(--muted);
  margin-bottom: 2px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-value {
  display: block;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.history-table-container {
  max-height: 300px;
  overflow-y: auto;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.history-table th {
  background: #1a1f28;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid #232a36;
  position: sticky;
  top: 0;
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
}

.history-table td {
  padding: 6px;
  border-bottom: 1px solid #1a1f28;
  color: var(--text);
}

.history-table tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

.history-table .date-cell {
  font-family: 'Courier New', monospace;
  font-size: 10px;
  width: 80px;
}

.history-table .from-cell {
  font-weight: 500;
  width: 80px;
}

.history-table .to-cell {
  font-weight: 500;
  width: 80px;
}

.history-table .duration-cell {
  text-align: right;
  font-family: 'Courier New', monospace;
  width: 70px;
}

.history-table .route-info {
  font-size: 9px;
  color: var(--muted);
  display: block;
}

.history-table .incomplete-flight {
  opacity: 0.6;
  font-style: italic;
}

/* Live Data Graphs */
.graph-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: #0f141c;
  border-radius: 6px;
  border: 1px solid #232a36;
}

.graph-btn {
  background: #1a1f28;
  border: 1px solid #2b3240;
  color: var(--text);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s ease;
}

.graph-btn:hover {
  background: #252a33;
}

.graph-status {
  font-size: 11px;
  color: var(--muted);
}

.graph-container {
  margin-bottom: 16px;
  background: #0f141c;
  border: 1px solid #232a36;
  border-radius: 8px;
  padding: 12px;
}

.graph-title {
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-graph {
  width: 100%;
  height: 80px;
  background: linear-gradient(to bottom, rgba(26, 31, 40, 0.3), rgba(15, 20, 28, 0.5));
  border-radius: 4px;
  display: block;
}

/* Airport Labels */
.mapboxgl-popup-content {
  background: var(--card);
  border: 1px solid #232a36;
  border-radius: 8px;
  color: var(--text);
  font-size: 12px;
  padding: 8px 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.mapboxgl-popup-anchor-bottom .mapboxgl-popup-tip {
  border-top-color: var(--card);
}

.mapboxgl-popup-anchor-top .mapboxgl-popup-tip {
  border-bottom-color: var(--card);
}

.mapboxgl-popup-anchor-left .mapboxgl-popup-tip {
  border-right-color: var(--card);
}

.mapboxgl-popup-anchor-right .mapboxgl-popup-tip {
  border-left-color: var(--card);
}

/* Airport symbol styling in CSS for better performance */
.airport-symbol {
  color: #60a5fa;
  font-size: 14px;
  font-weight: bold;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.airport-label {
  color: #e6e9ee;
  font-size: 10px;
  font-weight: 600;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.9);
  white-space: nowrap;
}

/* Rotate only the brand icon 90° left (points north) */
.brand-icon{
  display:inline-block;
  transform:rotate(0deg);
  transform-origin:50% 50%;
  width:18px;
  height:18px;
}
/* Enhanced Responsive Design */
@media (max-width: 1024px) {
  /* Tablet adjustments */
  .card {
    width: 210px;
  }

  .detailGrid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .filters-panel {
    width: 350px;
  }
}

@media (max-width: 768px) {
  /* Mobile layout adjustments */
  .topbar {
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    left: 4px;
    right: 4px;
    top: 4px;
  }

  .brand {
    align-self: center;
  }

  .search {
    width: 100%;
    flex-direction: column;
    gap: 6px;
  }

  .search input {
    min-width: 0;
    width: 100%;
  }

  .search label {
    align-self: flex-start;
  }

  .search select,
  .search button {
    width: 100%;
  }

  .map-controls {
    width: 100%;
    justify-content: space-between;
  }

  .auth {
    display: none; /* Hide auth on mobile to save space */
  }

  /* Panel adjustments for mobile */
  .card {
    left: 4px;
    right: 4px;
    width: auto;
    top: auto;
    bottom: 60px;
    max-height: 50vh;
    overflow-y: auto;
  }

  /* Detail panel mobile adjustments */
  #detailPanel {
    top: auto;
    bottom: 4px;
    left: 4px;
    right: 4px;
    max-height: 70vh;
  }

  .detailGrid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .detailGrid > div {
    padding: 8px;
  }

  /* Aircraft image mobile optimization */
  .aircraft-image {
    height: 180px;
  }

  .image-info {
    padding: 12px;
  }

  .aircraft-info {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  /* Graph adjustments for mobile */
  .data-graph {
    height: 60px;
  }

  .graph-container {
    margin-bottom: 12px;
    padding: 8px;
  }

  /* Filters panel mobile */
  .filters-panel {
    width: 95vw;
    max-width: none;
    top: 80px;
  }

  .filter-group {
    margin-bottom: 12px;
  }

  .filter-actions {
    flex-direction: column;
    gap: 8px;
  }

  .filter-actions button {
    width: 100%;
    padding: 12px;
  }

  /* Debug panel mobile */
  .debug-panel {
    right: 4px;
    left: 4px;
    bottom: 4px;
    max-width: none;
    font-size: 11px;
  }

  .debug-toggle {
    right: 4px;
    bottom: auto;
    top: 4px;
    left: auto;
  }

  /* Toast adjustments */
  .toast {
    left: 4px;
    right: 4px;
    transform: none;
    top: 100px;
    font-size: 12px;
  }

  /* Stats panel mobile optimizations */
  .stat {
    padding: 8px;
    margin: 6px 0;
  }

  .stat .value {
    font-size: 18px;
  }

  /* Hide complex tooltips on mobile for performance */
  .tooltip::after,
  .tooltip::before {
    display: none;
  }
}

/* Mobile device class for performance optimizations */
.mobile-device .tooltip::after,
.mobile-device .tooltip::before {
  display: none !important;
}

.mobile-device .data-graph {
  /* Reduce complexity on mobile */
  image-rendering: pixelated;
}

/* Touch-friendly buttons on mobile */
@media (hover: none) and (pointer: coarse) {
  button {
    min-height: 44px;
    min-width: 44px;
  }

  .topbar button {
    padding: 8px 16px;
  }
}

@media (max-width: 480px) {
  /* Small mobile phones */
  .topbar {
    padding: 8px;
  }

  .brand-text {
    font-size: 14px;
  }

  .search input,
  .search select,
  .search button {
    height: 38px;
    font-size: 14px;
  }

  .card {
    bottom: 40px;
    max-height: 40vh;
    font-size: 13px;
  }

  #detailPanel {
    max-height: 60vh;
    font-size: 13px;
  }

  .aircraft-image {
    height: 160px;
  }

  .section-title {
    font-size: 12px;
  }

  .detailGrid .k {
    font-size: 11px;
  }

  .detailGrid .v {
    font-size: 14px;
  }

  .filters-panel {
    top: 60px;
    padding: 12px;
  }

  .filters-content h3 {
    font-size: 14px;
  }
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top: 2px solid #4ade80;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Search suggestions */
.search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.search-suggestions.hidden {
  display: none;
}

.suggestion-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  color: #333;
  font-size: 14px;
}

.suggestion-item:hover {
  background: #f0f0f0;
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-type {
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  font-weight: 600;
}

.suggestion-value {
  margin-top: 2px;
}

/* Modal styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none !important;
  visibility: hidden;
  opacity: 0;
}

.modal-content {
  background: var(--card);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 0;
  width: 400px;
  max-width: 90vw;
  box-shadow: 0 20px 50px rgba(0,0,0,.5);
  border: 1px solid var(--border);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 20px 0;
  margin-bottom: 20px;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.modal-body {
  padding: 0 20px 20px;
}

.modal-body input {
  width: 100%;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.7);
  color: var(--text);
  padding: 0 12px;
  margin-bottom: 12px;
  font-size: 14px;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.modal-body input::placeholder {
  color: var(--muted);
}

.modal-body input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(30, 41, 59, 0.9);
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.2);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.primary-btn {
  flex: 1;
  background: var(--primary);
  border: none;
  color: white;
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s ease;
}

.primary-btn:hover {
  background: var(--primary-hover);
}

.modal-actions .ghost {
  flex: 1;
  background: var(--chip);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.2s ease;
}

.modal-actions .ghost:hover {
  background: rgba(96, 165, 250, 0.15);
  border-color: var(--primary);
}

.modal-links {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}

.modal-links a {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.2s ease;
}

.modal-links a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ========================================================
   WEATHER LAYER CONTROL
   ======================================================== */

.weather-control {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: none;
}

.weather-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(96, 165, 250, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.weather-btn:hover {
  background: rgba(37, 99, 235, 0.9);
  border-color: rgba(96, 165, 250, 0.6);
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.weather-icon {
  font-size: 24px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.weather-menu {
  position: absolute;
  bottom: 60px;
  right: 0;
  background: rgba(30, 41, 59, 0.98);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(96, 165, 250, 0.3);
  border-radius: 12px;
  padding: 8px;
  min-width: 180px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: fadeIn 0.2s ease-out;
}

.weather-menu.hidden {
  display: none;
}

.weather-menu-header {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(96, 165, 250, 0.2);
  margin-bottom: 4px;
}

.weather-option {
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #e0e7ff;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.weather-option:hover {
  background: rgba(96, 165, 250, 0.15);
}

.weather-option .check {
  width: 16px;
  font-size: 14px;
  color: #60a5fa;
  font-weight: bold;
}

@media (max-width: 768px) {
  .weather-control {
    bottom: 80px;
    right: 12px;
  }

  .weather-btn {
    width: 45px;
    height: 45px;
  }

  .weather-icon {
    font-size: 20px;
  }

  .weather-menu {
    bottom: 55px;
  }
}
