/* Atlas del agua — familia «Mapa troncal»: papel, tinta, agua */
:root {
  --paper: #f4f2ec; --paper-2: #fbfaf7; --paper-3: #ebe8df; --rule: #dcd8cd; --rule-2: #c4bfb1;
  --ink: #16181d; --ink-2: #3c3e44; --ink-3: #66676c;
  --red: #e3172b; --blue: #0f6fd1;
  --water: #2166ac; --water-2: #5aa2d0; --water-3: #d4e6f1; --water-ink: #0d3f73;
  --good: #0b7d16; --warning: #9a6a00; --serious: #c2410c; --critical: #c4101f;
  --serious-f: #ec835a; --critical-f: #d03b3b;
  --f-ui: 'Barlow', system-ui, sans-serif; --f-cond: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
  --side: 430px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--ink); font: 14px/1.45 var(--f-ui); display: grid; grid-template-rows: auto 1fr; overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--blue); outline-offset: 2px; }
.num, b, td, .tiles { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- cabecera */
#top { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--paper-2); border-bottom: 1px solid var(--rule); min-height: 58px; z-index: 5; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.mark { width: 34px; height: 34px; flex: none; }
.bt { display: flex; flex-direction: column; line-height: 1.05; }
.bt small { font: 600 11.5px var(--f-cond); color: var(--ink-3); letter-spacing: .01em; }
.bt b { font: 800 20px var(--f-cond); letter-spacing: -.01em; }
.twins { display: flex; gap: 2px; background: var(--paper-3); border-radius: 999px; padding: 3px; }
.twins a { font: 600 13px var(--f-cond); color: var(--ink-2); text-decoration: none; padding: 5px 12px; border-radius: 999px; }
.twins a:hover { background: #fff; }
.twins a[aria-current] { background: var(--ink); color: #fff; }
.tag { font: 700 11px var(--f-cond); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); border: 1px solid var(--rule-2); border-radius: 4px; padding: 2px 6px; }
.grow { flex: 1; }
.pulse { display: flex; align-items: center; gap: 8px; font: 600 13px var(--f-cond); color: var(--ink-2); background: #fff; border: 1px solid var(--rule); border-radius: 999px; padding: 5px 12px; max-width: 46vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); flex: none; box-shadow: 0 0 0 0 rgba(227,23,43,.5); animation: late 2s ease-out infinite; }
.pulse.off .dot { background: var(--ink-3); animation: none; }
@keyframes late { 0% { box-shadow: 0 0 0 0 rgba(227,23,43,.45); } 100% { box-shadow: 0 0 0 10px rgba(227,23,43,0); } }
.clockbox { display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.clockbox b { font: 700 24px var(--f-cond); letter-spacing: -.01em; }
.clockbox small { font: 600 11.5px var(--f-cond); color: var(--ink-3); margin-top: 2px; }

/* ---------------------------------------------------------------- disposición */
main { display: grid; grid-template-columns: 1fr var(--side); min-height: 0; }
#mapwrap { position: relative; min-height: 0; background: #efece4; }
#map { position: absolute; inset: 0; }
#side { background: var(--paper-2); border-left: 1px solid var(--rule); display: flex; flex-direction: column; min-height: 0; }
.panels { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.panel { padding: 16px 18px 28px; animation: rise .35s cubic-bezier(.16,1,.3,1); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }
/* «Qué es este mapa»: texto fijo debajo de las pestañas (lo lee Google y quien llega sin contexto) */
.acerca { padding: 4px 18px 22px; border-top: 1px dashed var(--rule); margin: 0 0 4px; color: var(--ink-2, var(--ink)); }
.acerca h2 { font: 700 15.5px var(--f-cond); margin: 16px 0 6px; }
.acerca p { margin: 6px 0; max-width: 64ch; font-size: 13.5px; line-height: 1.5; }
.side-foot { font-size: 11.5px; color: var(--ink-3); padding: 8px 18px 10px; border-top: 1px solid var(--rule); }

/* pestañas: una línea de tinta con una estación por pestaña */
.tabs { position: relative; display: flex; justify-content: space-between; padding: 12px 18px 8px; border-bottom: 1px solid var(--rule); background: var(--paper-2); }
.tabs::before { content: ''; position: absolute; left: 30px; right: 30px; top: 21px; height: 5px; background: var(--water); border-radius: 3px; }
.tab { position: relative; background: none; border: 0; padding: 20px 2px 2px; cursor: pointer; font: 600 13.5px var(--f-cond); color: var(--ink-3); flex: 1; }
.tab::before { content: ''; position: absolute; left: 50%; top: 2px; width: 13px; height: 13px; margin-left: -6.5px; background: #fff; border: 2.5px solid var(--ink); border-radius: 50%; transition: transform .2s; }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"]::before { background: var(--red); border-color: var(--red); transform: scale(1.3); }
.tab:hover::before { transform: scale(1.15); }

/* ---------------------------------------------------------------- tipografía de panel */
.panel h2 { font: 700 22px/1.15 var(--f-cond); margin: 0 0 6px; letter-spacing: -.01em; text-wrap: balance; }
.panel h3 { font: 700 15.5px var(--f-cond); margin: 26px 0 8px; display: flex; align-items: baseline; gap: 8px; }
.panel h3 small, .note { font: 500 12px var(--f-ui); color: var(--ink-3); }
.panel p { margin: 6px 0; max-width: 64ch; }
.lead { font-size: 15px; color: var(--ink-2); }
.lead b { color: var(--ink); }
.big { font: 800 28px/1 var(--f-cond); letter-spacing: -.01em; }
.src { font-size: 11.5px; color: var(--ink-3); margin-top: 6px; }
.chart { position: relative; margin: 6px 0 2px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 4px 12px; font: 600 12px var(--f-cond); color: var(--ink-2); margin: 4px 0; }
.legend-row i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend-row i.ln { height: 3px; width: 14px; vertical-align: 3px; border-radius: 2px; }
.legend-row i.dash { height: 0; width: 14px; border-top: 2px dashed var(--ink); background: none; vertical-align: 3px; }

/* cifras: tabla de filetes */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); margin: 12px 0 4px; background: #fff; }
.tiles > div { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 10px 12px 9px; min-width: 0; }
.tiles b { display: block; font: 800 25px/1.05 var(--f-cond); letter-spacing: -.01em; }
.tiles span { display: block; font: 600 12.5px var(--f-cond); color: var(--ink-2); margin-top: 3px; }
.tiles small { display: block; font-size: 11.5px; color: var(--ink-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tiles .crit b { color: var(--critical); }
.tiles .wat b { color: var(--water-ink); }

/* listas */
.rows { list-style: none; margin: 4px 0; padding: 0; border-top: 1px solid var(--rule); }
.rows li { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; padding: 8px 2px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.rows li:hover { background: var(--paper-3); }
.rows .t { font: 600 14px/1.2 var(--f-cond); min-width: 0; }
.rows .s { font-size: 12px; color: var(--ink-3); grid-column: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .v { font: 700 16px var(--f-cond); text-align: right; grid-row: 1 / span 2; grid-column: 2; white-space: nowrap; }
.rows .v small { display: block; font: 600 11.5px var(--f-cond); color: var(--ink-3); }
.empty { color: var(--ink-3); font-size: 13px; padding: 10px 0; }
.more { background: none; border: 0; color: var(--blue); font: 600 13px var(--f-cond); padding: 8px 0; cursor: pointer; }

/* vasos (embalses) */
.vasos { list-style: none; padding: 0; margin: 6px 0; border-top: 1px solid var(--rule); }
.vasos li { display: grid; grid-template-columns: 9.5em 1fr 4.2em; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--rule); cursor: pointer; }
.vasos li:hover { background: var(--paper-3); }
.vasos .n { font: 600 13.5px/1.15 var(--f-cond); }
.vasos .n small { display: block; font: 500 11.5px var(--f-ui); color: var(--ink-3); }
.vaso { position: relative; height: 16px; border: 1.5px solid var(--ink); border-radius: 3px; background: #fff; overflow: hidden; }
.vaso i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--water); }
.vaso u { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); text-decoration: none; }
.vasos .p { font: 700 16px var(--f-cond); text-align: right; }
.vasos .p small { display: block; font: 600 11px var(--f-cond); }
.up { color: var(--good); } .down { color: var(--serious); }

/* placas de estado */
.badge { display: inline-block; font: 700 11px var(--f-cond); text-transform: uppercase; letter-spacing: .04em; padding: 2px 6px; border-radius: 3px; background: var(--paper-3); color: var(--ink-2); white-space: nowrap; }
.badge.crit { background: var(--critical); color: #fff; }
.badge.ser { background: #fde3d6; color: #8a2e07; }
.badge.wat { background: var(--water-3); color: var(--water-ink); }
.badge.ink { background: var(--ink); color: #fff; }

/* barra de mezcla */
.mix { display: flex; height: 26px; border-radius: 4px; overflow: hidden; margin: 8px 0 4px; background: var(--paper-3); }
.mix i { display: block; height: 100%; border-right: 2px solid var(--paper-2); }
.mix i:last-child { border-right: 0; }

/* fuentes */
.pipe { list-style: none; margin: 8px 0; padding: 0; }
.pipe li { border: 1px solid var(--rule); background: #fff; border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
.pipe .h { display: flex; justify-content: space-between; gap: 8px; font: 700 14px var(--f-cond); }
.pipe .m { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.pipe .m b { color: var(--ink); font-weight: 600; }
.pipe .err { color: var(--critical); font-size: 12px; margin-top: 4px; }

/* ---------------------------------------------------------------- sobre el mapa */
#hero { position: absolute; left: 16px; top: 16px; max-width: min(520px, calc(100% - 340px)); background: rgba(251,250,247,.94); border: 1px solid var(--rule); border-radius: 8px; padding: 14px 16px 12px; box-shadow: 0 6px 24px rgba(22,24,29,.10); z-index: 3; animation: rise .6s cubic-bezier(.16,1,.3,1) both; }
#hero h1 { font: 800 29px/1.05 var(--f-cond); margin: 0; letter-spacing: -.015em; text-wrap: balance; }
#hero h1 b { color: var(--water); }
#hero p { margin: 7px 0 0; font-size: 14px; color: var(--ink-2); }
#hero p b { color: var(--ink); }
#hero .live { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--rule); font: 600 13px var(--f-cond); color: var(--ink-2); }
#hero .live span { display: inline-flex; align-items: center; gap: 6px; }
#hero .live .dot { width: 8px; height: 8px; }
#hero .x { position: absolute; right: 6px; top: 6px; border: 0; background: none; padding: 4px; cursor: pointer; color: var(--ink-3); display: none; }
#hero .x svg { width: 16px; height: 16px; }

#maptools { position: absolute; right: 12px; top: 12px; display: flex; gap: 8px; align-items: flex-start; z-index: 4; }
.seg { display: flex; background: var(--paper-3); border: 1px solid var(--rule); border-radius: 999px; padding: 3px; gap: 2px; box-shadow: 0 2px 8px rgba(22,24,29,.08); }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 999px; cursor: pointer; font: 600 13px var(--f-cond); color: var(--ink-2); }
.seg button:hover { background: #fff; }
.seg button.on { background: var(--ink); color: #fff; }
#layers { position: relative; }
#layers summary { list-style: none; display: flex; align-items: center; gap: 6px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 999px; padding: 6px 12px; cursor: pointer; font: 600 13px var(--f-cond); box-shadow: 0 2px 8px rgba(22,24,29,.08); }
#layers summary::-webkit-details-marker { display: none; }
#layers summary svg { width: 16px; height: 16px; }
#layers .menu { position: absolute; right: 0; top: 40px; width: 300px; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 10px; box-shadow: 0 10px 30px rgba(22,24,29,.15); }
#layers label { display: flex; gap: 8px; align-items: flex-start; padding: 5px 2px; font-size: 13px; cursor: pointer; }
#layers input { accent-color: var(--ink); margin-top: 2px; }

.legend { position: absolute; left: 16px; bottom: 26px; background: rgba(251,250,247,.95); border: 1px solid var(--rule); border-radius: 8px; padding: 9px 12px 8px; z-index: 3; font: 600 12px var(--f-cond); color: var(--ink-2); max-width: 300px; box-shadow: 0 4px 16px rgba(22,24,29,.08); }
.legend h4 { margin: 0 0 6px; font: 700 12px var(--f-cond); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); display: flex; justify-content: space-between; align-items: center; gap: 12px; cursor: pointer; }
.legend .li { display: flex; align-items: center; gap: 8px; margin: 4px 0; line-height: 1.2; }
.legend .li img { flex: none; }
.legend .sw { flex: none; width: 18px; display: inline-flex; justify-content: center; }
.legend .ramp { display: flex; height: 9px; border-radius: 2px; overflow: hidden; width: 120px; }
.legend .ramp i { flex: 1; }
.legend.min .body { display: none; }

#ficha { position: absolute; left: 16px; bottom: 26px; width: min(380px, calc(100% - 32px)); max-height: calc(100% - 120px); overflow-y: auto; background: var(--paper-2); border: 1px solid var(--rule); border-radius: 10px; padding: 14px 16px 12px; z-index: 6; box-shadow: 0 12px 36px rgba(22,24,29,.18); animation: rise .3s cubic-bezier(.16,1,.3,1); }
#ficha h3 { font: 700 19px/1.15 var(--f-cond); margin: 0 26px 2px 0; }
#ficha .s { font-size: 12.5px; color: var(--ink-3); }
#ficha .x { position: absolute; right: 8px; top: 8px; border: 0; background: var(--paper-3); border-radius: 50%; width: 28px; height: 28px; display: grid; place-items: center; cursor: pointer; }
#ficha .x svg { width: 15px; height: 15px; }
#ficha .kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; margin: 10px 0 4px; }
#ficha .kv dt { color: var(--ink-3); } #ficha .kv dd { margin: 0; font-weight: 600; }
#ficha .desc { font-size: 13px; color: var(--ink-2); margin: 8px 0; }

#loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; background: var(--paper); z-index: 10; text-align: center; transition: opacity .5s; }
#loading.out { opacity: 0; pointer-events: none; }
#loading b { font: 700 22px var(--f-cond); }
#loading small { color: var(--ink-3); font-size: 13px; max-width: 34ch; }
.drop { width: 78px; height: 78px; }
.drop path:first-child { fill: none; stroke: var(--ink); stroke-width: 3; stroke-dasharray: 200; stroke-dashoffset: 200; animation: draw 1.6s ease-out forwards; }
.drop .fill { fill: var(--water); clip-path: path('M60 14c18 24 30 40 30 56a30 30 0 0 1-60 0c0-16 12-32 30-56z'); transform: translateY(40px); animation: fillup 2.4s 0.4s cubic-bezier(.16,1,.3,1) infinite alternate; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fillup { to { transform: translateY(-14px); } }

/* tooltip */
#tip { position: fixed; z-index: 50; pointer-events: none; background: #fff; border: 1px solid var(--rule-2); border-radius: 6px; padding: 7px 10px; font: 13px/1.35 var(--f-ui); box-shadow: 0 6px 20px rgba(22,24,29,.14); max-width: 290px; }
#tip .tt { font: 700 13px var(--f-cond); margin-bottom: 3px; }
#tip .tl { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
#tip .tl i { width: 9px; height: 9px; border-radius: 2px; flex: none; }
#tip .tl i.ln { height: 3px; }
#tip .tl i.dash { height: 0; border-top: 2px dashed var(--ink); width: 10px; }
#tip .tl b { margin-left: auto; padding-left: 10px; }
#tip .tl s { text-decoration: none; color: var(--ink-3); width: 3.2em; text-align: right; }
#tip .tl.tot { border-top: 1px solid var(--rule); margin-top: 3px; padding-top: 3px; }
#tip .tn { color: #9c1220; font-size: 12px; margin-top: 3px; }
.deck-tooltip { background: #fff !important; color: var(--ink) !important; border: 1px solid var(--rule-2); border-radius: 6px; box-shadow: 0 6px 20px rgba(22,24,29,.14); font: 13px/1.35 var(--f-ui) !important; padding: 8px 10px !important; max-width: 280px; }
.deck-tooltip b { font-family: var(--f-cond); }
.maplibregl-ctrl-attrib { font-size: 10.5px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------------------------------------------------------------- móvil */
@media (max-width: 900px) {
  body { overflow: auto; display: block; }
  #top { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; }
  .twins { order: 5; width: 100%; } .twins a { flex: 1; text-align: center; }
  .tag { display: none; }
  .pulse { order: 6; max-width: 100%; width: 100%; justify-content: flex-start; }
  .clockbox b { font-size: 20px; }
  main { display: block; }
  #mapwrap { height: 62vh; }
  #hero { left: 10px; right: 10px; top: auto; bottom: 10px; max-width: none; padding: 10px 12px; }
  #hero h1 { font-size: 22px; }
  #hero .live { font-size: 12px; }
  #hero .x { display: block; }
  #maptools { right: 8px; top: 8px; left: 8px; justify-content: space-between; }
  .cams { overflow-x: auto; max-width: calc(100% - 96px); }
  .cams button { padding: 5px 9px; white-space: nowrap; }
  #hero p:not(.live) { display: none; }
  #hero h1 { font-size: 21px; padding-right: 22px; }
  .legend { display: none; }
  #ficha { left: 8px; right: 8px; width: auto; bottom: 8px; max-height: 70%; }
  #side { border-left: 0; border-top: 1px solid var(--rule); }
  .panels { overflow: visible; }
  .tabs { position: sticky; top: 0; z-index: 4; padding: 12px 8px 8px; }
  .tabs::before { left: 18px; right: 18px; }
}

/* marca Datos de Colombia */
.mark.bandera { width: 34px; height: 23px; border-radius: 3px; }
