:root {
  color-scheme: light;
  --surface-1: rgba(255, 255, 255, 0.75);
  --page: #f2f6f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --good: #006300;
  --critical: #d03b3b;

  /* ---- Aqua glass ---- */
  --glass-blur: blur(24px) saturate(180%);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-highlight: rgba(255, 255, 255, 0.6);
  --glass-scrim: rgba(10, 30, 40, 0.30);
  --aqua-bg:
    radial-gradient(ellipse 65% 45% at 15% 0%, rgba(56, 189, 248, 0.38), transparent 60%),
    radial-gradient(ellipse 60% 50% at 88% 12%, rgba(129, 140, 248, 0.30), transparent 60%),
    radial-gradient(ellipse 70% 55% at 45% 100%, rgba(45, 212, 191, 0.32), transparent 60%),
    var(--page);

  --cat-1: #2a78d6; /* Alimentación */
  --cat-2: #eb6834; /* Transporte */
  --cat-3: #1baf7a; /* Vivienda */
  --cat-4: #eda100; /* Servicios */
  --cat-5: #e87ba4; /* Salud */
  --cat-6: #008300; /* Entretenimiento */
  --cat-7: #4a3aa7; /* Compras */
  --cat-8: #e34948; /* Suscripciones */
  --cat-9: #0f8a8a; /* Tarjetas de crédito */
  --cat-fold: #898781; /* Educación / Transferencias / Ahorro / Otros */

  --ingreso: var(--cat-1);
  --gasto: var(--cat-2);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-1: rgba(32, 36, 38, 0.75);
    --page: #0a0e10;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --good: #0ca30c;
    --critical: #e66767;

    --glass-border: rgba(255, 255, 255, 0.14);
    --glass-highlight: rgba(255, 255, 255, 0.08);
    --glass-scrim: rgba(0, 0, 0, 0.45);
    --aqua-bg:
      radial-gradient(ellipse 65% 45% at 15% 0%, rgba(56, 189, 248, 0.22), transparent 60%),
      radial-gradient(ellipse 60% 50% at 88% 12%, rgba(129, 140, 248, 0.20), transparent 60%),
      radial-gradient(ellipse 70% 55% at 45% 100%, rgba(45, 212, 191, 0.18), transparent 60%),
      var(--page);

    --cat-1: #3987e5;
    --cat-2: #d95926;
    --cat-3: #199e70;
    --cat-4: #c98500;
    --cat-5: #d55181;
    --cat-6: #008300;
    --cat-7: #9085e9;
    --cat-8: #e66767;
    --cat-9: #22a6a6;
    --cat-fold: #898781;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--aqua-bg);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cat-1); }

main {
  padding: calc(22px + env(safe-area-inset-top, 0px)) 16px calc(112px + env(safe-area-inset-bottom, 0px));
  max-width: 480px;
  margin: 0 auto;
}

.view { display: none; }
.view.active { display: block; }

.large-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 4px 0 20px;
}

.card {
  background: var(--surface-1);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 14px;
  box-shadow:
    0 1px 2px rgba(11, 11, 11, 0.03),
    0 8px 24px rgba(11, 11, 11, 0.06),
    inset 0 1px 0 var(--glass-highlight);
}

.card h2, .card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 700;
}

.card h2 svg, .card-title svg { flex-shrink: 0; color: var(--text-muted); }

/* ---- Hero balance ---- */
.hero-card { padding: 22px 20px 20px; }
.hero-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.hero-value {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 2px;
}
.hero-value.positive { color: var(--good); }
.hero-value.negative { color: var(--critical); }

.today-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.today-card .hero-label { margin-bottom: 4px; }
.today-value {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gasto);
}

/* ---- Stat tiles ---- */
.stat-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}

.stat-tile {
  background: var(--surface-1);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}

