/* Weather Wise v2 — portal privado. Tema claro único, pensado primero para el celular.
 * Escritorio (≥1024 px): mapa + panel de detalle fijo a la derecha. Tablet y móvil: mapa arriba, detalle debajo, navegación inferior. */
:root {
  --bg: #f3f5f0;
  --surface: #ffffff;
  --surface-2: #f7f8f4;
  --ink: #142019;
  --ink-2: #33433a;
  --muted: #5f6d64;
  --line: #dde3da;
  --line-2: #eaeee7;
  --primary: #0f5f4a;
  --primary-2: #0b4a3a;
  --primary-soft: #e3efe9;
  --accent: #d99a1e;
  --accent-soft: #fbf0d8;
  --tmax: #c8502b;
  --tmin: #2f68a8;
  --rain: #2a86c2;
  --dry: #b6782b;
  --ok: #2d7a46;
  --ok-soft: #e4f2e8;
  --warn: #a8690f;
  --warn-soft: #fbf0d8;
  --crit: #b3372e;
  --crit-soft: #f9e3e0;
  --info: #1f6e9e;
  --info-soft: #e1eff8;
  --shadow-sm: 0 1px 2px rgba(20, 32, 25, .06), 0 1px 1px rgba(20, 32, 25, .04);
  --shadow: 0 8px 24px rgba(20, 32, 25, .10), 0 1px 3px rgba(20, 32, 25, .08);
  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --r: 12px;
  --r-sm: 8px;
  --panel-w: 460px;
  --top-h: 60px;
  --bottom-h: 64px;
  color-scheme: light;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--f-body); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
