/* ==========================================================================
   Caudal · sistema de diseño
   Paleta base: #134074 · #13315C · #0B2545 · #8DA9C4 · #EEF4ED
   Tipografía: Cabinet Grotesk (Fontshare) · Iconos: MingCute
   ========================================================================== */

@font-face { font-family: "Cabinet Grotesk"; src: url("../vendor/fonts/cabinet-grotesk-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Cabinet Grotesk"; src: url("../vendor/fonts/cabinet-grotesk-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Cabinet Grotesk"; src: url("../vendor/fonts/cabinet-grotesk-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Cabinet Grotesk"; src: url("../vendor/fonts/cabinet-grotesk-800.woff2") format("woff2"); font-weight: 800; font-display: swap; }

/* ---------- Tokens · modo claro ---------- */
:root {
  /* paleta de marca */
  --yale: #134074;
  --berkeley: #13315C;
  --oxford: #0B2545;
  --powder: #8DA9C4;
  --mint: #EEF4ED;

  /* superficies */
  --bg: #EEF4ED;
  --side: #E4ECE5;
  --surface: #FFFFFF;
  --surface-2: #F5F8F5;
  --surface-3: #EAF0EC;
  --line: rgba(19, 49, 92, .10);
  --line-strong: rgba(19, 49, 92, .20);

  /* texto */
  --ink: #0B2545;
  --ink-2: #13315C;
  --muted: #546D8A;
  --faint: #8597AC;

  /* acción */
  --primary: #134074;
  --primary-hover: #13315C;
  --on-primary: #EEF4ED;
  --accent-soft: rgba(141, 169, 196, .28);
  --focus: rgba(19, 64, 116, .28);

  /* estados (siempre con icono + texto) */
  --good: #1E7A4C;
  --good-bg: rgba(30, 122, 76, .10);
  --bad: #C0392B;
  --bad-bg: rgba(192, 57, 43, .09);
  --exact: #134074;
  --exact-bg: rgba(141, 169, 196, .30);

  /* gráficos (validado: banda L, croma, CVD, contraste vs #FFF) */
  --c-needs: #1D5BA6;
  --c-wants: #C08A2E;
  --c-save: #2F9C8A;
  --c-debt: #9B3D7A;
  --c-inv: #8B6FD6;
  --c-none: #8597AC;
  --c-brand: #134074;
  --c-brand-soft: #B9CBDC;
  --c-track: #E6EDE8;
  --grid: rgba(19, 49, 92, .08);

  --shadow: 0 1px 2px rgba(11, 37, 69, .04), 0 4px 16px rgba(11, 37, 69, .05);
  --shadow-pop: 0 12px 40px rgba(11, 37, 69, .18);

  /* escala */
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-pill: 999px;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --fs-xs: 12px; --fs-sm: 13px; --fs-md: 14px; --fs-base: 15px; --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 28px; --fs-3xl: 36px; --fs-4xl: 46px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  color-scheme: light;
}

/* ---------- Tokens · modo oscuro ---------- */
:root[data-theme="dark"] {
  /* Base más profunda y neutra (derivada de Oxford #0B2545) para que las
     tarjetas se separen del fondo y el texto tenga contraste alto (AA/AAA). */
  --bg: #071629;
  --side: #050F1E;
  --surface: #0E2240;
  --surface-2: #132B4D;
  --surface-3: #1A355B;
  --line: rgba(180, 199, 217, .14);
  --line-strong: rgba(180, 199, 217, .30);

  --ink: #F3F7F2;      /* 14.7:1 sobre tarjeta */
  --ink-2: #DCE6EF;    /* 12.6:1 */
  --muted: #B4C7D9;    /*  9.2:1 */
  --faint: #90A9C2;    /*  6.5:1 */

  --primary: #A9C3DC;
  --primary-hover: #C3D6E8;
  --on-primary: #071629;
  --accent-soft: rgba(141, 169, 196, .18);
  --focus: rgba(169, 195, 220, .40);

  --good: #6BDDA0;
  --good-bg: rgba(107, 221, 160, .14);
  --bad: #FF9488;
  --bad-bg: rgba(255, 148, 136, .14);
  --exact: #B6D0EC;
  --exact-bg: rgba(182, 208, 236, .16);

  /* validado contra superficie #0E2240 */
  --c-needs: #5592DF;
  --c-wants: #BC8A30;
  --c-save: #2DAA94;
  --c-debt: #B04A86;
  --c-inv: #9783E2;
  --c-none: #6A87A6;
  --c-brand: #A9C3DC;
  --c-brand-soft: #34557E;
  --c-track: #1D3A60;
  --grid: rgba(180, 199, 217, .10);

  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 6px 20px rgba(0, 0, 0, .25);
  --shadow-pop: 0 16px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}
/* En oscuro el texto fino se lee peor: un punto más de peso en lo pequeño */
:root[data-theme="dark"] .eyebrow, :root[data-theme="dark"] .sheet th, :root[data-theme="dark"] .nav-label,
:root[data-theme="dark"] .kv .k, :root[data-theme="dark"] .sheet-total .lbl { font-weight: 800; }
:root[data-theme="dark"] .legend, :root[data-theme="dark"] .hint, :root[data-theme="dark"] .t-muted,
:root[data-theme="dark"] .nav-item, :root[data-theme="dark"] .view-head p { font-weight: 500; }
:root[data-theme="dark"] .chart text { fill: var(--muted); font-weight: 500; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Cabinet Grotesk", system-ui, sans-serif;
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
  font-variant-numeric: tabular-nums;
}
body.theming, body.theming * { transition: background-color .35s var(--ease), border-color .35s var(--ease), color .35s var(--ease) !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.ic { width: 1.15em; height: 1.15em; flex: none; display: inline-block; vertical-align: -0.2em; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w, 236px) 1fr; height: 100vh; height: 100dvh; transition: grid-template-columns .3s var(--ease); }
body.nav-closed .app { --side-w: 0px; }
body.nav-closed .side { visibility: hidden; }

.side {
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: var(--s-5) var(--s-3);
  gap: var(--s-2);
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark { width: 30px; height: 30px; }
.brand-name { font-weight: 800; font-size: 22px; letter-spacing: -.02em; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: var(--fs-xs); color: var(--faint); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; padding: 14px 12px 6px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: var(--r-md);
  border: 0; background: none; text-align: left; width: 100%;
  color: var(--ink-2); font-weight: 500; font-size: var(--fs-md);
  transition: background .15s, color .15s;
}
.nav-item .ic { font-size: 18px; color: var(--muted); transition: color .15s; }
.nav-item:hover { background: var(--accent-soft); }
.nav-item.active { background: var(--surface); color: var(--ink); font-weight: 700; box-shadow: var(--shadow); }
:root[data-theme="dark"] .nav-item.active { background: var(--surface-2); }
.nav-item.active .ic { color: var(--primary); }
.nav-item .dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; }
.dot.st-over { background: var(--bad); }
.dot.st-under { background: var(--good); }
.dot.st-exact { background: var(--exact); }

.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--s-2); padding-top: var(--s-4); }
.theme-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px;
  background: var(--surface-3); border-radius: var(--r-pill); position: relative;
}
:root[data-theme="dark"] .theme-switch { background: var(--side); border: 1px solid var(--line); }
.theme-switch button {
  border: 0; background: none; border-radius: var(--r-pill); padding: 7px 0;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: 500; color: var(--muted); position: relative; z-index: 1;
  transition: color .2s; white-space: nowrap; min-width: 0;
}
.theme-switch button .ic { font-size: 14px; }
.theme-switch button[aria-pressed="true"] { color: var(--ink); font-weight: 700; }
.theme-switch .thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 10px) / 3);
  background: var(--surface); border-radius: var(--r-pill); box-shadow: var(--shadow);
  transition: transform .35s var(--ease);
}
:root[data-theme="dark"] .theme-switch .thumb { background: var(--surface-3); }
/* El "pulgar" se coloca según la opción elegida (data-mode), no según el tema resultante */
:root[data-mode="system"] .theme-switch .thumb { transform: translateX(calc(100% + 2px)); }
:root[data-mode="dark"] .theme-switch .thumb { transform: translateX(calc(200% + 4px)); }
.side-btn {
  display: flex; align-items: center; gap: 10px; border: 0; background: none;
  padding: 8px 12px; border-radius: var(--r-md); color: var(--muted); font-size: var(--fs-sm); width: 100%; text-align: left;
}
.side-btn:hover { background: var(--accent-soft); color: var(--ink); }
.side-meta { font-size: var(--fs-xs); color: var(--faint); padding: 4px 12px 0; }

