* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  background: #1a1a2e;
}

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

/* Bottom panel */
#panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(20, 20, 40, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px 16px 0 0;
  color: #fff;
  transition: transform 0.3s ease;
  max-height: 70vh;
  overflow-y: auto;
}

#panel.collapsed #panel-body {
  display: none;
}

#panel.collapsed #toggle-panel {
  transform: rotate(180deg);
}

#panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  cursor: pointer;
}

#panel-header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

#toggle-panel {
  background: none;
  border: none;
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.3s;
  padding: 4px 8px;
}

#panel-body {
  padding: 0 20px 20px;
}

/* Stats row */
#stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.stat {
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 1px;
  margin-bottom: 2px;
}

.stat-value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Signal bar */
#signal-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 10px;
}

#signal-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  transition: width 0.5s ease, background-color 0.5s ease;
  background: #22c55e;
}

/* Legend */
#legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.legend-label {
  font-size: 10px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.legend-gradient {
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #ef4444, #f97316, #eab308, #22c55e, #06b6d4);
}

/* Controls */
#controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  padding: 14px 8px;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 48px;
}

.btn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}

.btn-primary {
  background: #3b82f6;
  color: #fff;
}

.btn-danger {
  background: #ef4444;
  color: #fff;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

/* Locate button */
.map-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  background: rgba(20, 20, 40, 0.9);
  backdrop-filter: blur(8px);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Toast */
#toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  background: rgba(20, 20, 40, 0.95);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  transition: opacity 0.3s;
  pointer-events: none;
}

#toast.hidden {
  opacity: 0;
}

/* Update banner */
#update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2100;
  background: linear-gradient(135deg, #059669, #10b981);
  color: #fff;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 2px 16px rgba(0,0,0,0.4);
}

#update-banner.hidden {
  display: none;
}

#update-banner .btn {
  flex: 0 0 auto;
  padding: 10px 18px;
  min-height: unset;
  font-size: 13px;
}

/* Install banner */
#install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  background: linear-gradient(135deg, #1e40af, #3b82f6);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 -2px 16px rgba(0,0,0,0.4);
}

#install-banner.hidden {
  display: none;
}

#install-banner .btn {
  flex: 0 0 auto;
  padding: 10px 18px;
  min-height: unset;
  font-size: 13px;
}

.btn-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

/* Safe area padding for notched phones */
#panel {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.map-btn {
  top: calc(16px + env(safe-area-inset-top, 0px));
}

/* Leaflet overrides for dark theme */
.leaflet-control-attribution {
  background: rgba(20, 20, 40, 0.7) !important;
  color: rgba(255,255,255,0.5) !important;
  font-size: 9px !important;
}

.leaflet-control-attribution a {
  color: rgba(255,255,255,0.6) !important;
}

.leaflet-control-zoom a {
  background: rgba(20, 20, 40, 0.9) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,0.1) !important;
}
