@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --ink: #12131e;
  --surface: #161826;
  --surface-alt: #232532;
  --surface-2: #2b2e3f;
  --divider: rgba(233,233,237,.16);
  --cream: #e9e9ed;
  --muted: rgba(233,233,237,.55);
  --muted-2: rgba(233,233,237,.72);

  --accent: #9184d9;
  --accent-100: #f5f4ff;
  --accent-300: #d2cefd;
  --accent-400: #b5abfc;
  --accent-600: #796cbf;
  --accent-800: #423a6a;
  --accent-900: #2b2741;

  --income: oklch(72% .14 150);
  --income-bg: oklch(26% .05 150);
  --income-text: oklch(88% .06 150);
  --expense: oklch(70% .14 45);
  --expense-bg: oklch(26% .05 45);
  --expense-text: oklch(88% .06 45);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;

  --shadow-sm: 0 0 0 1px rgba(233,233,237,.08);
  --shadow-md: 0 0 0 1px rgba(233,233,237,.10), 0 6px 18px rgba(0,0,0,.55);
  --shadow-lg: 0 0 0 1px rgba(233,233,237,.14), 0 16px 40px rgba(0,0,0,.65);
}

/* ══════════════ Modo claro (preferencia por cuenta, no afecta a los demás) ══════════════ */
body.tema-claro {
  --ink: #f3f3f6;
  --surface: #ffffff;
  --surface-alt: #eceef3;
  --surface-2: #dfe2e9;
  --divider: rgba(18,19,30,.12);
  --cream: #14151f;
  --muted: rgba(18,19,30,.58);
  --muted-2: rgba(18,19,30,.75);

  --accent: #7a6bd0;
  --accent-100: #ffffff;
  --accent-300: #6a5bc4;
  --accent-400: #5a4bb5;
  --accent-600: #9184d9;
  --accent-800: #d2cefd;
  --accent-900: #ffffff;

  --income: oklch(52% .14 150);
  --income-bg: oklch(94% .03 150);
  --income-text: oklch(38% .10 150);
  --expense: oklch(52% .16 35);
  --expense-bg: oklch(94% .03 35);
  --expense-text: oklch(40% .12 35);

  --shadow-sm: 0 0 0 1px rgba(18,19,30,.06);
  --shadow-md: 0 0 0 1px rgba(18,19,30,.08), 0 6px 18px rgba(18,19,30,.10);
  --shadow-lg: 0 0 0 1px rgba(18,19,30,.10), 0 16px 40px rgba(18,19,30,.14);
}


* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  display: flex;
  justify-content: center;
}

#app {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 28px 18px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
header .title { font-family: 'Inter', sans-serif; font-weight: 500; font-size: 21px; letter-spacing: -0.015em; }
header .subtitle { font-size: 11px; color: var(--muted); letter-spacing: 1.2px; text-transform: uppercase; margin-left: 8px; }
#btn-refresh {
  background: transparent; border: 1px solid var(--divider); color: var(--muted);
  width: 30px; height: 30px; border-radius: 50%; font-size: 15px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .15s ease;
}
#btn-refresh:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); }
#btn-refresh.spinning { animation: spin 0.6s linear; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

main { flex: 1; padding: 18px 18px 100px; }
.hidden { display: none !important; }

.section-label { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; font-weight: 500; }

.lang-desktop-corner { display: none; }

.patrocinador-logo {
  height: 24px; max-width: 100px; object-fit: contain;
  filter: grayscale(1); opacity: .7; transition: filter .2s, opacity .2s;
}
.patrocinador-logo:hover { filter: none; opacity: 1; }

/* Tarjeta genérica de fondo (usada en el nuevo Resumen: salud/balance, moneda, objetivos, disponible, categorías) */
.card {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}

/* Balance card */
.balance-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 22px 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden; margin-bottom: 18px;
}
.balance-card::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: linear-gradient(180deg, var(--accent), transparent 85%);
}
.balance-amount {
  font-family: 'Inter', sans-serif; font-weight: 500; letter-spacing: -0.02em;
  font-size: 34px; margin-top: 4px; font-variant-numeric: tabular-nums;
}
.balance-row { display: flex; gap: 20px; margin-top: 14px; }
.balance-row span { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }

.metodo-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-radius: var(--radius-md); padding: 12px 14px;
  box-shadow: var(--shadow-sm); margin-bottom: 8px; font-size: 14px;
}
.bar-bg { height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar-fill { height: 100%; border-radius: 3px; transition: width .6s cubic-bezier(.16,1,.3,1); }

.empty-state { text-align: center; padding: 70px 20px 0; }
.empty-state .title { font-family: 'Inter', sans-serif; font-weight: 500; font-size: 18px; margin: 14px 0 8px; }
.empty-state .body { font-size: 13.5px; color: var(--muted); line-height: 1.55; }

.filtros { display: flex; gap: 8px; margin-bottom: 16px; }
.filtro-btn {
  padding: 6px 14px; border-radius: 20px; font-size: 12.5px; cursor: pointer; font-weight: 500;
  border: 1px solid var(--divider); background: transparent; color: var(--muted); transition: all .15s ease;
}
.filtro-btn.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-300); }

.ledger { position: relative; padding-left: 16px; }
.ledger::before { content: ''; position: absolute; left: 4px; top: 4px; bottom: 4px; width: 1px; background: var(--divider); }
.tx-item { position: relative; margin-bottom: 12px; opacity: 0; animation: rise .35s ease forwards; }
.tx-item:nth-child(n) { animation-delay: calc(var(--i, 0) * 20ms); }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.tx-dot { position: absolute; left: -16px; top: 6px; width: 6px; height: 6px; border-radius: 50%; }
.tx-dot.ingreso { background: var(--income); }
.tx-dot.gasto { background: var(--expense); }
.tx-card {
  background: var(--surface); border-radius: var(--radius-md); padding: 12px 14px; box-shadow: var(--shadow-sm);
  display: flex; justify-content: space-between; align-items: center; gap: 10px; transition: box-shadow .15s ease;
}
.tx-card:hover { box-shadow: var(--shadow-md); }
.tx-desc { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.tx-meta { font-size: 11px; color: var(--muted); margin-top: 1px; }
.tx-amount { font-weight: 500; font-size: 14px; font-variant-numeric: tabular-nums; }
.tx-amount.ingreso { color: var(--income-text); }
.tx-amount.gasto { color: var(--expense-text); }
.tx-delete { background: none; border: none; cursor: pointer; color: var(--muted); padding: 2px; transition: color .15s ease; }
.tx-delete:hover { color: var(--expense-text); }

/* KPIs / gráficos */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.kpi-card { background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 14px; }
.kpi-label { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; font-weight: 500; }
.kpi-value { font-weight: 500; font-size: 17px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Igual que .kpi-sub pero para frases/párrafos largos: sí hace salto de línea normal.
   .kpi-sub a secas se queda así a propósito (recorta con "...") para etiquetas cortas de una
   línea, como la descripción de un movimiento en una fila de tabla — ahí SÍ interesa que corte. */
.kpi-sub-texto { font-size: 12.5px; color: var(--muted); line-height: 1.55; white-space: normal; overflow: visible; text-overflow: clip; }

.stats-charts-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.chart-block {
  margin-bottom: 0; background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 18px 18px 20px; min-width: 0;
}
.chart-block.chart-block-wide { grid-column: 1 / -1; }
.chart-block svg { width: 100%; height: auto; display: block; }
/* El donut lleva tamaño fijo a propósito (no debe estirarse a lo ancho de la tarjeta,
   o el círculo crece de forma desproporcionada) — solo las demás gráficas ocupan el 100%. */
.chart-block svg.chart-donut-svg { width: auto; max-width: 100%; margin: 0 auto; }
.chart-donut-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; justify-content: center; }
.chart-block path, .chart-block polyline { stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: draw 1.1s cubic-bezier(.16,1,.3,1) forwards; }
.chart-block circle { animation: fadein .5s ease forwards; opacity: 0; }
.chart-block rect { transform-box: fill-box; transform-origin: bottom; animation: growbar .5s cubic-bezier(.16,1,.3,1) backwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fadein { to { opacity: 1; } }
@keyframes growbar { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@media (prefers-reduced-motion: reduce) {
  .chart-block path, .chart-block polyline, .chart-block circle, .chart-block rect, .tx-item { animation: none !important; opacity: 1 !important; stroke-dashoffset: 0 !important; transform: none !important; }
}
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 10px; }
.chart-legend .item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.chart-legend .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
@media (min-width: 720px) {
  .stats-charts-grid { grid-template-columns: 1fr 1fr; }
}

/* Filtros avanzados historial */
.filters-panel { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.search-input {
  width: 100%; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-md);
  padding: 10px 12px; color: var(--cream); font-size: 14px; outline: none; font-family: inherit;
}
.search-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.select-row { display: flex; gap: 8px; }
.select-field {
  flex: 1; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-md);
  padding: 9px 8px; color: var(--cream); font-size: 12.5px; outline: none; font-family: inherit;
}
.select-field:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.csv-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 0; border-radius: var(--radius-md); font-size: 12.5px; cursor: pointer; font-weight: 500;
  border: 1px solid var(--accent); background: transparent; color: var(--accent); transition: background .15s ease;
}
.csv-btn:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.results-count { font-size: 11.5px; color: var(--muted); margin: -4px 0 12px; }

