/* ---------- Layout: barra lateral fija + mapa ---------- */
.layout {
  display: block;
}

.map-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  background: var(--bg);
  height: 82vh;
  min-height: 600px;
}

#map {
  grid-column: 2;
  grid-row: 1;
  width: 100%;
  height: 100%;
  background: #0d0806;
}

#map .leaflet-tile-pane {
  filter: grayscale(0.3) sepia(0.35) hue-rotate(320deg) brightness(0.55) contrast(1.05);
}

/* ---------- Barra lateral ---------- */
.float-panel {
  z-index: 400; /* debajo del header (1100) pero encima de los controles de Leaflet */
  display: flex;
  flex-direction: column;
}

.float-left {
  grid-column: 1;
  grid-row: 1;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--panel-border);
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border) transparent;
}

.card {
  background: rgba(28, 19, 13, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 14px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.float-left .card {
  background: none;
  backdrop-filter: none;
  border: none;
  border-bottom: 1px solid var(--panel-border);
  border-radius: 0;
  box-shadow: none;
  padding: 20px 24px;
}

.float-left .card:last-child { border-bottom: none; }

.card-label {
  margin: 0 0 12px 0;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ---------- Filtros ---------- */
.btn-group {
  display: flex;
  gap: 2px;
  background: #0d0806;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  padding: 3px;
}

.btn-filter {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 8px 6px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.btn-filter:hover {
  color: var(--text);
  background: rgba(255, 122, 61, 0.08);
}

.btn-filter.active {
  background: linear-gradient(135deg, var(--accent-strong), var(--muy-fuerte));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(255, 61, 46, 0.3);
}

.btn-filter:focus-visible,
.legend-toggle input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Leyenda ---------- */
.legend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text);
  padding: 6px 0;
}

.legend-toggle {
  cursor: pointer;
}

.legend-toggle input {
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

.legend-value {
  margin-left: auto;
  color: var(--text-faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

.dot-fuerte { background: var(--fuerte); box-shadow: 0 0 6px rgba(255,176,32,0.6); }
.dot-muy-fuerte { background: var(--muy-fuerte); box-shadow: 0 0 6px rgba(255,61,46,0.6); }
.dot-nasa { background: #ff9130; box-shadow: 0 0 6px rgba(255,145,48,0.6); }
.dot-ia { background: #3da5ff; box-shadow: 0 0 6px rgba(61,165,255,0.6); }
.dot-comunidad { background: #a34dff; box-shadow: 0 0 6px rgba(163,77,255,0.6); }

.region-fixed {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.region-fixed::before { content: "📍"; }

.risk-bar {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #6fa8c9, #f3d46b 45%, #e8782a 72%, #d8261c);
}

.risk-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- Franja inferior: un solo panel con dos bloques ---------- */
.float-right {
  position: absolute;
  left: 320px;
  right: 20px;
  bottom: 28px;
  flex-direction: row;
  align-items: stretch;
  background: rgba(28, 19, 13, 0.94);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.float-right .card {
  background: none;
  backdrop-filter: none;
  border: none;
  border-radius: 0;
  box-shadow: none;
  padding: 14px 22px;
}

.float-right .card + .card {
  flex: 1;
  min-width: 0;
  border-left: 1px solid var(--panel-border);
}

.float-right .card-label { margin-bottom: 8px; }

.summary-card {
  display: flex;
  align-items: center;
  gap: 32px;
}

.summary-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
}

.summary-row strong {
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.summary-row strong.danger { color: var(--muy-fuerte); }

.dept-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.dept-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
}

.dept-list li span.count {
  color: var(--fuerte);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ---------- Controles de Leaflet en tono oscuro ---------- */
.leaflet-bar a,
.leaflet-bar a:hover {
  background: var(--panel);
  color: var(--text);
  border-bottom: 1px solid var(--panel-border);
}

.leaflet-bar a:hover { background: var(--panel-alt); }

.leaflet-bar {
  border: 1px solid var(--panel-border);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.leaflet-control-attribution {
  background: rgba(15, 9, 6, 0.75) !important;
  color: var(--text-faint) !important;
}

.leaflet-control-attribution a { color: var(--text-dim) !important; }

.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  font-size: 13px;
}
.leaflet-popup-tip { background: var(--panel); }

/* ---------- "Que esta pasando hoy" ---------- */
.today-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  column-gap: 64px;
  align-content: start;
  padding: 56px max(48px, calc((100% - 1200px) / 2)) 48px;
  border-top: 1px solid var(--panel-border);
  background: var(--bg-soft);
}

.today-title {
  grid-column: 1;
  margin: 0 0 14px 0;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.today-text {
  grid-column: 1;
  max-width: 56ch;
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.7;
  margin: 0 0 10px 0;
}

.today-updated { grid-column: 1; color: var(--text-faint); font-size: 12.5px; margin: 0; }

.stats-grid {
  grid-column: 2;
  grid-row: 1 / span 3;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 40px;
}

.stat-card {
  display: flex;
  flex-direction: column-reverse; /* etiqueta arriba, cifra abajo */
  justify-content: flex-end;
  gap: 8px;
  padding: 20px 0 24px;
  border-top: 1px solid var(--panel-border);
}

.stat-top { display: flex; align-items: baseline; gap: 10px; }

.stat-number {
  font-size: 42px;
  line-height: 1;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(255, 122, 61, 0.25);
}

.stat-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
}

.stat-trend { font-size: 13px; font-weight: 600; }
.stat-trend.up { color: var(--muy-fuerte); }
.stat-trend.down { color: var(--live); }

.today-sources {
  grid-column: 1 / -1;
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid var(--panel-border);
  font-size: 12px;
  color: var(--text-faint);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .map-wrap { display: block; height: auto; min-height: 0; }
  #map { height: 62vh; }
  .float-left { border-right: none; border-bottom: 1px solid var(--panel-border); }
  .float-right {
    position: static;
    flex-direction: column;
    border-radius: 0;
    border-width: 0 0 1px 0;
    box-shadow: none;
  }
  .float-right .card + .card { border-left: none; border-top: 1px solid var(--panel-border); }
  .summary-card { justify-content: space-between; gap: 12px; }
  .today-summary { display: block; padding: 32px 20px; }
  .stats-grid { margin-top: 24px; }
  .stat-number { font-size: 34px; }
}