.stat-tile .label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-tile .value {
  font-size: 19px;
  font-weight: 700;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* ---- Upload ---- */
.dropzone {
  border: 2px dashed var(--baseline);
  border-radius: 18px;
  padding: 44px 20px;
  text-align: center;
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone.dragover { border-color: var(--cat-1); background: color-mix(in srgb, var(--cat-1) 6%, var(--surface-1)); }
.dropzone.state-success { border-color: var(--good); border-style: solid; }
.dropzone.state-error { border-color: var(--critical); border-style: solid; }
.dropzone-icon { color: var(--text-muted); margin-bottom: 14px; }
.dropzone.dragover .dropzone-icon { color: var(--cat-1); }
.dropzone.state-success .dropzone-icon { color: var(--good); }
.dropzone.state-error .dropzone-icon { color: var(--critical); }
.dropzone-title { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.dropzone-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 18px; }

.spinner {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 3px solid var(--gridline);
  border-top-color: var(--cat-1);
  margin: 0 auto 14px;
  animation: dc-spin 0.8s linear infinite;
  display: none;
}
.dropzone.processing .spinner { display: block; }
.dropzone.processing .dropzone-icon,
.dropzone.processing .dropzone-cta { display: none; }
@keyframes dc-spin { to { transform: rotate(360deg); } }

button.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--cat-1);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
button.primary:disabled { opacity: 0.5; cursor: default; }

button.secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-1);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  border-radius: 10px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}

#upload-status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}
#upload-status.error { color: var(--critical); }
#upload-status.ok { color: var(--good); }

/* ---- Filters ---- */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
  margin-bottom: 12px;
  padding-bottom: 2px;
}

select, input[type="text"], input[type="number"], input[type="date"], input[type="month"], input[type="password"] {
  background: var(--page);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
}

.filters select { font-size: 13px; } /* los <select> no disparan zoom en iOS */

.filters select { flex-shrink: 0; }

/* ---- Add expense ---- */
.field-label { font-size: 12px; font-weight: 700; color: var(--text-secondary); margin: 0 0 6px; display: block; }
.expense-form { display: flex; flex-direction: column; }
.expense-form input {
  width: 100%;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 12px;
}
.expense-form input:last-of-type { margin-bottom: 16px; }
#expense-status { font-size: 13px; color: var(--text-secondary); margin: 10px 0 0; text-align: center; }

.expense-form.quick-add {
  flex-direction: row;
  gap: 8px;
}
.expense-form.quick-add #expense-quick-input {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}
.expense-form.quick-add button.primary {
  flex-shrink: 0;
  padding: 13px 16px;
}

