/* Bolsillo · Sistema visual del rediseño
   Pocos colores, cada uno con un trabajo. Curvas, sombras y duraciones vienen de Open Props (/vendor/open-props.css).
   Escala tipográfica en el teléfono: 34 · 26 · 20 · 16 · 14 px. Esquinas: 16 controles, 24–28 tarjetas, 40 hojas. */

@font-face { font-family: "Inter"; src: url("/fonts/inter.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Space Grotesk"; src: url("/fonts/space-grotesk.woff2") format("woff2"); font-weight: 500 700; font-style: normal; font-display: swap; }

/* ---------- Tokens ---------- */
:root {
  color-scheme: light;
  /* Marca */
  --ink: #0E1726;            /* Tinta: texto y fondos oscuros */
  --paper: #F6F8FB;          /* Papel: fondo de la app */
  --mist: #EAF0FA;           /* Niebla: superficies y pistas */
  --accent: #2563EB;         /* Azul: acción principal */
  --in: #0F766E;             /* Ingreso: siempre con «+» */
  --out: #C2410C;            /* Gasto: siempre con «−» */
  --bad: #B42318;            /* Error: con ícono y texto */
  --warn-bg: #FFF1CC;        /* Aviso: fondo de advertencias */
  --warn-text: #7A4E00;
  /* Derivados */
  --page: var(--paper);
  --surface: #FFFFFF;
  --surface-2: #F0F4FA;
  --surface-3: var(--mist);
  --line: #E1E7F0;
  --line-strong: #C9D3E1;
  --text: var(--ink);
  --text-2: #3B4759;
  --muted: #5B687D;
  --accent-strong: #1D4ED8;
  --accent-text: #1D4ED8;
  --accent-soft: #E6EEFE;
  --on-accent: #FFFFFF;
  --in-soft: #E2F3F0;
  --out-soft: #FCEBE2;
  --bad-soft: #FDECEA;
  --warn: #B77900;
  --info-soft: var(--accent-soft);
  --ink-surface: #0E1726;
  --on-ink: #F6F8FB;
  --on-ink-muted: #A9B6CC;
  --hero-in: #5EEAD4;
  --hero-out: #FDBA8C;
  --scrim: rgb(14 23 38 / 0.45);
  --cat-toward: #000;
  --cat-keep: 76%;
  --cat-bg: 13%;
  /* Forma */
  --r-control: 16px;
  --r-card: 28px;
  --r-sheet: 40px;
  --r-pill: 999px;
  /* Sombras de Open Props, teñidas con la tinta */
  --shadow-color: 218 45% 14%;
  --shadow-strength: 2%;
  --shadow-card: var(--shadow-2);
  --shadow-raised: var(--shadow-3);
  --shadow-sheet: var(--shadow-6);
  /* Movimiento */
  --t-tap: var(--duration-quick-2, 120ms);
  --t-enter: 220ms;
  --t-view: var(--duration-moderate-2, 260ms);
  --ease: var(--ease-out-3, cubic-bezier(0, 0, .3, 1));
  --ease-spring: var(--ease-spring-2, cubic-bezier(.2, .8, .2, 1));
  /* Tipografía */
  --display: "Space Grotesk", "Inter", "Segoe UI", system-ui, sans-serif;
  --body: "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  --fs-1: 34px; --fs-2: 26px; --fs-3: 20px; --fs-4: 16px; --fs-5: 14px; --fs-6: 12px;
}

/* Modo oscuro: los mismos tokens con otros valores */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0B1220; --surface: #121C2E; --surface-2: #18243A; --surface-3: #1E2B44;
    --line: #24324B; --line-strong: #33445F;
    --text: #EEF2F8; --text-2: #C3CDDC; --muted: #93A1B8;
    --accent: #3B7BF6; --accent-strong: #5B8FF8; --accent-text: #8AB0FF; --accent-soft: rgb(59 123 246 / 0.18);
    --in: #2DD4BF; --in-soft: rgb(45 212 191 / 0.14); --out: #FB923C; --out-soft: rgb(251 146 60 / 0.14);
    --bad: #F97066; --bad-soft: rgb(249 112 102 / 0.15); --warn: #F5B544; --warn-bg: rgb(245 181 68 / 0.16); --warn-text: #F8CF7E;
    --ink-surface: #16213A; --on-ink: #EEF2F8; --on-ink-muted: #A9B6CC;
    --scrim: rgb(2 6 14 / 0.62);
    --shadow-color: 220 60% 2%; --shadow-strength: 30%;
    --cat-toward: #fff; --cat-keep: 58%; --cat-bg: 22%;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0B1220; --surface: #121C2E; --surface-2: #18243A; --surface-3: #1E2B44;
  --line: #24324B; --line-strong: #33445F;
  --text: #EEF2F8; --text-2: #C3CDDC; --muted: #93A1B8;
  --accent: #3B7BF6; --accent-strong: #5B8FF8; --accent-text: #8AB0FF; --accent-soft: rgb(59 123 246 / 0.18);
  --in: #2DD4BF; --in-soft: rgb(45 212 191 / 0.14); --out: #FB923C; --out-soft: rgb(251 146 60 / 0.14);
  --bad: #F97066; --bad-soft: rgb(249 112 102 / 0.15); --warn: #F5B544; --warn-bg: rgb(245 181 68 / 0.16); --warn-text: #F8CF7E;
  --ink-surface: #16213A; --on-ink: #EEF2F8; --on-ink-muted: #A9B6CC;
  --scrim: rgb(2 6 14 / 0.62);
  --shadow-color: 220 60% 2%; --shadow-strength: 30%;
  --cat-toward: #fff; --cat-keep: 58%; --cat-bg: 22%;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; overflow-x: clip; }
html { scroll-padding-top: 16px; }
body {
  font: 400 15px/1.5 var(--body);
  background: var(--page); color: var(--text);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, p { margin: 0; }
h1 { font: 700 clamp(26px, 3.4vw, var(--fs-1))/1.12 var(--display); letter-spacing: -0.025em; }
h2 { font: 600 17px/1.3 var(--display); letter-spacing: -0.01em; }
h3 { font: 600 var(--fs-5)/1.3 var(--body); color: var(--text-2); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 100; padding: 10px 16px; border-radius: var(--r-control); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.skip-link:focus { top: 12px; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.nowrap { flex-wrap: nowrap; }
.stack { display: grid; gap: 16px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--in); }
.out { color: var(--out); }
.neg { color: var(--bad); }
.optional { color: var(--muted); font-weight: 400; }
number-flow { font-variant-numeric: tabular-nums; --number-flow-char-height: 1em; --number-flow-mask-height: 0.2em; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.main { padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: 1160px; width: 100%; outline: none; }
.shared .app, .logged-out .app { grid-template-columns: minmax(0, 1fr); }
.shared .nav, .logged-out .nav { display: none; }
.shared .main { margin: 0 auto; max-width: 780px; }

/* Barra lateral (escritorio) */
.nav {
  position: sticky; top: 0; height: 100dvh;
  padding: 22px 16px; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border-right: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font: 700 21px/1 var(--display); letter-spacing: -0.02em; }
.brand img { width: 34px; height: 34px; border-radius: 10px; }
.brand-i { position: relative; display: inline-block; }
.brand-i::after { content: ""; position: absolute; left: 50%; top: 0.06em; width: 0.22em; height: 0.22em; border-radius: 50%; background: #22D3EE; transform: translateX(-50%); }
.nav button {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 46px;
  padding: 10px 14px; border: 0; border-radius: var(--r-control); background: none; cursor: pointer; text-align: left;
  color: var(--text-2); font-weight: 500;
  transition: background-color var(--t-tap) var(--ease), color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease);
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button:active { transform: scale(0.97); }
.nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.nav .ico { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; }
.nav .nav-lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .nav-add { order: -1; margin-bottom: 14px; justify-content: center; background: var(--accent); color: var(--on-accent); font-weight: 600; box-shadow: 0 8px 20px -8px rgb(37 99 235 / 0.55); }
.nav .nav-add:hover { background: var(--accent-strong); color: var(--on-accent); }
.nav .brand { order: -2; }
.nav-pill { display: none; }

/* Barra inferior (teléfono): cinco destinos con Registrar al centro */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .nav {
    --nav-side: 14px; --nav-pad: 6px;
    position: fixed; left: var(--nav-side); right: var(--nav-side); top: auto; bottom: calc(12px + env(safe-area-inset-bottom));
    height: auto; z-index: 30; flex-direction: row; align-items: center; gap: 0; padding: var(--nav-pad) 6px;
    border: 1px solid var(--line); border-radius: 26px;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: saturate(1.6) blur(16px); -webkit-backdrop-filter: saturate(1.6) blur(16px);
    box-shadow: var(--shadow-raised);
    transition: left var(--t-view) var(--ease), right var(--t-view) var(--ease), transform var(--t-view) var(--ease);
  }
  .nav.is-compact:not(:has(:focus-visible)) { --nav-side: clamp(22px, 8vw, 40px); }
  .brand { display: none; }
  .nav-pill {
    display: block; position: absolute; top: var(--nav-pad); bottom: var(--nav-pad); left: 6px; width: calc((100% - 12px) / 5);
    border-radius: 20px; background: var(--accent-soft); pointer-events: none; z-index: 0;
    transition: transform 280ms var(--ease-spring), opacity var(--t-tap) var(--ease);
  }
  .nav button {
    z-index: 1; flex: 1 1 0; min-width: 0; min-height: 52px; flex-direction: column; justify-content: center; align-items: center;
    gap: 2px; padding: 4px 2px; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: 0.01em;
  }
  .nav button[aria-current="page"], .nav button:hover { background: none; }
  .nav button[aria-current="page"] { color: var(--accent-text); }
  .nav .nav-lbl { max-width: 100%; }
  @media (max-width: 400px) { .nav button { font-size: 10px; letter-spacing: -0.01em; } }
  .nav .nav-add { order: 0; margin: 0; background: none; box-shadow: none; color: var(--on-accent); }
  .nav .nav-add .ico {
    width: 48px; height: 48px; border-radius: 18px; background: var(--accent); margin-top: -2px;
    box-shadow: 0 10px 22px -8px rgb(37 99 235 / 0.7); transition: transform var(--t-tap) var(--ease);
  }
  .nav .nav-add .ico svg.i { width: 24px; height: 24px; stroke-width: 2.4; }
  .nav .nav-add .nav-lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .nav .nav-add:hover { background: none; }
  .nav .nav-add:active .ico { transform: scale(0.92); }
  .main { padding: 20px 16px calc(112px + env(safe-area-inset-bottom)); }
  .shared .main { padding-bottom: 32px; }
  .subview .nav { display: none; }
  .subview .main { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}

/* Encabezado de pantalla */
.head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; min-height: 48px; }
.head-titles { flex: 1; min-width: 0; }
.head-titles h1 { overflow-wrap: anywhere; }
.head-sub { font-size: var(--fs-5); color: var(--muted); margin-bottom: 2px; }
.head-sub::first-letter, .day span::first-letter, .plan-period-label::first-letter { text-transform: uppercase; }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* Sin conexión */
.offline-banner {
  position: sticky; top: 0; z-index: 70; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 16px calc(10px); padding-top: max(10px, env(safe-area-inset-top));
  background: var(--warn-bg); color: var(--warn-text); font-size: 14px; font-weight: 500; border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
}
.offline-banner[hidden] { display: none; }
.offline-banner .btn { background: color-mix(in srgb, var(--warn-text) 12%, transparent); color: var(--warn-text); min-height: 34px; }

/* Siluetas de carga */
.skeleton { display: grid; gap: 14px; max-width: 760px; }
.sk { display: block; border-radius: 14px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 40%, var(--surface-2) 80%); background-size: 300% 100%; animation: shimmer 1.4s var(--ease) infinite; }
.sk-line { height: 14px; width: 60%; } .sk-line.short { width: 30%; }
.sk-title { height: 34px; width: 52%; margin-bottom: 8px; }
.sk-hero { height: 168px; border-radius: var(--r-card); }
.sk-row { height: 60px; border-radius: 18px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Componentes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  padding: 20px 22px; box-shadow: var(--shadow-card); min-width: 0;
}
.card > h2 { margin-bottom: 14px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: start; }
.grid > * { grid-column: span 12; min-width: 0; }
@media (min-width: 960px) { .grid > .half { grid-column: span 6; } }
.widget { display: flex; flex-direction: column; gap: 10px; }
.widget-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 4px; min-height: 34px; }
.widget-head h2 { font-size: 18px; }
.section-action { display: flex; }

/* Botones: se hunden un poco al tocarlos y vuelven */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border: 0; border-radius: var(--r-control);
  background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 15px; line-height: 1.2;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: transform var(--t-tap) var(--ease), background-color var(--t-tap) var(--ease), color var(--t-tap) var(--ease), box-shadow var(--t-tap) var(--ease);
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn .i { width: 18px; height: 18px; }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px -8px rgb(37 99 235 / 0.6); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 18%, transparent); }
.btn.danger-solid { background: var(--bad); color: #fff; }
.btn.danger-solid:hover { background: color-mix(in srgb, var(--bad) 88%, #000); }
.btn.ghost { background: none; color: var(--accent-text); }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.ghost.danger { color: var(--bad); }
.btn.ghost.danger:hover { background: var(--bad-soft); }
.btn.icon { width: 44px; min-height: 44px; padding: 0; border-radius: 50%; }
.btn.small { min-height: 38px; padding: 7px 14px; font-size: 14px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; border-radius: 50%;
  border: 2.2px solid currentColor; border-color: var(--on-accent) var(--on-accent) transparent transparent; animation: spin 0.7s linear infinite;
}
.btn:not(.primary).is-busy::after { border-color: var(--text) var(--text) transparent transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.circle-btn { width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-1); flex: none; }
.circle-btn:hover { background: var(--surface-2); }
.circle-btn.danger { color: var(--bad); background: var(--surface); }

/* Campos */
input, select, textarea {
  width: 100%; min-width: 0; min-height: 48px; padding: 11px 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-control);
  background: var(--surface); color: var(--text);
  transition: border-color var(--t-tap) var(--ease), box-shadow var(--t-tap) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 0.62; }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--line-strong)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[aria-invalid], textarea[aria-invalid] { border-color: var(--bad); }
input[aria-invalid]:focus { box-shadow: 0 0 0 4px var(--bad-soft); }
input[readonly] { background: var(--surface-2); }
input[type="checkbox"] { width: 20px; height: 20px; min-height: auto; padding: 0; accent-color: var(--accent); }
textarea { resize: vertical; min-height: 84px; }
select { appearance: none; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); }
label.check { display: flex; align-items: center; gap: 10px; font-size: 15px; color: var(--text); font-weight: 400; padding: 4px 0; cursor: pointer; }
.fields { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); align-items: end; }
.fields > label { min-width: 0; }
.full-field { grid-column: 1 / -1; }
.field-help { color: var(--muted); font-size: 13px; margin-top: -6px; }
.form-note, .participant-fields { margin-top: 14px; }
.participant-fields { border: 0; padding: 0; margin-inline: 0; min-width: 0; }
.participant-fields legend { margin-bottom: 6px; }