/* ---------- Main ---------- */
.main { overflow-y: auto; overflow-x: hidden; position: relative; min-width: 0; }
.content, .view, .grid > * { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--s-4);
  padding: 18px 36px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.main.scrolled .topbar { border-bottom-color: var(--line); }
.month-switch { display: flex; align-items: center; gap: 6px; }
.month-title {
  font-weight: 800; font-size: var(--fs-3xl); letter-spacing: -.03em; line-height: 1;
  margin: 0 8px; min-width: 7ch; white-space: nowrap;
}
.month-title .yr { color: var(--faint); font-weight: 700; }
.icon-btn {
  width: 36px; height: 36px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--surface); display: inline-grid; place-items: center; color: var(--ink-2);
  transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.icon-btn:active { transform: scale(.96); }
.icon-btn .ic { font-size: 18px; }
.chip-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-pill);
  padding: 6px 12px; font-size: var(--fs-sm); font-weight: 500; color: var(--ink-2);
}
.chip-btn:hover { border-color: var(--line-strong); }
.topbar .spacer { flex: 1; }
.save-state { font-size: var(--fs-sm); color: var(--faint); display: flex; align-items: center; gap: 6px; transition: opacity .3s; }
.save-state.saving { color: var(--muted); }
.balance-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 16px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line);
}
.balance-pill .lbl { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.balance-pill .val { font-weight: 800; font-size: var(--fs-lg); }

.content { padding: 8px 36px 56px; max-width: var(--content-w, 1400px); margin-inline: auto; }
body.nav-closed { --content-w: 1180px; }
.view { animation: viewIn .4s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Tipografía de vista ---------- */
.view-head { display: flex; align-items: flex-end; gap: var(--s-6); margin: 8px 0 22px; flex-wrap: wrap; }
.view-head h1 { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; margin: 0; display: flex; align-items: center; gap: 12px; }
.view-head h1 .ic { color: var(--primary); }
.view-head p { margin: 4px 0 0; color: var(--muted); max-width: 62ch; }
.view-head .grow { flex: 1; }

/* ---------- Tarjetas ---------- */
.grid { display: grid; gap: var(--s-5); }
.g-hero { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.g-12 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
.mt { margin-top: var(--s-5); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s-6); box-shadow: var(--shadow); min-width: 0;
}
.card.flush { padding: 0; }
.card-head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-head h2, .card-head h3 { margin: 0; font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.01em; display: flex; align-items: center; gap: 10px; }
.card-head h2 .ic, .card-head h3 .ic { color: var(--muted); }
.card-head .sub { color: var(--muted); font-size: var(--fs-sm); }
.card-head .end { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.card.flush .card-head { padding: var(--s-5) var(--s-6) 0; }
.eyebrow { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }

/* ---------- Meta del mes ---------- */
.goal-card { display: flex; flex-direction: column; gap: var(--s-3); }
.goal-input {
  width: 100%; resize: none; border: 1px solid transparent; background: transparent;
  font-size: var(--fs-xl); font-weight: 700; letter-spacing: -.01em; line-height: 1.3;
  padding: 6px 10px; margin: 0 -10px; border-radius: var(--r-md); min-height: 64px;
  transition: border-color .15s, background .15s;
}
.goal-input::placeholder { color: var(--faint); font-weight: 500; }
.goal-input:hover { background: var(--surface-2); }
.goal-input:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 4px var(--focus); }
.goal-amount { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; color: var(--muted); font-size: var(--fs-sm); }
.goal-amount .field { width: 150px; }
.goal-progress { display: flex; flex-direction: column; gap: 6px; }
.goal-progress .row { display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--muted); }
.goal-progress b { color: var(--ink); }

/* ---------- Saldo ---------- */
.hero-balance { display: flex; flex-direction: column; gap: var(--s-4); position: relative; overflow: hidden; }
.hero-balance .big { font-size: var(--fs-4xl); font-weight: 800; letter-spacing: -.035em; line-height: 1; }
.hero-balance .formula { display: flex; gap: var(--s-6); flex-wrap: wrap; }
.kv { display: flex; flex-direction: column; gap: 2px; }
.kv .k { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.kv .v { font-size: var(--fs-lg); font-weight: 700; }
.flow-bar { display: flex; height: 12px; border-radius: 99px; overflow: hidden; background: var(--c-track); gap: 2px; }
.flow-bar span { display: block; height: 100%; transition: width .6s var(--ease); }
.flow-bar span:first-child { border-radius: 99px 0 0 99px; }
.flow-bar span:last-child { border-radius: 0 99px 99px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: var(--fs-sm); color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend b { color: var(--ink); font-weight: 700; }

/* ---------- Estados ---------- */
.st { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: var(--fs-sm); padding: 3px 10px 3px 7px; border-radius: var(--r-pill); white-space: nowrap; }
.st .ic { font-size: 15px; }
.st-under { color: var(--good); background: var(--good-bg); }
.st-over { color: var(--bad); background: var(--bad-bg); }
.st-exact { color: var(--exact); background: var(--exact-bg); }
.st-none { color: var(--muted); background: var(--surface-3); }
.t-under { color: var(--good) !important; }
.t-over { color: var(--bad) !important; }
.t-exact { color: var(--exact) !important; }
.t-muted { color: var(--muted); }

/* ---------- Barras de progreso ---------- */
.meter { position: relative; height: 8px; background: var(--c-track); border-radius: 99px; overflow: visible; }
.meter > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; background: var(--c-brand); transition: width .6s var(--ease), background .3s; max-width: 100%; }
.meter.st-under > span { background: var(--good); }
.meter.st-over > span { background: var(--bad); }
.meter.st-exact > span { background: var(--exact); }
.meter .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 2px; opacity: .55; }
.meter.lg { height: 12px; }

/* ---------- Tablas editables ---------- */
.table-wrap { overflow-x: auto; }
table.sheet { width: 100%; border-collapse: separate; border-spacing: 0; }
.sheet th {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  color: var(--muted); text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.sheet th:first-child, .sheet td:first-child { padding-left: var(--s-6); }
.sheet th:last-child, .sheet td:last-child { padding-right: var(--s-5); }
.sheet th.num, .sheet td.num { text-align: right; }
.sheet td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sheet tbody tr { transition: background .12s; }
.sheet tbody tr:hover { background: var(--surface-2); }
.sheet tbody tr.enter { animation: rowIn .35s var(--ease); }
@keyframes rowIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.sheet tfoot td { border-bottom: 0; padding-top: 14px; padding-bottom: 14px; font-weight: 700; }
.sheet .w-del { width: 44px; }
.sheet .w-check { width: 64px; text-align: center; }
.sheet .w-date { width: 150px; }
.sheet .w-money { width: 150px; }
.sheet .w-type { width: 190px; }
.sheet .w-small { width: 96px; }

.field {
  width: 100%; border: 1px solid transparent; background: transparent; border-radius: var(--r-sm);
  padding: 7px 9px; font-size: var(--fs-md); min-width: 0;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.field::placeholder { color: var(--faint); }
.field:hover { border-color: var(--line); background: var(--surface); }
.field:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--focus); }
.field.money { text-align: right; font-weight: 700; }
.field.boxed { border-color: var(--line); background: var(--surface); }
select.field { appearance: none; padding-right: 26px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 52%, calc(100% - 9px) 52%; background-size: 4px 4px; background-repeat: no-repeat; }
select.field option { background: var(--surface); color: var(--ink); }
input[type="date"].field { color: var(--ink-2); }
input[type="date"].field::-webkit-calendar-picker-indicator { opacity: .5; cursor: pointer; }
:root[data-theme="dark"] input[type="date"].field::-webkit-calendar-picker-indicator { filter: invert(1); }

.cell-type { display: flex; align-items: center; gap: 4px; }
.cell-type .cat-ic { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; background: var(--surface-3); color: var(--ink-2); }
.cell-type .cat-ic .ic { font-size: 15px; }
.cat-ic.b-needs { color: var(--c-needs); }
.cat-ic.b-wants { color: var(--c-wants); }
.cat-ic.b-savings { color: var(--c-save); }

.check {
  width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--line-strong); background: var(--surface);
  display: inline-grid; place-items: center; color: transparent; transition: all .15s; padding: 0;
}
.check .ic { font-size: 14px; }
.check[aria-checked="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.check:hover { border-color: var(--primary); }

.del-btn {
  width: 30px; height: 30px; border-radius: var(--r-sm); border: 0; background: none; color: var(--faint);
  display: inline-grid; place-items: center; opacity: 0; transition: opacity .12s, color .12s, background .12s;
}
.sheet tr:hover .del-btn, .del-btn:focus-visible { opacity: 1; }
.del-btn:hover { color: var(--bad); background: var(--bad-bg); }

.add-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: none; padding: 12px var(--s-6); color: var(--muted); font-weight: 500; font-size: var(--fs-md);
  border-bottom: 1px solid var(--line); text-align: left; transition: color .12s, background .12s;
}
.add-row:hover { color: var(--primary); background: var(--surface-2); }
.add-row kbd { margin-left: auto; font-family: inherit; font-size: var(--fs-xs); color: var(--faint); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }

