/* ==========================================================================
   Sistema de Control y Cuadre de Agua — sistema de diseño
   Base: Bootstrap 5.3 (sobrescrito via variables). Mobile-first.
   ========================================================================== */

:root {
  /* Estructura (tinta) */
  --ink-950: #070d1a;
  --ink-900: #0b1324;
  --ink-800: #121c33;
  --ink-700: #1c2945;
  --ink-500: #64748b;
  --ink-300: #cbd2dd;

  /* Marca: verde petroleo */
  --color-primario: #0f766e;
  --color-primario-fuerte: #115e59;
  --color-primario-suave: #e3f2ef;
  --color-acento: #2dd4bf;

  /* Superficies y texto */
  --color-fondo: #f3f5f8;
  --color-superficie: #ffffff;
  --color-borde: #e4e8ee;
  --color-texto: #0f172a;
  --color-texto-suave: #64748b;

  /* Estados */
  --color-exito: #15803d;
  --color-exito-suave: #e7f6ec;
  --color-advertencia: #b45309;
  --color-advertencia-suave: #fdf1e1;
  --color-peligro: #b91c1c;
  --color-peligro-suave: #fbe9e9;
  --color-info: #1d4ed8;
  --color-info-suave: #e8eefc;

  --radio: 16px;
  --radio-sm: 12px;
  --sombra-sm: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --sombra: 0 4px 6px -2px rgba(15, 23, 42, .05), 0 12px 24px -8px rgba(15, 23, 42, .12);
  --sidebar-ancho: 264px;
  --bottomnav-alto: 68px;
  --topbar-alto: 60px;

  /* Bootstrap */
  --bs-body-font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bs-body-bg: var(--color-fondo);
  --bs-body-color: var(--color-texto);
  --bs-primary: #0f766e;
  --bs-primary-rgb: 15, 118, 110;
  --bs-success: #15803d;
  --bs-success-rgb: 21, 128, 61;
  --bs-danger: #b91c1c;
  --bs-danger-rgb: 185, 28, 28;
  --bs-warning-rgb: 180, 83, 9;
  --bs-secondary-color: #64748b;
  --bs-border-color: #e4e8ee;
  --bs-link-color: #0f766e;
  --bs-link-color-rgb: 15, 118, 110;
  --bs-link-hover-color: #115e59;
  --bs-link-hover-color-rgb: 17, 94, 89;
  --bs-border-radius: 12px;
  --bs-border-radius-lg: 14px;
  --bs-focus-ring-color: rgba(15, 118, 110, .25);
}

* { -webkit-tap-highlight-color: transparent; }

body {
  background: var(--color-fondo);
  color: var(--color-texto);
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
}

.text-muted, .text-body-secondary { color: var(--color-texto-suave) !important; }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .02em; }
h1, h2, h3, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 700; letter-spacing: -.01em; }

/* ==========================================================================
   Estructura: sidebar (PC), topbar + navegacion inferior (movil)
   ========================================================================== */

.app-main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-content {
  flex: 1;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem 1rem calc(var(--bottomnav-alto) + 1.5rem + env(safe-area-inset-bottom));
}

/* Topbar movil */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1030;
  height: var(--topbar-alto);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: 0 1rem;
  background: var(--ink-900);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04), 0 6px 18px -10px rgba(0, 0, 0, .5);
}