/* Errores: junto al campo, con ícono */
.field-error, .form-error:not(:empty) {
  display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; padding: 10px 12px;
  border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-size: 13.5px; font-weight: 500; line-height: 1.4;
}
.field-error[hidden], .form-error:empty { display: none; }
.field-error .i { width: 17px; height: 17px; margin-top: 1px; }
.form-error::before {
  content: ""; flex: none; width: 17px; height: 17px; margin-top: 1px; background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 8v4M12 16h.01'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* Notas y avisos dentro de una pantalla */
.inline-note, .inline-alert { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; }
.inline-note { background: var(--surface-2); color: var(--text-2); }
.inline-note .i, .inline-alert .i { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.inline-note .i { color: var(--muted); }
.inline-note.good { background: var(--in-soft); color: var(--in); }
.inline-note.good .i { color: currentColor; }
.inline-alert.warn { background: var(--warn-bg); color: var(--warn-text); }
.inline-alert.bad { background: var(--bad-soft); color: var(--bad); }
.inline-alert.info { background: var(--info-soft); color: var(--accent-text); }

/* Interruptores */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; font-size: 15px; font-weight: 500; color: var(--text); cursor: pointer; }
.switch > span { display: grid; gap: 2px; }
.switch small { font-size: 12.5px; font-weight: 400; color: var(--muted); }
.switch input[type="checkbox"], input[type="checkbox"][role="switch"] {
  appearance: none; -webkit-appearance: none; position: relative; width: 48px; height: 28px; flex: none; margin: 0;
  border: 0; border-radius: var(--r-pill); background: var(--line-strong); cursor: pointer; transition: background-color var(--t-enter) var(--ease);
}
.switch input[type="checkbox"]::after, input[type="checkbox"][role="switch"]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 6px rgb(0 0 0 / 0.22); transition: transform var(--t-enter) var(--ease-spring);
}
.switch input:checked, input[type="checkbox"][role="switch"]:checked { background: var(--accent); }
.switch input:checked::after, input[type="checkbox"][role="switch"]:checked::after { transform: translateX(20px); }
.switch-list { display: grid; }
.switch-list .switch + .switch { border-top: 1px solid var(--line); }

