:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --surface-2: #e8edf2;
  --text: #1a2a3a;
  --muted: #5e7285;
  --line: #d0d8e0;
  --brand: #31546A;
  --accent: #65A6A7;
  --alto: #b42318;
  --alto-bg: #fde7e4;
  --medio: #b45309;
  --medio-bg: #fdf0dc;
  --bajo: #2f6f4f;
  --bajo-bg: #e3f2ea;
  --neutro-bg: #eceff3;
  --header: #31546A;
  --header-text: #e8f0f4;
  --shadow: 0 2px 12px rgba(15, 27, 42, .1), 0 1px 3px rgba(15, 27, 42, .06);
  --r: 10px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f1b24;
  --surface: #182530;
  --surface-2: #1e2f3c;
  --text: #dce8f0;
  --muted: #8a9fb2;
  --line: #2a3d4e;
  --brand: #65A6A7;
  --accent: #7ec0c1;
  --alto: #ff8a7a;
  --alto-bg: #3a1714;
  --medio: #fbbf62;
  --medio-bg: #36260e;
  --bajo: #7dd3a4;
  --bajo-bg: #12301f;
  --neutro-bg: #1b2b3b;
  --header: #1a2d3d;
  --header-text: #c8dae8;
  --shadow: 0 4px 16px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1b24;
    --surface: #182530;
    --surface-2: #1e2f3c;
    --text: #dce8f0;
    --muted: #8a9fb2;
    --line: #2a3d4e;
    --brand: #65A6A7;
    --accent: #7ec0c1;
    --alto: #ff8a7a;
    --alto-bg: #3a1714;
    --medio: #fbbf62;
    --medio-bg: #36260e;
    --bajo: #7dd3a4;
    --bajo-bg: #12301f;
    --neutro-bg: #1b2b3b;
    --header: #1a2d3d;
    --header-text: #c8dae8;
    --shadow: 0 4px 16px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
h1 { font-size: 1.2rem; line-height: 1.25; margin: .2rem 0 .4rem; letter-spacing: -.01em; text-wrap: balance; }
h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 1rem 0 .35rem; }
.small, .hint { font-size: .78rem; color: var(--muted); }
.lead { color: var(--muted); margin: 0 0 .8rem; font-size: .85rem; }

#map { position: fixed; inset: 0; background: var(--bg); opacity: 0; transition: opacity .4s ease; }
#map.listo { opacity: 1; }

/* ═══ HEADER ═══ */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 0;
  background: var(--header); color: var(--header-text);
  height: 56px; padding: 0 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar-left { display: flex; align-items: center; flex-shrink: 0; }
.brand {
  display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--header-text);
  padding: 4px 0; white-space: nowrap;
}
.brand img { border-radius: 4px; width: 38px; height: 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 1.05rem; font-weight: 700; }
.brand-name b { color: var(--accent); }
.brand-sub { font-size: .68rem; opacity: .7; letter-spacing: .02em; }