.brand {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: #fff;
  text-decoration: none;
  min-width: 0;
}
.brand:hover { color: #fff; }
.brand-mark {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 1.1rem;
  color: #fff;
  background: linear-gradient(145deg, #14b8a6, var(--color-primario-fuerte));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 6px 14px -6px rgba(20, 184, 166, .6);
}
.brand-text { line-height: 1.1; min-width: 0; }
.brand-text strong { display: block; font-size: .98rem; font-weight: 700; white-space: nowrap; }
.brand-text small { display: block; font-size: .72rem; color: rgba(255, 255, 255, .55); white-space: nowrap; }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .85rem;
  color: var(--ink-900);
  background: linear-gradient(145deg, #99f6e4, #5eead4);
  border: 2px solid rgba(255, 255, 255, .15);
  flex: 0 0 auto;
}

.topbar .btn-icon {
  color: #fff;
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .1);
}

/* Sidebar PC */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-ancho);
  z-index: 1030;
  flex-direction: column;
  background:
    radial-gradient(120% 50% at 0% 0%, rgba(45, 212, 191, .10), transparent 60%),
    var(--ink-900);
  color: rgba(255, 255, 255, .75);
  padding: 1.25rem .9rem;
  overflow-y: auto;
}
.sidebar .brand { padding: .25rem .5rem 1.25rem; }
.sidebar-label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255, 255, 255, .35);
  padding: 1rem .75rem .4rem;
  font-weight: 600;
}
.side-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .62rem .75rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, .7);
  text-decoration: none;
  font-weight: 500;
  font-size: .93rem;
  transition: background .15s ease, color .15s ease;
}
.side-link i { font-size: 1.1rem; width: 1.25rem; text-align: center; }
.side-link:hover { color: #fff; background: rgba(255, 255, 255, .05); }
.side-link.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(45, 212, 191, .18), rgba(45, 212, 191, .04));
  box-shadow: inset 3px 0 0 var(--color-acento);
}
.side-link.active i { color: var(--color-acento); }
.sidebar-user {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .8rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-user .info { min-width: 0; flex: 1; line-height: 1.2; }
.sidebar-user .info strong { display: block; color: #fff; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user .info small { color: rgba(255, 255, 255, .45); font-size: .75rem; text-transform: capitalize; }
.sidebar-user .btn { min-height: 36px; width: 36px; padding: 0; color: rgba(255, 255, 255, .7); border: 1px solid rgba(255, 255, 255, .12); }
.sidebar-user .btn:hover { color: #fff; background: rgba(255, 255, 255, .08); }

@media (min-width: 992px) {
  .app-main { margin-left: var(--sidebar-ancho); }
  .app-content { padding: 2rem 2rem 3rem; }
}

/* Navegacion inferior movil */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  height: calc(var(--bottomnav-alto) + env(safe-area-inset-bottom));
  padding: 0 .5rem env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--color-borde);
  box-shadow: 0 -8px 24px -16px rgba(15, 23, 42, .25);
}
.bottom-nav a, .bottom-nav button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  color: var(--ink-500);
  text-decoration: none;
  font-size: .68rem;
  font-weight: 600;
  background: none;
  border: 0;
  padding: 0;
}
.bottom-nav i { font-size: 1.3rem; line-height: 1; }
.bottom-nav .active { color: var(--color-primario); }
.bottom-nav .nav-fab {
  margin-top: -26px;
  height: auto;
}
.bottom-nav .nav-fab span.fab {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 1.5rem;
  background: linear-gradient(145deg, #14b8a6, var(--color-primario-fuerte));
  box-shadow: 0 10px 20px -6px rgba(15, 118, 110, .6), 0 0 0 4px var(--color-fondo);
}
.bottom-nav .nav-fab.active span.fab { background: linear-gradient(145deg, #0d9488, var(--ink-800)); }

/* Menu "Mas" (offcanvas inferior) */
.offcanvas-bottom.menu-mas {
  height: auto;
  max-height: 85vh;
  border-radius: 24px 24px 0 0;
  border: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.sheet-handle {
  width: 42px;
  height: 5px;
  border-radius: 3px;
  background: var(--ink-300);
  margin: .6rem auto 0;
}
.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .6rem;
}
.menu-grid a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: .9rem .4rem;
  border-radius: 14px;
  background: var(--color-fondo);
  color: var(--color-texto);
  text-decoration: none;
  font-size: .8rem;
  font-weight: 600;
  text-align: center;
}
.menu-grid a i {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  background: var(--color-superficie);
  color: var(--color-primario);
  box-shadow: var(--sombra-sm);
}
.menu-grid a.active { background: var(--color-primario-suave); color: var(--color-primario-fuerte); }

/* ==========================================================================
   Encabezado de pagina
   ========================================================================== */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-header h1 {
  font-size: 1.45rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: .55rem;
}
.page-header p { margin: .2rem 0 0; color: var(--color-texto-suave); font-size: .9rem; }
.page-header .acciones { display: flex; gap: .5rem; flex-wrap: wrap; }
@media (min-width: 992px) {
  .page-header h1 { font-size: 1.75rem; }
}

.eyebrow {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--color-primario);
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 1.75rem 0 .8rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .5rem;
}
.section-title.con-accion { justify-content: space-between; }
.section-title .count {
  font-size: .75rem;
  font-weight: 700;
  color: var(--color-texto-suave);
  background: var(--color-superficie);
  border: 1px solid var(--color-borde);
  border-radius: 999px;
  padding: .1rem .55rem;
  margin-left: .4rem;
}

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  --bs-card-border-color: var(--color-borde);
  --bs-card-border-radius: var(--radio);
  --bs-card-inner-border-radius: calc(var(--radio) - 1px);
  --bs-card-bg: var(--color-superficie);
  box-shadow: var(--sombra-sm);
}
.card.shadow-sm { box-shadow: var(--sombra-sm) !important; }
.card-body { padding: 1.15rem; }
@media (min-width: 768px) { .card-body { padding: 1.5rem; } }