/* Wizard */
.progress { display: flex; gap: 6px; margin-bottom: 26px; }
.progress div { flex: 1; height: 2px; border-radius: 2px; background: var(--divider); transition: background .3s ease; }
.progress div.done { background: var(--accent); }
.question-label { font-family: 'Inter', sans-serif; font-weight: 500; font-size: 19px; margin-bottom: 16px; letter-spacing: -0.01em; }

.input-field {
  width: 100%; box-sizing: border-box; background: var(--surface); border: 1px solid var(--divider); border-radius: var(--radius-md);
  padding: 14px 16px; color: var(--cream); font-size: 16px; outline: none; margin-bottom: 12px; font-family: inherit;
}
.input-field:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.amount-wrap { position: relative; }
.amount-wrap input { font-weight: 500; font-size: 26px; padding-right: 40px; font-variant-numeric: tabular-nums; }
.amount-wrap .currency { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); }

.option-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option-row-list { display: flex; flex-direction: column; gap: 10px; }
.option-pair { display: flex; gap: 10px; }

.option-card {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 22px 10px; border-radius: var(--radius-md); cursor: pointer; transition: all .15s ease;
  border: 1px solid var(--divider); background: var(--surface); color: var(--cream); text-align: center; flex: 1;
}
.option-card.small { padding: 16px 8px; }
.option-card.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.option-card span { font-size: 13.5px; }
.option-card.small span { font-size: 12px; }

.option-row {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--radius-md); cursor: pointer;
  border: 1px solid var(--divider); background: var(--surface); color: var(--cream); transition: all .15s ease;
}
.option-row.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.option-row .check { margin-left: auto; color: var(--accent); }

.wizard-nav { display: flex; gap: 10px; margin-top: 28px; }
.nav-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 0; border-radius: var(--radius-md); font-size: 14px; cursor: pointer; font-weight: 500;
  border: 1px solid var(--divider); background: transparent; color: var(--muted); text-decoration: none;
  transition: background .15s ease, transform .1s ease, border-color .15s ease;
}
.nav-btn:hover { border-color: var(--muted); }
.nav-btn.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-900); }
.nav-btn.primary:hover { filter: brightness(1.08); }
.nav-btn.primary:active { transform: scale(.98); }
.nav-btn.primary:disabled { opacity: 0.4; cursor: default; filter: none; }
.nav-btn.danger { border-color: var(--expense); color: var(--expense-text); }
.nav-btn.danger:hover { background: color-mix(in srgb, var(--expense) 14%, transparent); }
.nav-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.error-banner {
  margin-top: 12px; padding: 10px 14px; border-radius: var(--radius-md);
  background: var(--expense-bg); border: 1px solid color-mix(in srgb, var(--expense) 50%, transparent);
  color: var(--expense-text); font-size: 13px;
}

/* Ajustes */
.settings-group { margin-bottom: 22px; }
.settings-group-title { font-size: 11px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; margin-bottom: 10px; font-weight: 500; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: 13px 14px; margin-bottom: 8px; font-size: 14px;
}
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--surface-2); border-radius: 20px; cursor: pointer; transition: .2s; }
.switch .slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: var(--cream); border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); background: var(--accent-900); }

.profile-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 22px; }
.profile-name { font-family: 'Inter', sans-serif; font-weight: 500; font-size: 17px; }
.profile-email { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.profile-sub { font-size: 12px; color: var(--income-text); margin-top: 10px; }

/* Toasts */
#toast-alertas { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 50; width: calc(100% - 36px); max-width: 444px; }
.toast {
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--expense) 50%, transparent); border-radius: var(--radius-md);
  padding: 12px 14px; margin-bottom: 8px; font-size: 13px; box-shadow: var(--shadow-lg); animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Modal */
#modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
#modal-analisis { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 24px; max-width: 400px; width: 100%; max-height: 80vh; overflow-y: auto; }
#modal-analisis .modal-title { font-family: 'Inter', sans-serif; font-weight: 500; font-size: 18px; margin-bottom: 12px; }
#modal-analisis .modal-body { font-size: 13.5px; line-height: 1.6; color: var(--cream); white-space: pre-line; }

/* Menú "Más" */
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
  padding: 15px 16px; cursor: pointer; color: var(--cream); font-size: 14.5px; text-decoration: none; transition: box-shadow .15s ease;
}
.menu-item:hover { box-shadow: var(--shadow-md); }
.menu-item .arrow { color: var(--muted); }
.subview-back { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; margin-bottom: 18px; background: none; border: none; padding: 0; text-decoration: none; }
.subview-back:hover { color: var(--accent); }

/* Presupuesto */
.budget-intro { background: var(--surface); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 18px; }
.budget-intro-title { display: flex; align-items: center; gap: 8px; font-family: 'Inter', sans-serif; font-weight: 500; font-size: 14.5px; margin-bottom: 8px; }
.budget-intro p { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0 0 8px; }
.budget-intro p:last-child { margin-bottom: 0; }

.budget-split-preview { display: flex; height: 10px; border-radius: 6px; overflow: hidden; margin: 14px 0 22px; background: var(--surface-2); }
.budget-split-preview div { transition: width .15s ease; }

.pct-row { margin-bottom: 20px; }
.pct-row-head { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-bottom: 8px; }
.pct-row-head .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.pct-row-head .pct-num { margin-left: auto; font-family: ui-monospace, monospace; font-weight: 600; font-size: 14px; }

.pct-slider {
  width: 100%; height: 8px; border-radius: 6px; appearance: none; -webkit-appearance: none;
  background: var(--surface-2); cursor: pointer; outline: none;
}
.pct-slider::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--cream); box-shadow: var(--shadow-md); border: 3px solid var(--track-color, var(--accent));
  cursor: grab; margin-top: -6px;
}
.pct-slider::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--cream); box-shadow: var(--shadow-md);
  border: 3px solid var(--track-color, var(--accent)); cursor: grab;
}
.pct-slider::-webkit-slider-runnable-track { height: 8px; border-radius: 6px; background: transparent; }
.pct-slider::-moz-range-track { height: 8px; border-radius: 6px; background: transparent; }
.pct-slider.gasto::-webkit-slider-thumb { border-color: var(--expense); }
.pct-slider.gasto::-moz-range-thumb { border-color: var(--expense); }
.pct-slider.ahorro::-webkit-slider-thumb { border-color: var(--accent); }
.pct-slider.ahorro::-moz-range-thumb { border-color: var(--accent); }
.pct-slider.inversion::-webkit-slider-thumb { border-color: var(--income); }
.pct-slider.inversion::-moz-range-thumb { border-color: var(--income); }

.pct-total { text-align: center; font-size: 13.5px; margin: 4px 0 18px; padding: 10px; border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.pct-total.ok { color: var(--income-text); background: var(--income-bg); }
.pct-total.bad { color: var(--expense-text); background: var(--expense-bg); }
.budget-compare { margin-top: 22px; }
.budget-compare-row { margin-bottom: 14px; }
.budget-compare-labels { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }

/* Patrimonio / activos */
.activo-card { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); padding: 13px 14px; margin-bottom: 8px; }
.activo-info .nombre { font-size: 14px; }
.activo-info .tipo { font-size: 11px; color: var(--muted); }
.activo-valor { font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }

.ia-box { background: color-mix(in srgb, var(--accent) 8%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: var(--radius-md); padding: 16px; margin-top: 16px; font-size: 13.5px; line-height: 1.6; white-space: pre-line; }
.ia-btn { width: 100%; padding: 13px 0; border-radius: var(--radius-md); border: 1px solid var(--accent); background: transparent; color: var(--accent); font-size: 14px; cursor: pointer; margin-top: 10px; font-weight: 500; transition: background .15s ease; }
.ia-btn:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.ia-btn:disabled { opacity: 0.5; }

/* Auth / pricing pages */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 30px 26px; }
.auth-title { font-family: 'Inter', sans-serif; font-weight: 500; font-size: 22px; text-align: center; letter-spacing: -0.015em; }
.auth-subtitle { font-size: 13px; color: var(--muted); text-align: center; margin-top: 6px; margin-bottom: 22px; }
.auth-label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; margin-top: 12px; }
.auth-footer { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 20px; }
.auth-footer a { color: var(--accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

.plan-card { border: 1px solid var(--divider); border-radius: var(--radius-lg); padding: 22px; margin-top: 10px; background: var(--surface-alt); }
.plan-name { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 500; }
.plan-price { font-weight: 500; font-size: 32px; margin-top: 6px; letter-spacing: -0.02em; }
.plan-price-block { min-height: 68px; }
.plan-price span { font-size: 13px; color: var(--muted); font-weight: 400; }
.plan-features { list-style: none; padding: 0; margin: 16px 0; font-size: 13.5px; color: var(--cream); line-height: 2; }

/* Bottom nav (mobile) */
nav.bottom-nav {
  position: sticky; bottom: 0; width: 100%;
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(16px);
  border-top: 1px solid var(--divider);
  display: flex; align-items: flex-end; justify-content: space-around;
  padding: 8px 6px max(10px, env(safe-area-inset-bottom));
}
nav.bottom-nav button {
  flex: 1; max-width: 76px; background: none; border: none; padding: 7px 4px 5px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted);
  border-radius: 14px; transition: color .15s ease, background .15s ease;
}
nav.bottom-nav button.active { color: var(--accent-300); background: color-mix(in srgb, var(--accent) 10%, transparent); }
nav.bottom-nav button span:last-child {
  font-size: 10px; letter-spacing: 0.1px; white-space: nowrap;
  font-weight: 500;
}
nav.bottom-nav .nav-icon { font-size: 18px; line-height: 1; }

/* Botón central "Añadir": círculo elevado, flotando por encima de la barra */
nav.bottom-nav .bottom-nav-fab {
  flex: 0 0 auto; max-width: none; width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-300));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 45%, transparent);
  margin: -22px 6px 0; padding: 0; align-items: center; justify-content: center;
  border: 3px solid var(--ink);
}
nav.bottom-nav .bottom-nav-fab:active { transform: scale(.94); }
nav.bottom-nav .bottom-nav-fab .nav-icon-plus { font-size: 26px; font-weight: 400; color: var(--ink); line-height: 1; }

/* ══════════════ Escritorio: barra lateral + reflow a paneles ══════════════ */
.sidebar { display: none; }

@media (min-width: 1024px) {
  body { align-items: flex-start; }
  #app { max-width: 1240px; flex-direction: row; min-height: 100vh; }

  .sidebar {
    display: flex; flex-direction: column; justify-content: space-between;
    width: 240px; flex-shrink: 0; padding: 24px 16px; border-right: 1px solid var(--divider);
    position: sticky; top: 0; height: 100vh;
  }
  .sidebar-top { display: flex; flex-direction: column; gap: 22px; }
  .sidebar-brand { font-family: 'Inter', sans-serif; font-weight: 500; font-size: 18px; padding: 0 8px; letter-spacing: -0.01em; }
  .sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
  .sidebar-nav button {
    display: flex; align-items: center; gap: 12px; padding: 10px 10px; border-radius: var(--radius-md);
    background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 500; cursor: pointer;
    text-align: left; font-family: inherit; transition: background .15s ease, color .15s ease;
  }
  .sidebar-nav button:hover { background: var(--surface); color: var(--cream); }
  .sidebar-nav button.active { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-300); }
  .sidebar-nav .nav-icon { font-size: 16px; width: 18px; text-align: center; }

  .sidebar-bottom { border-top: 1px solid var(--divider); padding-top: 16px; }
  .sidebar-user { display: flex; align-items: center; gap: 10px; padding: 10px 8px; }
  .sidebar-user .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-800); color: var(--accent-300); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 500; flex-shrink: 0; }
  .sidebar-user .name { font-size: 13px; }
  .sidebar-user .plan { font-size: 11px; color: var(--muted); }
  .sidebar-logout {
    display: block; text-align: center; font-size: 12px; color: var(--muted);
    text-decoration: none; padding: 8px; margin-top: 2px; border-radius: 8px;
  }
  .sidebar-logout:hover { color: var(--expense-text); background: var(--expense-bg); }

  #app > header, #app > nav.bottom-nav { display: none; }
  .menu-item-solo-movil { display: none; }
  #app > main { flex: 1; padding: 40px 48px 60px; max-width: 900px; }
  #toast-alertas { max-width: 380px; right: 24px; left: auto; transform: none; }
  .lang-desktop-corner { display: block; position: fixed; top: 24px; right: 24px; z-index: 50; }

  .balance-card { padding: 26px 24px; }
  .balance-amount { font-size: 40px; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .option-grid { grid-template-columns: repeat(3, 1fr); }
  .auth-card { max-width: 420px; }
}