.empty-row td { text-align: center; color: var(--faint); padding: 26px 0 !important; }

/* Pie de tabla con total */
.sheet-total {
  display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap;
  padding: var(--s-4) var(--s-6); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.sheet-total .lbl { font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: var(--fs-xs); }
.sheet-total .val { font-weight: 800; font-size: var(--fs-xl); margin-left: auto; }

/* ---------- Panel total vs límite (cabecera de sección) ---------- */
.budget-panel { display: grid; grid-template-columns: 1.1fr 1fr 1fr 1.4fr; gap: 0; padding: 0; overflow: hidden; }
.budget-panel > div { padding: var(--s-5) var(--s-6); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.budget-panel > div:last-child { border-right: 0; }
.budget-panel .num-xl { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.budget-panel .num-lg { font-size: var(--fs-xl); font-weight: 700; }
.budget-panel .hint { font-size: var(--fs-xs); color: var(--faint); }
.limit-edit { display: flex; align-items: center; gap: 6px; }
.limit-edit .field { font-size: var(--fs-xl); font-weight: 700; padding: 4px 8px; margin-left: -9px; text-align: left; max-width: 180px; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; background: var(--accent-soft); color: var(--ink-2); white-space: nowrap; }
.link-btn { border: 0; background: none; color: var(--primary); font-size: var(--fs-xs); font-weight: 700; padding: 0; }
.link-btn:hover { text-decoration: underline; }

/* ---------- 50/30/20 ---------- */
.rule-rows { display: flex; flex-direction: column; gap: var(--s-5); }
.rule-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; }
.rule-row .name { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.rule-row .name i { width: 10px; height: 10px; border-radius: 3px; }
.rule-row .name .pct { color: var(--muted); font-weight: 500; font-size: var(--fs-sm); }
.rule-row .meter { grid-column: 1 / -1; }
.rule-row .nums { grid-column: 1 / -1; display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--muted); }
.rule-row .nums b { color: var(--ink); }
.rule-edit { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); margin-top: var(--s-5); padding-top: var(--s-4); border-top: 1px solid var(--line); flex-wrap: wrap; }
.rule-edit .field { width: 56px; text-align: center; padding: 4px; }

/* ---------- Mini tarjetas de secciones ---------- */
.sec-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: var(--s-4); }
.sec-card {
  text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-lg);
  padding: var(--s-5); display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow);
  transition: transform .2s var(--ease), border-color .2s;
}
.sec-card:hover { transform: translateY(-2px); border-color: var(--line-strong); }
.sec-card .top { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 700; font-size: var(--fs-sm); }
.sec-card .top .ic { font-size: 18px; }
.sec-card .top .go { margin-left: auto; opacity: 0; transition: opacity .2s, transform .2s; }
.sec-card:hover .top .go { opacity: 1; transform: translateX(2px); }
.sec-card .amt { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.01em; }
.sec-card .of { font-size: var(--fs-sm); color: var(--muted); }
.sec-card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; white-space: nowrap; }

