* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; font-family: system-ui, -apple-system, sans-serif; }

.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(13, 27, 42, 0.92); color: #fff;
  backdrop-filter: blur(6px);
}
.brand { font-size: 18px; letter-spacing: 0.3px; }
.controls { display: flex; gap: 12px; align-items: center; }
.controls select { padding: 6px 8px; border-radius: 8px; border: none; font-size: 14px; }
.toggle { font-size: 13px; display: flex; align-items: center; gap: 6px; cursor: pointer; }

#map { position: absolute; inset: 52px 0 0 0; }

.legend {
  position: fixed; bottom: 14px; left: 12px; z-index: 1000;
  background: rgba(255,255,255,0.94); border-radius: 10px; padding: 8px 12px;
  display: flex; gap: 12px; font-size: 12px; box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.dot.excellent { background: #16a34a; }
.dot.good { background: #84cc16; }
.dot.fair { background: #f59e0b; }
.dot.poor { background: #dc2626; }
.dot.historical { background: #94a3b8; }
.dot.gauge { background: #2563eb; }

.drawer {
  position: fixed; top: 64px; right: 12px; z-index: 1100; width: 320px; max-height: calc(100% - 90px);
  overflow-y: auto; background: #fff; border-radius: 14px; padding: 16px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25); transition: transform .2s, opacity .2s;
}
.drawer.hidden { transform: translateX(30px); opacity: 0; pointer-events: none; }
.drawer .close { position: absolute; top: 8px; right: 10px; border: none; background: none; font-size: 22px; cursor: pointer; color: #64748b; }
.drawer h2 { margin: 0 34px 12px 0; font-size: 16px; line-height: 1.3; }

.scoreRow { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.scoreDial {
  width: 64px; height: 64px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff; background: #94a3b8; flex-shrink: 0;
}
.band { font-weight: 600; font-size: 15px; text-transform: capitalize; }
.conf { font-size: 12px; color: #64748b; margin-top: 2px; }
.conf .chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-weight: 600; }
.chip.live { background: #dcfce7; color: #15803d; }
.chip.recent { background: #fef9c3; color: #a16207; }
.chip.historical { background: #e2e8f0; color: #475569; }

.factors { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.factor .frow { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 2px; }
.factor .bar { height: 6px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.factor .bar > i { display: block; height: 100%; border-radius: 4px; }

.meta { font-size: 12px; color: #64748b; border-top: 1px solid #e2e8f0; padding-top: 8px; }
.attribution { margin-top: 4px; }
.attribution a { color: #2563eb; text-decoration: none; }

.normRange { font-size: 11.5px; color: #64748b; margin: -4px 0 2px; }

.trends h3, .extras h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #94a3b8; margin: 10px 0 6px; }
.trendLoading { font-size: 12px; color: #94a3b8; }
.sparkLabel { font-size: 12.5px; margin: 6px 0 2px; }
.sparkRange { color: #94a3b8; font-size: 11px; }
.spark { display: block; background: #f8fafc; border-radius: 6px; }
.extras .frow { display: flex; justify-content: space-between; font-size: 12.5px; padding: 2px 0; }
.warn { color: #dc2626; font-weight: 600; }

.loading {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 1200;
  background: rgba(13,27,42,0.9); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px;
}

.clusterIcon {
  display: flex; align-items: center; justify-content: center; border-radius: 50%;
  color: #fff; font-weight: 700; box-shadow: 0 1px 6px rgba(0,0,0,0.35); border: 2px solid rgba(255,255,255,0.85);
}
.stationIcon { border-radius: 50%; border: 1.5px solid rgba(255,255,255,0.9); box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
