/* ==========================================================
   Ríos de Agua Viva — Claymorphism + Glassmorphism
   ========================================================== */
@font-face {
  font-family: "Nunito";
  font-style: normal;
  font-weight: 500 900;
  font-display: swap;
  src: url("../fonts/nunito-latin.woff2") format("woff2");
}
:root, .tema-claro {
  --ink: #1f1d47;
  --ink-soft: #5b5a85;
  --ink-mute: #8c8bb0;

  --violet: #7c5cff;
  --violet-2: #a78bfa;
  --teal: #14b8a6;
  --teal-2: #5eead4;
  --sky: #38bdf8;
  --coral: #fb7185;
  --coral-2: #fda4af;
  --amber: #f59e0b;
  --amber-2: #fcd34d;
  --mint: #34d399;

  --glass: rgba(255, 255, 255, .55);
  --glass-strong: rgba(255, 255, 255, .72);
  --glass-border: rgba(255, 255, 255, .75);

  --clay-shadow:
    12px 12px 28px rgba(80, 70, 160, .18),
    -8px -8px 22px rgba(255, 255, 255, .85),
    inset 3px 3px 6px rgba(255, 255, 255, .7),
    inset -4px -4px 10px rgba(80, 70, 160, .10);
  --clay-inset:
    inset 4px 4px 10px rgba(80, 70, 160, .14),
    inset -4px -4px 10px rgba(255, 255, 255, .9);
  --glass-shadow: 0 12px 40px rgba(60, 50, 140, .14);
  --soft-shadow: 5px 5px 12px rgba(80, 70, 160, .14), -4px -4px 10px rgba(255, 255, 255, .9);
  --soft-shadow-sm: 3px 3px 8px rgba(80, 70, 160, .13), -2px -2px 6px rgba(255, 255, 255, .9);

  --bg: #f3f1fb;
  --bg-1: #e9e4ff;
  --bg-2: #d6f7f3;
  --bg-3: #ffe4e8;
  --bg-4: #e0f2fe;
  --blob-opacity: .55;

  --surface: #ffffff;
  --surface-2: #f1eefc;
  --clay-bg: linear-gradient(145deg, var(--surface), var(--surface-2));
  --receipt-bg: linear-gradient(160deg, #ffffff 0%, #f6f4ff 100%);
  --input-bg: rgba(255, 255, 255, .7);
  --input-bg-focus: #ffffff;
  --readonly-bg: rgba(237, 233, 254, .55);
  --hover-bg: rgba(255, 255, 255, .58);
  --row-alt: rgba(255, 255, 255, .35);
  --row-hover: rgba(255, 255, 255, .75);
  --track: #c7c5e0;

  --danger: #e11d48;
  --ok-ink: #047857;
  --warn-ink: #b45309;
  --bad-ink: #be123c;
  --info-ink: #0369a1;
  --alert-ok-bg: rgba(209, 250, 229, .75);
  --alert-ok-ink: #065f46;
  --alert-err-bg: rgba(255, 228, 230, .8);
  --alert-err-ink: #9f1239;

  --r-xl: 28px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;

  color-scheme: light;
}

/* ---------- Tema oscuro ----------
   El atributo data-tema-activo lo resuelve el script del <head> (claro / oscuro / sistema).
   Solo aplica en pantalla: al imprimir siempre se usa el tema claro. */
@media screen {
  :root[data-tema-activo="oscuro"] {
    color-scheme: dark;

    --ink: #eceaff;
    --ink-soft: #b9b6e0;
    --ink-mute: #8b88b8;
    --violet-2: #b6a1ff;

    --glass: rgba(30, 27, 58, .58);
    --glass-strong: rgba(34, 31, 64, .8);
    --glass-border: rgba(255, 255, 255, .09);

    --clay-shadow:
      12px 12px 28px rgba(0, 0, 0, .45),
      -6px -6px 18px rgba(130, 120, 255, .05),
      inset 2px 2px 5px rgba(255, 255, 255, .07),
      inset -4px -4px 10px rgba(0, 0, 0, .35);
    --clay-inset:
      inset 4px 4px 10px rgba(0, 0, 0, .45),
      inset -3px -3px 8px rgba(255, 255, 255, .04);
    --glass-shadow: 0 14px 44px rgba(0, 0, 0, .4);
    --soft-shadow: 5px 5px 12px rgba(0, 0, 0, .4), -3px -3px 8px rgba(130, 120, 255, .05), inset 1px 1px 2px rgba(255, 255, 255, .06);
    --soft-shadow-sm: 3px 3px 8px rgba(0, 0, 0, .38), -2px -2px 6px rgba(130, 120, 255, .05), inset 1px 1px 2px rgba(255, 255, 255, .06);

    --bg: #100f1f;
    --bg-1: #2a1f5c;
    --bg-2: #0b3b3b;
    --bg-3: #3d1530;
    --bg-4: #0c2a44;
    --blob-opacity: .22;

    --surface: #262345;
    --surface-2: #1d1b36;
    --receipt-bg: linear-gradient(160deg, #282548 0%, #1c1a34 100%);
    --input-bg: rgba(14, 13, 30, .55);
    --input-bg-focus: rgba(14, 13, 30, .8);
    --readonly-bg: rgba(124, 92, 255, .1);
    --hover-bg: rgba(255, 255, 255, .06);
    --row-alt: rgba(255, 255, 255, .025);
    --row-hover: rgba(255, 255, 255, .07);
    --track: #4a4770;

    --danger: #fb7185;
    --ok-ink: #6ee7b7;
    --warn-ink: #fcd34d;
    --bad-ink: #fda4af;
    --info-ink: #7dd3fc;
    --alert-ok-bg: rgba(6, 78, 59, .55);
    --alert-ok-ink: #a7f3d0;
    --alert-err-bg: rgba(136, 19, 55, .5);
    --alert-err-ink: #fecdd3;
  }
}

* { box-sizing: border-box; }

@view-transition { navigation: auto; }
.sidebar { view-transition-name: barra-lateral; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .18s; }
@media (prefers-reduced-motion: reduce) { @view-transition { navigation: none; } }
[hidden] { display: none !important; }

html, body { margin: 0; }

body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background: var(--bg);
  transition: background-color .3s ease, color .3s ease;
  -webkit-font-smoothing: antialiased;
}

/* Fondo y blobs decorativos.
   Rendimiento: el fondo vive en una capa fija que se pinta una sola vez; los blobs usan degradados
   radiales (se ven difuminados sin el costoso filter: blur) y solo se animan en computadoras. */
.blobs {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; contain: strict;
  background:
    radial-gradient(1200px 700px at 0% 0%, var(--bg-1) 0%, transparent 60%),
    radial-gradient(900px 600px at 100% 0%, var(--bg-2) 0%, transparent 55%),
    radial-gradient(900px 700px at 100% 100%, var(--bg-3) 0%, transparent 55%),
    radial-gradient(800px 600px at 0% 100%, var(--bg-4) 0%, transparent 55%),
    var(--bg);
}
.blob { position: absolute; border-radius: 50%; opacity: var(--blob-opacity); background: radial-gradient(closest-side, var(--bc), transparent); }
.blob.b1 { --bc: var(--violet-2); width: 560px; height: 560px; top: -190px; left: 14%; }
.blob.b2 { --bc: var(--teal-2); width: 480px; height: 480px; bottom: -160px; right: 5%; animation-delay: -6s; }
.blob.b3 { --bc: var(--coral-2); width: 420px; height: 420px; top: 36%; left: -140px; animation-delay: -12s; }
.blob.b4 { --bc: var(--amber-2); width: 360px; height: 360px; top: 8%; right: -110px; opacity: calc(var(--blob-opacity) * .65); animation-delay: -3s; }
@keyframes flotar {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(30px, -25px, 0) scale(1.06); }
}
@media (min-width: 961px) and (hover: hover) and (prefers-reduced-motion: no-preference) {
  .blob { animation: flotar 18s ease-in-out infinite; will-change: transform; }
}