/* ══════════════ RTL (árabe) ══════════════ */
[dir="rtl"] { text-align: right; }
[dir="rtl"] .balance-card::before { left: auto; right: 0; background: linear-gradient(180deg, var(--accent), transparent 85%); }
[dir="rtl"] .ledger { padding-left: 0; padding-right: 16px; }
[dir="rtl"] .ledger::before { left: auto; right: 4px; }
[dir="rtl"] .tx-dot { left: auto; right: -16px; }
[dir="rtl"] .amount-wrap .currency { right: auto; left: 16px; }
[dir="rtl"] .subview-back, [dir="rtl"] .auth-footer a, [dir="rtl"] .menu-item .arrow { transform: scaleX(-1); display: inline-block; }
[dir="rtl"] .switch input:checked + .slider::before { transform: translateX(-18px); }
[dir="rtl"] .switch .slider::before { left: auto; right: 3px; }
[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--divider); }
[dir="rtl"] .lang-desktop-corner { right: auto; left: 24px; }
[dir="rtl"] #toast-alertas { left: 14px; right: auto; transform: none; }
@media (min-width: 1024px) {
  [dir="rtl"] #toast-alertas { left: 24px; right: auto; }
}
[dir="rtl"] .sidebar-nav button { text-align: right; }
[dir="rtl"] .nav-icon { margin-left: 0; }


