/* ═══════════════════════════════════════════════════════════════
   Proher Natura — Control de Gastos · Design System v3.0
   Stack: Vanilla CSS · Skill: ui-ux-pro-max (Swiss Minimalism + Wellness)
   Fuentes: Playfair Display · Plus Jakarta Sans · Inter · JetBrains Mono
═══════════════════════════════════════════════════════════════ */

/* ─── DESIGN TOKENS ─────────────────────────────────────────── */
:root {

  /* Verde PHN — escala completa */
  --green-50:  #F6FAEB;
  --green-100: #EEF5DF;
  --green-200: #DCEBB5;
  --green-300: #C2D97A;
  --green-400: #A5C23A;
  --green-500: #80BA26;  /* Verde PHN principal */
  --green-600: #6FA31F;
  --green-700: #4F7D11;
  --green-800: #4A5C06;
  --green-900: #343F04;

  /* Neutros cálidos */
  --neutral-50:  #FAFAF7;
  --neutral-100: #F5F4EE;
  --neutral-200: #E8E6DD;
  --neutral-300: #D5D1C4;
  --neutral-400: #A8A398;
  --neutral-500: #757065;
  --neutral-600: #524E45;
  --neutral-700: #36332D;
  --neutral-800: #221F1B;
  --neutral-900: #14120F;

  /* Acento dorado — premium discreto */
  --gold:      #C4A35A;
  --gold-soft: #EDD9A3;
  --gold-bg:   #FBF5E6;

  /* Estados semánticos */
  --success:    var(--green-500);
  --success-bg: var(--green-50);
  --warning:    #D97706;
  --warning-bg: #FEF3E2;
  --error:      #C0504A;
  --error-bg:   #FDF0EF;
  --info:       #4A6FA5;
  --info-bg:    #EAF1F9;

  /* Semánticos de app */
  --bg-app:          var(--neutral-50);
  --bg-surface:      #FFFFFF;
  --bg-overlay:      rgba(20, 18, 15, 0.60);
  --text-primary:    var(--neutral-800);
  --text-secondary:  var(--neutral-600);
  --text-tertiary:   var(--neutral-500);
  --text-on-green:   #FFFFFF;
  --border-subtle:   var(--neutral-200);
  --border-default:  var(--neutral-300);
  --border-strong:   var(--neutral-400);

  /* Tipografía — stack del sistema (SF Pro en Apple) para sensación nativa */
  --font-display: 'Playfair Display', Georgia, serif;
  --font-heading: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', 'Plus Jakarta Sans', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', 'Inter', system-ui, sans-serif;
  --font-mono:    'SF Mono', 'JetBrains Mono', ui-monospace, monospace;

  /* Escala tipográfica (ratio 1.25) */
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.375rem;
  --text-2xl:  1.75rem;
  --text-3xl:  2.25rem;

  /* Pesos */
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* Line heights */
  --leading-tight:   1.2;
  --leading-snug:    1.4;
  --leading-normal:  1.6;
  --leading-relaxed: 1.75;

  /* Letter spacing */
  --tracking-tight:  -0.02em;
  --tracking-normal: 0em;
  --tracking-wide:   0.06em;

  /* Espaciado (base 8px) */
  --space-1:  0.25rem;   /* 4px  */
  --space-2:  0.5rem;    /* 8px  */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-8:  2rem;      /* 32px */
  --space-10: 2.5rem;    /* 40px */
  --space-12: 3rem;      /* 48px */
  --space-16: 4rem;      /* 64px */

  /* Radios */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   20px;
  --radius-2xl:  28px;
  --radius-full: 9999px;

  /* Sombras — capas sutiles con undertone cálido */
  --shadow-xs: 0 1px 2px 0 rgba(20, 18, 15, 0.04);
  --shadow-sm:
    0 1px 2px 0 rgba(20, 18, 15, 0.04),
    0 2px 6px 0 rgba(20, 18, 15, 0.04);
  --shadow-md:
    0 1px 3px 0 rgba(20, 18, 15, 0.05),
    0 4px 10px 0 rgba(20, 18, 15, 0.05),
    0 12px 28px -4px rgba(20, 18, 15, 0.06);
  --shadow-lg:
    0 4px 8px -2px rgba(20, 18, 15, 0.06),
    0 16px 32px -4px rgba(20, 18, 15, 0.10),
    0 32px 64px -12px rgba(20, 18, 15, 0.07);
  --shadow-xl:
    0 8px 16px -4px rgba(20, 18, 15, 0.08),
    0 24px 48px -8px rgba(20, 18, 15, 0.12);
  --shadow-green: 0 4px 20px rgba(139, 171, 10, 0.28);
  --shadow-focus: 0 0 0 3px rgba(139, 171, 10, 0.22);

  /* Transiciones */
  --transition-fast:    150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-default: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:    320ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-spring:  380ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Layout */
  --topbar-h: 60px;
  --wizard-h: 64px;
  --sticky-offset: calc(var(--topbar-h) + var(--wizard-h));
}

/* ─── RESET ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-app);
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  min-height: 100vh;
  padding-bottom: calc(var(--space-16) + env(safe-area-inset-bottom, 0px));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, svg { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }

/* Focus visible — accesibilidad sin sacrificar estética */
:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-sm);
}

/* Skip link */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  background: var(--green-500);
  color: #fff;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  z-index: 9999;
  transition: top var(--transition-fast);
}
.skip-link:focus { top: var(--space-4); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── LAYOUT ─────────────────────────────────────────────────── */
.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 var(--space-5);
}

/* ─── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  height: var(--topbar-h);
  background: rgba(250, 250, 247, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: box-shadow var(--transition-default);
}
.topbar--scrolled {
  box-shadow: var(--shadow-sm);
  background: rgba(250, 250, 247, 0.97);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.brand-logo {
  height: 38px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}
.brand-leaf { font-size: 26px; line-height: 1; }

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.brand-text strong {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  color: var(--green-700);
  line-height: 1.1;
}
.brand-text small {
  font-family: var(--font-heading);
  font-size: 10px;
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  font-weight: var(--weight-medium);
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.cost-display {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--neutral-100);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 3px 10px;
  white-space: nowrap;
  transition: background .2s, color .2s, border-color .2s;
}
.cost-display--warn  { color: #92400e; background: #fef3c7; border-color: #f59e0b; }
.cost-display--alert { color: #991b1b; background: #fee2e2; border-color: #ef4444; }

.btn-reset-cost {
  font-size: 13px;
  line-height: 1;
  color: var(--text-tertiary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  opacity: .7;
  transition: opacity .15s;
}
.btn-reset-cost:hover { opacity: 1; }

/* ─── WIZARD PROGRESS ────────────────────────────────────────── */
.wizard-progress {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-5);
  height: var(--wizard-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: var(--topbar-h);
  z-index: 40;
  gap: 0;
}

.wp-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.wp-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--neutral-100);
  border: 2px solid var(--border-default);
  color: var(--text-tertiary);
  font-family: var(--font-heading);
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--transition-default),
    border-color var(--transition-default),
    box-shadow var(--transition-default),
    color var(--transition-default);
  position: relative;
  overflow: hidden;
}

.wp-dot-num {
  position: absolute;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.wp-dot-check {
  position: absolute;
  opacity: 0;
  transform: scale(0);
  transition: opacity var(--transition-spring), transform var(--transition-spring);
  color: var(--green-500);
}

.wp-dot--active {
  background: var(--green-50);
  border-color: var(--green-500);
  color: var(--green-600);
  box-shadow: 0 0 0 4px rgba(139, 171, 10, 0.12);
  animation: dotPulse 2.5s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(139, 171, 10, 0.12); }
  50%       { box-shadow: 0 0 0 8px rgba(139, 171, 10, 0.06); }
}

