:root {
  --bg: #f1f5f4;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --text: #1f2933;
  --muted: #5f6b73;
  --border: #dde3e1;
  --primary: #0f766e;
  --primary-soft: #d9efec;
  --primary-contrast: #ffffff;
  --income: #15803d;
  --expense: #c2410c;
  --warning: #b45309;
  --danger: #b91c1c;
  --series-income: #1baf7a;
  --series-expense: #eb6834;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  --tabbar-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1716;
    --surface: #182321;
    --surface-2: #1f2c29;
    --text: #e6ecea;
    --muted: #9aa8a4;
    --border: #2a3835;
    --primary: #2bb3a3;
    --primary-soft: #173a36;
    --primary-contrast: #06201d;
    --income: #4ade80;
    --expense: #fb923c;
    --warning: #fbbf24;
    --danger: #f87171;
    --series-income: #199e70;
    --series-expense: #d95926;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
}

button, input, select { font: inherit; color: inherit; }
h2 { margin: 0 0 12px; font-size: 1.05rem; }
h3 { margin: 0 0 10px; font-size: 0.95rem; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 0.9rem; margin-bottom: 10px; }
.small { font-size: 0.82rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
[hidden] { display: none !important; }

/* ---------- Encabezado ---------- */
.app-header {
  position: sticky; top: 0; z-index: 10;
  background: var(--primary);
  color: var(--primary-contrast);
  padding: env(safe-area-inset-top) 16px 0;
}
.header-inner {
  max-width: 760px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 56px;
}
.brand { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; }
.app-header h1 { margin: 0; font-size: 1.15rem; white-space: nowrap; }
.book-label {
  background: none; border: 0; padding: 0 0 4px; cursor: pointer;
  color: inherit; opacity: 0.9; font-size: 0.8rem;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.account-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 0; border-radius: 999px;
  width: 40px; height: 40px; padding: 0; flex: 0 0 auto;
  cursor: pointer; display: grid; place-items: center;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.05rem; font-weight: 700; overflow: hidden;
  color: var(--primary-contrast);
  flex: 0 0 auto;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.small { width: 36px; height: 36px; background: var(--primary); font-size: 0.95rem; }

/* ---------- Carga ---------- */
.loading { display: grid; place-items: center; gap: 12px; padding: 80px 16px; color: var(--muted); }
.spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid var(--border); border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Diseño general ---------- */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 16px calc(var(--tabbar-h) + 96px + env(safe-area-inset-bottom));
  display: grid;
  gap: 16px;
}
.view { display: grid; gap: 16px; min-width: 0; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-head h2 { margin: 0; }
.intro p { margin-bottom: 12px; }

/* ---------- Botones ---------- */
.btn {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-contrast);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none;
}
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.small { min-height: 36px; padding: 6px 14px; font-size: 0.9rem; }
.btn.block { width: 100%; }
.btn.danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--danger); }
.btn.google { background: #fff; color: #1f2933; border-color: var(--border); }
.btn:disabled { opacity: 0.5; cursor: default; }
.g-logo {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 800; font-size: 0.9rem; color: #fff;
  background: conic-gradient(#ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0);
}
.icon-btn {
  width: 44px; height: 44px; flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 1.6rem; line-height: 1;
  cursor: pointer;
}
.icon-btn.small { width: 36px; height: 36px; font-size: 1rem; }
.icon-btn:hover { border-color: var(--primary); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.link-btn {
  background: none; border: 0; padding: 2px 4px;
  color: var(--primary); text-decoration: underline; cursor: pointer; font-size: 0.85rem;
}
.button-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.button-row .btn { flex: 1 1 auto; }

/* ---------- Aviso de sesión ---------- */
.banner {
  display: flex; flex-direction: column; gap: 12px;
  background: var(--primary-soft); border-color: transparent;
}
.banner p { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.signin-actions { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.signin-actions .link-btn { font-size: 0.9rem; padding: 6px; }
.password-note { font-size: 0.85rem; color: var(--muted); margin: 12px 0 8px; }
@media (min-width: 560px) {
  .banner { flex-direction: row; align-items: center; justify-content: space-between; }
  .banner .btn, .signin-actions { flex: 0 0 auto; }
}

/* ---------- Mes ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-label { text-align: center; flex: 1; }
#month-name, #year-name { display: block; font-size: 1.2rem; font-weight: 600; }

/* ---------- Saldo ---------- */
.hero { display: flex; flex-direction: column; gap: 2px; text-align: center; }
.hero-label { color: var(--muted); font-size: 0.9rem; }
.hero-value { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-split {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border);
}
.hero-split > div { display: flex; flex-direction: column; min-width: 0; }
.mini-label { color: var(--muted); font-size: 0.8rem; }
.mini-value { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.cmp { font-size: 0.75rem; color: var(--muted); min-height: 1em; }
.cmp.good, .limit.good { color: var(--income); }
.cmp.bad, .limit.bad { color: var(--danger); }
.income { color: var(--income); }
.expense { color: var(--expense); }
.neutral { color: var(--muted); }

/* ---------- Cuentas ---------- */
.account-strip {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 2px 16px;
}
.account-strip::-webkit-scrollbar { display: none; }
.account-chip {
  flex: 0 0 auto; min-width: 130px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 10px 12px; border-radius: 12px; cursor: pointer; text-align: left;
  border: 1px solid var(--border); border-left: 4px solid var(--acc-color, var(--primary));
  background: var(--surface-2);
}
.account-chip.active { border-color: var(--acc-color, var(--primary)); box-shadow: 0 0 0 1px var(--acc-color, var(--primary)); }
.acc-name { font-size: 0.85rem; color: var(--muted); white-space: nowrap; }
.acc-bal { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Presupuesto ---------- */
.progress { height: 12px; border-radius: 6px; background: var(--border); overflow: hidden; }
.progress > span {
  display: block; height: 100%; width: 0;
  background: var(--primary); border-radius: 6px;
  transition: width 0.3s ease;
}
.progress.warn > span { background: var(--warning); }
.progress.over > span { background: var(--danger); }
.budget-text { margin-top: 8px; font-size: 0.95rem; }
.budget-text strong.over { color: var(--danger); }

/* ---------- Gráficos ---------- */
.chart-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut { width: 190px; height: 190px; max-width: 100%; }
.donut .center-label { font-size: 7px; fill: var(--muted); }
.donut .center-value { font-size: 10px; font-weight: 700; fill: var(--text); }
.legend { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 10px; }
.legend li { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; column-gap: 8px; row-gap: 4px; font-size: 0.9rem; }
.legend .swatch { width: 14px; height: 14px; border-radius: 4px; }
.legend .amount { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }
.legend .pct { color: var(--muted); font-weight: 400; margin-left: 4px; }
.legend .bar { grid-column: 2 / -1; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.legend .bar > span { display: block; height: 100%; }
.legend .limit { grid-column: 2 / -1; font-size: 0.78rem; color: var(--muted); }
.legend .limit.strong { font-weight: 600; }
@media (min-width: 560px) {
  .chart-wrap { flex-direction: row; }
  .donut { flex: 0 0 190px; }
}

.legend-inline { display: flex; gap: 16px; font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.legend-inline span { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.dot.income { background: var(--series-income); }
.dot.expense { background: var(--series-expense); }

.bars-wrap { position: relative; }
.bars { width: 100%; height: auto; display: block; overflow: visible; }
.bars .grid { stroke: var(--border); stroke-width: 1; }
.bars .axis { stroke: var(--muted); stroke-width: 1; opacity: 0.6; }
.bars .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.bars .bar.income { fill: var(--series-income); }
.bars .bar.expense { fill: var(--series-expense); }
.bars .hit { fill: transparent; cursor: pointer; }
.bars .hit:hover { fill: var(--text); fill-opacity: 0.05; }
.chart-tip {
  position: absolute; top: 0; z-index: 2; pointer-events: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  padding: 8px 10px; font-size: 0.82rem; min-width: 170px;
}
.chart-tip strong { display: block; margin-bottom: 4px; }
.tip-row { display: grid; grid-template-columns: 12px 1fr auto; gap: 6px; align-items: center; }
.tip-row b { font-variant-numeric: tabular-nums; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; min-width: 0; }
.stat.totals { grid-column: 1 / -1; gap: 6px; }
.total-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.stat:not(.totals) .stat-value { font-size: 1.02rem; white-space: nowrap; overflow-wrap: normal; }
.total-row + .total-row { padding-top: 6px; border-top: 1px solid var(--border); }
.stat-value { font-size: 1.15rem; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
@media (min-width: 640px) {
  .stats { grid-template-columns: 2fr 1fr 1fr; }
  .stat.totals { grid-column: auto; }
}

.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.year-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.year-table th, .year-table td { padding: 8px 4px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.year-table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.year-table .num, .year-table th:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.year-table tfoot td { font-weight: 700; border-bottom: 0; }
.year-table tr.clickable { cursor: pointer; }
.year-table tr.clickable:hover, .year-table tr.clickable:focus-visible { background: var(--surface-2); outline: none; }

/* ---------- Filtros ---------- */
.filters { display: grid; gap: 10px; margin-bottom: 8px; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 0 12px;
}
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent;
  min-height: 44px; font-size: 16px; outline: none;
}
.search:focus-within { border-color: var(--primary); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips.scroll {
  flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
  margin: 0 -16px; padding: 0 16px 2px;
}
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; min-height: 34px;
  font-size: 0.85rem; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-contrast); font-weight: 600; }
.filter-summary { font-size: 0.85rem; color: var(--muted); margin: 4px 0; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline select { width: auto; flex: 1; }

/* ---------- Listas ---------- */
.day-group + .day-group { margin-top: 8px; }
.day-head {
  display: flex; justify-content: space-between;
  font-size: 0.8rem; color: var(--muted); font-weight: 600;
  padding: 8px 0 4px; border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.02em;
}
.movement, .row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  column-gap: 12px;
  align-items: center;
  padding: 10px 6px;
  margin: 0 -6px;
  width: calc(100% + 12px);
  border: 0; border-radius: 12px;
  background: none; text-align: left; cursor: pointer;
}
.row.static { cursor: default; }
.movement:hover, .movement:focus-visible, .row:not(.static):hover, .row:not(.static):focus-visible { background: var(--surface-2); }
.row.paused { opacity: 0.55; }
.movement .icon, .row .icon {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.25rem;
}
.info { min-width: 0; }
.info .title { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.info .note { color: var(--muted); font-size: 0.85rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.movement .amount, .row .amount { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .amount { color: var(--muted); }
.row .amount.income { color: var(--income); }
.row .amount.expense { color: var(--expense); }
.rows { display: grid; }

.empty { color: var(--muted); text-align: center; margin: 16px 0 4px; display: grid; justify-items: center; gap: 10px; }
.footer-note { text-align: center; color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.steps { margin: 8px 0 0; padding-left: 20px; color: var(--muted); font-size: 0.9rem; display: grid; gap: 4px; }

/* ---------- Metas ---------- */
.goal-list { display: grid; gap: 12px; }
.goal { border-left: 5px solid var(--goal-color); }
.goal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.goal-icon {
  width: 46px; height: 46px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center; font-size: 1.5rem;
  background: color-mix(in srgb, var(--goal-color) 18%, transparent);
}
.goal-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.goal-title strong { overflow-wrap: anywhere; }
.goal-bar > span { background: var(--goal-color); }
.goal-info { margin-top: 8px; font-size: 0.9rem; }
.goal.done .goal-info { font-weight: 600; color: var(--income); }

/* ---------- Ajustes ---------- */
.account-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.account-row .avatar { width: 44px; height: 44px; background: var(--primary); }
.account-row strong { display: block; }
.account-row small { color: var(--muted); overflow-wrap: anywhere; }
.sync-status { font-size: 0.85rem; color: var(--muted); margin-bottom: 12px; }
#share-info .field { margin-bottom: 12px; }
#share-info .rows { margin: 8px 0 4px; }

/* ---------- Barra de pestañas ---------- */
.tabbar {
  position: fixed; z-index: 15; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 0 max(8px, calc(50% - 380px)) env(safe-area-inset-bottom);
}
.tabbar button {
  height: var(--tabbar-h);
  background: none; border: 0; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 0.75rem; color: var(--muted);
}
.tabbar button span { font-size: 1.3rem; filter: grayscale(0.6); opacity: 0.75; }
.tabbar button.active { color: var(--primary); font-weight: 700; }
.tabbar button.active span { filter: none; opacity: 1; }

/* ---------- Botón flotante ---------- */
.fab {
  position: fixed; z-index: 20;
  right: max(20px, calc(50% - 360px));
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%;
  border: 0; background: var(--primary); color: var(--primary-contrast);
  font-size: 2rem; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.fab:active { transform: scale(0.95); }

/* ---------- Hojas (ventanas desde abajo) ---------- */
.sheet {
  border: 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  width: 100%; max-width: 560px;
  max-height: 92vh; overflow-y: auto;
  margin: auto auto 0;
  border-radius: 20px 20px 0 0;
  background: var(--surface); color: var(--text);
}
.sheet[open] { animation: slide-up 0.2s ease-out; }
.sheet::backdrop { background: rgba(0, 0, 0, 0.45); }
@keyframes slide-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 600px) {
  .sheet { margin: auto; border-radius: 20px; padding-bottom: 20px; }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; }
.sheet-actions { display: flex; gap: 8px; margin-top: 16px; }
.sheet-actions .btn.primary { flex: 1; }
.sheet-text { margin-bottom: 8px; }
.form { display: grid; gap: 12px; }
.form .sheet-actions { margin-top: 4px; }
.form-note { font-size: 0.9rem; color: var(--muted); }
.link-input {
  width: 100%; min-height: 44px; padding: 10px 12px; margin-top: 8px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2);
  font-size: 0.9rem;
}

.segmented {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.type-toggle { margin-bottom: 12px; }
.form .type-toggle { margin-bottom: 0; }
.seg-option { position: relative; }
.seg-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-option span { display: block; text-align: center; padding: 10px 6px; font-weight: 600; color: var(--muted); font-size: 0.95rem; }
.seg-option input:checked + span { background: var(--primary); color: var(--primary-contrast); }
.seg-option input:checked + span.t-gasto { background: var(--expense); color: #fff; }
.seg-option input:checked + span.t-ingreso { background: var(--income); color: #fff; }
.seg-option input:checked + span.t-transfer { background: #475569; color: #fff; }
.seg-option input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }

.amount-field {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  border-bottom: 2px solid var(--border); margin-bottom: 16px; padding: 4px 0;
}
.amount-field:focus-within { border-bottom-color: var(--primary); }
.amount-field .currency { font-size: 2rem; font-weight: 700; color: var(--muted); }
.amount-field input {
  border: 0; background: transparent; outline: none;
  font-size: 2.2rem; font-weight: 800; width: 100%; max-width: 280px;
  text-align: center; font-variant-numeric: tabular-nums;
}

.category-grid {
  border: 0; margin: 0 0 12px; padding: 0;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
@media (min-width: 480px) { .category-grid { grid-template-columns: repeat(4, 1fr); } }
.category-grid legend { font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; padding: 0; }
.cat-option { position: relative; min-width: 0; }
.cat-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.cat-option span {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--surface-2);
  font-size: 0.8rem; font-weight: 600; text-align: center;
  overflow: hidden; text-overflow: ellipsis;
}
.cat-option span b { font-size: 1.6rem; font-weight: 400; line-height: 1.2; }
.cat-option input:checked + span { border-color: var(--cat-color, var(--primary)); background: var(--cat-soft, var(--primary-soft)); }
.cat-option input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

.form-row { display: grid; grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
@media (min-width: 480px) { .form-row { grid-template-columns: 1fr 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 0.85rem; color: var(--muted); }
.field .hint { font-size: 0.78rem; color: var(--muted); }
.field input, .field select {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2);
  font-size: 16px; /* evita el zoom automático en iOS */
}
.field input:focus, .field select:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; font-size: 0.95rem; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.form-error { color: var(--danger); font-size: 0.9rem; }
#movement-form .form-error, #recurring-note { margin-top: 8px; }

.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.icon-opt {
  height: 42px; border-radius: 10px; border: 2px solid transparent;
  background: var(--surface-2); font-size: 1.3rem; cursor: pointer;
}
.icon-opt.active { border-color: var(--primary); background: var(--primary-soft); }
.icon-custom {
  grid-column: span 2; height: 42px; border-radius: 10px; text-align: center;
  border: 1px dashed var(--border); background: var(--surface-2); font-size: 1rem;
}
.color-row { display: flex; flex-wrap: wrap; gap: 8px; }
.color-opt {
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
  border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border);
}
.color-opt.active { box-shadow: 0 0 0 2px var(--text); }

/* ---------- Aviso ---------- */
.toast {
  position: fixed; z-index: 30;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + 88px + env(safe-area-inset-bottom));
  width: max-content; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 12px;
  background: #1f2933; color: #fff;
  padding: 12px 16px; border-radius: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  font-size: 0.95rem;
}
.toast button {
  background: none; border: 0; color: #5eead4; font-weight: 700; cursor: pointer; padding: 4px;
}

/* ---------- Gastos compartidos ---------- */
.split-wrap { display: grid; gap: 10px; margin-bottom: 12px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.split-members { border: 0; margin: 0; padding: 0; }
.split-members legend, .checks legend { font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; padding: 0; }
.split-members .check, .checks .check { min-height: 36px; }
.checks { border: 0; margin: 0; padding: 0; }
.family-me { font-size: 1.15rem; font-weight: 700; margin-bottom: 8px; }
.row.debt { grid-template-columns: 1fr auto; }
.settle-right { display: flex; align-items: center; gap: 8px; font-variant-numeric: tabular-nums; }
.row.static:has(.settle-right) { grid-template-columns: 1fr auto; }

/* ---------- Importar del banco ---------- */
.file-btn { position: relative; margin: 12px 0 8px; cursor: pointer; }
.import-preview { margin: 12px 0; display: grid; gap: 6px; }
.import-count { font-weight: 600; margin-bottom: 6px; }
.import-mini {
  display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  font-size: 0.85rem; padding: 6px 8px; border-radius: 8px; background: var(--surface-2);
}
.import-mini .desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-tools { display: flex; gap: 12px; margin: 4px 0 8px; }
.import-list { display: grid; gap: 6px; margin: 8px 0 12px; }
.import-row {
  display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start;
  padding: 10px; border: 1px solid var(--border); border-radius: 12px;
}
.import-row.off { opacity: 0.5; }
.import-row input[type=checkbox] { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--primary); }
.import-top { display: flex; justify-content: space-between; gap: 8px; }
.import-top .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-top b { white-space: nowrap; font-variant-numeric: tabular-nums; }
.import-bottom { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.import-bottom .note { color: var(--muted); font-size: 0.82rem; white-space: nowrap; }
.import-bottom select {
  min-height: 34px; max-width: 60%; padding: 4px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 0.85rem;
}
.import-go { position: sticky; bottom: 0; }

/* ---------- Plan ---------- */
.waterfall { display: grid; gap: 2px; }
.wf-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.wf-label { display: flex; flex-direction: column; min-width: 0; }
.wf-label small { color: var(--muted); font-size: 0.78rem; }
.wf-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.wf-row.income b { color: var(--income); }
.wf-row.expense b { color: var(--expense); }
.wf-row.goal b { color: var(--primary); }
.wf-row.total { border-bottom: 0; padding-top: 12px; }
.wf-row.total b { font-size: 1.3rem; }
.waterfall .muted, .waterfall .form-error { margin-top: 6px; }
.plan-rows { display: grid; gap: 12px; margin: 8px 0 14px; }
.plan-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.92rem; margin-bottom: 4px; }
.plan-amounts { font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.plan-row.over .plan-amounts { color: var(--danger); font-weight: 600; }
.plan-row .progress { height: 8px; }
.plan-note { display: block; color: var(--muted); font-size: 0.78rem; margin-top: 3px; }
.plan-row.over .plan-note { color: var(--danger); }
.goal-status { font-weight: 800; font-size: 1.1rem; }
.goal-status.ok { color: var(--income); }
.goal-status.bad { color: var(--warning); }
.tip-total { font-weight: 600; margin-bottom: 10px; color: var(--income); }
.tip-list { display: grid; gap: 10px; }
.tip {
  display: grid; grid-template-columns: auto 1fr; gap: 10px;
  padding: 12px; border-radius: 12px; background: var(--surface-2); border-left: 4px solid var(--primary);
}
.tip.warn { border-left-color: var(--warning); }
.tip.good { border-left-color: var(--income); }
.tip-icon { font-size: 1.4rem; line-height: 1.2; }
.tip-body p { font-size: 0.88rem; margin: 4px 0 6px; color: var(--text); }
.tip-body .btn { margin-top: 4px; }
.tip-saving { display: inline-block; font-size: 0.8rem; font-weight: 700; color: var(--income); }
.year-mini { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.payslip-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
@media (min-width: 560px) { .payslip-grid { grid-template-columns: repeat(6, 1fr); } }
.ps-cell {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px; border-radius: 10px; border: 1px dashed var(--border); background: none; cursor: pointer;
  font-size: 0.8rem; min-height: 64px;
}
.ps-cell.has { border-style: solid; background: var(--surface-2); }
.ps-cell b { font-variant-numeric: tabular-nums; font-size: 0.82rem; }
.ps-cell small.ok { color: var(--income); font-size: 0.7rem; }
.ps-cell small.muted { color: var(--muted); font-size: 0.7rem; margin: 0; }
.ps-month { color: var(--muted); font-weight: 600; }
.payslip-totals { display: grid; gap: 6px; margin-bottom: 8px; }
.docs-status { display: grid; gap: 6px; margin: 8px 0; }
.docs-row { display: flex; justify-content: space-between; gap: 8px; font-size: 0.85rem; padding: 8px; border-radius: 8px; background: var(--surface-2); }
.docs-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.docs-kind { white-space: nowrap; font-weight: 600; }
.docs-kind.warn { color: var(--warning); white-space: normal; text-align: right; }
.docs-status .btn { margin-top: 6px; }
.ps-review { padding: 12px; border: 1px solid var(--border); border-radius: 12px; display: grid; gap: 8px; }
.ps-review.warn { border-color: var(--warning); }
.ps-review.off { opacity: 0.5; }
.ps-review-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.ps-review-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ps-review-head input { width: 20px; height: 20px; accent-color: var(--primary); }
.ps-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ps-fields .field input { min-height: 38px; padding: 6px 10px; }
.tabbar button { font-size: 0.7rem; }
