/* ===== Tokens de marca (fuente de verdad: DESIGN-SYSTEM.md §1-§5) ===== */
/* Modo claro únicamente: la marca es clara (fondo crema). No hay modo oscuro. */
:root {
  color-scheme: light;

  /* TIPOGRAFÍA (DS §2.1) — self-hosted, ver @font-face abajo */
  --font-display: 'Space Grotesk', sans-serif;  /* títulos, números grandes */
  --font-body:    'Inter', sans-serif;          /* body, UI, párrafos */

  /* AZUL — acción / interacción (DS §1.1) */
  --blue-50:   #EAF3FC;   /* fondos suaves, highlights */
  --blue-200:  #74BBF4;   /* azul personaje (blob) — NO texto/botones */
  --blue-500:  #2B7CD3;   /* AZUL UI BASE — acciones, links, focus */
  --blue-600:  #1E5FA8;   /* hover de botones azules */
  --blue-700:  #16447A;   /* texto azul sobre claro, pressed */

  /* ROJO/CORAL — acento de foco / urgencia (DS §1.2) */
  --red-50:    #FDECEA;
  --red-100:   #F6C6C1;
  --red-500:   #E7473B;   /* BASE — badge "próximo", urgencia */
  --red-600:   #BE3429;
  --red-700:   #92271E;

  /* NEUTROS CÁLIDOS (DS §1.3) */
  --cream:         #FDFBF7;   /* fondo principal de página */
  --white:         #FFFFFF;   /* fondo de cards */
  --surface:       #F8F6F0;   /* fondos inset (filas, chips) */
  --ink:           #16130F;   /* texto principal */
  --muted:         #6B6862;   /* texto secundario */
  --muted-light:   #B0ABA1;   /* deshabilitado, placeholders */
  --border:        #EAE4D8;   /* bordes de cards y divisores */
  --border-strong: #E0DACE;   /* bordes con presencia (btn secundario) */

  /* SEMÁNTICOS (DS §1.4) */
  --success: #1D9E75;  --success-bg: #E1F5EE;
  --warning: #BA7517;  --warning-bg: #FAEEDA;
  --danger:  #BE3429;  --danger-bg:  #FDECEA;

  /* RADIOS (DS §4) */
  --radius-sm:   8px;     /* botones, inputs, chips */
  --radius-md:   12px;    /* cards estándar */
  --radius-lg:   16px;    /* bloques destacados (totales) */
  --radius-xl:   18px;    /* contenedores grandes */
  --radius-pill: 999px;   /* badges, pills */

  --border-width:        1px;
  --border-width-strong: 1.5px;

  /* ELEVACIÓN (DS §5): profundidad por layering, sombra mínima */
  --shadow-soft: 0 4px 24px rgba(22, 19, 15, 0.06);

  --tap: 44px;

  /* Default del cuadrito cuando la suscripción no tiene color asignado.
     No es la paleta funcional de 20 (esa vive en app.js, spec-004 §9.2);
     es un neutro cálido placeholder. */
  --color-default: var(--muted-light);
}

/* ===== Fuentes self-hosted (spec-004 §5; vanilla sin build → woff2 + @font-face) ===== */
/* Subset latin de fontsource. Pesos: Space Grotesk 400/500/700, Inter 400/500. */
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/space-grotesk-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/space-grotesk-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk'; font-style: normal; font-weight: 700; font-display: swap;
  src: url('fonts/space-grotesk-700.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap;
  src: url('fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter'; font-style: normal; font-weight: 500; font-display: swap;
  src: url('fonts/inter-500.woff2') format('woff2');
}

/* ===== Reset / base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0));
}
h1, h2, h3, p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, button, textarea { font: inherit; color: inherit; }
/* Safari iOS: un control de TEXTO con font-size < 16px provoca auto-zoom al
   enfocarlo y NO regresa → el usuario queda zoomeado y debe alejar a mano (es
   el "al entrar la app no se ve al tamaño correcto"). 16px lo desactiva. Aplica
   a inputs de texto, email, password, número, fecha y selects; los botones no
   disparan zoom. Diferencia vs los 15px del body es imperceptible; no afecta
   desktop. (El meta viewport en index.html ya es correcto: width=device-width,
   initial-scale=1 — no es la causa.) */
input:not([type="checkbox"]):not([type="radio"]),
select,
textarea { font-size: 16px; }

/* ===== Header ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  padding-top: calc(14px + env(safe-area-inset-top, 0));
}
.brand { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.brand-title { display: flex; align-items: center; gap: 8px; }
.app-header h1 {
  font-family: var(--font-display);
  font-size: 24px;          /* heading-m mobile (DS §2.2) */
  font-weight: 700;
  letter-spacing: -0.03em;  /* tracking negativo en headlines (DS §2.3) */
  line-height: 1.05;
}
.brand-tagline {
  font-family: var(--font-body);
  font-size: 13px;          /* small (DS §2.2) */
  color: var(--muted);
}