/* ══════════════ Páginas de marketing (landing + detalle de planes) ══════════════ */

  body { display: block; position: relative; overflow-x: hidden; }
  body::before {
    content: ''; position: fixed; top: -10%; left: 50%; transform: translateX(-50%);
    width: 900px; height: 500px; background: radial-gradient(ellipse, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%);
    pointer-events: none; z-index: 0;
  }
  .lp-wrap { max-width: 1320px; margin: 0 auto; padding: 0 32px; position: relative; z-index: 1; }
  .lp-nav {
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
    padding: 20px 0; border-bottom: 1px solid var(--divider);
  }
  .lp-brand { font-family: 'Inter', sans-serif; font-weight: 500; font-size: 18px; letter-spacing: -0.01em; }
  .lp-nav-links { display: flex; align-items: center; gap: 24px; justify-content: center; }
  .lp-nav-actions { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
  @media (max-width: 640px) {
    .lp-nav { grid-template-columns: auto 1fr; }
    .lp-nav-links { display: none; }
  }
  .lp-link { color: var(--muted); text-decoration: none; font-size: 14px; padding: 8px 4px; }
  .lp-link:hover { color: var(--cream); }
  .lp-btn {
    display: inline-flex; align-items: center; justify-content: center; padding: 9px 18px;
    border-radius: var(--radius-md); font-size: 14px; font-weight: 500; text-decoration: none;
    border: 1px solid var(--divider); color: var(--cream); transition: border-color .15s ease, transform .1s ease;
  }
  .lp-btn:hover { border-color: var(--accent); }
  .lp-btn:active { transform: scale(.97); }
  .lp-btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-900); }
  .lp-btn-primary:hover { filter: brightness(1.08); }

  .lp-hero { padding: 120px 0 100px; display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 80px; align-items: center; }
  .lp-eyebrow { color: var(--accent-300); font-size: 12px; letter-spacing: 1.2px; text-transform: uppercase; font-weight: 500; margin-bottom: 14px; }
  .lp-hero h1 { font-size: 54px; line-height: 1.08; letter-spacing: -0.02em; margin: 0 0 20px; }
  .lp-hero h1 span { color: var(--accent-300); }
  .lp-hero p { font-size: 17px; color: var(--muted-2); line-height: 1.6; max-width: 500px; margin: 0 0 28px; }
  .lp-hero-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
  .lp-hero-note { font-size: 12.5px; color: var(--muted); margin-top: 14px; }

  .lp-mock { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 24px; }
  .lp-mock-label { font-size: 11px; color: var(--accent-300); text-transform: uppercase; letter-spacing: 1px; font-weight: 500; }
  .lp-mock-amount { font-size: 36px; font-weight: 500; letter-spacing: -0.02em; margin: 6px 0 16px; }
  .lp-mock-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-top: 1px solid var(--divider); font-size: 13.5px; }
  .lp-mock-row:first-of-type { border-top: none; }
  .lp-mock-chart { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--divider); }
  .lp-mock-chart-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 10px; }

  .lp-section { padding: 80px 0; border-top: 1px solid var(--divider); }
  .lp-section h2 { font-size: 28px; letter-spacing: -0.015em; margin: 0 0 10px; }
  .lp-section-sub { color: var(--muted); font-size: 14.5px; max-width: 520px; margin-bottom: 40px; }
  .lp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
  .icon-chip {
    width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
    font-size: 19px; margin-bottom: 14px; background: color-mix(in srgb, var(--accent) 14%, transparent);
  }
  .lp-card { background: var(--surface); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-sm); transition: box-shadow .2s ease, transform .2s ease; }
  .lp-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
  .lp-card h3 { font-size: 16px; font-weight: 500; margin: 0 0 8px; }
  .lp-card p { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin: 0; }

  .lp-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; counter-reset: paso; }
  .lp-step { position: relative; padding-left: 4px; }
  .lp-step::before {
    counter-increment: paso; content: counter(paso);
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%; margin-bottom: 16px;
    background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-300);
    font-weight: 600; font-size: 14px;
  }
  .lp-step h3 { font-size: 15.5px; font-weight: 500; margin: 0 0 6px; }
  .lp-step p { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin: 0; }

  .lp-faq { max-width: 720px; }
  .lp-faq details {
    border-bottom: 1px solid var(--divider); padding: 18px 0;
  }
  .lp-faq summary {
    cursor: pointer; font-size: 15px; font-weight: 500; list-style: none;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
  }
  .lp-faq summary::-webkit-details-marker { display: none; }
  .lp-faq summary::after { content: '+'; color: var(--accent-300); font-size: 20px; font-weight: 300; flex-shrink: 0; transition: transform .2s ease; }
  .lp-faq details[open] summary::after { transform: rotate(45deg); }
  .lp-faq p { font-size: 13.5px; color: var(--muted); line-height: 1.6; margin: 12px 0 0; }

  .lp-plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; max-width: 920px; margin: 0 auto; }
  .lp-cta-band {
    text-align: center; padding: 70px 0; border-top: 1px solid var(--divider);
  }
  .lp-cta-band h2 { font-size: 30px; margin: 0 0 10px; letter-spacing: -0.015em; }
  .lp-cta-band p { color: var(--muted); margin: 0 0 26px; }

  .lp-footer { padding: 40px 0 50px; border-top: 1px solid var(--divider); display: flex; flex-direction: column; align-items: center; gap: 18px; }
  .lp-footer-links { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
  .lp-footer-links a { color: var(--muted); font-size: 12.5px; text-decoration: none; }
  .lp-footer-links a:hover { color: var(--cream); }
  .lp-footer-brand { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }

  .lp-reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s ease; }
  .lp-reveal.lp-visible { opacity: 1; transform: translateY(0); }
  @media (prefers-reduced-motion: reduce) { .lp-reveal { opacity: 1; transform: none; transition: none; } }

  @media (max-width: 760px) {
    .lp-hero { grid-template-columns: 1fr; padding: 50px 0 40px; text-align: left; }
    .lp-hero h1 { font-size: 32px; }
    .lp-plans { grid-template-columns: 1fr; }
    .lp-steps { grid-template-columns: 1fr; }
    .lp-nav-actions .lp-link { display: none; }
  }

/* ---- Páginas de detalle de plan ---- */
.pd-hero {
  padding: 52px 0 36px; text-align: center; max-width: 560px; margin: 0 auto;
}
.pd-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 20px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-300);
  font-size: 11.5px; font-weight: 500; letter-spacing: .4px; margin-bottom: 12px;
}
.pd-hero h1 { font-size: 28px; letter-spacing: -0.02em; margin: 0 0 10px; line-height: 1.16; }
.pd-hero .pd-price { font-family: 'Inter', sans-serif; font-size: 15px; color: var(--muted-2); margin-bottom: 14px; }
.pd-hero .pd-price strong { font-size: 27px; color: var(--cream); font-weight: 500; letter-spacing: -0.02em; }
.pd-hero p { font-size: 14.5px; color: var(--muted-2); line-height: 1.5; margin: 0 auto 18px; max-width: 460px; }