/* Control segmentado */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--surface-2); border-radius: 14px; }
.seg button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: none;
  padding: 8px 14px; border-radius: 11px; min-height: 40px; cursor: pointer; color: var(--text-2); font-size: 14px; font-weight: 600;
  transition: background-color var(--t-tap) var(--ease), color var(--t-tap) var(--ease), box-shadow var(--t-tap) var(--ease);
}
.seg button .i { width: 17px; height: 17px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1), 0 1px 3px rgb(14 23 38 / 0.1); }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }
.seg.wide { display: flex; }
.seg.wide button { flex: 1; }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 500; border: 0; white-space: nowrap;
}
.chip .i { width: 14px; height: 14px; }
button.chip {
  cursor: pointer; padding: 8px 14px; font-size: 14px; min-height: 40px; background: var(--surface); border: 1.5px solid var(--line); color: var(--text);
  transition: background-color var(--t-tap) var(--ease), border-color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease);
}
button.chip:hover { border-color: var(--accent); }
button.chip:active { transform: scale(0.96); }
button.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); border-color: var(--accent); }
.chip.removable { gap: 6px; padding-inline-end: 10px; }
.chip.removable .i { width: 14px; height: 14px; color: var(--muted); }
.chip small { color: var(--muted); font-size: 12px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* Estados: siempre con palabra; el color solo la refuerza */
.status-chip {
  display: inline-flex; align-items: center; gap: 5px; flex: none; padding: 4px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600; line-height: 1.3; white-space: nowrap; background: var(--surface-2); color: var(--text-2);
}
.status-chip .i { width: 13px; height: 13px; stroke-width: 2.3; }
.status-chip.good { background: var(--in-soft); color: var(--in); }
.status-chip.warn { background: var(--warn-bg); color: var(--warn-text); }
.status-chip.bad { background: var(--bad-soft); color: var(--bad); }
.status-chip.info { background: var(--info-soft); color: var(--accent-text); }

/* Barra de uso: azul hasta el 80 %, ámbar después y roja al pasarse */
.usage { height: 10px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.usage > span { display: block; height: 100%; width: var(--pct); border-radius: inherit; background: var(--accent); transition: width 600ms var(--ease); }
.usage.warn > span { background: var(--warn); }
.usage.bad > span { background: var(--bad); }
.usage.good > span { background: var(--in); }
.grow-in { animation: grow-in 700ms var(--ease) both; }
@keyframes grow-in { from { width: 0; } }

/* Ícono de categoría */
.cat {
  width: 44px; height: 44px; border-radius: 14px; flex: none; display: grid; place-items: center;
  color: color-mix(in srgb, var(--cat, #64748b) var(--cat-keep), var(--cat-toward));
  background: color-mix(in srgb, var(--cat, #64748b) var(--cat-bg), transparent);
}
.cat.sm { width: 30px; height: 30px; border-radius: 10px; }
.cat.sm svg.i { width: 16px; height: 16px; }
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 700; font-size: 15px;
  color: color-mix(in srgb, var(--cat, #2563eb) var(--cat-keep), var(--cat-toward));
  background: color-mix(in srgb, var(--cat, #2563eb) var(--cat-bg), transparent);
}
.badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; }

/* Estados vacíos con una acción concreta */
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.empty-state { display: grid; justify-items: center; gap: 10px; text-align: center; padding: clamp(20px, 6vw, 36px) 12px; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 22px; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 4px; }
.empty-icon .i { width: 28px; height: 28px; }
.empty-state h2 { font-size: var(--fs-3); }
.empty-state p { color: var(--muted); max-width: 38ch; }
.empty-state .btn { margin-top: 8px; }
.empty-extra { display: flex; justify-content: center; padding-bottom: 8px; }
.start-error { max-width: 520px; margin: 10vh auto 0; }

/* Pasos */
.steps { display: flex; gap: 6px; list-style: none; margin: 0 0 14px; padding: 0; }
.steps li { flex: 1; display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); font-size: 13px; font-weight: 600; transition: background-color var(--t-enter) var(--ease), color var(--t-enter) var(--ease); }
.steps li > span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface); font-size: 12px; flex: none; }
.steps li > span .i { width: 14px; height: 14px; stroke-width: 2.6; }
.steps li.current { background: var(--accent-soft); color: var(--accent-text); }
.steps li.current > span { background: var(--accent); color: var(--on-accent); }
.steps li.done { color: var(--in); }
.steps li.done > span { background: var(--in-soft); color: var(--in); }

/* ---------- Avisos ---------- */
.toasts {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 80;
  display: grid; gap: 8px; width: min(460px, calc(100vw - 24px)); pointer-events: none;
}
@media (max-width: 860px) { .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); } .subview .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); } }
body:has(.chat-pill) > .toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
body:has(.dialog[open]) .toasts, .dialog .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
.dialog .toasts { position: fixed; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 8px 8px 14px;
  border-radius: 18px; background: var(--ink-surface); color: var(--on-ink); box-shadow: var(--shadow-sheet);
  font-size: 14px; font-weight: 500; line-height: 1.4;
}
.toast > .i { width: 20px; height: 20px; }
.toast.success > .i { color: var(--hero-in); }
.toast.info > .i { color: #93C5FD; }
.toast.warning { background: var(--warn-bg); color: var(--warn-text); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); }
.toast.error { background: var(--bad); color: #fff; }
.toast-text { flex: 1; min-width: 0; }
.toast-action {
  flex: none; min-height: 38px; padding: 6px 12px; border: 0; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 14px;
  background: rgb(255 255 255 / 0.14); color: inherit; transition: background-color var(--t-tap) var(--ease);
}
.toast-action:hover { background: rgb(255 255 255 / 0.24); }
.toast.warning .toast-action { background: color-mix(in srgb, var(--warn-text) 12%, transparent); }
.toast-close { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; background: none; color: inherit; opacity: 0.75; cursor: pointer; }
.toast-close:hover { opacity: 1; background: rgb(255 255 255 / 0.12); }
.toast-close .i { width: 16px; height: 16px; }

/* ---------- Hojas y diálogos ---------- */
.dialog {
  inset: auto 0 0; margin: auto auto 0; width: min(560px, 100vw); max-height: 94dvh; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 22px calc(22px + env(safe-area-inset-bottom));
  border: 1px solid var(--line); border-bottom: 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-sheet);
  /* La entrada la anima Motion con un resorte; la salida es un fundido corto en CSS */
  transition: opacity 180ms var(--ease), translate 220ms var(--ease), display 220ms allow-discrete, overlay 220ms allow-discrete;
}
.dialog:not([open]) { opacity: 0; translate: 0 28%; }
.dialog::backdrop { background: transparent; transition: background-color 220ms var(--ease), display 220ms allow-discrete, overlay 220ms allow-discrete; }
.dialog[open]::backdrop { background: var(--scrim); }
@starting-style { .dialog[open]::backdrop { background: transparent; } }
.dialog::before { content: ""; display: block; width: 40px; height: 5px; border-radius: var(--r-pill); background: var(--line-strong); margin: 0 auto 12px; }
.dialog h2 { font: 700 22px/1.2 var(--display); letter-spacing: -0.02em; }
.dialog .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }
.dialog .foot .foot-start { margin-right: auto; }
.dialog-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.sheet-head > div { min-width: 0; }
.sheet-form { display: grid; gap: 14px; }
.sheet-form .sheet-head { margin-bottom: 2px; }
.sheet-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1 1 auto; }
@media (min-width: 861px) {
  .dialog { inset: 0; margin: auto; border-radius: var(--r-card); border-bottom: 1px solid var(--line); max-height: min(88dvh, 860px); padding-bottom: 24px; }
  .dialog:not([open]) { translate: 0 16px; }
  .dialog::before { display: none; }
}
@media (max-width: 860px) {
  .dialog { width: 100%; max-width: 100%; padding: 12px 20px calc(22px + env(safe-area-inset-bottom)); }
  .dialog .foot .btn { flex: 1; }
  .dialog .foot .foot-start { flex: 0 0 auto; }
}
@media (max-width: 360px) { .dialog-fields { grid-template-columns: minmax(0, 1fr); } }

