/* ============================================================================
   AcuaMonitor — Design System
   Estilo: observability técnico (Datadog/Grafana) + coherencia con marca ES
   Versión: 1.0  ·  2026-05-29
   ============================================================================

   Cómo usar este archivo:
   - Cárgalo en cada HTML antes de cualquier otro CSS:
       <link rel="stylesheet" href="/styles/design-system.css">
   - Usa los tokens (--am-*) en tu CSS, NO hardcodees colores
   - Los componentes (.panel, .kpi, .btn, etc) son drop-in: dan look correcto
     sin necesidad de añadir más estilos en la página

   Filosofía:
   - Datos protagonistas, no decoración
   - Tipografía monoespaciada (IBM Plex Mono) para CUALQUIER número
   - Status dots (green/amber/red) son el "lenguaje universal" de observability
   - Pocas animaciones, todas funcionales (pulse en live, fade en estado)
   ============================================================================ */


/* ─── 1. RESET MÍNIMO ───────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

input, textarea, select {
  font: inherit;
  color: inherit;
}


/* ─── 2. TOKENS ─────────────────────────────────────────────────────────── */

:root {
  /* Superficies (escala de dark mode tipo Grafana — 4 niveles de profundidad) */
  --am-bg:           #0a0a0c;   /* canvas / fondo de página */
  --am-surface:      #131318;   /* panel base */
  --am-surface-hi:   #1a1a22;   /* panel elevado / hover */
  --am-surface-low:  #0e0e13;   /* panel hundido / inputs */

  /* Bordes */
  --am-border:       #25252f;
  --am-border-hi:    #34344a;   /* hover / focus */

  /* Texto (escala 4 niveles) */
  --am-text:         rgba(255, 255, 255, 0.92);
  --am-text-muted:   rgba(255, 255, 255, 0.65);
  --am-text-soft:    rgba(255, 255, 255, 0.45);
  --am-text-faint:   rgba(255, 255, 255, 0.28);

  /* Acento principal — Hydro (coherente con Engineering Solutions) */
  --am-accent:       #4a7a96;
  --am-accent-hi:    #5e93b0;
  --am-accent-soft:  rgba(74, 122, 150, 0.15);
  --am-accent-glow:  rgba(74, 122, 150, 0.35);
  --am-mist:         #7ba3bd;   /* highlight tipográfico */

  /* Status — el lenguaje universal de observability */
  --am-ok:           #10b981;   /* verde — todo bien, live */
  --am-ok-soft:      rgba(16, 185, 129, 0.15);
  --am-warn:         #f59e0b;   /* ámbar — atención */
  --am-warn-soft:    rgba(245, 158, 11, 0.15);
  --am-err:          #ef4444;   /* rojo — crítico */
  --am-err-soft:     rgba(239, 68, 68, 0.15);
  --am-info:         #3b82f6;   /* azul info (no agua) */
  --am-info-soft:    rgba(59, 130, 246, 0.15);

  /* Tipografía */
  --am-font-ui:      "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --am-font-data:    "IBM Plex Mono", "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;

  /* Tamaños tipográficos */
  --am-fs-xs:        11px;
  --am-fs-sm:        13px;
  --am-fs-base:      14px;
  --am-fs-md:        16px;
  --am-fs-lg:        20px;
  --am-fs-xl:        28px;
  --am-fs-2xl:       40px;
  --am-fs-3xl:       56px;
  --am-fs-4xl:       72px;

  /* Pesos */
  --am-fw-regular:   400;
  --am-fw-medium:    500;
  --am-fw-semibold:  600;

  /* Espaciado (escala 4px) */
  --am-sp-1:         4px;
  --am-sp-2:         8px;
  --am-sp-3:         12px;
  --am-sp-4:         16px;
  --am-sp-5:         20px;
  --am-sp-6:         24px;
  --am-sp-8:         32px;
  --am-sp-10:        40px;
  --am-sp-12:        48px;
  --am-sp-16:        64px;
  --am-sp-20:        80px;

  /* Radios */
  --am-r-sm:         4px;
  --am-r-md:         6px;
  --am-r-lg:         10px;
  --am-r-full:       9999px;

  /* Sombras (suaves, no glamour) */
  --am-shadow-1:     0 1px 2px rgba(0,0,0,0.4);
  --am-shadow-2:     0 4px 12px rgba(0,0,0,0.45);
  --am-shadow-glow:  0 0 20px var(--am-accent-glow);

  /* Layout shell */
  --am-sidebar-w:    240px;
  --am-topbar-h:     60px;

  /* Transiciones */
  --am-trans-fast:   120ms cubic-bezier(0.4, 0, 0.2, 1);
  --am-trans-base:   180ms cubic-bezier(0.4, 0, 0.2, 1);
}


/* ─── 3. BASE TIPOGRÁFICA ────────────────────────────────────────────────── */