.wp-dot--done {
  background: var(--green-500);
  border-color: var(--green-500);
  color: #fff;
  animation: none;
  box-shadow: none;
}
.wp-dot--done .wp-dot-num   { opacity: 0; transform: scale(0.5); }
.wp-dot--done .wp-dot-check { opacity: 1; transform: scale(1); color: #fff; }

.wp-label {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  transition: color var(--transition-default);
}
.wp-dot--active ~ .wp-label,
.wp-step:has(.wp-dot--active) .wp-label {
  color: var(--green-600);
}
.wp-step:has(.wp-dot--done) .wp-label {
  color: var(--text-secondary);
}

/* Líneas conectoras con fill animado */
.wp-line {
  width: 60px;
  height: 2px;
  background: var(--border-subtle);
  margin: 0 var(--space-1);
  align-self: center;
  margin-bottom: 18px;
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}
.wp-line-fill {
  position: absolute;
  inset: 0;
  background: var(--green-500);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 2px;
}
.wp-line--done .wp-line-fill { transform: scaleX(1); }

/* ─── WIZARD PAGES ───────────────────────────────────────────── */
.wiz-page { display: none; padding: var(--space-8) 0; }
.wiz-page--active {
  display: block;
  animation: pageEnter 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}
.wiz-exit-left   { animation: exitLeft  0.26s ease-in forwards; }
.wiz-exit-right  { animation: exitRight 0.26s ease-in forwards; }
.wiz-enter-right { animation: enterRight 0.32s cubic-bezier(0.22, 1, 0.36, 1); }
.wiz-enter-left  { animation: enterLeft  0.32s cubic-bezier(0.22, 1, 0.36, 1); }

@keyframes pageEnter   { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes exitLeft    { to   { opacity: 0; transform: translateX(-24px); } }
@keyframes exitRight   { to   { opacity: 0; transform: translateX(24px);  } }
@keyframes enterRight  { from { opacity: 0; transform: translateX(24px);  } to { opacity: 1; transform: none; } }
@keyframes enterLeft   { from { opacity: 0; transform: translateX(-24px); } to { opacity: 1; transform: none; } }

/* ─── CARD ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
}

.card--form {
  max-width: 560px;
  margin: 0 auto;
}

.page-head { margin-bottom: var(--space-8); }

.page-head h2 {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

.page-head__sub {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-2);
  line-height: var(--leading-normal);
}

/* ─── FORM FIELDS ────────────────────────────────────────────── */
.form-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.flbl {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.flbl-opt {
  font-weight: var(--weight-regular);
  color: var(--text-tertiary);
}

.req {
  color: var(--error);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
}

.finp {
  height: 44px;
  padding: 0 var(--space-4);
  background: var(--neutral-50);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  width: 100%;
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast),
    box-shadow var(--transition-fast);
}
.finp:hover { border-color: var(--border-strong); }
.finp:focus {
  outline: none;
  border-color: var(--green-500);
  background: var(--bg-surface);
  box-shadow: var(--shadow-focus);
}
.finp::placeholder { color: var(--text-tertiary); }
.finp--narrow { max-width: 160px; }
.finp.inp-err {
  border-color: var(--error);
  background: var(--error-bg);
  box-shadow: 0 0 0 3px rgba(192, 80, 74, 0.12);
}

.fecha-display {
  height: 44px;
  padding: 0 var(--space-4);
  display: flex;
  align-items: center;
  background: var(--green-50);
  border: 1.5px solid var(--green-200);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--green-700);
  letter-spacing: 0.01em;
}

/* ─── MÉTODOS DE PAGO ────────────────────────────────────────── */
.metodo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}

.metodo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  background: var(--neutral-50);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-lg);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  cursor: pointer;
  transition:
    border-color var(--transition-default),
    background var(--transition-default),
    color var(--transition-default),
    box-shadow var(--transition-default),
    transform var(--transition-spring);
  min-height: 72px;
  position: relative;
}

@media (hover: hover) {
  .metodo-btn:hover {
    border-color: var(--green-400);
    background: var(--green-50);
    color: var(--green-600);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
  }
}
.metodo-btn:active { transform: scale(0.97); }

.metodo-btn--on {
  border-color: var(--green-500);
  background: var(--green-50);
  color: var(--green-700);
  box-shadow: 0 0 0 3px rgba(139, 171, 10, 0.14);
}
.metodo-btn--on::after {
  content: '';
  position: absolute;
  top: 7px;
  right: 7px;
  width: 8px;
  height: 8px;
  background: var(--green-500);
  border-radius: 50%;
  animation: dotAppear var(--transition-spring) forwards;
}
@keyframes dotAppear { from { transform: scale(0); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.metodo-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
}

.metodo-grid.grp-err {
  border: 2px dashed var(--error);
  border-radius: var(--radius-lg);
  padding: var(--space-2);
}

/* ─── P1 ACTIONS ─────────────────────────────────────────────── */
.p1-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-8);
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ─── BOTONES — sistema completo ─────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-5);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1;
  white-space: nowrap;
  border: 1.5px solid transparent;
  min-height: 44px;
  cursor: pointer;
  transition:
    background var(--transition-default),
    border-color var(--transition-default),
    color var(--transition-default),
    box-shadow var(--transition-default),
    transform var(--transition-spring);
  -webkit-user-select: none;
  user-select: none;
}

/* Primary */
.btn-primary {
  background: var(--green-500);
  color: var(--text-on-green);
  box-shadow: var(--shadow-xs), 0 2px 10px rgba(139, 171, 10, 0.22);
}
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) {
    background: var(--green-600);
    box-shadow: var(--shadow-md), 0 4px 16px rgba(139, 171, 10, 0.32);
    transform: translateY(-1px);
  }
}
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-primary:disabled {
  background: var(--neutral-200);
  color: var(--text-tertiary);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Secondary */
.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
  box-shadow: var(--shadow-xs);
}
@media (hover: hover) {
  .btn-secondary:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
  }
}
.btn-secondary:active { transform: scale(0.98); }

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
@media (hover: hover) {
  .btn-ghost:hover {
    background: var(--neutral-100);
    color: var(--text-primary);
  }
}
.btn-ghost:active { transform: scale(0.98); }

/* Full width */
.btn-full { width: 100%; }

/* Download btn */
.btn-download {
  padding: 0 var(--space-6) !important;
  min-height: 48px !important;
  font-size: var(--text-base) !important;
  box-shadow: var(--shadow-sm), 0 4px 20px rgba(139, 171, 10, 0.28) !important;
}
@media (hover: hover) {
  .btn-download:hover:not(:disabled) {
    box-shadow: var(--shadow-md), 0 8px 28px rgba(139, 171, 10, 0.36) !important;
  }
}

/* ─── STICKY TOTAL ───────────────────────────────────────────── */
.sticky-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-5);
  position: sticky;
  top: var(--sticky-offset);
  z-index: 30;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-default);
}

.sticky-total:has(.st-amount:not(:empty)) {
  box-shadow: var(--shadow-md);
}

.st-info { display: flex; flex-direction: column; gap: 2px; }

.st-label {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.st-amount {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--green-600);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tight);
  transition: color var(--transition-fast);
}

/* ─── AI MODE BAR ────────────────────────────────────────────── */
.ai-mode-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0 var(--space-4);
  flex-wrap: wrap;
}

.ai-mode-bar__label {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-right: var(--space-1);
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  padding: 5px 12px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 30px;
}
@media (hover: hover) {
  .mode-btn:hover {
    border-color: var(--green-400);
    color: var(--green-600);
    background: var(--green-50);
  }
}
.mode-btn--active {
  background: var(--green-50);
  border-color: var(--green-400);
  color: var(--green-700);
}

.mode-btn__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.mode-btn__dot--green { background: #80BA26; }
.mode-btn__dot--amber { background: var(--warning); }

/* ─── EXPENSE CARDS ──────────────────────────────────────────── */
.ec {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-4);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  transition:
    box-shadow var(--transition-default),
    transform var(--transition-default),
    border-color var(--transition-default);
  contain: layout style paint;
}
@media (hover: hover) {
  .ec:hover { box-shadow: var(--shadow-md); }
}

.ec__hint-badge {
  font-family: var(--font-heading);
  font-size: 10px;
  padding: 2px 7px;
  background: var(--neutral-100);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-tertiary);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  margin-left: var(--space-2);
}

.slot--analyzing {
  border-color: var(--green-500) !important;
  border-style: solid !important;
  animation: slotPulse 1.5s ease-in-out infinite;
}
@keyframes slotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(139, 171, 10, 0.35); }
  50%       { box-shadow: 0 0 0 5px rgba(139, 171, 10, 0); }
}

.ec__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
  border-left: 4px solid transparent;
  gap: var(--space-3);
}
@media (hover: hover) {
  .ec__head:hover { background: var(--neutral-50); }
}

.ec__head--ok {
  background: var(--green-50);
  border-left-color: var(--green-500);
}
.ec__head--warn {
  background: var(--warning-bg);
  border-left-color: var(--warning);
}

