* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  padding: 0;
  background: #f5f6f8;
  color: #2a2a2a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 32px;
  background: #fff;
  border-bottom: 1px solid #e8e8ec;
}

.header-titulo {
  flex: 1;
  min-width: 260px;
}

.header-titulo h1 {
  margin: 0;
  color: #1a1a1a;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.header-titulo p {
  margin: 3px 0 0;
  color: #888;
  font-size: 12px;
  font-weight: 400;
}

.header-logos {
  display: flex;
  align-items: center;
  gap: 18px;
}

.logo-cides {
  width: auto;
  height: 40px;
  filter: invert(1) brightness(0.2);
}

.header-logo-tagh {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #1a1a1a;
  font-family: "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 1px;
}

.header-logo-tagh::after {
  display: inline-block;
  width: 6px;
  height: 20px;
  margin-left: 4px;
  background: #c8102e;
  content: "";
}

.header-logo-tagh .sub {
  color: #666;
  font-size: 11px;
  font-weight: 300;
  letter-spacing: 1.4px;
}

.filtros-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  padding: 14px 32px;
  background: #fff;
  border-bottom: 1px solid #e8e8ec;
}

.filtros-row.row-2 {
  grid-template-columns: 1fr;
  padding-top: 0;
  padding-bottom: 16px;
}

.filtro select {
  width: 100%;
  min-width: 0;
  padding: 10px 36px 10px 14px;
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid #d6d8dc;
  border-radius: 6px;
  background: #fff url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8.5L1.5 4h9z'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: #333;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.filtro select:hover {
  border-color: #999;
}

.filtro select:focus {
  border-color: #1f4e78;
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 78, 120, 0.1);
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 20px;
  padding: 20px 32px 12px;
}

.mapa-wrap {
  position: relative;
  overflow: hidden;
  min-width: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

#map {
  width: 100%;
  height: 560px;
  background: #f8f9fb;
}

.mapa-titulo {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 400;
  padding: 5px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  color: #333;
  font-size: 11px;
  font-weight: 700;
}

.kpis {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kpi {
  padding: 18px 16px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.kpi-label {
  margin-bottom: 6px;
  color: #666;
  font-size: 13px;
  font-weight: 500;
}

.kpi-valor {
  color: #1a1a1a;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0;
}

.kpi-extra {
  margin-top: 4px;
  color: #999;
  font-size: 11px;
}

.legend {
  min-width: 140px;
  padding: 10px 12px;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
  font-size: 11px;
  line-height: 1.5;
}

.legend .titulo {
  margin-bottom: 6px;
  color: #333;
  font-size: 11px;
  font-weight: 700;
}

.legend-bar {
  height: 10px;
  margin-bottom: 4px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 2px;
  background: linear-gradient(to right, #1a9850 0%, #91cf60 20%, #d9ef8b 40%, #fee08b 60%, #fc8d59 80%, #d73027 100%);
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  color: #666;
  font-size: 10px;
}

.legend-sin-dato {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: #666;
  font-size: 10px;
}

.legend-sin-dato i {
  display: inline-block;
  width: 14px;
  height: 10px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #e6e6e6;
}

.leaflet-tooltip.lc-label {
  padding: 1px 5px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  color: #1a1a1a;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
}

.leaflet-tooltip.lc-label::before {
  display: none;
}

.leaflet-tooltip.lc-label.label-grande {
  padding: 2px 7px;
  font-size: 12px;
}

.leaflet-tooltip.lc-label.label-chico {
  padding: 1px 3px;
  font-size: 9px;
}

.leaflet-popup-content {
  min-width: 240px;
  margin: 12px 14px;
}

.popup-tabla h4 {
  margin: 0 0 4px;
  color: #1a1a1a;
  font-size: 14px;
  font-weight: 700;
}

.popup-tabla .sub {
  margin-bottom: 8px;
  color: #888;
  font-size: 11px;
}

.popup-tabla table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.popup-tabla td {
  padding: 3px 0;
}

.popup-tabla td:first-child {
  color: #666;
}

.popup-tabla td:last-child {
  color: #1a1a1a;
  font-weight: 600;
  text-align: right;
}

.popup-tabla tr.destacado td {
  padding-top: 6px;
  border-top: 1px solid #e8e8ec;
  color: #1f4e78;
  font-weight: 700;
}

.disclaimer {
  margin-top: 8px;
  padding: 14px 32px 20px;
  border-top: 1px solid #e8e8ec;
  color: #888;
  font-size: 11px;
  line-height: 1.5;
}

.disclaimer strong {
  color: #555;
}

#status {
  position: fixed;
  bottom: 14px;
  left: 50%;
  z-index: 9999;
  transform: translateX(-50%);
  padding: 7px 16px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 11px;
  transition: opacity 0.3s;
}

#status.hidden {
  opacity: 0;
  pointer-events: none;
}

.is-hidden {
  display: none !important;
}

.auth-gate {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
  background: #f5f6f8;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.auth-card h1 {
  margin: 0 0 6px;
  color: #1a1a1a;
  font-size: 20px;
  font-weight: 700;
}

.auth-card p {
  margin: 0 0 18px;
  color: #888;
  font-size: 13px;
}

.auth-card input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid #d6d8dc;
  border-radius: 6px;
  font-size: 14px;
}

.auth-card input:focus {
  border-color: #1f4e78;
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 78, 120, 0.1);
}

.auth-card button {
  width: 100%;
  margin-top: 12px;
  padding: 11px 14px;
  border: none;
  border-radius: 6px;
  background: #1f4e78;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.auth-card button:hover {
  background: #163a5a;
}

.auth-msg {
  margin-top: 14px;
  min-height: 18px;
  color: #555;
  font-size: 12px;
  line-height: 1.4;
}

.auth-logout {
  padding: 7px 14px;
  border: 1px solid #d6d8dc;
  border-radius: 6px;
  background: #fff;
  color: #555;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.auth-logout:hover {
  border-color: #999;
}

.admin-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 24px 32px;
}

.admin-add {
  display: flex;
  gap: 10px;
  margin-bottom: 6px;
}

.admin-add input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d6d8dc;
  border-radius: 6px;
  font-size: 14px;
}

.admin-add button {
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  background: #1f4e78;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.admin-search {
  width: 100%;
  margin-top: 14px;
  padding: 9px 14px;
  border: 1px solid #d6d8dc;
  border-radius: 6px;
  font-size: 13px;
}

.admin-search:focus {
  border-color: #1f4e78;
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 78, 120, 0.1);
}

.allowlist {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.allowlist li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid #e8e8ec;
  border-radius: 6px;
  margin-bottom: 8px;
  background: #fff;
  font-size: 13px;
}

.allowlist li.vacio {
  justify-content: center;
  color: #999;
}

.allowlist .quitar {
  padding: 5px 12px;
  border: 1px solid #e0b4b4;
  border-radius: 6px;
  background: #fff;
  color: #b23b3b;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.allowlist .quitar:hover {
  background: #fdf1f1;
}

@media (max-width: 900px) {
  .header {
    flex-wrap: wrap;
  }

  .filtros-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    grid-template-columns: 1fr;
  }

  .kpis {
    flex-flow: row wrap;
  }

  .kpi {
    flex: 1 1 calc(33% - 14px);
    min-width: 140px;
  }
}

@media (max-width: 560px) {
  .header,
  .filtros-row,
  .main,
  .disclaimer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .filtros-row {
    grid-template-columns: 1fr;
  }

  #map {
    height: 480px;
  }

  .kpi {
    flex-basis: 100%;
  }
}
