/* Mapa a pantalla completa + panel lateral colapsable */
html, body { overflow: hidden; }
#map { position: fixed; inset: 0; background: var(--bg); z-index: 0; }

/* Teselas oscuras calentadas hacia carbón/ámbar (sin el azul del mapa base) */
.leaflet-tile-pane { filter: sepia(.45) saturate(.75) brightness(.92) contrast(1.05); }
.leaflet-container { font-family: var(--mono); background: var(--bg); }
.leaflet-control-attribution { background: rgba(20, 17, 15, .75) !important; color: var(--texto-3) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--texto-2) !important; }
.leaflet-bar a, .leaflet-bar a:hover {
  background: var(--bg-2); color: var(--texto); border-bottom-color: var(--linea);
}
.leaflet-bar a:hover { background: var(--bg-3); color: var(--ambar); }
.leaflet-bar { border: 1px solid var(--linea); box-shadow: none; }

/* ---------------------------------------------------------------- panel */
#panel {
  position: fixed; top: 0; bottom: 0; left: 0; width: 392px; max-width: 100vw; z-index: 1000;
  background: rgba(20, 17, 15, .94); backdrop-filter: blur(6px);
  border-right: 1px solid var(--linea);
  display: flex; flex-direction: column;
  transition: transform .25s ease;
}
body.panel-cerrado #panel { transform: translateX(-100%); }
#toggle {
  position: fixed; top: 12px; left: 404px; z-index: 1001; width: 34px; height: 34px; padding: 0;
  background: var(--bg-2); font-size: 16px; line-height: 1; transition: left .25s ease;
}
body.panel-cerrado #toggle { left: 12px; }
#panel-scroll { overflow-y: auto; flex: 1; padding: 0 14px 20px; }

.cabecera { padding: 14px 14px 10px; border-bottom: 1px solid var(--linea); }
.logo { font-size: 18px; color: var(--ambar); display: flex; align-items: baseline; gap: 8px; }
.logo b { color: var(--magma); }
.logo .sub { font-size: 11px; color: var(--texto-2); letter-spacing: 0; font-weight: 400; }
.cabecera nav { margin-top: 6px; display: flex; gap: 14px; font-size: 12px; }
.pulso { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--magma); margin-right: 4px; animation: pulso 2s infinite; }
@keyframes pulso { 0% { box-shadow: 0 0 0 0 rgba(230,57,70,.7); } 70% { box-shadow: 0 0 0 8px rgba(230,57,70,0); } 100% { box-shadow: 0 0 0 0 rgba(230,57,70,0); } }

section.bloque { padding: 14px 0 4px; border-bottom: 1px dashed var(--linea); }
section.bloque:last-child { border-bottom: 0; }
section.bloque > h2 { font-size: 11px; text-transform: uppercase; color: var(--texto-2); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; }
section.bloque > h2 .nota { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--texto-3); }