.ec__head-left {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.ec__head-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.ec__num {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.ec__badge {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  padding: 2px 8px;
  background: var(--neutral-100);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.ec__amt {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-tight);
}

.ec__status {
  font-size: var(--text-sm);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.ec__del {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--transition-fast),
    color var(--transition-fast);
  flex-shrink: 0;
}
@media (hover: hover) {
  .ec__del:hover {
    background: var(--error-bg);
    color: var(--error);
  }
}

.ec__tog {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--neutral-100);
  transition:
    background var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-default);
  flex-shrink: 0;
}
@media (hover: hover) {
  .ec__tog:hover {
    background: var(--neutral-200);
    color: var(--text-primary);
  }
}
.ec--collapsed .ec__tog { transform: rotate(180deg); }

.ec__body {
  padding: var(--space-5) var(--space-6) var(--space-5);
  border-top: 1px solid var(--border-subtle);
}
.ec--collapsed .ec__body { display: none; }

/* Grupos y filas */
.ec__group { margin-bottom: var(--space-5); }

.ec__lbl {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.ec__row   { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-bottom: var(--space-4); }
.ec__row--4 { grid-template-columns: 1.6fr minmax(150px, 1.3fr) 1fr 1fr; }
.ec__field { display: flex; flex-direction: column; gap: var(--space-1); }
.hidden { display: none !important; }

.ec__inp {
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--neutral-50);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  width: 100%;
  transition:
    border-color var(--transition-fast),
    background var(--transition-fast),
    box-shadow var(--transition-fast);
}
.ec__inp:hover  { border-color: var(--border-strong); }
.ec__inp:focus  {
  outline: none;
  border-color: var(--green-500);
  background: var(--bg-surface);
  box-shadow: var(--shadow-focus);
}
.ec__inp::placeholder { color: var(--text-tertiary); }
.ec__inp.inp-err { border-color: var(--error); background: var(--error-bg); }
.ec__inp[type="date"] { padding: 0 var(--space-3); }

/* Importe */
.importe-wrap { position: relative; }
.peso {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  font-size: var(--text-sm);
  pointer-events: none;
}
.importe-inp {
  padding-left: 22px !important;
  font-family: var(--font-mono) !important;
  font-weight: var(--weight-semibold) !important;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Tipo de gasto */
.tipo-grid {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-2);
}

.tipo-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  min-width: 64px;
  background: var(--neutral-50);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-lg);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-default);
  min-height: 52px;
  justify-content: center;
}
@media (hover: hover) {
  .tipo-opt:hover {
    border-color: var(--green-400);
    background: var(--green-50);
    color: var(--green-600);
    transform: translateY(-1px);
  }
}
.tipo-opt--on {
  border-color: var(--green-500);
  background: var(--green-50);
  color: var(--green-700);
  box-shadow: 0 0 0 2px rgba(139, 171, 10, 0.12);
}
.tipo-opt:active { transform: scale(0.96); }
.tipo-grid.grp-err { outline: 2px dashed var(--error); border-radius: var(--radius-lg); }

/* ─── FOLIO ──────────────────────────────────────────────────── */
.folio-wrap { position: relative; }
.folio-inp  { padding-right: 110px !important; }

.folio-badge {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  white-space: nowrap;
  pointer-events: none;
}
.folio-badge--uuid    { background: var(--green-50); color: var(--green-700); border: 1px solid var(--green-300); }
.folio-badge--interno { background: var(--info-bg); color: var(--info); border: 1px solid #B3C7E0; }

.btn-folio-info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--neutral-200);
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: var(--weight-bold);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}
@media (hover: hover) {
  .btn-folio-info:hover { background: var(--green-500); color: #fff; }
}

/* ─── CONFIDENCE BADGES ──────────────────────────────────────── */
.conf-badge {
  font-size: 10px;
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  font-weight: var(--weight-bold);
}
.conf-alta  { color: var(--success); }
.conf-media { color: var(--warning); }
.conf-baja  { color: var(--text-tertiary); }

/* ─── SLOTS GRID ─────────────────────────────────────────────── */
.slots-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.slot {
  position: relative;
  border: 1.5px dashed var(--green-300);
  border-radius: var(--radius-lg);
  background: var(--green-50);
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  transition: all var(--transition-default);
  overflow: hidden;
  cursor: pointer;
}
@media (hover: hover) {
  .slot:hover {
    border-color: var(--green-500);
    background: var(--green-100);
    transform: scale(1.01);
  }
}

.slot__num {
  position: absolute;
  bottom: 5px;
  right: 7px;
  font-family: var(--font-heading);
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: var(--weight-semibold);
}

.slot__upload,
.slot__cam {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--green-200);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  color: var(--green-600);
  cursor: pointer;
  min-height: 44px;
  justify-content: center;
  transition: all var(--transition-fast);
  min-width: 48px;
}
@media (hover: hover) {
  .slot__upload:hover,
  .slot__cam:hover {
    background: var(--green-50);
    border-color: var(--green-400);
  }
}

.slot__upload-ico,
.slot__cam-ico {
  display: flex;
  align-items: center;
  color: var(--green-500);
}

.slot__upload-lbl,
.slot__cam-lbl {
  font-size: 9px;
  font-weight: var(--weight-semibold);
  color: var(--green-600);
}

.slot--filled {
  border-style: solid;
  border-color: var(--green-400);
  background: var(--bg-surface);
  cursor: default;
}
@media (hover: hover) {
  .slot--filled:hover {
    transform: none;
    border-color: var(--green-500);
    background: var(--bg-surface);
  }
}

.slot__thumb-wrap {
  width: 100%;
  height: 64px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--neutral-100);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.slot__thumb { width: 100%; height: 100%; object-fit: cover; }
.slot__pdf-ico { font-size: 26px; }

.slot__name {
  font-family: var(--font-heading);
  font-size: 9px;
  color: var(--text-tertiary);
  padding: 2px 5px;
  text-align: center;
  word-break: break-all;
  line-height: 1.3;
  max-height: 26px;
  overflow: hidden;
}

.slot__rm {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  background: rgba(192, 80, 74, 0.90);
  color: #fff;
  border-radius: 50%;
  font-size: 9px;
  font-weight: var(--weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
  transition: background var(--transition-fast);
}
@media (hover: hover) {
  .slot__rm:hover { background: var(--error); }
}

.slot-counter {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  color: var(--text-tertiary);
  background: var(--neutral-100);
  border-radius: var(--radius-full);
  padding: 1px 8px;
  margin-left: var(--space-2);
}
.slot-fmt-hint {
  font-family: var(--font-heading);
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

/* ─── AI ROW ─────────────────────────────────────────────────── */
.ec__ai-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
  flex-wrap: wrap;
}

.btn-ai {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  height: 38px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--green-600);
  cursor: pointer;
  transition: all var(--transition-default);
}
@media (hover: hover) {
  .btn-ai:hover:not(:disabled) {
    background: var(--green-50);
    border-color: var(--green-400);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
}
.btn-ai:active:not(:disabled) { transform: scale(0.98); }
.btn-ai--off, .btn-ai:disabled { opacity: 0.40; cursor: not-allowed; }

.ai-badge {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--green-600);
  font-weight: var(--weight-semibold);
  padding: 4px 10px;
  background: var(--green-50);
  border-radius: var(--radius-full);
  border: 1px solid var(--green-200);
}
.ai-badge--sm { font-size: 10px; padding: 1px 7px; }

.btn-premium {
  font-family: var(--font-heading);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  color: #6d28d9;
  background: #ede9fe;
  border: 1px solid #c4b5fd;
  border-radius: var(--radius-full);
  padding: 3px 10px;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn-premium:hover:not(:disabled) { background: #ddd6fe; transform: translateY(-1px); }
.btn-premium:disabled { opacity: .5; cursor: not-allowed; }

/* ─── ADD EXPENSE ────────────────────────────────────────────── */
.btn-add-expense {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-4);
  background: var(--bg-surface);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-xl);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-default);
  margin-bottom: var(--space-6);
  min-height: 56px;
}
@media (hover: hover) {
  .btn-add-expense:hover {
    border-color: var(--green-400);
    background: var(--green-50);
    color: var(--green-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
}
.btn-add-expense:active { transform: scale(0.99); }

/* Empty state */
.no-expenses-msg {
  text-align: center;
  padding: var(--space-12) var(--space-8);
  color: var(--text-tertiary);
}
.no-expenses-icon {
  display: flex;
  justify-content: center;
  margin-bottom: var(--space-4);
  opacity: 0.35;
  color: var(--text-secondary);
}
.no-expenses-title {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

/* Observaciones */
/* ─── ARRASTRAR Y PEGAR ───────────────────────────────────────── */
.dropzone--over {
  outline: 2px dashed var(--primary);
  outline-offset: 3px;
  border-radius: var(--radius-lg);
  background: var(--green-50);
}
.dropzone--over .slot { border-color: var(--primary); }

/* El gesto solo existe con ratón: en el teléfono el texto sobra */
.drop-hint { display: none; }
@media (hover: hover) and (pointer: fine) {
  .drop-hint {
    display: block;
    margin: 4px 0 0;
    font-size: 11.5px;
    color: var(--text-tertiary);
  }
}

/* ─── DINERO RECIBIDO (efectivo / transferencia) ──────────────── */
.recibido {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.recibido[hidden] { display: none !important; }

.recibido__head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.recibido__ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: var(--radius-lg);
  background: var(--green-50);
  color: var(--primary);
}
.recibido__head-txt { min-width: 0; }
.recibido__title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}
.recibido__sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.recibido__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}
@media (max-width: 560px) {
  .recibido__grid { grid-template-columns: 1fr; }
}

.recibido__hint {
  margin: -2px 0 var(--space-2);
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.4;
}

.recibido__slotbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}
.recibido__scan[hidden] { display: none !important; }
#recibido-req[hidden]     { display: none !important; }
.recibido__scan {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12.5px;
}
#recibido-slots.grp-err { outline: 2px dashed var(--error); border-radius: var(--radius-lg); }