/* ---------- Gráficos ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { font-family: inherit; fill: var(--muted); font-size: 12px; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--line-strong); stroke-width: 1; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .bar { transition: opacity .15s; }
.chart.hovering .bar:not(.on) { opacity: .45; }
.chart .x-hair { stroke: var(--ink); stroke-width: 1; opacity: .25; }
.donut-wrap { display: flex; align-items: center; gap: var(--s-6); }
.donut-wrap .chart { width: 190px; flex: none; }
.donut-wrap .legend { flex-direction: column; gap: 10px; font-size: var(--fs-md); }
.donut-center .t1 { font-size: 22px; font-weight: 800; fill: var(--ink); }
.donut-center .t2 { font-size: 12px; fill: var(--muted); }
.donut-seg { transition: opacity .15s, stroke-width .15s; cursor: pointer; }
.donut-seg.on { stroke-width: 22; }
.chart.hovering .donut-seg:not(.on) { opacity: .4; }

.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar { display: grid; grid-template-columns: minmax(110px, 160px) 1fr auto; gap: 12px; align-items: center; font-size: var(--fs-sm); }
.hbar .lbl { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-weight: 500; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.hbar .lbl .ic { color: var(--muted); }
.hbar .trk { height: 10px; border-radius: 0 4px 4px 0; position: relative; }
.hbar .trk span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; background: var(--c-brand); transition: width .6s var(--ease); min-width: 2px; }
.hbar .v { font-weight: 700; min-width: 80px; text-align: right; }
.hbar:hover .trk span { filter: brightness(1.1); }

.tip {
  position: fixed; z-index: 100; pointer-events: none;
  background: var(--oxford); color: var(--mint); border-radius: 10px; padding: 9px 12px;
  font-size: var(--fs-sm); box-shadow: var(--shadow-pop); min-width: 140px;
  opacity: 0; transform: translateY(4px); transition: opacity .12s, transform .12s;
}
:root[data-theme="dark"] .tip { background: var(--mint); color: var(--oxford); }
.tip.show { opacity: 1; transform: none; }
.tip .tt { font-weight: 700; margin-bottom: 4px; }
.tip .tr { display: flex; justify-content: space-between; gap: 16px; align-items: center; }
.tip .tr i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 6px; }
.tip .tr b { font-weight: 700; }

.no-data { color: var(--faint); font-size: var(--fs-sm); padding: 24px 0; text-align: center; }

/* ---------- Movimientos ---------- */
.moves { display: flex; flex-direction: column; }
.move { display: grid; grid-template-columns: 34px 1fr auto auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.move:last-child { border-bottom: 0; }
.move .cat-ic { width: 34px; height: 34px; border-radius: 10px; background: var(--surface-3); display: grid; place-items: center; }
.move .t { font-weight: 700; font-size: var(--fs-md); }
.move .s { color: var(--muted); font-size: var(--fs-xs); }
.move .d { color: var(--muted); font-size: var(--fs-sm); }
.move .a { font-weight: 700; min-width: 90px; text-align: right; }

/* ---------- Estado vacío / nuevo mes ---------- */
.empty-month { display: grid; place-items: center; min-height: 60vh; }
.empty-month .card { max-width: 560px; text-align: center; padding: var(--s-10); display: flex; flex-direction: column; gap: var(--s-4); align-items: center; }
.empty-month h2 { font-size: var(--fs-2xl); font-weight: 800; margin: 0; letter-spacing: -.02em; }
.empty-month p { color: var(--muted); margin: 0; }
.empty-month .big-ic { width: 64px; height: 64px; border-radius: 20px; background: var(--accent-soft); display: grid; place-items: center; color: var(--primary); }
.empty-month .big-ic .ic { font-size: 30px; }
.btn-row { display: flex; gap: var(--s-3); flex-wrap: wrap; justify-content: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; border-radius: var(--r-md); padding: 10px 18px;
  font-weight: 700; font-size: var(--fs-md); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  transition: background .15s, transform .1s, border-color .15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 12px; font-size: var(--fs-sm); }

/* ---------- Popover ajustes ---------- */
.pop {
  position: fixed; z-index: 60; left: 248px; bottom: 20px; width: 300px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  padding: var(--s-4); display: flex; flex-direction: column; gap: 4px;
  animation: popIn .2s var(--ease);
}
.pop[hidden] { display: none; }
@keyframes popIn { from { opacity: 0; transform: translateY(6px) scale(.98); } to { opacity: 1; transform: none; } }
.pop h4 { margin: 4px 8px 8px; font-size: var(--fs-md); }
.pop label { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; font-size: var(--fs-sm); color: var(--muted); }
.pop label .field { width: 150px; }
.pop hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }
.pop .side-btn { color: var(--ink-2); }
.pop .side-btn.danger { color: var(--bad); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); z-index: 90;
  background: var(--oxford); color: var(--mint); border-radius: var(--r-pill); padding: 10px 10px 10px 18px;
  display: flex; align-items: center; gap: 14px; font-size: var(--fs-md); box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--ease);
}
:root[data-theme="dark"] .toast { background: var(--mint); color: var(--oxford); }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: rgba(141, 169, 196, .25); color: inherit; font-weight: 700; border-radius: var(--r-pill); padding: 5px 12px; }
.toast button:empty { display: none; }