.pd-feature-row {
  display: grid; grid-template-columns: 42px 1fr; gap: 14px; padding: 16px 0;
  border-top: 1px solid var(--divider); align-items: start;
}
.pd-feature-row:first-of-type { border-top: none; }
.pd-feature-row .pd-icon {
  width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 17px; background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.pd-feature-row h3 { font-size: 15px; font-weight: 500; margin: 2px 0 4px; }
.pd-feature-row p { font-size: 13.5px; color: var(--muted); line-height: 1.55; margin: 0; max-width: 560px; }

.pd-compare { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pd-compare th, .pd-compare td { padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--divider); }
.pd-compare th { font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.pd-compare td:first-child, .pd-compare th:first-child { text-align: left; color: var(--cream); }
.pd-compare .pd-col-actual { background: color-mix(in srgb, var(--accent) 7%, transparent); border-left: 1px solid var(--accent); border-right: 1px solid var(--accent); }
.pd-compare .yes { color: var(--income-text); }
.pd-compare .no { color: var(--muted); }

.pd-plans-switch { display: flex; justify-content: center; gap: 8px; margin: 20px 0 4px; flex-wrap: wrap; }
.pd-plans-switch a {
  padding: 6px 14px; border-radius: 20px; font-size: 12.5px; text-decoration: none;
  border: 1px solid var(--divider); color: var(--muted);
}
.pd-plans-switch a.pd-activo { border-color: var(--accent); color: var(--accent-300); background: color-mix(in srgb, var(--accent) 12%, transparent); }

@media (max-width: 640px) {
  .pd-hero h1 { font-size: 24px; }
  .pd-feature-row { grid-template-columns: 1fr; }
  .pd-compare { font-size: 12px; }
}

/* ---- Página de características: zigzag + cuadrícula ---- */
.feat-zigzag {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 60px; align-items: center;
  padding: 90px 0; border-top: 1px solid var(--divider);
}
.feat-zigzag-text h2 { margin-bottom: 18px; }
.feat-zigzag-text p { margin-bottom: 16px; }
.feat-zigzag-text p:last-of-type { margin-bottom: 0; }
.feat-zigzag:first-of-type { border-top: none; }
.feat-zigzag:nth-of-type(even) .feat-zigzag-text { order: 2; }
.feat-zigzag-icon {
  width: 52px; height: 52px; border-radius: 15px; display: flex; align-items: center; justify-content: center;
  font-size: 24px; background: color-mix(in srgb, var(--accent) 16%, transparent); margin-bottom: 18px;
}
.feat-zigzag h2 { font-size: 24px; letter-spacing: -0.01em; margin: 0 0 12px; }
.feat-zigzag p { font-size: 14.5px; color: var(--muted); line-height: 1.65; margin: 0 0 10px; }
.feat-zigzag-example {
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 22px; position: relative;
}
.feat-zigzag-example::before {
  content: ''; position: absolute; inset: -20px; z-index: -1; border-radius: 24px;
  background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%);
}

/* ---- Página de características: selector de pestañas ---- */
.feat-tabs {
  display: flex; gap: 8px; margin-bottom: 28px; flex-wrap: wrap;
}
.feat-tab {
  flex: 1; min-width: 150px; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 12px; border-radius: var(--radius-md); border: 1px solid var(--divider);
  background: var(--surface); color: var(--cream); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.feat-tab .feat-tab-icon { font-size: 17px; }
.feat-tab:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--divider)); }
.feat-tab.active {
  background: var(--accent); border-color: var(--accent); color: var(--accent-900); font-weight: 600;
}
.feat-tab-panel {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 60px; align-items: center;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 44px 48px;
}
.feat-tab-panel.hidden { display: none; }
.feat-tab-panel .feat-zigzag-icon { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.feat-tab-panel .feat-zigzag-example { box-shadow: none; }
.feat-tab-panel .feat-zigzag-example::before { content: none; }

@media (max-width: 760px) {
  .feat-tab-panel { grid-template-columns: 1fr; gap: 28px; padding: 30px 24px; }
  .feat-tab { min-width: 44%; font-size: 13px; padding: 12px 8px; }
}

.feat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.feat-card {
  background: var(--surface); border-radius: var(--radius-lg); padding: 24px;
  box-shadow: var(--shadow-sm); transition: box-shadow .2s ease, transform .2s ease;
}
.feat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.feat-card h3 { font-size: 15px; font-weight: 500; margin: 0 0 8px; }
.feat-card p { font-size: 13px; color: var(--muted); line-height: 1.55; margin: 0; }

@media (max-width: 760px) {
  .feat-zigzag { grid-template-columns: 1fr; gap: 28px; padding: 56px 0; }
  .feat-zigzag:nth-of-type(even) .feat-zigzag-text { order: 0; }
  .feat-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .feat-grid { grid-template-columns: 1fr; }
}