.recibido__transf {
  margin-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  padding-top: var(--space-3);
}
.recibido__transf[hidden] { display: none !important; }
.recibido__transf > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  padding: 4px 0;
  list-style: revert;
}
.recibido__transf > summary::marker { color: var(--primary); }
.recibido__transf > .recibido__grid { margin-top: var(--space-3); }

.recibido__resumen {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-4);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--bg-subtle, var(--green-50));
  border: 1px solid var(--border-subtle);
}
.recibido__resumen[hidden] { display: none !important; }
.recibido__res-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 90px;
}
.recibido__res-item em {
  font-style: normal;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
}
.recibido__res-item strong {
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.recibido__res-item small { font-size: 11px; color: var(--text-tertiary); }
.recibido__res-item--saldo { margin-left: auto; text-align: right; }
.recibido__res-item--saldo strong { color: var(--primary); }

.recibido__resumen--debe  .recibido__res-item--saldo strong { color: var(--warning, #B26A00); }
.recibido__resumen--favor .recibido__res-item--saldo strong { color: var(--error); }
.recibido__resumen--ok    .recibido__res-item--saldo strong { color: var(--success, var(--primary)); }

.obs-section { margin-bottom: var(--space-6); }
.obs-section textarea {
  width: 100%;
  resize: vertical;
  min-height: 68px;
  padding: var(--space-3) var(--space-4);
  background: var(--neutral-50);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: var(--leading-normal);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.obs-section textarea:hover  { border-color: var(--border-strong); }
.obs-section textarea:focus  {
  outline: none;
  border-color: var(--green-500);
  background: var(--bg-surface);
  box-shadow: var(--shadow-focus);
}

/* Nav */
.wiz-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

/* ─── PÁGINA 3 ───────────────────────────────────────────────── */
.p3-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: var(--space-6);
  align-items: start;
}

.p3-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: sticky;
  top: var(--sticky-offset);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.p3-summary {
  padding: var(--space-4);
  background: var(--neutral-50);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  margin-bottom: var(--space-2);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  min-height: 48px;
}

.p3-actions-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Preview area */
.p3-preview {
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.prev-topbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--space-2) var(--space-4);
  background: var(--neutral-700);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.prev-page-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  font-weight: var(--weight-medium);
  min-height: 16px;
}

.pdf-prev-container {
  background: var(--neutral-600);
  padding: var(--space-5) var(--space-5) var(--space-8);
  min-height: 500px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-5);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.prev-page {
  box-shadow: 0 6px 24px rgba(0,0,0,0.5), 0 1px 4px rgba(0,0,0,0.3);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.prev-canvas { display: block; max-width: 100%; height: auto; }

.prev-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  color: rgba(255,255,255,0.55);
  padding: var(--space-16) var(--space-5);
  text-align: center;
  font-family: var(--font-heading);
  font-size: var(--text-sm);
}
.prev-error { color: #FF8A80; padding: var(--space-12); text-align: center; font-size: var(--text-sm); }

.prev-spin {
  width: 36px;
  height: 36px;
  border: 2.5px solid rgba(255,255,255,0.12);
  border-top-color: var(--green-400);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── TOAST ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: calc(var(--topbar-h) + var(--space-4));
  right: var(--space-5);
  max-width: 360px;
  width: max-content;
  padding: var(--space-3) var(--space-4);
  background: var(--neutral-800);
  color: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  opacity: 0;
  transform: translateX(calc(100% + var(--space-5)));
  transition:
    transform var(--transition-spring),
    opacity var(--transition-default);
  z-index: 200;
  pointer-events: none;
  border-left: 4px solid transparent;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  line-height: var(--leading-snug);
}

.toast--show {
  opacity: 1;
  transform: translateX(0);
}

.toast--success {
  border-left-color: var(--green-400);
  background: var(--neutral-800);
}
.toast--error {
  border-left-color: var(--error);
  background: var(--neutral-800);
}
.toast--info {
  border-left-color: var(--info);
  background: var(--neutral-800);
}
.toast--warning {
  border-left-color: var(--warning);
  background: var(--neutral-800);
}

/* ─── MODAL ──────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}
.modal-overlay.modal--open {
  display: flex;
  animation: overlayIn var(--transition-default) forwards;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  overflow-y: auto;
  animation: modalIn var(--transition-spring) forwards;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1)    translateY(0); }
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.modal-head h3 {
  font-family: var(--font-heading);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--neutral-100);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}
@media (hover: hover) {
  .modal-close:hover { background: var(--neutral-200); color: var(--text-primary); }
}

.modal-body {
  padding: var(--space-5) var(--space-6) var(--space-6);
}
.modal-intro {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-4);
  line-height: var(--leading-normal);
}

.folio-tipo {
  background: var(--neutral-50);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  border: 1px solid var(--border-subtle);
}
.folio-tipo-head {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
  color: var(--text-primary);
}
.folio-tipo-desc {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
  line-height: var(--leading-normal);
}
.folio-code {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--green-50);
  border: 1px solid var(--green-200);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  color: var(--green-700);
  margin: 2px 3px 2px 0;
  word-break: break-all;
}
.folio-codes { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-1); }
.folio-tag {
  display: inline-block;
  margin-top: var(--space-2);
  font-family: var(--font-heading);
  font-size: 10px;
  background: var(--green-50);
  color: var(--green-700);
  border: 1px solid var(--green-200);
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-weight: var(--weight-semibold);
}
.folio-consejo {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: var(--warning-bg);
  border: 1px solid #FDE68A;
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-2);
  line-height: var(--leading-normal);
}

/* ─── CHAT FAB ───────────────────────────────────────────────── */
.chat-fab-wrap {
  position: fixed;
  bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
  right: var(--space-6);
  z-index: 250;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
}

.chat-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  padding: 0;
  background: transparent;
  border-radius: 50%;
  box-shadow: none;
  transition: transform var(--transition-spring);
  animation: fabPulse 4s ease-in-out infinite;
}
@media (hover: hover) {
  .chat-fab:hover { transform: translateY(-3px) scale(1.05); animation: none; }
}
.chat-fab:active { transform: scale(0.95); animation: none; }
.chat-fab--open  { animation: none; }

@keyframes fabPulse {
  0%, 92%, 100% { transform: scale(1); }
  96%           { transform: scale(1.04); }
}

.chat-fab-wrap--open .chat-fab-lbl { display: none; }
.chat-fab-ico { width: 60px; height: 60px; object-fit: contain; }

.chat-fab-lbl {
  font-family: var(--font-heading);
  font-size: 10px;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: #fff;
  background: rgba(20, 18, 15, 0.52);
  backdrop-filter: blur(6px);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  pointer-events: none;
  white-space: nowrap;
}

/* ─── CHAT PANEL ─────────────────────────────────────────────── */
.chat-panel {
  position: fixed;
  bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  right: var(--space-6);
  width: 360px;
  max-width: calc(100vw - var(--space-8));
  height: 500px;
  max-height: calc(100vh - 140px);
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl), 0 0 0 1px var(--border-subtle);
  z-index: 249;
  display: flex;
  flex-direction: column;
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition:
    transform var(--transition-spring),
    opacity var(--transition-default);
}
.chat-panel--open {
  transform: none;
  opacity: 1;
  pointer-events: auto;
}

.chat-inner { display: flex; flex-direction: column; height: 100%; overflow: hidden; border-radius: var(--radius-xl); }

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--green-600);
  color: #fff;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: var(--space-2); }