/* Confirmación destructiva: nombra el objeto y la consecuencia; nunca se cierra sola */
.confirm-sheet { width: min(440px, 100vw); }
.confirm-panel { display: grid; justify-items: center; gap: 10px; text-align: center; padding-top: 6px; }
.confirm-panel h2 { font-size: 21px; }
.confirm-panel p { color: var(--text-2); max-width: 40ch; }
.confirm-panel input { margin-top: 6px; }
.confirm-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 20px; margin-bottom: 4px; }
.confirm-icon .i { width: 26px; height: 26px; }
.confirm-icon.danger { background: var(--bad-soft); color: var(--bad); }
.confirm-icon.primary { background: var(--accent-soft); color: var(--accent-text); }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; margin-top: 12px; }
.confirm-actions:has(> :only-child) { grid-template-columns: 1fr; }
.confirm-actions .btn { white-space: normal; }

/* ---------- Inicio ---------- */
.home-grid { gap: 20px; }
.hero {
  display: grid; gap: 8px; padding: clamp(20px, 5vw, 30px); border-radius: var(--r-card); color: var(--on-ink);
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent) 55%, transparent) 0%, transparent 55%),
    linear-gradient(160deg, color-mix(in srgb, var(--ink-surface) 88%, var(--accent)) 0%, var(--ink-surface) 70%);
  box-shadow: var(--shadow-raised); overflow: hidden;
}
.hero .label { font-size: 15px; color: var(--on-ink-muted); }
.hero .value { font: 700 clamp(36px, 9vw, 52px)/1.08 var(--display); letter-spacing: -0.035em; overflow-wrap: anywhere; }
.hero .value.neg { color: var(--hero-out); }
.hero .flows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 10px; }
.hero .flows > span { display: grid; gap: 4px; padding: 12px 14px; border-radius: 18px; background: rgb(255 255 255 / 0.07); border: 1px solid rgb(255 255 255 / 0.09); font: 600 clamp(15px, 4vw, 19px)/1.2 var(--display); overflow-wrap: anywhere; }
.hero .flows small { display: flex; align-items: center; gap: 6px; font: 500 12.5px/1.3 var(--body); color: var(--on-ink-muted); }
.hero .flows small::first-letter { text-transform: uppercase; }
.hero .flows .i { width: 15px; height: 15px; }
.hero .in { color: var(--hero-in); }
.hero .out { color: var(--hero-out); }
.home-head .circle-btn { color: var(--accent-text); }

