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

body {
  background: #0d0f12;
  color: #e2e6ef;
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
  min-height: 100vh;
  padding: 2rem 1.5rem;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f87171;
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.75); }
}

h1 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: #e2e6ef;
}

.meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  color: #6b7280;
}

.refresh-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  background: #14171c;
  color: #6b7280;
  border: 1px solid #262b35;
  border-radius: 6px;
  padding: 5px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.refresh-btn:hover {
  color: #e2e6ef;
  border-color: #3d4454;
}

/* ── Grid ── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
}

/* ── Panel ── */
.panel {
  background: #14171c;
  border: 1px solid #262b35;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.police-top { border-top: 2px solid #4a9eff; }
.ems-top    { border-top: 2px solid #f87171; }
.fire-top   { border-top: 2px solid #fb923c; }

.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid #262b35;
}

.panel-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.panel-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.panel-count {
  margin-left: auto;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  padding: 2px 9px;
  border-radius: 99px;
  font-weight: 500;
}

.panel-body {
  padding: 0 16px;
  flex: 1;
}

.panel-footer {
  padding: 9px 16px;
  border-top: 1px solid #262b35;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.63rem;
}

.panel-footer a {
  text-decoration: none;
}

.panel-footer a:hover {
  text-decoration: underline;
}

/* ── Call rows ── */
.call-row {
  padding: 11px 0;
  border-bottom: 1px solid #262b35;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.call-row:last-child {
  border-bottom: none;
}

.call-left {
  flex: 1;
  min-width: 0;
}

.call-type {
  font-size: 0.83rem;
  font-weight: 500;
  color: #e2e6ef;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-addr {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.67rem;
  color: #6b7280;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.call-sub {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.63rem;
  color: #3d4454;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pills {
  display: flex;
  gap: 5px;
  margin-top: 5px;
  flex-wrap: wrap;
  align-items: center;
}

.pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  font-weight: 500;
  padding: 1px 7px;
  border-radius: 4px;
}

.zip {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.62rem;
  color: #3d4454;
}

.time-badge {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.63rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 2px;
}

/* ── State messages ── */
.empty {
  padding: 22px 0;
  text-align: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: #3d4454;
}

.error-msg {
  padding: 22px 0;
  text-align: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: #fca5a5;
}

/* ── Debug page ── */
.debug-page {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  color: #e2e6ef;
  white-space: pre-wrap;
  line-height: 1.6;
}

.debug-page h2 {
  font-size: 0.9rem;
  margin-bottom: 1rem;
  color: #4a9eff;
}

/* ── Map Section ── */
.map-section {
  margin-top: 1.5rem;
  background: #14171c;
  border: 1px solid #262b35;
  border-radius: 10px;
  overflow: hidden;
}

.map-header {
  padding: 12px 16px;
  border-bottom: 1px solid #262b35;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.map-title-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.map-title {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  color: #e2e6ef;
}

.map-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.65rem;
  color: #6b7280;
}

.legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 3px;
}

/* ── Weather bar ── */
.weather-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  color: #e2e6ef;
}

.weather-icon { font-size: 1.1rem; }
.weather-temp { font-weight: 500; font-size: 0.85rem; }
.weather-desc { color: #6b7280; }
.weather-detail { color: #6b7280; }

/* ── Map container ── */
#map {
  height: 480px;
  width: 100%;
  background: #0d0f12;
}

/* Override Leaflet popups for dark theme */
.leaflet-popup-content-wrapper {
  background: #1c2029;
  color: #e2e6ef;
  border: 1px solid #262b35;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

.leaflet-popup-tip {
  background: #1c2029;
}

.leaflet-popup-close-button {
  color: #6b7280 !important;
}

/* ── Locate button ── */
.call-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.locate-btn {
  background: none;
  border: 1px solid #262b35;
  border-radius: 5px;
  color: #6b7280;
  font-size: 0.75rem;
  padding: 2px 5px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.locate-btn:hover {
  color: #e2e6ef;
  border-color: #3d4454;
}