.chat-avatar { width: 32px; height: 32px; object-fit: contain; border-radius: 50%; }
.chat-title {
  display: block;
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
}
.chat-subtitle {
  display: block;
  font-family: var(--font-heading);
  font-size: 10px;
  opacity: 0.72;
}
.chat-header-actions { display: flex; gap: var(--space-1); }

.chat-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.16);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast);
}
@media (hover: hover) {
  .chat-icon-btn:hover { background: rgba(255,255,255,0.28); }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: var(--neutral-50);
}

.chat-bubble {
  max-width: 86%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: bubbleIn var(--transition-default) cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes bubbleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.chat-bubble--user {
  background: var(--green-500);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-bubble--assistant {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-xs);
}
.chat-bubble--error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #F5C1BE;
  align-self: flex-start;
}

.chat-typing-dots { display: flex; align-items: center; gap: 4px; height: 16px; }
.chat-typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--text-tertiary);
  border-radius: 50%;
  animation: dotBounce 0.9s infinite;
}
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%            { transform: scale(1); opacity: 1; }
}

.chat-faq-wrap { padding: var(--space-1) 0; }
.chat-faq-label {
  font-family: var(--font-heading);
  font-size: 10px;
  color: var(--text-tertiary);
  margin-bottom: var(--space-2);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}
.chat-faq-chips { display: flex; flex-direction: column; gap: var(--space-1); }
.chat-faq-chip {
  padding: var(--space-2) var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--green-200);
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--green-600);
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
  min-height: 36px;
  display: flex;
  align-items: center;
}
@media (hover: hover) {
  .chat-faq-chip:hover {
    background: var(--green-50);
    border-color: var(--green-400);
  }
}

.chat-input-row {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--neutral-50);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.chat-input:focus {
  outline: none;
  border-color: var(--green-500);
  background: var(--bg-surface);
  box-shadow: var(--shadow-focus);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--green-500);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  flex-shrink: 0;
}
@media (hover: hover) {
  .chat-send-btn:hover { background: var(--green-600); }
}
.chat-send-btn:active { transform: scale(0.94); }

/* ─── WHATSAPP BUTTONS ───────────────────────────────────────── */
.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-5);
  min-height: 44px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  background: #25D366;
  color: #fff;
  border: 1.5px solid transparent;
  box-shadow: 0 2px 10px rgba(37, 211, 102, 0.24);
  cursor: pointer;
  transition:
    background var(--transition-default),
    box-shadow var(--transition-default),
    transform var(--transition-spring);
}
@media (hover: hover) {
  .btn-whatsapp:hover {
    background: #1ebe5c;
    box-shadow: 0 4px 18px rgba(37, 211, 102, 0.38);
    transform: translateY(-1px);
  }
}
.btn-whatsapp:active { transform: scale(0.98); }
.btn-whatsapp:disabled {
  background: var(--neutral-200);
  color: var(--text-tertiary);
  cursor: not-allowed;
  box-shadow: none;
}

/* ─── WHATSAPP MODAL ─────────────────────────────────────────── */
.wa-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-2) 0;
  counter-reset: wa-step;
}
.wa-steps li {
  counter-increment: wa-step;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  background: var(--neutral-50);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid #25D366;
  line-height: var(--leading-snug);
}
.wa-step-hint {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: 3px;
  font-weight: var(--weight-regular);
}

/* ─── AI SUMMARY ─────────────────────────────────────────────── */
.ai-summary {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--neutral-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  line-height: var(--leading-snug);
}
.ai-summary__header {
  font-family: var(--font-heading);
  color: var(--text-tertiary);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}
.ai-summary__stats {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.ai-summary__stat           { font-family: var(--font-heading); font-weight: var(--weight-semibold); font-size: var(--text-xs); }
.ai-summary__stat--ok       { color: var(--success); }
.ai-summary__stat--warn     { color: var(--warning); }
.ai-summary__stat--err      { color: var(--error); }
.ai-summary__warns          { margin-top: var(--space-2); display: flex; flex-direction: column; gap: var(--space-1); }
.ai-summary__warn-item      { font-size: 11px; color: var(--warning); font-family: var(--font-heading); }

/* ─── AI PROGRESS PANEL ──────────────────────────────────────── */
.ai-panel {
  margin-top: var(--space-3);
  background: var(--neutral-50);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-size: var(--text-xs);
  transition: opacity .4s;
}
.ai-panel--fade { opacity: 0; }

.ai-panel__rows { padding: var(--space-2) var(--space-3); display: flex; flex-direction: column; gap: 2px; }

.ai-panel__row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: var(--space-2);
  padding: 3px 0;
}
.ai-panel__icon { text-align: center; font-size: 13px; }
.ai-panel__name { font-family: var(--font-heading); font-weight: var(--weight-medium); color: var(--text-secondary); }
.ai-panel__status {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aips--wait     { color: var(--text-tertiary); background: var(--neutral-100); }
.aips--run      { color: #1d4ed8; background: #dbeafe; animation: aips-pulse 1s ease-in-out infinite; }
.aips--done     { color: #4F7D11; background: #EEF5DF; }
.aips--fail     { color: #b45309; background: #fef3c7; }
.aips--warn     { color: #92400e; background: #fef3c7; }
.aips--ensemble { color: #7c3aed; background: #ede9fe; animation: aips-pulse 1s ease-in-out infinite; }
.aips--premium  { color: #c2410c; background: #ffedd5; animation: aips-pulse 1s ease-in-out infinite; }

.ai-summary--manual { border-left: 3px solid var(--error, #ef4444); }

@keyframes aips-pulse { 0%,100% { opacity:1; } 50% { opacity:.6; } }

.ai-panel__foot {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--neutral-100);
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-tertiary);
}

/* ─── CONFIDENCE INPUT BORDERS ───────────────────────────────── */
.ec__inp--conf-alta  { border-color: var(--green-400) !important; }
.ec__inp--conf-media { border-color: var(--warning) !important; }
.ec__inp--conf-baja  { border-color: var(--error) !important; border-style: dashed !important; }

/* ─── FOOTER ─────────────────────────────────────────────────── */
.footer {
  text-align: center;
  padding: var(--space-8) var(--space-5);
  margin-top: var(--space-10);
  border-top: 1px solid var(--border-subtle);
}
.footer p {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  color: var(--text-secondary); /* contraste AA en texto pequeño */
}

/* ─── UTILIDADES ─────────────────────────────────────────────── */
.muted  { color: var(--text-tertiary); }
.small  { font-size: var(--text-xs); }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --topbar-h: 56px;
    --wizard-h: 58px;
  }

  body { font-size: 15px; }

  .wizard-progress { top: var(--topbar-h); }
  .sticky-total    { top: var(--sticky-offset); }
  .p3-controls     { position: static; }

  .p3-layout { grid-template-columns: 1fr; }
  .p3-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
    position: static;
  }
  .p3-controls .btn-ghost,
  .p3-controls .btn-download,
  .p3-controls .p3-summary,
  .p3-controls .p3-actions-group { grid-column: span 2; }

  .p3-controls .btn-download {
    position: sticky;
    bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    z-index: 20;
  }

  .ec__row--4 { grid-template-columns: 1fr 1fr; }
  .ec__row    { grid-template-columns: 1fr; }

  .metodo-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-2); }
  .metodo-btn  { padding: var(--space-3) var(--space-2); min-height: 64px; }

  .tipo-grid { gap: var(--space-1); }
  .tipo-opt  { min-width: 58px; padding: var(--space-2) var(--space-2); font-size: 11px; }

  .wiz-nav { flex-direction: column-reverse; }
  .wiz-nav button { width: 100%; }
  .p1-actions { flex-direction: column-reverse; }
  .p1-actions button { width: 100%; }

  .card { padding: var(--space-5); }
  .card--form { max-width: 100%; }
  .page-head h2 { font-size: var(--text-xl); }

  .chat-panel { width: calc(100vw - var(--space-6)); right: var(--space-3); }
  .chat-fab-wrap { right: var(--space-4); }

  .toast {
    right: var(--space-3);
    left: var(--space-3);
    width: auto;
    max-width: none;
    transform: translateY(-16px);
  }
  .toast--show { transform: translateY(0); }
}

@media (max-width: 480px) {
  .wp-label { display: none; }
  .wp-line  { width: 32px; }
  .ec__row--4 { grid-template-columns: 1fr; }
  .folio-inp  { padding-right: var(--space-3) !important; }
  .folio-badge { position: static; transform: none; display: inline-block; margin-top: var(--space-1); }
}

@media (max-width: 360px) {
  .metodo-grid { grid-template-columns: 1fr; }
}

@media print {
  body { background: white; }
  .topbar, .wizard-progress, .footer, .wiz-nav, .p3-controls,
  .chat-fab-wrap, .chat-panel, .modal-overlay { display: none !important; }
}

/* ─── PWA: INSTALL BUTTON ────────────────────────────────────── */
.btn-pwa-install {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0 var(--space-3);
  height: 32px;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  background: var(--green-500);
  color: #fff;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(139, 171, 10, 0.30);
  transition: background var(--transition-default), transform var(--transition-spring);
}
@media (hover: hover) {
  .btn-pwa-install:hover { background: var(--green-600); transform: translateY(-1px); }
}
.btn-pwa-install:active { transform: scale(0.96); }

/* ─── PWA: IOS INSTALL MODAL ─────────────────────────────────── */
.ios-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  pointer-events: none;
  transition: background var(--transition-default);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.ios-modal--open {
  background: rgba(0, 0, 0, 0.52);
  pointer-events: auto;
}
.ios-modal__box {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-6) var(--space-6) calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  position: relative;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.18);
}
.ios-modal--open .ios-modal__box {
  transform: translateY(0);
}
.ios-modal__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  background: var(--neutral-100);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 14px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}
.ios-modal__icon {
  font-size: 40px;
  text-align: center;
  margin-bottom: var(--space-3);
}
.ios-modal__title {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  text-align: center;
  margin-bottom: var(--space-4);
}
.ios-modal__steps {
  padding-left: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.ios-modal__steps li {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: var(--leading-normal);
}
.ios-modal__share-ico {
  display: inline-block;
  background: var(--green-100);
  color: var(--green-600);
  border-radius: var(--radius-sm);
  padding: 0 5px;
  font-style: normal;
}
.ios-modal__note {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-align: center;
  margin-top: var(--space-2);
}

/* ─── PWA: UPDATE BANNER ─────────────────────────────────────── */
.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  background: var(--green-800);
  color: #fff;
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  transform: translateY(-100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: 0 2px 12px rgba(0,0,0,0.22);
}
.update-banner--visible {
  transform: translateY(0);
}
.update-banner__msg {
  flex: 1;
  font-weight: var(--weight-semibold);
}
.update-banner__btn {
  padding: 4px 14px;
  background: #fff;
  color: var(--green-800);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  cursor: pointer;
  transition: background var(--transition-default);
}
@media (hover: hover) {
  .update-banner__btn:hover { background: var(--green-100); }
}
.update-banner__dismiss {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 16px;
  cursor: pointer;
  padding: 0 var(--space-1);
  line-height: 1;
}
@media (hover: hover) {
  .update-banner__dismiss:hover { color: #fff; }
}

/* ═══════════════════════════════════════════════════════════════
   VISTA FACTURAS — Navbar tabs + grid de proveedores
   ═══════════════════════════════════════════════════════════════ */

/* ─── App tabs (en el topbar) ────────────────────────────────── */
.app-tabs {
  display: flex;
  align-self: stretch;      /* se estira hasta la altura del topbar */
  align-items: stretch;     /* los hijos llenan esa altura */
  flex: 1;
  justify-content: center;
  gap: var(--space-1);
}

.app-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 var(--space-4);
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast);
  white-space: nowrap;
  border-radius: 0;
}
@media (hover: hover) {
  .app-tab:hover {
    color: var(--text-primary);
    background: var(--green-50);
  }
}
.app-tab--active {
  color: var(--green-600);
  border-bottom-color: var(--green-500);
  font-weight: var(--weight-semibold);
}