.rejilla { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.rejilla label { display: block; font-size: 11px; color: var(--texto-2); }
.rejilla label.ancho { grid-column: 1 / -1; }
.rejilla label span { display: block; margin-bottom: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chips button { padding: 3px 8px; font-size: 11px; border-radius: 999px; color: var(--texto-2); }
.chips button.activo { border-color: var(--ambar); color: var(--ambar); }
.fila-check { margin: 8px 0; display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--texto-2); }
.acciones { display: flex; gap: 8px; margin: 10px 0 6px; }
.acciones button { flex: 1; }

.segmentado { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; }
.segmentado button { border: 0; border-radius: 0; background: var(--bg-2); color: var(--texto-2); padding: 8px; }
.segmentado button.activo { background: var(--ambar); color: #1a1209; font-weight: 700; }

#grafico-wrap { position: relative; height: 170px; }

/* ---------------------------------------------------------- últimos 20 */
#ultimos { list-style: none; margin: 0; padding: 0; }
#ultimos li {
  display: grid; grid-template-columns: 46px 1fr; gap: 10px; padding: 7px 4px;
  border-bottom: 1px solid rgba(58, 47, 40, .6); cursor: pointer; border-radius: 4px;
}
#ultimos li:hover { background: var(--bg-3); }
#ultimos li.nuevo { animation: nuevo 3s ease-out; }
@keyframes nuevo { from { background: rgba(255, 159, 28, .35); } to { background: transparent; } }
.mag-chip {
  align-self: start; text-align: center; font-weight: 700; font-size: 14px; padding: 5px 0;
  border-radius: 4px; color: #1a1209;
}
#ultimos .lugar { font-size: 12px; color: var(--texto); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#ultimos .meta { font-size: 11px; color: var(--texto-3); }
#reloj { color: var(--texto-3); }

/* ---------------------------------------------------- flotantes sobre el mapa */
#estado {
  position: fixed; right: 12px; bottom: 28px; z-index: 900; background: rgba(20, 17, 15, .85);
  border: 1px solid var(--linea); border-radius: var(--radio); padding: 6px 10px; font-size: 11px; color: var(--texto-2);
  max-width: min(60vw, 420px); text-align: right;
}
#estado.cargando::before { content: "◌ "; color: var(--ambar); }
#estado.error { color: var(--magma); border-color: var(--magma); }
#leyenda {
  position: fixed; right: 12px; bottom: 66px; z-index: 900; background: rgba(20, 17, 15, .85);
  border: 1px solid var(--linea); border-radius: var(--radio); padding: 8px 10px; font-size: 11px; width: 190px;
}
#leyenda .marcas { display: flex; justify-content: space-between; margin-top: 3px; color: var(--texto-2); }
#leyenda .circulos { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 8px; }
#leyenda .circulos i { display: block; border-radius: 50%; border: 1px solid rgba(255,255,255,.35); background: rgba(255, 159, 28, .45); }

#detalle {
  position: fixed; z-index: 950; right: 58px; top: 12px; width: 320px; max-width: calc(100vw - 24px);
  background: rgba(20, 17, 15, .96); border: 1px solid var(--linea); border-top: 3px solid var(--ambar);
  border-radius: var(--radio); padding: 12px 14px 12px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
}
#detalle[hidden] { display: none; }
#detalle .cerrar { position: absolute; right: 6px; top: 6px; border: 0; background: transparent; font-size: 16px; padding: 2px 8px; color: var(--texto-2); }
#detalle .grande { font-size: 34px; font-weight: 700; line-height: 1; }
#detalle .tipo { font-size: 12px; color: var(--texto-2); margin-left: 6px; font-weight: 400; }
#detalle .lugar { margin: 6px 24px 8px 0; color: var(--texto); }
#detalle dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 12px; }
#detalle dt { color: var(--texto-3); }
#detalle dd { margin: 0; text-align: right; }
#detalle .pie { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--linea); font-size: 11px; color: var(--texto-2); }

/* Marcador pulsante del sismo seleccionado */
.anillo { width: 44px; height: 44px; margin: -22px 0 0 -22px; border: 2px solid var(--ambar); border-radius: 50%; animation: anillo 1.6s ease-out infinite; }
@keyframes anillo { from { transform: scale(.4); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }

/* Clusters */
.cluster {
  display: flex; align-items: center; justify-content: center; border-radius: 50%; color: #1a1209; font-weight: 700;
  border: 2px solid rgba(255, 241, 208, .7); font-size: 11px; font-family: var(--mono);
}

/* ------------------------------------------------------------- móvil */
@media (max-width: 720px) {
  #panel { width: 100vw; }
  #toggle { left: auto; right: 12px; }
  body.panel-cerrado #toggle { left: auto; right: 12px; }
  #detalle { top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; max-width: none; }
  #leyenda { display: none; }
  #estado { bottom: 80px; right: 12px; }
  body:not(.panel-cerrado) #detalle { display: none; }
}