body {
  font-family: var(--am-font-ui);
  font-size: var(--am-fs-base);
  font-weight: var(--am-fw-regular);
  line-height: 1.5;
  color: var(--am-text);
  background: var(--am-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Cualquier número (datos) va en monospace — clave del look observability */
.am-mono,
[data-mono] {
  font-family: var(--am-font-data);
  font-feature-settings: "tnum" 1; /* tabular nums, alineación perfecta */
  letter-spacing: -0.01em;
}

h1, h2, h3, h4 {
  font-weight: var(--am-fw-medium);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h1 { font-size: var(--am-fs-3xl); }
h2 { font-size: var(--am-fs-2xl); }
h3 { font-size: var(--am-fs-xl); }
h4 { font-size: var(--am-fs-lg); }

.am-eyebrow {
  font-size: var(--am-fs-xs);
  font-weight: var(--am-fw-medium);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--am-text-soft);
}


/* ─── 4. COMPONENTES — PANEL ────────────────────────────────────────────── */

/* El bloque de información básico. Todo dashboard se construye con paneles. */
.am-panel {
  background: var(--am-surface);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
  padding: var(--am-sp-5);
  transition: border-color var(--am-trans-base), background var(--am-trans-base);
}

.am-panel:hover {
  border-color: var(--am-border-hi);
}

.am-panel--inset {
  background: var(--am-surface-low);
}

.am-panel--flat {
  background: transparent;
}

.am-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--am-sp-4);
}

.am-panel__title {
  font-size: var(--am-fs-xs);
  font-weight: var(--am-fw-medium);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--am-text-soft);
}


/* ─── 5. COMPONENTES — KPI ──────────────────────────────────────────────── */

/* La métrica numérica destacada. Número en mono grande + label pequeño. */
.am-kpi {
  display: flex;
  flex-direction: column;
  gap: var(--am-sp-2);
}

.am-kpi__value {
  font-family: var(--am-font-data);
  font-size: var(--am-fs-2xl);
  font-weight: var(--am-fw-medium);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--am-text);
  font-feature-settings: "tnum" 1;
}

.am-kpi__value--sm  { font-size: var(--am-fs-xl); }
.am-kpi__value--lg  { font-size: var(--am-fs-3xl); }

.am-kpi__unit {
  font-size: 0.5em;
  font-weight: var(--am-fw-regular);
  color: var(--am-text-soft);
  margin-left: 0.25em;
  letter-spacing: 0;
}

.am-kpi__label {
  font-size: var(--am-fs-xs);
  color: var(--am-text-muted);
  letter-spacing: 0.05em;
}

.am-kpi__delta {
  font-family: var(--am-font-data);
  font-size: var(--am-fs-sm);
  color: var(--am-text-soft);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.am-kpi__delta--up   { color: var(--am-ok); }
.am-kpi__delta--down { color: var(--am-err); }


/* ─── 6. COMPONENTES — STATUS DOT ──────────────────────────────────────── */

/* El "semáforo" universal de observability. */
.am-status {
  display: inline-flex;
  align-items: center;
  gap: var(--am-sp-2);
  font-size: var(--am-fs-xs);
  font-weight: var(--am-fw-medium);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--am-text-muted);
}

.am-status__dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--am-text-faint);
}

.am-status--ok   .am-status__dot { background: var(--am-ok); }
.am-status--warn .am-status__dot { background: var(--am-warn); }
.am-status--err  .am-status__dot { background: var(--am-err); }
.am-status--ok   { color: var(--am-ok); }
.am-status--warn { color: var(--am-warn); }
.am-status--err  { color: var(--am-err); }

/* Modificador --live: añade pulso (solo para "en vivo"/transmitiendo) */
.am-status--live .am-status__dot::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: am-pulse 1.6s ease-out infinite;
}

@keyframes am-pulse {
  0%   { transform: scale(0.6); opacity: 0.6; }
  100% { transform: scale(2.2); opacity: 0; }
}


/* ─── 7. COMPONENTES — PILL / BADGE ────────────────────────────────────── */

.am-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--am-sp-2);
  padding: 3px var(--am-sp-3);
  border-radius: var(--am-r-full);
  background: var(--am-surface-hi);
  border: 1px solid var(--am-border);
  color: var(--am-text-muted);
  font-size: var(--am-fs-xs);
  font-weight: var(--am-fw-medium);
  white-space: nowrap;
}

.am-pill--accent { background: var(--am-accent-soft); border-color: transparent; color: var(--am-mist); }
.am-pill--ok     { background: var(--am-ok-soft);     border-color: transparent; color: var(--am-ok); }
.am-pill--warn   { background: var(--am-warn-soft);   border-color: transparent; color: var(--am-warn); }
.am-pill--err    { background: var(--am-err-soft);    border-color: transparent; color: var(--am-err); }


/* ─── 8. COMPONENTES — BUTTON ──────────────────────────────────────────── */

.am-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--am-sp-2);
  padding: var(--am-sp-3) var(--am-sp-5);
  border-radius: var(--am-r-md);
  font-size: var(--am-fs-sm);
  font-weight: var(--am-fw-medium);
  border: 1px solid transparent;
  transition: background var(--am-trans-fast), border-color var(--am-trans-fast), transform var(--am-trans-fast);
  white-space: nowrap;
}

