/* =========================================================
   FinzApp — hoja de estilos
   Mobile-first: los estilos base son para celular; las
   media queries (min-width) van agregando/ajustando para
   tablet y escritorio.
   ========================================================= */

:root{
  --purple-500:#6C5CE7;
  --purple-400:#8B7CF6;
  --purple-50:#EFECFE;
  --indigo-500:#6366F1;
  --indigo-400:#7C6FF0;
  --green-500:#10B981;
  --green-400:#34D399;
  --green-50:#E7F9F1;
  --red-500:#EF4444;
  --red-400:#F87171;
  --red-50:#FDECEC;
  --amber-500:#F59E0B;
  --amber-400:#FBBF24;
  --amber-50:#FFF6E3;

  --bg:#F0F2F5;
  --surface:#FFFFFF;
  --surface-alt:#F8FAFC;
  --hover-tint:#F5F6F8;
  --border:#EEF0F4;

  --text:#0F1117;
  --text-secondary:#374151;
  --text-tertiary:#68717F;
  --text-muted:#A8B0BF;
  --text-soft:#A8B0BF;

  --radius-lg:22px;
  --radius-md:16px;
  --radius-sm:12px;

  --shadow-card:0 2px 10px rgba(20,20,43,0.06);
  --shadow-pop:0 20px 50px rgba(20,20,43,0.18);

  --font: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'DM Mono', ui-monospace, "SF Mono", Menlo, monospace;

  color-scheme: light;
}

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

html,body{
  margin:0;
  padding:0;
  background:var(--bg);
  color:var(--text);
  font-family:var(--font);
  -webkit-font-smoothing:antialiased;
  height:100%;
}

body{
  min-height:100dvh;
  overscroll-behavior-y:none;
}

/* el atributo hidden debe ganar siempre, sin importar la especificidad
   de otras reglas (p.ej. utilidades display:flex en el mismo elemento) */
[hidden]{ display:none !important; }

h1,h2,h3,p{ margin:0; }

button{ font-family:inherit; }

input{ font-family:inherit; }

.avatar{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:38px;height:38px;
  border-radius:12px;
  background:linear-gradient(135deg,var(--purple-400),var(--purple-500));
  color:#fff;
  font-weight:600;
  font-size:15px;
  flex-shrink:0;
}

/* ---------- inputs / botones reutilizables ---------- */

.input{
  width:100%;
  background:var(--surface-alt);
  border:1.5px solid transparent;
  border-radius:var(--radius-sm);
  padding:14px 16px;
  font-size:16px;
  color:var(--text);
  outline:none;
  transition:border-color .15s ease, background .15s ease;
}
.input::placeholder{ color:var(--text-muted); }
.input:focus{ border-color:var(--purple-400); background:var(--surface); }
.input-code{ text-transform:uppercase; letter-spacing:2px; text-align:center; font-weight:700; }

.password-field{ position:relative; }
.password-field .input{ padding-right:46px; }
.password-toggle{
  position:absolute;
  right:4px; top:50%;
  transform:translateY(-50%);
  width:34px; height:34px;
  display:flex; align-items:center; justify-content:center;
  background:none; border:none;
  color:var(--text-muted);
  cursor:pointer;
  border-radius:999px;
}
.password-toggle:hover{ background:var(--hover-tint); color:var(--text-tertiary); }

.btn{
  width:100%;
  border:none;
  border-radius:var(--radius-sm);
  padding:15px 18px;
  font-size:15.5px;
  font-weight:700;
  cursor:pointer;
  transition:transform .12s ease, filter .15s ease, opacity .15s ease;
  -webkit-tap-highlight-color:transparent;
}
.btn:active{ transform:scale(0.98); }
.btn:disabled{ opacity:.45; cursor:not-allowed; }
.btn:disabled:active{ transform:none; }

.btn-primary{
  background:linear-gradient(135deg,var(--purple-400),var(--purple-500));
  color:#fff;
  box-shadow:0 8px 20px rgba(108,92,231,0.32);
}
.btn-primary:hover:not(:disabled){ filter:brightness(1.05); }

.btn-secondary{
  background:var(--surface-alt);
  color:var(--text);
}
.btn-secondary:hover{ background:var(--hover-tint); }