@media (max-width: 480px) {
  .app-tab-lbl { display: none; }
  .app-tab { padding: 0 var(--space-3); font-size: var(--text-base); }
}

/* ─── Vista contenedores ─────────────────────────────────────── */
#vista-facturas {
  min-height: 60vh;
}

/* ─── Facturas View shell ────────────────────────────────────── */
.fv {
  max-width: 1100px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4) var(--space-16);
}

.fv-head {
  text-align: center;
  margin-bottom: var(--space-6);
}
.fv-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}
.fv-sub {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-top: var(--space-2);
}

/* ─── Search ─────────────────────────────────────────────────── */
.fv-search-wrap {
  position: relative;
  margin-bottom: var(--space-4);
}
.fv-search-ico {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  pointer-events: none;
}
.fv-search-inp {
  width: 100%;
  padding: var(--space-3) var(--space-3) var(--space-3) 2.5rem;
  font-size: var(--text-base);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.fv-search-inp:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: var(--shadow-focus);
}

/* ─── Category tabs ──────────────────────────────────────────── */
.fv-cats {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-6);
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}
.fv-cats::-webkit-scrollbar { height: 4px; }
.fv-cats::-webkit-scrollbar-track { background: transparent; }
.fv-cats::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 99px; }

.fv-cat-btn {
  white-space: nowrap;
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-full);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
@media (hover: hover) {
  .fv-cat-btn:hover {
    border-color: var(--green-400);
    color: var(--text-primary);
  }
}
.fv-cat-btn--active {
  background: var(--green-500);
  color: #fff;
  border-color: var(--green-500);
  box-shadow: 0 2px 8px rgba(139,171,10,0.30);
}

/* ─── Providers grid ─────────────────────────────────────────── */
.fv-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}
@media (min-width: 540px)  { .fv-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 768px)  { .fv-grid { grid-template-columns: repeat(5, 1fr); gap: var(--space-4); } }
@media (min-width: 1024px) { .fv-grid { grid-template-columns: repeat(6, 1fr); } }

/* ─── Provider card ──────────────────────────────────────────── */
.fv-card {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition:
    transform var(--transition-default),
    box-shadow var(--transition-default),
    border-color var(--transition-default);
  user-select: none;
  -webkit-user-select: none;
}
@media (hover: hover) {
  .fv-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--green-300);
  }
}
.fv-card:active { transform: scale(0.96); }

.fv-fav {
  position: absolute;
  top: var(--space-1);
  right: var(--space-2);
  font-size: 13px;
  line-height: 1;
}

.fv-logo {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 0;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  background: linear-gradient(90deg,
    var(--neutral-100) 25%,
    var(--neutral-200) 50%,
    var(--neutral-100) 75%);
  background-size: 200% 100%;
  animation: fv-shimmer 1.4s infinite;
}
@keyframes fv-shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
.fv-card-img {
  max-width: 100%;
  max-height: 52px;
  object-fit: contain;
  display: block;
  transition: opacity 0.2s ease;
}
@media (min-width: 768px) {
  .fv-card-img { max-height: 68px; }
}

.fv-name {
  font-family: var(--font-heading);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-align: center;
  line-height: var(--leading-tight);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (min-width: 768px) {
  .fv-name { font-size: var(--text-sm); }
}

/* ─── Empty state ────────────────────────────────────────────── */
.fv-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-16) var(--space-4);
  color: var(--text-secondary);
}
.fv-empty-ico {
  display: block;
  font-size: 3rem;
  margin-bottom: var(--space-4);
}
.fv-empty h3 {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.fv-empty p {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-bottom: var(--space-4);
}
.fv-clear-btn {
  padding: var(--space-2) var(--space-5);
  background: var(--green-500);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  cursor: pointer;
  transition: background var(--transition-fast);
}
@media (hover: hover) {
  .fv-clear-btn:hover { background: var(--green-600); }
}

/* ═══════════════════════════════════════════════════════════════
   FASE 1 — Fixes UX/UI (auditoría Playwright 09/06/2026)
   Capa de overrides: responsive 344px, estados, contraste.
═══════════════════════════════════════════════════════════════ */

/* Header de card: en pantallas angostas el badge y el importe se
   encimaban — el lado izquierdo pasa a su propia fila completa. */
@media (max-width: 480px) {
  .ec__head        { flex-wrap: wrap; row-gap: var(--space-2); }
  .ec__head-left   { flex: 1 1 100%; }
  .ec__head-right  { margin-left: auto; }
}

/* FAB del asistente: en móvil tapaba controles del formulario.
   Más chico, sin etiqueta, y las páginas reservan espacio abajo. */
@media (max-width: 768px) {
  .chat-fab     { width: 56px; height: 56px; }
  .chat-fab-ico { width: 46px; height: 46px; }
  .wiz-page     { padding-bottom: calc(var(--space-16) + 64px); }
}
@media (max-width: 480px) {
  .chat-fab-lbl { display: none; }
}

/* Topbar móvil: el contador de costo IA es info de administrador */
@media (max-width: 640px) {
  .cost-display   { display: none; }
  .btn-reset-cost { display: none !important; }
}

/* Estado seleccionado también vía aria-pressed (paridad con la clase) */
.metodo-btn[aria-pressed="true"],
.tipo-opt[aria-pressed="true"] {
  border-color: var(--green-500);
}

/* Focus visible reforzado en controles de selección */
.metodo-btn:focus-visible,
.tipo-opt:focus-visible,
.app-tab:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-color: var(--green-500);
}

