/* ============================================================
   SAI Analítica · hoja de estilos
   ============================================================ */

:root {
  --bg: #f3f6fa;
  --bg-2: #eef3f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eef3f8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #122033;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --primary: #0b6bcb;
  --primary-2: #0757a6;
  --primary-soft: #e8f2fe;
  --navy: #081d33;
  --navy-2: #0c2a47;
  --rain: #2f80ed;
  --rain-soft: #e8f1fd;
  --temp: #e8663c;
  --temp-soft: #fdefe9;
  --snow: #3f9bd8;
  --snow-soft: #e9f5fc;
  --water: #149a86;
  --water-soft: #e6f7f4;
  --flow: #6378d4;
  --flow-soft: #edf0fc;
  --ok: #15803d;
  --ok-soft: #e8f7ee;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --danger: #b91c1c;
  --danger-soft: #fdecec;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 32px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: "Cascadia Code", "Consolas", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 78% -10%, rgba(47, 128, 237, .07), transparent 60%),
    radial-gradient(900px 500px at 10% 0%, rgba(20, 154, 134, .05), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ------------------------------------------------------------
   Layout
   ------------------------------------------------------------ */
.app {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  min-height: 100vh;
}
.main { min-width: 0; display: flex; flex-direction: column; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 16px 16px;
  color: #e6eef8;
  background:
    radial-gradient(700px 300px at 0% 0%, rgba(47, 128, 237, .22), transparent 55%),
    radial-gradient(500px 300px at 100% 100%, rgba(20, 154, 134, .12), transparent 55%),
    linear-gradient(180deg, #081d33 0%, #0a2440 60%, #0a213a 100%);
  display: flex;
  flex-direction: column;
  z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, .06);
}
.sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.55), transparent 75%);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 8px 22px;
  position: relative;
}
.brand-mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  color: #7fc4ff;
  background: linear-gradient(145deg, rgba(47, 128, 237, .28), rgba(20, 154, 134, .18));
  border: 1px solid rgba(127, 196, 255, .28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12), 0 8px 20px rgba(0,0,0,.18);
}
.brand-mark svg { width: 26px; height: 26px; stroke-width: 1.9; }
.brand-name { font-weight: 750; font-size: 16px; letter-spacing: -.01em; color: #fff; }
.brand-sub { font-size: 11px; color: #8fb3d6; letter-spacing: .08em; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 18px; overflow-y: auto; padding: 2px 4px 12px; scrollbar-width: thin; }
.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-title {
  font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: #6f93b7; padding: 0 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; border-radius: 10px;
  color: #b8cde3; font-weight: 550; font-size: 13.5px;
  transition: background .15s ease, color .15s ease, transform .15s ease;
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item svg { width: 18px; height: 18px; opacity: .85; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(47, 128, 237, .26), rgba(47, 128, 237, .07));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(127, 196, 255, .14);
}
.nav-item.active::before {
  content: ""; position: absolute; left: -4px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 3px; background: #62b0ff;
  box-shadow: 0 0 12px rgba(98, 176, 255, .7);
}
.nav-item.active svg { color: #7fc4ff; opacity: 1; }

.sidebar-foot { margin-top: auto; padding: 14px 4px 0; position: relative; }
.source-card {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 11px; border-radius: 12px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .07);
}
.source-dot {
  width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; flex: none;
  background: #64748b; box-shadow: 0 0 0 3px rgba(100, 116, 139, .15);
}
.source-dot.ok { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }
.source-dot.warn { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .16); }
.source-dot.off { background: #f87171; box-shadow: 0 0 0 3px rgba(248, 113, 113, .16); }
.source-title { font-size: 12px; font-weight: 650; color: #e8f1fb; }
.source-sub { font-size: 10.5px; color: #8fb3d6; }
.sidebar-note { font-size: 10.5px; line-height: 1.45; color: #6f93b7; padding: 10px 10px 0; }

/* ------------------------------------------------------------
   Topbar
   ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 13px 28px;
  background: rgba(243, 246, 250, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(226, 232, 240, .9);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: -.02em; white-space: nowrap; }
.page-subtitle { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.sync-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 11px; border-radius: 999px;
  background: rgba(255, 255, 255, .75);
  border: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
  white-space: nowrap;
}
.sync-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); flex: none; }
.sync-pill.ok .sync-dot { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .14); }
.sync-pill.warn .sync-dot { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .14); }
.sync-pill.running .sync-dot { background: var(--primary); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }

.mobile-menu { display: none; }
.sidebar-backdrop { display: none; }

/* ------------------------------------------------------------
   Buttons, inputs
   ------------------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 650; white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .05s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn-primary {
  background: linear-gradient(180deg, #1178da, var(--primary));
  border-color: #0b62b8; color: #fff;
  box-shadow: 0 1px 2px rgba(11, 107, 203, .25), 0 8px 18px rgba(11, 107, 203, .18);
}
.btn-primary:hover { background: linear-gradient(180deg, #0f6fcc, var(--primary-2)); border-color: #09549f; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--muted);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11.5px; font-weight: 650; color: var(--muted); letter-spacing: .02em; }
.input, .select {
  height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 0 12px;
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus { border-color: #8ab8ea; box-shadow: 0 0 0 3px rgba(47, 128, 237, .12); }
.select {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
}
.select-wrap { display: flex; align-items: center; gap: 8px; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted-2); }
.search-wrap .input { padding-left: 34px; }

.segmented {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 3px; border-radius: 10px; background: var(--surface-3);
  border: 1px solid var(--border);
}
.segmented button {
  border: 0; background: transparent; color: var(--muted);
  height: 30px; padding: 0 10px; border-radius: 7px;
  font-size: 12px; font-weight: 650;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,.12); }

/* ------------------------------------------------------------
   Page structure
   ------------------------------------------------------------ */
.view { padding: 26px 28px 40px; max-width: 1480px; width: 100%; margin: 0 auto; flex: 1; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 18px; flex-wrap: wrap; margin-bottom: 18px;
}
.page-head h2 { margin: 0; font-size: 27px; letter-spacing: -.03em; font-weight: 780; }
.page-head .lead { margin: 5px 0 0; color: var(--muted); font-size: 13.5px; max-width: 760px; }
.page-controls { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.section-title {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 28px 0 12px; font-size: 16px; font-weight: 750; letter-spacing: -.01em;
}
.section-title .sub { font-size: 12px; font-weight: 500; color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }

/* ------------------------------------------------------------
   Hero
   ------------------------------------------------------------ */
.hero {
  position: relative; overflow: hidden;
  border-radius: 22px;
  padding: 34px 36px;
  background:
    radial-gradient(900px 380px at 85% 0%, rgba(47, 128, 237, .38), transparent 60%),
    radial-gradient(600px 300px at 0% 100%, rgba(20, 154, 134, .22), transparent 55%),
    linear-gradient(120deg, #071a2e 0%, #0a2b4b 55%, #0a3f68 100%);
  color: #fff;
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
  gap: 28px; align-items: center;
  box-shadow: 0 20px 50px rgba(8, 29, 51, .22);
}
.hero::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(700px 400px at 80% 20%, #000, transparent 75%);
}
.hero-copy { position: relative; z-index: 1; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11px; font-weight: 750; letter-spacing: .14em; text-transform: uppercase;
  color: #8ecbff; margin-bottom: 12px;
}
.eyebrow::before { content: ""; width: 22px; height: 1px; background: #8ecbff; opacity: .65; }
.hero h1 {
  margin: 0; font-size: clamp(30px, 3.3vw, 44px); line-height: 1.06;
  letter-spacing: -.035em; font-weight: 780; max-width: 700px;
}
.hero p { margin: 14px 0 0; color: rgba(232, 241, 251, .72); font-size: 14.5px; max-width: 640px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .075);
  border: 1px solid rgba(255, 255, 255, .12);
  color: #d8e9fa; font-size: 11.5px; font-weight: 550;
  backdrop-filter: blur(4px);
}
.hero-badge svg { width: 14px; height: 14px; color: #8ecbff; }
.hero-art { position: relative; z-index: 1; min-height: 210px; }
.hero-chart {
  position: relative; height: 190px; display: flex; align-items: flex-end; gap: 7px;
  padding: 18px 6px 26px;
}
.hero-bar {
  flex: 1; border-radius: 5px 5px 2px 2px; min-height: 3px;
  background: linear-gradient(180deg, #7cc4ff, rgba(47, 128, 237, .35));
  position: relative; opacity: .92;
  transform-origin: bottom;
  animation: barIn .7s cubic-bezier(.2,.8,.2,1) both;
}
.hero-bar:nth-child(2n) { background: linear-gradient(180deg, #62e0c6, rgba(20, 154, 134, .35)); }
.hero-bar:hover { opacity: 1; }
@keyframes barIn { from { transform: scaleY(.1); opacity: 0; } to { transform: scaleY(1); opacity: .92; } }
.hero-chart-line {
  position: absolute; left: 0; right: 0; bottom: 26px; height: 150px; pointer-events: none;
}
.hero-chart-line svg { width: 100%; height: 100%; overflow: visible; }
.hero-axis { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; color: rgba(255,255,255,.42); font-size: 9px; }
.hero-caption {
  display: flex; align-items: center; justify-content: space-between;
  color: rgba(255,255,255,.55); font-size: 10.5px; padding: 0 6px;
}
.hero-caption strong { color: #fff; font-weight: 650; }

/* ------------------------------------------------------------
   KPI
   ------------------------------------------------------------ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 17px 14px;
  box-shadow: var(--shadow);
  min-height: 138px;
  display: flex; flex-direction: column;
}
.kpi::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent, var(--primary)); opacity: .85;
}
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.kpi-label { font-size: 11.5px; font-weight: 650; color: var(--muted); letter-spacing: .01em; }
.kpi-icon {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-soft, var(--primary-soft)); color: var(--accent, var(--primary));
  flex: none;
}
.kpi-icon svg { width: 16px; height: 16px; }
.kpi-value {
  margin-top: 10px; font-size: 29px; font-weight: 780; letter-spacing: -.035em;
  display: flex; align-items: baseline; gap: 5px; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.kpi-value .unit { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; padding-top: 10px; }
.kpi-delta { font-size: 11.5px; font-weight: 650; display: inline-flex; align-items: center; gap: 4px; }
.kpi-delta svg { width: 13px; height: 13px; }
.kpi-delta.wet, .kpi-delta.up { color: var(--primary); }
.kpi-delta.dry, .kpi-delta.down { color: var(--warn); }
.kpi-delta.warm { color: var(--temp); }
.kpi-delta.cool { color: var(--snow); }
.kpi-delta.neutral { color: var(--muted); }
.kpi-sub { font-size: 10.5px; color: var(--muted-2); margin-top: 2px; }
.kpi-spark { width: 78px; height: 28px; flex: none; }
.kpi-spark svg { width: 100%; height: 100%; overflow: visible; }

/* ------------------------------------------------------------
   Cards & charts
   ------------------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 20px;
  min-width: 0;
}
.card.tight { padding: 14px 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 8px; }
.card-title { font-size: 14px; font-weight: 750; letter-spacing: -.01em; margin: 0; }
.card-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.card-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.chart-box { position: relative; width: 100%; height: 300px; }
.chart-box.tall { height: 360px; }
.chart-box.short { height: 220px; }
.chart-box.hero-chart-box { height: 320px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 9px; height: 9px; border-radius: 3px; background: var(--primary); }
.legend-swatch.line { height: 3px; border-radius: 2px; width: 14px; }
.legend-swatch.dashed { background: repeating-linear-gradient(90deg, var(--muted-2) 0 3px, transparent 3px 6px); height: 2px; width: 14px; }

/* ------------------------------------------------------------
   Tables
   ------------------------------------------------------------ */
.table-card { padding: 0; overflow: hidden; }
.table-head { padding: 17px 20px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.table-wrap { overflow: auto; max-height: 520px; }
.table-wrap.tall { max-height: 680px; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.data-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  color: var(--muted); text-align: left;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td { padding: 9px 12px; border-bottom: 1px solid #edf1f6; color: var(--text-2); vertical-align: middle; }
.data-table tbody tr:hover { background: #f8fbff; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .strong { font-weight: 650; color: var(--text); }
.data-table .rank { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 7px; background: var(--surface-3); font-size: 10.5px; font-weight: 700; color: var(--muted); }
.data-table .rank.top { background: #fff4d6; color: #9a6700; }
.data-table .zona { color: var(--muted); font-size: 11.5px; }
.data-table .station-name { font-weight: 600; color: var(--text); }
.data-table .station-name:hover { color: var(--primary); }
.table-empty { padding: 30px; text-align: center; color: var(--muted); font-size: 12.5px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 7px; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; white-space: nowrap;
}
.badge.blue { background: var(--rain-soft); color: #1d5fb4; }
.badge.green { background: var(--ok-soft); color: var(--ok); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.gray { background: var(--surface-3); color: var(--muted); }
.badge.teal { background: var(--water-soft); color: var(--water); }
.badge.purple { background: var(--flow-soft); color: var(--flow); }

/* ------------------------------------------------------------
   Specific blocks
   ------------------------------------------------------------ */
.headline-stats { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.headline-stat { display: flex; flex-direction: column; gap: 1px; }
.headline-stat .v { font-size: 18px; font-weight: 750; letter-spacing: -.02em; }
.headline-stat .l { font-size: 10.5px; color: var(--muted); }

.rank-list { display: flex; flex-direction: column; gap: 9px; }
.rank-row { display: flex; align-items: center; gap: 10px; }
.rank-row .idx { width: 20px; font-size: 10.5px; color: var(--muted-2); font-weight: 700; text-align: right; flex: none; }
.rank-row .name { flex: 1; min-width: 0; font-size: 12px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .bar { width: 82px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; flex: none; }
.rank-row .bar span { display: block; height: 100%; border-radius: 3px; background: var(--primary); }
.rank-row .val { width: 58px; text-align: right; font-size: 11.5px; font-weight: 700; font-variant-numeric: tabular-nums; flex: none; }

.zones-chart { display: flex; flex-direction: column; gap: 7px; max-height: 440px; overflow-y: auto; padding-right: 4px; }
.zone-row { display: grid; grid-template-columns: 92px 1fr 54px; align-items: center; gap: 9px; }
.zone-name { font-size: 11.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zone-track { height: 7px; border-radius: 4px; background: var(--surface-3); position: relative; overflow: hidden; }
.zone-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #7db6f2, var(--primary)); }
.zone-fill.dry { background: linear-gradient(90deg, #f5c27a, #d97706); }
.zone-value { text-align: right; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Calendar heatmap */
.cal-heat { display: flex; gap: 3px; overflow: visible; padding: 4px 0 6px; }
.cal-scroll { overflow-x: auto; padding-bottom: 2px; }
.cal-week { display: grid; grid-template-rows: repeat(7, 12px); gap: 3px; }
.cal-cell { width: 12px; height: 12px; border-radius: 3px; background: #edf1f6; position: relative; }
.cal-cell:hover { outline: 2px solid var(--primary); outline-offset: 1px; }
.cal-cell[data-level="1"] { background: #d7e9fb; }
.cal-cell[data-level="2"] { background: #a9cdf4; }
.cal-cell[data-level="3"] { background: #6ba9e8; }
.cal-cell[data-level="4"] { background: #2f80ed; }
.cal-cell[data-level="5"] { background: #0b57a8; }
.cal-months { display: flex; gap: 3px; color: var(--muted-2); font-size: 9px; padding-bottom: 4px; }
.cal-month { width: 12px; flex: none; }
.cal-legend { display: flex; align-items: center; gap: 4px; font-size: 10px; color: var(--muted); }
.cal-legend .cal-cell { width: 10px; height: 10px; }

/* Gauge / reservoir cards */
.res-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.res-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 15px; box-shadow: var(--shadow-sm); cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.res-card:hover { border-color: #a9cdf4; box-shadow: var(--shadow); transform: translateY(-1px); }
.res-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.res-name { font-size: 12.5px; font-weight: 700; line-height: 1.25; }
.res-zone { font-size: 10.5px; color: var(--muted); }
.res-pct { font-size: 22px; font-weight: 780; letter-spacing: -.03em; line-height: 1; }
.res-pct small { font-size: 10px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.res-bar { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.res-bar span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, #57c6b4, var(--water)); }
.res-meta { display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); }
.res-spark { height: 24px; }
.res-spark svg { width: 100%; height: 100%; overflow: visible; }
.res-grid-empty { grid-column: 1 / -1; }

/* ------------------------------------------------------------
   Mapa de estaciones
   ------------------------------------------------------------ */
.map-card { padding: 18px 20px 14px; margin-bottom: 16px; }
.station-map {
  width: 100%; height: 440px; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: #e9eff5; z-index: 0;
}
.station-map .leaflet-container {
  font-family: var(--font); background: #e9eff5; font-size: 11px;
}
.station-map .leaflet-control-attribution {
  font-size: 9px; background: rgba(255,255,255,.82); color: var(--muted);
}
.station-map .leaflet-control-attribution a { color: var(--muted); }
.station-map .leaflet-bar a { color: var(--text-2); }
.leaflet-div-icon.sai-map-icon { background: transparent; border: 0; }
.sai-pin {
  display: block; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid #fff; background: var(--pin, #0b6bcb);
  box-shadow: 0 1px 5px rgba(8, 29, 51, .35);
  transition: transform .12s ease;
}
.leaflet-marker-icon:hover .sai-pin { transform: scale(1.25); }
.sai-cluster {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 50%; background: rgba(11, 107, 203, .92);
  border: 3px solid #fff; color: #fff; font-size: 10.5px; font-weight: 800;
  box-shadow: 0 3px 12px rgba(8, 29, 51, .28);
}
.sai-cluster.teal { background: rgba(20, 154, 134, .92); }
.sai-cluster.amber { background: rgba(180, 83, 9, .9); }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 5px 13px; }
.map-legend-item { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--muted); }
.map-dot { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #fff; box-shadow: 0 1px 3px rgba(8,29,51,.18); flex: none; }
.map-bottom { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.map-note { font-size: 10px; color: var(--muted-2); max-width: 560px; line-height: 1.45; }
.sai-popup { min-width: 220px; max-width: 290px; }
.sai-popup-title { font-size: 14px; font-weight: 750; color: var(--text); line-height: 1.25; }
.sai-popup-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.sai-popup-badges { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 6px; }
.sai-popup-meta { font-size: 10.5px; color: var(--muted); line-height: 1.5; }
.sai-popup-actions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.sai-popup-actions .btn { height: 26px; padding: 0 8px; font-size: 10.5px; border-radius: 7px; box-shadow: none; }
.sai-popup-actions .btn svg { width: 13px; height: 13px; }
.leaflet-popup-content { margin: 12px 14px; }
.leaflet-popup-content p { margin: 0; }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: 0 10px 30px rgba(8,29,51,.2); }
.map-card .card-head { margin-bottom: 12px; }

.sidebar-logout {
  width: 100%; margin-top: 10px; padding: 8px 10px;
  border-radius: 10px; border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.05); color: #cfe0f2;
  font-size: 11.5px; font-weight: 600; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.sidebar-logout:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.2); }

/* ------------------------------------------------------------
   Acceso
   ------------------------------------------------------------ */
.login-overlay {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center; padding: 22px;
  background:
    radial-gradient(900px 420px at 85% 0%, rgba(47, 128, 237, .35), transparent 60%),
    radial-gradient(600px 300px at 0% 100%, rgba(20, 154, 134, .2), transparent 55%),
    linear-gradient(120deg, #071a2e 0%, #0a2b4b 55%, #0a3f68 100%);
}
.login-card {
  position: relative; width: min(410px, 100%);
  background: var(--surface); border-radius: 20px;
  padding: 28px 28px 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .38);
}
.login-logo {
  width: 48px; height: 48px; border-radius: 14px;
  display: grid; place-items: center; margin-bottom: 16px;
  color: #0b6bcb; background: linear-gradient(145deg, #e8f2fe, #dff5f0);
  border: 1px solid #d7e8fb;
}
.login-logo svg { width: 29px; height: 29px; stroke-width: 1.8; }
.login-card h1 { margin: 0 0 6px; font-size: 23px; letter-spacing: -.03em; }
.login-card p { margin: 0; color: var(--muted); font-size: 12.5px; }
.login-form { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.login-form label { font-size: 11.5px; font-weight: 650; color: var(--muted); }
.login-form input {
  height: 44px; border-radius: 11px; border: 1px solid var(--border);
  padding: 0 13px; font-size: 15px; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.login-form input:focus { border-color: #8ab8ea; box-shadow: 0 0 0 3px rgba(47, 128, 237, .12); }
.login-form button {
  height: 44px; border: 1px solid #0b62b8; border-radius: 11px;
  background: linear-gradient(180deg, #1178da, var(--primary));
  color: #fff; font-size: 13px; font-weight: 700; cursor: pointer;
  box-shadow: 0 8px 18px rgba(11, 107, 203, .18);
}
.login-form button:hover { background: linear-gradient(180deg, #0f6fcc, var(--primary-2)); }
.login-form button:disabled { opacity: .6; cursor: wait; }
.login-error { min-height: 18px; color: var(--danger); font-size: 11.5px; }
.login-note { margin-top: 14px; text-align: center; color: var(--muted-2); font-size: 10px; line-height: 1.5; }

/* Sync */
.sync-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; align-items: start; }
.sync-option { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid #edf1f6; }
.sync-option:last-child { border-bottom: 0; }
.sync-option input { margin-top: 4px; accent-color: var(--primary); }
.sync-option .t { font-size: 12.5px; font-weight: 650; }
.sync-option .d { font-size: 11px; color: var(--muted); }
.sync-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 14px; }
.progress {
  height: 9px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 10px 0 8px;
}
.progress span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #57b0ff, var(--primary));
  transition: width .35s ease;
  position: relative; overflow: hidden;
}
.progress span::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  animation: shimmer 1.6s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.sync-current { font-size: 12px; color: var(--text-2); font-weight: 550; min-height: 18px; }
.sync-counters { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; font-size: 11px; color: var(--muted); }
.sync-counters strong { color: var(--text); font-weight: 700; }
.sync-log {
  margin-top: 12px; background: #0b1f33; color: #b8cde3;
  border-radius: 12px; padding: 12px 14px; max-height: 260px; overflow: auto;
  font-family: var(--mono); font-size: 10.5px; line-height: 1.7;
}
.sync-log .ok { color: #6ee7b7; }
.sync-log .error { color: #fca5a5; }
.sync-log .warn { color: #fcd34d; }
.sync-log .muted { color: #6f93b7; }
.sync-log .info { color: #b8cde3; }

/* Onboarding */
.onboarding {
  display: grid; grid-template-columns: 1.1fr .9fr; gap: 26px;
  padding: 30px; border-radius: 20px;
  background: linear-gradient(120deg, #ffffff, #f7fbff);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.onboarding h2 { margin: 0 0 8px; font-size: 25px; letter-spacing: -.03em; }
.onboarding p { margin: 0 0 16px; color: var(--muted); max-width: 640px; }
.onboarding .steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; gap: 10px; align-items: flex-start; }
.step .n { width: 22px; height: 22px; border-radius: 7px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 10.5px; font-weight: 800; flex: none; }
.step .t { font-size: 12.5px; font-weight: 650; }
.step .d { font-size: 11.5px; color: var(--muted); }
.onboarding-art { display: grid; place-items: center; }
.onboarding-art svg { width: 100%; max-width: 330px; height: auto; }

/* Empty / loading */
.empty { padding: 34px 24px; text-align: center; }
.empty-icon { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; margin: 0 auto 12px; background: var(--surface-3); color: var(--muted); }
.empty-icon svg { width: 22px; height: 22px; }
.empty h3 { margin: 0 0 5px; font-size: 15px; }
.empty p { margin: 0 auto 14px; color: var(--muted); font-size: 12.5px; max-width: 440px; }
.loading-screen { display: grid; place-items: center; min-height: 50vh; color: var(--muted); gap: 12px; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #dbe7f4; border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, #eef2f7 25%, #f7f9fc 50%, #eef2f7 75%); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* Toast / modal */
.toast-wrap { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast {
  display: flex; align-items: flex-start; gap: 9px;
  min-width: 260px; max-width: 380px;
  padding: 12px 14px; border-radius: 12px;
  background: #0b1f33; color: #e6eef8; box-shadow: 0 14px 40px rgba(8,29,51,.3);
  font-size: 12.5px; animation: toastIn .25s ease both;
}
.toast.ok { border-left: 3px solid #34d399; }
.toast.error { border-left: 3px solid #f87171; }
.toast.info { border-left: 3px solid #60a5fa; }
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 29, 51, .55); backdrop-filter: blur(3px); z-index: 90; display: grid; place-items: center; padding: 20px; }
.modal { background: var(--surface); border-radius: 18px; max-width: 760px; width: 100%; max-height: 88vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.3); padding: 22px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.modal-head h3 { margin: 0; font-size: 18px; letter-spacing: -.02em; }

/* Footer */
.footer {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 16px 28px 22px; color: var(--muted-2); font-size: 10.5px;
  border-top: 1px solid var(--border); margin-top: 10px;
}
.footer a { color: var(--muted); }
.footer-sep { opacity: .5; }

/* Utility */
.hidden { display: none !important; }
.stat-line { display: flex; align-items: baseline; gap: 6px; }
.stat-line .big { font-size: 24px; font-weight: 780; letter-spacing: -.03em; }
.stat-line .unit { font-size: 11px; color: var(--muted); font-weight: 600; }
.note {
  display: flex; gap: 8px; align-items: flex-start;
  padding: 10px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--muted); font-size: 11px; line-height: 1.5;
}
.note svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.note.warn { background: var(--warn-soft); border-color: #fde5c0; color: #8a5307; }
.note.info { background: var(--primary-soft); border-color: #cfe4fb; color: #185a99; }

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .res-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .app { grid-template-columns: 224px minmax(0, 1fr); }
  .view { padding: 22px; }
  .topbar { padding: 12px 22px; }
  .hero { grid-template-columns: 1fr; padding: 28px; }
  .hero-art { display: none; }
  .sync-grid { grid-template-columns: 1fr; }
  .onboarding { grid-template-columns: 1fr; }
  .onboarding-art { display: none; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 268px;
    transform: translateX(-102%); transition: transform .22s ease;
    box-shadow: 20px 0 60px rgba(0,0,0,.3);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(8,29,51,.45); z-index: 35; }
  .mobile-menu { display: inline-grid; }
  .topbar { padding: 11px 16px; }
  .view { padding: 18px 16px 30px; }
  .station-map { height: 340px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .page-title { font-size: 17px; }
  .sync-pill { display: none; }
  .footer { padding: 14px 16px 20px; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .res-grid { grid-template-columns: 1fr; }
  .page-head h2 { font-size: 23px; }
  .hero { padding: 24px 20px; border-radius: 18px; }
  .hero h1 { font-size: 29px; }
  .station-map { height: 300px; }
  .map-card { padding: 14px; }
  .card { padding: 15px; }
  .chart-box { height: 260px; }
  .chart-box.tall { height: 300px; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { width: 38px; padding: 0; }
  .table-wrap { max-height: 460px; }
  .cal-week { grid-template-rows: repeat(7, 10px); }
  .cal-cell { width: 10px; height: 10px; }
  .cal-months .cal-month { width: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