.btn-success{
  background:linear-gradient(135deg,var(--green-400),var(--green-500));
  color:#fff;
  box-shadow:0 8px 20px rgba(16,185,129,0.28);
}
.btn-danger-solid{
  background:linear-gradient(135deg,var(--red-400),var(--red-500));
  color:#fff;
  box-shadow:0 8px 20px rgba(239,68,68,0.28);
}
.btn-amber{
  background:linear-gradient(135deg,var(--amber-400),var(--amber-500));
  color:#fff;
  box-shadow:0 8px 20px rgba(245,158,11,0.28);
}
.btn-indigo{
  background:linear-gradient(135deg,var(--indigo-400),var(--indigo-500));
  color:#fff;
  box-shadow:0 8px 20px rgba(99,102,241,0.28);
}
.btn-danger-outline{
  background:var(--red-50);
  border:1.5px solid #fbd0d0;
  color:var(--red-500);
}
.btn-danger-outline:hover{ background:#fddede; }

.btn-pill{
  width:auto;
  padding:10px 16px;
  border-radius:999px;
  font-size:13.5px;
}

.btn-link{
  width:100%;
  background:none;
  border:none;
  color:var(--text-tertiary);
  font-size:14px;
  font-weight:500;
  padding:10px;
  cursor:pointer;
}
.btn-link:hover{ color:var(--purple-500); }

.btn-danger{
  color:var(--red-500);
}

.icon-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:30px;height:30px;
  border-radius:999px;
  border:none;
  background:var(--surface-alt);
  color:var(--text-tertiary);
  cursor:pointer;
  flex-shrink:0;
  transition:background .15s ease, color .15s ease;
}
.icon-btn:hover{ background:var(--hover-tint); }
.icon-btn.confirm{ background:var(--green-50); color:var(--green-500); }
.icon-btn.confirm:hover{ background:#d3f5e6; }
.icon-btn.danger{ background:var(--red-50); color:var(--red-500); }
.icon-btn.danger:hover{ background:#fddede; }
.icon-btn.add-tpl.theme-amber{ background:var(--amber-500); color:#fff; }
.icon-btn.add-tpl.theme-amber:hover{ background:#dc8a09; }
.icon-btn.add-tpl.theme-indigo{ background:var(--indigo-500); color:#fff; }
.icon-btn.add-tpl.theme-indigo:hover{ background:#5254d6; }

/* =========================================================
   ONBOARDING
   ========================================================= */

.setup-screen{
  min-height:100dvh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px 18px;
  background:
    radial-gradient(circle at 15% 10%, #efecfe 0%, transparent 45%),
    radial-gradient(circle at 90% 85%, #e7f9f1 0%, transparent 40%),
    var(--bg);
}

.setup-card{
  width:100%;
  max-width:420px;
  background:var(--surface);
  border-radius:24px;
  padding:32px 26px;
  box-shadow:var(--shadow-card);
}

.setup-icon{
  width:52px;height:52px;
  border-radius:16px;
  background:linear-gradient(135deg,var(--purple-400),var(--purple-500));
  display:flex;align-items:center;justify-content:center;
  margin-bottom:20px;
}

.setup-step h1{
  font-size:24px;
  font-weight:700;
  letter-spacing:-0.3px;
}
.wave{ display:inline-block; animation:wave 1.6s ease infinite; transform-origin:70% 70%; }
@keyframes wave{
  0%,60%,100%{ transform:rotate(0); }
  10%{ transform:rotate(14deg); }
  20%{ transform:rotate(-8deg); }
  30%{ transform:rotate(14deg); }
  40%{ transform:rotate(-4deg); }
}

.setup-sub{
  color:var(--text-tertiary);
  font-size:12px;
  font-weight:400;
  margin-top:6px;
  margin-bottom:22px;
  line-height:1.5;
}

.setup-step .input{ margin-bottom:14px; }
.setup-step .btn + .btn{ margin-top:10px; }

.join-panel{
  margin-top:16px;
  padding-top:16px;
  border-top:1px solid var(--border);
}
.join-panel .input{ margin-bottom:12px; }
.field-error{
  color:var(--red-500);
  font-size:13px;
  margin-top:10px;
  text-align:center;
}

/* =========================================================
   LAYOUT PRINCIPAL
   ========================================================= */

#view-main{
  display:flex;
  min-height:100dvh;
}

.main-col{
  flex:1;
  min-width:0;
  display:flex;
  flex-direction:column;
}

.main-content{
  flex:1;
  padding:18px 16px calc(96px + env(safe-area-inset-bottom));
  max-width:640px;
  width:100%;
  margin:0 auto;
}

/* ---------- barra superior con logo (móvil) ---------- */

.mobile-topbar{
  display:flex;
  align-items:center;
  gap:8px;
  padding:calc(14px + env(safe-area-inset-top)) 16px 10px;
  font-weight:700;
  font-size:15px;
  color:var(--text);
}
.mobile-topbar .brand-icon{
  width:22px;
  color:var(--purple-500);
  display:flex;
  align-items:center;
}
.mobile-topbar .brand-icon svg{ display:block; }

/* ---------- barra inferior (móvil) ---------- */

.bottom-nav{
  position:fixed;
  left:0;right:0;bottom:0;
  display:flex;
  background:var(--surface);
  border-top:1px solid var(--border);
  padding:8px 4px calc(8px + env(safe-area-inset-bottom));
  z-index:40;
}

.nav-item{
  flex:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:3px;
  background:none;
  border:none;
  padding:6px 2px;
  color:var(--text-muted);
  cursor:pointer;
  font-size:9px;
  font-weight:400;
}
.nav-item svg{ width:22px; height:22px; }
.nav-item.active{ color:var(--purple-500); font-weight:600; }
.nav-item .nav-underline{
  display:none;
}

/* ---------- sidebar (escritorio) ---------- */

.sidebar{
  display:none;
}

/* =========================================================
   TARJETAS Y COMPONENTES COMUNES
   ========================================================= */

.page-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  margin-bottom:18px;
}
.page-eyebrow{
  color:var(--text-muted);
  font-size:11px;
  font-weight:600;
  letter-spacing:0.08em;
  text-transform:uppercase;
}
.page-title{
  font-size:24px;
  font-weight:700;
  letter-spacing:-0.3px;
  margin-top:2px;
}

.home-topbar{
  display:flex;
  align-items:center;
  gap:10px;
}
.sync-dot{
  width:22px;height:22px;
  display:flex;align-items:center;justify-content:center;
}
.sync-dot.ok svg{ color:var(--green-500); }
.sync-dot.err svg{ color:var(--red-500); }
.sync-dot.busy svg{ color:var(--amber-500); animation:spin 1.1s linear infinite; }
@keyframes spin{ to{ transform:rotate(360deg); } }

.card{
  background:var(--surface);
  border-radius:var(--radius-lg);
  padding:18px;
  box-shadow:var(--shadow-card);
  margin-bottom:14px;
}

.card-row{
  display:flex;
  gap:12px;
}

/* botones grandes de acción (Agregar Ingreso / Egreso) */
.action-tiles{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
  margin-bottom:14px;
}
.action-tile{
  border:none;
  border-radius:var(--radius-lg);
  padding:18px 16px;
  text-align:left;
  cursor:pointer;
  color:#fff;
  display:flex;
  flex-direction:column;
  gap:22px;
  transition:transform .12s ease, filter .15s ease;
}
.action-tile:active{ transform:scale(0.97); }
.action-tile.income{ background:linear-gradient(135deg,var(--green-400),var(--green-500)); box-shadow:0 10px 24px rgba(16,185,129,0.30); }
.action-tile.expense{ background:linear-gradient(135deg,var(--red-400),var(--red-500)); box-shadow:0 10px 24px rgba(239,68,68,0.30); }
.action-tile .tile-icon{
  width:34px;height:34px;
  border-radius:10px;
  background:rgba(255,255,255,0.25);
  display:flex;align-items:center;justify-content:center;
}
.action-tile .tile-title{ font-weight:600; font-size:14px; }
.action-tile .tile-sub{ font-size:12px; font-weight:400; opacity:0.9; margin-top:2px; }

/* saldo disponible */
.balance-split{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
  margin-bottom:12px;
}
.balance-mini{
  background:var(--surface-alt);
  border-radius:var(--radius-md);
  padding:12px 14px;
}
.balance-mini .mini-label{
  display:flex;align-items:center;gap:6px;
  font-size:11px;
  color:var(--text-muted);
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.08em;
}
.balance-mini .mini-value{
  font-family:var(--font-mono);
  font-size:14px;
  font-weight:500;
  margin-top:6px;
}
.balance-mini .mini-value.card-account{ color:var(--indigo-500); }
.balance-mini .mini-value.cash-account{ color:var(--amber-500); }

.balance-total{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding-top:12px;
  border-top:1px solid var(--border);
}
.balance-total .label{
  font-size:11px;
  color:var(--text-muted);
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.08em;
}
.balance-total .value{ font-family:var(--font-mono); font-size:28px; font-weight:600; }
.value.positive{ color:var(--green-500); }
.value.negative{ color:var(--red-500); }
.value.neutral{ color:var(--text); }

.stat-card .stat-label{
  font-size:11px;
  color:var(--text-muted);
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.08em;
}
.stat-card .stat-value{
  font-family:var(--font-mono);
  font-size:28px;
  font-weight:600;
  margin-top:6px;
}

.stat-card-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
.stat-card-main{ flex:1; min-width:0; }
.stat-card-breakdown{
  display:flex;
  flex-direction:column;
  align-items:flex-end;
  gap:6px;
  flex-shrink:0;
}
.stat-line{
  font-family:var(--font-mono);
  font-size:13px;
  font-weight:500;
  white-space:nowrap;
}
.stat-line .lbl{
  font-family:var(--font);
  font-size:11px;
  font-weight:400;
  color:var(--text-muted);
  margin-left:2px;
}
.stat-line.in{ color:var(--green-500); }
.stat-line.out{ color:var(--red-500); }

.card-label-sm{
  font-size:11px;
  color:var(--text-muted);
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.08em;
  margin-bottom:2px;
}

.section-title{
  font-size:13px;
  font-weight:600;
  margin-bottom:2px;
}

/* filas de movimientos */
.tx-list{ display:flex; flex-direction:column; }
.tx-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 0;
  border-bottom:1px solid var(--border);
}
.tx-row:last-child{ border-bottom:none; padding-bottom:0; }
.tx-row:first-child{ padding-top:4px; }
.tx-icon{
  width:42px;height:42px;
  border-radius:13px;
  display:flex;align-items:center;justify-content:center;
  font-size:19px;
  flex-shrink:0;
  background:var(--surface-alt);
}
.tx-icon.theme-amber{ background:var(--amber-50); color:var(--amber-500); }
.tx-icon.theme-indigo{ background:var(--purple-50); color:var(--indigo-500); }
.tx-icon.theme-green{ background:var(--green-50); color:var(--green-500); }
.tx-icon.theme-red{ background:var(--red-50); color:var(--red-500); }
.tx-body{ flex:1; min-width:0; }
.tx-title{
  font-weight:500;
  font-size:14px;
  display:flex;
  align-items:flex-start;
  flex-wrap:wrap;
  gap:4px 6px;
  min-width:0;
}
.tx-title-text{
  overflow-wrap:anywhere;
  min-width:0;
}
.tx-meta{
  font-size:12px;
  font-weight:400;
  color:var(--text-tertiary);
  margin-top:2px;
  overflow-wrap:anywhere;
}
.tx-amount{
  font-family:var(--font-mono);
  font-weight:500;
  font-size:14px;
  flex-shrink:0;
  text-align:right;
}
.tx-amount.positive{ color:var(--green-500); }
.tx-amount.negative{ color:var(--red-500); }
.tx-actions{
  display:flex;
  align-items:center;
  gap:6px;
  flex-shrink:0;
}

.tag{
  display:inline-flex;
  align-items:center;
  padding:2px 7px;
  border-radius:999px;
  font-size:10px;
  font-weight:600;
  text-transform:uppercase;
  letter-spacing:0.08em;
  flex-shrink:0;
}
.tag-recurrent{ background:var(--purple-50); color:var(--purple-500); }
.tag-edited{ background:var(--surface-alt); color:var(--text-tertiary); }
.tag-author{ color:#fff; }

.tx-row{ cursor:pointer; }
.tx-row:hover{ background:var(--hover-tint); border-radius:12px; }

.empty-state{
  text-align:center;
  padding:30px 10px;
  color:var(--text-muted);
  font-size:14px;
  font-weight:400;
}
.empty-state .empty-emoji{ font-size:32px; display:block; margin-bottom:8px; }

/* vencimientos */
.due-item{
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 0;
}
.due-badge{
  width:36px;height:36px;
  border-radius:11px;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
}
.due-badge.pay{ background:var(--purple-50); color:var(--purple-500); }
.due-badge.collect{ background:var(--amber-50); color:var(--amber-500); }
.due-title{ font-weight:500; font-size:14px; }
.due-date{ font-size:12px; font-weight:400; color:var(--text-tertiary); }
.due-date.urgent{ color:var(--red-500); font-weight:500; }
.due-amount{ margin-left:auto; font-family:var(--font-mono); font-weight:500; font-size:14px; }
.due-amount.pay{ color:var(--indigo-500); }
.due-amount.collect{ color:var(--amber-500); }
.due-group-label{
  font-size:11px;
  font-weight:600;
  letter-spacing:0.08em;
  color:var(--text-muted);
  text-transform:uppercase;
  margin:12px 0 2px;
}
.due-group-label:first-child{ margin-top:0; }

/* =========================================================
   POR COBRAR / POR PAGAR
   ========================================================= */

.month-strip{
  display:flex;
  gap:8px;
  overflow-x:auto;
  padding-bottom:4px;
  margin-bottom:14px;
  scrollbar-width:none;
}
.month-strip::-webkit-scrollbar{ display:none; }
.month-chip{
  flex:0 0 auto;
  min-width:76px;
  background:var(--surface);
  border:1.5px solid var(--border);
  border-radius:var(--radius-md);
  padding:10px 8px;
  text-align:center;
  cursor:pointer;
  transition:background .15s ease,border-color .15s ease;
}
.month-chip .m-label{
  font-size:11px;
  font-weight:600;
  letter-spacing:0.08em;
  color:var(--text-muted);
  text-transform:uppercase;
}
.month-chip .m-value{
  font-family:var(--font-mono);
  font-size:13px;
  font-weight:500;
  margin-top:3px;
  color:var(--text-tertiary);
}
.month-chip .m-count{
  font-size:12px;
  font-weight:400;
  color:var(--text-muted);
  margin-top:1px;
}
.month-chip.active{
  border-color:transparent;
  color:#fff;
}
.month-chip.active.theme-amber{ background:linear-gradient(135deg,var(--amber-400),var(--amber-500)); }
.month-chip.active.theme-indigo{ background:linear-gradient(135deg,var(--indigo-400),var(--indigo-500)); }
.month-chip.active .m-label,
.month-chip.active .m-value,
.month-chip.active .m-count{ color:#fff; }

.total-month-card{
  margin-bottom:14px;
}
.total-month-card .card-label-sm{ margin-bottom:4px; }
.total-month-card .total-value{
  font-family:var(--font-mono);
  font-size:28px;
  font-weight:600;
}
.total-value.theme-amber{ color:var(--amber-500); }
.total-value.theme-indigo{ color:var(--indigo-500); }

.recurring-panel{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:4px;
}
.recurring-panel .section-title{ display:flex; align-items:center; gap:8px; }
.recurring-count{
  font-size:12px;
  color:var(--text-tertiary);
  font-weight:400;
}
.recurring-template-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:10px 0;
  border-bottom:1px solid var(--border);
}
.recurring-template-row:last-child{ border-bottom:none; }

/* =========================================================
   REPORTE
   ========================================================= */

.segmented{
  display:flex;
  background:var(--surface-alt);
  border-radius:var(--radius-sm);
  padding:4px;
  margin-bottom:14px;
}
.segmented button{
  flex:1;
  border:none;
  background:none;
  padding:10px 6px;
  border-radius:10px;
  font-weight:500;
  font-size:13.5px;
  color:var(--text-tertiary);
  cursor:pointer;
}
.segmented button.active{
  background:var(--surface);
  color:var(--text);
  box-shadow:0 2px 6px rgba(20,20,43,0.08);
}
#direction-toggle button[data-direction="add"].active{
  background:var(--green-50);
  color:var(--green-500);
}
#direction-toggle button[data-direction="remove"].active{
  background:var(--red-50);
  color:var(--red-500);
}

.period-nav{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:14px;
}
.period-nav .period-label{
  font-weight:600;
  font-size:14px;
  text-align:center;
  flex:1;
}
.period-nav button{
  width:34px;height:34px;
  border-radius:999px;
  border:none;
  background:var(--surface);
  box-shadow:var(--shadow-card);
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;
  color:var(--text-tertiary);
  flex-shrink:0;
}

.summary-tiles{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
  margin-bottom:14px;
}
.summary-tile{
  background:var(--surface);
  border-radius:var(--radius-md);
  padding:12px 10px;
  box-shadow:var(--shadow-card);
  text-align:left;
}
.summary-tile .stl-label{
  font-size:11px;
  color:var(--text-muted);
  font-weight:600;
  letter-spacing:0.08em;
  text-transform:uppercase;
}
.summary-tile .stl-value{
  font-family:var(--font-mono);
  font-size:13px;
  font-weight:500;
  margin-top:4px;
}

.chart-wrap{
  display:flex;
  align-items:flex-end;
  gap:2px;
  height:170px;
  padding:6px 2px 0;
}
.chart-axis{
  display:flex;
  flex-direction:column;
  justify-content:space-between;
  height:100%;
  padding-bottom:22px;
  font-family:var(--font-mono);
  font-size:10px;
  font-weight:500;
  color:var(--text-muted);
  text-align:right;
  margin-right:6px;
}
.chart-bars{
  flex:1;
  display:flex;
  align-items:flex-end;
  gap:14px;
  height:100%;
  overflow-x:auto;
}
.chart-cat{
  display:flex;
  flex-direction:column;
  align-items:center;
  min-width:44px;
  height:100%;
  flex-shrink:0;
}
.chart-cat-bars{
  flex:1;
  display:flex;
  align-items:flex-end;
  gap:4px;
}
.chart-bar{
  width:12px;
  border-radius:4px 4px 0 0;
  min-height:2px;
  cursor:default;
  transition:opacity .15s ease;
}
.chart-bar.in{ background:linear-gradient(180deg,var(--green-400),var(--green-500)); }
.chart-bar.out{ background:linear-gradient(180deg,var(--indigo-400),var(--indigo-500)); }
.chart-bar:hover{ opacity:0.75; }
.chart-cat-label{
  font-size:11px;
  color:var(--text-tertiary);
  font-weight:400;
  margin-top:6px;
  max-width:56px;
  text-align:center;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

/* =========================================================
   AHORRO
   ========================================================= */

.savings-hero{
  background:linear-gradient(135deg,var(--amber-400),var(--amber-500));
  border-radius:var(--radius-lg);
  padding:20px;
  color:#fff;
  margin-bottom:14px;
}
.savings-hero .card-label-sm{ color:rgba(255,255,255,0.85); }
.savings-hero .total-value{ font-family:var(--font-mono); font-size:32px; font-weight:600; color:#fff; margin:4px 0 14px; }
.savings-hero .split-row{ display:flex; gap:24px; }
.savings-hero .split-item .lbl{ font-size:11px; opacity:0.85; text-transform:uppercase; font-weight:600; letter-spacing:0.08em; }
.savings-hero .split-item .val{ font-family:var(--font-mono); font-size:13px; font-weight:500; margin-top:2px; }

.goal-card{ margin-bottom:14px; cursor:pointer; transition:box-shadow .15s ease, transform .12s ease; }
.goal-card:hover{ box-shadow:0 6px 18px rgba(20,20,43,0.10); }
.goal-card:active{ transform:scale(0.995); }
.goal-head{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:12px;
}
.goal-emoji{
  width:44px;height:44px;
  border-radius:13px;
  background:var(--amber-50);
  display:flex;align-items:center;justify-content:center;
  font-size:20px;
  flex-shrink:0;
}
.goal-name{ font-weight:500; font-size:14px; }
.goal-meta{ font-size:12px; font-weight:400; color:var(--text-tertiary); margin-top:1px; }
.goal-amounts{
  margin-left:auto;
  text-align:right;
  flex-shrink:0;
}
.goal-amounts .cur{ font-family:var(--font-mono); font-weight:500; font-size:14px; color:var(--amber-500); }
.goal-amounts .pct{ font-size:12px; font-weight:400; color:var(--text-tertiary); }
.progress-track{
  height:8px;
  background:var(--surface-alt);
  border-radius:999px;
  overflow:hidden;
  margin-bottom:14px;
}
.progress-fill{
  height:100%;
  border-radius:999px;
  background:linear-gradient(90deg,var(--amber-400),var(--amber-500));
  transition:width .3s ease;
}
.progress-fill.complete{ background:linear-gradient(90deg,var(--green-400),var(--green-500)); }

.deposit-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 6px;
  margin:0 -6px;
  border-top:1px solid var(--border);
  border-radius:10px;
  cursor:pointer;
}
.deposit-row:hover{ background:var(--hover-tint); }
.deposit-row .dep-date{ font-size:12px; font-weight:400; color:var(--text-tertiary); flex:1; min-width:0; overflow-wrap:anywhere; }
.deposit-row .dep-amount{ font-family:var(--font-mono); font-weight:500; font-size:14px; color:var(--amber-500); flex-shrink:0; }
.deposit-row .dep-amount.withdraw{ color:var(--red-500); }

/* =========================================================
   CUENTA
   ========================================================= */

.profile-hero{
  background:linear-gradient(135deg,var(--purple-400),var(--purple-500));
  border-radius:var(--radius-lg);
  padding:20px;
  color:#fff;
  margin-bottom:14px;
}
.profile-hero-top{
  display:flex;
  align-items:center;
  gap:12px;
  margin-bottom:18px;
}
.profile-hero .avatar{
  width:46px;height:46px;
  background:rgba(255,255,255,0.22);
  font-size:17px;
}

.avatar-sm{
  width:24px;height:24px;
  border-radius:8px;
  font-size:10px;
  font-weight:600;
}
.avatar-stack{ display:flex; align-items:center; }
.avatar-stack .avatar-sm{ border:2px solid var(--surface); }
.avatar-stack .avatar-sm + .avatar-sm{ margin-left:-8px; }
.profile-hero-name{ font-weight:500; font-size:16px; }
.profile-hero-sub{ font-size:12px; font-weight:400; opacity:0.85; }
.profile-stats{ display:flex; gap:10px; }
.profile-stat{
  flex:1;
  background:rgba(255,255,255,0.16);
  border-radius:var(--radius-sm);
  padding:10px 12px;
}
.profile-stat .p-label{ font-size:11px; font-weight:600; letter-spacing:0.08em; text-transform:uppercase; opacity:0.85; }
.profile-stat .p-value{ font-family:var(--font-mono); font-weight:500; font-size:14px; margin-top:3px; }

.share-row{
  display:flex;
  align-items:center;
  gap:10px;
  background:var(--surface-alt);
  border-radius:var(--radius-sm);
  padding:14px 16px;
}
.share-code{
  flex:1;
  font-weight:600;
  letter-spacing:2px;
  font-size:15px;
  color:var(--purple-500);
}
.sync-status-text{
  font-size:12px;
  font-weight:400;
  color:var(--text-tertiary);
  margin-top:10px;
  display:flex;
  align-items:center;
  gap:6px;
}
.sync-status-text.ok{ color:var(--green-500); }
.sync-status-text.err{ color:var(--red-500); }

.stat-list-row{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 0;
  border-bottom:1px solid var(--border);
}
.stat-list-row:last-child{ border-bottom:none; padding-bottom:2px; }
.stat-list-row:first-child{ padding-top:2px; }
.stat-list-icon{
  width:38px;height:38px;
  border-radius:11px;
  background:var(--purple-50);
  color:var(--purple-500);
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
}
.stat-list-label{ flex:1; font-weight:500; font-size:14px; }
.stat-list-value{ font-family:var(--font-mono); font-weight:500; font-size:14px; }

/* =========================================================
   MODALES
   ========================================================= */

.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(20,20,43,0.42);
  display:flex;
  align-items:flex-end;
  justify-content:center;
  z-index:100;
  animation:fadeIn .15s ease;
}
@keyframes fadeIn{ from{ opacity:0; } to{ opacity:1; } }

.modal-sheet{
  width:100%;
  max-width:480px;
  max-height:92vh;
  overflow-y:auto;
  background:var(--surface);
  border-radius:24px 24px 0 0;
  padding:10px 22px calc(24px + env(safe-area-inset-bottom));
  animation:slideUp .22s cubic-bezier(.2,.9,.3,1);
}
@keyframes slideUp{ from{ transform:translateY(100%); } to{ transform:translateY(0); } }

.modal-grabber{
  width:40px;height:4px;
  background:var(--border);
  border-radius:999px;
  margin:8px auto 14px;
}

.modal-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:18px;
  gap:10px;
}
.modal-head-left{ display:flex; align-items:center; gap:12px; }
.modal-head-icon{
  width:40px;height:40px;
  border-radius:12px;
  display:flex;align-items:center;justify-content:center;
  flex-shrink:0;
}
.modal-head-icon.income{ background:var(--green-50); color:var(--green-500); }
.modal-head-icon.expense{ background:var(--red-50); color:var(--red-500); }
.modal-head-icon.collect{ background:var(--amber-50); color:var(--amber-500); }
.modal-head-icon.pay{ background:var(--purple-50); color:var(--indigo-500); }
.modal-head-icon.savings{ background:var(--amber-50); color:var(--amber-500); }
.modal-title{ font-weight:700; font-size:18px; }
.modal-sub{ font-size:12px; font-weight:400; color:var(--text-tertiary); margin-top:1px; }

.field-label{
  font-size:11px;
  font-weight:600;
  color:var(--text-muted);
  text-transform:uppercase;
  letter-spacing:0.08em;
  margin-bottom:6px;
  display:block;
}
.field-group{ margin-bottom:16px; }

.amount-field{
  background:var(--surface-alt);
  border-radius:var(--radius-md);
  padding:14px 16px;
  display:flex;
  align-items:center;
  gap:6px;
}
.amount-field.income{ background:var(--green-50); }
.amount-field.expense{ background:var(--red-50); }
.amount-field.collect{ background:var(--amber-50); }
.amount-field.pay{ background:var(--purple-50); }
.amount-field .curr-sign{ font-family:var(--font-mono); font-size:22px; font-weight:600; color:var(--text-muted); }
.amount-field.income .curr-sign{ color:var(--green-500); }
.amount-field.expense .curr-sign{ color:var(--red-500); }
.amount-field.collect .curr-sign{ color:var(--amber-500); }
.amount-field.pay .curr-sign{ color:var(--indigo-500); }
.amount-field input{
  font-family:var(--font-mono);
  border:none;
  background:none;
  outline:none;
  font-size:28px;
  font-weight:600;
  width:100%;
  color:var(--text);
}
.amount-field input::placeholder{ color:var(--text-muted); }

.detail-amount{
  font-family:var(--font-mono);
  font-size:34px;
  font-weight:700;
  text-align:center;
  margin:2px 0 20px;
}
.detail-amount.positive{ color:var(--green-500); }
.detail-amount.negative{ color:var(--red-500); }
.detail-amount.neutral{ color:var(--amber-500); }

.detail-list{ margin-bottom:20px; }
.detail-row{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:14px;
  padding:11px 0;
  border-bottom:1px solid var(--border);
}
.detail-row:last-child{ border-bottom:none; }
.detail-row .dr-label{
  font-size:11px;
  font-weight:600;
  color:var(--text-muted);
  text-transform:uppercase;
  letter-spacing:0.08em;
  flex-shrink:0;
  padding-top:2px;
}
.detail-row .dr-value{
  font-size:14px;
  font-weight:500;
  color:var(--text);
  text-align:right;
  overflow-wrap:anywhere;
  min-width:0;
}
.detail-tags{ display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }

.detail-actions{ display:flex; gap:10px; }
.detail-actions .btn{ flex:1; margin-top:0; }
.detail-actions .btn-secondary-outline{
  background:none;
  border:1.5px solid var(--border);
  color:var(--text);
}
.detail-actions .btn-secondary-outline:hover{ background:var(--hover-tint); }
.detail-actions .btn-danger-outline{
  background:var(--red-50);
  border:1.5px solid #fbd0d0;
  color:var(--red-500);
}
.detail-actions .btn-danger-outline:hover{ background:#fddede; }

.plain-input-underline{
  border:none;
  border-bottom:1.5px solid var(--border);
  background:none;
  width:100%;
  padding:10px 2px;
  font-size:14px;
  font-weight:400;
  outline:none;
  color:var(--text);
}
.plain-input-underline::placeholder{ color:var(--text-muted); }
.plain-input-underline:focus{ border-color:var(--purple-400); }

.field-textline{ margin-bottom:14px; }

.method-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:10px;
}
.method-btn{
  border:1.5px solid var(--border);
  background:var(--surface);
  border-radius:var(--radius-sm);
  padding:12px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  font-weight:600;
  font-size:13px;
  color:var(--text-tertiary);
  cursor:pointer;
}
.method-btn.selected.income{ border-color:var(--green-500); background:var(--green-50); color:var(--green-500); }
.method-btn.selected.expense{ border-color:var(--red-500); background:var(--red-50); color:var(--red-500); }
.method-btn.selected.collect{ border-color:var(--amber-500); background:var(--amber-50); color:var(--amber-500); }
.method-btn.selected.pay{ border-color:var(--indigo-500); background:var(--purple-50); color:var(--indigo-500); }
.method-btn.selected.neutral{ border-color:var(--purple-400); background:var(--purple-50); color:var(--purple-500); }

.checkbox-row{
  display:flex;
  align-items:flex-start;
  gap:10px;
  cursor:pointer;
}
.checkbox-row input{ margin-top:3px; width:17px; height:17px; accent-color:var(--purple-500); flex-shrink:0; }
.checkbox-row .cb-title{ font-weight:500; font-size:14px; }
.checkbox-row .cb-sub{ font-size:12px; font-weight:400; color:var(--text-tertiary); }

.recurring-toggle-btn{
  display:inline-flex;
  align-items:center;
  gap:6px;
  border:1.5px solid transparent;
  background:var(--purple-50);
  border-radius:999px;
  padding:8px 13px;
  font-size:12px;
  font-weight:600;
  color:var(--purple-500);
  cursor:pointer;
  transition:background .15s ease, color .15s ease;
}
.recurring-toggle-btn:hover{ background:#e4defc; }
.recurring-toggle-btn.active{ background:var(--purple-500); color:#fff; }

.recurring-toggle-btn.theme-green{ background:var(--green-50); color:var(--green-500); }
.recurring-toggle-btn.theme-green:hover{ background:#d3f5e6; }
.recurring-toggle-btn.theme-green.active{ background:var(--green-500); color:#fff; }

.recurring-toggle-btn.theme-red{ background:var(--red-50); color:var(--red-500); }
.recurring-toggle-btn.theme-red:hover{ background:#fddede; }
.recurring-toggle-btn.theme-red.active{ background:var(--red-500); color:#fff; }

.recurring-toggle-btn.theme-amber{ background:var(--amber-50); color:var(--amber-500); }
.recurring-toggle-btn.theme-amber:hover{ background:#ffecc4; }
.recurring-toggle-btn.theme-amber.active{ background:var(--amber-500); color:#fff; }

.recurring-toggle-btn.theme-indigo{ background:var(--purple-50); color:var(--indigo-500); }
.recurring-toggle-btn.theme-indigo:hover{ background:#e4defc; }
.recurring-toggle-btn.theme-indigo.active{ background:var(--indigo-500); color:#fff; }

.recurring-picker{
  background:var(--surface-alt);
  border-radius:var(--radius-md);
  padding:12px;
  margin-bottom:16px;
}
.recurring-picker-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:10px 8px;
  border-radius:10px;
  cursor:pointer;
}
.recurring-picker-item:hover{ background:var(--hover-tint); }
.recurring-picker-item .rp-name{ font-weight:500; font-size:14px; }
.recurring-picker-item .rp-meta{ font-size:12px; font-weight:400; color:var(--text-tertiary); }
.recurring-picker-item .rp-amount{ font-family:var(--font-mono); font-weight:500; font-size:14px; }

.emoji-grid{
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:6px;
  margin-bottom:16px;
}
.emoji-opt{
  aspect-ratio:1;
  display:flex;align-items:center;justify-content:center;
  font-size:19px;
  border-radius:10px;
  border:1.5px solid var(--border);
  background:var(--surface);
  cursor:pointer;
}
.emoji-opt.selected{ border-color:var(--amber-500); background:var(--amber-50); }

.modal-footer-btn{ margin-top:6px; }

/* =========================================================
   PRINT / PDF
   ========================================================= */

/* #print-report se queda en el flujo normal del documento (no
   position:fixed fuera de pantalla): eso es necesario para que
   html2canvas pueda medir su alto real al generar el PDF — un elemento
   fixed con left:-9999px se captura con alto 0 (pagina en blanco) en
   varios navegadores. En vez de moverlo, lo recorta un contenedor
   ancestro de tamaño 0, así nadie lo ve en pantalla pero su layout
   interno se calcula con normalidad. Al imprimir (@media print) el
   recorte se quita para que se vea en la hoja. */
.print-clip{
  position:fixed;
  top:0; left:0;
  width:0; height:0;
  overflow:hidden;
}
#print-report{
  width:800px;
  background:#fff;
  padding:20px;
}
.pr-head{ margin-bottom:18px; }
.pr-head h1{ font-size:20px; margin-bottom:2px; color:#111; }
.pr-head p{ color:#666; font-size:12px; }
.pr-summary{ display:flex; gap:14px; margin-bottom:18px; }
.pr-summary div{ flex:1; border:1px solid #ddd; border-radius:8px; padding:10px 12px; }
.pr-summary .pr-label{ font-size:10px; color:#888; text-transform:uppercase; }
.pr-summary .pr-value{ font-family:var(--font-mono); font-size:16px; font-weight:600; margin-top:4px; color:#111; }
/* table-layout:fixed reparte las columnas por porcentaje fijo en vez de
   por el ancho del contenido: así la tabla nunca puede volverse más
   ancha que el contenedor (que era la causa real del recorte del PDF —
   con fuentes de reemplazo, antes de que carguen las de Google Fonts,
   el texto puede medir más ancho y desbordar una tabla de layout auto). */
#print-report table{ width:100%; table-layout:fixed; border-collapse:collapse; font-size:11.5px; color:#111; }
#print-report th, #print-report td{
  text-align:left; padding:6px 8px; border-bottom:1px solid #eee;
  overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
#print-report th{ color:#888; text-transform:uppercase; font-size:10px; }
#print-report th:nth-child(1), #print-report td:nth-child(1){ width:13%; }
#print-report th:nth-child(2), #print-report td:nth-child(2){ width:27%; }
#print-report th:nth-child(3), #print-report td:nth-child(3){ width:19%; }
#print-report th:nth-child(4), #print-report td:nth-child(4){ width:15%; }
#print-report th:nth-child(5), #print-report td:nth-child(5){ width:11%; }
#print-report th:nth-child(6), #print-report td:nth-child(6){ width:15%; text-align:right; }

@media print{
  body *{ visibility:hidden; }
  #print-report, #print-report *{ visibility:visible; }
  .print-clip{
    position:absolute;
    top:0; left:0;
    width:100%; height:auto;
    overflow:visible;
  }
  #print-report{
    position:absolute;
    left:0; top:0; width:100%;
  }
}

/* =========================================================
   RESPONSIVE — TABLET / ESCRITORIO
   ========================================================= */

@media (min-width:768px){

  .setup-card{ padding:40px; }

  #view-main{ }

  .sidebar{
    display:flex;
    flex-direction:column;
    width:236px;
    flex-shrink:0;
    background:var(--surface);
    border-right:1px solid var(--border);
    padding:22px 16px;
    height:100dvh;
    position:sticky;
    top:0;
  }
  .sidebar-brand{
    display:flex;
    align-items:center;
    gap:10px;
    font-weight:700;
    font-size:17px;
    padding:6px 10px 26px;
  }
  .brand-icon{ width:26px; color:var(--purple-500); display:flex; align-items:center; }
  .brand-icon svg{ display:block; }

  .mobile-topbar{ display:none; }

  .sidebar-nav{
    display:flex;
    flex-direction:column;
    gap:4px;
    flex:1;
  }
  .sidebar-nav .nav-item{
    flex-direction:row;
    justify-content:flex-start;
    gap:12px;
    padding:11px 12px;
    border-radius:12px;
    font-size:14px;
  }
  .sidebar-nav .nav-item.active{
    background:var(--purple-50);
    color:var(--purple-500);
  }
  .sidebar-nav .nav-item:hover:not(.active){ background:var(--hover-tint); }

  .sidebar-account{
    display:flex;
    align-items:center;
    gap:10px;
    background:var(--surface-alt);
    border:none;
    border-radius:12px;
    padding:10px;
    cursor:pointer;
    text-align:left;
    font-weight:500;
    font-size:14px;
    color:var(--text);
  }
  .sidebar-account:hover{ background:var(--hover-tint); }

  .bottom-nav{ display:none; }

  .main-content{
    max-width:760px;
    padding:32px 32px 48px;
  }

  .action-tiles{ grid-template-columns:1fr 1fr; gap:16px; }
  .action-tile{ padding:22px; }

  .card{ padding:22px; }

  .summary-tiles{ gap:14px; }

  .modal-backdrop{ align-items:center; }
  .modal-sheet{
    border-radius:24px;
    max-height:88vh;
    padding:8px 26px 26px;
  }
  .modal-grabber{ display:none; }
}

@media (min-width:1080px){
  .main-content{ max-width:920px; }

  .home-grid{
    display:grid;
    grid-template-columns:1.15fr 0.85fr;
    gap:16px;
    align-items:start;
  }
}

@media (min-width:1080px){
  .report-grid{
    display:grid;
    grid-template-columns:1fr;
  }
}