/* Badge "alpha" (spec-004 §9.5): contexto, no alerta → neutro cálido, NO rojo */
.badge-alpha {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  line-height: 1.4;
  white-space: nowrap;
}

/* Ícono "i" → nota humana (Lucide info, DS §10). Área táctil ≥44px sin inflar la fila. */
.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--tap);
  min-height: var(--tap);
  margin: -10px -8px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-pill);
  transition: color 150ms ease;
}
.info-btn:hover { color: var(--blue-500); }

/* Nota de versión temprana (popover nativo) */
.alpha-note {
  max-width: 300px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--ink);
  padding: 16px 18px;
  box-shadow: var(--shadow-soft);
}
.alpha-note-text {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
}
.alpha-note::backdrop { background: rgba(22, 19, 15, 0.25); }

.header-actions { display: flex; gap: 4px; }

.icon-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, color 150ms ease;
}
.icon-btn:hover { background: var(--surface); color: var(--ink); }
.icon-btn:active { background: var(--border); }
.icon-btn svg { width: 20px; height: 20px; }   /* Lucide en botón (DS §10) */

/* ===== Main ===== */
.app-main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 20px;   /* padding lateral 20px mobile (DS §3) */
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ===== Totales (DS §9.3: layering de color antes que sombra) ===== */
.totals {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 0;
}
.totals-row .label { color: var(--muted); font-size: 14px; }
.totals-row .value {
  font-family: var(--font-display);   /* números grandes en Space Grotesk (DS §9.3) */
  font-weight: 700;
  font-size: 24px;                    /* heading-m mobile */
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.totals-row.secondary { padding-top: 8px; margin-top: 8px; border-top: 1px solid var(--border); }
.totals-row.secondary .label { font-size: 12px; color: var(--muted-light); }
.totals-row.secondary .value { font-size: 15px; font-weight: 500; color: var(--muted); }
.totals-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 8px 0; }

/* Estado vacío con blob azul (spec-004 §9.4 #1) — sin chrome de card */
.totals.is-empty { background: none; border: none; padding: 32px 16px; }
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.empty-blob { width: 80px; height: auto; margin-bottom: 6px; }   /* foco 40-80px (DS §11) */
.empty-state-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.empty-state-sub { font-size: 14px; color: var(--muted); }

/* ===== Lista ===== */
.list-section { display: flex; flex-direction: column; gap: 8px; }
.list-heading {
  font-family: var(--font-display);   /* heading-s (DS §2.2): sentence case */
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.list-heading .count,
.paused-toggle .count { color: var(--muted); font-weight: 400; }
/* Chevron Lucide: rota a "abierto" según [aria-expanded] del toggle */
.chevron { display: inline-flex; align-items: center; color: var(--muted-light); transition: transform 150ms ease; }
.chevron svg { width: 18px; height: 18px; }
.paused-toggle[aria-expanded="true"] .chevron { transform: rotate(90deg); }

.sub-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.sub-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);   /* card estándar (DS §8.1) */
  padding: 16px 18px;
  min-height: var(--tap);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 150ms ease;
}
.sub-item:hover { border-color: var(--border-strong); }   /* DS §8.1: hover = borde, no fondo */
.sub-item:active { background: var(--surface); }

.color-square {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  background: var(--color-default);
  flex-shrink: 0;
  border: 1px solid rgba(22, 19, 15, 0.08);
}