.am-btn:hover  { transform: translateY(-1px); }
.am-btn:active { transform: translateY(0); }
.am-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Primario — gradient hydro con glow sutil */
.am-btn--primary {
  background: linear-gradient(135deg, var(--am-accent-hi) 0%, var(--am-accent) 100%);
  color: white;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08) inset, 0 4px 14px rgba(74, 122, 150, 0.25);
}
.am-btn--primary:hover {
  background: linear-gradient(135deg, #6ba0bd 0%, var(--am-accent-hi) 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 6px 20px rgba(74, 122, 150, 0.4);
}

/* Secundario — outline */
.am-btn--secondary {
  background: var(--am-surface);
  border-color: var(--am-border);
  color: var(--am-text);
}
.am-btn--secondary:hover { border-color: var(--am-border-hi); background: var(--am-surface-hi); }

/* Ghost — sin fondo */
.am-btn--ghost {
  color: var(--am-text-muted);
}
.am-btn--ghost:hover { color: var(--am-text); background: var(--am-surface-hi); }

/* Tamaños */
.am-btn--sm { padding: 6px var(--am-sp-3); font-size: var(--am-fs-xs); }
.am-btn--lg { padding: var(--am-sp-4) var(--am-sp-6); font-size: var(--am-fs-base); }


/* ─── 9. COMPONENTES — INPUT ───────────────────────────────────────────── */

.am-input {
  width: 100%;
  padding: var(--am-sp-3) var(--am-sp-4);
  background: var(--am-surface-low);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
  color: var(--am-text);
  font-size: var(--am-fs-sm);
  transition: border-color var(--am-trans-fast);
}

.am-input::placeholder { color: var(--am-text-faint); }
.am-input:focus { outline: none; border-color: var(--am-accent); }
.am-input:disabled { opacity: 0.5; cursor: not-allowed; }


/* ─── 10. COMPONENTES — DATA TABLE ─────────────────────────────────────── */

.am-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--am-fs-sm);
}

.am-table thead th {
  text-align: left;
  padding: var(--am-sp-2) var(--am-sp-3);
  border-bottom: 1px solid var(--am-border);
  font-size: var(--am-fs-xs);
  font-weight: var(--am-fw-medium);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--am-text-soft);
}

.am-table tbody td {
  padding: var(--am-sp-3);
  border-bottom: 1px solid var(--am-border);
  color: var(--am-text-muted);
}

.am-table tbody tr:hover { background: var(--am-surface-hi); }
.am-table tbody tr:last-child td { border-bottom: none; }

.am-table td[data-mono],
.am-table td.am-mono {
  font-family: var(--am-font-data);
  color: var(--am-text);
}


/* ─── 11. COMPONENTES — CHART CONTAINER ────────────────────────────────── */

/* Wrapper de canvas/svg. Da el frame correcto a Chart.js, Recharts, etc. */
.am-chart {
  position: relative;
  width: 100%;
  height: 200px;
}

.am-chart--sm { height: 120px; }
.am-chart--lg { height: 320px; }
.am-chart--xl { height: 440px; }


/* ─── 12. LAYOUT SHELL (sidebar + topbar + canvas) ─────────────────────── */

.am-shell {
  display: grid;
  grid-template-columns: var(--am-sidebar-w) 1fr;
  grid-template-rows: var(--am-topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}

.am-shell__sidebar {
  grid-area: sidebar;
  background: var(--am-surface);
  border-right: 1px solid var(--am-border);
  padding: var(--am-sp-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--am-sp-2);
  overflow-y: auto;
}

/* Brand AcuaMonitor en sidebar (arriba) */
.am-shell__brand {
  display: flex;
  align-items: center;
  gap: var(--am-sp-3);
  padding: 0 var(--am-sp-4);
  margin-bottom: var(--am-sp-2);
  font-size: var(--am-fs-md);
  font-weight: var(--am-fw-semibold);
  letter-spacing: -0.01em;
  color: var(--am-text);
}

/* Co-branding tenant (acueducto cliente) */
.am-shell__tenant {
  display: flex;
  align-items: center;
  gap: var(--am-sp-3);
  margin: 0 var(--am-sp-3) var(--am-sp-3);
  padding: var(--am-sp-3);
  background: var(--am-surface-hi);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
}

.am-shell__tenant-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--am-r-sm);
  background: var(--am-surface-low);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.am-shell__tenant-info { flex: 1; min-width: 0; }