.card-title-sm {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* Hero oscuro (dashboard, registro) */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 1.25rem;
  color: #fff;
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(45, 212, 191, .28), transparent 55%),
    radial-gradient(70% 90% at 0% 100%, rgba(15, 118, 110, .45), transparent 60%),
    var(--ink-900);
  box-shadow: var(--sombra);
}
.hero::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -60px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .06);
  box-shadow: 0 0 0 30px rgba(255, 255, 255, .02), 0 0 0 60px rgba(255, 255, 255, .015);
  pointer-events: none;
}
.hero .hero-label { color: rgba(255, 255, 255, .6); font-size: .8rem; font-weight: 500; }
.hero .hero-valor { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.hero .hero-sub { color: rgba(255, 255, 255, .7); font-size: .85rem; }
.hero .chip-estado {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  background: rgba(45, 212, 191, .15);
  color: #5eead4;
  border: 1px solid rgba(45, 212, 191, .3);
}
.hero .chip-estado .dot { width: 7px; height: 7px; border-radius: 50%; background: #2dd4bf; box-shadow: 0 0 0 3px rgba(45, 212, 191, .25); }
.hero .btn-hero {
  color: #fff;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .15);
}
.hero .btn-hero:hover { background: rgba(255, 255, 255, .15); color: #fff; }
@media (min-width: 768px) {
  .hero { padding: 1.75rem; }
  .hero .hero-valor { font-size: 2.4rem; }
}

/* Indicadores (stat cards) */
.stat {
  height: 100%;
  background: var(--color-superficie);
  border: 1px solid var(--color-borde);
  border-radius: var(--radio);
  padding: .9rem 1rem;
  box-shadow: var(--sombra-sm);
  display: flex;
  flex-direction: column;
  gap: .35rem;
}
.stat .stat-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.stat .stat-label { font-size: .76rem; font-weight: 600; color: var(--color-texto-suave); }
.stat .stat-valor { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .stat-sub { font-size: .75rem; color: var(--color-texto-suave); }
.ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  flex: 0 0 auto;
  background: var(--color-primario-suave);
  color: var(--color-primario);
}
.ico-exito { background: var(--color-exito-suave); color: var(--color-exito); }
.ico-advertencia { background: var(--color-advertencia-suave); color: var(--color-advertencia); }
.ico-peligro { background: var(--color-peligro-suave); color: var(--color-peligro); }
.ico-info { background: var(--color-info-suave); color: var(--color-info); }
.ico-ink { background: #eef1f6; color: var(--ink-700); }
.ico-lg { width: 46px; height: 46px; border-radius: 14px; font-size: 1.3rem; }

/* Fila de indicadores con scroll horizontal en movil */
.stats-scroll {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(140px, 1fr);
  gap: .65rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 1rem;
  padding-bottom: .25rem;
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  scrollbar-width: none;
}
.stats-scroll::-webkit-scrollbar { display: none; }
.stats-scroll > * { scroll-snap-align: start; }
@media (min-width: 992px) {
  .stats-scroll { margin: 0; padding-left: 0; padding-right: 0; grid-auto-flow: row; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* Tarjetas de acceso / items navegables */
.card-acceso {
  display: block;
  height: 100%;
  background: var(--color-superficie);
  border: 1px solid var(--color-borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra-sm);
  color: inherit;
  text-decoration: none;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.card-acceso:hover {
  color: inherit;
  transform: translateY(-2px);
  box-shadow: var(--sombra);
  border-color: #d3dae4;
}
.card-acceso:active { transform: scale(.985); }

.acceso-rapido {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}
.acceso-rapido .titulo { font-weight: 700; font-size: .92rem; }
.acceso-rapido .desc { font-size: .78rem; color: var(--color-texto-suave); margin-top: -.45rem; }

/* Lista tipo iOS (items en una sola card) */
.lista {
  background: var(--color-superficie);
  border: 1px solid var(--color-borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra-sm);
  overflow: hidden;
}
.lista-item {
  display: flex;
  align-items: center;
  gap: .85rem;
  padding: .85rem 1rem;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid var(--color-borde);
  transition: background .12s ease;
}
.lista-item:last-child { border-bottom: 0; }
a.lista-item:hover { background: #f8fafc; color: inherit; }
.lista-item .cuerpo { flex: 1; min-width: 0; }
.lista-item .titulo { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista-item .sub { font-size: .8rem; color: var(--color-texto-suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista-item .chev { color: var(--ink-300); }
.iniciales {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .85rem;
  flex: 0 0 auto;
  background: var(--color-primario-suave);
  color: var(--color-primario-fuerte);
}

/* Estado vacio */
.vacio {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--color-texto-suave);
  background: var(--color-superficie);
  border: 1px dashed #d3dae4;
  border-radius: var(--radio);
}
.vacio i { font-size: 2rem; color: var(--ink-300); display: block; margin-bottom: .5rem; }
.vacio strong { display: block; color: var(--color-texto); margin-bottom: .2rem; }

/* ==========================================================================
   Botones
   ========================================================================== */

.btn {
  min-height: 44px;
  font-weight: 600;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  --bs-btn-focus-box-shadow: 0 0 0 .25rem rgba(15, 118, 110, .25);
}
.btn-sm { min-height: 36px; border-radius: 10px; font-size: .85rem; }
.btn-lg { min-height: 54px; border-radius: 14px; font-size: 1.05rem; }

.btn-primary {
  --bs-btn-bg: var(--color-primario);
  --bs-btn-border-color: var(--color-primario);
  --bs-btn-hover-bg: var(--color-primario-fuerte);
  --bs-btn-hover-border-color: var(--color-primario-fuerte);
  --bs-btn-active-bg: #134e4a;
  --bs-btn-active-border-color: #134e4a;
  --bs-btn-disabled-bg: var(--color-primario);
  --bs-btn-disabled-border-color: var(--color-primario);
  box-shadow: 0 6px 14px -8px rgba(15, 118, 110, .8);
}
.btn-dark {
  --bs-btn-bg: var(--ink-900);
  --bs-btn-border-color: var(--ink-900);
  --bs-btn-hover-bg: var(--ink-700);
  --bs-btn-hover-border-color: var(--ink-700);
}
.btn-outline-primary {
  --bs-btn-color: var(--color-primario);
  --bs-btn-border-color: #b7dcd5;
  --bs-btn-hover-bg: var(--color-primario);
  --bs-btn-hover-border-color: var(--color-primario);
  --bs-btn-active-bg: var(--color-primario-fuerte);
  --bs-btn-active-border-color: var(--color-primario-fuerte);
}
.btn-light {
  --bs-btn-bg: var(--color-superficie);
  --bs-btn-border-color: var(--color-borde);
  --bs-btn-hover-bg: #f1f4f8;
  --bs-btn-hover-border-color: #d7dde6;
  --bs-btn-color: var(--color-texto);
}
.btn-success {
  --bs-btn-bg: var(--color-exito);
  --bs-btn-border-color: var(--color-exito);
  --bs-btn-hover-bg: #166534;
  --bs-btn-hover-border-color: #166534;
}
.btn-danger {
  --bs-btn-bg: var(--color-peligro);
  --bs-btn-border-color: var(--color-peligro);
  --bs-btn-hover-bg: #991b1b;
  --bs-btn-hover-border-color: #991b1b;
}
.btn-outline-danger {
  --bs-btn-color: var(--color-peligro);
  --bs-btn-border-color: #f1c4c4;
  --bs-btn-hover-bg: var(--color-peligro);
  --bs-btn-hover-border-color: var(--color-peligro);
}
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }

/* Selector segmentado (btn-check) */
.segmentado {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  background: #eef1f5;
  border-radius: 14px;
}
.segmentado .btn {
  border: 0;
  min-height: 42px;
  border-radius: 10px;
  color: var(--color-texto-suave);
  background: transparent;
  font-size: .88rem;
  box-shadow: none;
}
.segmentado .btn-check:checked + .btn {
  background: var(--color-superficie);
  color: var(--color-texto);
  box-shadow: var(--sombra-sm);
}
.segmentado .btn-check:checked + .btn.seg-exito { color: var(--color-exito); }
.segmentado .btn-check:checked + .btn.seg-peligro { color: var(--color-peligro); }
.segmentado .btn-check:checked + .btn.seg-advertencia { color: var(--color-advertencia); }

/* Chips de seleccion rapida (cilindros) */
.chips-rapidos { display: flex; gap: .45rem; flex-wrap: wrap; }
.chips-rapidos button {
  min-height: 38px;
  min-width: 48px;
  padding: 0 .8rem;
  border-radius: 999px;
  border: 1px solid var(--color-borde);
  background: var(--color-superficie);
  font-weight: 700;
  font-size: .88rem;
  color: var(--color-texto);
  transition: all .12s ease;
}
.chips-rapidos button:hover { border-color: #b7dcd5; }
.chips-rapidos button.activo { background: var(--color-primario); border-color: var(--color-primario); color: #fff; }

/* ==========================================================================
   Formularios
   ========================================================================== */

.form-label {
  font-size: .82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: .4rem;
}
.form-control, .form-select {
  min-height: 48px;
  font-size: 16px; /* evita zoom automatico en iOS */
  border-radius: 12px;
  border-color: #d9dfe7;
  background-color: #fbfcfd;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
textarea.form-control { min-height: 80px; }
.form-control:focus, .form-select:focus {
  border-color: var(--color-primario);
  background-color: #fff;
  box-shadow: 0 0 0 4px rgba(15, 118, 110, .12);
}
.form-control-lg, .form-select-lg { min-height: 54px; font-size: 1.1rem; border-radius: 14px; }
.form-control-sm, .form-select-sm { min-height: 42px; font-size: 16px; }
.form-text { font-size: .8rem; color: var(--color-texto-suave); }
.form-check-input { width: 1.25em; height: 1.25em; margin-top: .15em; border-color: #c4ccd8; }
.form-check-input:checked { background-color: var(--color-primario); border-color: var(--color-primario); }
.form-check-input:focus { box-shadow: 0 0 0 4px rgba(15, 118, 110, .15); border-color: var(--color-primario); }
.form-switch .form-check-input { width: 2.4em; }
.input-group-text { background: #f1f4f8; border-color: #d9dfe7; border-radius: 12px; color: var(--color-texto-suave); }

input[inputmode="numeric"] {
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
  font-weight: 600;
}

/* Buscador con icono */
.buscador { position: relative; }
.buscador > i {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-texto-suave);
  pointer-events: none;
}
.buscador .form-control { padding-left: 2.6rem; }

/* Opcion tipo tarjeta (checkbox grande) */
.opcion-check {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  border: 1px solid var(--color-borde);
  border-radius: 14px;
  background: #fbfcfd;
  cursor: pointer;
  margin: 0;
}
.opcion-check .form-check-input { margin: .1rem 0 0; flex: 0 0 auto; float: none; }
.opcion-check:has(.form-check-input:checked) { border-color: #9fd3c9; background: var(--color-primario-suave); }
.opcion-check .texto { font-size: .9rem; font-weight: 500; line-height: 1.35; }

/* Barra de accion fija en movil */
.barra-accion {
  position: sticky;
  bottom: calc(var(--bottomnav-alto) + env(safe-area-inset-bottom) + .5rem);
  z-index: 20;
  margin-top: 1rem;
}
.barra-accion .btn { width: 100%; box-shadow: 0 12px 24px -10px rgba(15, 118, 110, .7); }
@media (min-width: 992px) {
  .barra-accion { position: static; }
}

/* ==========================================================================
   Badges de estado: siempre icono + texto
   ========================================================================== */

.badge {
  font-weight: 700;
  font-size: .72rem;
  padding: .38em .7em;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: .3em;
  letter-spacing: .01em;
}
.badge-pagado { background: var(--color-exito-suave); color: var(--color-exito); }
.badge-pendiente { background: var(--color-advertencia-suave); color: var(--color-advertencia); }
.badge-deuda { background: var(--color-peligro-suave); color: var(--color-peligro); }
.badge-neutro { background: #eef1f5; color: #475569; }
.badge-info { background: var(--color-info-suave); color: var(--color-info); }

/* ==========================================================================
   Alertas
   ========================================================================== */

.alert {
  border-radius: 14px;
  border: 1px solid transparent;
  font-size: .9rem;
  display: flex;
  gap: .65rem;
  align-items: flex-start;
}
.alert > i:first-child { font-size: 1.1rem; line-height: 1.3; }
.alert-success { background: var(--color-exito-suave); color: #14532d; border-color: #c9ead4; }
.alert-warning { background: var(--color-advertencia-suave); color: #78350f; border-color: #f5dcb8; }
.alert-danger { background: var(--color-peligro-suave); color: #7f1d1d; border-color: #f2c9c9; }
.alert-info { background: var(--color-info-suave); color: #1e3a8a; border-color: #cfdaf7; }
.alert .alert-link { color: inherit; }

/* ==========================================================================
   Tablas (en movil se transforman en tarjetas apiladas)
   ========================================================================== */

.tabla-wrap {
  background: var(--color-superficie);
  border: 1px solid var(--color-borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra-sm);
  overflow: hidden;
}
.table {
  --bs-table-bg: transparent;
  margin: 0;
  font-size: .9rem;
}
.table > thead th {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-texto-suave);
  background: #f8fafc;
  border-bottom: 1px solid var(--color-borde);
  padding: .8rem 1rem;
  white-space: nowrap;
}
.table > tbody td { padding: .8rem 1rem; border-color: #eef1f5; vertical-align: middle; }
.table > tbody tr:last-child td { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f8fafc; }

@media (max-width: 767.98px) {
  .tabla-wrap.tabla-cards { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .tabla-responsive-cards thead { display: none; }
  .tabla-responsive-cards, .tabla-responsive-cards tbody { display: block; }
  .tabla-responsive-cards tbody tr {
    display: block;
    margin-bottom: .65rem;
    border: 1px solid var(--color-borde);
    border-radius: var(--radio);
    padding: .65rem 1rem;
    background: var(--color-superficie);
    box-shadow: var(--sombra-sm);
  }
  .tabla-responsive-cards tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: .75rem;
    border: none;
    padding: .38rem 0;
    text-align: right;
  }
  .tabla-responsive-cards tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: .8rem;
    color: var(--color-texto-suave);
    text-align: left;
  }
  .tabla-responsive-cards tbody td[data-label=""]::before { content: none; }
  .tabla-responsive-cards tbody td[data-label=""] { justify-content: flex-end; }
  .tabla-responsive-cards tbody td.td-titulo {
    font-weight: 700;
    font-size: 1rem;
    border-bottom: 1px solid #eef1f5;
    padding-bottom: .55rem;
    margin-bottom: .2rem;
    justify-content: flex-start;
    text-align: left;
  }
  .tabla-responsive-cards tbody td.td-titulo::before { content: none; }
  .tabla-responsive-cards tbody tr.fila-vacia { text-align: center; }
  .tabla-responsive-cards tbody tr.fila-vacia td { justify-content: center; }
  .tabla-responsive-cards tbody tr.fila-vacia td::before { content: none; }
}

/* ==========================================================================
   Navegacion por pestanas (pills)
   ========================================================================== */

.tabs-pill {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #e9edf2;
  border-radius: 14px;
  border: 0;
  margin-bottom: 1rem;
  max-width: 100%;
  overflow-x: auto;
}
.tabs-pill .nav-link {
  border: 0;
  border-radius: 10px;
  color: var(--color-texto-suave);
  font-weight: 600;
  font-size: .88rem;
  padding: .55rem 1rem;
  white-space: nowrap;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.tabs-pill .nav-link.active { background: var(--color-superficie); color: var(--color-texto); box-shadow: var(--sombra-sm); }
.tabs-pill .nav-link .count { font-size: .72rem; background: var(--color-peligro-suave); color: var(--color-peligro); border-radius: 999px; padding: .05rem .45rem; }

/* ==========================================================================
   Modales: hoja inferior en movil
   ========================================================================== */

.modal-content {
  border: 0;
  border-radius: 22px;
  box-shadow: 0 30px 60px -20px rgba(15, 23, 42, .45);
}
.modal-header { border-bottom: 0; padding: 1.25rem 1.25rem .5rem; }
.modal-title { font-weight: 700; font-size: 1.1rem; }
.modal-body { padding: .5rem 1.25rem 1rem; }
.modal-footer { border-top: 0; padding: .5rem 1.25rem 1.25rem; gap: .5rem; flex-wrap: nowrap; }
.modal-footer > .btn { flex: 1; margin: 0; }
.modal-backdrop.show { opacity: .55; }

@media (max-width: 575.98px) {
  .modal-sheet { margin: 0; min-height: 100%; display: flex; align-items: flex-end; max-width: none; }
  .modal-sheet .modal-content { border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom); max-height: 92vh; overflow-y: auto; }
  .modal.fade .modal-sheet { transform: translateY(40px); }
  .modal.show .modal-sheet { transform: none; }
}

/* Lista de resumen (clave / valor) */
.resumen { list-style: none; margin: 0; padding: 0; }
.resumen li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: .6rem 0;
  border-bottom: 1px dashed var(--color-borde);
  font-size: .92rem;
}
.resumen li:last-child { border-bottom: 0; }
.resumen li span:first-child { color: var(--color-texto-suave); }
.resumen li span:last-child { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.resumen-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  margin-top: .75rem;
  border-radius: 14px;
  background: var(--ink-900);
  color: #fff;
}
.resumen-total .monto { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.resultado-pill {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem .9rem;
  border-radius: 12px;
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: .75rem;
}

/* ==========================================================================
   Toasts
   ========================================================================== */

.toast-container { z-index: 1090; }
.toast-app {
  border: 0;
  border-radius: 14px;
  background: var(--ink-900);
  color: #fff;
  box-shadow: 0 18px 40px -12px rgba(7, 13, 26, .55);
  overflow: hidden;
}
.toast-app .toast-body { display: flex; gap: .7rem; align-items: flex-start; padding: .9rem 1rem; font-size: .9rem; font-weight: 500; }
.toast-app .toast-body i { font-size: 1.15rem; line-height: 1.2; }
.toast-app.t-success .toast-body i { color: #4ade80; }
.toast-app.t-danger .toast-body i { color: #f87171; }
.toast-app.t-warning .toast-body i { color: #fbbf24; }
.toast-app.t-info .toast-body i, .toast-app.t-primary .toast-body i { color: #5eead4; }
.toast-app .btn-close { filter: invert(1); opacity: .6; }
@media (max-width: 575.98px) {
  .toast-container { left: 0; right: 0; width: 100%; padding: .75rem !important; top: calc(var(--topbar-alto) - .25rem) !important; }
  .toast-container .toast { width: 100%; }
}

/* ==========================================================================
   Login
   ========================================================================== */

.login-body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
  color: #fff;
  background:
    radial-gradient(60% 50% at 85% 10%, rgba(45, 212, 191, .22), transparent 60%),
    radial-gradient(50% 50% at 10% 90%, rgba(15, 118, 110, .35), transparent 60%),
    var(--ink-950);
}
.login-wrap { width: 100%; max-width: 420px; }
.login-brand { text-align: center; margin-bottom: 1.75rem; }
.login-brand .brand-mark { width: 64px; height: 64px; border-radius: 20px; font-size: 1.9rem; margin: 0 auto 1rem; }
.login-brand h1 { font-size: 1.4rem; font-weight: 800; margin: 0; }
.login-brand p { color: rgba(255, 255, 255, .55); margin: .35rem 0 0; font-size: .9rem; }
.login-card {
  background: var(--color-superficie);
  color: var(--color-texto);
  border-radius: 24px;
  padding: 1.75rem 1.5rem;
  box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .6);
}
.login-card h2 { font-size: 1.15rem; margin-bottom: .25rem; }
.login-foot { text-align: center; color: rgba(255, 255, 255, .35); font-size: .78rem; margin-top: 1.5rem; }
.input-icono { position: relative; }
.input-icono > i { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); color: var(--color-texto-suave); pointer-events: none; }
.input-icono .form-control { padding-left: 2.75rem; }
.input-icono .toggle-pass { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); min-height: 40px; width: 40px; border: 0; background: none; color: var(--color-texto-suave); }

/* ==========================================================================
   Pantalla de registro de agua
   ========================================================================== */

.lectura-actual-sticky {
  position: sticky;
  top: calc(var(--topbar-alto) + .5rem);
  z-index: 15;
}
@media (min-width: 992px) {
  .lectura-actual-sticky { top: 1rem; }
}
.lectura-display {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-weight: 700;
  letter-spacing: .06em;
}

/* Animacion de carga en botones */
.btn .spinner-border { width: 1rem; height: 1rem; border-width: .15em; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

.min-w-0 { min-width: 0; }
@media (max-width: 575.98px) {
  .stat { padding: .75rem .8rem; }
  .stat .stat-valor { font-size: 1.1rem; overflow-wrap: anywhere; }
  .stat .ico { width: 30px; height: 30px; font-size: .9rem; }
}

/* ==========================================================================
   Aplicacion instalable (PWA)
   ========================================================================== */

.banner-instalar {
  position: fixed;
  left: .75rem;
  right: .75rem;
  bottom: calc(var(--bottomnav-alto) + env(safe-area-inset-bottom) + .75rem);
  z-index: 1040;
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem .85rem;
  border-radius: 18px;
  background: var(--ink-900);
  color: #fff;
  box-shadow: 0 20px 40px -14px rgba(7, 13, 26, .6);
  animation: subirBanner .35s ease-out;
}
.banner-instalar[hidden] { display: none; }
.banner-instalar img { border-radius: 12px; flex: 0 0 auto; }
.banner-instalar .texto { flex: 1; min-width: 0; line-height: 1.25; }
.banner-instalar .texto strong { display: block; font-size: .9rem; }
.banner-instalar .texto small { color: rgba(255, 255, 255, .6); font-size: .75rem; }
.banner-instalar .btn-close { filter: invert(1); opacity: .6; flex: 0 0 auto; }
@media (min-width: 992px) {
  .banner-instalar { left: auto; right: 1.5rem; bottom: 1.5rem; max-width: 400px; }
}
@keyframes subirBanner { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Abierta como app: respetar la barra de estado / notch del telefono */
.topbar {
  padding-top: env(safe-area-inset-top);
  height: calc(var(--topbar-alto) + env(safe-area-inset-top));
}
@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
  .lectura-actual-sticky { top: calc(var(--topbar-alto) + env(safe-area-inset-top) + .5rem); }
}

[hidden] { display: none !important; }

/* Lista de seleccion multiple (asignar vecinos a pileta) */
.lista-check { max-height: 360px; overflow-y: auto; }
.lista-check .lista-item { cursor: pointer; margin: 0; }
.lista-check .lista-item:hover { background: #f8fafc; }
.lista-check .lista-item:has(.form-check-input:checked) { background: var(--color-primario-suave); }
.titulo-sin-pileta { color: var(--color-advertencia); }
.iniciales.ico-advertencia { background: var(--color-advertencia-suave); color: var(--color-advertencia); }
.mt-n2 { margin-top: -.5rem !important; }
