*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface2: #f4f1eb;
  --border: #e8e3d8;
  --border2: #d8d2c4;
  --text: #1a1814;
  --muted: #67625a;        /* 4.7:1 sobre el fondo de encabezados (#e8e3d8), 5.3:1 sobre surface2 */
  --muted-on-dark: #9a9488; /* texto secundario sobre fondos oscuros: 5.9:1 */
  --muted2: #8a8476;        /* placeholders, guiones y días futuros: 3.3:1 */
  --accent: #1a5c3a;
  --accent-light: #e8f5ee;
  --accent-mid: #287b4e;    /* 4.6:1 sobre surface2 */
  --red: #c0351a;
  --red-light: #fdf0ec;
  --orange: #94560c;        /* 4.6:1 sobre el fondo de encabezados de tabla (#e8e3d8) */
  --orange-light: #fef5e6;
  --blue: #2456a6;          /* azul de crédito: se distingue del texto (#1a1814); 6.6:1 sobre blanco */
  --blue-light: #eaf0fa;
  --mono: 'Anybody', sans-serif;
  --serif: 'DM Serif Display', serif;
  --r: 10px;
  --fs-11: 11px;
  --fs-12: 12px;
  --usd: #2a6a1a;
  --accent-text: #1a5c3a;
  --ink: #1a1814;           /* superficies oscuras fijas: barra, hero, resumen, avisos */
  --on-ink: #faf7f2;
  --ink-line: #2e2c28;
  --surface-alt: #faf8f4;
  --hover: #f0ede6;
  --highlight: #fff3a3;
  --shadow: rgba(0,0,0,0.12);
  --on-red: #ffffff;
  color-scheme: light;
}
/* ── TEMAS ──
   Sin elegir nada (Sistema) sigue al modo del celu/PC. En Ajustes → Apariencia se puede fijar
   Claro, Oscuro u OLED (negro puro); eso pone data-theme en <html>. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151310;          --surface: #1e1b17;     --surface2: #26231e;   --surface-alt: #221f1a;
    --border: #332f29;      --border2: #423d35;     --hover: #2b2722;
    --text: #ede8df;        /* 14:1 sobre surface */
    --muted: #a8a194;       /* 5.2:1 sobre border */
    --muted2: #7d776c;      /* solo placeholders y guiones: 3.5:1 */
    --muted-on-dark: #9a9488;
    --accent: #2f7d52;      /* fondo de botones: texto blanco 5:1 */
    --accent-text: #5cb886; /* 7:1 sobre surface */
    --accent-light: #1f3328; --accent-mid: #6cc596;
    --red: #f08a70;   --red-light: #3a1f18;   --on-red: #1e1b17; /* texto oscuro sobre rojo claro: 7:1 */
    --orange: #e0a050; --orange-light: #3a2a14;
    --blue: #8fb0e6;  --blue-light: #1c2638;
    --usd: #8fd07a;
    --ink: #0e0d0b; --on-ink: #faf7f2; --ink-line: #2a2722;
    --highlight: #5c4f12;
    --shadow: rgba(0,0,0,0.5);
  }
  :root:not([data-theme="light"]) .search-highlight { color: var(--text); }
}
:root[data-theme="dark"], :root[data-theme="oled"] {
    color-scheme: dark;
    --bg: #151310;          --surface: #1e1b17;     --surface2: #26231e;   --surface-alt: #221f1a;
    --border: #332f29;      --border2: #423d35;     --hover: #2b2722;
    --text: #ede8df;        /* 14:1 sobre surface */
    --muted: #a8a194;       /* 5.2:1 sobre border */
    --muted2: #7d776c;      /* solo placeholders y guiones: 3.5:1 */
    --muted-on-dark: #9a9488;
    --accent: #2f7d52;      /* fondo de botones: texto blanco 5:1 */
    --accent-text: #5cb886; /* 7:1 sobre surface */
    --accent-light: #1f3328; --accent-mid: #6cc596;
    --red: #f08a70;   --red-light: #3a1f18;   --on-red: #1e1b17; /* texto oscuro sobre rojo claro: 7:1 */
    --orange: #e0a050; --orange-light: #3a2a14;
    --blue: #8fb0e6;  --blue-light: #1c2638;
    --usd: #8fd07a;
    --ink: #0e0d0b; --on-ink: #faf7f2; --ink-line: #2a2722;
    --highlight: #5c4f12;
    --shadow: rgba(0,0,0,0.5);
}
:root[data-theme="dark"] .search-highlight, :root[data-theme="oled"] .search-highlight { color: var(--text); }
/* OLED: negro puro para el fondo (las pantallas OLED apagan esos píxeles) */
:root[data-theme="oled"] {
  --bg: #000000; --surface: #0b0b0b; --surface2: #141414; --surface-alt: #101010;
  --border: #262626; --border2: #343434; --hover: #1a1a1a;
  --ink: #000000; --ink-line: #262626; --shadow: rgba(0,0,0,0.8);
}
/* en OLED las tarjetas oscuras (total del mes) se distinguen del fondo con un borde */
:root[data-theme="oled"] .mes-resumen, :root[data-theme="oled"] .inicio-hero,
:root[data-theme="oled"] .resumen-final { border: 1px solid var(--border); }