/* Touch targets: mínimo 44px en controles chicos de la card */
@media (pointer: coarse) {
  .ec__del, .ec__tog       { width: 44px; height: 44px; }
  .btn-folio-info          { min-width: 28px; min-height: 28px; }
  .slot__rm                { min-width: 32px; min-height: 32px; }
}

/* Botones de método de pago: feedback hover consistente */
@media (hover: hover) {
  .metodo-btn:hover { border-color: var(--green-400); background: var(--green-50); }
}

/* ═══════════════════════════════════════════════════════════════════
   LOGIN LOCAL (gate) + CHIP DE USUARIO + HISTORIAL
═══════════════════════════════════════════════════════════════════ */

/* ── Gate de login ── */
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--green-100), transparent 60%),
    var(--bg-app);
  overflow-y: auto;
}
.auth-gate[hidden] { display: none; }
body.auth-locked { overflow: hidden; }

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-8) var(--space-6) var(--space-6);
  margin: auto;
}

.auth-head { text-align: center; margin-bottom: var(--space-6); }
.auth-logo {
  height: 64px;
  width: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}
.auth-title {
  font-family: 'Playfair Display', serif;
  font-size: var(--text-2xl);
  color: var(--green-700);
  margin: var(--space-3) 0 var(--space-1);
}
.auth-sub { color: var(--text-secondary); font-size: var(--text-sm); margin: 0; }

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1);
  background: var(--green-50);
  border-radius: var(--radius-full);
  padding: 4px;
  margin-bottom: var(--space-6);
}
.auth-tab {
  border: none;
  background: transparent;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s ease;
}
.auth-tab--on {
  background: var(--bg-surface);
  color: var(--green-700);
  box-shadow: var(--shadow-sm);
}

.auth-form { display: flex; flex-direction: column; }
.auth-form[hidden] { display: none; }
.auth-lbl {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  margin-top: var(--space-3);
}
.auth-form .auth-lbl:first-child { margin-top: 0; }
.auth-inp {
  width: 100%;
  padding: var(--space-3);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  background: var(--bg-surface);
  color: var(--text-primary);
}
.auth-inp:focus { outline: none; border-color: var(--green-500); box-shadow: var(--shadow-focus); }

.auth-btn {
  margin-top: var(--space-5);
  padding: var(--space-3) var(--space-4);
  background: var(--green-500);
  color: var(--text-on-green);
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-green);
  transition: background .15s ease;
}
.auth-btn:hover { background: var(--green-600); }
.auth-btn:active { transform: translateY(1px); }

.auth-err {
  color: #C0392B;
  font-size: var(--text-sm);
  margin: var(--space-3) 0 0;
}
.auth-empty,
.auth-hint {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin: var(--space-3) 0 0;
  line-height: 1.5;
}
.auth-empty { text-align: center; }

/* ── Chip de usuario en la topbar ── */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--green-50);
  border: 1px solid var(--green-200);
  border-radius: var(--radius-full);
  padding: 3px 6px 3px 4px;
}
.user-chip-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--green-500);
  color: var(--text-on-green);
  font-weight: 700;
  font-size: var(--text-sm);
}
.user-chip-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--green-700);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-chip-logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--green-600);
  border-radius: 50%;
  cursor: pointer;
}
.user-chip-logout:hover { background: var(--green-100); color: var(--green-800); }

@media (max-width: 480px) {
  .user-chip-name { display: none; }
}

/* ── Vista Historial ── */
.hist-head { margin: var(--space-6) 0 var(--space-4); }
.hist-head h2 {
  font-family: var(--font-heading);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  margin: 0;
}
.hist-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}
.hist-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}
.hist-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-2);
}
.hist-month {
  font-weight: 700;
  color: var(--green-700);
  text-transform: capitalize;
}
.hist-date { font-size: var(--text-xs); color: var(--text-tertiary); }
.hist-card-total {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}
.hist-card-meta { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-1); }

.hist-card-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.hist-btn {
  flex: 1 1 auto;
  min-width: 72px;
  padding: var(--space-2) var(--space-3);
  border: 1.5px solid var(--border-default);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  cursor: pointer;
  transition: all .15s ease;
}
.hist-btn:hover { border-color: var(--green-400); background: var(--green-50); }
.hist-btn--primary {
  background: var(--green-500);
  border-color: var(--green-500);
  color: var(--text-on-green);
}
.hist-btn--primary:hover { background: var(--green-600); border-color: var(--green-600); }
.hist-btn--danger { color: #C0392B; }
.hist-btn--danger:hover { border-color: #E6A6A0; background: #FCEDEC; }

.hist-empty {
  text-align: center;
  color: var(--text-secondary);
  padding: var(--space-16) var(--space-4);
}
.hist-empty-ico { font-size: 3rem; margin-bottom: var(--space-3); }

/* ── Vista Reembolsos ── */
.reemb-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.reemb-kpi {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4) var(--space-5);
}
.reemb-kpi--ok  { border-left-color: var(--green-500); }
.reemb-kpi--due { border-left-color: #E08A2E; }
.reemb-kpi-lbl {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-tertiary);
}
.reemb-kpi-val {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}
.reemb-kpi--due .reemb-kpi-val { color: #C87A1E; }

.reemb-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}
.reemb-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}
.reemb-card-top .hist-date { margin-left: var(--space-2); }

.reemb-badge {
  flex-shrink: 0;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 700;
  border: 1px solid transparent;
}
.reemb-badge--pendiente { background: #FDF0E3; color: #A65D0B; border-color: #F0CFA6; }
.reemb-badge--parcial   { background: #E9F2FD; color: #1F5FA8; border-color: #B9D4F2; }
.reemb-badge--pagado    { background: var(--green-50); color: var(--green-700); border-color: var(--green-400); }

.reemb-card-nums { display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap; }
.reemb-pendiente {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}
.reemb-de { font-size: var(--text-sm); color: var(--text-secondary); }

.reemb-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--border-subtle);
  overflow: hidden;
}
.reemb-bar-fill {
  height: 100%;
  background: var(--green-500);
  border-radius: 999px;
  transition: width .25s ease;
}