.sub-info { min-width: 0; }
.sub-name {
  font-family: var(--font-display);   /* card title heading-s (DS §8.1, §2.2) */
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.sub-meta {
  color: var(--muted);
  font-size: 15px;            /* monto/fecha en row = body (DS §2.2) */
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

/* Badge / pill (DS §9) */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.4;
  white-space: nowrap;
}
/* "PRÓXIMO" → rojo de marca: acento de urgencia (spec-004 §9.1, DS §1.2) */
.badge.soon { background: var(--red-50); color: var(--red-600); }

.sub-actions { display: flex; gap: 4px; }
.row-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  border: 1.5px solid var(--border-strong);   /* botón secundario (DS §6.2) */
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  font-weight: 500;
  font-size: 14px;
  padding: 0 12px;
  transition: background 150ms ease;
}
.row-btn:hover { background: var(--surface); }

.empty {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
}

/* Pausadas */
.paused-section { gap: 0; }
.paused-toggle {
  background: transparent;
  border: none;
  padding: 8px 4px;
  text-align: left;
  font-family: var(--font-display);   /* heading-s, igual que .list-heading */
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
}
.paused-list { margin-top: 8px; }
.paused-list .sub-item { opacity: 0.85; }

/* ===== FAB (azul UI de marca, spec-004 §7.4) ===== */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--blue-500);
  color: var(--white);
  line-height: 1;
  box-shadow: 0 6px 16px rgba(22, 19, 15, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: background 150ms ease, transform 100ms ease;
}
.fab:hover { background: var(--blue-600); }
.fab:active { transform: scale(0.96); }
.fab svg { width: 26px; height: 26px; }   /* Lucide plus (DS §10) */

/* ===== Modales ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 19, 15, 0.45);   /* overlay cálido (ink translúcido) */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 0;
}
.modal-backdrop[hidden] { display: none; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 16px; }
}

.modal {
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  /* En Safari iOS `vh` usa el viewport GRANDE (cuenta el área tras la barra de
     direcciones) → el modal queda más alto que la pantalla visible y el botón
     Guardar cae detrás de la barra. `dvh` usa el viewport dinámico (visible) y
     lo arregla. `vh` queda de fallback para navegadores sin dvh. */
  max-height: 92vh;
  max-height: 92dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -8px 32px rgba(22, 19, 15, 0.18);
  animation: slide-up 0.18s ease;
}
@media (min-width: 640px) {
  .modal { border-radius: var(--radius-lg); }
}
.modal-sm { max-width: 360px; }

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  font-family: var(--font-display);   /* heading-s (DS §2.2) */
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.modal-body {
  padding: 16px;
  /* Bottom-sheet en mobile: respeta el safe-area inferior (indicador de inicio)
     para que el botón Guardar quede siempre alcanzable. */
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;   /* scroll inercial dentro del modal en iOS */
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span,
.field > legend {
  font-size: 13px;
  color: var(--ink);          /* label en --ink (DS §7.1) */
  font-weight: 500;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field select {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 14px;          /* DS §7.1 */
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--ink);
  appearance: none;
  -webkit-appearance: none;
}
.field input::placeholder { color: var(--muted-light); }
/* Focus ring azul — clave del barrido (spec-004 §7.3, DS §7.1) */
.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 3px var(--blue-50);
}
/* Select: chevron-down (Lucide, DS §7.3) */
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B6862' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}
/* Checkbox / radio (DS §7.3) */
input[type="checkbox"],
input[type="radio"] { accent-color: var(--blue-500); }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.color-field { border: none; padding: 0; margin: 0; }
.color-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.color-swatch {
  position: relative;
  aspect-ratio: 1;
  min-width: var(--tap);
  min-height: var(--tap);
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  background-clip: padding-box;
  cursor: pointer;
  padding: 0;
}
.color-swatch:focus-visible {
  outline: 2px solid var(--blue-500);
  outline-offset: 2px;
}
.color-swatch.selected {
  border-color: var(--ink);
  box-shadow: 0 0 0 2px var(--white) inset;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
  background: var(--danger-bg);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 4px;
  flex-wrap: wrap;
}
/* Botones — jerarquía DS §6 / spec-004 §7.1 */
.btn {
  min-height: var(--tap);
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 15px;
  transition: background 150ms ease, border-color 150ms ease;
}
/* Primario — azul UI sólido */
.btn-primary { background: var(--blue-500); color: var(--white); }
.btn-primary:hover { background: var(--blue-600); }
.btn-primary:active { background: var(--blue-700); }
/* Secundario — contorno cálido */
.btn-ghost {
  background: transparent;
  border: 1.5px solid var(--border-strong);
  color: var(--ink);
}
.btn-ghost:hover { background: var(--surface); }
/* Peligro — primario con familia roja (Eliminar / Confirmar) */
.btn-danger { background: var(--danger); color: var(--white); margin-right: auto; }
.btn-danger:hover { background: var(--red-700); }

