.container {
  justify-content: flex-start;
}

main {
  justify-content: flex-start;
  align-items: stretch;
  padding-bottom: 0;
}

.mapa-header {
  text-align: center;
  padding: 2.5em 1em 1.4em;
}

.mapa-header h1 {
  display: inline-block;
  position: relative;
  padding-bottom: 14px;
  color: var(--gray, #555);
  font-size: clamp(1.2em, 1.5em + 2vw, 1.875em);
  font-weight: 900;
  text-transform: uppercase;
}

.mapa-header h1::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 48px;
  height: 3px;
  border-radius: 2px;
  transform: translateX(-50%);
  background: var(--yellow, #f9d821);
}

.mapa-header p {
  margin-top: 0.7em;
  color: #888;
  font-size: 0.93em;
  font-weight: 500;
}

.cidade-seletor {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 0 2em 1.5em;
}

.cidade-btn {
  padding: 10px 20px;
  font-family: "Montserrat", sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gray, #555);
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cidade-btn:hover {
  border-color: var(--yellow, #f9d821);
  box-shadow: 0 4px 12px rgba(249, 216, 33, 0.25);
}

.cidade-btn.ativa {
  background: var(--yellow, #f9d821);
  border-color: var(--yellow, #f9d821);
  color: #0f0f0f;
  box-shadow: 0 4px 14px rgba(249, 216, 33, 0.4);
}

.mapa-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0 2em 2em;
  box-sizing: border-box;
}

#map {
  width: 100%;
  height: 72vh;
  min-height: 420px;
  border: 1px solid #d0d0d0;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  z-index: 0;
}

.mapa-painel {
  position: absolute;
  top: 16px;
  right: calc(2em + 14px);
  z-index: 1005;
  min-width: 190px;
  padding: 1.2em 1.5em 1.4em;
  border: 1px solid #e0e0e0;
  border-top: 3px solid var(--yellow, #f9d821);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
  color: var(--gray, #555);
}

.painel-titulo {
  margin-bottom: 1em;
  padding-bottom: 0.6em;
  border-bottom: 1px solid #eee;
  color: var(--gray, #555);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.painel-stat {
  display: flex;
  flex-direction: column;
  margin-bottom: 0.85em;
}

.stat-num {
  color: var(--gray, #555);
  font-size: 1.6em;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.5px;
}

.stat-num.amarelo {
  color: #c8a800;
}

.stat-label {
  margin-top: 3px;
  color: #aaa;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.painel-progress {
  margin-top: 0.4em;
}

.progress-label {
  margin-bottom: 6px;
  color: #888;
  font-size: 11px;
}

.progress-label strong {
  color: #c8a800;
  font-weight: 800;
}

.progress-bar-track {
  width: 100%;
  height: 5px;
  border-radius: 99px;
  background: #eee;
  overflow: hidden;
}

.progress-bar-fill {
  width: 0%;
  height: 100%;
  border-radius: 99px;
  background: var(--yellow, #f9d821);
}

.mapa-legenda {
  position: absolute;
  right: calc(2em + 14px);
  bottom: calc(2em + 14px);
  z-index: 1005;
  display: flex;
  gap: 1em;
  padding: 0.5em 1em;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.leg-item {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #555;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.leg-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.leg-dot.mod {
  background: #f9d821;
  border: 1px solid #c8a800;
}

.leg-dot.pend {
  background: #e0e0e0;
  border: 1px solid #aaa;
}

.leaflet-control-layers,
.leaflet-control-geocoder {
  border: 1px solid #e0e0e0 !important;
  border-radius: 6px !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
  background: #fff !important;
  font-family: "Montserrat", sans-serif !important;
}

.leaflet-control-layers {
  font-size: 11px !important;
  font-weight: 700 !important;
}

.leaflet-control-geocoder-form input,
.leaflet-control-geocoder-alternatives {
  font-family: "Montserrat", sans-serif !important;
  font-size: 12px !important;
}

.leaflet-control-geocoder-form input {
  width: 220px !important;
}

.leaflet-popup-content-wrapper {
  padding: 0 !important;
  border: 1px solid #2e2e50 !important;
  border-radius: 7px !important;
  background: #1a1a2e !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
}

.leaflet-popup-content {
  margin: 0 !important;
  line-height: 1.4 !important;
}

.leaflet-popup-tip {
  background: #1a1a2e !important;
}

.leaflet-popup-close-button {
  top: 4px !important;
  right: 6px !important;
  color: #666 !important;
  font-size: 14px !important;
}

.popup-card {
  min-width: 150px;
  padding: 9px 13px 8px;
}

.popup-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 4px;
}

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

.popup-lbl {
  color: #555;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.popup-val {
  color: #d0d0d0;
  font-size: 11px;
  font-weight: 700;
}

.popup-val.led-val {
  color: #f9d821;
}

.leaflet-popup-content a.popup-btn,
.leaflet-popup-content a.popup-btn:visited,
.leaflet-popup-content a.popup-btn:link {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 6px 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  box-sizing: border-box;
  color: #c0c0c0 !important;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-align: center;
  text-decoration: none !important;
  text-transform: uppercase;
  transition: background 0.15s, color 0.15s;
}

.leaflet-popup-content a.popup-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #e8e8e8 !important;
}

@media (max-width: 1120px) {
  .mapa-wrapper {
    padding: 0 1em 1.5em;
  }

  .mapa-painel {
    right: calc(1em + 12px);
    min-width: 165px;
  }

  .mapa-legenda {
    right: calc(1em + 12px);
    bottom: calc(1.5em + 14px);
  }
}

@media (max-width: 500px) {
  .cidade-seletor {
    padding: 0 0.5em 1em;
    gap: 8px;
  }

  .cidade-btn {
    font-size: 11px;
    padding: 9px 14px;
  }

  .mapa-wrapper {
    padding: 0 0.5em 1em;
    flex-direction: column;
  }

  #map {
    order: 1;
    height: 55vh;
    min-height: 300px;
    border-radius: 8px;
  }

  .mapa-painel {
    position: static;
    order: 2;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.4em;
    margin-top: 0.75em;
    min-width: unset;
    border-radius: 8px;
  }

  .painel-titulo {
    grid-column: 1 / -1;
    margin-bottom: 0.2em;
  }

  .painel-stat {
    margin-bottom: 0;
  }

  .painel-progress {
    grid-column: 1 / -1;
  }

  .mapa-legenda {
    position: static;
    order: 3;
    justify-content: center;
    width: 100%;
    margin-top: 0.5em;
    border-radius: 8px;
    box-sizing: border-box;
  }
}