.am-shell__tenant-name {
  font-size: var(--am-fs-sm);
  font-weight: var(--am-fw-medium);
  letter-spacing: -0.01em;
  color: var(--am-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.am-shell__tenant-code {
  font-family: var(--am-font-data);
  font-size: 10px;
  color: var(--am-text-soft);
  margin-top: 2px;
}

/* Topbar */
.am-shell__topbar {
  grid-area: topbar;
  background: var(--am-bg);
  border-bottom: 1px solid var(--am-border);
  padding: 0 var(--am-sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--am-sp-4);
  z-index: 20;
}

/* Breadcrumb / título de la vista actual */
.am-shell__breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--am-sp-2);
  font-size: var(--am-fs-md);
  font-weight: var(--am-fw-medium);
  letter-spacing: -0.01em;
  color: var(--am-text);
}

.am-shell__breadcrumb-sep {
  color: var(--am-text-faint);
  font-size: var(--am-fs-sm);
}

.am-shell__breadcrumb-current {
  color: var(--am-text-muted);
  font-weight: var(--am-fw-regular);
}

/* Acciones de la topbar (derecha) */
.am-shell__topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--am-sp-3);
}

/* Clock + status conexión */
.am-shell__clock {
  font-family: var(--am-font-data);
  font-size: var(--am-fs-sm);
  color: var(--am-text);
  letter-spacing: -0.01em;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.1;
}

.am-shell__clock-date {
  font-size: 10px;
  color: var(--am-text-soft);
}

/* Pill de usuario en topbar */
.am-shell__user {
  display: flex;
  align-items: center;
  gap: var(--am-sp-2);
  padding: 6px var(--am-sp-3);
  background: var(--am-surface);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-full);
  font-size: var(--am-fs-sm);
  color: var(--am-text);
  transition: border-color var(--am-trans-fast);
}

.am-shell__user:hover { border-color: var(--am-border-hi); }

.am-shell__user-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--am-accent-hi), var(--am-accent));
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: var(--am-fw-semibold);
  color: white;
  flex-shrink: 0;
}

/* Main canvas */
.am-shell__main {
  grid-area: main;
  padding: var(--am-sp-6) var(--am-sp-8);
  overflow-x: hidden;
  background: var(--am-bg);
}

/* Sidebar nav items */
.am-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 var(--am-sp-3);
}

.am-nav__item {
  display: flex;
  align-items: center;
  gap: var(--am-sp-3);
  padding: 8px var(--am-sp-3);
  border-radius: var(--am-r-sm);
  color: var(--am-text-muted);
  font-size: var(--am-fs-sm);
  transition: background var(--am-trans-fast), color var(--am-trans-fast);
}

.am-nav__item:hover { background: var(--am-surface-hi); color: var(--am-text); }

.am-nav__item--active {
  background: var(--am-accent-soft);
  color: var(--am-mist);
}

.am-nav__item--active svg { color: var(--am-mist); }

.am-nav__item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--am-text-soft);
}

.am-nav__item:hover svg { color: var(--am-text); }

/* Sección dentro de la nav (con etiqueta tipo "OPERACIÓN") */
.am-nav__section {
  padding: var(--am-sp-3) var(--am-sp-4) var(--am-sp-1);
  font-size: 10px;
  font-weight: var(--am-fw-medium);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--am-text-faint);
}

/* Sidebar foot (separador + status + reloj/agua) */
.am-shell__sidebar-foot {
  margin-top: auto;
  padding: var(--am-sp-3) var(--am-sp-4);
  border-top: 1px solid var(--am-border);
  display: flex;
  flex-direction: column;
  gap: var(--am-sp-2);
  font-size: var(--am-fs-xs);
  color: var(--am-text-soft);
}


/* ─── 13. UTILITIES ─────────────────────────────────────────────────────── */

.am-stack       { display: flex; flex-direction: column; gap: var(--am-sp-4); }
.am-stack--sm   { display: flex; flex-direction: column; gap: var(--am-sp-2); }
.am-stack--lg   { display: flex; flex-direction: column; gap: var(--am-sp-6); }
.am-row         { display: flex; align-items: center; gap: var(--am-sp-4); }
.am-row--sm     { display: flex; align-items: center; gap: var(--am-sp-2); }
.am-row--between{ display: flex; align-items: center; justify-content: space-between; gap: var(--am-sp-4); }
.am-grid-2      { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--am-sp-4); }
.am-grid-3      { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--am-sp-4); }
.am-grid-4      { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--am-sp-4); }

.am-muted       { color: var(--am-text-muted); }
.am-soft        { color: var(--am-text-soft); }
.am-faint       { color: var(--am-text-faint); }

.am-hide-scroll::-webkit-scrollbar { display: none; }
.am-hide-scroll { scrollbar-width: none; }


/* ─── 14. GRID DE FONDO TÉCNICO (opcional — para hero/empty states) ────── */

.am-grid-bg {
  background-image:
    linear-gradient(var(--am-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--am-border) 1px, transparent 1px);
  background-size: 48px 48px;
  background-position: -1px -1px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}


/* ─── 14b. COMPONENTES — TANK WIDGET ───────────────────────────────────── */

/* Visualización de nivel de tanque. Cilindro estilizado con fill animado +
   marcas de escala + valor numérico en mono. Uso típico: dashboard de tanques.
*/