/* ── CELU: que se sienta app instalada ── */
html {
  -webkit-tap-highlight-color: transparent; /* sin flash gris al tocar */
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;                /* sin pull-to-refresh ni rebote de toda la página */
}
button, a, [role="button"], .month-item, .gasto-row, .profile-btn {
  touch-action: manipulation;               /* sin demora de 300ms al tocar */
}
button, [role="button"], .mobile-tab, .nav-tab {
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
@media (pointer: coarse) {
  input, textarea, select { font-size: 16px !important; } /* menos de 16px hace que iOS haga zoom */
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}


/* ── NAV ── */
nav {
  background: var(--ink);
  padding: 0 20px 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: calc(56px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px); /* deja libre la zona del notch / barra de estado */
  position: sticky; top: 0; z-index: 200;
}


/* ── NAV DERECHA / PERFIL ── */
.nav-right { position: relative; display: flex; align-items: center; }
.profile-btn {
  display: flex; align-items: center; gap: 9px;
  cursor: pointer; padding: 5px 10px; border-radius: 8px;
  transition: background 0.15s;
}
@media (hover: hover) and (pointer: fine) { .profile-btn:hover { background: rgba(255,255,255,0.08); } }
.profile-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-12); font-weight: 500; overflow: hidden; flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { color: #ccc; font-size: var(--fs-12); }
.profile-chevron { color: #888; font-size: var(--fs-12); transition: transform 0.2s; }
.profile-chevron.open { transform: rotate(180deg); }
.profile-menu {
  position: absolute; top: calc(100% + 10px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; width: 220px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  opacity: 0; pointer-events: none; transform: translateY(-6px);
  transition: opacity 0.15s, transform 0.15s; z-index: 250;
}
.profile-menu.open { opacity: 1; pointer-events: all; transform: translateY(0); }
.pm-header { padding: 16px; display: flex; align-items: center; gap: 12px; }
.pm-avatar-wrap { position: relative; flex-shrink: 0; }
.pm-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; overflow: hidden;
}
.pm-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pm-avatar-edit {
  position: absolute; bottom: -2px; right: -2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--ink); color: var(--on-ink); border: none;
  font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
@media (hover: hover) and (pointer: fine) { .pm-avatar-edit:hover { background: var(--accent); } }
.pm-info { min-width: 0; }
.pm-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pm-email { font-size: var(--fs-12); color: var(--muted); margin-top: 2px; }
.pm-divider { height: 1px; background: var(--border); margin: 0 12px; }
.pm-item {
  width: 100%; background: none; border: none;
  text-align: left; padding: 10px 16px;
  font-family: var(--mono); font-size: var(--fs-12); color: var(--text);
  cursor: pointer; display: flex; align-items: center; gap: 9px;
  transition: background 0.1s;
}
@media (hover: hover) and (pointer: fine) { .pm-item:hover { background: var(--surface2); } }
.pm-item:last-child { border-radius: 0 0 12px 12px; }
.pm-icon { font-size: 14px; color: var(--muted); }


/* ══════════════════════════════════════
   ESCALA TIPOGRÁFICA GLOBAL
   sm: 12px  |  base: 14px  |  display: serif variable
══════════════════════════════════════ */
.t-sm   { font-size: var(--fs-12); }
.t-base { font-size: 14px; }
.t-label {
  font-size: var(--fs-12); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}


/* ── INICIO ── */
.inicio { padding: 32px 28px; max-width: 900px; display: flex; flex-direction: column; gap: 24px; }


/* ── HERO: métrica protagonista ── */
.inicio-hero {
  background: var(--ink); border-radius: 14px;
  padding: 32px 36px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 32px;
}
.hero-main { display: flex; flex-direction: column; gap: 10px; }
.hero-label { font-size: var(--fs-12); color: #888; text-transform: uppercase; letter-spacing: 0.1em; }
.hero-total { font-family: var(--serif); font-size: 64px; color: #fff; line-height: 1; }


/* barra presupuesto dentro del hero */
.hero-budget { display: flex; flex-direction: column; gap: 7px; min-width: 220px; max-width: 320px; }
.hb-track {
  height: 4px; background: rgba(255,255,255,0.15);
  border-radius: 2px; overflow: hidden;
}
.hb-fill {
  height: 100%; border-radius: 2px;
  transition: width 0.5s ease, background 0.3s;
  min-width: 0; width: 0%;
}
.hb-fill.ok   { background: #a8e6c3; }
.hb-fill.warn { background: #f0b840; }
.hb-fill.over { background: #e05a3a; }
.hb-budget-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hb-budget-sub { font-size: var(--fs-12); color: var(--muted-on-dark); line-height: 1.4; }
.hb-budget-sub.over { color: #e05a3a; }
.hb-budget-btn {
  background: none; border: none; cursor: pointer;
  font-family: var(--mono); font-size: var(--fs-12);
  white-space: nowrap; transition: color 0.15s; flex-shrink: 0;
}
.hb-budget-btn.no-limit { color: var(--muted-on-dark); border-bottom: 1px dashed var(--ink-line); padding-bottom: 1px; }
@media (hover: hover) and (pointer: fine) { .hb-budget-btn.no-limit:hover { color: #a8e6c3; border-bottom-color: #a8e6c3; } }
.hb-budget-btn.has-limit { color: #a8e6c3; font-family: var(--serif); font-size: 16px; }
@media (hover: hover) and (pointer: fine) { .hb-budget-btn.has-limit:hover { opacity: 0.7; } }
.hero-breakdown {
  display: flex; gap: 28px; align-items: flex-end; padding-bottom: 4px;
}
.hb-item { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.hb-label { font-size: var(--fs-12); color: var(--muted-on-dark); }
.hb-val   { font-family: var(--serif); font-size: 22px; color: #fff; opacity: 0.7; }
.hb-val.dim { opacity: 0.5; }


/* ── SEGUNDA FILA: barras + categorías ── */
.inicio-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}


/* sección genérica con borde */
.i-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
}
.i-card-head {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--surface2);
  display: flex; align-items: center; justify-content: space-between;
}
.i-card-head .ic-title { font-size: var(--fs-12); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.i-card-head .ic-total { font-size: 14px; font-weight: 500; }


/* Filas de la plantilla */
.tpl-row {
  display: grid; grid-template-columns: 1fr 130px 90px 32px;
  gap: 12px; padding: 10px 20px; align-items: center;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.tpl-row:last-child { border-bottom: none; }
@media (hover: hover) and (pointer: fine) { .tpl-row:hover { background: var(--surface2); } }
.tpl-empty { padding: 20px; text-align: center; color: var(--muted); font-size: var(--fs-12); }
.tpl-empty-cta { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 28px 20px; }
.tpl-total {
  padding: 10px 20px; font-size: var(--fs-12); color: var(--muted);
  border-top: 1px solid var(--border); text-align: right;
  background: var(--surface2);
}


/* BARRAS */
.bars-wrap { padding: 20px 20px 16px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 80px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; cursor: default; }
.bar-inner { width: 100%; border-radius: 3px 3px 0 0; min-height: 3px; transition: opacity 0.15s; }
@media (hover: hover) and (pointer: fine) { .bar-col:hover .bar-inner { opacity: 0.7; } }
.bar-lbl { font-size: var(--fs-12); color: var(--muted); }
.bar-past .bar-inner { background: var(--border2); }
.bar-cur .bar-inner { background: var(--accent); }


/* CATEGORÍAS */
.cat-list { }
.cat-list-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; border-bottom: 1px solid var(--border);
}
.cat-list-row:last-child { border-bottom: none; }
.cat-dot-sm { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.cat-bar-track { flex: 1; height: 3px; background: var(--border); border-radius: 2px; }
.cat-bar-fill { height: 100%; border-radius: 2px; }
.cat-list-name { font-size: 14px; color: var(--muted); min-width: 80px; }
.cat-list-val { font-size: 14px; font-weight: 500; min-width: 65px; text-align: right; }


/* COLS INICIO (legado, ya no se usa) */
.inicio-cols { display: none; }
.side-fijos { display: none; }



/* ── SEGUIMIENTO LAYOUT ── */
.seguimiento-page {
  display: flex; flex-direction: column;
  background: var(--bg);
}
.seg-body {
  padding: 12px 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.seg-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; max-width: 860px; }


/* COLLAPSIBLE */
.collapsible { cursor: pointer; user-select: none; }
@media (hover: hover) and (pointer: fine) { .collapsible:hover { background: var(--surface2); } }
.collapse-icon { font-size: var(--fs-12); color: var(--muted); transition: transform 280ms var(--ease-out); flex-shrink: 0; }
.collapse-icon.collapsed { transform: rotate(-90deg); }
.tabla-body { overflow: hidden; } /* abrir/cerrar se anima desde toggleTabla (alto real) */
.tabla-body.collapsed { max-height: 0 !important; }


/* ── CONFIG ── */
.config-page { padding: 32px; max-width: 640px; }
.config-header { display: flex; align-items: center; gap: 16px; margin-bottom: 28px; }
.config-sections { display: flex; flex-direction: column; gap: 24px; }
.config-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 22px 24px;
}
.config-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 16px;
}
.config-row label { font-size: var(--fs-12); color: var(--muted); flex-shrink: 0; }

/* ── CONFIG AVATAR ── */
.cfg-avatar-row { display: flex; align-items: flex-start; gap: 20px; }
.cfg-avatar-wrap { display: flex; gap: 20px; align-items: center; width: 100%; }
.cfg-avatar {
  width: 80px; height: 80px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; overflow: hidden;
  border: 3px solid var(--border);
}
.cfg-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cfg-avatar-actions { flex: 1; display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.cfg-avatar-btn {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-family: var(--mono); font-size: var(--fs-12);
  padding: 8px 14px; border-radius: 6px; cursor: pointer;
  transition: all 0.12s; text-align: left; width: fit-content;
}
@media (hover: hover) and (pointer: fine) { .cfg-avatar-btn:hover { border-color: var(--accent); color: var(--accent-text); } }
.cfg-avatar-or { font-size: var(--fs-12); color: var(--muted); }
.cfg-bank-info { font-size: var(--fs-12); color: var(--muted); line-height: 1.6; }


/* SECCIÓN AYUDA */
.help-item {
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.help-item:last-child { border-bottom: none; }
.help-q { font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.help-a { font-size: var(--fs-12); color: var(--muted); line-height: 1.7; }
.help-a strong { color: var(--text); font-weight: 500; }
.logo {
  font-family: var(--serif);
  font-size: 22px;
  color: #faf7f2;
  letter-spacing: -0.5px;
}
.logo em { color: #a8e6c3; font-style: italic; }
.nav-tabs { display: flex; }
.nav-tab {
  background: none; border: none;
  color: #888; font-family: var(--mono); font-size: var(--fs-12); font-weight: 400;
  padding: 0 18px; height: 56px; cursor: pointer;
  border-bottom: 2px solid transparent;
  letter-spacing: 0.06em; text-transform: uppercase;
  transition: all 0.15s;
}
@media (hover: hover) and (pointer: fine) { .nav-tab:hover { color: #faf7f2; } }
.nav-tab.active { color: #faf7f2; border-bottom-color: #a8e6c3; }


/* ── PAGES ── */
.page { display: none; }
.page.active { display: block; }


/* ── CLASES PRESERVADAS (migradas del bloque viejo) ── */
.btn-create {
  background: var(--accent); color: #fff;
  border: none; font-family: var(--mono); font-size: 14px; font-weight: 500;
  padding: 12px 28px; border-radius: 8px; cursor: pointer;
  transition: opacity 0.15s;
}
@media (hover: hover) and (pointer: fine) { .btn-create:hover { opacity: 0.85; } }
.btn-open {
  background: var(--ink); color: var(--on-ink);
  border: none; font-family: var(--mono); font-size: var(--fs-12); font-weight: 500;
  padding: 10px 20px; border-radius: 6px; cursor: pointer;
  letter-spacing: 0.04em; transition: opacity 0.15s;
}
@media (hover: hover) and (pointer: fine) { .btn-open:hover { opacity: 0.8; } }
.cal-sidebar {
  width: 300px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 28px 20px;
  position: sticky; top: 56px; height: calc(100dvh - 56px); overflow-y: auto;
}
.cal-sidebar h3 { font-family: var(--serif); font-size: 20px; margin-bottom: 20px; }
.cal-sidebar h3 em { color: var(--accent-mid); font-style: italic; }
.cs-title { font-size: var(--fs-12); color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }
.main-panel {
  flex: 1; padding: 32px 32px;
  display: flex; flex-direction: column; gap: 0;
}
.mi-amount { font-size: var(--fs-12); font-weight: 500; color: var(--red); }
.mi-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.mi-left { display: flex; align-items: center; gap: 10px; }
.mi-name { font-size: 14px; font-weight: 500; }
.mi-sub { font-size: var(--fs-12); color: var(--muted); margin-top: 2px; }
.mobile-nav {
  display: none;
  position: fixed; top: auto; bottom: 0; left: 0; right: 0; z-index: 200; /* top:auto anula el top:0 de la regla nav */
  background: var(--ink); border-top: 1px solid var(--ink-line);
  padding: 0 0 env(safe-area-inset-bottom, 0px); height: calc(56px + env(safe-area-inset-bottom, 0px));
}
.mobile-nav-tabs {
  display: flex; height: 100%;
}
.mobile-tab {
  flex: 1; background: none; border: none;
  color: var(--muted-on-dark); font-family: var(--mono); font-size: var(--fs-12);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; cursor: pointer; transition: color 0.15s;
  padding: 0;
}
.mobile-tab .mt-icon { font-size: 18px; line-height: 1; }
.mobile-tab.active { color: #a8e6c3; }
.months-list { display: flex; flex-direction: column; gap: 6px; }
.ob-header { margin-bottom: 32px; }
.ob-intro { font-size: 14px; color: var(--muted); line-height: 1.6; }
.ob-step {
  display: flex; gap: 20px; padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.ob-step:first-child { border-top: 1px solid var(--border); }
.ob-step-body { display: flex; flex-direction: column; gap: 5px; }
.ob-step-desc { font-size: var(--fs-12); color: var(--muted); line-height: 1.6; }
.ob-step-desc strong { color: var(--text); font-weight: 500; }
.ob-step-desc em { color: var(--accent-text); font-style: normal; font-weight: 500; }
.ob-step-num {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: var(--ink); color: var(--on-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-12); font-weight: 500; margin-top: 1px;
}
.ob-step-title { font-size: 14px; font-weight: 500; }
.ob-steps { display: flex; flex-direction: column; gap: 0; margin-bottom: 32px; }
/* Año grande en gris suave arriba de la guía, que se difumina hacia abajo, y el texto debajo (sin superponerse).
   Es decorativo: el año ya está en el título. Color del texto con poca opacidad: sirve en claro, oscuro y OLED. */
.ob-year {
  font-family: var(--serif); font-size: 200px; line-height: 0.8; letter-spacing: -0.03em;
  color: color-mix(in srgb, var(--text) 11%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, rgba(0, 0, 0, 0.35) 100%);
          mask-image: linear-gradient(to bottom, #000 55%, rgba(0, 0, 0, 0.35) 100%);
  margin: 0 0 20px -6px;
  user-select: none; white-space: nowrap;
}
/* El nombre del mes es más largo que el año: mismo estilo, tamaño según el ancho del panel ("Septiembre" entra entero) */
.ob-year.ob-mes { font-size: min(150px, 18cqw); }
/* La máscara del difuminado recorta a la caja: que la caja mida lo que la palabra.
   Alto fijo (el del año) y la palabra apoyada abajo: año y mes dejan el texto exactamente en el mismo lugar. */
.ob-year { width: max-content; height: 160px; display: flex; align-items: flex-end; }
.onboarding { max-width: 480px; }
.ob-header .btn-create { margin-top: 16px; }
.panel-empty {
  flex: 1; display: flex; flex-direction: column;
  padding: 40px 32px; container-type: inline-size;
}
.panel-preview { display: flex; flex-direction: column; gap: 20px; }
.pc-bar-fill { height: 100%; border-radius: 3px; }
.pc-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: var(--fs-12); }
.pc-bar-row .pcn { color: var(--muted); min-width: 90px; }
.pc-bar-row .pcv { min-width: 60px; text-align: right; font-weight: 500; }
.pc-bar-track { flex: 1; height: 5px; background: var(--border); border-radius: 3px; }
.prev-stat {
  background: var(--surface2); border-radius: 8px; padding: 14px 16px;
  border: 1px solid var(--border);
}
.prev-stat .psl { font-size: var(--fs-12); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.prev-stat .psv { font-family: var(--serif); font-size: 22px; }
.prev-stat .psv.red { color: var(--red); }
.prev-stat .psv.blue { color: var(--blue); }
.preview-cats { }
.preview-cats .pc-title { font-size: var(--fs-12); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.preview-head {
  display: flex; align-items: center; justify-content: space-between;
}
.preview-head h2 { font-family: var(--serif); font-size: 28px; }
.preview-head h2 em { color: var(--accent-mid); font-style: italic; }
.preview-stats { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.registros-layout {
  display: flex; min-height: calc(100dvh - 56px);
}
.dot-current { background: var(--orange); }
.dot-data { background: var(--accent); }
.dot-empty { background: var(--muted2); }
.dot-future { background: var(--border2); }
.month-item {
  border-radius: 8px; padding: 12px 14px;
  cursor: pointer; transition: all 0.12s;
  border: 1px solid transparent;
  display: flex; align-items: center; justify-content: space-between;
}
@media (hover: hover) and (pointer: fine) { .month-item:hover:not(.future) { background: var(--surface2); } }
.month-item.selected { background: var(--accent-light); border-color: var(--accent); }
.month-item.future { opacity: 0.35; cursor: default; pointer-events: none; }
.month-item.current-month { border-color: var(--border2); }


/* ══════════════════════════════════════
   SEGUIMIENTO
══════════════════════════════════════ */
.seg-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px 0;
  display: flex; flex-direction: column;
  position: sticky; top: 56px; z-index: 10;
}
.seg-row1 {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px;
}
.seg-left { display: flex; align-items: center; gap: 14px; }
.seg-right { display: flex; align-items: center; gap: 10px; }
.btn-back {
  background: none; border: 1px solid var(--border);
  color: var(--muted); font-family: var(--mono); font-size: var(--fs-12);
  padding: 5px 11px; border-radius: 6px; cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) { .btn-back:hover { border-color: var(--border2); color: var(--text); } }
.seg-title { font-family: var(--serif); font-size: 28px; line-height: 1; }
.seg-title em { color: var(--accent-mid); font-style: italic; }
.btn-del-mes {
  background: none; border: none;
  color: var(--red); font-family: var(--mono); font-size: var(--fs-12);
  padding: 6px 10px; border-radius: 6px; cursor: pointer;
  transition: all 0.15s; letter-spacing: 0.02em;
}
@media (hover: hover) and (pointer: fine) { .btn-del-mes:hover { color: var(--red); background: var(--red-light); } }

/* TOTALS STRIP */
.totals-strip { display: flex; border-top: 1px solid var(--border); }

.tot-item.total-general {
  flex: 1.2; background: var(--surface2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 10px 16px;
}
.tg-label { font-size: var(--fs-11); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.tg-montos { display: flex; align-items: baseline; gap: 8px; }
.tg-uyu { font-family: var(--serif); font-size: 20px; color: var(--red); line-height: 1; }
.tg-sep { font-size: 13px; color: var(--border2); }
.tg-usd { font-family: var(--serif); font-size: 20px; color: var(--usd); line-height: 1; }
.tg-aproxes { display: flex; align-items: center; gap: 7px; }
.tg-aprox { font-size: var(--fs-12); color: var(--muted); }
.tg-aprox strong { color: var(--text); font-weight: 500; }
.tg-aprox-sep { font-size: var(--fs-11); color: var(--border2); }

.tot-item {
  flex: 1; padding: 10px 14px; display: flex; align-items: center; gap: 9px;
  border-right: 1px solid var(--border);
}
.tot-item:last-child { border-right: none; }
.tot-icon { display: none !important; /* los íconos ≡ ↕ ◻ no se entendían; el color del punto ya distingue */
  width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center;
  justify-content: center; font-size: var(--fs-12); flex-shrink: 0;
}
.tot-icon.fijos   { background: var(--surface2); color: var(--text); }
.tot-icon.debito  { background: var(--orange-light); color: var(--orange); }
.tot-icon.credito { background: var(--blue-light); color: var(--blue); }
.tot-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.tot-label { font-size: var(--fs-11); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.tot-montos-row { display: flex; align-items: center; gap: 7px; }
.tot-montos { display: flex; align-items: baseline; gap: 5px; }
.tot-uyu { font-family: var(--serif); font-size: 16px; line-height: 1; }
.tot-uyu.dark   { color: var(--text); }
.tot-uyu.orange { color: var(--orange); }
.tot-uyu.blue   { color: var(--blue); }
.tot-sep-dot { font-size: var(--fs-11); color: var(--border2); }
.tot-usd { font-size: var(--fs-11); color: var(--usd); font-weight: 500; white-space: nowrap; }
.tot-aprox {
  display: flex; align-items: center; gap: 3px;
  padding-left: 7px; border-left: 1px solid var(--border); white-space: nowrap; flex-shrink: 0;
}
.tot-aprox-sym { font-size: var(--fs-11); color: var(--muted); }
.tot-aprox-val { font-size: var(--fs-11); color: var(--muted); font-weight: 500; }

/* TIPO DE CAMBIO */
.tc-block {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 11px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; max-width: 860px;
}
.tc-left { display: flex; align-items: center; gap: 11px; }
.tc-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--usd); flex-shrink: 0; }
.tc-dot.live { background: var(--accent-mid); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.35} }
.tc-info { display: flex; flex-direction: column; gap: 2px; }
.tc-title { font-size: var(--fs-11); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.tc-val-row { display: flex; align-items: baseline; gap: 7px; }
.tc-val-big { font-family: var(--serif); font-size: 20px; color: var(--text); }
.tc-sub { font-size: var(--fs-12); color: var(--muted); }
.tc-right { display: flex; align-items: center; gap: 8px; }
.tc-input-wrap { display: none; align-items: center; gap: 7px; }
.tc-input-wrap.open { display: flex; }
.tc-input {
  width: 90px; background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
  font-family: var(--mono); font-size: 14px; color: var(--text); padding: 5px 9px;
  outline: none; transition: border-color 0.15s;
}
.tc-input:focus { border-color: var(--accent); }
.btn-tc-save {
  background: var(--accent); color: #fff; border: none; font-family: var(--mono);
  font-size: var(--fs-12); font-weight: 500; padding: 5px 12px; border-radius: 6px; cursor: pointer;
}
.btn-tc-edit {
  background: none; border: 1px solid var(--border); color: var(--muted);
  font-family: var(--mono); font-size: var(--fs-11); padding: 4px 11px; border-radius: 6px;
  cursor: pointer; transition: all 0.12s; white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) { .btn-tc-edit:hover { border-color: var(--border2); color: var(--text); } }
.btn-tc-cancel { background: none; border: none; color: var(--muted); font-family: var(--mono); font-size: var(--fs-12); cursor: pointer; padding: 5px 6px; }
.tc-auto-badge {
  display: inline-flex; align-items: center; gap: 4px; background: var(--accent-light);
  color: var(--accent-text); font-size: var(--fs-11); font-weight: 500; padding: 3px 8px; border-radius: 10px;
}
.tc-or { font-size: var(--fs-11); color: var(--muted); }

/* RESUMEN FINAL */
.resumen-final {
  background: var(--ink); border-radius: var(--r);
  padding: 18px 22px; display: flex; align-items: center; gap: 22px; max-width: 860px;
}
.rf-col { display: flex; flex-direction: column; gap: 3px; }
.rf-label { font-size: var(--fs-11); color: var(--muted-on-dark); text-transform: uppercase; letter-spacing: 0.1em; }
.rf-val { font-family: var(--serif); font-size: 24px; line-height: 1; }
.rf-aprox { font-size: var(--fs-11); color: var(--muted-on-dark); margin-top: 1px; }
.rf-aprox span { color: var(--muted-on-dark); }
.rf-divider { width: 1px; height: 42px; background: var(--ink-line); flex-shrink: 0; }
.rf-equiv { display: flex; flex-direction: column; gap: 3px; }
.rf-equiv-label { font-size: var(--fs-11); color: var(--muted-on-dark); text-transform: uppercase; letter-spacing: 0.1em; }
.rf-equiv-val { font-family: var(--serif); font-size: 22px; color: #888; line-height: 1; }
.rf-equiv-sub { font-size: var(--fs-11); color: var(--muted-on-dark); margin-top: 1px; }


/* MODAL ELIMINAR MES */
.del-mes-overlay {
  position: fixed; inset: 0; background: rgba(26,24,20,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.del-mes-overlay.open { opacity: 1; pointer-events: all; }
.del-mes-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: translateY(8px); transition: transform 0.2s;
}
.del-mes-overlay.open .del-mes-modal { transform: translateY(0); }
.del-mes-icon { font-size: 32px; margin-bottom: 16px; }
.del-mes-title { font-family: var(--serif); font-size: 22px; margin-bottom: 10px; }
.del-mes-body { font-size: 14px; color: var(--muted); line-height: 1.7; margin-bottom: 28px; }
.del-mes-body strong { color: var(--text); font-weight: 500; }
.del-mes-body em { color: var(--red); font-style: normal; font-weight: 500; }
.del-mes-btns { display: flex; gap: 10px; }
.btn-del-confirm {
  flex: 2; background: var(--red); color: var(--on-red); border: none;
  font-family: var(--mono); font-size: 13px; font-weight: 500;
  padding: 11px; border-radius: 7px; cursor: pointer;
  transition: opacity 0.15s;
}
.btn-del-confirm:disabled {
  opacity: 0.35; cursor: not-allowed;
}
@media (hover: hover) and (pointer: fine) { .btn-del-confirm:not(:disabled):hover { opacity: 0.85; } }
.btn-del-countdown {
  font-size: var(--fs-11); opacity: 0.7; margin-left: 6px;
}


/* seg-body */
.tc-val.red { color: var(--red); }
.tc-val.orange { color: var(--orange); }
.tc-val.blue { color: var(--blue); }
.tc-val.dark { color: var(--text); }


/* TABLA SECTION */
.tabla-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden; max-width: 860px;
}

/* Mantener el border-radius con overflow:hidden en el padre */
.tabla-head {
  padding: 8px 14px; border-bottom: 2px solid var(--border2);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--border);
}

/* Solo la parte izquierda del header es clickeable para colapsar */
.th-left {
  display: flex; align-items: center; gap: 7px;
  cursor: pointer; padding: 2px 5px; border-radius: 6px;
  transition: background 0.12s; user-select: none;
}
@media (hover: hover) and (pointer: fine) { .th-left:hover { background: rgba(0,0,0,0.06); } }
.th-left h2 { font-size: 13px; font-weight: 500; }
.th-count {
  font-size: var(--fs-11); padding: 1px 7px; border-radius: 10px;
  background: var(--border); color: var(--muted);
}
.th-total { font-size: 14px; font-weight: 500; }
.th-total.red { color: var(--red); }
.th-total.orange { color: var(--orange); }
.th-total.blue { color: var(--blue); }

/* Table header dual-currency totals */
.th-totals { display: flex; align-items: baseline; gap: 5px; }
.th-uyu { font-size: 13px; font-weight: 500; }
.th-uyu.dark   { color: var(--text); }
.th-uyu.orange { color: var(--orange); }
.th-uyu.blue   { color: var(--blue); }
.th-sep { font-size: var(--fs-11); color: var(--border2); }
.th-usd { font-size: var(--fs-12); color: var(--usd); font-weight: 500; }
.th-equiv { font-size: var(--fs-11); color: var(--muted); }
.btn-add {
  background: var(--accent); color: #fff;
  border: none; font-family: var(--mono); font-size: var(--fs-12); font-weight: 500;
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
  transition: opacity 0.15s; letter-spacing: 0.03em; white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) { .btn-add:hover { opacity: 0.85; } }


/* BÚSQUEDA */
.btn-search-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: 6px; padding: 5px 8px; cursor: pointer;
  font-size: var(--fs-12); line-height: 1; transition: all 0.15s; color: var(--muted);
}
@media (hover: hover) and (pointer: fine) { .btn-search-toggle:hover { border-color: var(--border2); color: var(--text); } }
.btn-search-toggle.active { border-color: var(--accent); color: var(--accent-text); background: var(--accent-light); }
.search-bar {
  display: none; align-items: center; gap: 0;
  border-bottom: 2px solid var(--accent);
  background: var(--surface);
}
.search-bar.open { display: flex; }
.search-input {
  flex: 1; border: none; background: transparent;
  font-family: var(--mono); font-size: 14px; color: var(--text);
  padding: 10px 16px; outline: none;
}
.search-input::placeholder { color: var(--muted); }
.search-clear {
  background: none; border: none; color: var(--muted2);
  font-size: 18px; padding: 0 14px; cursor: pointer; line-height: 1;
  transition: color 0.15s;
}
@media (hover: hover) and (pointer: fine) { .search-clear:hover { color: var(--red); } }
.search-results-info {
  padding: 6px 20px; font-size: var(--fs-12); color: var(--muted);
  background: var(--surface2); border-bottom: 1px solid var(--border);
  font-style: italic;
}

/* highlight del texto encontrado */
.search-highlight {
  background: var(--highlight); border-radius: 2px;
  font-weight: 500; color: var(--text);
}

/* En modo búsqueda, permitir que la descripción muestre el texto completo */
.gasto-row .gr-desc mark.search-highlight {
  white-space: normal;
}
.gasto-row.search-result .gr-desc {
  overflow: visible; white-space: normal; word-break: break-word;
}


/* SELECCIÓN MÚLTIPLE */
.sel-bar {
  display: none; align-items: center; gap: 12px;
  font-size: var(--fs-12);
}
.sel-bar.visible { display: flex; }
.sel-count { color: var(--accent-text); font-weight: 500; flex: 1; }
.sel-bar-actions { display: flex; gap: 8px; align-items: center; }
.btn-del-sel {
  background: var(--red); color: var(--on-red); border: none;
  font-family: var(--mono); font-size: var(--fs-12); font-weight: 500;
  padding: 5px 14px; border-radius: 5px; cursor: pointer;
  transition: opacity 0.15s;
}
@media (hover: hover) and (pointer: fine) { .btn-del-sel:hover { opacity: 0.85; } }
.btn-cancel-sel {
  background: none; border: 1px solid var(--border2); color: var(--muted);
  font-family: var(--mono); font-size: var(--fs-12);
  padding: 5px 12px; border-radius: 5px; cursor: pointer;
  transition: all 0.12s;
}
@media (hover: hover) and (pointer: fine) { .btn-cancel-sel:hover { color: var(--text); border-color: var(--border2); } }


/* checkbox — ver definición en sección de tablas */


/* TABLA FOOT */
.tabla-foot {
  padding: 6px 14px; border-top: 2px solid var(--border2);
  background: var(--border); display: grid; column-gap: 10px; align-items: center;
}
.tf-uyu   { text-align: right; font-size: var(--fs-12); font-weight: 500; color: var(--muted); }
.tf-usd   { text-align: right; font-size: var(--fs-12); font-weight: 500; color: var(--usd); }
.tf-label { font-size: var(--fs-11); color: var(--muted); text-align: right; text-transform: uppercase; letter-spacing: 0.07em; }

/* SIDEBAR */
.seg-sidebar {
  position: fixed;
  top: calc(56px + 8px);
  display: flex; flex-direction: column; gap: 10px;
  width: 240px;
  /* JS will set left position */
  pointer-events: auto;
}
/* Sidebar is hidden/shown via JS */
.sb-block {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
}
.sb-head {
  padding: 9px 14px; background: var(--border);
  border-bottom: 2px solid var(--border2);
  font-size: var(--fs-11); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.sb-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.sb-budget-nums { display: flex; align-items: baseline; gap: 6px; }
.sb-gastado { font-family: var(--serif); font-size: 22px; color: var(--red); line-height: 1; }
.sb-sep     { font-size: 13px; color: var(--border2); }
.sb-limite  { font-family: var(--serif); font-size: 18px; color: var(--muted); line-height: 1; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .sb-limite:hover { color: var(--accent-text); } }
.sb-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 2px 0; }
.sb-fill  { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.sb-fill.ok   { background: var(--accent-mid); }
.sb-fill.warn { background: var(--orange); }
.sb-fill.over { background: var(--red); }
.sb-budget-sub { font-size: var(--fs-11); color: var(--muted); display: flex; justify-content: space-between; }
.sb-cat-row {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; border-bottom: 1px solid var(--border);
}
.sb-cat-row:last-child { border-bottom: none; }
.sb-cat-dot     { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.sb-cat-name    { font-size: var(--fs-12); color: var(--muted); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-cat-bar-wrap{ width: 50px; flex-shrink: 0; }
.sb-cat-track   { height: 3px; background: var(--border); border-radius: 2px; overflow: hidden; }
.sb-cat-fill    { height: 100%; border-radius: 2px; }
.sb-cat-val     { font-size: var(--fs-11); font-weight: 500; color: var(--text); text-align: right; min-width: 48px; }
.sb-cal-grid { display: grid; grid-template-columns: repeat(7, 28px); gap: 3px; }
.sb-cal-dow  { font-size: var(--fs-11); color: var(--muted); text-align: center; text-transform: uppercase; letter-spacing: 0.05em; padding-bottom: 4px; }
.sb-cal-day  {
  width: 28px; height: 28px; border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-11); color: var(--muted); cursor: default; position: relative;
}
.sb-cal-day.empty    { background: transparent; }
.sb-cal-day.no-gasto { background: var(--surface2); }
.sb-cal-day.has-gasto { background: var(--accent-light); color: var(--accent-text); font-weight: 500; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .sb-cal-day.has-gasto:hover { background: var(--accent-light); } }
.sb-cal-day.today { outline: 2px solid var(--accent-mid); outline-offset: -2px; }
.sb-cal-day.future { background: transparent; color: var(--muted2); cursor: default; }
.day-dot { position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); width: 3px; height: 3px; border-radius: 50%; background: var(--accent); }
.sb-legend { display: flex; gap: 12px; margin-top: 8px; font-size: var(--fs-11); color: var(--muted); }
.sb-legend span { display: flex; align-items: center; gap: 4px; }
.sb-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.budget-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px 22px;
}
.bc-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.bc-label { font-size: var(--fs-12); color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 6px; }
.bc-nums { display: flex; align-items: baseline; gap: 6px; }
.bc-gastado { font-family: var(--serif); font-size: 26px; }
.bc-sep { font-size: var(--fs-12); color: var(--muted); }
.bc-limite {
  background: none; border: none; font-family: var(--mono); font-size: 14px;
  color: var(--muted); cursor: pointer; padding: 0; border-bottom: 1px dashed var(--muted2);
  transition: color 0.15s;
}
@media (hover: hover) and (pointer: fine) { .bc-limite:hover { color: var(--accent-text); border-bottom-color: var(--accent); } }
.bc-limite.set { font-family: var(--serif); font-size: 26px; color: var(--text); border-bottom: none; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .bc-limite.set:hover { color: var(--accent-text); } }
.bc-pct { font-family: var(--serif); font-size: 32px; }
.bc-pct.ok { color: var(--accent-text); }
.bc-pct.warn { color: var(--orange); }
.bc-pct.over { color: var(--red); }
.bc-track { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-bottom: 8px; }
.bc-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease, background 0.3s; min-width: 0; }
.bc-fill.ok { background: var(--accent); }
.bc-fill.warn { background: var(--orange); }
.bc-fill.over { background: var(--red); }
.bc-sub { font-size: var(--fs-12); color: var(--muted); }


/* SORTABLE COLUMN HEADERS */
.col-heads span.sortable {
  cursor: pointer; user-select: none;
  display: inline-flex; align-items: center; gap: 3px;
  transition: color 0.12s;
}
@media (hover: hover) and (pointer: fine) { .col-heads span.sortable:hover { color: var(--text); } }
.col-heads span.sort-asc::after { content: ' ↑'; font-size: var(--fs-12); }
.col-heads span.sort-desc::after { content: ' ↓'; font-size: var(--fs-12); }


/* TOOLTIP CUOTA */
.gr-cuota-wrap { position: relative; display: inline-flex; }
.cuota-tooltip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--on-ink);
  font-size: var(--fs-12); padding: 6px 10px; border-radius: 6px;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.15s;
  z-index: 50;
}
.cuota-tooltip::after {
  content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  border: 4px solid transparent; border-top-color: var(--ink);
}
@media (hover: hover) and (pointer: fine) { .gr-cuota-wrap:hover .cuota-tooltip { opacity: 1; } }


/* TOAST */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--on-ink);
  font-family: var(--mono); font-size: var(--fs-12);
  padding: 10px 20px; border-radius: 8px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 500; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.btn-import {
  background: none; border: 1px dashed var(--border2);
  color: var(--muted); font-family: var(--mono); font-size: var(--fs-12);
  padding: 5px 12px; border-radius: 5px; cursor: pointer;
  transition: all 0.12s; letter-spacing: 0.04em; position: relative;
}
@media (hover: hover) and (pointer: fine) { .btn-import:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-light); } }

/* Tooltip hacia abajo para btn-import */
.btn-import::after {
  bottom: auto; top: calc(100% + 8px);
}
.btn-import::before {
  bottom: auto; top: calc(100% + 2px);
  border-top-color: transparent; border-bottom-color: var(--ink);
}


/* TOOLTIP GENÉRICO — implementado via JS (div#global-tooltip) */
[data-tip] { position: relative; cursor: default; }
.import-overlay {
  position: fixed; inset: 0; background: rgba(26,24,20,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 400; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.import-overlay.open { opacity: 1; pointer-events: all; }
.import-modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; width: 680px; max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: translateY(10px); transition: transform 0.2s;
}
.import-overlay.open .import-modal { transform: translateY(0); }
.im-head {
  padding: 20px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.im-head h3 { font-family: var(--serif); font-size: 20px; }
.im-head h3 em { color: var(--accent-mid); font-style: italic; }
.im-head .im-count { font-size: var(--fs-12); color: var(--muted); }
.im-body { flex: 1; overflow-y: auto; padding: 0; }
.im-row {
  display: grid; gap: 10px; padding: 10px 24px;
  align-items: center; border-bottom: 1px solid var(--border);
  font-size: var(--fs-12);
}
.im-row:last-child { border-bottom: none; }
.im-row-deb { grid-template-columns: 60px 1fr 110px 80px 24px; }
.im-row-cred { grid-template-columns: 60px 1fr 100px 70px 80px 24px; }
.im-head-row {
  display: grid; gap: 10px; padding: 8px 24px;
  background: var(--surface-alt); border-bottom: 1px solid var(--border);
  font-size: var(--fs-12); color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em;
}
.im-fecha { color: var(--muted); }
.im-cat-sel { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; font-family: var(--mono); font-size: var(--fs-12); color: var(--text); padding: 2px 5px; width: 100%; }
.im-monto { text-align: right; font-weight: 500; }
.im-monto.orange { color: var(--orange); }
.im-monto.blue { color: var(--blue); }
.im-cuota { font-size: var(--fs-12); padding: 2px 6px; border-radius: 8px; background: var(--blue-light); color: var(--blue); text-align: center; }
.im-del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; }
@media (hover: hover) and (pointer: fine) { .im-del:hover { color: var(--red); } }
.im-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.im-footer .im-summary { font-size: var(--fs-12); color: var(--muted); }
.im-footer .im-summary b { color: var(--text); }
.im-actions { display: flex; gap: 10px; }
.btn-confirm {
  background: var(--accent); color: #fff; border: none;
  font-family: var(--mono); font-size: 14px; font-weight: 500;
  padding: 10px 22px; border-radius: 7px; cursor: pointer; transition: opacity 0.15s;
}
@media (hover: hover) and (pointer: fine) { .btn-confirm:hover { opacity: 0.85; } }
.im-loading { padding: 40px; text-align: center; color: var(--muted); font-size: 14px; }
.im-error { padding: 24px; color: var(--red); font-size: var(--fs-12); line-height: 1.6; }


/* ROWS */
.row-empty { padding: 28px 24px; text-align: center; color: var(--muted); font-size: 14px; }


/* fijos: cb | nombre | categoría | monto UYU | monto USD | del */
.row-fijo   { grid-template-columns: 20px 1fr 130px 90px 72px 28px; }

/* débito: cb | fecha | desc | cat | monto UYU | monto USD | del */
.row-debito { grid-template-columns: 20px 55px 1fr 120px 90px 72px 28px; }

/* crédito: cb | fecha | desc | cat | cuotas | cuota | total | USD | del */
.row-credito{ grid-template-columns: 20px 55px 1fr 110px 60px 90px 90px 72px 28px; }


/* col-heads — idénticos a las filas */
.ch-fijo   { grid-template-columns: 20px 1fr 130px 90px 72px 28px; }
.ch-debito { grid-template-columns: 20px 55px 1fr 120px 90px 72px 28px; }
.ch-credito{ grid-template-columns: 20px 55px 1fr 110px 60px 90px 90px 72px 28px; }

/* USD column styles */
.gr-usd { text-align: right; font-size: var(--fs-12); font-weight: 500; color: var(--usd); white-space: nowrap; }
.gr-usd.empty { color: var(--muted2); font-weight: 400; }
.gr-uyu.dim { color: var(--muted2); font-weight: 400; }
.gr-monto.dim { color: var(--muted2); font-weight: 400; }
.col-usd-head { text-align: right; color: var(--usd) !important; }
.gasto-row.has-usd { background: var(--surface); }
@media (hover: hover) and (pointer: fine) { .gasto-row.has-usd:hover { background: var(--accent-light); } }


/* CHECKBOX */
.gr-cb {
  width: 15px; height: 15px; cursor: pointer;
  accent-color: var(--accent); flex-shrink: 0;
  opacity: 0; transition: opacity 0.1s;
}
.gasto-row:hover .gr-cb,
.gasto-row.selected .gr-cb { opacity: 1; }
.gasto-row {
  display: grid; gap: 0; padding: 7px 14px;
  align-items: center; border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  column-gap: 10px;
}
.gasto-row:last-child { border-bottom: none; }
@media (hover: hover) and (pointer: fine) { .gasto-row:hover { background: var(--surface2); } }
.gasto-row.editable { cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .gasto-row.editable:hover { background: var(--hover); } }
@media (hover: hover) and (pointer: fine) { .gasto-row.editable:hover .gr-desc { color: var(--accent-text); } }
.gasto-row.selected { background: var(--accent-light); }
.gr-fecha { font-size: var(--fs-12); color: var(--muted); white-space: nowrap; }
.gr-desc  { font-size: 13px; font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gr-cat-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-12); padding: 3px 9px; border-radius: 10px;
  background: var(--surface2); color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.gr-uyu { text-align: right; font-weight: 500; font-size: 13px; white-space: nowrap; }
.gr-monto { text-align: right; font-weight: 500; font-size: 13px; white-space: nowrap; }
.gr-uyu.red    { color: var(--red); }
.gr-monto.red    { color: var(--red); }
.gr-uyu.orange { color: var(--orange); }
.gr-monto.orange { color: var(--orange); }
.gr-uyu.blue   { color: var(--blue); }
.gr-monto.blue   { color: var(--blue); }
.gr-cuota { text-align: center; }
.cuota-pill {
  display: inline-block; font-size: var(--fs-12); padding: 2px 8px; border-radius: 10px;
  background: var(--blue-light); color: var(--blue); white-space: nowrap;
}
.gr-del {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 15px; padding: 2px 4px; border-radius: 3px; transition: all 0.1s; line-height: 1;
  justify-self: center;
}
@media (hover: hover) and (pointer: fine) { .gr-del:hover { color: var(--red); background: var(--red-light); } }


/* checkbox alineado al centro */
.gr-check {
  width: 15px; height: 15px; cursor: pointer;
  accent-color: var(--accent); flex-shrink: 0;
  opacity: 0; transition: opacity 0.1s;
  justify-self: center;
}
.gasto-row:hover .gr-check,
.gasto-row.selected .gr-check { opacity: 1; }


/* TABLE HEADER */
.col-heads {
  display: grid; column-gap: 10px; padding: 4px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2); align-items: center;
}
.col-heads span {
  font-size: var(--fs-11); color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* alineaciones de columnas en header */
.ch-fijo   span:nth-child(4) { text-align: right; }   /* Monto UYU */
.ch-fijo   span:nth-child(5) { text-align: right; }   /* USD */
.ch-debito span:nth-child(5) { text-align: right; }   /* Monto UYU */
.ch-debito span:nth-child(6) { text-align: right; }   /* USD */
.ch-credito span:nth-child(6),
.ch-credito span:nth-child(7) { text-align: right; }
.ch-credito span:nth-child(8) { text-align: right; }  /* USD */
.ch-credito span:nth-child(5) { text-align: center; }


/* ── MODAL ── */
.overlay {
  position: fixed; inset: 0; background: rgba(26,24,20,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px; width: 400px;
  transform: translateY(10px); transition: transform 0.2s;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.overlay.open .modal { transform: translateY(0); }
.modal h3 { font-family: var(--serif); font-size: 22px; margin-bottom: 22px; }
.modal h3 em { color: var(--accent-mid); font-style: italic; }
.fg { margin-bottom: 14px; }
.fg label { display: block; font-size: var(--fs-12); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.fi, .fs {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-family: var(--mono); font-size: 14px;
  padding: 10px 12px; border-radius: 7px; outline: none; transition: border-color 0.15s;
}
.fi:focus, .fs:focus { border-color: var(--accent); }
.fi::placeholder { color: var(--muted); }
.fs option { background: var(--surface); }
.fg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fg-row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.modal-btns { display: flex; gap: 10px; margin-top: 22px; }
.btn-cancel {
  flex: 1; background: none; border: 1px solid var(--border); color: var(--muted);
  font-family: var(--mono); font-size: var(--fs-12); padding: 10px; border-radius: 7px; cursor: pointer; transition: all 0.15s;
}
@media (hover: hover) and (pointer: fine) { .btn-cancel:hover { border-color: var(--border2); color: var(--text); } }
.btn-save {
  flex: 2; background: var(--accent); border: none; color: #fff;
  font-family: var(--mono); font-size: 14px; font-weight: 500;
  padding: 10px; border-radius: 7px; cursor: pointer; transition: opacity 0.15s;
}
@media (hover: hover) and (pointer: fine) { .btn-save:hover { opacity: 0.85; } }

/* ── AÑO EN REGISTROS ── */
.registros-title { display: flex; align-items: baseline; gap: 6px; }
.anio-nav { margin-left: auto; display: flex; gap: 4px; }
.anio-btn {
  background: none; border: 1px solid var(--border); color: var(--text);
  font-family: var(--mono); font-size: 14px; line-height: 1;
  width: 28px; height: 28px; border-radius: 6px; cursor: pointer;
}
@media (hover: hover) and (pointer: fine) { .anio-btn:hover:not(:disabled) { border-color: var(--border2); } }
.anio-btn:disabled { opacity: 0.35; cursor: default; }

/* ── LOGIN ── */
.login-overlay { background: var(--bg); z-index: 1000; transition: none; }
.login-modal { width: min(400px, calc(100% - 32px)); }
.login-logo { font-family: var(--serif); font-size: 40px; text-align: center; margin-bottom: 24px; }
.login-logo em { color: var(--accent-mid); }
.login-modal .fi { font-size: 16px; } /* 16px evita que el celu haga zoom al tocar el campo */
.login-error { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 8px; }
.login-btn { width: 100%; padding: 12px; }
.login-btn:disabled { opacity: 0.6; cursor: wait; }


/* cuotas toggle */
.cuotas-toggle { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; cursor: pointer; }
.cuotas-toggle input { accent-color: var(--accent); cursor: pointer; }
.cuotas-toggle span { font-size: var(--fs-12); color: var(--muted); }
/* Campos de cuotas: se despliegan hacia abajo y aparecen, en vez de saltar de golpe.
   visibility evita que se pueda llegar con Tab a campos ocultos. Con "reducir movimiento" no se anima. */
.cuotas-fields {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px;
  max-height: 0; opacity: 0; overflow: hidden; transform: translateY(-6px); visibility: hidden;
  transition: max-height 280ms var(--ease-out), opacity 200ms ease-out, transform 280ms var(--ease-out), visibility 0s 280ms;
}
.cuotas-fields.show {
  max-height: 260px; opacity: 1; transform: none; visibility: visible;
  transition: max-height 320ms var(--ease-out), opacity 240ms ease-out 60ms, transform 320ms var(--ease-out), visibility 0s;
}

@media (max-width: 400px) {
  .hero-total { font-size: 40px; }
  .hero-breakdown { gap: 14px; }
  .hb-val { font-size: 16px; }
}

/* Oculta el cartel "Powered by Netlify" que Netlify inyecta como iframe.
   shortcut: depende del id que usa Netlify hoy; si cambia y el cartel vuelve, actualizar el selector. */
#nl-badge-frame { display: none !important; }

/* ── ACCESIBILIDAD ── */
:focus-visible { outline: 2px solid var(--accent-mid); outline-offset: 2px; }
.fi:focus-visible, .fs:focus-visible { outline: none; } /* los campos ya marcan el foco con el borde */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* En pantallas táctiles, todo lo que se toca mide al menos 44px de alto */
@media (pointer: coarse) {
  .btn-add, .btn-import, .btn-back, .btn-tc-edit, .btn-search-toggle, .btn-del-mes, .anio-btn,
  .btn-save, .btn-cancel, .btn-confirm, .btn-del-confirm, .btn-create, .btn-open, .pm-item,
  .btn-tc-save, .btn-tc-cancel, .btn-clear-sel, .btn-del-sel, .btn-cancel-sel {
    min-height: 44px;
  }
  .btn-search-toggle, .anio-btn { min-width: 44px; }
  .pm-avatar-edit { width: 28px; height: 28px; }
  .gr-cb { width: 22px; height: 22px; }
}

/* Aviso con "Deshacer" */
.toast.has-action { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 6px 8px 6px 20px; }
.toast-btn {
  background: none; border: none; color: #a8e6c3; font-family: var(--mono);
  font-size: var(--fs-12); font-weight: 500; padding: 8px 12px; min-height: 36px; border-radius: 6px; cursor: pointer;
}

/* ── MOVIMIENTO ── (breve y con propósito; se apaga con "reducir movimiento") */
:root { --ease-out: cubic-bezier(.22, 1, .36, 1); }
.page.active { animation: page-in 180ms var(--ease-out); }
@keyframes page-in { from { opacity: 0; transform: translateY(4px); } }
.modal, .import-modal, .del-mes-modal { transition: transform 240ms var(--ease-out); }

/* Respuesta al tocar: el botón se hunde apenas, al instante */
.btn-add, .btn-save, .btn-confirm, .btn-create, .btn-open, .btn-cancel, .btn-import, .btn-back,
.btn-del-confirm, .btn-del-sel, .btn-tc-edit, .btn-tc-save, .anio-btn, .btn-search-toggle,
.gr-del, .month-item, .mobile-tab, .toast-btn, .pm-item {
  transition: transform 100ms var(--ease-out), background-color 150ms, border-color 150ms, color 150ms, opacity 150ms;
}
:is(.btn-add, .btn-save, .btn-confirm, .btn-create, .btn-open, .btn-cancel, .btn-import, .btn-back,
    .btn-del-confirm, .btn-del-sel, .btn-tc-edit, .btn-tc-save, .anio-btn, .btn-search-toggle,
    .gr-del, .month-item, .toast-btn):active:not(:disabled) { transform: scale(0.97); }
.mobile-tab:active .mt-icon { transform: scale(0.9); }
.mt-icon { transition: transform 100ms var(--ease-out); }
button:disabled { cursor: default; }
.btn-save:disabled, .btn-confirm:disabled { opacity: 0.6; }

/* Gasto recién agregado: se resalta un instante */
.row-nueva { animation: row-nueva 1.2s var(--ease-out); }
@keyframes row-nueva { from { background: var(--accent-light); } }

/* ── CARGANDO ── barra fina bajo la barra superior mientras se traen los datos */
body.cargando nav:not(.mobile-nav)::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 2px; width: 40%;
  background: var(--accent-mid); animation: cargando 1s var(--ease-out) infinite;
}
@keyframes cargando { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* ── SIN CONEXIÓN ── */
.offline-banner {
  display: none; position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); z-index: 150;
  background: var(--orange-light); color: var(--orange); border-bottom: 1px solid var(--border);
  font-size: var(--fs-12); text-align: center; padding: 8px 16px;
}
body.offline .offline-banner { display: block; }

/* ── ESCRITORIO ANGOSTO / TABLET ── el panel lateral fijo no entra: va abajo, en columnas */
@media (min-width: 701px) and (max-width: 1180px) {
  .seg-sidebar {
    position: static !important; left: auto !important; top: auto !important; width: auto !important;
    flex-direction: row; flex-wrap: wrap; padding: 0 28px 28px; max-width: 916px;
  }
  .seg-sidebar > * { flex: 1 1 240px; }
}

/* ── CUENTA (Config) ── */
.ic-sub { font-size: var(--fs-12); color: var(--muted); margin-left: 10px; }
.cfg-email { font-size: 14px; color: var(--text); overflow-wrap: anywhere; text-align: right; }
.btn-logout {
  background: none; border: 1px solid var(--border); color: var(--red);
  font-family: var(--mono); font-size: 14px; padding: 10px 22px; border-radius: 7px; cursor: pointer; margin-top: 4px;
}
@media (hover: hover) and (pointer: fine) { .btn-logout:hover { border-color: var(--red); } }

/* ── INICIO: datos nuevos ── */
.hero-prev { font-size: var(--fs-12); color: var(--muted-on-dark); margin-top: -2px; }
.btn-link {
  background: none; border: none; color: var(--accent-text); font-family: var(--mono);
  font-size: var(--fs-12); font-weight: 500; cursor: pointer; margin-left: auto; padding: 6px 4px;
}
@media (hover: hover) and (pointer: fine) { .btn-link:hover { text-decoration: underline; } }
.rec-row {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: center;
  padding: 11px 20px; border-bottom: 1px solid var(--border); font-size: 14px;
}
.rec-row:last-child { border-bottom: none; }
.rec-fecha { font-size: var(--fs-12); color: var(--muted); }
.rec-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-monto { font-weight: 500; white-space: nowrap; }
.rec-monto.orange { color: var(--orange); }
.rec-monto.blue { color: var(--blue); }

/* ── INICIO EN ESCRITORIO: grilla de 2 columnas centrada, sin franja vacía a la derecha ── */
.inicio { margin: 0 auto; width: 100%; }
@media (min-width: 1100px) {
  .inicio {
    max-width: 1240px; display: grid; gap: 20px; align-items: start;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
  }
  .inicio-hero { grid-column: 1 / -1; padding: 36px 44px; }
  .hero-budget { max-width: 420px; }
  .hero-breakdown { gap: 44px; }
  .inicio-grid { display: contents; }
  /* "Por mes" estira hasta el alto de "Por categoría": sin hueco abajo */
  .inicio-grid > .i-card { align-self: stretch; display: flex; flex-direction: column; }
  .bars-wrap { flex: 1; display: flex; }
  .bars { flex: 1; height: auto; min-height: 140px; }
}

/* ── ANIMACIONES DE INICIO (solo al entrar a la pantalla) ── */
#page-inicio.animar .i-card, #page-inicio.animar .inicio-hero { animation: card-in 380ms var(--ease-out) both; }
#page-inicio.animar .inicio-grid > .i-card:nth-child(1) { animation-delay: 60ms; }
#page-inicio.animar .inicio-grid > .i-card:nth-child(2) { animation-delay: 110ms; }
#page-inicio.animar .plantilla-card { animation-delay: 160ms; }
#page-inicio.animar .recientes-card { animation-delay: 200ms; }
@keyframes card-in { from { opacity: 0; transform: translateY(10px); } }
#page-inicio.animar .bar-inner { transform-origin: bottom; animation: bar-grow 520ms var(--ease-out) both; animation-delay: calc(120ms + var(--i, 0) * 35ms); }
@keyframes bar-grow { from { transform: scaleY(0); } }
#page-inicio.animar .cat-bar-fill { transform-origin: left; animation: bar-x 520ms var(--ease-out) 160ms both; }
@keyframes bar-x { from { transform: scaleX(0); } }
.hb-fill { transition: width 700ms var(--ease-out), background 300ms; }

/* ── SALUDO CON FOTO (solo celu: en escritorio la foto está en la barra) ── */
.hero-saludo { display: none; align-items: center; gap: 10px; margin-bottom: 6px; color: var(--on-ink); font-size: 15px; font-weight: 500; }
.hero-avatar {
  width: 36px; height: 36px; border-radius: 50%; overflow: hidden; flex-shrink: 0;
  background: var(--accent); color: #fff; font-size: 14px; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
}
.hero-avatar img { width: 100%; height: 100%; object-fit: cover; }
/* ── UN SOLO CONTENEDOR PARA TODA LA APP (escritorio) ──
   Contenido de 1184px centrado (1240 con márgenes de 28). El header usa el mismo borde,
   así el logo arranca donde arranca el contenido y la foto termina donde termina. */
:root { --page: 1184px; --edge: max(28px, calc((100% - var(--page)) / 2)); }
@media (min-width: 701px) {
  /* La barra de scroll aparece solo cuando hace falta, pero no corre nada de costado: el header y las páginas
     se estiran por debajo de ella (100% - 100vw = su ancho, o 0 si no está), así todo se centra como si no existiera.
     Los márgenes laterales (28px o más) son más anchos que la barra: nada queda tapado. */
  html { overflow-x: clip; }
  body > nav:not(.mobile-nav), body > .page { margin-right: calc(100% - 100vw); }

  /* Transición al abrir y cerrar un mes: el título viaja de Registros a Seguimiento */
  .preview-head h2, #seg-title { view-transition-name: titulo-mes; }
  html.en-transicion .page.active { animation: none; } /* la transición ya anima la entrada */
  /* El header ocupa toda la ventana: logo pegado a la izquierda y foto a la derecha, a 28px del borde */
  nav:not(.mobile-nav) { padding-left: 28px; padding-right: 28px; }
  /* Logo y foto miden distinto: con 3 columnas iguales a los costados, las pestañas quedan en el centro real */
  nav:not(.mobile-nav) { display: grid; grid-template-columns: 1fr auto 1fr; }
  nav:not(.mobile-nav) .logo { grid-column: 1; justify-self: start; }
  nav:not(.mobile-nav) .nav-tabs { grid-column: 2; }
  nav:not(.mobile-nav) .nav-right { grid-column: 3; justify-self: end; }
  .seg-header, .seg-body { padding-left: var(--edge); padding-right: var(--edge); }
  .seg-main { max-width: calc(var(--page) - 256px); } /* deja lugar justo para el panel lateral de 240 + 16 */
  .registros-layout { max-width: calc(var(--page) + 56px); margin: 0 auto; width: 100%; }
  .cal-sidebar { border-left: 1px solid var(--border); }
  .config-page { max-width: calc(var(--page) + 56px); margin: 0 auto; padding: 32px 28px; width: 100%; }
}
/* Config en dos columnas que se acomodan solas, sin huecos entre tarjetas */
@media (min-width: 1100px) {
  .config-sections { display: block; columns: 2; column-gap: 24px; }
  .config-section { break-inside: avoid; margin-bottom: 24px; }
}

/* ══════════════════════════════════════
   VISTA MES (celu) — v3
   Un número grande, un filtro, una lista agrupada por día. Lo raro va al ⋯ y al +.
══════════════════════════════════════ */
#page-mes { display: none; }
.mes { padding: 8px 16px calc(96px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }

.mes-top { display: grid; grid-template-columns: 44px 1fr 44px 44px; align-items: center; }
.mes-titulo { font-family: var(--serif); font-size: 26px; font-weight: 400; text-align: center; line-height: 1.1; }
.mes-nav, .mes-mas {
  width: 44px; height: 44px; border: none; background: none; color: var(--text);
  font-size: 26px; line-height: 1; border-radius: 22px; cursor: pointer;
}
.mes-mas { font-size: 22px; color: var(--muted); }
.mes-nav:disabled { opacity: 0.25; }
.mes-nav:active:not(:disabled), .mes-mas:active { background: var(--surface2); }

.mes-resumen {
  background: var(--ink); color: var(--on-ink); border-radius: 18px; padding: 18px 20px 20px;
  display: flex; flex-direction: column; gap: 8px;
}
.mes-hola { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.mes-total { font-family: var(--serif); font-size: 48px; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.mes-detalle:empty, .mes-anterior:empty { display: none; }
.mes-detalle, .mes-anterior { font-size: 13px; color: var(--muted-on-dark); }
.mes-presu { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted-on-dark); margin-top: 4px; }
.mes-presu .hb-track { height: 6px; border-radius: 3px; }
.mes-presu-over { color: #f08a70; }
.mes-link { background: none; border: none; color: #a8e6c3; font-family: var(--mono); font-size: 14px; padding: 10px 0; text-align: left; cursor: pointer; }

/* Filtro por tipo: control segmentado, cada opción con su total */
.mes-filtros {
  display: grid; grid-template-columns: 0.85fr 0.95fr 0.95fr 1.85fr; gap: 2px; padding: 3px; /* el último es "Gastos mensuales fijos": más ancho para que entre en dos renglones */
  background: var(--surface2); border: 1px solid var(--border); border-radius: 12px;
}
.mes-filtro {
  border: none; background: none; border-radius: 9px; padding: 8px 2px; min-height: 52px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: var(--mono); color: var(--text); cursor: pointer;
}
.mes-filtro span { font-size: 14px; font-weight: 500; line-height: 1.15; text-align: center; }
.mes-filtro small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.mes-filtro.activo { background: var(--surface); box-shadow: 0 1px 3px var(--shadow); }

.mes-buscar {
  width: 100%; font-size: 16px; font-family: var(--mono); color: var(--text);
  background: var(--surface2); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 14px; margin-top: 12px; outline: none;
}
.mes-buscar:focus { border-color: var(--accent-mid); }
.mes-buscar::placeholder { color: var(--muted); }

/* Lista: grupos por día como en la app del banco */
.mov-grupo-titulo {
  font-size: 13px; color: var(--muted); font-weight: 500; padding: 18px 4px 6px;
}
.mov-grupo { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.mov {
  width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 2px;
  padding: 12px 16px; background: none; border: none; border-bottom: 1px solid var(--border);
  text-align: left; font-family: var(--mono); color: var(--text); cursor: pointer;
}
.mov:last-child { border-bottom: none; }
.mov:active { background: var(--hover); }
.mov-desc { font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mov-monto { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mov-monto.usd { color: var(--usd); }
.mov-sub { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }
.mes-lista-vacia { text-align: center; color: var(--muted); font-size: 15px; padding: 32px 16px; line-height: 1.5; }

.mes-vacio { text-align: center; padding: 28px 12px; display: flex; flex-direction: column; gap: 10px; align-items: center; color: var(--muted); font-size: 15px; line-height: 1.5; }
.mes-vacio-titulo { font-family: var(--serif); font-size: 22px; color: var(--text); }
.mes-vacio .btn-save { width: 100%; max-width: 320px; margin-top: 8px; min-height: 48px; }

/* Botón + flotante: la acción principal, a mano del pulgar */
.fab {
  position: fixed; right: 16px; bottom: calc(56px + 16px + env(safe-area-inset-bottom, 0px)); z-index: 150;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 6px 20px var(--shadow), 0 2px 6px var(--shadow);
  display: flex; align-items: center; justify-content: center;
  transition: transform 120ms var(--ease-out);
}
.fab:active { transform: scale(0.92); }
.fab[hidden], #mes-cuerpo[hidden], .mes-mas[hidden] { display: none; }
.mes-mas[hidden] { display: block; visibility: hidden; }

/* Hojas de opciones (Agregar, ⋯) */
.hoja h3 { font-family: var(--serif); font-size: 22px; margin-bottom: 14px; }
.hoja-grupo { background: var(--surface2); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; }
.hoja-opt {
  width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 13px 16px; min-height: 56px; background: none; border: none; border-bottom: 1px solid var(--border);
  text-align: left; font-family: var(--mono); color: var(--text); cursor: pointer;
}
.hoja-opt:last-child { border-bottom: none; }
.hoja-opt:active { background: var(--hover); }
.hoja-opt b { font-size: 16px; font-weight: 500; }
.hoja-opt span { font-size: 13px; color: var(--muted); }
.hoja-peligro b { color: var(--red); }
.hoja-sep { font-size: 13px; color: var(--muted); font-weight: 500; padding: 18px 4px 6px; }
.hoja-cancelar { width: 100%; margin-top: 16px; min-height: 48px; font-size: 15px; }

/* Eliminar dentro de la edición de un gasto */
.btn-del-row {
  width: 100%; background: none; border: 1px solid var(--border); color: var(--red);
  font-family: var(--mono); font-size: 14px; padding: 11px; border-radius: 7px; cursor: pointer; margin-top: 18px;
}
@media (hover: hover) and (pointer: fine) { .btn-del-row:hover { border-color: var(--red); } }

/* ══ VISTA HISTORIAL (celu) — v3 ══ */
#page-historial { display: none; }
.hist { padding: 8px 16px calc(32px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 16px; }
.hist-resumen {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 18px 20px;
  display: flex; flex-direction: column; gap: 4px;
}
.hist-total-label { font-size: 13px; color: var(--muted); }
.hist-total { font-family: var(--serif); font-size: 40px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hist-promedio { font-size: 13px; color: var(--muted); }
.hist-bars { display: flex; align-items: flex-end; gap: 5px; height: 96px; margin-top: 14px; }
.hist-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.hist-bar-fill { width: 100%; border-radius: 3px 3px 0 0; background: var(--border2); }
.hist-bar.actual .hist-bar-fill { background: var(--accent-mid); }
.hist-bar span { font-size: 11px; color: var(--muted); }
.hist-mes .mov-monto { color: var(--text); }
.hist-mes .hist-vacio { color: var(--muted); font-weight: 400; }

/* ══ VISTA AJUSTES (celu) — v3 ══ */
#page-ajustes, .cfg-volver { display: none; }
.config-section[data-sec="fijos"] { display: none; } /* en PC la plantilla está en Inicio */
.cfg-ayuda { font-size: var(--fs-12); color: var(--muted); line-height: 1.5; margin-bottom: 10px; }
.tpl-cfg { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
/* Separación justa entre grupos: con letra grande (HyperOS suele venir al 110%) todo entra sin deslizar */
.ajustes { padding: 0 16px calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 18px; }
.ajustes .aj-fila { min-height: 48px; padding-top: 10px; padding-bottom: 10px; } /* 48 > 44, el mínimo cómodo para el dedo */
.ajustes-titulo { font-family: var(--serif); font-size: 32px; font-weight: 400; padding: 8px 4px 0; }
.aj-fila {
  width: 100%; display: flex; align-items: center; gap: 12px; min-height: 52px;
  padding: 12px 12px 12px 16px; background: none; border: none; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 16px; color: var(--text); text-align: left; cursor: pointer;
}
.aj-fila:last-child { border-bottom: none; }
.aj-fila:active { background: var(--hover); }
.aj-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.aj-txt b { font-weight: 500; }
.aj-txt small { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aj-valor { color: var(--muted); font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.aj-chev { color: var(--muted2); font-size: 22px; line-height: 1; }
.aj-perfil { min-height: 72px; }
.aj-perfil .hero-avatar { width: 48px; height: 48px; font-size: 18px; }
.aj-perfil .aj-txt b { font-size: 18px; }
.aj-salir { justify-content: center; color: var(--red); font-weight: 500; }

/* ══ PASO 4 (celu) ══ */
.mes-ver-cats { margin-top: 2px; padding: 8px 0 0; }
.mes-ver-cats[hidden] { display: none; }

/* Deslizar para borrar: la fila se corre y deja ver "Eliminar" detrás */
.mov-swipe { position: relative; background: var(--red); border-bottom: 1px solid var(--border); overflow: hidden; }
.mov-swipe:last-child { border-bottom: none; }
.mov-swipe .mov { position: relative; background: var(--surface); border-bottom: none; touch-action: pan-y; }
.mov-borrar {
  position: absolute; top: 0; right: 0; bottom: 0; width: 88px; border: none; cursor: pointer;
  background: var(--red); color: var(--on-red); font-family: var(--mono); font-size: 14px; font-weight: 500;
}

/* Hoja de categorías: reusa el panel lateral, sin repetir el presupuesto que ya está arriba */
.hoja-cats { display: flex; flex-direction: column; gap: 12px; }
.hoja-cats > .sb-block:first-child { display: none; }

/* ══ SELECCIONAR VARIOS (vista Mes, celu) ══ */
.sel-modo .mov { padding-left: 54px; }
.sel-modo .mov::before {
  content: ''; position: absolute; left: 16px; top: 50%; width: 24px; height: 24px; margin-top: -12px;
  border-radius: 50%; border: 2px solid var(--border2); box-sizing: border-box;
}
.sel-modo .mov.marcado::before {
  border-color: var(--accent); background: var(--accent)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 12l4 4 8-8'/%3E%3C/svg%3E") center / 16px no-repeat;
}
.sel-modo .mov.marcado { background: var(--accent-light); }
.sel-barra {
  position: fixed; left: 0; right: 0; bottom: calc(56px + env(safe-area-inset-bottom, 0px)); z-index: 160;
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 4px;
  padding: 8px 8px; background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: 0 -4px 16px var(--shadow);
}
.sel-barra[hidden] { display: none; }
.sel-cuenta { text-align: center; font-size: 14px; color: var(--muted); }
.sel-btn {
  background: none; border: none; font-family: var(--mono); font-size: 15px; font-weight: 500;
  color: var(--accent-text); min-height: 44px; padding: 0 12px; border-radius: 8px; cursor: pointer;
}
.sel-btn:active { background: var(--hover); }
.sel-borrar { color: var(--red); }
.sel-borrar:disabled { color: var(--muted2); }
/* ══ SELECTOR DE TIPO EN EL FORMULARIO (celu) ══ */
.tipo-seg {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; padding: 3px; margin: -8px 0 18px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 10px;
}
.tipo-seg[hidden], .tipo-seg[hidden] + .tipo-ayuda { display: none; }
.tipo-ayuda { margin: -10px 0 16px; font-size: var(--fs-12); color: var(--muted); }
.tipo-seg button {
  border: none; background: none; border-radius: 8px; min-height: 40px; cursor: pointer;
  font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--muted);
}
.tipo-seg button.activo { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px var(--shadow); }

/* ══ CAMBIO DE TIPO EN EL FORMULARIO ══
   La pastilla blanca se desliza a la opción elegida y los campos nuevos aparecen suaves. */
.tipo-seg { position: relative; --i: 0; }
.tipo-seg::before {
  content: ''; position: absolute; top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 10px) / 3); border-radius: 8px;
  background: var(--surface); box-shadow: 0 1px 3px var(--shadow);
  transform: translateX(calc(var(--i) * (100% + 2px)));
  transition: transform 280ms var(--ease-out);
}
.tipo-seg button { position: relative; transition: color 200ms; }
.tipo-seg button.activo { background: none; box-shadow: none; }
.campos-entrando { animation: campos-in 260ms var(--ease-out); }
@keyframes campos-in { from { opacity: 0; transform: translateY(6px); } }

/* ══ FORMULARIO CON SELECTOR DE TIPO: mismo alto para Débito, Crédito y Fijo ══
   Los tres bloques se apilan en la misma celda; el que no está elegido queda invisible
   (y fuera del Tab), así la hoja no sube ni baja al cambiar de tipo. */
#modal.con-tipo { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; }
/* filas fijas: la manija de la hoja (::before) también es parte de la grilla */
#modal.con-tipo::before { grid-row: 1; }
#modal.con-tipo > #modal-title { grid-row: 2; }
#modal.con-tipo > .tipo-lista { grid-row: 3; }
#modal.con-tipo > .tipo-ayuda { grid-row: 4; }
#modal.con-tipo .tipo-campos { display: block !important; grid-row: 5; grid-column: 1; }
#modal.con-tipo > .btn-del-row { grid-row: 6; }
#modal.con-tipo > .modal-btns { grid-row: 7; }
#modal.con-tipo .tipo-campos.tipo-oculto { display: none !important; } /* cada tipo mide lo suyo: sin hueco vacío; el cambio de alto se anima desde app.js */

/* ══ FORMULARIO DE GASTO: misma estructura en los 3 tipos ══ */
.fg-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.fg-label label { margin-bottom: 0; }
/* "Pagué en cuotas": interruptor tipo iOS */
.switch-cuotas {
  display: inline-flex !important; align-items: center; gap: 6px; cursor: pointer;
  text-transform: none !important; letter-spacing: 0 !important; font-size: var(--fs-12) !important; color: var(--muted);
}
.switch-cuotas input {
  appearance: none; -webkit-appearance: none; margin: 0; cursor: pointer; flex-shrink: 0;
  width: 34px; height: 20px; border-radius: 10px; background: var(--border2); position: relative;
  transition: background-color 200ms ease;
}
.switch-cuotas input::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.25); transition: transform 220ms var(--ease-out);
}
.switch-cuotas input:checked { background: var(--accent-mid); }
.switch-cuotas input:checked::after { transform: translateX(14px); }
.switch-cuotas input:focus-visible { outline: 2px solid var(--accent-mid); outline-offset: 2px; }
@media (pointer: coarse) { .switch-cuotas { padding: 8px 0; margin: -8px 0; } } /* área de toque más alta sin mover nada */

/* Con el mismo armado ya no hace falta reservar alto: cada tipo mide lo suyo, que ahora es igual */
/* Los tres tipos quedan apilados en la misma celda (el que no se ve conserva su lugar):
   la hoja mide siempre lo del más alto aunque el celu dibuje distinto algún control nativo. */
#modal.con-tipo .tipo-campos.tipo-oculto { display: none !important; } /* cada tipo mide lo suyo: sin hueco vacío; el cambio de alto se anima desde app.js */

/* ══ ABRIR / CERRAR FORMULARIOS EN PC: aparece con un leve zoom, no solo 10px ══ */
@media (min-width: 701px) {
  .overlay:not(.login-overlay) .modal { transform: translateY(12px) scale(0.97); opacity: 0;
    transition: transform 260ms var(--ease-out), opacity 200ms ease-out; }
  .overlay.open:not(.login-overlay) .modal { transform: none; opacity: 1; }
}

/* Con cuotas, el monto de arriba es el total de la compra */
.lbl-total { display: none; }
.cuota-calc { display: flex; align-items: baseline; gap: 8px; font-size: 14px; color: var(--muted); margin: -2px 0 14px; }
.cuota-calc b { font-family: var(--serif); font-size: 24px; font-weight: 400; color: var(--text); }
#fields-credito:has(#tiene-cuotas:checked) .lbl-monto { display: none; }
#fields-credito:has(#tiene-cuotas:checked) .lbl-total { display: inline; }
/* Cuotas: fila propia de lado a lado, texto a la izquierda e interruptor a la derecha (como en Ajustes de iOS) */
.switch-cuotas.fila-cuotas {
  display: flex !important; justify-content: space-between; width: 100%; min-height: 44px;
  margin: 0 0 12px; padding: 0; border-top: 1px solid var(--border);
  font-size: 15px !important; color: var(--text);
}
.switch-cuotas input { margin: -4px 0; } /* el interruptor no agranda la fila: Crédito mide lo mismo que Débito */
/* Todas las etiquetas del formulario ocupan una línea de 19px; la del monto con el interruptor también */
.fg > label, .fg-label { line-height: 19px; }
.fg-label { height: 19px; }
.fg .switch-cuotas { margin: -12px 0; padding: 12px 0; } /* área de toque de 43px sin agrandar la fila */

/* ══ ELEGIR MES (celu) ══ */
.mes-titulo-wrap { font-size: inherit; font-weight: 400; display: flex; justify-content: center; }
.mes-titulo {
  display: inline-flex; align-items: center; gap: 6px; background: none; border: none; cursor: pointer;
  font-family: var(--serif); font-size: 26px; color: var(--text); padding: 6px 10px; border-radius: 10px; min-height: 44px;
}
.mes-titulo:active { background: var(--surface2); }
.mes-titulo-chev { color: var(--muted); margin-top: 3px; }
.selmes-top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; margin-bottom: 14px; }
.selmes-top h3 { text-align: center; margin: 0 !important; }
.selmes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.selmes-mes {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 62px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface2);
  font-family: var(--mono); color: var(--text); cursor: pointer;
  transition: transform 100ms var(--ease-out), background-color 150ms;
}
.selmes-mes span { font-size: 16px; font-weight: 500; }
.selmes-mes small { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.selmes-mes:not(.con-datos) span { color: var(--muted); font-weight: 400; }
.selmes-mes.hoy { border-color: var(--accent-mid); }
.selmes-mes.elegido { background: var(--accent); border-color: var(--accent); }
.selmes-mes.elegido span, .selmes-mes.elegido small { color: #fff; }
.selmes-mes:disabled { opacity: 0.35; cursor: default; }
.selmes-mes:active:not(:disabled) { transform: scale(0.96); }

.mes-titulo { font-size: 22px; white-space: nowrap; padding: 6px 6px; } /* "Septiembre 2026" + flechita entran en una línea */

/* ══ ENCABEZADO DEL MES CENTRADO + "HOY" ══
   Mismo ancho a los dos lados del título (88px), así queda centrado en la pantalla. */
.mes .mes-top { grid-template-columns: 44px 44px minmax(0, 1fr) 44px 44px; }
.hist .mes-top { grid-template-columns: 44px minmax(0, 1fr) 44px; }
.mes-hoy {
  width: 44px; height: 44px; border: none; background: none; border-radius: 22px; cursor: pointer;
  font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--accent-text);
  transition: opacity 200ms ease-out, transform 100ms var(--ease-out);
}
.mes-hoy:active { background: var(--surface2); transform: scale(0.95); }
.mes-hoy.oculto { opacity: 0; pointer-events: none; } /* ocupa lugar igual: el título no se mueve */

/* ══ ENCABEZADO FIJO ══
   Siempre los mismos tres elementos: ‹ título ›. Lo que aparece según el caso vive en otro lado:
   "Hoy" en la tarjeta del total y ⋯ junto al buscador. Así nunca quedan huecos que lo desequilibren. */
.mes .mes-top { grid-template-columns: 44px minmax(0, 1fr) 44px; }
.mes-hola { min-height: 36px; }
.mes-hoy {
  width: auto; height: 32px; margin-left: auto; padding: 0 14px; border-radius: 16px;
  background: rgba(255, 255, 255, 0.12); color: #a8e6c3; font-size: 14px;
}
.mes-hoy:active { background: rgba(255, 255, 255, 0.2); }
.mes-hoy.oculto { display: none; }
.mes-buscar-fila { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.mes-buscar-fila .mes-buscar { margin-top: 0; flex: 1; min-width: 0; }
.mes-buscar-fila .mes-mas {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 12px; font-size: 20px; color: var(--text);
  background: var(--surface2); border: 1px solid var(--border);
}

/* ══ "HOY" ARRIBA A LA DERECHA (celu) ══ como "Hoy" en Calendario: aparece solo cuando sirve */
nav .mes-hoy {
  margin-left: auto; height: 32px; padding: 0 14px; border-radius: 16px; border: none; cursor: pointer;
  background: rgba(255, 255, 255, 0.12); color: #a8e6c3; font-family: var(--mono); font-size: 14px; font-weight: 500;
  transition: opacity 200ms ease-out, transform 220ms var(--ease-out), visibility 0s;
}
nav .mes-hoy.oculto { display: inline-block; opacity: 0; transform: scale(0.9); visibility: hidden; pointer-events: none;
  transition: opacity 160ms ease-in, transform 160ms ease-in, visibility 0s 160ms; }
@media (pointer: coarse) { nav .mes-hoy { position: relative; } nav .mes-hoy::after { content: ''; position: absolute; inset: -6px; } } /* área de toque de 44px */
@media (min-width: 701px) { nav .mes-hoy { display: none !important; } }

/* ══ APARIENCIA ══ */
.tema-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.tema-seg button {
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 4px 10px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface2); cursor: pointer;
  font-family: var(--mono); font-size: 13px; color: var(--text);
  transition: border-color 150ms, transform 100ms var(--ease-out);
}
.tema-seg button:active { transform: scale(0.96); }
.tema-seg button.activo { border-color: var(--accent-mid); box-shadow: 0 0 0 1px var(--accent-mid); }
.tema-muestra { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border2); }
.tema-muestra.sistema { background: linear-gradient(135deg, #faf7f2 50%, #151310 50%); }
.tema-muestra.claro { background: #faf7f2; }
.tema-muestra.oscuro { background: #151310; }
.tema-muestra.oled { background: #000; }
/* al cambiar de tema, los colores pasan suave en vez de saltar */
.cambiando-tema, .cambiando-tema *, .cambiando-tema *::before, .cambiando-tema *::after {
  transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease !important;
}

/* ══ PULIDO GENERAL ══ */
/* Registros (PC): lista de gastos del mes debajo de las categorías */
.preview-gastos .pc-title { font-size: var(--fs-12); color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 10px; }
.preview-gastos .pc-title span { margin-left: 6px; padding: 1px 7px; border-radius: 10px; background: var(--surface2); letter-spacing: 0; }
.preview-gastos .btn-link { margin: 10px 0 0; }

/* Todos los campos del formulario con la misma altura: en Android la fecha y las listas
   nativas se dibujan más altas que un campo de texto y hacían variar el alto entre tipos. */
#modal .fi, #modal .fs { height: 44px; box-sizing: border-box; line-height: normal; }

/* ══ HOJA "EN QUÉ GASTASTE" (celu) ══
   Reusa el panel lateral de la PC, pensado para 240px. Acá todo ocupa el ancho completo:
   el calendario con 7 columnas flexibles y días cuadrados, las barras de categoría estiradas. */
.hoja-cats .sb-head { font-size: 13px; padding: 10px 16px; }
.hoja-cats .sb-body { padding: 12px 16px 14px; }
.hoja-cats .sb-cat-row { gap: 12px; padding: 11px 0; }
.hoja-cats .sb-cat-dot { width: 8px; height: 8px; }
.hoja-cats .sb-cat-name { flex: 0 0 32%; font-size: 15px; color: var(--text); }
.hoja-cats .sb-cat-bar-wrap { flex: 1; width: auto; }
.hoja-cats .sb-cat-track { height: 6px; border-radius: 3px; }
.hoja-cats .sb-cat-fill { border-radius: 3px; }
.hoja-cats .sb-cat-val { font-size: 15px; min-width: 72px; font-variant-numeric: tabular-nums; }
.hoja-cats .sb-cal-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.hoja-cats .sb-cal-dow { font-size: 12px; padding-bottom: 2px; }
.hoja-cats .sb-cal-day { width: auto; height: auto; aspect-ratio: 1; font-size: 15px; border-radius: 10px; }
.hoja-cats .day-dot { width: 4px; height: 4px; bottom: 5px; }
.hoja-cats .sb-legend { font-size: 13px; margin-top: 12px; gap: 16px; }
.hoja-cats .sb-legend i { width: 12px; height: 12px; }
@media (max-height: 820px) { /* celus más bajos: que "Listo" entre sin deslizar */
  .hoja-cats .sb-cat-row { padding: 8px 0; }
  .hoja-cats .sb-cal-grid { gap: 4px; }
  .hoja-cats .sb-legend { margin-top: 8px; }
  .hoja-cats .sb-cal-day { aspect-ratio: 1.3; }
}

/* ══ EDITOR DE FOTO ══ */
.foto-editor h3 { margin-bottom: 14px; }
.foto-marco {
  position: relative; width: min(280px, 100%); aspect-ratio: 1; margin: 0 auto; overflow: hidden;
  border-radius: 14px; background: #111; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none;
}
.foto-marco:active { cursor: grabbing; }
.foto-marco img { position: absolute; left: 0; top: 0; max-width: none; pointer-events: none; }
/* el círculo muestra cómo va a quedar; lo de afuera se oscurece */
.foto-marco::after {
  content: ''; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.55); outline: 2px solid rgba(255, 255, 255, 0.85); outline-offset: -2px;
}
.foto-zoom { display: flex; align-items: center; gap: 12px; margin: 18px auto 0; width: min(280px, 100%); color: var(--muted); }
.foto-zoom input { flex: 1; accent-color: var(--accent-mid); height: 28px; }
.foto-ayuda { font-size: 13px; color: var(--muted); text-align: center; margin: 10px 0 4px; line-height: 1.5; }

/* ══ CREAR CUENTA / USUARIO ══ */
.login-alt { text-align: center; font-size: 14px; color: var(--muted); margin-top: 16px; }
.login-alt button {
  background: none; border: none; padding: 8px 4px; cursor: pointer;
  font-family: var(--mono); font-size: 14px; font-weight: 500; color: var(--accent-text);
}
#form-registro[hidden], #form-login[hidden] { display: none; }
.reg-estado { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.4; min-height: 18px; }
.reg-estado.ok { color: var(--accent-text); }
.reg-estado.mal { color: var(--red); }
.login-overlay { overflow-y: auto; padding: 16px 0; } /* el registro es más largo: que se pueda desplazar en celus bajos */
.cfg-usuario-wrap { display: flex; flex-direction: column; }
.cfg-usuario-fijo { font-size: 15px; color: var(--text); font-weight: 500; padding: 10px 0 0; }
.cfg-usuario-fijo[hidden], #cfg-usuario[hidden] { display: none; }
.login-overlay { align-items: safe center; } /* si el formulario no entra, que no se corte arriba */

/* ══ LOGIN / REGISTRO: ejemplos en gris, sin el color del autocompletar, ojito para la contraseña ══ */
.login-modal .fi::placeholder { color: var(--muted2); }
/* Chrome pinta de celeste/amarillo los campos autocompletados: se mantiene el gris de la app */
.login-modal .fi:-webkit-autofill,
.login-modal .fi:-webkit-autofill:hover,
.login-modal .fi:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 40px var(--surface2) inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  transition: background-color 9999s;
}
.pass-wrap { position: relative; }
.pass-wrap .fi { padding-right: 48px; }
.ver-pass {
  position: absolute; top: 0; right: 0; width: 46px; height: 100%; min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; color: var(--muted); cursor: pointer; border-radius: 0 7px 7px 0;
}
.ver-pass:active { color: var(--text); }
.ver-pass .ojo-cerrado { display: none; }
.ver-pass[aria-pressed="true"] .ojo-abierto { display: none; }
.ver-pass[aria-pressed="true"] .ojo-cerrado { display: block; }

/* ══ EXPORTAR ══ */
.btn-exportar {
  background: none; border: 1px solid var(--border); color: var(--accent-text);
  font-family: var(--mono); font-size: 14px; padding: 10px 22px; border-radius: 7px; cursor: pointer; margin: 4px 0 8px;
}
@media (hover: hover) and (pointer: fine) { .btn-exportar:hover { border-color: var(--accent-mid); } }
/* ══ TRANSICIÓN REGISTROS ⇄ SEGUIMIENTO (PC) ══
   Lo viejo se apaga rápido, lo nuevo sube apenas y aparece; el título del mes viaja a su lugar nuevo.
   Solo corre si el navegador la soporta y no está activado "reducir movimiento" (ver conTransicion en app.js). */
::view-transition-group(*) { animation-duration: 420ms; animation-timing-function: var(--ease-out); }
::view-transition-old(root) { animation: 160ms ease-out both vt-salir; }
::view-transition-new(root) { animation: 420ms var(--ease-out) both vt-entrar; }
@keyframes vt-salir { to { opacity: 0; } }
@keyframes vt-entrar { from { opacity: 0; transform: translateY(10px); } }


/* ══ TIPO DE CAMBIO: automático o manual ══ */
.tc-modo { margin-bottom: 16px; }
.tc-auto-valor { font-family: var(--serif); font-size: 32px; line-height: 1.1; margin-bottom: 6px; }
.tc-auto-unidad { font-family: var(--mono); font-size: 14px; color: var(--muted); }
#tc-auto-info[hidden], #tc-manual-campos[hidden] { display: none; }

/* Tipo de cambio automático: de dónde sale y cuándo se actualizó */
.tc-detalle { margin: 10px 0 14px; border-top: 1px solid var(--border); }
.tc-detalle > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.tc-detalle dt { color: var(--muted); }
.tc-detalle dd { margin: 0; text-align: right; }
.tc-detalle a { color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }
#btn-tc-actualizar:disabled { opacity: 0.6; cursor: default; }

/* ══ SEGUIMIENTO EN PC: una barra para las tres tablas ══ */
.seg-toolbar, .seg-menu-wrap { display: none; }
.seg-dia[hidden] { display: none; }
@media (min-width: 701px) {
  .btn-del-mes { display: none; }                 /* pasa al menú ⋯ */
  .seg-menu-wrap { display: block; position: relative; }
  .tabla-head .btn-search-toggle, .tabla-head .btn-add, .tabla-head .btn-import, .search-bar { display: none !important; }
  .seg-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
  .seg-main[data-filtro="debito"]  .tabla-section:not([data-tipo="debito"]),
  .seg-main[data-filtro="credito"] .tabla-section:not([data-tipo="credito"]),
  .seg-main[data-filtro="fijos"]   .tabla-section:not([data-tipo="fijos"]),
  .seg-main[data-dia] .tabla-section[data-tipo="fijos"] { display: none; }
  .resumen-final.sin-usd { display: none; }      /* sin dólares repetía el total de arriba */

  /* Sin gastos en dólares, la columna USD no ocupa lugar */
  .tabla-section.sin-usd .gr-usd, .tabla-section.sin-usd .col-usd-head, .tabla-section.sin-usd .tf-usd { display: none; }
  .tabla-section.sin-usd .row-fijo,    .tabla-section.sin-usd .ch-fijo    { grid-template-columns: 20px 1fr 130px 90px 28px; }
  .tabla-section.sin-usd .row-debito,  .tabla-section.sin-usd .ch-debito  { grid-template-columns: 20px 55px 1fr 120px 90px 28px; }
  .tabla-section.sin-usd .row-credito, .tabla-section.sin-usd .ch-credito { grid-template-columns: 20px 55px 1fr 110px 60px 90px 90px 28px; }

  /* Borrar: botón de 28px (cómodo con el mouse) que aparece al pasar por la fila o con el teclado */
  .gasto-row .gr-del { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; font-size: 17px; border-radius: 6px; }
}
@media (min-width: 701px) and (hover: hover) and (pointer: fine) {
  .gasto-row .gr-del { opacity: 0; }
  .gasto-row:hover .gr-del, .gasto-row:focus-within .gr-del { opacity: 1; }
}

.seg-buscar {
  flex: 1; min-width: 220px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--muted);
}
.seg-buscar:focus-within { border-color: var(--accent-mid); }
.seg-buscar input { flex: 1; min-width: 0; border: none; background: none; outline: none; font: inherit; font-size: 14px; color: var(--text); }
/* Filtro: control segmentado de una pieza; la opción elegida es la pastilla clara */
.seg-toolbar .seg-filtro {
  display: inline-flex; gap: 2px; margin: 0; padding: 3px; height: 38px; box-sizing: border-box;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface2);
}
.seg-toolbar .seg-filtro button {
  flex-direction: row; padding: 0 14px; border: none; border-radius: 7px; background: none; box-shadow: none;
  font-size: 13px; color: var(--muted); transition: background 160ms var(--ease-out), color 160ms;
}
.seg-toolbar .seg-filtro button.activo { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }
.seg-agregar { height: 38px; padding: 0 16px; }
.seg-dia {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px 0 14px;
  padding: 8px 12px; border-radius: 9px; background: var(--accent-light); color: var(--accent-text); font-size: 13px;
}
.seg-dia button { background: none; border: none; color: inherit; font: inherit; font-weight: 500; cursor: pointer; padding: 4px 6px; border-radius: 6px; }

.btn-seg-mas {
  width: 36px; height: 36px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font-size: 18px; line-height: 1; cursor: pointer;
}
.seg-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; min-width: 250px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,0.14);
}
.seg-menu.open { display: block; animation: page-in 160ms var(--ease-out); }
.seg-menu button {
  display: block; width: 100%; text-align: left; background: none; border: none; font: inherit; font-size: 14px;
  color: var(--text); padding: 9px 12px; border-radius: 7px; cursor: pointer;
}
.seg-menu hr { border: none; border-top: 1px solid var(--border); margin: 6px 4px; }
.seg-menu .seg-menu-peligro { color: var(--red); }
@media (hover: hover) and (pointer: fine) {
  .seg-menu button:hover, .btn-seg-mas:hover { background: var(--surface2); }
  .seg-dia button:hover { background: color-mix(in srgb, var(--accent-mid) 15%, transparent); }
}

/* Total del mes: color normal; ámbar cerca del límite y rojo solo si te pasás */
.tg-uyu { color: var(--text); font-size: 22px; }
.total-general[data-estado="warn"] .tg-uyu { color: var(--orange); }
.total-general[data-estado="over"] .tg-uyu { color: var(--red); }
.tg-de { font-size: 13px; color: var(--muted); }
.tg-track { width: 100%; max-width: 280px; height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; margin: 5px 0 2px; }
.tg-track[hidden] { display: none; }
.tg-fill { height: 100%; border-radius: 3px; background: var(--accent-mid); transition: width 480ms var(--ease-out); }
.total-general[data-estado="warn"] .tg-fill { background: var(--orange); }
.total-general[data-estado="over"] .tg-fill { background: var(--red); }
.tg-sub { font-size: var(--fs-12); color: var(--muted); }

/* ══ CALENDARIO: cuánto gastaste cada día ══ */
.sb-cal-grid.con-semanas { grid-template-columns: repeat(7, minmax(0, 1fr)) 32px; gap: 2px; }
.sb-cal-grid.con-semanas .sb-cal-day { width: auto; height: auto; aspect-ratio: 1; }
button.sb-cal-day { border: none; padding: 0; font: inherit; font-size: var(--fs-11); cursor: pointer; }
.sb-cal-day.nivel-1, .sb-legend i.nivel-1 { background: color-mix(in srgb, var(--accent-mid) 16%, var(--surface)); color: var(--text); }
.sb-cal-day.nivel-2, .sb-legend i.nivel-2 { background: color-mix(in srgb, var(--accent-mid) 34%, var(--surface)); color: var(--text); }
.sb-cal-day.nivel-3, .sb-legend i.nivel-3 { background: color-mix(in srgb, var(--accent-mid) 58%, var(--surface)); color: var(--surface); }
.sb-cal-day.nivel-4, .sb-legend i.nivel-4 { background: var(--accent-mid); color: var(--surface); }
.sb-cal-day.pasado { box-shadow: inset 0 0 0 1.5px var(--red); }
.sb-cal-day.elegido { outline: 2px solid var(--text); outline-offset: 1px; }
@media (hover: hover) and (pointer: fine) { button.sb-cal-day:hover { filter: brightness(0.95); } }
.sb-cal-sem { font-size: 10px; color: var(--muted); display: flex; align-items: center; justify-content: flex-end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cal-marca { position: absolute; top: 2px; right: 2px; width: 5px; height: 5px; background: var(--blue); }
.cal-marca.cierre { border-radius: 50%; }          /* cierre: punto redondo */
.cal-marca.vence { background: var(--red); }       /* vencimiento: cuadradito (no solo el color los distingue) */
.sb-legend { align-items: center; gap: 4px; }
.sb-legend span { margin: 0 2px; }
.sb-cal-ayuda { font-size: var(--fs-11); color: var(--muted); line-height: 1.45; margin-top: 8px; }
.sb-ritmo { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: var(--surface2); font-size: 12px; font-weight: 500; }
.sb-ritmo.ok { color: var(--accent-text); }
.sb-ritmo.over { color: var(--red); }
.sb-ritmo span { display: block; margin-top: 2px; font-size: var(--fs-11); font-weight: 400; color: var(--muted); }
.sb-tarjetas { display: flex; flex-direction: column; gap: 4px; margin-top: 10px; font-size: var(--fs-11); color: var(--muted); }
.sb-tarjetas span { display: flex; align-items: center; gap: 6px; }
.sb-tarjetas .cal-marca { position: static; flex-shrink: 0; }

/* ══ AJUSTES: tarjetas de crédito ══ */
.tarjeta-fila { display: grid; grid-template-columns: 1fr 100px 100px 36px; gap: 10px; align-items: end; margin-bottom: 10px; }
.tarjeta-fila label { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-12); color: var(--muted); }
.tarjeta-fila .tarjeta-borrar { opacity: 1; height: 40px; }
/* ══ SEGUIMIENTO: alineación ══
   Todo arranca en la misma línea (16px desde el borde de la tarjeta): franja, título de tabla, casilla y fecha.
   El total va pegado a su monto, en la columna de montos; y el total del encabezado, junto al título. */
@media (min-width: 701px) {
  .tabla-head { padding: 8px 16px 8px 11px; justify-content: flex-start; gap: 12px; } /* 11 + 5 del botón del título = 16 */
  .tabla-head .sel-bar { margin-left: auto; }
  .th-totals .th-uyu { font-size: 14px; }
  .gasto-row { padding-left: 16px; padding-right: 16px; }
  .col-heads { padding-left: 16px; padding-right: 16px; }
  .tabla-foot { padding: 8px 16px; }
  .tabla-foot > span:empty { display: none; }
  .tabla-foot > span { grid-row: 1; }
  .tf-label { text-align: right; }
  .tf-uyu { font-size: 13px; font-weight: 600; color: var(--text); }
  .tf-usd { font-size: 13px; font-weight: 600; }
  /* "Total" ocupa todo hasta la columna del monto y se apoya a la derecha, al lado del número */
  .tabla-foot.ch-fijo    .tf-label { grid-column: 1 / 4; } .tabla-foot.ch-fijo    .tf-uyu { grid-column: 4; } .tabla-foot.ch-fijo    .tf-usd { grid-column: 5; }
  .tabla-foot.ch-debito  .tf-label { grid-column: 1 / 5; } .tabla-foot.ch-debito  .tf-uyu { grid-column: 5; } .tabla-foot.ch-debito  .tf-usd { grid-column: 6; }
  .tabla-foot.ch-credito .tf-label { grid-column: 1 / 6; } .tabla-foot.ch-credito .tf-uyu { grid-column: 6; } .tabla-foot.ch-credito .tf-usd { grid-column: 8; }
}

/* La franja sigue el mismo orden que las tablas y el filtro: Débito, Crédito, Fijos */
@media (min-width: 701px) {
  .totals-strip .tot-item { border-right: 1px solid var(--border); }
  .totals-strip .tot-item:nth-child(2) { order: 3; border-right: none; } /* Fijos al final */
}

/* ══ SEGUIMIENTO: un total por tabla, sin franjas vacías ══ */
.th-totals[hidden] { display: none; }
@media (min-width: 701px) {
  /* Las tablas ocupan el mismo ancho que la barra de arriba: sin hueco a la derecha */
  .seg-main .tabla-section, .seg-main .tc-block, .seg-main .resumen-final { max-width: none; }
  /* Un solo total por tabla: el del encabezado (se sigue viendo con la tabla plegada) */
  .tabla-foot { display: none !important; }
  /* Encabezado liviano: título, cantidad y total juntos, sin una banda de color medio vacía */
  .tabla-head { background: transparent; border-bottom: 1px solid var(--border); padding-top: 10px; padding-bottom: 10px; }
  .tabla-head h2 { font-size: 15px; }
  /* Tabla vacía: sin títulos de columna encima del mensaje */
  .tabla-body:has(.row-empty) .col-heads { display: none; }
  .tabla-body .row-empty { padding: 22px 16px; }
}

/* Modo oscuro: los colores de categoría muy oscuros (Compras, Educación…) se aclaran para que se vean */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) :is(.gr-cat-tag > span, .sb-cat-dot, .sb-cat-fill) { filter: brightness(1.9) saturate(1.15); }
}
:root:is([data-theme="dark"], [data-theme="oled"]) :is(.gr-cat-tag > span, .sb-cat-dot, .sb-cat-fill) { filter: brightness(1.9) saturate(1.15); }

/* Encabezado de tabla como sección desplegable (estilo Finder): flecha a la izquierda, nombre con su
   cantidad en gris, y el total a la derecha. Los tres totales quedan en columna sin huecos forzados. */
@media (min-width: 701px) {
  .tabla-head { padding: 10px 16px 10px 9px; gap: 12px; }
  .tabla-head .th-left { display: flex; align-items: baseline; gap: 8px; padding: 4px 8px 4px 4px; }
  .tabla-head .collapse-icon { order: -1; width: 16px; height: 16px; display: grid; place-items: center; align-self: center; color: var(--muted); }
  .tabla-head .collapse-icon:not(.collapsed) { transform: none; }
  .tabla-head .th-count { background: none; padding: 0; border-radius: 0; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
  .tabla-head .th-right-normal { margin-left: auto; }
  .tabla-head .th-totals .th-uyu { font-family: var(--serif); font-size: 16px; font-weight: 400; line-height: 1; } /* igual que los totales de la franja */
}

.collapse-icon svg { display: block; }

/* ══ TABLAS: cada título de columna alineado con su contenido ══ */
/* Los títulos ordenables son inline-flex: text-align no los mueve, justify-content sí */
.col-heads span.sortable[style*="text-align:right"]  { justify-content: flex-end; }
.col-heads span.sortable[style*="text-align:center"] { justify-content: center; }
/* Categoría: el título arranca donde arranca el texto de la etiqueta (relleno 9 + punto 6 + espacio 5) */
.col-heads span.sortable[onclick*="'cat'"] { padding-left: 20px; }
@media (min-width: 701px) {
  /* PC: la nube mide lo que su texto y va centrada bajo el título "Categoría" */
  .gasto-row .gr-cat-tag { justify-self: center; padding: 2px 9px 2px 8px; gap: 5px; } /* mide lo que su texto, centrada bajo el título */
  .col-heads span.sortable[onclick*="'cat'"] { padding-left: 0; justify-content: center; }
}
/* Números con dígitos del mismo ancho: los montos quedan encolumnados */
.gr-uyu, .gr-monto, .gr-usd, .gr-fecha { font-variant-numeric: tabular-nums; }
@media (min-width: 701px) {
  /* Flecha en la columna de las casillas y nombre en la columna del texto de las filas */
  .tabla-head { padding-left: 12px; }
  .tabla-head .th-left { gap: 14px; }
}

@media (min-width: 701px) {
  /* El total del encabezado termina en la columna de montos (deja libre la columna de borrar: 28 + 10) */
  .tabla-head { padding-right: 54px; }
}

/* ══ SEGUIMIENTO (PC): encabezado sin banda + una tarjeta de resumen ══
   El encabezado comparte el fondo de la página. El resumen es una tarjeta como las tablas, del mismo
   ancho que el contenido: el total del mes (el único protagonista) y al lado Débito, Crédito y Fijos.
   En lugar de íconos sueltos, el punto del color de cada tipo. */
@media (min-width: 701px) {
  .seg-header { background: var(--bg); border-bottom: none; padding-top: 18px; } /* mismo fondo que la página, pero tapa lo que pasa por detrás al bajar (es sticky) */
  .seg-row1 { padding-bottom: 18px; }
  .seg-body { padding-top: 24px; }

  .totals-strip {
    display: grid; grid-template-columns: minmax(0, 1.7fr) repeat(3, minmax(0, 1fr));
    border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); overflow: hidden;
  }
  .totals-strip .tot-item, .totals-strip .tot-item.total-general {
    background: none; border-right: 1px solid var(--border); padding: 18px 20px;
    display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px;
  }
  .totals-strip .tot-item:nth-child(2) { border-right: none; } /* Fijos, que se muestra al final */
  .totals-strip .tot-icon { display: none; }
  .totals-strip .tot-text { gap: 6px; }
  .totals-strip .tot-label { display: inline-flex; align-items: center; gap: 7px; }
  .totals-strip .tot-label::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
  .totals-strip .tot-item:has(.tot-icon.debito)  .tot-label::before { background: var(--orange); }
  .totals-strip .tot-item:has(.tot-icon.credito) .tot-label::before { background: var(--blue); }
  .totals-strip .tot-item:has(.tot-icon.fijos)   .tot-label::before { background: var(--text); opacity: 0.55; }
  .totals-strip .tot-uyu { font-size: 22px; }

  .total-general .tg-uyu { font-size: 30px; }
  .total-general .tg-track { max-width: 360px; height: 6px; margin: 4px 0 2px; }
}

/* Resumen en la columna de las tablas (no de punta a punta) y compacto: la página queda en dos columnas */
@media (min-width: 701px) {
  .totals-strip { max-width: calc(100% - 256px); grid-template-columns: minmax(0, 1.5fr) repeat(3, minmax(0, 1fr)); }
  .totals-strip .tot-item, .totals-strip .tot-item.total-general { padding: 14px 18px; gap: 4px; justify-content: flex-start; }
  .totals-strip .tot-uyu { font-size: 19px; }
  .total-general .tg-uyu { font-size: 26px; }
  .total-general .tg-track { max-width: none; width: 100%; height: 5px; }
  .seg-body { padding-top: 16px; }
}

/* Resumen: las cuatro cajas con los mismos tres renglones (título, monto y barra), alineados entre sí */
.tot-parte { display: none; }
@media (min-width: 701px) {
  .totals-strip .tot-text { width: 100%; }
  .tot-parte { display: flex; flex-direction: column; gap: 3px; width: 100%; margin-top: 4px; }
  .tot-parte-track { width: 100%; height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
  .tot-parte-fill { height: 100%; border-radius: 3px; background: var(--muted); transition: width 480ms var(--ease-out); }
  .tot-parte span { font-size: var(--fs-12); color: var(--muted); }
  .totals-strip .tot-item:has(.tot-icon.debito)  .tot-parte-fill { background: var(--orange); }
  .totals-strip .tot-item:has(.tot-icon.credito) .tot-parte-fill { background: var(--blue); }
  .totals-strip .tot-item:has(.tot-icon.fijos)   .tot-parte-fill { background: var(--text); opacity: 0.55; }
  /* el monto en la misma línea que el total del mes */
  .total-general .tg-montos { min-height: 26px; align-items: baseline; }
  .totals-strip .tot-montos-row { min-height: 26px; align-items: flex-end; }
}

@media (min-width: 701px) {
  /* mismas alturas en las cuatro cajas: barra y texto de abajo en la misma línea */
  .total-general .tg-track { margin: 8px 0 0; }
  .tot-parte { gap: 4px; }
}

/* Selección (PC): la cuenta va pegada al título, en lugar del número de gastos, y las acciones al borde derecho */
/* La barra de selección aparece superpuesta a la derecha, en el lugar del total: el nombre, "32 gastos · …" y el
   alto del encabezado no cambian ni se mueven */
@media (min-width: 701px) {
  .tabla-head { position: relative; }
  .tabla-head .sel-bar.visible {
    position: absolute; right: 20px; top: 50%; transform: translateY(-50%); margin: 0; gap: 12px;
    padding-left: 16px; background: inherit; /* tapa el total, que queda invisible pero en su lugar */
  }
  .tabla-head .sel-count { flex: 0 1 auto; font-size: 13px; color: var(--text); }
}

/* Gasto en dólares: los pesos se muestran aproximados (≈) y más apagados que un monto real en pesos */
.gr-uyu.aprox { opacity: 0.72; font-weight: 400; }


/* Total de tabla con dólares: arriba el total convertido a pesos, abajo de qué se compone */
@media (min-width: 701px) {
  .tabla-head .th-totals { flex-direction: column; align-items: flex-end; gap: 2px; }
  .tabla-head .th-totals .th-usd { font-size: var(--fs-11); color: var(--muted); }
}

@media (min-width: 701px) {
  /* Con columna de dólares visible, el total en pesos queda sobre la columna de pesos (no sobre la de US$) */
  .tabla-section:not(.sin-usd) .tabla-head { padding-right: 136px; }
  .tot-parte span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}

@media (min-width: 701px) {
  /* La columna derecha va por encima del encabezado fijo; si no entra en la ventana, se desplaza adentro */
  #seg-sidebar { z-index: 5; max-height: calc(100vh - 140px); overflow-y: auto; overscroll-behavior: contain; }
  /* El encabezado fijo va arriba de todo (así el menú ⋯ se ve completo), pero su fondo solo cubre la columna
     de las tablas: sobre la columna derecha es transparente y no la tapa */
  .seg-header { background: linear-gradient(to right, var(--bg) calc(100% - var(--edge) - 240px), transparent 0); } /* hasta donde empieza la columna derecha: tapa también el brillo de color de las tablas */
  /* La zona transparente no se queda con los clics: solo el título y la tarjeta los reciben */
  .seg-header { pointer-events: none; }
  .seg-header > * { pointer-events: auto; }

  /* Totales del encabezado en fila: pesos sobre la columna de pesos, US$ sobre la columna de dólares */
  .tabla-head .th-totals { flex-direction: row; align-items: baseline; gap: 10px; }
  .tabla-section:not(.sin-usd) .tabla-head { padding-right: 54px; }
  .tabla-head .th-totals .th-usd { width: auto; min-width: 72px; white-space: nowrap; text-align: right; font-family: var(--serif); font-size: 16px; color: var(--usd); }
  .th-conv { font-size: 13px; color: var(--muted); white-space: nowrap; }
  .th-conv[hidden] { display: none; }
}

/* Pie con el total combinado (solo si la tabla tiene dólares): "Total en [Pesos | Dólares]  ≈ $50.348" */
.tabla-combo { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 10px 54px 10px 16px; border-top: 1px solid var(--border); background: var(--surface2); }
.tabla-combo[hidden], .tabla-body.collapsed ~ .tabla-combo { display: none; }
.combo-lbl { font-size: 13px; color: var(--muted); }
.combo-seg { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.combo-seg button { border: none; background: none; font: inherit; font-size: 12px; color: var(--muted); padding: 4px 10px; border-radius: 6px; cursor: pointer; }
.combo-seg button.activo { background: var(--surface2); color: var(--text); font-weight: 500; box-shadow: 0 1px 2px rgba(0,0,0,0.12); }
.combo-val { font-family: var(--serif); font-size: 18px; color: var(--text); min-width: 110px; text-align: right; }
/* ══ MENÚ DEL PERFIL ══
   Grilla de dos columnas: íconos centrados bajo la foto (44px) y textos alineados con el nombre.
   Opciones con margen y resaltado redondeado, como los menús de macOS. */
.profile-menu { width: 248px; padding: 6px; }
.pm-header { padding: 10px 10px 12px; gap: 12px; }
.pm-avatar-edit { width: 20px; height: 20px; border: 2px solid var(--surface); font-size: 13px; bottom: -3px; right: -3px; }
.pm-name { font-size: 15px; }
.pm-email { font-size: var(--fs-12); margin-top: 3px; }
.pm-divider { margin: 2px 10px 6px; }
.pm-item {
  display: grid; grid-template-columns: 44px 1fr; column-gap: 12px; align-items: center;
  padding: 8px 10px; border-radius: 8px; font-size: 13px;
}
.pm-item:last-child { border-radius: 8px; }
.pm-icon { display: grid; place-items: center; color: var(--muted); }
.pm-icon svg { display: block; }

/* ══ MENÚS FLOTANTES (⋯ y perfil): fondo esmerilado y aparición suave, como en macOS ══
   Translúcido con desenfoque: lo de atrás se intuye pero no compite con el texto.
   Con "reducir transparencia" activado, fondo sólido. */
.seg-menu, .profile-menu {
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: 0 16px 40px rgba(0,0,0,0.22), 0 0 0 0.5px rgba(0,0,0,0.08);
}
.seg-menu { transform-origin: top right; }
.seg-menu.open { animation: menu-in 180ms var(--ease-out); }
.profile-menu { transform-origin: top right; transform: translateY(-4px) scale(0.97); transition: opacity 160ms var(--ease-out), transform 180ms var(--ease-out); }
.profile-menu.open { transform: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-4px) scale(0.97); } }
@media (prefers-reduced-transparency: reduce) {
  .seg-menu, .profile-menu { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (prefers-reduced-motion: reduce) {
  .seg-menu.open { animation: none; }
  .profile-menu, .profile-menu.open { transform: none; transition: opacity 120ms; }
}

/* El menú ⋯ flota sobre la página (se ubica debajo de su botón desde app.js) */
#seg-menu { position: fixed; z-index: 170; }

/* Halo de los menús: un degradado del color del fondo alrededor, así lo que está cerca se esfuma
   (igual que las filas contra el encabezado al bajar) y lo lejano no cambia */
.seg-menu, .profile-menu {
  box-shadow:
    0 0 0 0.5px rgba(0,0,0,0.10),
    0 10px 28px rgba(0,0,0,0.20),
    0 0 36px 22px color-mix(in srgb, var(--bg) 88%, transparent);
}

/* ══ CONFIGURACIÓN (PC) — v2 ══
   Como Ajustes del Mac: la lista de secciones con sus valores a la izquierda, una sola sección a la derecha.
   Todos los formularios con el mismo armado: etiqueta a la izquierda, campo a la derecha, Guardar debajo del campo. */
.cfg-nav { display: none; }
.cfg-nav-salir {
  background: none; border: none; color: var(--red); font: inherit; font-size: 14px;
  padding: 8px 14px; border-radius: 8px; cursor: pointer; text-align: left;
}
details.help-item > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; margin: 0; }
details.help-item > summary::-webkit-details-marker { display: none; }
details.help-item > summary::after {
  content: '›'; margin-left: auto; color: var(--muted); font-size: 18px; line-height: 1;
  transition: transform 200ms var(--ease-out);
}
details.help-item[open] > summary::after { transform: rotate(90deg); }
details.help-item > .help-a { padding-top: 8px; }
details.help-item[open] > .help-a { animation: ayuda-abre 200ms var(--ease-out); }
@keyframes ayuda-abre { from { opacity: 0; transform: translateY(-4px); } }
@media (prefers-reduced-motion: reduce) {
  details.help-item > summary::after { transition: none; }
  details.help-item[open] > .help-a { animation: none; }
}
@media (min-width: 701px) {
  .config-page {
    display: grid; grid-template-columns: 248px minmax(0, 620px); column-gap: 32px; align-items: start;
    max-width: calc(248px + 32px + 620px + 56px);
  }
  .config-header { grid-column: 1 / -1; }
  .config-sections { display: block; columns: auto; }
  .config-section { margin-bottom: 0; }
  .config-section[hidden] { display: none !important; }

  /* Lista de secciones */
  .cfg-nav { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 96px; }
  .cfg-nav .mov-grupo { border-radius: 12px; }
  .cfg-nav .aj-fila { min-height: 40px; padding: 9px 14px; font-size: 14px; gap: 10px; cursor: pointer; }
  .cfg-nav .aj-valor { font-size: 13px; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  .cfg-nav .aj-perfil { min-height: 64px; padding: 12px 14px; gap: 12px; }
  .cfg-nav .aj-perfil .hero-avatar { width: 40px; height: 40px; font-size: 15px; }
  .cfg-nav .aj-perfil .aj-txt b { font-size: 15px; }
  .cfg-nav .aj-perfil .aj-txt small { font-size: 12px; }
  .cfg-nav .aj-fila.activa { background: color-mix(in srgb, var(--accent-mid) 18%, var(--surface)); }
  .cfg-nav .aj-fila.activa .aj-txt { font-weight: 500; }
  @media (hover: hover) and (pointer: fine) {
    .cfg-nav .aj-fila:not(.activa):hover { background: var(--surface2); }
    .cfg-nav-salir:hover { background: color-mix(in srgb, var(--red) 10%, transparent); }
  }
  .cfg-nav .aj-fila:focus-visible, .cfg-nav-salir:focus-visible { outline: 2px solid var(--accent-mid); outline-offset: -2px; }

  /* Sección elegida */
  .config-section { padding: 26px 28px; }
  .config-section > .cs-title {
    font-family: var(--serif); font-size: 26px; letter-spacing: 0; text-transform: none;
    color: var(--text); margin-bottom: 22px !important; line-height: 1.1;
  }
  .config-section .config-row {
    display: grid; grid-template-columns: 150px minmax(0, 1fr); align-items: center;
    column-gap: 20px; margin: 0 0 14px;
  }
  .config-section .config-row > label { font-size: 13px; }
  .config-section .config-row .fi, .config-section .config-row .fs { width: 100%; max-width: 280px !important; }
  .cfg-email { text-align: left; font-size: 14px; }
  /* Guardar alineado con los campos */
  .config-section .config-row ~ .btn-save,
  #tc-manual-campos .btn-save { margin-left: 170px; }
  .config-section .cfg-ayuda { max-width: 52ch; }
  .cfg-avatar-row { margin-bottom: 22px; }
  .cfg-avatar { width: 72px; height: 72px; }
  .cfg-avatar-actions { flex: none; }
  .config-section[data-sec="ayuda"] { padding-bottom: 12px; }
}

/* ══ CONFIGURACIÓN (PC) — v3 ══
   La barra lateral es navegación, no tarjetas: filas sueltas con ícono y una píldora para la elegida,
   como Ajustes del Mac. Los valores viven en cada sección, no se repiten en la lista. */
.solo-pc { display: none; }
@media (min-width: 701px) {
  .solo-pc { display: block; }
  .cfg-back { display: none; } /* Inicio ya está arriba, en la barra */
  .config-header { margin-bottom: 22px; }

  .cfg-nav { gap: 18px; }
  .cn-grupo { display: flex; flex-direction: column; gap: 2px; }
  .cfg-nav .aj-fila {
    display: flex; align-items: center; gap: 10px;
    background: none; border: none; border-radius: 8px;
    min-height: 34px; padding: 7px 10px; font-size: 14px; color: var(--text); text-align: left; width: 100%;
  }
  .cfg-nav .cn-ico { flex-shrink: 0; color: var(--muted); }
  .cfg-nav .aj-perfil { min-height: 56px; padding: 8px 10px; gap: 12px; }
  .cfg-nav .aj-perfil .hero-avatar { width: 38px; height: 38px; font-size: 14px; }
  .cfg-nav .aj-fila.activa { background: color-mix(in srgb, var(--accent-mid) 16%, transparent); }
  .cfg-nav .aj-fila.activa .cn-ico { color: var(--accent-text); }
  .cfg-nav .aj-fila.activa .aj-txt { font-weight: 500; }
  @media (hover: hover) and (pointer: fine) {
    .cfg-nav .aj-fila:not(.activa):hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
  }
  .cfg-nav-salir { align-self: flex-start; padding: 7px 10px; }

  /* Filas del formulario: la etiqueta acompaña la primera línea del valor (Usuario, Email) */
  .config-section .config-row { align-items: baseline; }
  .config-section .config-row > label { padding-top: 0; }
  .cfg-sangria { margin-left: 170px; }
  .cfg-sep { margin-top: 22px !important; padding-top: 20px; border-top: 1px solid var(--border); }
  .config-section[data-sec="importar"] .btn-exportar { margin: 0; }

  /* Perfil: foto con su botón alineada a la columna de los campos */
  .config-section[data-sec="perfil"] .cfg-avatar-row { margin-left: 170px; }
  .cfg-avatar-wrap { gap: 16px; }
}

/* Barra lateral de Configuración: una sola columna para íconos y foto (32px), así todos los textos
   arrancan en la misma línea; mismo alto para todas las filas y el mismo aire entre grupos */
@media (min-width: 701px) {
  .cfg-nav { gap: 16px; }
  .cfg-nav .aj-fila {
    display: grid; grid-template-columns: 32px minmax(0, 1fr); column-gap: 10px; align-items: center;
    min-height: 36px; padding: 0 10px 0 6px;
  }
  .cfg-nav .cn-ico { justify-self: center; }
  .cfg-nav .aj-perfil { min-height: 52px; padding: 0 10px 0 6px; column-gap: 10px; }
  .cfg-nav .aj-perfil .hero-avatar { width: 32px; height: 32px; font-size: 13px; }
  .cfg-nav .aj-txt { gap: 1px; }
  .cfg-nav .cfg-nav-salir { align-self: stretch; color: var(--red); font-size: 14px; }
  .cfg-nav .cfg-nav-salir .cn-ico { color: var(--red); }
}

/* Barra lateral de Configuración como un solo panel (mismo fondo y borde que la sección de la derecha):
   los grupos se separan con una línea fina, no con aire, así nada queda flotando */
@media (min-width: 701px) {
  .cfg-nav {
    gap: 0; padding: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  }
  .cn-grupo, .cfg-nav .cfg-nav-salir { margin-top: 6px; padding-top: 6px; position: relative; }
  .cn-grupo::before, .cfg-nav .cfg-nav-salir::before {
    content: ''; position: absolute; top: 0; left: 10px; right: 10px; height: 1px; background: var(--border);
  }
  .cfg-nav .cfg-nav-salir { padding-top: 0; margin-top: 12px; overflow: visible; }
  .cfg-nav .cfg-nav-salir::before { top: -6px; }
}

/* ══ PERFIL ══
   Arriba, quién sos: foto grande, nombre y usuario, y "Cambiar foto" como enlace (como la Cuenta del Mac).
   Debajo, una línea y los datos con el mismo armado que el resto de las secciones. */
.cfg-ident { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cfg-ident b { font-family: var(--serif); font-weight: 400; font-size: 24px; line-height: 1.1; color: var(--text); }
.cfg-ident small { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
@media (min-width: 701px) {
  .config-section[data-sec="perfil"] > .cs-title { display: none; }
  .config-section[data-sec="perfil"] .cfg-avatar-row {
    margin: 0 0 22px; padding-bottom: 22px; border-bottom: 1px solid var(--border);
  }
  .config-section[data-sec="perfil"] .cfg-avatar-wrap { gap: 18px; }
  .config-section[data-sec="perfil"] .cfg-avatar { width: 76px; height: 76px; border-width: 0; }
  .config-section[data-sec="perfil"] .cfg-avatar-actions { gap: 6px; align-items: flex-start; }
  .config-section[data-sec="perfil"] .cfg-avatar-btn {
    background: none; border: none; padding: 2px 0; border-radius: 4px;
    color: var(--accent-text); font-size: 13px;
  }
  @media (hover: hover) and (pointer: fine) {
    .config-section[data-sec="perfil"] .cfg-avatar-btn:hover { text-decoration: underline; text-underline-offset: 3px; }
  }
  .config-section[data-sec="perfil"] .cfg-avatar-btn:focus-visible { outline: 2px solid var(--accent-mid); outline-offset: 2px; }
}

/* Menú ⋯ en grupos (como las listas agrupadas de iOS) y hoja de importar */
.hoja-grupo-sep { margin-top: 12px; }
.hoja-opt-mas { position: relative; padding-right: 36px !important; }
.hoja-opt-mas::after { content: '›'; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 22px; color: var(--muted); }
.hoja-fila { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 6px 4px 16px; min-height: 52px; }
.hoja-fila b { font-size: 16px; font-weight: 500; }
/* Banco: la fila entera es el botón; al tocarla se abren los bancos dentro de la misma burbuja */
.imp-banco-btn { width: 100%; background: none; border: none; cursor: pointer; font-family: var(--mono); color: var(--text); text-align: left; padding-right: 16px; transition: background-color 150ms; }
.imp-banco-btn:hover, .imp-banco-btn:active { background: var(--hover); }
.imp-banco-btn:focus-visible { outline: 2px solid var(--accent-mid); outline-offset: -2px; }
.imp-banco-valor { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 500; color: var(--accent-mid); }
.imp-banco-valor svg { transition: transform 220ms var(--ease-out); }
.imp-banco-btn[aria-expanded="true"] .imp-banco-valor svg { transform: rotate(180deg); }
.imp-banco-zona { position: relative; }
/* Menú flotante con fondo esmerilado y halo, igual que el del perfil y el ⋯ */
.imp-bancos {
  position: absolute; top: calc(100% + 6px); right: 0; width: 240px; z-index: 5;
  border-radius: 12px; overflow: hidden; padding: 4px 0;
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(1.5); backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: 0 0 0 0.5px rgba(0,0,0,0.10), 0 10px 28px rgba(0,0,0,0.20), 0 0 36px 22px color-mix(in srgb, var(--bg) 88%, transparent);
  transform-origin: top right; animation: menu-in 180ms var(--ease-out);
}
@media (prefers-reduced-transparency: reduce) { .imp-bancos { background: var(--surface); -webkit-backdrop-filter: none; backdrop-filter: none; } }
.imp-banco-opt {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 46px; padding: 0 16px; background: none; border: none; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 15px; color: var(--text); text-align: left; cursor: pointer;
}
.imp-banco-opt:last-child { border-bottom: none; }
button.imp-banco-opt:hover { background: var(--hover); }
.imp-banco-opt.apagado { color: var(--muted); cursor: default; }
.imp-banco-opt small { font-size: 12px; }
.imp-check { color: var(--accent-mid); font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .imp-bancos { animation: none; } .imp-banco-valor svg { transition: none; } }
/* Archivos: ícono de color (naranja débito, azul crédito, como en el resto de la app) + texto + › */
.imp-opt {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 12px 40px 12px 14px; min-height: 64px;
  position: relative; background: none; border: none; border-bottom: 1px solid var(--border);
  text-align: left; font-family: var(--mono); color: var(--text); cursor: pointer; transition: background-color 150ms;
}
.imp-opt:last-child { border-bottom: none; }
.imp-opt::after { content: '›'; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 24px; color: var(--muted); }
.imp-opt:hover, .imp-opt:active { background: var(--hover); }
.imp-opt:focus-visible { outline: 2px solid var(--accent-mid); outline-offset: -2px; }
.imp-icono {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
.imp-icono.debito  { background: var(--orange-light); color: var(--orange); }
.imp-icono.credito { background: var(--blue-light); color: var(--blue); }
.imp-texto { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.imp-texto b { font-size: 16px; font-weight: 500; }
.imp-texto span { font-size: 13px; color: var(--muted); }
.hoja-nota { font-size: 13px; color: var(--muted); padding: 10px 4px 0; }

/* Descripción corta debajo de cada tipo de gasto: quien no conoce la app entiende qué va en cada uno */
.tipo-seg button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-height: 50px; line-height: 1.2; }
.tipo-seg button { font-size: 14px; line-height: 1.15; padding: 4px 2px; }
.tipo-seg button small { font-size: 11px; font-weight: 400; color: var(--muted); }


/* Gastos mensuales fijos del Inicio: la categoría como en las tablas de cada mes (pastilla del ancho del texto, centrada) */
@media (min-width: 701px) { .tpl-row > .gr-cat-tag { justify-self: center; } }


/* ══ TUTORIAL DE PRIMERA VEZ ══
   La pantalla se oscurece salvo un recorte sobre el elemento que se explica; el globo va al lado. */
.tuto-capa { position: fixed; inset: 0; z-index: 500; opacity: 0; transition: opacity 200ms ease-out; }
.tuto-capa.open { opacity: 1; }
.tuto-foco {
  position: fixed; border-radius: 14px; pointer-events: none;
  box-shadow: 0 0 0 2px var(--accent-mid), 0 0 0 9999px rgba(10, 9, 7, 0.8);
}
.tuto-foco.sin-foco { left: 50% !important; top: 50% !important; width: 0 !important; height: 0 !important; box-shadow: 0 0 0 9999px rgba(10, 9, 7, 0.8); }
.tuto-globo {
  position: fixed; padding: 20px 20px 16px; border-radius: 16px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: 0 18px 50px rgba(0,0,0,0.35);
  transition: opacity 180ms ease-out, transform 220ms var(--ease-out);
}
/* Entre pasos: el globo se apaga y baja un poco; vuelve a aparecer ya en su lugar */
.tuto-capa.cambiando .tuto-globo { opacity: 0; transform: translateY(6px); }
.tuto-logo { font-family: var(--serif); letter-spacing: -0.5px; white-space: nowrap; }
.tuto-logo em { color: var(--accent-mid); font-style: italic; }
.tuto-globo h2 { font-family: var(--serif); font-size: 22px; font-weight: 400; margin: 10px 0 8px; }
.tuto-globo p { font-size: 15px; line-height: 1.5; color: var(--muted); }
.tuto-cabeza { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tuto-cuenta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tuto-puntos { display: flex; gap: 6px; }
.tuto-puntos i { width: 6px; height: 6px; border-radius: 50%; background: var(--border2); }
.tuto-puntos i.activo { width: 18px; border-radius: 3px; background: var(--accent-mid); }
.tuto-btns { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 18px; }
.tuto-saltar { min-height: 44px; padding: 0 8px; background: none; border: none; font-family: var(--mono); font-size: 14px; color: var(--muted); cursor: pointer; }
.tuto-saltar:hover { color: var(--text); }
.tuto-sig { width: auto !important; min-width: 120px; min-height: 44px; margin-left: auto; }
.tuto-saltar:focus-visible, .tuto-sig:focus-visible { outline: 2px solid var(--accent-mid); outline-offset: 2px; }
.tuto-ver { width: auto; padding: 9px 22px; margin-bottom: 18px; }
@media (prefers-reduced-motion: reduce) { .tuto-capa, .tuto-foco, .tuto-globo { transition: none; } .tuto-capa.cambiando .tuto-globo { transform: none; } }

/* ══ TIPO DE GASTO EN EL FORMULARIO: lista agrupada con tilde (como las listas de iOS) ══
   Filas de 56px con aire: nombre en 15px y debajo qué entra en 13px, sin cortar el nombre largo. */
.tipo-lista { display: flex; flex-direction: column; margin: -4px 0 20px; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface2); }
.tipo-lista[hidden] { display: none; }
.tipo-lista button {
  position: relative; display: flex; align-items: center; min-height: 56px; padding: 9px 44px 9px 16px; gap: 12px;
  background: none; border: none; border-bottom: 1px solid var(--border); text-align: left; cursor: pointer;
  font-family: var(--mono); color: var(--text); transition: background-color 150ms;
}
.tipo-lista button:last-child { border-bottom: none; }
.tipo-lista button:hover { background: var(--hover); }
.tipo-lista button:focus-visible { outline: 2px solid var(--accent-mid); outline-offset: -2px; }
.tipo-lista button > span { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tipo-lista b { font-size: 15px; font-weight: 500; line-height: 1.25; }
.tipo-lista small { font-size: 13px; color: var(--muted); line-height: 1.3; }
.tipo-lista [aria-checked="true"] { background: var(--surface); }
.tipo-lista [aria-checked="true"]::after { content: '✓'; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: var(--accent-mid); font-weight: 700; font-size: 16px; }

/* Encabezado de cada tipo dentro del mes: una sola línea (nombre, "33 gastos · qué entra" en gris, total a la derecha) */
.th-titulos { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.th-nombre { display: inline-flex; align-items: baseline; }
.th-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.tabla-head .th-sub .th-count { font-size: 13px; color: var(--muted); }
/* Cartel de versión nueva: abajo al centro, sobre la barra del celu; queda hasta que se toca Actualizar */
.update-banner {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 450;
  display: flex; align-items: center; gap: 14px; padding: 8px 8px 8px 18px; max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  font-family: var(--mono); font-size: 14px;
}
.update-banner[hidden] { display: none; }
.update-banner button {
  min-height: 40px; padding: 0 16px; border: none; border-radius: 10px; cursor: pointer;
  background: var(--accent); color: #fff; font-family: var(--mono); font-size: 14px; font-weight: 500;
}
.update-banner button:focus-visible { outline: 2px solid var(--accent-mid); outline-offset: 2px; }
/* Encabezado de cada tipo (PC): más aire arriba y abajo, el resalte al pasar el mouse en toda la fila
   (no una pastilla pegada al texto) y, plegado, el total contra el borde derecho como la flecha a la izquierda.
   Abierto, el total sigue alineado con la columna de montos. */
@media (min-width: 701px) {
  .tabla-head { padding-top: 14px; padding-bottom: 14px; transition: background-color 150ms; }
  .tabla-head .th-left, .tabla-head .th-left:hover { background: none; padding: 2px 0 2px 4px; }

  .th-titulos { gap: 12px; }
  /* El total queda siempre en el mismo lugar (alineado con la columna de montos), abierta o plegada */
}


/* Filas: jerarquía por tamaño y color, no todo igual.
   Descripción = lo principal (14px, color de texto). Monto del mes = color del tipo, 14px.
   Fecha, categoría, cuotas y total de la compra = datos de apoyo en gris. El azul queda solo para plata de crédito. */
@media (min-width: 701px) {
  .gasto-row .gr-desc { font-size: 14px; color: var(--text); }
  .gasto-row .gr-uyu { font-size: 14px; font-variant-numeric: tabular-nums; }
  .gr-uyu.secundario { color: var(--muted); font-weight: 400; }
}
/* Menos color y menos burbujas en las filas: el color del tipo queda en el punto y el total del encabezado;
   los montos de cada fila van en el color del texto. Las cuotas, texto gris sin burbuja (la categoría es la única). */
@media (min-width: 701px) {
  .gasto-row .gr-uyu.orange, .gasto-row .gr-uyu.blue, .gasto-row .gr-uyu.red { color: var(--text); }
  .cuota-pill { background: none; padding: 0; color: var(--muted); font-size: 13px; }
}

/* ══ TABLAS DE CADA MES (PC): una tarjeta por tipo, bien separadas ══
   - El texto "32 gastos · …" va debajo del nombre, chico y gris (dos renglones compactos).
   - El encabezado de cada tabla lleva el tono suave de su tipo (naranja débito, azul crédito, neutro fijos),
     así se distingue qué tabla es de un vistazo; las filas quedan blancas.
   - Los títulos de columna sin banda de color: solo texto gris y una línea, para no apilar dos franjas. */
@media (min-width: 701px) {
  .seg-main { gap: 20px; }
  .th-titulos { flex-direction: column; align-items: flex-start; gap: 2px; }
  .tabla-head .th-left { align-items: center; }
  .tabla-head .th-sub { font-size: 12px; }
  .tabla-head { padding-top: 11px; padding-bottom: 11px; border-bottom: 1px solid var(--border); }
  /* Tarjeta neutra (borde gris de siempre + sombra suave que la despega del fondo).
     El tipo se reconoce por el color del total, como en la franja de arriba. */
  .tabla-section[data-tipo="debito"]  { --tipo: var(--orange); }
  .tabla-section[data-tipo="credito"] { --tipo: var(--blue); }
  .tabla-section[data-tipo="fijos"]   { --tipo: var(--muted); }
  /* Resalte del tipo: la sombra de cada tarjeta toma el color de su gasto (naranja, azul o gris),
     como un brillo suave alrededor; el borde sigue neutro. El nombre de la tabla sigue diciendo qué es. */
  .tabla-section[data-tipo] {
    box-shadow: 0 1px 2px rgba(0,0,0,0.04),
                0 0 0 3px color-mix(in srgb, var(--tipo) 9%, transparent),
                0 12px 30px -12px color-mix(in srgb, var(--tipo) 42%, transparent);
  }
  .tabla-section[data-tipo] .tabla-head { background: var(--surface); cursor: pointer; }
  .tabla-section[data-tipo] .tabla-head:hover { background: color-mix(in srgb, var(--tipo) 6%, var(--surface)); box-shadow: none; }

  /* Filas alternadas en lugar de una línea entre cada una (lists-and-tables › Desktop: ayudan a seguir
     cada fila a lo largo de las columnas); el pasar del mouse sigue marcando la fila */
  .tabla-section [id^="list-"] > .gasto-row { border-bottom: none; }
  .tabla-section [id^="list-"] > .gasto-row:nth-child(even) { background: color-mix(in srgb, var(--surface2) 55%, var(--surface)); }
  .tabla-section [id^="list-"] > .gasto-row.editable:hover { background: var(--hover); }
  /* Filas seleccionadas para borrar: todas del mismo color de selección (le ganan a las filas alternadas y al mouse) */
  .tabla-section [id^="list-"] > .gasto-row.selected,
  .tabla-section [id^="list-"] > .gasto-row.selected:hover { background: var(--accent-light); }
  .tabla-section .col-heads { background: var(--surface); padding-top: 8px; padding-bottom: 8px; }
}

/* ══ HISTORIAL (PC): lista de meses compacta ══
   Una fila por mes (nombre y total), sin repetir "sin datos"; una barra fina compara cada mes con el
   más caro del año. Entran los 12 meses sin scroll. El total va en el color del texto: el rojo queda
   para "te pasaste del límite" y el azul para crédito. */
@media (min-width: 701px) {
  .months-list { gap: 2px; }
  .month-item { display: block; padding: 9px 12px; }
  .mi-fila { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
  .mi-name { font-size: 14px; font-weight: 500; }
  .mi-hoy { margin-left: 8px; font-size: 11px; font-weight: 500; color: var(--accent-mid); }
  .mi-amount { font-size: 13px; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }
  .mi-amount.vacio { color: var(--muted); font-weight: 400; }
  .mi-barra { height: 3px; margin-top: 7px; border-radius: 2px; background: var(--border); overflow: hidden; }
  .mi-barra i { display: block; height: 100%; border-radius: 2px; background: var(--accent-mid); }
  .month-item.future .mi-amount { visibility: hidden; }
}



/* ══ BARRAS DE DESPLAZAMIENTO (PC con mouse) ══
   Finas y redondeadas, del color del texto con transparencia sobre fondo invisible, como las de macOS:
   se ven sin pesar y se marcan más al pasar el mouse. En celus y tablets quedan las del sistema. */
@media (hover: hover) and (pointer: fine) {
  :root { --sb-thumb: color-mix(in srgb, var(--text) 22%, transparent); --sb-thumb-hover: color-mix(in srgb, var(--text) 40%, transparent); }
  ::-webkit-scrollbar { width: 12px; height: 12px; }
  ::-webkit-scrollbar-track { background: transparent; }
  ::-webkit-scrollbar-thumb { background: var(--sb-thumb); border-radius: 999px; border: 3px solid transparent; background-clip: padding-box; min-height: 40px; }
  ::-webkit-scrollbar-thumb:hover { background: var(--sb-thumb-hover); border-width: 2px; background-clip: padding-box; }
  ::-webkit-scrollbar-corner { background: transparent; }
  /* Firefox no entiende lo de arriba: usa la versión estándar */
  @supports not selector(::-webkit-scrollbar) {
    * { scrollbar-width: thin; scrollbar-color: var(--sb-thumb) transparent; }
  }
}

/* Encabezado fijo del mes (PC): sin efectos al deslizar. El encabezado termina justo en el borde de abajo de la
   franja de totales (que es más ancha que las tablas): las filas se esconden detrás de ese borde, sin otro corte.
   El aire entre la franja y las tablas va arriba de las tablas. */
@media (min-width: 701px) {
  .seg-header { padding-bottom: 0; }
  .seg-body { padding-top: 20px; }
}

/* Franja de totales un poco más ancha que las tablas (8px por lado): así las cubre del todo, brillo de color
   incluido, y se lee como la barra que está por encima */
@media (min-width: 701px) {
  .totals-strip { max-width: calc(100% - 256px + 16px); margin-left: -8px; }
}



/* Al bajar a las tablas (PC): la franja de totales queda con un halo de sombra suave y difusa alrededor de su borde
   (no una línea), así se lee por encima de las filas que pasan por debajo. Aparece y se va suave. */
@media (min-width: 701px) {
  .seg-header .totals-strip { transition: box-shadow 260ms var(--ease-out); }
  .seg-header.con-scroll .totals-strip {
    box-shadow: 0 2px 6px rgba(0,0,0,0.10), 0 12px 36px rgba(0,0,0,0.22);
  }
  :root:is([data-theme="dark"], [data-theme="oled"]) .seg-header.con-scroll .totals-strip {
    box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 14px 40px rgba(0,0,0,0.55);
  }
}
@media (min-width: 701px) and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .seg-header.con-scroll .totals-strip {
    box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 14px 40px rgba(0,0,0,0.55);
  }
}

/* PC angosta / tablet (701–1180px): la columna derecha va DEBAJO, no al costado. El encabezado no le reserva lugar:
   fondo sólido de lado a lado y la franja de totales del mismo ancho que las tablas (+8px por lado). */
@media (min-width: 701px) and (max-width: 1180px) {
  .seg-header { background: var(--bg); }
  .totals-strip { max-width: none; width: calc(100% + 16px); }
}


/* ══ MES AGRUPADO POR TIPO (celu) ══
   Los tres grupos de la PC con el mismo resalte: anillo 9% y sombra 42% del color del tipo.
   El total del grupo va en ese color; el nombre dice el tipo, así no depende solo del color. */
.tipo-titulo { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 24px 4px 8px; }
.tipo-titulo b { display: block; font-size: 20px; font-weight: 700; color: var(--text); }
.tipo-titulo small { font-size: 13px; color: var(--muted); }
.tipo-total { font-size: 18px; font-weight: 600; color: var(--tipo); font-variant-numeric: tabular-nums; }
.tipo-titulo[data-tipo="debito"], .tipo-grupo[data-tipo="debito"] { --tipo: var(--orange); }
.tipo-titulo[data-tipo="credito"], .tipo-grupo[data-tipo="credito"] { --tipo: var(--blue); }
.tipo-titulo[data-tipo="fijo"], .tipo-grupo[data-tipo="fijo"] { --tipo: var(--muted); }
.tipo-grupo {
  box-shadow: 0 1px 2px rgba(0,0,0,0.04),
              0 0 0 3px color-mix(in srgb, var(--tipo) 9%, transparent),
              0 12px 30px -12px color-mix(in srgb, var(--tipo) 42%, transparent);
}


/* Piezas del celu que quedaron en el HTML (sin versión de celu por ahora): en PC no se ven */
.modal-x, .modal-ok, .cat-chips { display: none; }

/* El + y su atajo viven fuera de las pantallas: en PC no existen */
@media (min-width: 701px) { #mes-fab, #radial { display: none; } }