.reactivate-name { font-weight: 500; color: var(--muted); }

/* ============================================================
   Gate de sesión (spec-002 §5) — login/registro como puerta de entrada.
   Reusa tokens de marca de :root; los inputs y botones usan .field/.btn.
   ============================================================ */

/* El estado lo maneja auth.js vía body[data-auth="loading|out|in"]. */
body[data-auth="loading"] #auth-screen,
body[data-auth="loading"] #app-root,
body[data-auth="out"]     #auth-loading,
body[data-auth="out"]     #app-root,
body[data-auth="in"]      #auth-loading,
body[data-auth="in"]      #auth-screen { display: none !important; }

/* Pantalla de carga mientras se resuelve la sesión */
.auth-loading {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--muted);
  font-size: 14px;
}
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--blue-500);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Pantalla de login / registro */
.auth-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px;   /* padding lateral 20px mobile (DS §3) */
  /* MOBILE: el blob emerge por ARRIBA de la card → reserva superior generosa
     (≈ mitad visible del blob) para que su cabeza no la corte el borde de la
     ventana. margin-block:auto en la card centra vertical y, si no cabe, hace
     scroll desde arriba sin recortar (align-items:center sí recortaría). */
  padding-top: calc(24px + env(safe-area-inset-top, 0) + clamp(104px, 30vw, 124px));
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
}
.auth-card {
  position: relative;        /* ancla del blob asomándose (DS §11) */
  width: 100%;
  max-width: 380px;
  margin-block: auto;        /* centra vertical; en overflow no recorta */
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 34px 24px 28px;   /* +aire arriba: el contenido empieza bajo el blob */
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Blob de bienvenida — asomándose DETRÁS de la card (DS §11).
   Truco de apilamiento: la card es position:relative SIN z-index ni transform,
   por lo que NO crea contexto de apilamiento; un hijo con z-index:-1 pinta
   DEBAJO del fondo blanco opaco de la card. Resultado: el blob solo se ve FUERA
   del recuadro de la card; el texto (contenido en flujo) queda siempre encima
   sobre blanco sólido → nunca hay texto sobre el blob. Proporción intacta.
   MOBILE (base): grande, centrado, emergiendo por el borde SUPERIOR (mitad
   superior visible: cabeza + brazo + hombros), sin tilt. 1 blob por viewport. */
.auth-blob {
  position: absolute;
  z-index: -1;                        /* DETRÁS de la card */
  left: 50%;
  bottom: 100%;                       /* base al ras del borde superior… */
  transform: translate(-50%, 50%);    /* …baja 50%: mitad inferior oculta tras la card */
  width: clamp(176px, 58vw, 224px);   /* presencia real */
  /* El archivo SVG trae width/height="1080" intrínsecos. Con height:auto, Safari
     iOS IGNORA el width CSS para la altura y usa los 1080px intrínsecos → blob
     gigante (full-screen) que empuja el form. aspect-ratio fuerza la proporción
     desde el width CSS; max-height es el tope DURO absoluto: pase lo que pase
     (cualquier navegador), el blob NUNCA crece más de esto. */
  aspect-ratio: 1 / 1;
  height: auto;
  max-width: 224px;
  max-height: 240px;
  pointer-events: none;               /* decorativo: los toques lo ATRAVIESAN y
                                         llegan al form/botón (clave en Safari iOS:
                                         sin esto el blob sobredimensionado captura
                                         el tap y "Iniciar sesión" no responde) */
}
/* DESKTOP (≥640px): el blob se asoma por el COSTADO IZQUIERDO con un tilt
   juguetón, como espiando por detrás del borde; el resto queda tras la card. */
@media (min-width: 640px) {
  .auth-screen {
    padding-top: calc(24px + env(safe-area-inset-top, 0));  /* ya no emerge por arriba */
  }
  .auth-blob {
    left: 0;
    bottom: auto;
    top: 50%;
    width: clamp(200px, 30vw, 364px);   /* ~30% más grande que antes (280→364) */
    max-width: 364px;                   /* sube el tope desktop (base es 224px) */
    max-height: 380px;                  /* tope duro desktop, acorde al width máx */
    /* Asoma ~60% por la izquierda: saca la carita COMPLETA (ambos ojos con
       lentes) fuera del borde de la card. En 640px el saliente (~120px) cabe en
       el margen lateral (~130px) → sin scroll horizontal; crece con la pantalla. */
    transform: translate(-60%, -50%) rotate(-12deg);
  }
}
.auth-brand { margin-bottom: 8px; }
.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 30px;            /* display protagonista (DS §2.2) */
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
}
.auth-title {
  font-family: var(--font-display);   /* heading-s (DS §2.2) */
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-top: 4px;
}
.auth-sub { font-size: 14px; color: var(--muted); margin-bottom: 8px; }

#auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-submit:disabled { opacity: 0.6; cursor: default; }

.field-hint { font-size: 12px; color: var(--muted); }

/* Botón-enlace (terciario, DS §6.3 / spec-004 §7.1): texto azul, sin fondo */
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--blue-500);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: inherit;
  text-decoration: none;
}
.link-btn:hover { color: var(--blue-600); text-decoration: underline; }

.auth-toggle {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Consentimiento (spec-002 §6) — solo visible en registro */
.auth-consent { margin-top: 2px; }
.consent-label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}
.consent-label input[type="checkbox"] {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--blue-500);   /* DS §7.3 */
}
.consent-label strong { color: var(--ink); font-weight: 500; }

/* ============================================================
   Aviso de privacidad (spec-002 §6) — popover nativo
   ============================================================ */
.privacy-panel {
  width: min(92vw, 440px);
  max-height: 84vh;
  margin: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--white);
  color: var(--ink);
  padding: 0;
  overflow: auto;
  box-shadow: var(--shadow-soft);
}
.privacy-panel::backdrop { background: rgba(22, 19, 15, 0.45); }
.privacy-inner { padding: 24px; display: flex; flex-direction: column; gap: 8px; }
.privacy-inner h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.privacy-inner h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  margin-top: 10px;
  color: var(--ink);
}
.privacy-inner p { font-size: 14px; line-height: 1.6; color: var(--muted); }
.privacy-inner strong { color: var(--ink); font-weight: 500; }
.privacy-inner .btn-ghost { margin-top: 16px; align-self: flex-end; }
.placeholder-tag {
  font-size: 12px !important;
  color: var(--warning) !important;
  background: var(--warning-bg);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  align-self: flex-start;
}

/* ===== Estados de red de la nube (spec-003 §4 estados / §8) ===== */
/* Sobre los tokens de marca de spec-004: azul de acción, neutros, radios. */

/* Mientras se carga o falla, ocultar totales y listas; mostrar solo #app-status. */
.app-main[data-state="loading"] .totals,
.app-main[data-state="loading"] .list-section,
.app-main[data-state="error"] .totals,
.app-main[data-state="error"] .list-section { display: none; }
.app-main[data-state="ready"] #app-status { display: none; }

.app-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 40vh;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}
.app-status p { margin: 0; max-width: 28ch; line-height: 1.5; }
.app-status .btn { margin-top: 2px; }
/* reutiliza .spinner (definido para el gate de auth) */

/* Toast transitorio para errores de operaciones puntuales (pausar, eliminar…). */
.app-toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%);
  z-index: 100;
  max-width: min(92vw, 420px);
  background: var(--danger-bg);
  color: var(--danger);
  border: var(--border-width) solid var(--red-100);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  box-shadow: var(--shadow-soft);
}
.app-toast[hidden] { display: none; }