.am-tank {
  display: flex;
  align-items: stretch;
  gap: var(--am-sp-4);
  padding: var(--am-sp-4);
}

.am-tank__body {
  position: relative;
  width: 80px;
  height: 200px;
  flex-shrink: 0;
  background: var(--am-surface-low);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
  overflow: hidden;
}

.am-tank__fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, var(--am-accent-hi) 0%, var(--am-accent) 100%);
  transition: height 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Borde superior del fill = "superficie del agua" con leve glow */
.am-tank__fill::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--am-mist);
  box-shadow: 0 0 8px var(--am-accent-glow);
}

/* Onda sutil en superficie (decorativa, indica que hay flujo) */
.am-tank__fill::after {
  content: "";
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 6px;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 6px,
    var(--am-mist) 6px,
    var(--am-mist) 8px
  );
  opacity: 0.4;
  animation: am-tank-wave 3s linear infinite;
}

@keyframes am-tank-wave {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-14px); }
}

/* Estados de nivel — cambia color del fill */
.am-tank--warn .am-tank__fill { background: linear-gradient(180deg, var(--am-warn) 0%, #c97a04 100%); }
.am-tank--err  .am-tank__fill { background: linear-gradient(180deg, var(--am-err)  0%, #a8201f 100%); }

/* Escala lateral (0% a 100%) */
.am-tank__scale {
  display: flex;
  flex-direction: column-reverse;
  justify-content: space-between;
  font-family: var(--am-font-data);
  font-size: 10px;
  color: var(--am-text-faint);
  padding: 2px 0;
  user-select: none;
}

/* Info al lado del cilindro */
.am-tank__info {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex: 1;
  min-width: 0;
}

.am-tank__name {
  font-size: var(--am-fs-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--am-text-soft);
}

.am-tank__pct {
  font-family: var(--am-font-data);
  font-size: var(--am-fs-2xl);
  font-weight: var(--am-fw-medium);
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--am-text);
}

.am-tank__pct-unit {
  font-size: 0.4em;
  color: var(--am-text-soft);
  margin-left: 0.2em;
}

.am-tank__volume {
  font-family: var(--am-font-data);
  font-size: var(--am-fs-sm);
  color: var(--am-text-muted);
}


/* ─── 14c. COMPONENTES — CHARTS BASE ──────────────────────────────────── */

/* Wrappers para SVG inline. La gracia es que el SVG hereda colores via
   `currentColor` y los paths se pintan con `stroke="currentColor"`.
*/

.am-chart-card {
  background: var(--am-surface);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
  padding: var(--am-sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--am-sp-3);
}

.am-chart-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--am-sp-4);
}

.am-chart-card__title {
  font-size: var(--am-fs-xs);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--am-text-soft);
}

.am-chart-card__value {
  font-family: var(--am-font-data);
  font-size: var(--am-fs-xl);
  font-weight: var(--am-fw-medium);
  line-height: 1;
  color: var(--am-text);
}

.am-chart-card__svg {
  width: 100%;
  height: auto;
  display: block;
  color: var(--am-accent-hi); /* line color */
}

/* Sparkline inline (junto al KPI) */
.am-sparkline {
  width: 100%;
  height: 36px;
  color: var(--am-accent-hi);
}


/* ─── 14d. COMPONENTES — GAUGE RADIAL ─────────────────────────────────── */

/* Gauge de 180° con umbrales (verde-ámbar-rojo). SVG puro. */
.am-gauge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--am-sp-2);
  padding: var(--am-sp-3);
}

.am-gauge__svg {
  width: 160px;
  height: 90px;
}

.am-gauge__value {
  font-family: var(--am-font-data);
  font-size: var(--am-fs-xl);
  font-weight: var(--am-fw-medium);
  letter-spacing: -0.02em;
  color: var(--am-text);
  margin-top: -32px;
}

.am-gauge__label {
  font-size: var(--am-fs-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--am-text-soft);
}


/* ─── 14e. COMPONENTES — MAP MODULE ────────────────────────────────────── */

/* Módulo mapa con panel lateral. El SVG/canvas del mapa va en .am-map__canvas;
   .am-map__panel es el detalle a la derecha. Pensado para encajar con Leaflet
   también (basta poner el div del mapa dentro de .am-map__canvas).
*/

.am-map {
  display: grid;
  grid-template-columns: 1fr 320px;
  background: var(--am-surface);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
  overflow: hidden;
  height: 560px;
}

.am-map__canvas {
  position: relative;
  background: var(--am-bg);
  overflow: hidden;
}

/* Top bar del mapa (filtros + búsqueda) — flota sobre el canvas */
.am-map__topbar {
  position: absolute;
  top: var(--am-sp-4);
  left: var(--am-sp-4);
  right: var(--am-sp-4);
  display: flex;
  gap: var(--am-sp-3);
  align-items: center;
  z-index: 10;
  pointer-events: none;
}

.am-map__topbar > * { pointer-events: auto; }