/* ---------- Prioridad ---------- */
.prio { font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .budget-panel { grid-template-columns: 1fr 1fr; }
  .budget-panel > div:nth-child(2) { border-right: 0; }
  .budget-panel > div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 1180px) {
  .g-hero, .g-2, .g-21, .g-12 { grid-template-columns: 1fr; }
  .topbar, .content { padding-left: 24px; padding-right: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Selector de moneda ---------- */
.cur-btn {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface);
  border-radius: var(--r-pill); padding: 7px 14px 7px 8px; font-weight: 700; font-size: var(--fs-sm); color: var(--ink-2);
  transition: border-color .15s, background .15s;
}
.cur-btn:hover { border-color: var(--line-strong); background: var(--surface-2); }
.cur-btn .sym { min-width: 26px; height: 26px; padding: 0 6px; border-radius: 99px; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--ink); font-weight: 800; }
.cur-btn .ic { font-size: 14px; color: var(--muted); }
.cur-pop {
  position: fixed; z-index: 70; top: 70px; right: 36px; width: 360px; max-height: min(520px, 75vh);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; overflow: hidden; animation: popIn .2s var(--ease);
}
.cur-search { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--muted); }
.cur-search .field { font-size: var(--fs-base); }
.cur-list { overflow-y: auto; padding: 6px; flex: 1; }
.cur-group { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--faint); padding: 10px 10px 4px; }
.cur-opt {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px; width: 100%;
  border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: var(--r-md); font-size: var(--fs-md); color: var(--ink-2);
}
.cur-opt:hover, .cur-opt.kb { background: var(--accent-soft); }
.cur-opt .code { font-weight: 800; color: var(--ink); }
.cur-opt .sy { color: var(--muted); font-weight: 700; }
.cur-opt[aria-selected="true"] { background: var(--surface-3); }
.cur-opt[aria-selected="true"] .code { color: var(--primary); }
.cur-note { font-size: var(--fs-xs); color: var(--faint); padding: 10px 14px; border-top: 1px solid var(--line); }
.pop .cur-line { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; font-size: var(--fs-sm); color: var(--muted); }


/* ==========================================================================
   Caudal 2
   ========================================================================== */
.small { font-size: var(--fs-xs); }
.side { overflow-x: hidden; }

/* ---------- Menú hamburguesa ---------- */
.menu-btn { flex: none; }
.scrim { display: none; }
.topbar { gap: var(--s-3); flex-wrap: wrap; }
/* La barra se alinea con el contenido, que queda centrado (sobre todo con el menú cerrado) */
@media (min-width: 1181px) { .topbar { padding-inline: max(36px, calc((100% - var(--content-w, 1400px)) / 2 + 36px)); } }
.month-title { border: 0; background: none; color: var(--ink); cursor: pointer; display: inline-flex; align-items: baseline; gap: 8px; padding: 4px 8px; border-radius: var(--r-md); font-family: inherit; }
.month-title:hover { background: var(--accent-soft); }
.month-title .mt-caret { font-size: 18px; color: var(--muted); align-self: center; }