.alert-card {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; padding: 16px 18px; border-radius: 22px; border: 1px solid transparent;
}
.alert-card .grow { min-width: 180px; }
.alert-card strong { display: block; font-size: 15px; }
.alert-card p { margin-top: 2px; }
.alert-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 14px; flex: none; background: rgb(255 255 255 / 0.6); }
.alert-amount { font: 700 22px/1.2 var(--display); margin-top: 6px !important; }
.alert-actions { display: flex; gap: 6px; flex-wrap: wrap; align-self: center; }
.alert-card.warn { background: var(--warn-bg); color: var(--warn-text); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.alert-card.bad { background: var(--bad-soft); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 25%, transparent); }
.alert-card.info { background: var(--info-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.alert-card.info strong { color: var(--text); }
.alert-card .btn.ghost { color: inherit; }
:root[data-theme="dark"] .alert-icon { background: rgb(255 255 255 / 0.08); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .alert-icon { background: rgb(255 255 255 / 0.08); } }

.debt-card { display: grid; gap: 6px; padding-block: 18px 10px; }
.debt-total { display: grid; gap: 2px; padding: 0 2px 8px; }
.debt-value { font: 700 28px/1.15 var(--display); letter-spacing: -0.02em; }
.debt-row { display: grid; gap: 10px; width: 100%; padding: 12px 10px; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; border-radius: 0; transition: background-color var(--t-tap) var(--ease); }
.debt-row:hover { background: var(--surface-2); }
.debt-row-top { display: flex; align-items: center; gap: 12px; }
.debt-row-top strong { display: block; }
.debt-row-top small { display: block; }

/* Barras por categoría */
.hbars { display: grid; gap: 6px; }
.hbar {
  display: grid; grid-template-columns: minmax(110px, 36%) 1fr auto; gap: 12px; align-items: center; width: 100%;
  border: 0; background: none; padding: 8px 6px; text-align: left; cursor: pointer; border-radius: 12px; transition: background-color var(--t-tap) var(--ease);
}
.hbar:hover { background: var(--surface-2); }
.hbar .name { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; font-weight: 500; }
.hbar .name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 10px; background: var(--surface-3); border-radius: var(--r-pill); overflow: hidden; }
.hbar .fill { display: block; height: 100%; width: var(--pct); min-width: 4px; background: var(--accent); border-radius: inherit; transition: width 600ms var(--ease); }
.hbar .val { font-size: 13.5px; font-weight: 600; text-align: right; }
.hbar .val small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
@media (max-width: 420px) { .hbar { grid-template-columns: minmax(96px, 40%) 1fr auto; gap: 8px; } }

/* Gráfico (Chart.js) */
.chart { position: relative; height: 230px; }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend i.in { background: var(--in); }
.legend i.out { background: var(--out); }

/* Límites de gasto */
.meter { display: grid; gap: 8px; }
.meter + .meter { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.budget-summary { display: flex; align-items: center; gap: 8px 12px; justify-content: space-between; flex-wrap: wrap; }
.budget-name { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.budget-amount { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }

/* Filas de registros */
.balance { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.balance:first-child, h2 + .balance { border-top: 0; }
.date-badge { width: 48px; height: 48px; border-radius: 15px; flex: none; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; align-content: center; line-height: 1.05; }
.date-badge b { font: 700 17px/1 var(--display); }
.date-badge small { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.date-badge.off { background: var(--surface-2); color: var(--muted); }
.record-actions { gap: 4px; }
@media (max-width: 520px) {
  .record-row { flex-wrap: wrap; gap: 6px 12px; }
  .record-row > .grow { flex-basis: 100%; overflow-wrap: anywhere; }
  .record-actions { width: 100%; flex-wrap: nowrap; padding-left: 60px; }
  .record-actions > .num { margin-right: auto; font-weight: 600; }
  input:not([type="checkbox"]), select, textarea { font-size: 16px; }
}

/* ---------- Movimientos ---------- */
.movement-toolbar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin-bottom: 14px; }
.movement-toolbar .movement-search { border-color: transparent; border-radius: var(--r-pill); background: var(--surface-2); min-height: 48px; padding-inline: 18px; }
.movement-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.movement-types { border-radius: var(--r-pill); min-width: 0; }
.movement-types button { border-radius: var(--r-pill); padding-inline: 13px; }
.movement-filter { padding-inline: 13px; border: 0; border-radius: var(--r-pill); background: var(--surface-2); flex: none; }
.movement-filter.is-active { color: var(--accent-text); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
@media (max-width: 350px) { .movement-filter .label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; }
.active-filters .chip { min-height: 34px; padding: 5px 12px; font-size: 13px; background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.active-filters .chip .i { color: currentColor; }
.tx-summary { display: grid; gap: 2px; margin: 4px 6px 0; }
.tx-summary strong { font-size: 17px; font-weight: 700; color: var(--text); }
.tx-summary strong small { font-size: 13px; font-weight: 500; color: var(--muted); }
.tx-summary .num { font-size: 15px; font-weight: 600; }
.day { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; color: var(--muted); padding: 20px 8px 8px; }
.day .pos { color: var(--in); }
.group { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 4px 6px; box-shadow: var(--shadow-card); }
.tx {
  position: relative; z-index: 1; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 64px; padding: 10px 10px;
  border: 0; background: var(--surface); text-align: left; cursor: pointer; border-radius: 16px; color: var(--text);
  transition: background-color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease);
  touch-action: pan-y;
}
.tx + .tx::before { content: ""; position: absolute; top: 0; left: 66px; right: 10px; height: 1px; background: var(--line); }
.tx:hover { background: var(--surface-2); }
.tx:active { transform: scale(0.99); }
.tx.is-swiping { transition: none; background: var(--surface); }
.tx .grow { display: grid; gap: 2px; overflow: hidden; }
.tx .title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx .meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 13px; color: var(--muted); }
.chips-inline { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.tx-amounts { display: grid; justify-items: end; gap: 2px; flex: none; }
.tx .amount { font: 600 16px/1.2 var(--display); white-space: nowrap; }
.tx .amount.pos { color: var(--in); }
.tx .amount.out, .item-amount.out { color: var(--text); }
.tx-sub { font-size: 12px; color: var(--muted); }
.swipe-bg {
  position: absolute; left: 6px; right: 6px; z-index: 0; display: flex; align-items: center; justify-content: flex-end; gap: 6px; padding-right: 20px;
  border-radius: 16px; background: var(--bad-soft); color: var(--bad); font-size: 13px; font-weight: 700; transition: background-color var(--t-tap) var(--ease), color var(--t-tap) var(--ease);
}
.swipe-bg.armed { background: var(--bad); color: #fff; }
.account-row .meta .chip { background: var(--accent-soft); color: var(--accent-text); }
.accounts-list { display: grid; }
.accounts-list .title { display: block; }
.account-value { display: grid; justify-items: end; text-align: right; flex: none; }
.account-value small { font-size: 11.5px; }
.amount.neg { color: var(--bad); }

/* Detalle de movimiento (tiquete) */
.detail-wrap { max-width: 580px; margin: 0 auto; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.detail-head-l, .detail-head-r { display: flex; align-items: center; gap: 10px; min-width: 0; }
.detail-head h1 { font-size: var(--fs-3); }
.tx-ticket { background: var(--surface); border-radius: var(--r-card); border: 1px solid var(--line); box-shadow: var(--shadow-card); overflow: hidden; }
.tx-ticket-top { display: flex; align-items: center; gap: 14px; padding: 24px 22px; }
.tx-ticket-cat { width: 54px; height: 54px; flex: none; border-radius: 18px; background: var(--cat); color: #fff; display: grid; place-items: center; }
.tx-ticket-cat svg.i { width: 26px; height: 26px; }
.tx-ticket-titles { flex: 1; min-width: 0; }
.tx-ticket-title { font: 700 17px/1.25 var(--display); overflow-wrap: anywhere; }
.tx-ticket-kind { display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--out); }
.tx-ticket-kind.pos { color: var(--in); }
.tx-ticket-kind.transfer { color: var(--accent-text); }
.tx-ticket-amount-col { text-align: right; flex: none; }
.tx-ticket-amount { font: 700 24px/1.15 var(--display); letter-spacing: -0.02em; white-space: nowrap; }
.tx-ticket-amount.pos { color: var(--in); }
.tx-ticket-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tx-ticket-sep { position: relative; height: 1px; margin: 0 20px; border-top: 1.5px dashed var(--line); }
.tx-ticket-sep::before, .tx-ticket-sep::after { content: ""; position: absolute; top: 50%; width: 20px; height: 20px; border-radius: 50%; background: var(--page); border: 1px solid var(--line); transform: translateY(-50%); }
.tx-ticket-sep::before { left: -31px; }
.tx-ticket-sep::after { right: -31px; }
.tx-ticket-meta { display: grid; gap: 14px; padding: 20px 22px; }
.tx-ticket-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.tx-ticket-k { color: var(--muted); }
.tx-ticket-v { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; text-align: right; }
.tx-ticket-v .cat.sm { width: 26px; height: 26px; }
.tx-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cat); flex: none; }
.origin-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.origin-pill.ai { background: rgb(124 58 237 / 0.12); color: #6D28D9; }
:root[data-theme="dark"] .origin-pill.ai { background: rgb(167 139 250 / 0.18); color: #C4B5FD; }
.origin-pill svg.i { width: 13px; height: 13px; }
.tx-ticket-note { display: flex; align-items: center; gap: 10px; padding: 18px 22px; color: var(--text-2); font-size: 14px; }
.tx-ticket-note svg.i { width: 17px; height: 17px; color: var(--muted); }
.tx-ticket-tags { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px 22px 22px; }
.tag-pill { display: inline-flex; align-items: center; gap: 4px; min-height: 34px; padding: 6px 14px; border-radius: var(--r-pill); font-size: 13px; font-weight: 500; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--line); }
.tag-pill.add { background: var(--surface); cursor: pointer; font-weight: 600; color: var(--accent-text); }
.tag-pill.add:hover { background: var(--accent-soft); }

/* ---------- Asistente ---------- */
.chat-screen { display: flex; flex-direction: column; max-width: 700px; margin: 0 auto; min-height: calc(100dvh - 52px - env(safe-area-inset-bottom)); }
.chat-head { margin-bottom: 12px; }
.chat-welcome { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 16px 4px 28px; }
.chat-hero-ico { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 22px; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 18px; }
.chat-hero-ico svg.i { width: 32px; height: 32px; }
.chat-hero-title { font: 700 clamp(26px, 6vw, 32px)/1.15 var(--display); letter-spacing: -0.02em; margin-bottom: 10px; }
.chat-hero-sub { color: var(--text-2); font-size: 15.5px; line-height: 1.55; max-width: 46ch; margin-bottom: 24px; }
.chat-suggestions { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.chat-sug { text-align: left; font-size: 14.5px; font-weight: 500; line-height: 1.4; padding: 12px 18px; border-radius: 20px; background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow-1); cursor: pointer; transition: background-color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease), border-color var(--t-tap) var(--ease); }
.chat-sug:hover { border-color: var(--accent); background: var(--accent-soft); }
.chat-sug:active { transform: scale(0.985); }
.chat { flex: 1; display: flex; flex-direction: column; gap: 10px; min-height: 200px; max-height: calc(100dvh - 190px); overflow-y: auto; padding: 6px 4px 16px; }
.msg { max-width: 86%; padding: 12px 16px; border-radius: 22px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.45; animation: msg-in var(--t-enter) var(--ease) both; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 8px; }
.msg.bot { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); color: var(--text); border-bottom-left-radius: 8px; box-shadow: var(--shadow-1); }
.msg.failed { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
@keyframes msg-in { from { opacity: 0; transform: translateY(8px); } }
.typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: typing 1.1s var(--ease) infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; } .typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing { 0%, 60%, 100% { opacity: 0.3; transform: none; } 30% { opacity: 1; transform: translateY(-3px); } }
.chat-warning { display: flex; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--text-2); font-size: 13px; white-space: normal; }
.chat-warning .i { width: 16px; height: 16px; flex: none; }
.chat-proposal { margin-top: 12px; padding: 14px; border-radius: 16px; background: var(--surface-2); white-space: normal; display: grid; gap: 8px; }
.chat-proposal ul { margin: 0; padding-inline-start: 18px; }
.chat-proposal li + li { margin-top: 8px; }
.chat-proposal .row { gap: 8px; }
.chat-pill { position: sticky; bottom: calc(12px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 6px 6px 6px 18px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-raised); }
.chat-pill:focus-within { border-color: var(--accent); box-shadow: var(--shadow-raised), 0 0 0 4px var(--accent-soft); }
.chat-pill input { flex: 1; border: 0; background: transparent; padding: 6px 0; min-height: 42px; box-shadow: none; }
.chat-pill input:focus { box-shadow: none; }
.chat-send { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; cursor: pointer; transition: transform var(--t-tap) var(--ease), background-color var(--t-tap) var(--ease); }
.chat-send:hover { background: var(--accent-strong); }
.chat-send:active { transform: scale(0.94); }
.chat-send:disabled { opacity: 0.45; cursor: not-allowed; }
.chat-send svg.i { width: 19px; height: 19px; }

/* ---------- Registrar ---------- */
.dialog[data-view="register"], .dialog[data-view="capture"] { background: var(--page); }
.register-head { margin-bottom: 12px; }
.register-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.register-option {
  border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 22px; padding: 16px 14px; cursor: pointer; min-width: 0; text-align: left;
  transition: background-color var(--t-tap) var(--ease), border-color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease);
}
.register-option:hover:not(:disabled) { border-color: var(--accent); }
.register-option:active:not(:disabled) { transform: scale(0.98); }
.register-option:disabled { opacity: 0.6; cursor: not-allowed; }
.register-option strong { display: block; font: 600 17px/1.25 var(--display); }
.register-option small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; line-height: 1.35; }
.register-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 16px; flex: none; background: var(--surface-2); color: var(--text-2); }
.register-smart, .register-row { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; }
.register-smart { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, var(--line)); padding: 18px 14px; }
.register-smart .register-icon { color: var(--on-accent); background: var(--accent); }
.register-smart > .i, .register-row > .i { color: var(--muted); }
.register-manual { display: grid; justify-items: start; gap: 4px; min-height: 128px; }
.register-manual .register-icon { margin-bottom: 8px; }
.register-manual.expense .register-icon { background: var(--out-soft); color: var(--out); }
.register-manual.income .register-icon { background: var(--in-soft); color: var(--in); }
.register-subhead h2 { flex: 1; }
.capture-box { border: 1.5px solid var(--line-strong); border-radius: 22px; background: var(--surface); padding: 14px 14px 10px; transition: border-color var(--t-tap) var(--ease), box-shadow var(--t-tap) var(--ease); }
.capture-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.capture-box[hidden] { display: none; }
#capture { border: 0; background: transparent; padding: 0; min-height: 72px; font-size: 17px; line-height: 1.45; resize: none; box-shadow: none; }
#capture:focus { box-shadow: none; }
.capture-box-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 8px; }
.mic-circle { min-height: 42px; padding: 8px 14px; border-radius: var(--r-pill); background: var(--surface-2); color: var(--text-2); }
.mic-circle.rec { background: var(--bad); color: #fff; animation: pulse 1.4s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgb(180 35 24 / 0.35); } 50% { box-shadow: 0 0 0 8px rgb(180 35 24 / 0); } }
.capture-hints { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.capture-hints[hidden] { display: none; }
.capture-hint { border: 1px solid var(--line); background: var(--surface); color: var(--text-2); border-radius: var(--r-pill); padding: 6px 12px; min-height: 34px; font-size: 13px; font-weight: 500; cursor: pointer; transition: background-color var(--t-tap) var(--ease), border-color var(--t-tap) var(--ease); }
.capture-hint:hover { border-color: var(--accent); color: var(--text); }
.preview { margin-top: 18px; display: grid; gap: 10px; }
.step-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.step-title strong { flex: 1; }
.step-dot { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 12px; font-weight: 700; }
.preview-list { display: grid; gap: 8px; }
.preview-item { border: 1.5px solid var(--line); border-radius: 20px; background: var(--surface); overflow: hidden; transition: border-color var(--t-tap) var(--ease), box-shadow var(--t-tap) var(--ease); }
.preview-item[open] { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.preview-item summary { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; list-style: none; }
.preview-item summary::-webkit-details-marker { display: none; }
.preview-item summary .chev { color: var(--muted); transition: transform var(--t-enter) var(--ease); }
.preview-item[open] summary .chev { transform: rotate(180deg); }
.preview-body { padding: 4px 14px 16px; display: grid; gap: 12px; }
.preview-body .fields { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.item-title { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-amount { font: 600 16px/1.2 var(--display); }
.preview-hint { text-align: center; }
.preview-foot { display: flex; gap: 8px; margin-top: 4px; }
.done { display: grid; justify-items: center; gap: 12px; text-align: center; padding: 10px 0 4px; }
.done-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--in-soft); color: var(--in); }
.done-icon .i { width: 32px; height: 32px; stroke-width: 2.6; }
.done h3 { font: 700 20px/1.2 var(--display); color: var(--text); }
.done-balances { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 6px; text-align: left; }
.done-balances li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.done-balances strong, .done-balances small { display: block; }
.done-balances small { color: var(--muted); font-size: 12.5px; }
.done-change { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; font-weight: 600; }
.done-change s { color: var(--muted); font-weight: 500; text-decoration-thickness: 1px; }
.done-change .i { width: 15px; height: 15px; color: var(--muted); }
.done-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; width: 100%; margin-top: 6px; }
@media (max-width: 420px) { .done-actions { grid-template-columns: 1fr 1fr; } .done-actions .primary { grid-column: 1 / -1; order: -1; } }

/* Formulario de movimiento */
.dialog[data-view="transaction"] { padding: 0; overflow: hidden; background: var(--page); }
.dialog[data-view="transaction"]::before, .dialog.date-picker::before { content: none; }
.tx-form { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; max-height: min(88dvh, 860px); }
.tx-form-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--page); }
.tx-form-head .btn { background: var(--surface); box-shadow: var(--shadow-1); }
.tx-form-body { overflow-y: auto; overscroll-behavior: contain; padding: 24px 20px 20px; }
.tx-form-main, .plan-amount-field { --amount-side: clamp(46px, 13vw, 70px); display: grid; grid-template-columns: var(--amount-side) minmax(0, 1fr) var(--amount-side); align-items: center; }
.tx-form-main { margin-bottom: 14px; }
.tx-form-main input { grid-column: 2; border: 0; background: transparent; padding: 3px 2px; text-align: center; font: 600 clamp(42px, 13vw, 64px)/1.15 var(--display); letter-spacing: -0.02em; }
.tx-form-main .select-trigger { grid-column: 1; grid-row: 1; }
.tx-form-main input, .plan-amount-field input { grid-row: 1; }
[data-grouped-amount]:focus { box-shadow: none; }
.tx-form-main input::placeholder, .plan-amount-field input::placeholder { color: var(--line-strong); }
.tx-form-body > .field-error, .plan-editor .field-error { max-width: 360px; margin: -4px auto 14px; justify-content: center; }
.tx-date { display: flex; width: fit-content; max-width: 100%; margin: 0 auto; padding: 7px 14px; border-radius: var(--r-pill); white-space: normal; font-size: 13.5px; min-height: 38px; }
.tx-date .i { width: 16px; height: 16px; color: var(--muted); }
.tx-date span::first-letter { text-transform: uppercase; }
.tx-form-fields { display: grid; gap: 18px; margin-top: 26px; }
.tx-form-fields label { display: block; min-width: 0; color: var(--text-2); font-size: 13px; }
.tx-form-fields :is(input, select) { display: block; margin-top: 6px; }
.tx-extras { display: flex; align-items: start; flex-wrap: wrap; gap: 8px; }
.tx-extras details { border: 0; padding: 0; }
.tx-extras details[open] { flex-basis: 100%; }
.tx-extras summary { display: inline-flex; min-height: 40px; gap: 6px; cursor: pointer; padding: 8px 14px; font-size: 13.5px; }
.tx-extras summary::-webkit-details-marker { display: none; }
.tx-extras textarea, .tx-extras input { margin-top: 8px; }
.tx-form-footer { display: grid; gap: 10px; padding: 12px 18px 16px; background: var(--surface); border-top: 1px solid var(--line); }
.tx-footer-actions { display: flex; gap: 8px; }
.tx-footer-actions .btn.primary { flex: 1; min-height: 50px; }
.tx-save-another { min-height: 40px; font-size: 14px; }
@media (max-width: 860px) {
  .dialog[data-view="transaction"] { max-height: 100dvh; height: 100dvh; border: 0; border-radius: 0; }
  .tx-form { height: 100dvh; max-height: 100dvh; }
  .tx-form-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .tx-form-footer { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* Calendario y días del mes */
.dialog.date-picker { width: min(440px, 100vw); padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.date-picker h2 { margin: 0 0 8px; font: 600 14px/1.3 var(--body); color: var(--muted); }
.date-current, .date-month { display: grid; align-items: center; gap: 6px; }
.date-current { grid-template-columns: auto 1fr auto; text-align: center; }
.date-current strong { font: 700 clamp(20px, 5.5vw, 24px)/1.2 var(--display); }
.date-current strong::first-letter, .date-month strong::first-letter { text-transform: uppercase; }
.date-shortcuts { display: flex; justify-content: center; gap: 6px; margin: 10px 0 14px; }
.date-shortcut, .date-day { border: 0; border-radius: var(--r-pill); color: var(--text); cursor: pointer; transition: background-color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease); }
.date-shortcut { background: var(--surface-2); padding: 7px 14px; min-height: 38px; font-weight: 500; }
.date-month { grid-template-columns: 1fr auto auto; margin-bottom: 6px; }
.date-picker .btn.icon { width: 40px; min-height: 40px; }
.date-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; gap: 4px; }
.date-grid > span { color: var(--muted); align-self: center; font-size: 12px; font-weight: 600; }
.date-day { background: transparent; width: 100%; max-width: 44px; height: clamp(36px, 10vw, 44px); justify-self: center; font-variant-numeric: tabular-nums; }
.date-day:hover { background: var(--surface-2); }
.date-day:active { transform: scale(0.94); }
.date-picker button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.day-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.day-grid .date-day { max-width: none; height: 46px; border-radius: 14px; background: var(--surface-2); font-weight: 600; }
.date-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.credit-date-note { margin: 2px 0 4px; }

/* Selectores, filtros y hojas de opciones */
select[hidden], input[type="date"][hidden], [data-period][hidden], .sheet-search[hidden] { display: none; }
.select-trigger {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px; min-width: 0; padding: 8px 14px;
  border: 1.5px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); color: var(--text); text-align: left; cursor: pointer;
  transition: border-color var(--t-tap) var(--ease);
}
.select-trigger:hover:not(:disabled) { border-color: var(--accent); }
.select-trigger:disabled { opacity: 0.55; cursor: not-allowed; }
.select-trigger span:not(.cat) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-trigger > .i { color: var(--muted); width: 16px; height: 16px; }
.select-trigger > .i:last-child { margin-left: auto; }
label > .select-trigger { margin-top: 0; }
.tx-form-main .select-trigger { justify-self: start; width: max-content; gap: 3px; padding: 0; border: 0; border-radius: 10px; background: transparent; min-height: 44px; }
.tx-form-main .select-trigger span { overflow: visible; }
.tx-form-main .select-trigger b { font: 600 clamp(28px, 9vw, 46px)/1 var(--display); color: var(--muted); }
.tx-form-fields .select-trigger { margin-top: 6px; }
.sheet-search { display: flex; align-items: center; min-width: 0; gap: 8px; padding-inline: 14px; border: 1.5px solid var(--line-strong); border-radius: var(--r-control); background: var(--surface); transition: border-color var(--t-tap) var(--ease), box-shadow var(--t-tap) var(--ease); }
.sheet-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.sheet-search > .i { color: var(--muted); width: 18px; height: 18px; }
.sheet-search input { border: 0; background: transparent; padding-inline: 0; }
.sheet-search input:focus { box-shadow: none; }
.dialog.panel-dialog, .dialog[data-view="filters"] { max-height: 88dvh; padding: 12px 0 0; overflow: hidden; background: var(--page); }
.sheet-panel { display: flex; flex-direction: column; max-height: calc(88dvh - 28px); }
.panel-head { padding: 0 20px 12px; margin: 0; }
.panel-head h2 { flex: 1; font: 700 22px/1.15 var(--display); }
.panel-body { min-height: 0; overflow-y: auto; padding: 4px 20px 18px; overscroll-behavior: contain; scrollbar-width: thin; }
.panel-footer { padding: 12px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.panel-footer .form-error:not(:empty) { margin: 0 0 10px; }
.option-search { margin: 0 20px 10px; }
.option-results h3, .filter-group legend { color: var(--muted); font: 600 12px/1.35 var(--body); letter-spacing: 0.06em; text-transform: uppercase; }
.option-results h3 { margin: 16px 4px 6px; }
.option-list { display: grid; gap: 2px; }
.option-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; text-align: left; min-height: 50px; padding: 6px 12px; border: 0; border-radius: 14px; color: var(--text); background: transparent; cursor: pointer; transition: background-color var(--t-tap) var(--ease); }
.option-row span:not(.cat) { grid-column: 2; overflow-wrap: anywhere; font-weight: 500; }
.option-row > .i:last-child { color: var(--accent-text); grid-column: 3; width: 18px; height: 18px; stroke-width: 2.4; }
.option-row:hover:not(:disabled) { background: var(--surface); }
.option-row[aria-pressed="true"] { background: var(--accent-soft); }
.option-row:disabled { opacity: 0.5; cursor: not-allowed; }
.filter-body { display: grid; gap: 18px; }
.filter-group { min-width: 0; border: 0; padding: 0; margin: 0; }
.filter-group legend { margin-bottom: 10px; padding: 0; }
.filter-group .chip { white-space: normal; }
.filter-group .chip .cat { width: 22px; height: 22px; border-radius: 7px; }
.filter-group .chip .cat .i { width: 13px; height: 13px; }
.filter-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.filter-pair label, .category-form label { min-width: 0; display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
.create-category { border: 1.5px dashed color-mix(in srgb, var(--accent) 50%, transparent); }
.category-form { display: grid; gap: 14px; padding-top: 10px; }
.category-preview { justify-self: center; display: grid; justify-items: center; gap: 8px; height: auto; padding: 14px 18px; font-size: 13.5px; }
.category-preview .cat, .appearance-preview .cat { width: 58px; height: 58px; border-radius: 20px; }
.category-preview .cat .i, .appearance-preview .cat .i { width: 28px; height: 28px; }
.appearance-preview { align-self: center; margin-bottom: 10px; }
.appearance-tabs { margin: 0 20px 12px; }
.appearance-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.appearance-grid .empty { grid-column: 1 / -1; }
.appearance-choice { display: grid; place-items: center; min-height: 52px; padding: 0; border-radius: 14px; border: 1.5px solid transparent; background: var(--surface); cursor: pointer; color: var(--text); transition: background-color var(--t-tap) var(--ease), border-color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease); }
.appearance-choice:hover, .appearance-choice[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.appearance-choice:active { transform: scale(0.94); }
.appearance-choice .swatch { width: 26px; height: 26px; border-radius: 50%; background: var(--swatch); box-shadow: inset 0 0 0 2px rgb(255 255 255 / 0.4); }

/* ---------- Plan ---------- */
.plan-tabs { margin-bottom: 16px; }
.plan-tabs .count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-2); font-size: 12px; }
.plan-tabs [aria-pressed="true"] .count { background: var(--accent-soft); color: var(--accent-text); }
.plan-cards { display: grid; gap: 14px; }
@media (min-width: 960px) { .plan-cards:has(> .plan-card + .plan-card) { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.plan-card { display: grid; gap: 16px; position: relative; padding: 18px 20px; transition: transform var(--t-tap) var(--ease), box-shadow var(--t-tap) var(--ease); }
.plan-card:hover { box-shadow: var(--shadow-raised); }
.plan-card-open { display: flex; align-items: center; gap: 12px; width: 100%; border: 0; padding: 0; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.plan-card-open::before { content: ''; position: absolute; inset: 0; border-radius: inherit; }
.plan-card-open > .grow > span { display: block; }
.plan-card-open strong { display: block; font: 700 19px/1.2 var(--display); overflow-wrap: anywhere; }
.plan-badge { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 15px; background: var(--accent-soft); color: var(--accent-text); }
.plan-badge.limit { color: var(--out); background: var(--out-soft); }
.plan-badge.savings { color: var(--in); background: var(--in-soft); }
.plan-badge.repeat { color: #7C3AED; background: rgb(124 58 237 / 0.12); }
.plan-create-menu { display: grid; gap: 8px; }
.plan-create-menu button { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 74px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); text-align: left; cursor: pointer; transition: border-color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease); }
.plan-create-menu button:hover { border-color: var(--accent); }
.plan-create-menu button:active { transform: scale(0.985); }
.plan-create-menu strong { font: 600 16px/1.25 var(--display); }
.plan-create-menu small { display: block; margin-top: 2px; color: var(--muted); }
.plan-create-menu button > .i { color: var(--muted); width: 18px; height: 18px; }
.plan-progress { display: grid; gap: 8px; }
.plan-figures { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.plan-figures b { color: var(--text); font: 700 clamp(18px, 5vw, 22px)/1.2 var(--display); }
.plan-figures strong { font-weight: 700; color: var(--text-2); }
.plan-progress.over .plan-figures strong { color: var(--bad); }
.plan-detail { display: grid; gap: 16px; }
.plan-history { display: flex; align-items: center; justify-content: space-between; gap: 6px; text-align: center; background: var(--surface-2); border-radius: 16px; padding: 4px; }
.plan-history strong::first-letter { text-transform: uppercase; }
.plan-contributions { display: grid; gap: 8px; padding: 14px; border-radius: 16px; background: var(--surface-2); }
.movement-disclosure > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; list-style: none; }
.movement-disclosure > summary::-webkit-details-marker { display: none; }
.movement-disclosure > summary > .num { margin-inline-start: auto; }
.movement-disclosure > summary > .i { width: 16px; height: 16px; flex: none; color: var(--muted); }
.movement-disclosure[open] > summary > .i { transform: rotate(180deg); }
.movement-disclosure > .tx-ticket-meta { padding-block: 8px; }
[data-installment-field][hidden] { display: none; }
.plan-amount-label { display: block; text-align: center; color: var(--muted); font-size: 14px; }
.plan-amount-label small { font-size: 11px; }
.plan-amount-field { margin: 10px 0 22px; font: 600 clamp(36px, 10vw, 56px)/1.2 var(--display); }
.plan-amount-field input:not([type="checkbox"]) { grid-column: 2; border: 0; background: transparent; padding: 4px 2px; font: inherit; text-align: center; font-variant-numeric: tabular-nums; }
.plan-fields { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; }
.plan-field { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; background: transparent; border: 0; text-align: left; color: var(--text); }
.plan-field + .plan-field, .plan-fields input[type="hidden"] + .plan-field { border-top: 1px solid var(--line); }
.plan-field-text > span, .plan-field-text > strong { display: block; }
.plan-field-text .select-trigger { margin: 0; min-height: 34px; background: transparent; border: 0; padding: 0 2px 0 0; }
.plan-field-text .select-trigger > .i:first-child:not(:last-child) { display: none; }
.plan-field input:not([type="checkbox"]) { border: 0; padding: 4px 0; min-height: 34px; background: transparent; }
.plan-field input:not([type="checkbox"]):focus { box-shadow: none; }
.plan-period-trigger { cursor: pointer; }
.plan-period-trigger > .i { color: var(--muted); width: 16px; height: 16px; }
.plan-period-body { display: grid; gap: 14px; }
.plan-period-preview { display: grid; gap: 4px; padding: 14px; border-radius: 16px; background: var(--surface); }
.plan-period-preview strong::first-letter { text-transform: uppercase; }
.plan-period-footer { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
[data-custom-period][hidden] { display: none; }

/* ---------- Tarjetas de crédito ---------- */
.credit-detail { display: grid; gap: 14px; }
.credit-available { display: grid; gap: 10px; padding: 18px; border-radius: 24px; color: var(--on-ink); background: linear-gradient(150deg, color-mix(in srgb, var(--ink-surface) 82%, #7C3AED) 0%, var(--ink-surface) 75%); }
.credit-available .status-chip { background: rgb(255 255 255 / 0.12); color: var(--on-ink); }
.credit-available .status-chip.bad { background: var(--bad); color: #fff; }
.credit-available .status-chip.warn { background: var(--warn-bg); color: var(--warn-text); }
.credit-value { font: 700 clamp(30px, 8vw, 40px)/1.1 var(--display); letter-spacing: -0.02em; }
.credit-available .usage { background: rgb(255 255 255 / 0.14); }
.credit-available .usage:not(.warn):not(.bad) > span { background: #93C5FD; }
.credit-figures { color: var(--on-ink-muted); }
.credit-figures b { color: var(--on-ink); font-weight: 600; }
.credit-available .inline-alert.bad { background: rgb(249 112 102 / 0.18); color: #FECACA; }
.credit-available .inline-note.good { background: rgb(45 212 191 / 0.14); color: var(--hero-in); }
.credit-cycle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.credit-cycle span { display: grid; gap: 4px; background: var(--surface-2); border-radius: 16px; padding: 12px 14px; color: var(--muted); }
.credit-cycle strong { color: var(--text); font-size: 14px; }
.credit-statement { display: grid; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 22px; }
.credit-statement h3 { font: 700 17px/1.2 var(--display); color: var(--text); }
.credit-statement-values { display: grid; gap: 8px; margin: 2px 0; font-size: 14px; }
.credit-statement-values > div { display: flex; justify-content: space-between; gap: 8px; }
.credit-statement-values dt { color: var(--muted); }
.credit-statement-values dd { margin: 0; font-weight: 600; }
.credit-pending { padding-top: 8px; border-top: 1px dashed var(--line); }
.credit-pending dt, .credit-pending dd { color: var(--text); font-weight: 700; font-size: 15px; }
.credit-actions { gap: 8px; }
.credit-actions .btn { white-space: normal; }
.credit-preview-note, .preview-error:not(:empty) { margin-top: 2px; }
.credit-form .foot .form-error:not(:empty) { width: 100%; }
.credit-day-field { display: grid; align-content: start; gap: 6px; color: var(--text-2); font-size: 13px; font-weight: 500; }
.credit-convert { margin-top: 4px; white-space: normal; }
.credit-delete:disabled { opacity: 0.6; }

/* ---------- Más y Ajustes ---------- */
.more-search { margin-bottom: 14px; }
.more-list { display: grid; gap: 6px; }
.more-group { margin: 14px 4px 4px; color: var(--muted); font: 600 12px/1.3 var(--body); letter-spacing: 0.06em; text-transform: uppercase; }
.more-group:first-child { margin-top: 0; }
.more-item { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 68px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); text-align: left; cursor: pointer; box-shadow: var(--shadow-1); transition: border-color var(--t-tap) var(--ease), transform var(--t-tap) var(--ease); }
.more-item:hover { border-color: var(--accent); }
.more-item:active { transform: scale(0.985); }
.more-item strong { display: block; font-weight: 600; }
.more-item small { display: block; color: var(--muted); font-size: 13px; }
.more-item > .i { color: var(--muted); width: 18px; height: 18px; }
.more-empty[hidden] { display: none; }
.more-foot { margin-top: 22px; text-align: center; }
.settings-grid { gap: 18px; }
.settings-card { display: grid; gap: 14px; scroll-margin-top: 16px; }
.settings-card:focus { outline: none; }
.settings-card:focus-visible { outline: 2.5px solid var(--accent); }
.settings-card > h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 18px; }
.settings-card h3 { margin-top: 6px; }
.inline-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.inline-form .btn { min-height: 48px; }
.section-buttons { gap: 8px; }
.convert-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr) auto; gap: 8px; align-items: stretch; }
.convert-out { font: 600 16px/1.4 var(--display); }
.convert-out:empty { display: none; }
.token-row { gap: 6px; }
.data-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; }
.data-actions .btn { justify-content: flex-start; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-radius: 18px; border: 1px solid color-mix(in srgb, var(--bad) 25%, var(--line)); background: color-mix(in srgb, var(--bad-soft) 55%, transparent); }
.danger-zone strong { display: block; color: var(--bad); }
details { border-top: 1px solid var(--line); padding: 14px 0; }
details summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; }
details ol { padding-left: 20px; margin: 10px 0 0; display: grid; gap: 6px; color: var(--text-2); }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; background: var(--surface-2); border-radius: 6px; }
code { padding: 2px 6px; overflow-wrap: anywhere; }

/* ---------- Listas ---------- */
.stack > .card .accounts-list .tx { padding-inline: 4px; }

/* ---------- Inicio de sesión ---------- */
.login { max-width: 440px; margin: 9vh auto 0; display: grid; gap: 22px; }
.login .brand { padding: 0; font-size: 26px; justify-content: center; }
.login .brand img { width: 48px; height: 48px; border-radius: 14px; }
.login-card { display: grid; gap: 10px; padding: 28px; }
.login-card h1 { font-size: var(--fs-2); }
.login-card .stack { margin-top: 10px; gap: 14px; }

/* ---------- Vista widget ---------- */
.widget-page { max-width: 440px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.widget-page .card { border-radius: 24px; padding: 18px 20px; }
.widget-page .hbar { cursor: default; }
.widget-page .quick-row { display: flex; gap: 8px; }

/* ---------- Movimiento reducido: todo pasa a un fundido corto ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
  .sk { animation: none; }
  .dialog { transition: opacity 120ms linear, display 120ms allow-discrete, overlay 120ms allow-discrete !important; }
  .dialog:not([open]) { translate: none; }
}