.am-map__search {
  flex: 0 0 280px;
  background: rgba(19, 19, 24, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
  padding: var(--am-sp-2) var(--am-sp-3);
  color: var(--am-text);
  font-size: var(--am-fs-sm);
}

.am-map__search:focus { outline: none; border-color: var(--am-accent); }
.am-map__search::placeholder { color: var(--am-text-faint); }

.am-map__filters {
  display: flex;
  gap: var(--am-sp-1);
  background: rgba(19, 19, 24, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
  padding: 3px;
}

.am-map__filter {
  padding: 4px var(--am-sp-3);
  border-radius: var(--am-r-sm);
  font-size: var(--am-fs-xs);
  font-weight: var(--am-fw-medium);
  color: var(--am-text-muted);
  cursor: pointer;
  transition: background var(--am-trans-fast), color var(--am-trans-fast);
}

.am-map__filter:hover { color: var(--am-text); }
.am-map__filter--active { background: var(--am-accent-soft); color: var(--am-mist); }

/* Legend abajo a la izquierda */
.am-map__legend {
  position: absolute;
  bottom: var(--am-sp-4);
  left: var(--am-sp-4);
  background: rgba(19, 19, 24, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
  padding: var(--am-sp-3) var(--am-sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--am-sp-2);
  z-index: 10;
}

.am-map__legend-item {
  display: flex;
  align-items: center;
  gap: var(--am-sp-3);
  font-size: var(--am-fs-xs);
  color: var(--am-text-muted);
}

.am-map__legend-item .am-mono { color: var(--am-text); min-width: 24px; text-align: right; }

/* Panel lateral derecho */
.am-map__panel {
  border-left: 1px solid var(--am-border);
  background: var(--am-surface);
  padding: var(--am-sp-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--am-sp-4);
}

.am-map__panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--am-sp-3);
}

.am-map__panel-title {
  font-size: var(--am-fs-md);
  font-weight: var(--am-fw-medium);
  letter-spacing: -0.01em;
}

.am-map__panel-sub {
  font-family: var(--am-font-data);
  font-size: var(--am-fs-xs);
  color: var(--am-text-soft);
  margin-top: 2px;
}

/* Markers SVG — el círculo central + halo */
.am-map-marker { cursor: pointer; }
.am-map-marker__core { transition: r 120ms ease; }
.am-map-marker:hover .am-map-marker__core { r: 9; }

.am-map-marker__halo {
  transform-origin: center;
  transform-box: fill-box;
  animation: am-marker-pulse 1.8s ease-out infinite;
}

@keyframes am-marker-pulse {
  0%   { transform: scale(0.6); opacity: 0.7; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* Responsive */
@media (max-width: 1024px) {
  .am-map {
    grid-template-columns: 1fr;
    height: auto;
  }
  .am-map__canvas { height: 360px; }
  .am-map__panel { border-left: none; border-top: 1px solid var(--am-border); }
}

/* Marcadores para Leaflet — divIcon HTML.
   Reusan los colores y animación del DS. Se sobreponen al tile real del mapa. */
.am-leaflet-marker {
  position: relative;
  width: 16px;
  height: 16px;
}

.am-leaflet-marker__core {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--am-bg);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.5);
}

.am-leaflet-marker__halo {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  opacity: 0.6;
  animation: am-marker-pulse 1.8s ease-out infinite;
}

/* Color por estado del marker */
.am-leaflet-marker--ok   .am-leaflet-marker__core,
.am-leaflet-marker--ok   .am-leaflet-marker__halo { background: var(--am-ok); }
.am-leaflet-marker--warn .am-leaflet-marker__core,
.am-leaflet-marker--warn .am-leaflet-marker__halo { background: var(--am-warn); }
.am-leaflet-marker--err  .am-leaflet-marker__core,
.am-leaflet-marker--err  .am-leaflet-marker__halo { background: var(--am-err); }
.am-leaflet-marker--off  .am-leaflet-marker__core { background: #555; }
.am-leaflet-marker--off  .am-leaflet-marker__halo { display: none; }

/* Marcador seleccionado: anillo punteado alrededor */
.am-leaflet-marker--selected::after {
  content: "";
  position: absolute;
  inset: -8px;
  border: 1.5px dashed var(--am-mist);
  border-radius: 50%;
  pointer-events: none;
}

/* Override del control y attribution de Leaflet para que combinen con el DS */
.leaflet-container { background: var(--am-bg); font-family: var(--am-font-ui); }
.leaflet-control-attribution {
  background: rgba(19, 19, 24, 0.85) !important;
  color: var(--am-text-faint) !important;
  font-size: 10px !important;
  padding: 2px 6px !important;
  backdrop-filter: blur(8px);
}
.leaflet-control-attribution a { color: var(--am-text-soft) !important; }


/* ───── OVERLAYS de capas KMZ del cliente ───── */

/* Red de distribución — polyline con dashflow animado (flujo) */
.am-pipe path {
  stroke-dasharray: 8 6 !important;
  animation: am-pipe-flow 1.4s linear infinite;
  filter: drop-shadow(0 0 4px rgba(74, 122, 150, 0.6));
}

.am-pipe--alarm path {
  stroke-dasharray: 4 4 !important;
  animation: am-pipe-flow 0.6s linear infinite;
  filter: drop-shadow(0 0 6px rgba(239, 68, 68, 0.7));
}

@keyframes am-pipe-flow {
  to { stroke-dashoffset: -14; }
}

/* Polígono de zona de cobertura */
.am-coverage path {
  stroke-dasharray: 6 6 !important;
}

/* Iconos custom para overlay: tanque (cilindro mini) */
.am-leaflet-tank {
  width: 24px;
  height: 28px;
  position: relative;
}

.am-leaflet-tank__body {
  position: absolute;
  inset: 0;
  background: var(--am-surface);
  border: 1.5px solid var(--am-mist);
  border-radius: 4px 4px 6px 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5), 0 0 0 1px rgba(0,0,0,0.4);
}

.am-leaflet-tank__fill {
  position: absolute;
  left: 1.5px;
  right: 1.5px;
  bottom: 1.5px;
  background: linear-gradient(180deg, var(--am-mist), var(--am-accent));
  border-radius: 0 0 4px 4px;
  transition: height 600ms ease;
}

.am-leaflet-tank--warn .am-leaflet-tank__fill { background: linear-gradient(180deg, var(--am-warn), #c97a04); }
.am-leaflet-tank--err  .am-leaflet-tank__fill { background: linear-gradient(180deg, var(--am-err),  #a8201f); }

/* Suscriptor / medidor: dot pequeño gris (alta densidad, no debe distraer) */
.am-leaflet-meter {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--am-bg);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.4);
}


/* ───── ANIMACIONES — reveal stagger + word swap (para login y otras pantallas) ───── */

@keyframes am-reveal {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.am-reveal {
  animation: am-reveal 700ms cubic-bezier(0.2, 0.65, 0.3, 1) both;
}

.am-reveal[data-delay="1"] { animation-delay: 80ms;  }
.am-reveal[data-delay="2"] { animation-delay: 160ms; }
.am-reveal[data-delay="3"] { animation-delay: 240ms; }
.am-reveal[data-delay="4"] { animation-delay: 320ms; }
.am-reveal[data-delay="5"] { animation-delay: 420ms; }
.am-reveal[data-delay="6"] { animation-delay: 520ms; }
.am-reveal[data-delay="7"] { animation-delay: 620ms; }

/* Word swap — cambia palabra clave del título con fade */
.am-word-swap {
  display: inline-block;
  position: relative;
  vertical-align: baseline;
}

.am-word-swap__word {
  display: inline-block;
  transition: opacity 300ms ease, transform 300ms ease;
}

.am-word-swap__word--out {
  opacity: 0;
  transform: translateY(-6px);
}

.am-word-swap__word--in {
  opacity: 0;
  transform: translateY(6px);
}


/* ─── 14f. COMPONENTES — TABS ──────────────────────────────────────────── */

/* Tabs segmentados estilo iOS/Linear. Patrón usado en login (operario/suscriptor)
   y en filtros del dashboard.
*/

.am-tabs {
  display: inline-flex;
  background: var(--am-surface-low);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
  padding: 3px;
  gap: 2px;
}

.am-tab {
  padding: var(--am-sp-2) var(--am-sp-4);
  border-radius: var(--am-r-sm);
  font-size: var(--am-fs-sm);
  font-weight: var(--am-fw-medium);
  color: var(--am-text-muted);
  transition: background var(--am-trans-fast), color var(--am-trans-fast);
  white-space: nowrap;
}

.am-tab:hover { color: var(--am-text); }
.am-tab--active {
  background: var(--am-surface-hi);
  color: var(--am-text);
  box-shadow: var(--am-shadow-1);
}

.am-tabs--full { display: flex; }
.am-tabs--full .am-tab { flex: 1; text-align: center; }


/* ─── 14g. PANTALLA AUTH (split 50/50) ─────────────────────────────────── */

/* Layout de pantalla completa para login / registro / recovery */

.am-auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--am-bg);
}

.am-auth__side {
  position: relative;
  padding: var(--am-sp-12) var(--am-sp-10);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Lado narrativa — mesh gradient con más presencia + glow hydro */
.am-auth__narrative {
  background:
    radial-gradient(circle 700px at 25% 30%, rgba(74, 122, 150, 0.22) 0%, transparent 55%),
    radial-gradient(circle 500px at 80% 90%, rgba(94, 147, 176, 0.12) 0%, transparent 50%),
    radial-gradient(circle 400px at 10% 80%, rgba(123, 163, 189, 0.08) 0%, transparent 60%),
    var(--am-bg);
  border-right: 1px solid var(--am-border);
}

/* Capa 1: grid técnico sutil */
.am-auth__narrative::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--am-border) 1px, transparent 1px),
    linear-gradient(90deg, var(--am-border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at 30% 40%, black 25%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 30% 40%, black 25%, transparent 75%);
  opacity: 0.6;
  pointer-events: none;
}

/* Capa 2: waveform/sparkline gigante de fondo — referencia funcional (caudal),
   no decoración literal de agua. Da depth + temática a la vez. */
.am-auth__narrative::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 12%;
  height: 280px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 280' preserveAspectRatio='none'><path d='M0 200 Q100 180 200 160 T400 140 Q500 110 600 90 T800 70 Q900 50 1000 80 T1200 60 L1200 280 L0 280 Z' fill='%234a7a96' fill-opacity='0.10'/><path d='M0 200 Q100 180 200 160 T400 140 Q500 110 600 90 T800 70 Q900 50 1000 80 T1200 60' stroke='%237ba3bd' stroke-width='1.5' stroke-opacity='0.35' fill='none'/></svg>");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  pointer-events: none;
  z-index: 0;
}