a { color: var(--violet); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 800; letter-spacing: -.01em; }

/* ---------- Layout ---------- */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; top: 16px; bottom: 16px; left: 16px; width: 256px;
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px 16px;
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(160%);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: var(--glass-shadow);
  z-index: 40;
  transition: transform .3s ease;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 12px; }
.brand-logo {
  width: 48px; height: 48px; flex: none; border-radius: 16px;
  display: grid; place-items: center; color: #fff; font-size: 24px;
  background: linear-gradient(145deg, var(--teal), var(--sky) 55%, var(--violet));
  box-shadow: 6px 6px 14px rgba(20, 184, 166, .35), inset 2px 2px 5px rgba(255,255,255,.5), inset -3px -3px 6px rgba(0,0,0,.12);
}
.brand-img {
  width: 52px; height: 52px; flex: none; border-radius: 16px; object-fit: cover; display: block;
  box-shadow: 5px 6px 14px rgba(30, 40, 120, .3), inset 0 0 0 1px rgba(255,255,255,.4);
}
.brand-img.hero-logo { width: 96px; height: 96px; border-radius: 24px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25), 0 0 0 3px rgba(255,255,255,.35); }
.brand-name { font-weight: 900; font-size: 17px; line-height: 1.1; }
.brand-sub { font-size: 12px; color: var(--ink-mute); font-weight: 700; }