img, svg { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-family: var(--f-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.err { color: var(--crit); background: var(--crit-soft); border-radius: var(--r-sm); padding: 8px 12px; margin: 10px 0; font-size: 14px; }
.ok-msg { color: var(--ok); background: var(--ok-soft); border-radius: var(--r-sm); padding: 8px 12px; margin: 10px 0; font-size: 14px; }
.eyebrow { font: 600 11.5px/1.3 var(--f-body); letter-spacing: .08em; text-transform: uppercase; color: var(--primary); }
.h1 { font: 800 clamp(26px, 4.2vw, 36px)/1.1 var(--f-display); letter-spacing: -.02em; margin: 4px 0 8px; }
.h2 { font: 700 22px/1.2 var(--f-display); letter-spacing: -.01em; margin: 4px 0 8px; }
.h3 { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; font: 700 16px/1.3 var(--f-display); margin: 0 0 10px; }
.h3 small { font: 400 12.5px/1.3 var(--f-body); color: var(--muted); }
.pad { padding: 20px; }
.pad-x { padding: 0 4px; }

/* ---------- Botones y formularios ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 16px; border: 1px solid var(--primary); border-radius: 10px; background: var(--primary); color: #fff; font-weight: 600; font-size: 14.5px; text-decoration: none; white-space: nowrap; transition: background .15s, box-shadow .15s, transform .05s; }
.btn:hover { background: var(--primary-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); background: var(--surface); }
.btn.ai { background: linear-gradient(135deg, #0f5f4a 0%, #13755a 55%, #1d6f86 100%); border-color: transparent; box-shadow: 0 2px 10px rgba(15, 95, 74, .25); }
.btn.ai:hover { filter: brightness(1.06); }
.spark { color: var(--accent); font-size: 1.05em; line-height: 1; }
.link { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label, .ctl > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type=email], input[type=password], input[type=text], input[type=search], input:not([type]), select {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px; }
input:focus, select:focus { border-color: var(--primary); outline: 2px solid var(--primary-soft); outline-offset: 0; }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235f6d64' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; }
.hint { font-size: 12.5px; color: var(--muted); }
.code-input { font: 600 24px/1 var(--f-mono) !important; letter-spacing: .4em; text-align: center; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--primary); flex: none; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font-size: 13.5px; font-weight: 600; color: var(--muted); min-height: 32px; }
.seg button.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }
.seg.wrap { flex-wrap: wrap; }
.lang { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--surface); }
.lang button { border: 0; background: none; padding: 4px 10px; border-radius: 999px; font: 600 12.5px/1.2 var(--f-body); color: var(--muted); min-height: 28px; }
.lang button.on { background: var(--primary); color: #fff; }

/* Chips */
.chip { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.crit { background: var(--crit-soft); color: var(--crit); border-color: transparent; }
.chip.info { background: var(--info-soft); color: var(--info); border-color: transparent; }

/* ---------- Estructura de la app ---------- */
.app { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: var(--top-h); padding: 0 16px; background: rgba(255, 255, 255, .96); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: 14.5px; }
.nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--primary-soft); color: var(--primary); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; font: 700 13.5px/1 var(--f-body); letter-spacing: .02em; }
.bottom-nav { display: none; }

/* Vista mapa (escritorio) */
.view-map { display: grid; grid-template-columns: minmax(0, 1fr) var(--panel-w); height: calc(100vh - var(--top-h)); height: calc(100dvh - var(--top-h)); }
.map-wrap { position: relative; min-width: 0; background: #8597ab; }
.map { position: absolute; inset: 0; }
.detail { background: var(--surface); border-left: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; min-width: 0; }
.page-in { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head > div { max-width: 720px; }
.page-head .muted { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow-sm); min-width: 0; }

/* Controles del mapa */
.map-search { position: absolute; top: 12px; left: 12px; z-index: 3; width: min(360px, calc(100% - 24px)); }
.map-search > svg { position: absolute; left: 12px; top: 13px; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; pointer-events: none; }
.map-search input { padding-left: 38px; border: 0; box-shadow: var(--shadow); border-radius: 12px; }
.search-list { list-style: none; margin: 6px 0 0; padding: 6px; background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); max-height: 50vh; overflow-y: auto; }
.search-list li { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.search-list li small { color: var(--muted); font-size: 12.5px; text-align: right; }
.search-list li:hover, .search-list li[aria-selected=true] { background: var(--primary-soft); }
.map-tools { position: absolute; top: 12px; right: 12px; z-index: 2; display: flex; gap: 8px; align-items: center; }
.map-tools .seg { background: var(--surface); box-shadow: var(--shadow); border: 0; }
.layer-pick select { min-height: 40px; width: auto; max-width: 230px; border: 0; box-shadow: var(--shadow); font-size: 14px; font-weight: 600; }
.legend { position: absolute; left: 12px; bottom: 12px; z-index: 2; width: 240px; padding: 10px 12px; background: rgba(255, 255, 255, .95); border-radius: 12px; box-shadow: var(--shadow); font-size: 12.5px; }
.legend b { display: block; margin-bottom: 6px; font-size: 12.5px; }
.legend-bar { height: 10px; border-radius: 5px; }
.legend-ticks { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font: 11.5px/1 var(--f-mono); }
.map-hint { position: absolute; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 1; margin: 0; padding: 7px 14px; border-radius: 999px; background: rgba(20, 32, 25, .72); color: #fff; font-size: 13px; white-space: nowrap; pointer-events: none; }
.legend:not([hidden]) ~ .map-hint { display: none; }

.pin { width: 26px; height: 34px; background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 34'%3E%3Cpath d='M13 33C13 33 2 20 2 12.5A11 11 0 0 1 24 12.5C24 20 13 33 13 33Z' fill='%23d99a1e' stroke='%23fff' stroke-width='2'/%3E%3Ccircle cx='13' cy='12.5' r='4.2' fill='%23fff'/%3E%3C/svg%3E"); filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .35)); }

/* ---------- Panel de detalle ---------- */
.intro .h2 { margin-top: 6px; }
.intro .h3 { margin: 20px 0 10px; font-size: 14px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.quick button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13.5px; font-weight: 500; }
.quick button:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.callout { display: grid; gap: 4px; margin-top: 20px; padding: 14px 16px; border-radius: var(--r); background: var(--accent-soft); border: 1px solid #efd9a6; font-size: 14px; }
.sec .callout { margin-top: 0; }
.callout b { font-family: var(--f-display); font-size: 15px; }
.callout a { font-weight: 600; justify-self: start; }
.d-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: flex-start; gap: 10px; padding: 16px 20px 12px; background: rgba(255, 255, 255, .97); border-bottom: 1px solid var(--line-2); }
.back { flex: none; width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 18px; line-height: 1; }
.back:hover { border-color: var(--primary); color: var(--primary); }
.d-tt { min-width: 0; }
.d-title { font: 800 23px/1.15 var(--f-display); letter-spacing: -.01em; margin: 3px 0 4px; overflow-wrap: anywhere; }
.d-meta { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.d-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 20px 4px; }
.d-actions .btn { flex: 1 1 auto; }
.sec { padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.sec:last-child { border-bottom: 0; padding-bottom: 28px; }
.now { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.now-t { font: 500 46px/1 var(--f-mono); letter-spacing: -.03em; }
.now-t sup { font-size: 18px; margin-left: 2px; vertical-align: top; position: relative; top: 4px; }
.now-sky { font: 700 18px/1.2 var(--f-display); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.stats > div { background: var(--surface-2); border-radius: 10px; padding: 9px 10px; min-width: 0; }
.stats dt { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats dd { margin: 2px 0 0; font: 600 18px/1.2 var(--f-mono); }
.stats dd small { font-size: 11.5px; color: var(--muted); margin-left: 2px; font-weight: 400; }
.key { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.key span { display: inline-flex; align-items: center; gap: 6px; }
.key i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; }
.k-max { background: var(--tmax); }
.k-min { background: var(--tmin); }
.k-rain { background: var(--rain); height: 10px !important; width: 10px !important; }
.k-rain.soft { opacity: .45; }
.k-norm { background: none !important; border-top: 2px dashed var(--ink-2); height: 0 !important; }
.k-a { background: var(--primary); height: 10px !important; }
.k-b { background: #a7b2aa; height: 10px !important; }
.mini-sel select { min-height: 34px; padding: 4px 30px 4px 10px; font-size: 13.5px; width: auto; }
.ind { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ind-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.ind-card .k { font-size: 12.5px; color: var(--muted); }
.ind-card .v { font: 600 20px/1.25 var(--f-mono); margin: 2px 0; }
.ind-card .v small { font: 400 12px var(--f-body); color: var(--muted); }
.ind-card .n { font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.ind-card .chip { white-space: normal; }

/* Tablas */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); background: var(--surface-2); padding: 8px 10px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td.wrap { white-space: normal; min-width: 240px; }
.tbl .link { font-weight: 600; }
.tbl-details { margin-top: 14px; }
.tbl-details summary { cursor: pointer; font-weight: 600; color: var(--primary); margin-bottom: 10px; }
.d-pos { color: var(--tmax); } .d-neg { color: var(--tmin); }
.d-warm { color: var(--tmax); } .d-cool { color: var(--tmin); } .d-wet { color: var(--rain); } .d-dry { color: var(--dry); }

/* ---------- Análisis AI ---------- */
.ai-sec { background: linear-gradient(180deg, #f2f8f5 0%, #ffffff 100%); }
.sec.ai-sec { border-left: 3px solid var(--primary); }
.card.ai-sec { border-color: #cfe3da; }
.ai-out { font-size: 14.5px; color: var(--ink); overflow-wrap: anywhere; }
.ai-out h3 { font: 700 16px/1.3 var(--f-display); margin: 16px 0 6px; color: var(--primary-2); }
.ai-out h3:first-child { margin-top: 0; }
.ai-out h4 { font-size: 14.5px; margin: 12px 0 4px; }
.ai-out p { margin: 0 0 8px; }
.ai-out ul, .ai-out ol { margin: 0 0 10px; padding-left: 20px; }
.ai-out li { margin: 3px 0; }
.ai-foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line-2); padding-top: 8px; margin-top: 12px !important; }
.ai-wait { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); animation: blink 1.2s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }

/* ---------- Gráficos SVG ---------- */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.wide-chart { min-width: 540px; }
.wide-chart.xl { min-width: 640px; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: var(--f-body); }
.chart .axis { font-size: 12px; fill: var(--muted); }
.chart .axis.dim { fill: #8d978f; font-size: 11px; }
.chart .grid { stroke: var(--line-2); stroke-width: 1; }
.chart .base { stroke: #b9c2bb; stroke-width: 1; }
.chart .band { fill: rgba(200, 80, 43, .09); }
.chart .line-max { fill: none; stroke: var(--tmax); stroke-width: 2.2; stroke-linejoin: round; }
.chart .line-min { fill: none; stroke: var(--tmin); stroke-width: 2.2; stroke-linejoin: round; }
.chart .dot-max { fill: var(--tmax); } .chart .dot-min { fill: var(--tmin); }
.chart .val { font: 600 12px var(--f-mono); }
.chart .val.max { fill: var(--tmax); } .chart .val.min { fill: var(--tmin); }
.chart .rain { fill: var(--rain); opacity: .85; }
.chart .rain.soft { opacity: .35; }
.chart .norm { fill: none; stroke: var(--ink-2); stroke-width: 1.6; stroke-dasharray: 4 3; }
.chart .warm { fill: var(--tmax); } .chart .cool { fill: var(--tmin); } .chart .wet { fill: var(--rain); } .chart .dry { fill: var(--dry); }
.chart .conf-media { opacity: .72; } .chart .conf-baja { opacity: .45; } .chart .conf-clim { opacity: .3; }
.chart .cmp-a { fill: var(--primary); } .chart .cmp-b { fill: #b7c0b9; }
.chart .cmp-a-line { fill: none; stroke: var(--primary); stroke-width: 2.4; stroke-linejoin: round; }
.chart .cmp-b-line { fill: none; stroke: #8e9a92; stroke-width: 2; stroke-dasharray: 5 4; }
.chart .cmp-norm { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-dasharray: 3 3; }
.chart .cmp-dot { fill: var(--primary); }
.spark-chart { width: 100%; height: 44px; display: block; margin: 8px 0 4px; }
.spark-chart .line-max { fill: none; stroke: var(--tmax); stroke-width: 1.8; }
.spark-chart .line-min { fill: none; stroke: var(--tmin); stroke-width: 1.8; }
.spark-chart .rain { fill: var(--rain); opacity: .6; }
.spark-chart path { vector-effect: non-scaling-stroke; }
.page .wide-chart { max-width: 900px; margin: 0 auto; }
@media (min-width: 1024px) {
  :root { --panel-w: clamp(460px, 40vw, 620px); }
  .detail > * { zoom: 1.18; }                     /* panel de datos más grande y legible en escritorio */
  .detail .wide-chart { min-width: 0; }
  .detail .chart .axis { font-size: 14px; }
  .detail .chart .axis.dim { font-size: 13px; }
  .detail .chart .val { font-size: 14px; }
}
.locate { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow); font-size: 14px; font-weight: 600; color: var(--ink); }
.locate svg { width: 18px; height: 18px; fill: none; stroke: var(--primary); stroke-width: 2; }
.locate[aria-busy="true"] { opacity: .6; }

/* ---------- Regiones ---------- */
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filters button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 14px; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.filters button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.rcard { display: block; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s; min-width: 0; }
.rcard:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.rc-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.rc-top > div:first-child { min-width: 0; }
.rc-top h3 { font: 700 18px/1.2 var(--f-display); margin: 3px 0 2px; }
.rc-top p { margin: 0; }
.rc-now { font: 600 24px/1 var(--f-mono); color: var(--tmax); text-align: right; flex: none; }
.rc-now small { display: block; font-size: 14px; color: var(--tmin); margin-top: 3px; }
.rc-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 6px 0 10px; }
.rc-stats dt { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rc-stats dd { margin: 1px 0 0; font: 600 14px/1.2 var(--f-mono); white-space: nowrap; }
.rc-stats dd small { font: 400 10.5px var(--f-body); color: var(--muted); display: block; }
.rc-sig { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- Gráficos a medida ---------- */
.controls { display: flex; flex-wrap: wrap; gap: 14px 18px; align-items: flex-end; }
.ctl { display: grid; gap: 6px; min-width: 0; }
.ctl select { min-width: 220px; }
.ctl-check { align-self: center; }
.ch-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.ch-summary > div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: grid; gap: 2px; min-width: 0; }
.ch-summary b { font: 600 20px/1.2 var(--f-mono); }

/* ---------- Reportes ---------- */
.doc { padding: clamp(18px, 3vw, 36px); display: grid; gap: 22px; }
.doc-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 2px solid var(--primary); }
.doc-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.doc-title { font: 800 clamp(22px, 3vw, 30px)/1.15 var(--f-display); margin: 0; letter-spacing: -.01em; }
.doc section { min-width: 0; }
.doc .ai-sec { padding: 16px; border-radius: var(--r); border: 1px solid #cfe3da; }
.bul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.doc-foot { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; }
.doc-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Modal y toast ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-scrim { position: absolute; inset: 0; background: rgba(20, 32, 25, .38); }
.modal-card { position: relative; width: min(460px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--surface); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.modal-x { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border: 0; background: var(--surface-2); border-radius: 50%; font-size: 20px; line-height: 1; color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 14px 0 18px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line-2); }
.switch > div { display: grid; gap: 2px; font-size: 14px; }
.switch span { color: var(--muted); font-size: 13px; }
.switch select { width: auto; }
.switch + .row { padding-top: 14px; border-top: 1px solid var(--line-2); }
.toggle { appearance: none; flex: none; width: 46px; height: 26px; margin: 0; border-radius: 999px; background: #c9d1cb; position: relative; cursor: pointer; transition: background .15s; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.toggle:checked { background: var(--primary); }
.toggle:checked::after { transform: translateX(20px); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; width: max-content; max-width: min(520px, calc(100% - 32px)); padding: 11px 16px; border-radius: 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-left: 4px solid var(--primary); box-shadow: var(--shadow); font-size: 14px; }

/* MapLibre: controles acordes al tema */
.maplibregl-ctrl-group { border-radius: 10px !important; box-shadow: var(--shadow) !important; }
.maplibregl-ctrl-attrib { font-size: 10.5px; }
.maplibregl-cooperative-gesture-screen { font-size: 15px; }

/* ---------- Tablet y móvil (< 1024 px) ---------- */
@media (max-width: 1023.98px) {
  :root { --top-h: 56px; }
  body { padding-bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0px)); }
  .topbar { padding: 0 12px; gap: 10px; }
  .nav { display: none; }
  .bottom-nav { display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; height: calc(var(--bottom-h) + env(safe-area-inset-bottom, 0px)); padding-bottom: env(safe-area-inset-bottom, 0px); background: rgba(255, 255, 255, .98); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(20, 32, 25, .06); }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600; min-width: 0; }
  .bottom-nav a svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .bottom-nav a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .bottom-nav a.on { color: var(--primary); }
  .bottom-nav a.on svg { stroke-width: 2.2; }
  .view-map { display: block; height: auto; }
  .map-wrap { height: 56vh; height: 56svh; min-height: 320px; max-height: 620px; }
  .detail { border-left: 0; overflow: visible; }
  .d-head { top: var(--top-h); }
  .page { padding: 20px 16px 32px; }
  .toast { bottom: calc(var(--bottom-h) + 14px + env(safe-area-inset-bottom, 0px)); }
}
/* La pantalla de acceso no tiene barra inferior */
@media (max-width: 1023.98px) { body:has(.app[hidden]) { padding-bottom: 0; } }

/* ---------- Móvil (< 640 px) ---------- */
@media (max-width: 639.98px) {
  .brand-name { font-size: 18px; }
  .brand-mark { width: 26px; height: 26px; }
  .map-search { top: 10px; left: 10px; width: calc(100% - 20px); }
  .map-tools { top: 62px; right: 10px; }
  .layer-pick select { max-width: 170px; font-size: 13.5px; min-height: 36px; }
  .map-tools .seg button { min-height: 28px; padding: 4px 10px; }
  .legend { left: 10px; bottom: 10px; width: min(220px, calc(100% - 80px)); }
  .map-hint { display: none; }
  .d-head { padding: 14px 16px 10px; }
  .d-actions { padding: 12px 16px 4px; }
  .d-actions .btn { padding: 8px 12px; font-size: 14px; }
  .d-actions .btn.ai { flex-basis: 100%; }
  .sec { padding: 14px 16px; }
  .pad { padding: 18px 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .now-t { font-size: 40px; }
  .page-head .btn.ai { width: 100%; }
  .controls { display: grid; grid-template-columns: 1fr; }
  .ctl select { min-width: 0; }
  .controls .btn { width: 100%; }
  .ch-summary { gap: 6px; }
  .ch-summary > div { padding: 8px; }
  .ch-summary b { font-size: 15px; }
  .rgrid { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .row2 { grid-template-columns: 1fr; }
  .g-title { font-size: 26px; }
  .modal { place-items: end center; padding: 0; }
  .modal-card { width: 100%; border-radius: 18px 18px 0 0; max-height: 88dvh; padding: 22px 18px calc(22px + env(safe-area-inset-bottom, 0px)); }
  .doc-actions .btn { flex: 1 1 auto; }
}

/* Impresión del reporte */
@media print {
  .topbar, .bottom-nav, .page-head, .controls, .doc-actions, .toast { display: none !important; }
  body { background: #fff; padding: 0; }
  .doc { box-shadow: none; border: 0; }
}

/* =====================================================================
 * v4 · Diseño premium: marca, acceso con foto, buscador, fotos, análisis,
 * pie de página y cookies.
 * ===================================================================== */
:root { --deep: #0b3b2e; --glass: rgba(255, 255, 255, .14); --r-lg: 18px; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn .ic { width: 17px; height: 17px; }
.btn.lg { min-height: 48px; font-size: 15.5px; border-radius: 12px; }
.btn.light { background: #fff; color: var(--deep); border-color: #fff; }
.btn.light:hover { background: #f1f5f2; }
.btn.glass { background: var(--glass); color: #fff; border-color: rgba(255, 255, 255, .45); backdrop-filter: blur(6px); }
.btn.glass:hover { background: rgba(255, 255, 255, .24); }
.btn.ghost.on { border-color: var(--accent); color: var(--warn); background: var(--accent-soft); opacity: 1; cursor: default; }
.btn.ghost.on .ic { fill: var(--accent); stroke: var(--accent); }
.eyebrow.light { color: #f3d79b; }
textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px; resize: vertical; min-height: 110px; }
textarea:focus { border-color: var(--primary); outline: 2px solid var(--primary-soft); outline-offset: 0; }
input[type=date], input[type=tel] { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px; }

/* Marca */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand-globe { width: 34px; height: 34px; border-radius: 50%; box-shadow: 0 2px 8px rgba(10, 40, 80, .25); }
.brand-name { font: 500 20px/1 var(--f-display); letter-spacing: -.01em; white-space: nowrap; display: inline-flex; align-items: baseline; gap: 1px; }
.brand-name b { font-weight: 800; color: var(--primary); }
.brand-name em { font: 600 10.5px/1 var(--f-body); font-style: normal; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin-left: 8px; }
.brand.light { color: #fff; }
.brand.light .brand-name b { color: #9fe3c4; }
.brand.light .brand-name em { color: rgba(255, 255, 255, .75); }

/* Acceso: foto de tormenta a pantalla completa con tarjeta clara */
.gate { position: relative; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; color: #fff; background: #0a1d17; isolation: isolate; }
.gate-bg { position: absolute; inset: 0; z-index: -1; overflow: hidden; }
.gate-bg img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 45%; animation: kenburns 28s ease-in-out infinite alternate; }
.gate-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, rgba(5, 18, 14, .82) 0%, rgba(5, 18, 14, .45) 48%, rgba(5, 18, 14, .25) 100%), linear-gradient(0deg, rgba(5, 18, 14, .7) 0%, rgba(5, 18, 14, 0) 30%); }
@keyframes kenburns { from { transform: scale(1.02); } to { transform: scale(1.1) translate(-1%, -1%); } }
@media (prefers-reduced-motion: reduce) { .gate-bg img { animation: none; } }
.gate-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 22px clamp(18px, 4vw, 48px); }
.gate-top .lang { background: rgba(255, 255, 255, .12); border-color: rgba(255, 255, 255, .3); }
.gate-top .lang button { color: rgba(255, 255, 255, .85); }
.gate-top .lang button.on { background: #fff; color: var(--deep); }
.gate-main { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 460px); gap: clamp(24px, 5vw, 80px); align-items: center; padding: 12px clamp(18px, 4vw, 48px) 40px; max-width: 1320px; width: 100%; margin: 0 auto; }
.gate-hero { max-width: 600px; text-shadow: 0 2px 16px rgba(0, 0, 0, .35); }
.gate-h { font: 800 clamp(34px, 4.6vw, 60px)/1.04 var(--f-display); letter-spacing: -.025em; margin: 12px 0 16px; }
.gate-hero p { font-size: clamp(16px, 1.4vw, 19px); line-height: 1.55; color: rgba(255, 255, 255, .9); margin: 0; max-width: 520px; }
.gate-hero .lead-btn { margin-top: 22px; text-shadow: none; background: #f2c14e; color: #10231b; border-color: #f2c14e; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.gate-hero .lead-btn:hover { background: #ffd36b; border-color: #ffd36b; }
.gate-card { background: rgba(255, 255, 255, .97); color: var(--ink); border-radius: 22px; padding: 26px 28px 24px; box-shadow: 0 30px 80px rgba(0, 0, 0, .35); backdrop-filter: blur(10px); }
.g-logo { display: block; width: 92px; height: auto; margin: -4px auto 10px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 18px; }
.tabs button { border: 0; background: none; min-height: 42px; border-radius: 10px; font: 700 15px/1 var(--f-body); color: var(--muted); }
.tabs button.on { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); }
.g-title { font: 800 26px/1.15 var(--f-display); letter-spacing: -.02em; margin: 0 0 6px; }
.g-lead { color: var(--muted); margin: 0 0 18px; font-size: 14.5px; }
.g-links { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 16px; margin-top: 14px; font-size: 14px; }
.check a { font-weight: 600; }
.check.inline { align-items: center; font-size: 13.5px; }
.check.inline input { margin: 0; }
.code-note { margin: 0 0 14px; padding: 12px 14px; border-radius: var(--r); background: var(--accent-soft); border: 1px solid #efd9a6; font-size: 13.5px; }
.code-note code { font: 700 18px/1 var(--f-mono); letter-spacing: .15em; color: var(--ink); margin-left: 4px; }

/* Barra superior */
.topbar { gap: 18px; padding: 0 20px; }
.contact-btn { min-height: 38px; padding: 6px 12px; font-size: 14px; }
.nav a .ic { width: 18px; height: 18px; }

/* Buscador (mapa, regiones, análisis) */
.picker { position: relative; }
.picker > .ic { position: absolute; left: 13px; top: 13px; color: var(--muted); pointer-events: none; z-index: 1; }
.picker input { padding-left: 40px; }
.map-search > .ic { top: 13px; }
.search-list { position: absolute; left: 0; right: 0; z-index: 10; }
.search-list li { align-items: center; justify-content: flex-start; }
.search-list li > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; color: var(--ink); }
.search-list li .ic { color: var(--primary); width: 17px; height: 17px; }
.search-list li.k-geo .ic { color: var(--info); }
.search-list li.k-saved .ic { color: var(--accent); fill: var(--accent); }
.search-list li small { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Panel de inicio en el mapa */
.intro { padding: 16px; display: grid; gap: 22px; }
.hero-card { position: relative; border-radius: var(--r-lg); padding: 24px 22px 22px; min-height: 260px; display: flex; flex-direction: column; justify-content: flex-end; color: #fff; background-size: cover; background-position: center; box-shadow: var(--shadow); }
.hero-card h2 { font: 800 26px/1.12 var(--f-display); letter-spacing: -.015em; margin: 8px 0 6px; text-shadow: 0 2px 12px rgba(0, 0, 0, .3); }
.hero-card p { margin: 0 0 16px; color: rgba(255, 255, 255, .9); font-size: 14.5px; }
.hero-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.hero-btns .btn { flex: 1 1 auto; }
.i-sec .h3 { font-size: 16px; margin-bottom: 10px; }
.see-all { font: 600 13.5px var(--f-body); text-decoration: none; }
.empty { margin: 0; padding: 14px; border: 1px dashed var(--line); border-radius: var(--r); background: var(--surface-2); }
.places { display: grid; gap: 8px; }
.place { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; }
.place:hover { border-color: var(--primary); }
.place-go { flex: 1; display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 0; background: none; text-align: left; min-width: 0; }
.place-go .ic { color: var(--accent); }
.place-go span { display: grid; min-width: 0; }
.place-go b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-go small { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.place-x { border: 0; border-left: 1px solid var(--line-2); background: none; width: 42px; color: var(--muted); display: grid; place-items: center; }
.place-x:hover { color: var(--crit); background: var(--crit-soft); }
.pcards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pcard { position: relative; aspect-ratio: 4 / 3; border: 0; border-radius: 14px; background-size: cover; background-position: center; color: #fff; text-align: left; padding: 12px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .2s, box-shadow .2s; }
.pcard:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.pcard b { font: 700 16px/1.15 var(--f-display); text-shadow: 0 1px 6px rgba(0, 0, 0, .4); }
.pc-type { font: 600 10.5px/1.2 var(--f-body); letter-spacing: .1em; text-transform: uppercase; color: rgba(255, 255, 255, .85); }
.d-note { margin-top: 4px; font-size: 13px; color: var(--warn); }
.d-actions .btn .ic { margin-right: -2px; }

/* Pronóstico a 12 meses: tarjetas por mes */
.h3 .seg { font-family: var(--f-body); }
.mgrid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 12px; }
.mcard { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; grid-template-columns: 1fr auto; gap: 1px 6px; background: var(--surface); min-width: 0; }
.mcard.conf-media { background: #fbfcfa; }
.mcard.conf-baja { background: var(--surface-2); }
.mcard.conf-clim { background: var(--surface-2); opacity: .8; }
.mc-m { grid-column: 1 / -1; font: 700 13px/1.2 var(--f-display); text-transform: capitalize; margin-bottom: 3px; }
.mc-t { font: 600 18px/1.2 var(--f-mono); }
.mc-a, .mc-p { font: 600 12px/1.6 var(--f-mono); text-align: right; }
.mc-r { font: 500 14px/1.3 var(--f-mono); color: var(--rain); }
.mc-r small { font-size: 11px; color: var(--muted); }
.mc-c { grid-column: 1 / -1; font-size: 10.5px; color: var(--muted); margin-top: 3px; }

/* Esqueletos de carga */
.skel { height: 14px; border-radius: 7px; margin: 10px 0; background: linear-gradient(90deg, var(--line-2) 0%, #f6f8f4 50%, var(--line-2) 100%); background-size: 200% 100%; animation: shimmer 1.3s infinite linear; }
.skel.short { width: 60%; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Páginas con portada fotográfica */
.page { padding: 0 0 48px; }
.page-hero { background-size: cover; background-position: center; color: #fff; padding: clamp(36px, 6vw, 72px) 24px clamp(30px, 5vw, 56px); }
.page-hero.slim { padding-top: clamp(28px, 4vw, 48px); padding-bottom: clamp(26px, 4vw, 44px); }
.page-hero-in { max-width: 1180px; margin: 0 auto; }
.page-hero .h1 { color: #fff; font-size: clamp(30px, 4.6vw, 48px); text-shadow: 0 2px 14px rgba(0, 0, 0, .3); }
.page-hero p { max-width: 640px; margin: 0 0 18px; color: rgba(255, 255, 255, .92); font-size: 16px; }
.page-hero .picker { max-width: 520px; }
.page-hero .picker input { border: 0; min-height: 50px; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); }
.page-hero .picker > .ic { top: 16px; }
.page-in { padding: 22px 24px 0; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Regiones con foto */
.rgrid { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.rcard { padding: 0; overflow: hidden; border-radius: var(--r-lg); }
.rc-photo { aspect-ratio: 16 / 9; background-size: cover; background-position: center; color: #fff; padding: 14px 16px; display: flex; flex-direction: column; justify-content: flex-end; }
.rc-photo h3 { font: 800 21px/1.15 var(--f-display); margin: 3px 0 2px; text-shadow: 0 1px 8px rgba(0, 0, 0, .4); }
.rc-photo p { margin: 0; font-size: 12.5px; color: rgba(255, 255, 255, .85); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-body { padding: 12px 16px 16px; min-height: 150px; }
.rc-now { display: flex; align-items: baseline; gap: 8px; text-align: left; font: inherit; color: inherit; }
.rc-now .t-max { font: 600 24px/1 var(--f-mono); color: var(--tmax); }
.rc-now .t-min { font: 600 17px/1 var(--f-mono); color: var(--tmin); }

/* Análisis a medida */
.an-place-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.an-where { display: flex; gap: 10px; align-items: center; min-width: 0; }
.an-where > .ic { width: 26px; height: 26px; color: var(--accent); }
.an-where > div { display: grid; min-width: 0; }
.an-where b { font: 800 22px/1.15 var(--f-display); overflow-wrap: anywhere; }
.an-place .picker { flex: 1 1 320px; max-width: 460px; }
.an-saved { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.chip-btn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.chip-btn .ic { width: 13px; height: 13px; color: var(--accent); fill: var(--accent); }
.chip-btn:hover { border-color: var(--primary); color: var(--primary); }
.an-ctl .ctl.wide { flex-basis: 100%; }
.an-ctl input[type=date] { min-width: 170px; }
.ychips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ychips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font: 600 13.5px var(--f-mono); color: var(--ink-2); min-height: 34px; }
.ychips button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.ychips .check { margin-left: 8px; }
.an-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.an-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.an-head .h2 { margin: 2px 0 0; text-transform: none; }
.an-head .note { margin-top: 4px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); min-width: 0; }
.kpi.main { background: var(--primary-soft); }
.kpi b { font: 600 22px/1.2 var(--f-mono); }
.kpi b small { font: 400 12.5px var(--f-body); color: var(--muted); }
.kpi > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.key .sw { margin-right: 0; }
.sw.s0, .chart .ms.s0 { background: #0f5f4a; fill: #0f5f4a; }
.sw.s1, .chart .ms.s1 { background: #d99a1e; fill: #d99a1e; }
.sw.s2, .chart .ms.s2 { background: #2f68a8; fill: #2f68a8; }
.sw.s3, .chart .ms.s3 { background: #c8502b; fill: #c8502b; }
.sw.s4, .chart .ms.s4 { background: #7a5bb5; fill: #7a5bb5; }
.sw.s5, .chart .ms.s5 { background: #3a9a8a; fill: #3a9a8a; }
.sw.avg, .chart .ms.avg { background: #9aa39d; fill: #9aa39d; }
.chart .ml { fill: none; stroke-width: 2; stroke-linejoin: round; }
.chart .ml.s0 { stroke: #0f5f4a; stroke-width: 2.8; }
.chart .ml.s1 { stroke: #d99a1e; } .chart .ml.s2 { stroke: #2f68a8; } .chart .ml.s3 { stroke: #c8502b; } .chart .ml.s4 { stroke: #7a5bb5; } .chart .ml.s5 { stroke: #3a9a8a; }
.chart .ml.avg { stroke: #6f7a73; stroke-dasharray: 5 4; }
.chart .md { fill: #0f5f4a; }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.vcard { display: grid; gap: 2px; text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; min-width: 0; }
.vcard:hover { border-color: var(--primary); }
.vcard.on { border-color: var(--primary); background: var(--primary-soft); }
.vcard > span { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcard b { font: 600 18px/1.25 var(--f-mono); }
.vcard b small { font: 400 11.5px var(--f-body); color: var(--muted); }
.vcard > small { font-size: 12px; }
.empty-state { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 36px 18px; color: var(--muted); }
.empty-state .ic { width: 32px; height: 32px; color: var(--accent); }
#an-doc:not(:empty) { margin-top: 4px; }
.doc .brand-globe { width: 30px; height: 30px; }

/* Contacto */
.ct-alt { margin: 14px 0 0; text-align: center; }
.sent { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 10px 0; }
.sent-ic { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.sent-ic .ic { width: 26px; height: 26px; }

/* Pie de página */
.site-foot { background: #0c2a21; color: rgba(255, 255, 255, .78); padding: 40px 24px 18px; font-size: 14px; }
.foot-grid { max-width: 1180px; margin: 0 auto; display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 28px; }
.foot-grid h4 { font: 700 13px/1 var(--f-body); letter-spacing: .1em; text-transform: uppercase; color: #fff; margin: 4px 0 12px; }
.foot-grid > div:not(.foot-brand) { display: grid; gap: 8px; align-content: start; justify-items: start; }
.foot-brand p { margin: 12px 0 0; max-width: 320px; line-height: 1.5; }
.site-foot .brand { color: #fff; }
.site-foot .brand-name b { color: #9fe3c4; }
.site-foot .brand-name em { color: rgba(255, 255, 255, .6); }
.site-foot a, .link-f { color: rgba(255, 255, 255, .82); text-decoration: none; background: none; border: 0; padding: 0; font: inherit; text-align: left; cursor: pointer; }
.site-foot a:hover, .link-f:hover { color: #fff; text-decoration: underline; text-underline-offset: 3px; }
.foot-bottom { max-width: 1180px; margin: 14px auto 0; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .12); display: flex; justify-content: space-between; gap: 8px 20px; flex-wrap: wrap; font-size: 12.5px; color: rgba(255, 255, 255, .62); }
.foot-credit a { color: #f3d79b; font-weight: 600; }
.site-foot.dark { background: rgba(5, 18, 14, .55); backdrop-filter: blur(6px); padding: 16px clamp(18px, 4vw, 48px) 14px; }
.foot-mini { max-width: 1180px; margin: 0 auto; }
.foot-links { display: flex; gap: 8px 18px; flex-wrap: wrap; font-size: 13px; }
.site-foot.dark .foot-bottom { margin-top: 10px; }
body[data-view="mapa"] .app .site-foot { display: none; }
@media (min-width: 1024px) { body[data-view="mapa"] .app .site-foot { display: block; } }

/* Banner de cookies */
.cookie { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 70; max-width: 760px; margin: 0 auto; display: flex; gap: 16px; align-items: center; padding: 16px 18px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.ck-text { flex: 1; min-width: 0; }
.ck-text b { font: 700 15px/1.2 var(--f-display); }
.ck-text p { margin: 4px 0 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.45; }
.ck-btns { display: flex; gap: 8px; flex: none; }

@media (max-width: 1023.98px) {
  .gate-main { grid-template-columns: 1fr; align-items: start; gap: 22px; padding-top: 4px; }
  .gate-hero { max-width: none; }
  .gate-h { font-size: clamp(28px, 7vw, 40px); margin: 6px 0 10px; }
  .gate-card { max-width: 520px; width: 100%; justify-self: center; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
  .foot-brand { grid-column: 1 / -1; }
  .site-foot { padding-bottom: calc(var(--bottom-h) + 18px + env(safe-area-inset-bottom, 0px)); }
  .site-foot.dark { padding-bottom: 14px; }
  body:has(.app:not([hidden])) .cookie { bottom: calc(var(--bottom-h) + 12px + env(safe-area-inset-bottom, 0px)); }
  .mgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 639.98px) {
  .brand-name { font-size: 17px; }
  .brand-name em { display: none; }
  .brand-globe { width: 30px; height: 30px; }
  .contact-btn span { display: none; }
  .contact-btn { padding: 6px 9px; }
  .topbar { gap: 8px; padding: 0 12px; }
  .top-actions { gap: 6px; }
  .gate-top { padding: 14px 16px; }
  .gate-hero p { font-size: 15px; }
  .gate-card { padding: 20px 18px 18px; border-radius: 18px; }
  .g-logo { width: 72px; }
  .intro { padding: 12px; }
  .hero-card { min-height: 230px; padding: 18px 16px 16px; }
  .hero-card h2 { font-size: 22px; }
  .mgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-hero { padding-left: 16px; padding-right: 16px; }
  .page-in { padding: 16px 16px 0; }
  .an-ctl .seg { flex-wrap: wrap; }
  .an-actions .btn { flex: 1 1 auto; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi b { font-size: 18px; }
  .vgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .foot-grid { gap: 20px; }
  .foot-bottom { flex-direction: column; }
  .cookie { flex-direction: column; align-items: stretch; left: 10px; right: 10px; }
  .ck-btns .btn { flex: 1; }
  .ychips .check { margin-left: 0; flex-basis: 100%; }
}
@media print {
  .site-foot, .cookie, .page-hero, .an-place, .an-ctl, .an-actions, #an-body, .bar { display: none !important; }
}