.am-auth__side > * { position: relative; z-index: 1; }

.am-auth__brand {
  display: flex;
  align-items: center;
  gap: var(--am-sp-3);
  font-size: var(--am-fs-md);
  font-weight: var(--am-fw-semibold);
  letter-spacing: -0.01em;
}

.am-auth__brand-mark {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--am-accent-hi), var(--am-accent));
  box-shadow: 0 0 16px var(--am-accent-glow);
}

.am-auth__hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--am-sp-6);
  max-width: 480px;
}

.am-auth__hero-title {
  font-size: var(--am-fs-3xl);
  font-weight: var(--am-fw-medium);
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.am-auth__hero-title em {
  font-family: var(--am-font-ui);
  font-style: normal;
  background: linear-gradient(135deg, var(--am-mist) 0%, var(--am-accent-hi) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.am-auth__hero-sub {
  font-size: var(--am-fs-md);
  color: var(--am-text-muted);
  line-height: 1.55;
}

.am-auth__features {
  display: flex;
  flex-direction: column;
  gap: var(--am-sp-3);
  margin-top: var(--am-sp-4);
}

.am-auth__feature {
  display: flex;
  align-items: center;
  gap: var(--am-sp-3);
  font-size: var(--am-fs-sm);
  color: var(--am-text-muted);
}

.am-auth__feature-bullet {
  font-family: var(--am-font-data);
  color: var(--am-mist);
  font-size: 11px;
}

.am-auth__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--am-fs-xs);
  color: var(--am-text-faint);
}

/* Lado form */
.am-auth__form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

.am-auth__form {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--am-sp-5);
}