/* ---- Transaction cards ---- */
.tx-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gridline);
}
.tx-row:last-child { border-bottom: none; padding-bottom: 0; }
.tx-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.tx-main { flex: 1; min-width: 0; }
.tx-desc { font-size: 14px; font-weight: 700; margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-date { font-size: 12px; color: var(--text-muted); }
.tx-right { text-align: right; flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.tx-amount-wrap { text-align: right; }
.tx-amount { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tx-amount.ingreso { color: var(--good); }
.tx-amount.gasto { color: var(--text-primary); }
.tx-cat-select {
  border: none;
  background: none;
  padding: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 2px;
  -webkit-appearance: none;
  appearance: none;
  text-align: right;
}
.tx-del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.tx-del:hover { color: var(--critical); }

.tx-row.excluded { opacity: 0.55; }
.excluded-badge {
  display: inline-block;
  margin-top: 3px;
  background: var(--page);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 24px 0;
  font-size: 13px;
}

canvas { max-width: 100%; }

/* ---- Page header (title + icon button) ---- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 20px;
}
.page-header .large-title { margin: 0; }
.page-header.with-back { justify-content: flex-start; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--surface-1);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.icon-btn:hover { color: var(--text-primary); }
.icon-btn.sm { width: 30px; height: 30px; }

/* ---- Segmented control (día/semana/mes) ---- */
.segmented {
  display: flex;
  background: var(--surface-1);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 14px;
  box-shadow: inset 0 1px 0 var(--glass-highlight);
}
.segmented-btn {
  flex: 1;
  border: none;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 6px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.segmented-btn.active {
  background: color-mix(in srgb, var(--surface-1) 100%, white 25%);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(11, 11, 11, 0.12), inset 0 1px 0 var(--glass-highlight);
}

@media (prefers-color-scheme: dark) {
  .segmented-btn.active {
    background: color-mix(in srgb, var(--surface-1) 100%, white 12%);
  }
}

/* ---- Distintivo de entorno beta ---- */
.beta-banner {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: calc(7px + env(safe-area-inset-top, 0px)) 12px 7px;
  background: #7c3aed;
  color: #fff;
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}
.beta-badge {
  background: rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

/* ---- Hero: balance + resumen de hoy ---- */
.hero-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.today-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: color-mix(in srgb, var(--gasto) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--gasto) 30%, transparent);
  border-radius: 999px;
  padding: 7px 10px 7px 12px;
  cursor: pointer;
  font: inherit;
  flex-shrink: 0;
  margin-bottom: 4px;
  color: var(--gasto);
}
.today-chip svg { opacity: 0.7; }
.today-chip-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.85;
}
.today-chip-value {
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* ---- Hoja modal (reemplaza a prompt/alert del navegador) ---- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: var(--glass-scrim);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 16px;
}
.sheet {
  width: 100%;
  max-width: 440px;
  background: color-mix(in srgb, var(--surface-1) 100%, white 6%);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 14px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 40px rgba(11, 11, 11, 0.22), inset 0 1px 0 var(--glass-highlight);
  max-height: 86vh;
  overflow-y: auto;
  animation: sheet-in .24s cubic-bezier(.2, .8, .3, 1);
}
@keyframes sheet-in { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-color-scheme: dark) {
  .sheet { background: color-mix(in srgb, var(--surface-1) 100%, white 4%); }
}
.sheet-grip {
  width: 38px; height: 4px; border-radius: 999px;
  background: var(--baseline); margin: 0 auto 14px; opacity: .7;
}
.sheet-title { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
.sheet-desc { margin: 0 0 16px; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.sheet-desc:empty { display: none; }
.sheet-field { margin-bottom: 14px; }
.sheet-field input, .sheet-field select {
  width: 100%; border-radius: 12px; padding: 12px 14px; font-size: 16px;
}
.sheet-actions { display: flex; gap: 10px; margin-top: 4px; }
.sheet-actions button { flex: 1; justify-content: center; }
.sheet-choice {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; text-align: left; padding: 13px 14px; margin-bottom: 8px;
  background: var(--page); border: 1px solid var(--border); border-radius: 12px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text-primary);
  cursor: pointer;
}
.sheet-choice:hover { border-color: var(--cat-1); }
.sheet-choice .muted { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.sheet-choice.danger { color: var(--critical); }

/* ---- Toast ---- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 16px);
  max-width: min(420px, calc(100vw - 32px));
  background: rgba(20, 22, 24, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: #fff;
  border-radius: 14px;
  padding: 11px 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
  z-index: 300;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Puedes gastar hoy (safe to spend) ---- */
.safe-card { text-align: center; padding: 20px; }
.safe-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--text-muted);
}
.safe-value {
  font-size: 38px; font-weight: 800; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; margin: 4px 0 2px; color: var(--good);
}
.safe-value.warn { color: var(--gasto); }
.safe-value.over { color: var(--critical); }
.safe-sub { font-size: 12px; color: var(--text-secondary); }
.safe-bar {
  height: 6px; border-radius: 999px; background: var(--gridline);
  margin-top: 14px; overflow: hidden;
}
.safe-bar > span {
  display: block; height: 100%; border-radius: 999px;
  background: var(--good); transition: width .3s ease;
}
.safe-bar > span.warn { background: var(--cat-4); }
.safe-bar > span.over { background: var(--critical); }

/* ---- Presupuestos ---- */
.budget-row { padding: 11px 0; border-bottom: 1px solid var(--gridline); }
.budget-row:last-child { border-bottom: none; padding-bottom: 0; }
.budget-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.budget-name { font-size: 13.5px; font-weight: 700; }
.budget-nums { font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.budget-bar {
  height: 7px; border-radius: 999px; background: var(--gridline);
  margin-top: 7px; overflow: hidden;
}
.budget-bar > span { display: block; height: 100%; border-radius: 999px; transition: width .3s ease; }
.budget-left { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
.budget-left.over { color: var(--critical); font-weight: 700; }
.budget-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.budget-total {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; margin-bottom: 12px; padding-bottom: 12px;
  border-bottom: 1px solid var(--gridline);
}
.budget-total-value { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.budget-total-label { font-size: 11.5px; color: var(--text-muted); }

/* ---- Comparación mes a mes ---- */
.category-compare { font-size: 12.5px; color: var(--text-secondary); margin: -8px 0 14px; }
.category-compare .up { color: var(--critical); font-weight: 700; }
.category-compare .down { color: var(--good); font-weight: 700; }

/* ---- Patrimonio neto ---- */
.networth-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  text-align: center;
}
.networth-row > div { display: flex; flex-direction: column; gap: 3px; }
.nw-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.nw-value { font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.nw-value.strong { font-size: 20px; font-weight: 800; }
.nw-value.negative { color: var(--critical); }
.nw-value.positive { color: var(--good); }

/* ---- Deudas ---- */
.debt-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--gridline);
}
.debt-row:last-child { border-bottom: none; padding-bottom: 0; }
.debt-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.debt-name { font-size: 14px; font-weight: 700; }
.debt-balance { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--critical); }
.debt-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.debt-free {
  display: inline-block;
  margin-top: 6px;
  background: color-mix(in srgb, var(--good) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--good) 30%, transparent);
  color: var(--good);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 700;
}
.debt-bar { height: 5px; border-radius: 999px; background: var(--gridline); margin-top: 7px; overflow: hidden; }
.debt-bar > span { display: block; height: 100%; background: var(--critical); border-radius: 999px; }
.debt-actions { display: flex; gap: 6px; margin-top: 8px; }
.link-btn {
  background: none; border: none; padding: 0; font: inherit; font-size: 11.5px;
  font-weight: 700; color: var(--cat-1); cursor: pointer;
}
.link-btn.danger { color: var(--critical); }

/* ---- Personas / dinero de otros ---- */
.person-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--gridline); cursor: pointer;
}
.person-row:last-child { border-bottom: none; padding-bottom: 0; }
.person-name { font-size: 14px; font-weight: 700; }
.person-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.person-balance { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.person-balance.positive { color: var(--good); }
.person-balance.negative { color: var(--critical); }

/* ---- Suscripciones ---- */
.subs-total { display: flex; align-items: baseline; gap: 7px; margin-bottom: 14px; }
.subs-total > span:first-child { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; }
.subs-total-label { font-size: 12px; color: var(--text-muted); }
.sub-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--gridline);
}
.sub-row:last-child { border-bottom: none; padding-bottom: 0; }
.sub-name { font-size: 13.5px; font-weight: 700; }
.sub-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.sub-amount { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; flex-shrink: 0; }
.sub-warn {
  display: inline-block; margin-top: 4px;
  background: color-mix(in srgb, var(--gasto) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--gasto) 30%, transparent);
  color: var(--gasto);
  border-radius: 999px; padding: 1px 8px; font-size: 10.5px; font-weight: 700;
}