/* ---------- Botones de la barra ---------- */
.rate-btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-pill); padding: 7px 14px 7px 10px; font-size: var(--fs-sm); color: var(--ink-2); }
.rate-btn:hover { border-color: var(--line-strong); }
.rate-btn .ic { color: var(--primary); font-size: 16px; }
.rate-btn b { font-weight: 800; color: var(--ink); }
.account-btn { position: relative; display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-pill); padding: 4px; height: 40px; min-width: 40px; color: var(--ink-2); font-weight: 700; font-size: var(--fs-sm); }
.account-btn:not(:has(img, .av)) { padding: 0 14px 0 10px; }
.account-btn img, .account-btn .av { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.account-btn .av { display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 800; }
.account-btn .sync-dot { position: absolute; right: -4px; bottom: -4px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); font-size: 11px; color: var(--good); }
.account-btn.s-pending .sync-dot, .account-btn.s-syncing .sync-dot { color: var(--muted); }
.account-btn.s-syncing .sync-dot .ic { animation: spin 1s linear infinite; }
.account-btn.s-error .sync-dot, .account-btn.s-offline .sync-dot { color: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn.sm { width: 30px; height: 30px; border-radius: 9px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.chip-btn .ic { font-size: 14px; }
.chip-btn.xs { padding: 3px 9px; font-size: 11px; white-space: nowrap; }
.chip-btn.done { background: var(--good-bg); color: var(--good); border-color: transparent; }

/* ---------- Explicaciones (i) ---------- */
.info { border: 0; background: none; padding: 0 2px; margin-left: 2px; color: var(--faint); cursor: help; display: inline-grid; place-items: center; vertical-align: middle; }
.info .ic { font-size: 15px; }
.info:hover, .info:focus-visible { color: var(--primary); }
.card-head h2 { font-size: var(--fs-lg); font-weight: 700; margin: 0; display: flex; align-items: center; gap: 10px; }
.card-head h2 > .ic { color: var(--muted); }
.eyebrow .info .ic { font-size: 13px; }

/* ---------- Concepto + nota ---------- */
.concept { display: flex; flex-direction: column; min-width: 180px; }
.concept .c-main { font-weight: 600; }
.concept .c-note { font-size: var(--fs-xs); color: var(--muted); padding-top: 2px; padding-bottom: 4px; }
.concept .c-note::placeholder { color: var(--faint); opacity: .7; }
.sheet tr:not(:hover) .c-note:placeholder-shown:not(:focus) { opacity: 0; }
@media (hover: none) { .sheet tr .c-note:placeholder-shown { opacity: .7; } }

/* ---------- Importe con moneda ---------- */
.sheet .w-amt { width: 230px; }
.amt { display: flex; align-items: center; gap: 4px; }
.amt .cur-sel { width: 70px; flex: none; font-size: var(--fs-xs); font-weight: 700; padding-right: 20px; color: var(--ink-2); }
.amt .money { flex: 1; min-width: 80px; }
.fx-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 4px 6px; font-size: var(--fs-xs); color: var(--muted); padding: 0 4px 4px; }
.fx-line b { color: var(--ink); }
.fx-line .fx-rate { display: inline-flex; align-items: center; gap: 3px; }
.fx-line .rate-in { width: 76px; padding: 2px 6px; font-size: var(--fs-xs); text-align: right; }
.fx-line .src-sel { width: auto; padding: 2px 22px 2px 6px; font-size: var(--fs-xs); }
.table-hint { margin: 0; padding: 10px var(--s-6); font-size: var(--fs-xs); color: var(--muted); border-bottom: 1px solid var(--line); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.table-hint .ic { color: var(--primary); }

/* ---------- Meta ---------- */
.goal-empty { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; border: 1.5px dashed var(--line-strong); background: var(--surface-2); border-radius: var(--r-md); padding: 16px 18px; cursor: pointer; color: var(--ink); transition: border-color .15s, background .15s; }
.goal-empty:hover { border-color: var(--primary); background: var(--accent-soft); }
.goal-empty .ic { font-size: 22px; color: var(--primary); }
.goal-empty b { display: block; font-size: var(--fs-lg); }
.goal-empty small { color: var(--muted); }
.goal-wrap { position: relative; }
.goal-wrap .goal-pen { position: absolute; right: 2px; top: 10px; color: var(--faint); pointer-events: none; }
.goal-input { border-color: var(--line); background: var(--surface-2); padding-right: 34px; field-sizing: content; min-height: 64px; max-height: 220px; }
.save-box { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 4px; }
.sb-item { background: var(--surface-2); border-radius: var(--r-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sb-item .k { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.sb-item b { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.01em; }
.sb-item small { color: var(--muted); font-size: var(--fs-xs); line-height: 1.4; }
.neg-note { margin: 0; padding: 10px 12px; border-radius: var(--r-md); background: var(--bad-bg); color: var(--bad); font-size: var(--fs-sm); font-weight: 600; display: flex; gap: 8px; align-items: flex-start; }

/* ---------- Reparto (5 bloques) ---------- */
.rule-group { border: 1px solid var(--line); border-radius: var(--r-md); padding: 14px 14px 4px; display: flex; flex-direction: column; gap: 16px; background: var(--surface-2); }
.rg-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-weight: 800; flex-wrap: wrap; }
.rg-head > span:first-child { display: flex; align-items: center; gap: 8px; }
.rg-head .pct { color: var(--muted); font-weight: 500; font-size: var(--fs-sm); }
.rule-row.sub .name { font-size: var(--fs-md); }
.rule-row.compact { margin-bottom: 16px; }
.rule-edit { gap: 8px; }
.rule-edit label { display: inline-flex; align-items: center; gap: 4px; }
.rule-edit label i { width: 8px; height: 8px; border-radius: 3px; }
.rule-edit .field { width: 50px; }
.mini-legend { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.mini-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.mini-legend b { color: var(--ink); }

/* ---------- Tablas: límite en la cabecera, progreso, pagos ---------- */
.card-head .lim { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.card-head .lim .field { width: 120px; border-color: var(--line); background: var(--surface-2); text-transform: none; letter-spacing: 0; }
.prog { display: flex; flex-direction: column; gap: 5px; padding: 6px 4px; }
.prog small { color: var(--muted); font-size: var(--fs-xs); }
.prog small b { color: var(--ink); }
.prog .st { align-self: flex-start; font-size: 11px; padding: 2px 8px 2px 5px; }
.pay-cell { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.sheet .w-act { width: 120px; }
.sheet tr.is-done td { background: color-mix(in srgb, var(--good-bg) 60%, transparent); }
.del-btn.show { opacity: 1; }
.trk-st { display: flex; align-items: center; gap: 10px; }
.trk-st .meter { flex: 1; }
.trk-st .st { padding: 2px 6px; }
.add-row.static { cursor: default; }
.add-row.static .field { max-width: 280px; }
.sheet .is-empty td { color: var(--faint); }
.sheet tr.clickable { cursor: pointer; }
.sheet tr.clickable:hover td { background: var(--accent-soft); }
.year-table tfoot td { border-top: 1px solid var(--line-strong); }
.more { text-align: center; margin-top: 12px; }
.hist { margin-bottom: 14px; }
.hist b { font-size: var(--fs-sm); }
.hist-row { display: flex; gap: 6px; align-items: flex-end; height: 64px; margin-top: 6px; }
.hist-row span { flex: 1; max-width: 42px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.hist-row i { width: 100%; border-radius: 4px 4px 0 0; background: var(--c-debt); opacity: .7; }
.hist-row span.cur i { opacity: 1; }
.hist-row small { font-size: 10px; color: var(--muted); }
.num-xl { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat b { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.02em; }
.stat small { color: var(--muted); font-size: var(--fs-xs); }
.year-nav { display: flex; gap: 6px; }
.legend .dash { background: none !important; border-top: 2px dashed var(--muted); border-radius: 0; height: 0; width: 14px; }
.search { width: 200px; }
.filter-chip { display: inline-flex; align-items: center; gap: 8px; background: var(--accent-soft); color: var(--ink); border-radius: var(--r-pill); padding: 5px 6px 5px 12px; font-size: var(--fs-sm); font-weight: 700; margin-bottom: 8px; }
.filter-chip button { border: 0; background: var(--surface); border-radius: 50%; width: 22px; height: 22px; display: grid; place-items: center; cursor: pointer; }
.move .d.link-btn { color: var(--muted); font-weight: 500; }
.cat-ic.b-debts { color: var(--c-debt); }
.cat-ic.b-investments { color: var(--c-inv); }
.cat-ic.b-none { color: var(--c-none); }

/* ---------- Calendario ---------- */
.cal-pop, .rates-pop {
  position: fixed; z-index: 72; width: 340px; max-height: calc(100dvh - 90px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop);
  padding: var(--s-4); animation: popIn .2s var(--ease);
}
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-year { border: 0; background: none; font-family: inherit; font-weight: 800; font-size: var(--fs-xl); line-height: 1; color: var(--ink); cursor: pointer; padding: 6px 12px; border-radius: var(--r-md); }
.cal-year:hover { background: var(--accent-soft); }
.cal-months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.cal-m { position: relative; border: 0; background: var(--surface-2); border-radius: 10px; padding: 9px 0; font-weight: 600; color: var(--ink-2); cursor: pointer; font-family: inherit; font-size: var(--fs-sm); }
.cal-m:hover { background: var(--accent-soft); }
.cal-m.on { background: var(--primary); color: var(--on-primary); }
.cal-m.cur:not(.on) { box-shadow: inset 0 0 0 1.5px var(--primary); }
.cal-m i { position: absolute; top: 5px; right: 6px; width: 5px; height: 5px; border-radius: 50%; background: var(--good); }
.cal-sub { display: flex; justify-content: space-between; align-items: center; margin: 14px 2px 8px; font-weight: 800; }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-days .dow { text-align: center; font-size: 11px; color: var(--faint); font-weight: 700; padding: 2px 0; }
.cal-d { position: relative; aspect-ratio: 1; border: 0; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: var(--fs-sm); color: var(--ink-2); background: color-mix(in srgb, var(--primary) calc(var(--a, 0) * 32%), var(--surface-2)); }
.cal-d.has { font-weight: 800; color: var(--ink); }
.cal-d:hover { outline: 2px solid var(--primary); }
.cal-d.today { box-shadow: inset 0 0 0 1.5px var(--good); }
.cal-hint { margin: 10px 2px 0; font-size: var(--fs-xs); color: var(--faint); }

/* ---------- Tasas y calculadora ---------- */
.rp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rates-pop h4 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: var(--fs-md); }
.rp-meta { margin: 4px 0 10px; font-size: var(--fs-xs); color: var(--muted); }
.rate-row { display: grid; grid-template-columns: 1fr 120px auto; gap: 8px; align-items: center; padding: 6px 0; }
.rate-row span { display: flex; flex-direction: column; }
.rate-row b { font-size: var(--fs-sm); }
.rate-row small { font-size: 11px; color: var(--muted); }
.rate-row em { font-style: normal; color: var(--muted); font-size: var(--fs-xs); font-weight: 700; }
.rate-row select { grid-column: 2 / 4; }
.rates-pop hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.calc { display: grid; grid-template-columns: 1fr 120px; gap: 8px; margin-top: 10px; }
.calc-in { font-size: var(--fs-lg) !important; }
.calc-out { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.calc-out > div { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; background: var(--surface-2); border-radius: 10px; font-size: var(--fs-sm); }
.calc-out b { font-weight: 800; }
.calc-out .calc-gap { background: var(--accent-soft); }
.calc-out p { margin: 0; font-size: var(--fs-sm); }

/* ---------- Ventanas (cuenta, categorías) ---------- */
.modal { position: fixed; inset: 0; z-index: 95; background: rgba(7, 22, 41, .45); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; animation: fadeIn .18s; }
.modal[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } }
.modal-card { width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); padding: var(--s-6); display: flex; flex-direction: column; gap: 14px; animation: popIn .22s var(--ease); }
.modal.wide .modal-card { width: min(640px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal-head h3 { margin: 0; font-size: var(--fs-xl); font-weight: 800; display: flex; align-items: center; gap: 10px; }
.modal-sub { margin: 0; color: var(--muted); font-size: var(--fs-sm); }
.modal-sub.small { font-size: var(--fs-xs); text-align: center; }
.modal-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
body.modal-open { overflow: hidden; }
.btn.google { justify-content: center; width: 100%; border-color: var(--line-strong); }
.btn.google .ic { font-size: 18px; }
.or { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: var(--fs-xs); }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form label { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2); }
.auth-form .field { font-size: var(--fs-base); padding: 10px 12px; }
.auth-form .btn { justify-content: center; }
.auth-err { margin: 0; min-height: 1em; color: var(--bad); font-size: var(--fs-sm); font-weight: 600; }
.auth-ok { margin: 0; color: var(--good); font-size: var(--fs-sm); font-weight: 600; }
.auth-links { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.acct-card { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-md); background: var(--surface-2); }
.acct-card > div { display: flex; flex-direction: column; min-width: 0; }
.acct-card .t-muted { font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; }
.acct-av { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-weight: 800; flex: none; }
.acct-actions { display: flex; flex-direction: column; gap: 8px; }
.acct-actions .btn { justify-content: flex-start; }
.sync-line { margin: 0; font-size: var(--fs-sm); font-weight: 600; display: flex; align-items: center; gap: 8px; color: var(--good); }
.sync-line.s-error, .sync-line.s-offline { color: var(--bad); }
.sync-line.s-pending, .sync-line.s-syncing { color: var(--muted); }
.cat-list { display: flex; flex-direction: column; gap: 6px; max-height: 46vh; overflow: auto; padding-right: 4px; }
.cat-item { display: grid; grid-template-columns: 34px 1fr 150px 60px 32px; gap: 8px; align-items: center; }
.cat-item .cat-pick { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; display: grid; place-items: center; background: var(--surface-3); }
.cat-used { font-size: 11px; text-align: right; }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); }
.icon-grid button { aspect-ratio: 1; border: 0; border-radius: 10px; background: var(--surface-2); cursor: pointer; color: var(--ink-2); }
.icon-grid button:hover { background: var(--accent-soft); color: var(--primary); }
.icon-grid .ic { font-size: 18px; }

/* ==========================================================================
   Móvil y tabletas
   ========================================================================== */
@media (max-width: 899px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 80; inset: 0 auto 0 0; width: min(290px, 84vw); transform: translateX(-102%); transition: transform .3s var(--ease); box-shadow: var(--shadow-pop); visibility: visible !important; }
  body.nav-open .side { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 79; background: rgba(7, 22, 41, .4); }
  .topbar { padding: 10px 14px; gap: 8px; }
  .month-title { font-size: var(--fs-2xl); margin: 0; padding: 4px; }
  .save-state { display: none; }
  .balance-pill { order: 5; width: 100%; justify-content: space-between; }
  .content { padding: 4px 14px 80px; }
  .cur-pop, .pop { left: 12px !important; right: 12px !important; width: auto; }
  .pop { bottom: 12px; }
}
@media (max-width: 640px) {
  .month-switch { gap: 2px; }
  .month-switch .icon-btn { width: 32px; height: 32px; }
  .month-title { font-size: var(--fs-xl); }
  .rate-btn span, #today { display: none; }
  .rate-btn { padding: 8px 10px; }
  .cur-btn { padding: 6px 8px 6px 6px; }
  .cur-btn .ic { display: none; }
  .account-btn:not(:has(img, .av)) span { display: none; }
  .account-btn:not(:has(img, .av)) { padding: 0 10px; }
  .cal-pop, .rates-pop { left: 12px !important; right: 12px !important; width: auto; top: 64px !important; }
  .view-head h1 { font-size: var(--fs-xl); }
  .card { padding: var(--s-4); border-radius: 16px; }
  .card.flush .card-head { padding: var(--s-4) var(--s-4) 0; flex-wrap: wrap; }
  .card-head { flex-wrap: wrap; }
  .card-head .end { margin-left: 0; flex-wrap: wrap; }
  .hero-balance .big { font-size: var(--fs-3xl); }
  .formula { gap: var(--s-4); }
  .save-box { grid-template-columns: 1fr; }
  .g-4 { grid-template-columns: 1fr 1fr; }
  .budget-panel { grid-template-columns: 1fr; }
  .budget-panel > div { border-right: 0 !important; border-bottom: 1px solid var(--line); padding: var(--s-4); }
  .donut-wrap { flex-direction: column; align-items: flex-start; }
  .sec-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .sec-card { min-width: 0; }
  .sec-card .foot { white-space: normal; flex-wrap: wrap; }
  .sec-card .top { min-width: 0; }
  .sec-card { padding: 14px; }
  .sec-card .amt { font-size: var(--fs-lg); }
  .sheet-total { padding: var(--s-4); }
  .add-row, .table-hint { padding-left: var(--s-4); padding-right: var(--s-4); }
  .add-row kbd { display: none; }
  .search { width: 100%; }
  .cat-item { grid-template-columns: 34px 1fr 32px; }
  .cat-item select { grid-column: 2; }
  .cat-used { display: none; }
  .modal { align-items: end; padding: 0; }
  .modal-card { width: 100% !important; border-radius: 20px 20px 0 0; max-height: 92dvh; padding: var(--s-5) var(--s-4) calc(var(--s-5) + env(safe-area-inset-bottom)); }

  /* Tablas → tarjetas: cada fila es un bloque con sus campos etiquetados */
  .table-wrap { overflow: visible; }
  table.sheet, .sheet tbody, .sheet tr, .sheet td { display: block; width: 100%; }
  .sheet thead { display: none; }
  .sheet tbody tr { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; padding: 12px var(--s-4) 10px; border-bottom: 1px solid var(--line); }
  .sheet td { border: 0; padding: 2px 0 !important; min-width: 0; }
  .sheet td[data-label]::before { content: attr(data-label); display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--faint); margin: 2px 0 1px 9px; }
  .sheet td[data-label=""]::before { display: none; }
  .sheet td:first-child { grid-column: 1 / -1; padding-right: 36px !important; }
  .sheet td[data-label="Importe"], .sheet td[data-label="Gasto"], .sheet td[data-label="Progreso"], .sheet td[data-label="Estado"] { grid-column: 1 / -1; }
  .sheet td:last-child:not([data-label]) { position: absolute; top: 8px; right: 8px; width: auto; }
  .sheet .del-btn { opacity: 1; }
  .sheet .w-check { text-align: left; }
  .sheet tfoot, .sheet tfoot tr, .sheet tfoot td { display: block; }
  .sheet tfoot tr { display: flex; justify-content: space-between; flex-wrap: wrap; padding: 10px var(--s-4); }
  .sheet .empty-row td { grid-column: 1 / -1; text-align: center; }
  .year-table tbody tr { grid-template-columns: repeat(2, 1fr); }
  .fx-line { justify-content: flex-start; }
  .concept { min-width: 0; }
  .sheet tr .c-note:placeholder-shown { opacity: .7 !important; }
  .tip { max-width: calc(100vw - 24px); }
}