.reemb-abonos { border-top: 1px solid var(--border-subtle); padding-top: var(--space-3); }
.reemb-abonos-title {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-tertiary);
}
.reemb-abonos-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); }
.reemb-abono-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--text-sm);
}
.reemb-abono-monto {
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}
.reemb-abono-meta { flex: 1; color: var(--text-secondary); font-size: var(--text-xs); }
.reemb-abono-del {
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: var(--text-lg);
  line-height: 1;
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
}
.reemb-abono-del:hover { color: #C0392B; background: #FCEDEC; }
.reemb-abono-empty { font-size: var(--text-sm); color: var(--text-tertiary); }

.reemb-add { flex: 0 0 auto; }
.reemb-modal-hint {
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════════════════════════
   MODO OSCURO (Apple-dark) + PULIDO + BOTÓN DE TEMA
   Activado por  <html data-theme="dark">  (ver js/theme.js)
═══════════════════════════════════════════════════════════════════ */

:root { color-scheme: light; }

[data-theme="dark"] {
  color-scheme: dark;

  /* Superficies — negro cálido escalonado, estilo iOS */
  --bg-app:         #0F1311;
  --bg-surface:     #181D1A;
  --bg-overlay:     rgba(0, 0, 0, 0.66);

  /* Texto */
  --text-primary:   #EDF1EC;
  --text-secondary: #B2BBB2;
  --text-tertiary:  #828B82;

  /* Bordes — líneas hairline translúcidas */
  --border-subtle:  rgba(255, 255, 255, 0.08);
  --border-default: rgba(255, 255, 255, 0.14);
  --border-strong:  rgba(255, 255, 255, 0.26);

  /* Escala neutra invertida — para componentes que usan --neutral-* crudo
     (botones de método, cards, chips, etc.) */
  --neutral-50:  #181D1A;
  --neutral-100: #1F2521;
  --neutral-200: #262D28;
  --neutral-300: #333B35;
  --neutral-400: #5A6359;
  --neutral-500: #828B82;
  --neutral-600: #AEB6AD;
  --neutral-700: #CBD2C9;
  --neutral-800: #EDF1EC;
  --neutral-900: #F5F8F4;

  /* Verde: rellenos (500/600) intactos para texto blanco;
     tintes y "texto verde" se adaptan a fondo oscuro */
  --green-50:  #16211A;
  --green-100: #1B2A20;
  --green-200: #26392D;
  --green-300: #38634A;
  --green-400: #579D74;
  --green-700: #8AD2A0;   /* era texto verde oscuro → ahora claro sobre fondo oscuro */

  /* Tintes de estado en oscuro */
  --success-bg: #16211A;
  --warning-bg: #2A2012;
  --error-bg:   #2A1715;
  --info-bg:    #141E2A;
  --gold-bg:    #231D10;

  /* Sombras — negras y profundas + hairline */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.40);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.40), 0 2px 8px 0 rgba(0, 0, 0, 0.36);
  --shadow-md: 0 2px 8px 0 rgba(0, 0, 0, 0.44), 0 12px 28px -4px rgba(0, 0, 0, 0.50);
  --shadow-lg: 0 8px 24px -4px rgba(0, 0, 0, 0.55), 0 24px 48px -8px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 12px 32px -6px rgba(0, 0, 0, 0.60), 0 32px 64px -12px rgba(0, 0, 0, 0.55);
  --shadow-focus: 0 0 0 3px rgba(100, 175, 130, 0.40);
}

/* Cristal esmerilado de la topbar en oscuro */
[data-theme="dark"] .topbar {
  background: rgba(18, 22, 20, 0.72);
  border-bottom-color: var(--border-subtle);
}
[data-theme="dark"] .topbar--scrolled { background: rgba(18, 22, 20, 0.88); }

/* Parches puntuales de blancos literales */
[data-theme="dark"] .update-banner__btn { background: var(--bg-surface); color: var(--text-primary); }

/* Toasts: en oscuro --neutral-800 se vuelve casi blanco, así que el texto
   blanco fijo quedaba ilegible. Forzamos superficie oscura elevada y
   conservamos el acento de color en el borde izquierdo. */
[data-theme="dark"] .toast,
[data-theme="dark"] .toast--success,
[data-theme="dark"] .toast--error,
[data-theme="dark"] .toast--info,
[data-theme="dark"] .toast--warning {
  background: #202622;
  color: var(--text-primary);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

/* Inputs/áreas con un punto más de elevación que el fondo */
[data-theme="dark"] .finp,
[data-theme="dark"] .auth-inp,
[data-theme="dark"] textarea,
[data-theme="dark"] select { background: #1F2521; }

/* ─── Botón de tema (sol/luna) ─────────────────────────────────── */
.btn-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.btn-theme:hover { background: var(--green-50); color: var(--green-600); }
.btn-theme:active { transform: scale(0.92); }

/* ═══════════════════════════════════════════════════════════════════
   PULIDO ESTILO APPLE
═══════════════════════════════════════════════════════════════════ */

/* Safe-area para la muesca / barra de estado en PWA y APK */
.topbar {
  height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(var(--space-6), env(safe-area-inset-left, 0px));
  padding-right: max(var(--space-6), env(safe-area-inset-right, 0px));
}

/* Títulos con tracking apretado (look SF Display) */
.page-head h2,
.auth-title,
.hist-head h2 { letter-spacing: var(--tracking-tight); }

/* Respuesta táctil: micro-escala al presionar en botones de acción */
.btn-primary:active,
.btn-secondary:active,
.btn-add-expense:active,
.metodo-btn:active,
.app-tab:active,
.hist-btn:active { transform: scale(0.98); }

/* Selección estilo Apple */
::selection { background: rgba(100, 175, 130, 0.30); }

/* Transición suave global al cambiar de tema (no en el primer pintado) */
.theme-anim,
.theme-anim *,
.theme-anim *::before,
.theme-anim *::after {
  transition: background-color 280ms ease, border-color 280ms ease, color 220ms ease, box-shadow 280ms ease !important;
}

/* ═══════════════════════════════════════════════════════════════════
   SELECTOR DE TARJETAS DE LA EMPRESA
═══════════════════════════════════════════════════════════════════ */
.card-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}
@media (min-width: 560px) {
  .card-picker { grid-template-columns: repeat(3, 1fr); }
}

.card-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  background: var(--bg-surface);
  border: 2px solid var(--border-default);
  border-radius: var(--radius-lg);
  transition:
    border-color var(--transition-default),
    box-shadow var(--transition-default),
    transform var(--transition-spring);
}
.card-opt-img {
  width: 100%;
  aspect-ratio: 1.586;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}
.card-opt-lbl {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  text-align: center;
  line-height: var(--leading-snug);
}
.card-opt-lbl strong {
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-weight: var(--weight-bold);
}

@media (hover: hover) {
  .card-opt:hover { border-color: var(--green-400); transform: translateY(-2px); box-shadow: var(--shadow-md); }
}
.card-opt:active { transform: scale(0.98); }

.card-opt--on {
  border-color: var(--green-500);
  box-shadow: var(--shadow-green);
}
.card-opt--on .card-opt-lbl,
.card-opt--on .card-opt-lbl strong { color: var(--green-600); }

/* Opción manual (otra tarjeta) */
.card-manual {
  margin-top: var(--space-4);
}
.card-manual > summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--green-600);
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
}
.card-manual > summary::-webkit-details-marker { display: none; }
.card-manual > summary::before {
  content: '+';
  font-weight: var(--weight-bold);
  font-size: var(--text-base);
}
.card-manual[open] > summary::before { content: '−'; }
.card-manual > summary:hover { color: var(--green-700); }
.card-manual .finp { margin-top: var(--space-3); }

/* ── Vista Reembolsos — modo oscuro ──
   Los badges y KPIs usan colores ámbar/azul fijos (no hay token para ellos);
   aquí se rebajan a versiones translúcidas legibles sobre fondo oscuro. */
[data-theme="dark"] .reemb-badge--pendiente { background: rgba(224,138,46,.16); color: #E8A65A; border-color: rgba(224,138,46,.38); }
[data-theme="dark"] .reemb-badge--parcial   { background: rgba(90,150,225,.16); color: #86B4EC; border-color: rgba(90,150,225,.38); }
[data-theme="dark"] .reemb-kpi--due         { border-left-color: #E8A65A; }
[data-theme="dark"] .reemb-kpi--due .reemb-kpi-val { color: #E8A65A; }
[data-theme="dark"] .reemb-abono-del:hover  { color: #F09A90; background: rgba(240,154,144,.14); }
.reemb-excedente { font-size: var(--text-xs); font-weight: 700; color: #C87A1E; width: 100%; }
[data-theme="dark"] .reemb-excedente { color: #E8A65A; }

/* ── Botón manual de descarga (último recurso de PdfDownload) ──
   Aparece solo si ningún método automático funcionó. El clic del usuario
   sobre un <a> real es lo único que ningún navegador bloquea. */
.pdf-manual-link {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: calc(100vw - 2 * var(--space-4));
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.18));
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.pdf-manual-btn {
  flex-shrink: 0;
  padding: var(--space-2) var(--space-4);
  background: var(--green-500);
  color: var(--text-on-green);
  border-radius: var(--radius-md);
  font-weight: 700;
  text-decoration: none;
}
.pdf-manual-btn:hover { background: var(--green-600); }
.pdf-manual-close {
  flex-shrink: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: var(--text-xl);
  line-height: 1;
  padding: 0 var(--space-1);
}

/* Diagnóstico del historial — discreto, no compite con las acciones reales */
.hist-diag {
  display: flex;
  justify-content: center;
  margin-top: var(--space-6);
}
.hist-diag-btn {
  width: auto;
  flex: 0 0 auto;
  padding-inline: var(--space-6);
  font-size: 0.8rem;
  opacity: 0.7;
}
.hist-diag-btn:hover { opacity: 1; }

/* Ayuda bajo el selector de método de pago */
.fhint { margin: calc(var(--space-2, 8px) * -1) 0 var(--space-3, 12px); font-size: 0.85rem; line-height: 1.35; color: var(--text-2, #5b6b5b); }
.fhint[hidden] { display: none !important; }
