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

:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2a3544;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --accent: #3b9eff;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --zone: rgba(248, 113, 113, 0.25);
}

html, body {
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.header__icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.header__city {
  color: var(--text-muted);
  font-weight: 400;
}

.header__stats {
  display: flex;
  gap: 1.25rem;
  flex: 1;
}

.stat {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat strong {
  color: var(--text);
  font-weight: 600;
}

.header__meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.last-updated {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.refresh-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.refresh-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.refresh-btn svg {
  width: 16px;
  height: 16px;
}

.refresh-btn--spinning svg {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.main {
  position: relative;
  height: calc(100% - 53px);
}

#map {
  width: 100%;
  height: 100%;
}

.legend {
  position: absolute;
  bottom: 1.5rem;
  left: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-size: 0.8rem;
  z-index: 1;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.legend h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.legend__scale {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.legend__gradient {
  flex: 1;
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(to right, #ef4444, #f97316, #eab308, #84cc16, #22c55e, #10b981);
}

.legend__scale-label {
  margin: 0.25rem 0 0.6rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

.legend ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot--available { background: var(--green); }
.dot--empty { background: var(--red); }
.dot--full { background: var(--yellow); }

.zone {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  flex-shrink: 0;
}

.zone--restricted {
  background: var(--zone);
  border: 1px solid var(--red);
}

.legend__note {
  margin-top: 0.6rem;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.error-banner {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #7f1d1d;
  color: #fecaca;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 2;
  max-width: 90%;
  text-align: center;
}

.mapboxgl-popup-content {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-radius: 10px !important;
  padding: 0.85rem 1rem !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
  font-family: inherit !important;
}

.mapboxgl-popup-tip {
  border-top-color: var(--surface) !important;
}

.popup__title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

.popup__row {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.popup__row strong {
  color: var(--text);
}

.popup__status {
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

@media (max-width: 600px) {
  .header__stats {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  .legend {
    bottom: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
  }
}