.topbar-nav {
  display: flex; align-items: center; gap: 3px; margin: 0 auto;
  padding: 0 20px; overflow-x: auto; scrollbar-width: none;
}
.topbar-nav::-webkit-scrollbar { display: none; }
.topbar-nav button {
  border: 0; background: transparent; color: rgba(255,255,255,.65);
  padding: 7px 14px; border-radius: 6px; font-size: .85rem; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s;
}
.topbar-nav button:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar-nav button[aria-checked="true"] { background: var(--accent); color: #fff; }

.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.data-freshness {
  font-size: .65rem; color: rgba(255,255,255,.65); white-space: nowrap;
  padding: 2px 7px; border-radius: 4px; background: rgba(255,255,255,.08);
  line-height: 1.3; display: none;
}
@media (min-width: 700px) { .data-freshness { display: inline-block; } }
.tema {
  width: 32px; height: 32px; border: 0; border-radius: 6px; background: rgba(255,255,255,.1);
  color: var(--header-text); display: grid; place-items: center; flex-shrink: 0;
}
.tema:hover { background: rgba(255,255,255,.2); }
.btn-info-hdr {
  width: 32px; height: 32px; border: 0; border-radius: 6px; background: rgba(255,255,255,.1);
  color: var(--header-text); display: grid; place-items: center; flex-shrink: 0;
}
.btn-info-hdr:hover { background: rgba(255,255,255,.2); }

/* ═══ SECONDARY TOOLBAR ═══ */
.toolbar2 {
  position: fixed; top: 56px; left: 0; right: 0; z-index: 9;
  display: flex; align-items: flex-start; gap: 8px; padding: 6px 12px;
  pointer-events: none;
}
.toolbar2 > * { pointer-events: auto; }
.tool-group {
  display: flex; gap: 4px; background: var(--surface); border-radius: 8px; padding: 3px;
  box-shadow: var(--shadow);
}
.tool-btn {
  border: 0; background: transparent; padding: 5px 10px; border-radius: 6px;
  font-size: .75rem; font-weight: 600; color: var(--muted); white-space: nowrap;
  display: inline-flex; align-items: center; gap: 4px; transition: background .15s;
}
.tool-btn:hover { background: var(--surface-2); }
.tool-btn[aria-pressed="true"] { background: var(--brand); color: #fff; }
.tool-btn svg { flex-shrink: 0; }

.leyenda {
  max-width: 330px; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: .72rem; margin-left: auto;
}
.leyenda:empty { display: none; }
.leyenda .tit { font-weight: 700; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }
.leyenda .tit a { font-weight: 500; }
.leyenda .fila { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.leyenda .sw { width: 14px; height: 10px; border-radius: 3px; flex: none; border: 1px solid rgba(0,0,0,.12); }
.leyenda .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.info-i { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .6rem; font-weight: 700; font-style: italic; cursor: help; margin-left: auto; flex: none; position: relative; font-family: Georgia, serif; }
.info-i .info-tip { display: none; position: absolute; bottom: calc(100% + 6px); right: -8px; width: 220px; padding: 8px 10px; background: var(--surface); color: var(--text); border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.25); font-size: .72rem; font-weight: 400; font-style: normal; line-height: 1.4; z-index: 90; pointer-events: none; white-space: normal; }
.info-i:hover .info-tip, .info-i:focus .info-tip { display: block; }

/* ═══ LEFT PANEL ═══ */
.panel {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; height: 88dvh;
  background: var(--surface); border-radius: 16px 16px 0 0; box-shadow: var(--shadow);
  transform: translateY(calc(88dvh - var(--peek, 42dvh))); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom);
}
.panel.abierto { transform: translateY(0); }
.panel.min { --peek: 132px; }
.handle { border: 0; background: transparent; padding: 10px 0 4px; display: flex; justify-content: center; flex: none; }
.handle span { width: 42px; height: 5px; border-radius: 3px; background: var(--line); }
.panel-body { overflow-y: auto; padding: 4px 14px 24px; overscroll-behavior: contain; flex: 1; }

@media (min-width: 1100px) {
  .toolbar2 { left: 340px; top: 56px; }
  .panel {
    top: 56px; left: 0; bottom: 56px; right: auto; width: 340px; height: auto;
    border-radius: 0; transform: none !important; box-shadow: 2px 0 8px rgba(0,0,0,.08);
  }
  .handle { display: none; }
  .panel-body { padding: 10px 14px 24px; }
}
@media (min-width: 900px) and (max-width: 1099px) {
  .toolbar2 { left: 320px; top: 56px; }
  .panel {
    top: 56px; left: 0; bottom: 56px; right: auto; width: 320px; height: auto;
    border-radius: 0; transform: none !important; box-shadow: 2px 0 8px rgba(0,0,0,.08);
  }
  .handle { display: none; }
  .panel-body { padding: 10px 14px 24px; }
}

/* ═══ ALERT / CARD STYLES ═══ */
.pr-card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.pr-card-header {
  padding: 8px 12px; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  display: flex; align-items: center; gap: 8px;
}
.pr-header-alerta { background: #fef3c7; color: #92400e; }
.pr-header-datos { background: #dbeafe; color: #1e40af; }
.pr-header-escenarios { background: #d1fae5; color: #065f46; }
.pr-card-body { padding: 10px 12px; font-size: .82rem; }
.pr-pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 currentColor; } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

:root[data-theme="dark"] .pr-header-alerta { background: #451a03; color: #fde68a; }
:root[data-theme="dark"] .pr-header-datos { background: #172554; color: #93c5fd; }
:root[data-theme="dark"] .pr-header-escenarios { background: #022c22; color: #6ee7b7; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .pr-header-alerta { background: #451a03; color: #fde68a; }
  :root:not([data-theme="light"]) .pr-header-datos { background: #172554; color: #93c5fd; }
  :root:not([data-theme="light"]) .pr-header-escenarios { background: #022c22; color: #6ee7b7; }
}

/* ═══ BUTTONS ═══ */
.cta {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 0; border-radius: 8px; padding: 10px 14px; background: var(--brand); color: #fff; font-weight: 700; font-size: .9rem;
}
.cta:hover { filter: brightness(1.1); }
.cta:disabled { opacity: .6; cursor: progress; }
.cta.secundario { background: var(--surface-2); color: var(--text); }
.cta.chico { width: auto; padding: 7px 11px; font-size: .82rem; }
.fila-botones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.volver { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 600; font-size: .85rem; margin-bottom: 6px; }

/* ═══ RESULTS ═══ */
.lugar { color: var(--muted); font-size: .82rem; margin: 0; }
.nivel { display: flex; gap: 12px; align-items: center; border-radius: 10px; padding: 10px 12px; margin: 8px 0 4px; }
.nivel .n { font-size: 1.15rem; font-weight: 800; letter-spacing: -.01em; }
.nivel p { margin: 2px 0 0; font-size: .82rem; }
.nivel.alto { background: var(--alto-bg); color: var(--alto); }
.nivel.medio { background: var(--medio-bg); color: var(--medio); }
.nivel.bajo { background: var(--bajo-bg); color: var(--bajo); }
.nivel .ic { width: 34px; height: 34px; border-radius: 50%; background: currentColor; flex: none; display: grid; place-items: center; }
.nivel .ic svg { color: var(--surface); }

.senales { list-style: none; padding: 0; margin: 8px 0 0; }
.senal { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.senal .tag { grid-row: span 2; align-self: start; font-size: .65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; padding: 3px 7px; border-radius: 6px; min-width: 56px; text-align: center; }
.senal .tag.alto { background: var(--alto-bg); color: var(--alto); }
.senal .tag.medio { background: var(--medio-bg); color: var(--medio); }
.senal .tag.bajo { background: var(--bajo-bg); color: var(--bajo); }
.senal .tag.neutro { background: var(--neutro-bg); color: var(--muted); }
.senal b { font-size: .85rem; }
.senal p { margin: 0; font-size: .8rem; color: var(--muted); }
.senal p a { white-space: nowrap; }

.consejos { background: var(--surface-2); border-radius: 10px; padding: 4px 12px; margin-top: 10px; }
.consejos ul { margin: 0 0 10px; padding-left: 18px; font-size: .82rem; }
.consejos li { margin: 4px 0; }

/* ═══ DEPTH LEGEND ═══ */
.depth-legend {
  position: fixed; z-index: 8; top: 104px; left: 50%; transform: translateX(-50%);
  background: var(--surface); border-radius: 10px; box-shadow: var(--shadow);
  padding: 6px 14px 8px; text-align: center; min-width: 220px;
}
.depth-title { font-size: .72rem; font-weight: 700; color: var(--text); }
.depth-bar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; margin: 4px 0 2px; }
.depth-swatch { flex: 1; }
.depth-labels { display: flex; justify-content: space-between; font-size: .65rem; color: var(--muted); }
@media (min-width: 900px) { .depth-legend { left: calc(340px + (100% - 340px) / 2); } }

.resumen { margin-top: 12px; }
.estado-card { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: .8rem; }
.estado-card .vencido { color: var(--medio); font-weight: 600; }
.quebradas-lista { list-style: none; padding: 0; margin: 6px 0 0; }
.quebradas-lista button { display: flex; width: 100%; justify-content: space-between; gap: 8px; text-align: left; border: 0; border-top: 1px solid var(--line); background: none; padding: 7px 0; font-size: .82rem; }
.quebradas-lista button span:last-child { color: var(--muted); white-space: nowrap; }

/* ═══ MODEL STATS ═══ */
.modelo-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; margin: 8px 0; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 7px 9px; }
.stat .v { font-size: 1rem; font-weight: 800; }
.stat .k { font-size: .7rem; color: var(--muted); }
.perfil { width: 100%; height: 90px; display: block; margin: 6px 0; }
.perfil.anchos-chart { height: 120px; }
.storm-select { width: 100%; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: .82rem; cursor: pointer; appearance: auto; }
.toggles { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.toggles label { display: inline-flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: 999px; padding: 5px 10px; font-size: .75rem; cursor: pointer; }
.aviso { border-left: 3px solid var(--medio); background: var(--medio-bg); padding: 7px 9px; border-radius: 0 8px 8px 0; font-size: .78rem; margin: 8px 0; color: var(--text); }
.cargando { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 10px 0; font-size: .82rem; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; z-index: 12; left: 50%; transform: translateX(-50%); bottom: calc(44dvh + 10px);
  background: var(--text); color: var(--surface); padding: 8px 14px; border-radius: 8px; font-size: .82rem; box-shadow: var(--shadow); max-width: calc(100% - 32px);
}
@media (min-width: 900px) { .toast { bottom: 24px; left: 50%; } }

.hist-flot {
  position: fixed; z-index: 8; left: 50%; transform: translateX(-50%); bottom: calc(44dvh + 10px); width: min(420px, calc(100% - 24px));
  background: var(--surface); color: var(--text); border-radius: 10px; box-shadow: var(--shadow); padding: 10px 12px; font-size: .82rem;
}
.hist-flot .fila-h { display: flex; align-items: center; gap: 8px; }
.hist-flot .fila-h b { flex: 1; }
.hist-flot .cerrar { border: 0; background: var(--surface-2); border-radius: 50%; width: 28px; height: 28px; font-size: 16px; line-height: 1; }
.hist-flot .deslizador { margin: 6px 0 2px; }
.hist-flot .opciones { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
@media (min-width: 900px) { .hist-flot { bottom: 24px; } }

dialog { border: 0; border-radius: 12px; padding: 0; max-width: min(560px, calc(100% - 24px)); max-height: 86dvh; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(8, 19, 31, .5); }
.dlg { padding: 20px 22px; }
.dlg ul { padding-left: 18px; font-size: .85rem; }
.dlg li { margin: 5px 0; }
.dlg p { font-size: .85rem; }
.fuentes { font-size: .8rem !important; }
.tel { display: flex; gap: 8px; flex-wrap: wrap; }
.tel a { background: var(--alto-bg); color: var(--alto); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-weight: 700; }

.visitas { display: inline-flex; align-items: center; gap: 6px; margin: 2px 0 0; font-size: .78rem; color: var(--muted); }
.visitas b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ═══ HISTORY ═══ */
.eventos { list-style: none; padding: 0; margin: 0; }
.evento { border-top: 1px solid var(--line); padding: 8px 0; }
.evento.activo .ev-cab { background: var(--surface-2); }
.ev-cab { display: flex; gap: 12px; align-items: center; width: 100%; text-align: left; border: 0; background: none; padding: 6px; border-radius: 8px; }
.ev-cab > span:last-child { display: flex; flex-direction: column; }
.ev-anio { font-weight: 800; font-size: 1rem; color: var(--brand); min-width: 56px; }
.evento details { font-size: .82rem; }
.evento summary, .consejos summary { cursor: pointer; color: var(--accent); font-weight: 600; padding: 4px 0; }
.evento p { margin: 6px 0; }
.deslizador { display: flex; align-items: center; gap: 8px; margin: 10px 0 4px; font-size: .82rem; }
.deslizador input { flex: 1; }

/* ═══ MAP POPUPS ═══ */
.maplibregl-popup-content { background: var(--surface) !important; color: var(--text); border-radius: 10px !important; box-shadow: var(--shadow) !important; padding: 10px 12px !important; font-size: .82rem; }
.maplibregl-popup-tip { border-top-color: var(--surface) !important; border-bottom-color: var(--surface) !important; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 18px; }
.pop p { margin: 6px 0; }
.pop b { font-size: .85rem; }

/* ═══ MAPLIBRE CONTROLS ═══ */
.maplibregl-ctrl-group { background: var(--surface) !important; box-shadow: var(--shadow) !important; border-radius: 8px !important; }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
[data-theme="dark"] .maplibregl-ctrl-icon { filter: invert(1); }
.maplibregl-ctrl-attrib { font-size: 10px; }
.ctrl-ubicacion button { display: grid; place-items: center; color: var(--text); }
.ctrl-ubicacion button.buscando svg { animation: pulso-ubic 1s ease-in-out infinite; color: var(--accent); }
@keyframes pulso-ubic { 50% { opacity: .35; } }
.maplibregl-ctrl-bottom-right { bottom: 132px; }
@media (min-width: 900px) { .maplibregl-ctrl-bottom-right { bottom: 58px; } }
.maplibregl-ctrl-top-right { top: 100px; }
@media (min-width: 900px) { .maplibregl-ctrl-top-right { top: 60px !important; } }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.nivel-rio b { min-width: 3.4em; text-align: right; font-size: 1rem; }
.nivel-rio input { accent-color: var(--accent); }

/* ═══ ADDRESS SEARCH ═══ */
.buscar-inicio { margin: 8px 0; }
.buscar-inicio .buscar-dir-row input { font-size: .88rem; padding: 9px 11px; }
.buscar-inicio .buscar-dir-row .cta { padding: 9px 16px; font-size: .88rem; }
.escenario-fila { transition: outline .15s, transform .1s; }
.escenario-fila:hover { transform: translateX(2px); }

/* ═══ ACCORDION SECTIONS ═══ */
.seccion-acordeon { margin: 6px 0; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.seccion-acordeon summary { padding: 9px 12px; font-weight: 700; font-size: .82rem; cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 8px; user-select: none; transition: background .15s; }
.seccion-acordeon summary::-webkit-details-marker { display: none; }
.seccion-acordeon summary::after { content: '▸'; font-size: .9rem; transition: transform .2s; flex-shrink: 0; }
.seccion-acordeon[open] summary::after { transform: rotate(90deg); }
.seccion-contenido { padding: 6px 12px 10px; }
.seccion-alertas summary { background: #ef4444; color: #fff; }
.seccion-alertas { border-color: #ef4444; }
.seccion-rios summary { background: #0b3d91; color: #fff; }
.seccion-rios { border-color: #0b3d91; }
.seccion-quebradas summary { background: #2e7dc9; color: #fff; }
.seccion-quebradas { border-color: #2e7dc9; }
.seccion-historia summary { background: #31546A; color: #fff; }
.seccion-historia { border-color: #31546A; }
:root[data-theme="dark"] .seccion-alertas summary { background: #b91c1c; color: #fee; }
:root[data-theme="dark"] .seccion-alertas { border-color: #b91c1c; }
:root[data-theme="dark"] .seccion-rios summary { background: #0a2f6e; color: #c8ddf8; }
:root[data-theme="dark"] .seccion-rios { border-color: #0a2f6e; }
:root[data-theme="dark"] .seccion-quebradas summary { background: #1a5a9e; color: #d0e4f8; }
:root[data-theme="dark"] .seccion-quebradas { border-color: #1a5a9e; }
:root[data-theme="dark"] .seccion-historia summary { background: #1e3648; color: #b8d0e2; }
:root[data-theme="dark"] .seccion-historia { border-color: #1e3648; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .seccion-alertas summary { background: #b91c1c; color: #fee; }
  :root:not([data-theme="light"]) .seccion-alertas { border-color: #b91c1c; }
  :root:not([data-theme="light"]) .seccion-rios summary { background: #0a2f6e; color: #c8ddf8; }
  :root:not([data-theme="light"]) .seccion-rios { border-color: #0a2f6e; }
  :root:not([data-theme="light"]) .seccion-quebradas summary { background: #1a5a9e; color: #d0e4f8; }
  :root:not([data-theme="light"]) .seccion-quebradas { border-color: #1a5a9e; }
  :root:not([data-theme="light"]) .seccion-historia summary { background: #1e3648; color: #b8d0e2; }
  :root:not([data-theme="light"]) .seccion-historia { border-color: #1e3648; }
}

.buscar-dir-row { display: flex; gap: 6px; margin: 4px 0; align-items: stretch; }
.buscar-dir-row input { flex: 1 1 0%; min-width: 0; width: auto; padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: .82rem; box-sizing: border-box; }
.buscar-dir-row .cta { width: auto; flex: 0 0 auto; padding: 7px 14px; white-space: nowrap; }
.dir-sugerencias { list-style: none; margin: 0; padding: 0; }
.dir-sugerencias:empty { display: none; }
.dir-sugerencias li { padding: 6px 9px; font-size: .78rem; cursor: pointer; border-radius: 6px; color: var(--text); }
.dir-sugerencias li:hover { background: var(--surface-2); }
#dir-resultado { margin: 6px 0; font-size: .8rem; color: var(--text); }

/* ═══ 3D FLOOD VIZ ═══ */
.flood3d-legend { position: absolute; top: 80px; right: 12px; background: var(--surface); border-radius: 8px; padding: 10px 14px; box-shadow: var(--shadow); z-index: 10; font-size: .78rem; color: var(--text); }
.flood3d-legend-title { font-weight: 700; margin-bottom: 6px; font-size: .8rem; }
.flood3d-legend-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; }
.flood3d-legend-row span { display: inline-block; width: 16px; height: 16px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); }
.flood3d-controls { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 10px; padding: 8px 14px; box-shadow: var(--shadow); z-index: 10; min-width: 280px; max-width: 95vw; }
.f3d-btn { background: var(--surface-2); border: 1px solid var(--line); color: var(--text); border-radius: 6px; padding: 5px 10px; font-size: .78rem; cursor: pointer; white-space: nowrap; }
.f3d-btn:hover { background: var(--accent); color: #fff; }
.f3d-btn:disabled { opacity: .5; cursor: default; }
.f3d-scrub { flex: 1; min-width: 60px; accent-color: var(--accent); }
.f3d-time { font-size: .75rem; color: var(--muted); min-width: 80px; text-align: center; }
.flood3d-rec { position: absolute; top: 12px; left: 12px; background: rgba(220,38,38,.9); color: #fff; padding: 5px 10px; border-radius: 8px; font-size: .72rem; font-weight: 700; display: flex; align-items: center; gap: 6px; z-index: 10; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: rec-blink 1s ease-in-out infinite; }
@keyframes rec-blink { 50% { opacity: .2; } }

.ocean-canvas { position: absolute; top: 0; left: 0; pointer-events: none; z-index: 1; }

/* ═══ FOOTER ═══ */
.site-footer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 6;
  background: var(--header); color: var(--header-text);
  display: flex; align-items: center; gap: 0; padding: 0;
  font-size: .78rem; line-height: 1.4;
  box-shadow: 0 -1px 6px rgba(0,0,0,.15);
}
.footer-concytec {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 24px; flex-shrink: 0;
}
.footer-logo-concytec { height: 36px; width: auto; }
.footer-concytec-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.footer-concytec-text a { color: var(--accent); }
.footer-sep { display: none; }
.footer-partners {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; overflow-x: auto; flex: 1; justify-content: flex-end;
}
.footer-partners a { display: flex; align-items: center; flex-shrink: 0; opacity: .85; transition: opacity .15s; }
.footer-partners a:hover { opacity: 1; }
.footer-logo { height: 36px; width: auto; }

/* ═══ MOBILE ═══ */
@media (max-width: 899px) {
  .topbar-nav { gap: 0; padding: 0 8px; }
  .topbar-nav button { padding: 5px 8px; font-size: .7rem; }
  .brand-sub { display: none; }
  .toolbar2 { top: 56px; flex-wrap: wrap; }
  .leyenda { max-width: 100%; }
  .maplibregl-ctrl-top-right .maplibregl-ctrl-group:not(.ctrl-ubicacion) { display: none; }
  .site-footer { flex-direction: column; align-items: stretch; }
  .footer-concytec { display: none; }
  .footer-sep { display: none; }
  .footer-partners { justify-content: center; gap: 16px; padding: 8px 12px; }
  .footer-logo { height: 24px; }
}