/* ---- Intereses ---- */
.interest-hero { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--critical); }
.interest-hours { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-top: 6px; }
.interest-note { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; }

/* ---- Proyección de fin de mes ---- */
.projection-card { display: flex; align-items: center; gap: 12px; }
.projection-icon { font-size: 22px; flex-shrink: 0; line-height: 1; }
.projection-title { font-size: 14px; font-weight: 700; }
.projection-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ---- Pregúntale a tus finanzas ---- */
.ask-answer {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-primary);
  margin-top: 14px;
  white-space: pre-wrap;
}
.ask-answer:empty { margin-top: 0; }
.ask-answer strong { font-weight: 800; }

/* ---- Month navigator ---- */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 14px;
}
.month-nav-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 130px;
  text-align: center;
}

/* ---- Category detail modal ---- */
.category-detail-box {
  max-width: 420px;
  width: 100%;
  text-align: left;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.category-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}
.category-detail-header h2 { margin: 0; font-size: 17px; font-weight: 800; }
.category-detail-total {
  font-size: 28px;
  font-weight: 800;
  margin: 6px 0 14px;
  font-variant-numeric: tabular-nums;
}
.category-detail-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* ---- Bottom tab bar ---- */
.tabbar {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex;
  background: color-mix(in srgb, var(--surface-1) 68%, transparent);
  backdrop-filter: blur(26px) saturate(180%);
  -webkit-backdrop-filter: blur(26px) saturate(180%);
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow:
    0 10px 30px rgba(11, 11, 11, 0.14),
    0 2px 6px rgba(11, 11, 11, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  padding: 8px 8px;
  max-width: 456px;
  margin: 0 auto;
  z-index: 10;
}
.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 8px 4px;
  border-radius: 18px;
  transition: background-color .15s ease, color .15s ease;
}
.tab-btn span { font-size: 10.5px; font-weight: 700; }
.tab-btn.active {
  color: var(--cat-1);
  background: color-mix(in srgb, var(--cat-1) 12%, transparent);
}

/* ---- Login overlay ---- */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--glass-scrim);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.login-box {
  background: var(--surface-1);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  box-shadow:
    0 1px 2px rgba(11, 11, 11, 0.03),
    0 12px 32px rgba(11, 11, 11, 0.12),
    inset 0 1px 0 var(--glass-highlight);
}

.login-box h2 { margin: 0 0 16px; display: flex; align-items: center; justify-content: center; gap: 8px; }

.login-box form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-box input { width: 100%; border-radius: 10px; padding: 12px 14px; }

#login-error {
  color: var(--critical);
  min-height: 1.2em;
  font-size: 0.85rem;
  margin: 10px 0 0;
}