/* Card co-branding del acueducto cliente */
.am-auth__tenant {
  display: flex;
  align-items: center;
  gap: var(--am-sp-4);
  padding: var(--am-sp-4);
  background: var(--am-surface);
  border: 1px solid var(--am-border);
  border-radius: var(--am-r-md);
}

.am-auth__tenant-logo {
  width: 48px;
  height: 48px;
  border-radius: var(--am-r-md);
  background: var(--am-surface-hi);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}

.am-auth__tenant-info { flex: 1; min-width: 0; }

.am-auth__tenant-name {
  font-size: var(--am-fs-md);
  font-weight: var(--am-fw-medium);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.am-auth__tenant-code {
  font-family: var(--am-font-data);
  font-size: var(--am-fs-xs);
  color: var(--am-text-soft);
  margin-top: 2px;
}

.am-auth__tenant-change {
  font-size: var(--am-fs-xs);
  color: var(--am-text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--am-border-hi);
  transition: color var(--am-trans-fast);
}
.am-auth__tenant-change:hover { color: var(--am-mist); }

.am-auth__field {
  display: flex;
  flex-direction: column;
  gap: var(--am-sp-2);
}

.am-auth__field-label {
  font-size: var(--am-fs-xs);
  font-weight: var(--am-fw-medium);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--am-text-soft);
}

.am-auth__input-group {
  position: relative;
}

.am-auth__input-toggle {
  position: absolute;
  right: var(--am-sp-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--am-text-soft);
  transition: color var(--am-trans-fast);
}
.am-auth__input-toggle:hover { color: var(--am-text); }


/* Responsive del auth */
@media (max-width: 900px) {
  .am-auth {
    grid-template-columns: 1fr;
  }
  .am-auth__narrative {
    border-right: none;
    border-bottom: 1px solid var(--am-border);
    min-height: auto;
    padding: var(--am-sp-8) var(--am-sp-5);
  }
  .am-auth__side { padding: var(--am-sp-8) var(--am-sp-5); }
  .am-auth__hero-title { font-size: var(--am-fs-xl); }
}


/* ─── 15. RESPONSIVE ─────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .am-shell {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .am-shell__sidebar { display: none; }
  .am-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .am-grid-3, .am-grid-4 { grid-template-columns: 1fr; }
  h1 { font-size: var(--am-fs-2xl); }
  h2 { font-size: var(--am-fs-xl); }
  .am-shell__main { padding: var(--am-sp-4); }
}