.nav-label { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-mute); padding: 10px 12px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; border-radius: var(--r-md);
  color: var(--ink-soft); font-weight: 700; font-size: 15px;
  transition: background .2s, color .2s, transform .2s, box-shadow .2s;
}
.nav-link i { font-size: 18px; width: 22px; text-align: center; }
.nav-link:hover { background: var(--hover-bg); color: var(--ink); transform: translateX(2px); }
.nav-link.active {
  color: #fff;
  background: linear-gradient(145deg, var(--violet), #6366f1);
  box-shadow: 6px 8px 18px rgba(124, 92, 255, .38), inset 2px 2px 5px rgba(255,255,255,.35), inset -3px -3px 7px rgba(30, 20, 120, .25);
}
.sidebar-footer { margin-top: auto; padding-top: 16px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border-radius: var(--r-md); background: var(--hover-bg);
  box-shadow: var(--clay-inset);
}
.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  display: grid; place-items: center; color: #fff; font-weight: 900;
  background: linear-gradient(145deg, var(--coral), var(--amber));
  box-shadow: 3px 3px 8px rgba(251,113,133,.35), inset 2px 2px 4px rgba(255,255,255,.4);
}
.user-chip .info { min-width: 0; flex: 1; }
.user-chip .name { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .mail { font-size: 11px; color: var(--ink-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  border: 0; cursor: pointer; width: 36px; height: 36px; border-radius: 12px;
  display: grid; place-items: center; color: var(--coral); font-size: 17px;
  background: var(--surface); box-shadow: var(--soft-shadow-sm);
}
.icon-btn:hover { color: var(--danger); }

.main { flex: 1; margin-left: 288px; padding: 24px 28px 40px 0; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.topbar h1 { font-size: 28px; }
.topbar .subtitle { color: var(--ink-soft); font-weight: 600; margin-top: 4px; }
.menu-toggle { display: none; }

/* ---------- Superficies ---------- */
.card {
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-xl);
  box-shadow: var(--glass-shadow);
  padding: 24px;
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-title { font-size: 18px; font-weight: 900; display: flex; align-items: center; gap: 10px; }
.card-title i { color: var(--violet); }
.card-sub { color: var(--ink-mute); font-size: 13px; font-weight: 700; }

.clay {
  background: var(--clay-bg);
  border-radius: var(--r-xl);
  box-shadow: var(--clay-shadow);
}

.grid { display: grid; gap: 22px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.grid-pago { grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); align-items: start; }
.mt { margin-top: 22px; }
.span-2 { grid-column: span 2; }

/* ---------- Estadísticas (clay) ---------- */
.stat {
  position: relative; padding: 22px; border-radius: var(--r-xl);
  background: var(--clay-bg);
  box-shadow: var(--clay-shadow);
  overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; width: 140px; height: 140px; border-radius: 50%;
  right: -50px; top: -50px; opacity: .14; background: var(--c1, var(--violet));
}
.stat-icon {
  width: 52px; height: 52px; border-radius: 18px; display: grid; place-items: center;
  font-size: 23px; color: #fff; margin-bottom: 16px;
  background: linear-gradient(145deg, var(--c1, var(--violet)), var(--c2, #6366f1));
  box-shadow: 5px 6px 14px color-mix(in srgb, var(--c1, var(--violet)) 40%, transparent),
              inset 2px 2px 5px rgba(255,255,255,.45), inset -3px -3px 6px rgba(0,0,0,.12);
}
.stat-label { color: var(--ink-soft); font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 28px; font-weight: 900; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat-foot { margin-top: 8px; font-size: 13px; color: var(--ink-mute); font-weight: 700; }
.c-violet { --c1: #7c5cff; --c2: #6366f1; }
.c-teal { --c1: #14b8a6; --c2: #0ea5e9; }
.c-coral { --c1: #fb7185; --c2: #f43f5e; }
.c-amber { --c1: #f59e0b; --c2: #f97316; }
.c-mint { --c1: #34d399; --c2: #10b981; }
.c-sky { --c1: #38bdf8; --c2: #6366f1; }

.progress { height: 12px; border-radius: 99px; background: rgba(124, 92, 255, .1); box-shadow: var(--clay-inset); overflow: hidden; margin-top: 12px; }
.progress > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--teal), var(--sky), var(--violet)); }

/* ---------- Botones ---------- */
.btn {
  --b1: var(--violet); --b2: #6366f1;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; cursor: pointer; font: inherit; font-weight: 800; font-size: 15px;
  padding: 12px 20px; border-radius: var(--r-md); color: #fff; white-space: nowrap;
  background: linear-gradient(145deg, var(--b1), var(--b2));
  box-shadow: 6px 8px 18px color-mix(in srgb, var(--b1) 38%, transparent),
              inset 2px 2px 5px rgba(255,255,255,.35), inset -3px -3px 7px rgba(0,0,0,.14);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s;
}
.btn:hover { transform: translateY(-2px); filter: brightness(1.05); }
.btn:active { transform: translateY(1px); box-shadow: inset 3px 3px 8px rgba(0,0,0,.18); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-teal { --b1: #14b8a6; --b2: #0ea5e9; }
.btn-coral { --b1: #fb7185; --b2: #f43f5e; }
.btn-amber { --b1: #f59e0b; --b2: #f97316; }
.btn-light {
  color: var(--ink); background: var(--clay-bg);
  box-shadow: var(--soft-shadow);
}
.btn-sm { padding: 8px 13px; font-size: 13px; border-radius: var(--r-sm); }
.btn-lg { padding: 15px 26px; font-size: 16px; }
.btn-block { width: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Formularios (clay inset) ---------- */
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field label, .label { font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.input, .select, textarea.input {
  width: 100%; font: inherit; font-weight: 700; color: var(--ink);
  padding: 12px 15px; border-radius: var(--r-md); border: 1px solid transparent;
  background: var(--input-bg);
  box-shadow: var(--clay-inset);
  outline: none; transition: border-color .2s, box-shadow .2s, background .2s;
}
.input:focus, .select:focus { border-color: var(--violet-2); background: var(--input-bg-focus); box-shadow: var(--clay-inset), 0 0 0 4px rgba(124,92,255,.15); }
.input[readonly] { background: var(--readonly-bg); color: var(--ink-soft); cursor: default; }
.select { appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16' fill='%237c5cff'%3E%3Cpath d='M8 11 3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.input:disabled, .select:disabled { opacity: .5; cursor: not-allowed; background: var(--readonly-bg); }
.hint { font-size: 12px; color: var(--ink-mute); font-weight: 700; }
.reveal { animation: aparecer .25s ease; }
@keyframes aparecer { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 15px; border-radius: 14px;
  font-weight: 800; font-size: 14px; color: var(--ink-soft); cursor: pointer; user-select: none;
  background: var(--clay-bg);
  box-shadow: var(--soft-shadow);
  transition: transform .15s, color .15s, background .15s, box-shadow .15s;
}
.chip span:hover { transform: translateY(-1px); color: var(--ink); }
.chip input:checked + span {
  color: #fff; background: linear-gradient(145deg, var(--cc, var(--violet)), var(--cc2, #6366f1));
  box-shadow: 5px 6px 14px color-mix(in srgb, var(--cc, var(--violet)) 38%, transparent), inset 2px 2px 5px rgba(255,255,255,.35), inset -3px -3px 6px rgba(0,0,0,.12);
}
.chip input:focus-visible + span { outline: 3px solid rgba(124,92,255,.35); outline-offset: 2px; }

.type-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid rgba(124,92,255,.08); }
.type-row:last-child { border-bottom: 0; }
.type-dot { width: 38px; height: 38px; border-radius: 13px; display: grid; place-items: center; color: #fff; font-size: 16px; flex: none;
  background: linear-gradient(145deg, var(--c1), var(--c2)); box-shadow: 3px 4px 10px color-mix(in srgb, var(--c1) 35%, transparent), inset 2px 2px 4px rgba(255,255,255,.4); }
.type-row .grow { flex: 1; min-width: 0; }
.big-total { font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; }

.error { color: var(--danger); font-size: 13px; font-weight: 700; }
.check { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--violet); }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.filters .field { min-width: 150px; }
.filters .grow { flex: 1; min-width: 220px; }
.filters > .select { width: auto; min-width: 150px; }

.section-label { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 15px; margin: 22px 0 14px; }
.section-label .num {
  width: 28px; height: 28px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-size: 13px;
  background: linear-gradient(145deg, var(--teal), var(--sky));
  box-shadow: 3px 3px 8px rgba(20,184,166,.35), inset 2px 2px 4px rgba(255,255,255,.4);
}

.mes-select-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-mute); padding: 12px 14px; border-bottom: 1px solid rgba(124, 92, 255, .12); white-space: nowrap;
}
.table td { padding: 13px 14px; border-bottom: 1px solid rgba(124, 92, 255, .08); font-weight: 600; vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--hover-bg); }
.table tfoot td { font-weight: 900; border-bottom: 0; border-top: 2px solid rgba(124, 92, 255, .2); }
.num-col { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--ink-mute); }
.strong { font-weight: 900; }
.code {
  display: inline-block; font-weight: 900; font-size: 12px; padding: 4px 9px; border-radius: 9px;
  color: var(--violet); background: rgba(124, 92, 255, .1);
}

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 99px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.badge-ok { background: rgba(52, 211, 153, .18); color: var(--ok-ink); }
.badge-warn { background: rgba(245, 158, 11, .18); color: var(--warn-ink); }
.badge-bad { background: rgba(251, 113, 133, .18); color: var(--bad-ink); }
.badge-info { background: rgba(56, 189, 248, .18); color: var(--info-ink); }
.badge-mute { background: rgba(140, 139, 176, .16); color: var(--ink-soft); }

/* ---------- Alertas ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 18px; border-radius: var(--r-lg); font-weight: 700; margin-bottom: 20px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--glass-border); }
.alert i { font-size: 20px; }
.alert-ok { background: var(--alert-ok-bg); color: var(--alert-ok-ink); }
.alert-error { background: var(--alert-err-bg); color: var(--alert-err-ink); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Estado de cuenta ---------- */
.months { display: grid; gap: 14px; grid-template-columns: repeat(6, minmax(0, 1fr)); }
.month {
  padding: 16px 12px; border-radius: var(--r-lg); text-align: center;
  background: var(--clay-bg); box-shadow: var(--clay-shadow);
  border-top: 5px solid var(--mc, var(--ink-mute));
}
.month .m-name { font-weight: 900; }
.month .m-amount { font-size: 18px; font-weight: 900; margin-top: 6px; font-variant-numeric: tabular-nums; }
.month .m-meta { font-size: 12px; color: var(--ink-mute); font-weight: 700; margin-top: 4px; min-height: 16px; }
.month.pagado { --mc: var(--mint); }
.month.vencido { --mc: var(--coral); }
.month.pendiente { --mc: var(--track); }

.profile { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.profile .avatar { width: 64px; height: 64px; border-radius: 22px; font-size: 24px; }
.kv { display: grid; gap: 4px; }
.kv .k { font-size: 12px; font-weight: 800; color: var(--ink-mute); text-transform: uppercase; letter-spacing: .06em; }
.kv .v { font-weight: 900; }

/* ---------- Planilla estilo hoja ---------- */
.sheet { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; min-width: 1150px; }
.sheet th, .sheet td { padding: 9px 10px; border-right: 1px solid rgba(124,92,255,.10); border-bottom: 1px solid rgba(124,92,255,.10); white-space: nowrap; }
.sheet thead th { position: sticky; top: 0; z-index: 2; background: linear-gradient(145deg, #4c3fd1, #7c5cff); color: #fff; font-weight: 900; text-align: center; }
.sheet thead th:first-child { border-top-left-radius: 16px; }
.sheet thead th:last-child { border-top-right-radius: 16px; }
.sheet thead tr.year th { background: linear-gradient(145deg, #0f766e, #14b8a6); font-size: 12px; }
.sheet td.mon { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; min-width: 72px; }
.sheet td.mon.pago { background: rgba(52, 211, 153, .10); }
.sheet td.mon.vencido { background: rgba(251, 113, 133, .10); }
.sheet td.ord { text-align: center; color: var(--ink-mute); font-weight: 800; }
.sheet td.nombre { font-weight: 800; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.sheet td.prom { text-align: right; font-weight: 900; color: var(--violet); }
.sheet td.tot { text-align: right; font-weight: 900; background: rgba(124, 92, 255, .06); }
.sheet tbody tr:nth-child(even) td { background-color: var(--row-alt); }
.sheet tbody tr:hover td { background-color: var(--row-hover); }
.sheet tfoot td { font-weight: 900; background: rgba(20, 184, 166, .12); text-align: right; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.legend span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; background: var(--lc); }

/* ---------- Recibo ---------- */
.receipt {
  position: relative; border-radius: var(--r-xl); padding: 26px;
  background: var(--receipt-bg);
  box-shadow: var(--clay-shadow); overflow: hidden;
}
.receipt::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 8px;
  background: linear-gradient(90deg, var(--teal), var(--sky), var(--violet), var(--coral), var(--amber));
}
.receipt-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 16px; border-bottom: 2px dashed rgba(124,92,255,.22); }
.receipt-org { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; min-width: 0; }
.receipt-logos { display: flex; align-items: center; gap: 12px; }
.receipt-logos .logo-principal {
  width: 80px; height: 80px; border-radius: 18px; object-fit: cover; flex: none;
  box-shadow: 4px 5px 12px rgba(30, 40, 120, .28), inset 0 0 0 1px rgba(255,255,255,.4);
}
/* DEMAD tiene fondo transparente y texto oscuro: siempre sobre blanco para que se lea en ambos temas */
.receipt-logos .logo-demad {
  display: grid; place-items: center; height: 80px; padding: 5px 12px; border-radius: 18px; flex: none;
  background: #fff; box-shadow: 4px 5px 12px rgba(30, 40, 120, .16), inset 0 0 0 1px rgba(124, 92, 255, .12);
}
.receipt-logos .logo-demad img { height: 70px; width: auto; display: block; }
.receipt-no { text-align: right; }
.receipt-no .lbl { font-size: 11px; font-weight: 900; letter-spacing: .1em; color: var(--ink-mute); text-transform: uppercase; }
.receipt-no .val { font-size: 24px; font-weight: 900; color: var(--coral); font-variant-numeric: tabular-nums; }
.receipt-body { display: grid; gap: 12px; padding: 18px 0; grid-template-columns: 1fr 1fr; }
.receipt-body .full { grid-column: 1 / -1; }
.receipt-total {
  display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-radius: var(--r-lg);
  color: #fff; background: linear-gradient(145deg, var(--teal), #0ea5e9);
  box-shadow: 6px 8px 18px rgba(20,184,166,.35), inset 2px 2px 5px rgba(255,255,255,.35);
}
.receipt-total .amount { font-size: 28px; font-weight: 900; font-variant-numeric: tabular-nums; }
.receipt-months { display: flex; flex-wrap: wrap; gap: 6px; }
.receipt-sign { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin-top: 46px; text-align: center; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.receipt-sign div { border-top: 1.5px solid var(--ink-mute); padding-top: 8px; }

/* ---------- Login ---------- */
.login-wrap { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 940px; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; padding: 0; }
.login-hero {
  position: relative; padding: 44px; color: #fff; display: flex; flex-direction: column; justify-content: space-between; gap: 30px;
  background: linear-gradient(150deg, #0d9488 0%, #0ea5e9 45%, #7c5cff 100%);
  overflow: hidden;
}
.login-hero::before, .login-hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.14); }
.login-hero::before { width: 260px; height: 260px; right: -80px; top: -70px; }
.login-hero::after { width: 200px; height: 200px; left: -60px; bottom: -60px; }
.login-hero > * { position: relative; }
.login-hero h2 { font-size: 32px; line-height: 1.15; }
.login-hero p { opacity: .9; font-weight: 600; line-height: 1.6; }
.hero-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-pills span { padding: 8px 14px; border-radius: 99px; background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35); font-weight: 800; font-size: 13px; backdrop-filter: blur(8px); }
.login-form { padding: 44px; display: flex; flex-direction: column; gap: 18px; justify-content: center; }
.input-icon { position: relative; }
.input-icon i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--violet); font-size: 17px; }
.input-icon .input { padding-left: 44px; }

/* ---------- Paginación ---------- */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; margin-top: 18px; align-items: center; }
.pagination a, .pagination span {
  min-width: 38px; height: 38px; padding: 0 10px; display: inline-grid; place-items: center; border-radius: 12px; font-weight: 800; font-size: 14px;
  background: var(--clay-bg); color: var(--ink-soft);
  box-shadow: var(--soft-shadow-sm);
}
.pagination .active { color: #fff; background: linear-gradient(145deg, var(--violet), #6366f1); }
.pagination .disabled { opacity: .45; }
.pagination .info { background: none; box-shadow: none; color: var(--ink-mute); margin-right: auto; }

.empty { text-align: center; padding: 40px 16px; color: var(--ink-mute); font-weight: 700; }
.empty i { font-size: 40px; display: block; margin-bottom: 10px; color: var(--violet-2); }

.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 240px; }

.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(124,92,255,.08); }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .t { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .s { font-size: 12px; color: var(--ink-mute); font-weight: 700; }
.list-row > :not(.grow) { flex: none; }

.overlay { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid-pago { grid-template-columns: minmax(0, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .months { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .grid-pago aside { position: static !important; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-120%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .overlay { display: block; position: fixed; inset: 0; background: rgba(31,29,71,.25); backdrop-filter: blur(3px); z-index: 30; }
  .main { margin-left: 0; padding: 16px; }
  .menu-toggle { display: inline-grid; }
  .grid-3, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .login-card { grid-template-columns: 1fr; }
  .login-hero { padding: 32px; }
  .login-form { padding: 32px 24px; }
}
@media (max-width: 640px) {
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid-3, .receipt-body { grid-template-columns: minmax(0, 1fr); }
  .months { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 18px; border-radius: 22px; }
  .topbar h1 { font-size: 23px; }
  .stat-value { font-size: 24px; }
}

/* ---------- Impresión ---------- */
@media print {
  @page { margin: 12mm; }
  body { background: #fff !important; }
  .blobs, .sidebar, .topbar, .no-print, .overlay, .alert { display: none !important; }
  .main { margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none !important; border: 0 !important; background: #fff !important; backdrop-filter: none !important; padding: 0 !important; }
  .receipt { box-shadow: none !important; border: 1.5px solid #c9c4ee; max-width: 760px; margin: 0 auto; }
  .print-only { display: block !important; }
  .sheet { font-size: 10px; min-width: 0; }
  .sheet th, .sheet td { padding: 4px 5px; }
  .sheet td.nombre { max-width: none; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.print-only { display: none; }

/* ---------- Notificación flotante ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; z-index: 60;
  max-width: min(520px, calc(100vw - 32px)); padding: 14px 20px; border-radius: 18px; font-weight: 800;
  color: #fff; background: rgba(31, 29, 71, .92); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .3); transition: opacity .25s, transform .25s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Selector de tema ---------- */
.theme-options { display: grid; gap: 20px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.theme-option { position: relative; cursor: pointer; }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-card {
  display: block; padding: 14px; border-radius: var(--r-xl); background: var(--clay-bg); box-shadow: var(--soft-shadow);
  border: 2px solid transparent; transition: transform .2s, border-color .2s, box-shadow .2s;
}
.theme-option:hover .theme-card { transform: translateY(-3px); }
.theme-option input:checked + .theme-card { border-color: var(--violet); box-shadow: var(--clay-shadow), 0 0 0 4px rgba(124, 92, 255, .18); }
.theme-option input:focus-visible + .theme-card { outline: 3px solid rgba(124, 92, 255, .4); outline-offset: 3px; }
.theme-name { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; padding: 0 4px; font-weight: 900; }
.theme-name .check-dot {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; color: transparent;
  box-shadow: var(--clay-inset); transition: background .2s, color .2s;
}
.theme-option input:checked + .theme-card .check-dot { color: #fff; background: linear-gradient(145deg, var(--violet), #6366f1); box-shadow: none; }
.theme-desc { padding: 2px 4px 0; font-size: 13px; font-weight: 700; color: var(--ink-mute); }

/* Mini vista previa de la interfaz */
.mock { position: relative; height: 128px; border-radius: 18px; overflow: hidden; display: flex; gap: 8px; padding: 10px; }
.mock.claro { background: linear-gradient(135deg, #ece7ff, #dff7f3 60%, #ffe6ea); }
.mock.oscuro { background: linear-gradient(135deg, #241a52, #0d2f33 60%, #33142a); }
.mock .m-side { width: 26%; border-radius: 11px; padding: 8px 6px; display: flex; flex-direction: column; gap: 5px; }
.mock .m-main { flex: 1; display: flex; flex-direction: column; gap: 7px; }
.mock .m-row { display: flex; gap: 7px; }
.mock .m-card { flex: 1; height: 34px; border-radius: 9px; }
.mock .m-wide { flex: 1; border-radius: 9px; }
.mock .m-line { height: 6px; border-radius: 4px; }
.mock .m-line.on { background: linear-gradient(90deg, #7c5cff, #6366f1); }
.mock.claro .m-side, .mock.claro .m-wide { background: rgba(255, 255, 255, .7); }
.mock.claro .m-card { background: #fff; box-shadow: 2px 2px 5px rgba(80, 70, 160, .15); }
.mock.claro .m-line { background: #d9d5f2; }
.mock.oscuro .m-side, .mock.oscuro .m-wide { background: rgba(38, 35, 69, .8); }
.mock.oscuro .m-card { background: #2b2850; box-shadow: 2px 2px 5px rgba(0, 0, 0, .4); }
.mock.oscuro .m-line { background: #3d3a66; }
.mock .m-card:nth-child(1) { border-top: 3px solid #14b8a6; }
.mock .m-card:nth-child(2) { border-top: 3px solid #7c5cff; }
.mock .m-card:nth-child(3) { border-top: 3px solid #fb7185; }
.mock-split { display: block; position: relative; height: 128px; border-radius: 18px; overflow: hidden; }
.mock-split .mock { position: absolute; inset: 0; border-radius: 0; }
.mock-split .mock.oscuro { clip-path: polygon(58% 0, 100% 0, 100% 100%, 42% 100%); }

@media (max-width: 760px) { .theme-options { grid-template-columns: minmax(0, 1fr); } }

/* Fuerza el tema claro dentro de un elemento (p. ej. la imagen del recibo). */
.tema-claro { color: var(--ink); }
.captura-recibo { position: fixed; left: -10000px; top: 0; width: 480px; pointer-events: none; }

/* ---------- Recibo (estructura del recibo impreso de la iglesia) ---------- */
.rc { max-width: 480px; padding: 26px 26px 20px; }
.rc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding-bottom: 14px; border-bottom: 2px dashed rgba(124, 92, 255, .22); }
.rc-org { min-width: 0; }
.rc-iglesia { font-size: 15px; font-weight: 800; color: var(--ink-soft); line-height: 1.2; }
.rc-nombre-org { font-size: 21px; font-weight: 900; line-height: 1.15; margin-top: 2px; }
.rc-lugar { font-size: 14px; font-style: italic; font-weight: 700; color: var(--ink-mute); margin-top: 4px; }
.rc .receipt-logos { gap: 8px; }
.rc .receipt-logos .logo-principal { width: 58px; height: 58px; border-radius: 14px; }
.rc .receipt-logos .logo-demad { height: 58px; padding: 4px 8px; border-radius: 14px; }
.rc .receipt-logos .logo-demad img { height: 50px; }

.rc-label { font-size: 12px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-mute); }
.rc-numero { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 18px; }
.rc-num {
  flex: 1; text-align: right; font-size: 34px; font-weight: 900; line-height: 1.1; color: var(--coral);
  font-variant-numeric: tabular-nums; padding-bottom: 4px; border-bottom: 2px solid var(--ink);
}
.rc-campo { display: flex; flex-direction: column; gap: 3px; margin-top: 14px; padding-bottom: 6px; border-bottom: 1.5px solid var(--ink); }
.rc-valor { font-size: 17px; font-weight: 800; }
.rc-valor-nombre { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }

.rc-tabla { display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; align-items: start; margin-top: 18px; }
.rc-label-der { text-align: right; padding-top: 12px; }
.rc-caja { padding: 10px 14px; border-radius: 14px; background: var(--input-bg); box-shadow: var(--clay-inset); border: 1px solid rgba(124, 92, 255, .12); font-weight: 800; font-size: 16px; }
.rc-monto { text-align: right; font-variant-numeric: tabular-nums; }
.rc-meses { min-height: 96px; display: flex; flex-direction: column; gap: 4px; }

.rc-total {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; padding: 14px 18px; border-radius: 18px;
  color: #fff; background: linear-gradient(145deg, var(--teal), #0ea5e9);
  box-shadow: 6px 8px 18px rgba(20,184,166,.32), inset 2px 2px 5px rgba(255,255,255,.35);
}
.rc-total span { font-size: 13px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; opacity: .9; }
.rc-total strong { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; }
.rc-letras { margin-top: 12px; padding-bottom: 6px; border-bottom: 1.5px solid var(--ink); font-weight: 800; font-size: 15px; }
.rc-letras .rc-label { margin-right: 4px; }
.rc-obs { margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }

.rc-pie { margin-top: 40px; text-align: center; }
.rc-firma { width: 70%; margin: 0 auto; padding-top: 8px; border-top: 1.5px solid var(--ink-mute); font-size: 13px; font-weight: 800; color: var(--ink-soft); }
.rc-emitido { margin-top: 14px; font-size: 11px; font-weight: 700; color: var(--ink-mute); }

@media (max-width: 420px) {
  .rc { padding: 20px 16px 16px; }
  .rc-head { flex-direction: column-reverse; }
  .rc-num { font-size: 28px; }
}
@media print { .rc { margin: 0 auto; } }
.code:empty { display: none; }

/* ---------- Firma en el recibo (se activa con la clase .con-firma) ---------- */
.rc-firma-zona { position: relative; height: 0; }
.rc-firma-img { display: none; position: absolute; left: 50%; bottom: -16px; transform: translateX(-50%); width: 190px; height: auto; pointer-events: none; }
.rc.con-firma .rc-pie { margin-top: 118px; }
.rc.con-firma .rc-firma-img { display: block; }
/* La tinta es oscura: en modo oscuro se aclara en pantalla (la imagen descargada siempre va en claro) */
:root[data-tema-activo="oscuro"] .rc-firma-img { filter: invert(1) hue-rotate(180deg) brightness(1.4); }
:root[data-tema-activo="oscuro"] .tema-claro .rc-firma-img { filter: none; }
@media print { .rc-firma-img { filter: none !important; } }

.firma-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 480px; margin-top: 18px;
  padding: 12px 16px; border-radius: 18px; background: var(--glass); border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: var(--glass-shadow);
}
.firma-toggle .txt { font-weight: 800; display: flex; align-items: center; gap: 10px; }
.firma-toggle .txt i { color: var(--violet); font-size: 18px; }
.switch { position: relative; width: 52px; height: 30px; flex: none; }
.switch input { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; z-index: 1; }
.switch .pista { position: absolute; inset: 0; border-radius: 99px; background: var(--input-bg); box-shadow: var(--clay-inset); transition: background .2s; }
.switch .pista::after {
  content: ""; position: absolute; top: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--clay-bg); box-shadow: 2px 2px 6px rgba(0, 0, 0, .25); transition: transform .2s;
}
.switch input:checked + .pista { background: linear-gradient(145deg, var(--violet), #6366f1); box-shadow: inset 2px 2px 5px rgba(0,0,0,.2); }
.switch input:checked + .pista::after { transform: translateX(22px); background: #fff; }
.switch input:focus-visible + .pista { outline: 3px solid rgba(124, 92, 255, .4); outline-offset: 2px; }

/* Separador "o" en el inicio de sesión */
.separador-o { display: flex; align-items: center; gap: 12px; margin: 6px 0 14px; color: var(--ink-mute); font-weight: 800; font-size: 13px; }
.separador-o::before, .separador-o::after { content: ""; flex: 1; height: 1px; background: rgba(124, 92, 255, .2); }

/* ---------- Rendimiento en teléfonos ----------
   El desenfoque de fondo (glass) es lo más costoso de dibujar al hacer scroll.
   En pantallas pequeñas se usa un desenfoque menor y un vidrio un poco más opaco: se ve casi igual y fluye mejor. */
@media (max-width: 960px) {
  :root { --glass: rgba(255, 255, 255, .68); }
  :root[data-tema-activo="oscuro"] { --glass: rgba(30, 27, 58, .74); }
  .card, .sidebar, .alert, .firma-toggle {
    backdrop-filter: blur(10px) saturate(140%);
    -webkit-backdrop-filter: blur(10px) saturate(140%);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .card, .sidebar, .alert, .firma-toggle, .toast { backdrop-filter: none; -webkit-backdrop-filter: none; }
  :root { --glass: rgba(255, 255, 255, .92); }
  :root[data-tema-activo="oscuro"] { --glass: rgba(30, 27, 58, .95); }
}
