/* MODEA · Panel de coordinación.
 * Fondo vivo (scene.js): una gota cae en un río. Encima, vidrio esmerilado. */
@font-face {
  font-family: "Manrope";
  src: url("vendor/manrope.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  --bg: #e4f1f0;
  --glass: rgba(255, 255, 255, .78);
  --glass-strong: rgba(255, 255, 255, .9);
  --glass-line: rgba(255, 255, 255, .75);
  --surface-2: rgba(240, 248, 247, .85);
  --ink: #10262d;
  --ink-2: #4a6168;
  --ink-3: #7b9298;
  --line: rgba(16, 60, 72, .12);
  --line-2: rgba(16, 60, 72, .07);
  --agua: #0f6b80;
  --agua-2: #1689a1;
  --aqua: #2fc1d3;
  --agua-clara: #cfeef1;
  --agua-tint: rgba(22, 137, 161, .1);
  --arcilla: #a3573a;
  --arcilla-clara: rgba(214, 140, 105, .18);
  --ocre: #b17a1f;
  --ocre-clara: rgba(233, 180, 80, .2);
  --hoja: #3f7d47;
  --hoja-clara: rgba(110, 175, 100, .18);
  --rojo: #b8402d;
  --rojo-clara: rgba(230, 110, 90, .16);
  --hero-ink: #0c2a33;
  --hero-ink-2: #2f5560;
  --side: rgba(6, 34, 43, .74);
  --side-ink: #dff4f5;
  --side-ink-2: #8fbfc6;
  --shadow: 0 1px 1px rgba(10, 50, 60, .04), 0 8px 28px -6px rgba(10, 60, 72, .16);
  --shadow-hover: 0 2px 2px rgba(10, 50, 60, .05), 0 18px 40px -8px rgba(10, 60, 72, .26);
  --shadow-lg: 0 24px 70px -12px rgba(5, 40, 50, .38);
  --r: 20px;
  --r-sm: 12px;
  --blur: blur(18px) saturate(150%);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #04131a;
    --glass: rgba(10, 30, 37, .7);
    --glass-strong: rgba(12, 34, 42, .88);
    --glass-line: rgba(140, 220, 230, .12);
    --surface-2: rgba(14, 40, 48, .8);
    --ink: #e6f4f4;
    --ink-2: #a2bfc3;
    --ink-3: #6f8d93;
    --line: rgba(160, 225, 235, .12);
    --line-2: rgba(160, 225, 235, .07);
    --agua: #5cc7d8;
    --agua-2: #84dbe8;
    --aqua: #5ee3f0;
    --agua-clara: rgba(92, 199, 216, .18);
    --agua-tint: rgba(92, 199, 216, .1);
    --arcilla: #e39b79;
    --ocre: #e7b75f;
    --hoja: #8fcf86;
    --rojo: #f28f7c;
    --hero-ink: #ecfbfb;
    --hero-ink-2: #a9d4da;
    --side: rgba(3, 18, 24, .7);
    --shadow: 0 1px 1px rgba(0, 0, 0, .2), 0 10px 30px -6px rgba(0, 0, 0, .5);
    --shadow-hover: 0 2px 2px rgba(0, 0, 0, .25), 0 20px 44px -8px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 70px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 "Manrope", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
#scene { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; display: block; }
#app { position: relative; z-index: 1; min-height: 100vh; }
a { color: var(--agua-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--agua-clara); }
.ico { display: inline-flex; width: 20px; height: 20px; flex: none; }
.ico svg { width: 100%; height: 100%; }
.drop { display: inline-block; flex: none; }
.drop svg { display: block; width: 100%; height: 100%; }
img.drop { object-fit: contain; }
.auth-brand img.drop { padding: 12px; border-radius: 20px; background: linear-gradient(145deg, #1e5b6e, #143e4b); box-shadow: 0 12px 28px -8px rgba(15, 70, 85, .55); }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }

/* ---------- Entradas animadas ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -47%) scale(.97); } }
@keyframes slide { from { opacity: 0; transform: translateX(40px); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 0% { transform: scale(.6); opacity: .7; } 100% { transform: scale(2.4); opacity: 0; } }
@keyframes breathe { 50% { box-shadow: 0 0 0 6px rgba(233, 182, 96, .18); } }
@keyframes bob { 50% { transform: translateY(-5px); } }
@keyframes spin { to { transform: rotate(360deg); } }
.enter { animation: rise .6s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- Ingreso ---------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 460px);
  align-items: center;
  gap: 40px;
  padding: 40px clamp(20px, 6vw, 96px);
}
.auth-brand { color: var(--hero-ink); align-self: start; padding-top: 6vh; animation: rise .9s var(--ease) both; }
.auth-brand .drop { width: 76px; height: 76px; color: var(--agua); filter: drop-shadow(0 8px 18px rgba(15, 107, 128, .35)); animation: bob 5s ease-in-out infinite; }
.auth-brand h1 { font-size: clamp(44px, 6vw, 76px); font-weight: 800; letter-spacing: -.035em; margin: 14px 0 10px; line-height: 1; }
.auth-brand h1 span { background: linear-gradient(100deg, var(--agua), var(--aqua)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.auth-brand p { font-size: clamp(16px, 1.6vw, 19px); color: var(--hero-ink-2); max-width: 30ch; margin: 0; font-weight: 500; }
.auth-card {
  background: var(--glass-strong);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-line);
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  padding: 34px 32px 28px;
  animation: rise .8s var(--ease) .15s both;
}
.auth-card h2 { font-size: 24px; font-weight: 800; margin-bottom: 4px; }
.auth-card p.lead { color: var(--ink-2); margin: 0 0 22px; }
.auth-foot { margin-top: 18px; color: var(--ink-3); font-size: 12.5px; text-align: center; }
.auth-logo { display: none; }
@media (max-width: 860px) {
  .auth { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 28px 16px; align-content: end; }
  .auth-brand { padding-top: 0; text-align: center; }
  .auth-brand p { margin: 0 auto; }
  .auth-brand h1 { font-size: 46px; }
}

/* ---------- Estructura ---------- */
.shell #app { display: grid; grid-template-columns: 264px minmax(0, 1fr); }
.side {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  background: var(--side);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-right: 1px solid rgba(255, 255, 255, .08);
  color: var(--side-ink);
  padding: 20px 14px;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 10px 22px; }
.brand .drop { width: 38px; height: 38px; color: #7fe0ec; filter: drop-shadow(0 4px 12px rgba(80, 220, 235, .4)); }
.brand strong { display: block; font-size: 19px; font-weight: 800; color: #fff; letter-spacing: -.02em; }
.brand small { color: var(--side-ink-2); font-size: 12px; font-weight: 500; }
.nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; flex: 1; }
.nav-sep { margin: 18px 12px 6px; font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--side-ink-2); opacity: .8; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 12px;
  color: var(--side-ink); text-decoration: none; font-weight: 600; font-size: 14.5px;
  transition: background .25s var(--ease), transform .25s var(--ease), color .2s;
}
.nav a:hover { background: rgba(255, 255, 255, .07); transform: translateX(2px); }
.nav a.on {
  background: linear-gradient(100deg, rgba(95, 220, 235, .22), rgba(95, 220, 235, .06));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(140, 230, 240, .18);
}
.nav a.on::before {
  content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0;
  background: linear-gradient(#7fe8f2, #2fc1d3); box-shadow: 0 0 14px rgba(80, 220, 235, .7);
}
.nav a .ico { opacity: .85; }
.nav a.on .ico { opacity: 1; color: #8eeaf3; }
.badge {
  margin-left: auto; min-width: 24px; padding: 0 8px; border-radius: 99px;
  background: linear-gradient(135deg, #f5c66d, #e49b3a); color: #2b1a05;
  font-size: 11.5px; font-weight: 800; text-align: center; line-height: 21px;
  animation: breathe 2.6s ease-in-out infinite;
}
.badge:empty { display: none; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .1); padding-top: 14px; display: grid; gap: 6px; }
.me { display: flex; align-items: center; gap: 11px; color: var(--side-ink); padding: 8px 10px; border-radius: 12px; font-weight: 600; }
.me:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.me small { display: block; color: var(--side-ink-2); font-size: 12px; font-weight: 500; }
.side .av { background: linear-gradient(135deg, #2fc1d3, #0f6b80); color: #fff; }
.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 16px 32px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 55%, transparent), transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.top h1 { font-size: 24px; font-weight: 800; color: var(--hero-ink); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; animation: fade .5s ease both; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.view { padding: 8px 32px 56px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; }
.icon-btn.menu { display: none; }
.scrim { display: none; }
@media (max-width: 900px) {
  .shell #app { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 276px; transform: translateX(-104%); transition: transform .35s var(--ease); }
  .nav-open .side { transform: none; box-shadow: var(--shadow-lg); }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(2, 16, 22, .5); z-index: 25; animation: fade .25s ease; }
  .icon-btn.menu { display: inline-flex; }
  .top { padding: 12px 16px; }
  .top h1 { font-size: 19px; }
  .view { padding: 4px 16px 44px; gap: 16px; }
}

/* ---------- Portada del resumen (sobre el río, sin tarjeta) ---------- */
.hero-banner { min-height: 210px; display: flex; flex-direction: column; justify-content: flex-end; padding: 6px 4px 8px; color: var(--hero-ink); }
.hero-banner .hello { font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--hero-ink-2); }
.hero-banner h2 { font-size: clamp(28px, 3.4vw, 42px); font-weight: 800; letter-spacing: -.03em; margin: 6px 0 8px; max-width: 18ch; }
.hero-banner p { margin: 0; font-size: 16px; color: var(--hero-ink-2); font-weight: 500; max-width: 52ch; }
.hero-banner strong { color: var(--hero-ink); }
@media (max-width: 900px) { .hero-banner { min-height: 150px; } }

/* ---------- Botones y campos ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--glass-strong); color: var(--ink);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s, border-color .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--agua-2) 40%, var(--line)); text-decoration: none; }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .55; cursor: default; transform: none; box-shadow: none; }
.btn .ico { width: 18px; height: 18px; }
.btn.primary {
  background: linear-gradient(135deg, var(--agua-2), var(--agua));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px -6px rgba(15, 107, 128, .7), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.btn.primary:hover { box-shadow: 0 10px 26px -8px rgba(15, 107, 128, .85), inset 0 1px 0 rgba(255, 255, 255, .25); }
.btn.ok { background: linear-gradient(135deg, #58a061, #3f7d47); border-color: transparent; color: #fff; }
.btn.warn { background: var(--ocre-clara); border-color: var(--ocre); }
.btn.danger { background: var(--rojo-clara); border-color: color-mix(in srgb, var(--rojo) 50%, transparent); color: var(--rojo); }
.btn.ghost { background: transparent; border-color: transparent; backdrop-filter: none; box-shadow: none; }
.btn.ghost:hover { background: var(--agua-tint); }
.top .btn.ghost { color: var(--hero-ink); }
.btn.light { color: var(--side-ink); justify-content: flex-start; }
.btn.light:hover { background: rgba(255, 255, 255, .08); }
.btn.sm { min-height: 32px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; min-height: 46px; font-size: 15px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn.primary { color: #03222a; background: linear-gradient(135deg, #8eeaf3, #3fc6d8); }
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--glass-strong); cursor: pointer; transition: transform .2s var(--ease);
}
.icon-btn:hover { transform: rotate(-4deg) scale(1.05); }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 700; color: var(--ink-2); letter-spacing: .01em; }
.field small { color: var(--ink-3); font-size: 12.5px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 9px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--glass-strong);
  transition: border-color .2s, box-shadow .2s, background .2s;
}
textarea.input { min-height: 88px; resize: vertical; }
.input:hover { border-color: color-mix(in srgb, var(--agua-2) 35%, var(--line)); }
.input:focus { outline: none; border-color: var(--agua-2); box-shadow: 0 0 0 4px var(--agua-clara); }
.input-wrap { position: relative; }
.input-wrap .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); width: 18px; height: 18px; }
.input-wrap .input { padding-left: 40px; }
.input-wrap .addon { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-2); font-size: 13px; font-weight: 700; }
.form { display: grid; gap: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.error { color: var(--rojo); background: var(--rojo-clara); border-radius: 12px; padding: 10px 14px; font-size: 14px; font-weight: 600; animation: rise .3s var(--ease); }
.error:empty { display: none; }
.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 600; }
.check input, .t input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--agua-2); cursor: pointer; }

/* ---------- Tarjetas de vidrio ---------- */
.card {
  background: var(--glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  min-width: 0; overflow: hidden;
  transition: box-shadow .3s var(--ease);
}
.card-h { display: flex; align-items: center; gap: 10px; padding: 18px 22px 6px; }
.card-h h2 { font-size: 16px; font-weight: 800; flex: 1; }
.card-h .muted { font-size: 13px; font-weight: 600; }
.card-b { padding: 10px 22px 22px; }
.card-b.flush { padding: 6px 0 0; }
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.grid.halves { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
@media (max-width: 1100px) { .grid.two, .grid.halves { grid-template-columns: minmax(0, 1fr); } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.kpi {
  position: relative; overflow: hidden;
  display: grid; gap: 1px; padding: 18px 20px 16px;
  background: var(--glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-line); border-radius: var(--r);
  box-shadow: var(--shadow); color: var(--ink);
  transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.kpi::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .35) 48%, transparent 66%);
  background-size: 250% 100%; background-position: 150% 0; transition: background-position .9s var(--ease);
}
a.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-hover); text-decoration: none; }
a.kpi:hover::after { background-position: -50% 0; }
.kpi .ico { width: 40px; height: 40px; padding: 9px; border-radius: 13px; background: var(--agua-tint); color: var(--agua); margin-bottom: 10px; transition: transform .4s var(--ease); }
a.kpi:hover .ico { transform: rotate(-8deg) scale(1.08); }
.kpi b { font-size: 34px; font-weight: 800; letter-spacing: -.035em; line-height: 1.05; }
.kpi span { font-weight: 700; font-size: 14px; }
.kpi small { color: var(--ink-2); font-size: 12.5px; font-weight: 500; }
.kpi .spark { position: absolute; right: 14px; top: 18px; width: 92px; height: 34px; opacity: .9; }
.kpi .spark path.area { opacity: .16; }
.kpi.t-ocre .ico { background: var(--ocre-clara); color: var(--ocre); }
.kpi.t-hoja .ico { background: var(--hoja-clara); color: var(--hoja); }
.kpi.t-arcilla .ico { background: var(--arcilla-clara); color: var(--arcilla); }
.kpi.mini { padding: 14px 16px; }
.kpi.mini b { font-size: 26px; }
@media (max-width: 560px) {
  .kpis { grid-template-columns: 1fr 1fr; gap: 12px; }
  .kpi { padding: 14px; }
  .kpi b { font-size: 26px; }
  .kpi .spark { display: none; }
}

.callout {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 18px 22px; border-radius: var(--r);
  background: linear-gradient(110deg, rgba(245, 198, 109, .32), rgba(245, 198, 109, .12)), var(--glass);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid rgba(228, 155, 58, .35); box-shadow: var(--shadow);
}
.callout.ok { background: linear-gradient(110deg, rgba(110, 175, 100, .26), rgba(110, 175, 100, .08)), var(--glass); border-color: rgba(80, 150, 85, .3); }
.callout .grow { flex: 1; min-width: 220px; }
.callout strong { display: block; font-size: 16px; font-weight: 800; }
/* Clave de estación automática: se muestra una sola vez. */
.key-box { font-size: 18px; font-weight: 700; letter-spacing: .02em; margin: 8px 0; padding: 10px 12px; border-radius: 10px; background: var(--glass-strong); border: 1px dashed var(--line); user-select: all; overflow-wrap: anywhere; }
.ring { width: 64px; height: 64px; flex: none; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring .bg { stroke: rgba(16, 60, 72, .12); }
.ring .fg { stroke: url(#ringGrad); stroke-linecap: round; transition: stroke-dashoffset 1.4s var(--ease); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 14px; font-weight: 800; }

/* ---------- Chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; line-height: 18px;
  background: var(--line-2); color: var(--ink-2); white-space: nowrap;
}
.chip .ico { width: 14px; height: 14px; }
.chip.agua { background: var(--agua-tint); color: var(--agua); }
.chip.ocre { background: var(--ocre-clara); color: color-mix(in srgb, var(--ocre) 85%, var(--ink)); }
.chip.hoja { background: var(--hoja-clara); color: var(--hoja); }
.chip.arcilla { background: var(--arcilla-clara); color: var(--arcilla); }
.chip.rojo { background: var(--rojo-clara); color: var(--rojo); }
.chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.q-veryGood { background: rgba(70, 140, 230, .16); color: #2563b8; }
.q-good { background: var(--hoja-clara); color: var(--hoja); }
.q-fair { background: rgba(230, 200, 60, .22); color: #7a6512; }
.q-poor { background: rgba(240, 150, 70, .2); color: #9a4f10; }
.q-veryPoor { background: var(--rojo-clara); color: var(--rojo); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .q-veryGood { color: #9cc3f5; }
  :root:not([data-theme="light"]) .q-fair { color: #e8d57e; }
  :root:not([data-theme="light"]) .q-poor { color: #f0b27a; }
}

/* ---------- Filtros y tablas ---------- */
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; padding: 18px 22px; border-bottom: 1px solid var(--line-2); }
.filters .field { min-width: 140px; flex: 1 1 140px; }
.filters .field.wide { flex: 2 1 230px; }
.filters .field.date { flex: 0 1 165px; }
.active-filter { display: flex; gap: 8px; align-items: center; padding: 12px 22px 0; flex-wrap: wrap; }
.active-filter:empty { display: none; }
.bulk {
  display: none; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 22px; background: linear-gradient(90deg, var(--agua-clara), transparent); border-bottom: 1px solid var(--line);
}
.bulk.on { display: flex; animation: rise .35s var(--ease); }
.bulk strong { margin-right: auto; }
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th {
  position: sticky; top: 0; text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--ink-3); font-weight: 800; padding: 12px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.t td { padding: 12px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; transition: background .2s; }
.t tbody tr { animation: fade .4s ease both; }
.t tbody tr:nth-child(-n+12) { animation-delay: calc(var(--row, 0) * 25ms); }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover td { background: var(--agua-tint); }
.t tbody tr.click:hover td:first-child { box-shadow: inset 3px 0 0 var(--aqua); }
.t tbody tr.sel td { background: var(--agua-clara); }
.t tr.doubtful .val { text-decoration: line-through; text-decoration-color: var(--rojo); }
.t .num { text-align: right; }
.t td.chk, .t th.chk { width: 40px; padding-right: 0; }
.t .sub { display: block; color: var(--ink-3); font-size: 12.5px; font-weight: 500; }
.val { font-weight: 800; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.empty { padding: 42px 20px; text-align: center; color: var(--ink-2); font-weight: 500; }
.empty .ico { width: 46px; height: 46px; padding: 11px; border-radius: 50%; background: var(--agua-tint); color: var(--agua); margin-bottom: 10px; }

/* ---------- Carga con brillo ---------- */
.skel { display: grid; gap: 20px; }
.skel .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.skel i {
  display: block; height: 120px; border-radius: var(--r);
  background: linear-gradient(100deg, var(--glass) 30%, var(--glass-strong) 50%, var(--glass) 70%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
  border: 1px solid var(--glass-line);
}
.skel i.tall { height: 320px; }
.loading { display: grid; place-items: center; padding: 60px 0; color: var(--ink-3); }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--agua-clara); border-top-color: var(--aqua); animation: spin .8s linear infinite; }

/* ---------- Listas ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 14px; align-items: center; padding: 12px 22px; border-top: 1px solid var(--line-2); transition: background .2s, transform .25s var(--ease); animation: rise .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 45ms); }
.list li:first-child { border-top: 0; }
.list li.click { cursor: pointer; }
.list li.click:hover { background: var(--agua-tint); transform: translateX(3px); }
.list .grow { flex: 1; min-width: 0; }
.list .grow > * { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.av {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: var(--agua-tint); color: var(--agua);
}
.av .ico { width: 19px; height: 19px; }
.av.ocre { background: var(--ocre-clara); color: var(--ocre); }
.av.hoja { background: var(--hoja-clara); color: var(--hoja); }
.av.arcilla { background: var(--arcilla-clara); color: var(--arcilla); }

/* ---------- Mapa y gráficas ---------- */
.map { height: 380px; z-index: 1; }
.map.tall { height: 600px; }
.map.short { height: 270px; }
.chart-box { position: relative; height: 300px; }
.chart-box.tall { height: 340px; }
.leaflet-container { font: 14px/1.45 "Manrope", system-ui, sans-serif; background: #cfe5e6; }
.leaflet-popup-content-wrapper { border-radius: 16px; box-shadow: var(--shadow-lg); }
.leaflet-popup-content { margin: 14px 16px; }
.leaflet-popup-content strong { display: block; font-size: 15px; font-weight: 800; }
.pin { position: relative; width: 18px; height: 18px; }
.pin i { position: absolute; inset: 0; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .35); }
.pin.live::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--c); animation: pulse 2s ease-out infinite; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; padding: 2px 22px 14px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: middle; box-shadow: 0 0 0 3px rgba(255, 255, 255, .6); }

/* ---------- Detalle de estación ---------- */
.hero { display: flex; gap: 22px; align-items: flex-start; padding: 22px; flex-wrap: wrap; }
.hero .big-ico { width: 64px; height: 64px; padding: 15px; border-radius: 20px; background: var(--agua-tint); color: var(--agua); box-shadow: inset 0 0 0 1px var(--line-2); }
.hero .big-ico.ocre { background: var(--ocre-clara); color: var(--ocre); }
.hero .big-ico.arcilla { background: var(--arcilla-clara); color: var(--arcilla); }
.hero .big-ico.hoja { background: var(--hoja-clara); color: var(--hoja); }
.station-photo { width: 168px; height: 128px; object-fit: cover; border-radius: 16px; box-shadow: var(--shadow); flex: none; }
.hero .grow { flex: 1; min-width: 240px; display: grid; gap: 10px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 7px 18px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink-3); font-weight: 600; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.tabs { display: flex; gap: 6px; padding: 12px 16px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  position: relative; border: 0; background: none; padding: 11px 16px; font-weight: 700; color: var(--ink-2); cursor: pointer;
  border-radius: 10px 10px 0 0; white-space: nowrap; transition: color .2s, background .2s;
}
.tabs button:hover { background: var(--agua-tint); }
.tabs button.on { color: var(--agua); }
.tabs button.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: linear-gradient(90deg, var(--agua-2), var(--aqua)); }

/* ---------- Panel lateral y ventanas ---------- */
.drawer-bg, .modal-bg { position: fixed; inset: 0; background: rgba(2, 18, 24, .42); backdrop-filter: blur(3px); z-index: 60; animation: fade .25s ease; }
.drawer {
  position: fixed; top: 10px; right: 10px; bottom: 10px; width: min(500px, calc(100% - 20px)); z-index: 61;
  background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-line); border-radius: 24px;
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden;
  animation: slide .4s var(--ease);
}
.drawer-h { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-h h2 { font-size: 17px; font-weight: 800; flex: 1; }
.drawer-b { padding: 20px; overflow-y: auto; display: grid; gap: 20px; align-content: start; }
.drawer-sec { animation: rise .5s var(--ease) both; }
.drawer-sec:nth-child(2) { animation-delay: .06s; }
.drawer-sec:nth-child(3) { animation-delay: .12s; }
.drawer-sec h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3); margin-bottom: 10px; font-weight: 800; }
.big-val { font-size: 46px; font-weight: 800; letter-spacing: -.04em; line-height: 1; background: linear-gradient(120deg, var(--agua), var(--aqua)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.big-val small { font-size: 18px; font-weight: 700; color: var(--ink-2); -webkit-text-fill-color: var(--ink-2); margin-left: 6px; }
.review-box { display: grid; gap: 12px; padding: 16px; border-radius: 16px; background: var(--surface-2); border: 1px solid var(--line); }
.review-box .row { display: flex; gap: 8px; flex-wrap: wrap; }
.modal {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 61;
  width: min(580px, calc(100% - 24px)); max-height: calc(100% - 32px); overflow-y: auto;
  background: var(--glass-strong); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-line); border-radius: 24px; box-shadow: var(--shadow-lg); animation: pop .35s var(--ease);
}
.modal-h { display: flex; align-items: center; gap: 10px; padding: 22px 24px 6px; }
.modal-h h2 { font-size: 20px; font-weight: 800; flex: 1; }
.modal-b { padding: 12px 24px 4px; }
.modal-f { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 24px 24px; flex-wrap: wrap; }

.toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); }
.toast {
  display: flex; align-items: center; gap: 11px; padding: 13px 16px; border-radius: 14px; font-weight: 600;
  background: rgba(8, 38, 46, .92); color: #eefbfb; backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg); animation: rise .4s var(--ease);
}
.toast .ico { width: 20px; height: 20px; padding: 2px; border-radius: 50%; background: #3fc6d8; color: #04232b; }
.toast.bad { background: rgba(110, 30, 20, .94); }
.toast.bad .ico { background: #f59a85; color: #3a0d06; }

.note { font-size: 13px; color: var(--ink-2); padding: 0 22px 16px; font-weight: 500; }
.segmented { display: inline-flex; padding: 3px; gap: 3px; border: 1px solid var(--line); border-radius: 12px; background: var(--glass-strong); }
.segmented button { border: 0; background: none; padding: 7px 15px; border-radius: 9px; font-weight: 700; cursor: pointer; color: var(--ink-2); transition: background .25s var(--ease), color .2s; }
.segmented button.on { background: linear-gradient(135deg, var(--agua-2), var(--agua)); color: #fff; box-shadow: 0 4px 12px -4px rgba(15, 107, 128, .6); }
.pw-hint { font-size: 12.5px; color: var(--ink-3); }
.page-intro { margin: -4px 4px 0; color: var(--hero-ink-2); font-weight: 600; }

/* Reportes y observaciones de la comunidad */
.obs-photo { display: block; width: 100%; max-height: 340px; object-fit: cover; border-radius: 16px; box-shadow: var(--shadow); background: var(--surface-2); }
.pin.sq i, .pin.sq.live::before { border-radius: 5px; transform: rotate(45deg) scale(.9); }
.legend i.sq { border-radius: 2px; transform: rotate(45deg) scale(.9); }
.t .sub.clamp { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 46ch; }

/* Avisos a la comunidad */
.av.rojo { background: var(--rojo-clara); color: var(--rojo); }
.notice-cell { display: flex; gap: 12px; align-items: flex-start; min-width: 240px; }
.t .sub.pre { white-space: pre-line; max-width: 62ch; margin-top: 2px; }
.t tr.off td { opacity: .6; }
.level-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.level-pick .lvl {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 12px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--glass-strong); cursor: pointer; font-weight: 700;
  transition: background .25s var(--ease), border-color .25s var(--ease), box-shadow .25s var(--ease), transform .2s var(--ease);
}
.level-pick .lvl:hover { transform: translateY(-1px); }
.level-pick .lvl input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.level-pick .lvl .ico { width: 18px; height: 18px; }
.level-pick .lvl.agua { color: var(--agua); }
.level-pick .lvl.ocre { color: color-mix(in srgb, var(--ocre) 85%, var(--ink)); }
.level-pick .lvl.rojo { color: var(--rojo); }
.level-pick .lvl.on { border-color: currentColor; box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent); }
.level-pick .lvl.agua.on { background: var(--agua-tint); }
.level-pick .lvl.ocre.on { background: var(--ocre-clara); }
.level-pick .lvl.rojo.on { background: var(--rojo-clara); }
.level-pick .lvl:focus-within { outline: 2px solid var(--agua-2); outline-offset: 2px; }
@media (max-width: 520px) { .level-pick { grid-template-columns: 1fr; } }

/* Alertas tempranas */
.badge.red { background: linear-gradient(135deg, #f2836d, #c8402d); color: #fff; }
.callout.danger { background: linear-gradient(110deg, rgba(230, 110, 90, .3), rgba(230, 110, 90, .1)), var(--glass); border-color: color-mix(in srgb, var(--rojo) 40%, transparent); color: inherit; }
a.callout.danger:hover { text-decoration: none; box-shadow: var(--shadow-hover); }
.callout .big-ico { width: 52px; height: 52px; padding: 13px; border-radius: 16px; background: var(--rojo-clara); color: var(--rojo); }
.callout .big-ico .ico { width: 100%; height: 100%; }
.level-pick .lvl.arcilla { color: var(--arcilla); }
.level-pick .lvl.hoja { color: var(--hoja); }
.level-pick .lvl.arcilla.on { background: var(--arcilla-clara); }
.level-pick .lvl.hoja.on { background: var(--hoja-clara); }
.av.agua { background: var(--agua-tint); color: var(--agua); }
.drawer-b > * { min-width: 0; }
.drawer .list li { padding-left: 0; padding-right: 0; }
.drawer .list li .grow { min-width: 0; overflow-wrap: anywhere; }

/* Anuncios: miniatura en la lista y vista previa en el formulario. */
.ann-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line, #dde5e7); display: block; }
.ann-preview { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.ann-preview:empty { display: none; }
.ann-preview img { max-width: 100%; max-height: 220px; border-radius: 12px; border: 1px solid var(--line, #dde5e7); }
