/* Mis cuentas: papel y tinta, con un billete de guilloché como única pieza llamativa.
   Azul = lo que entra, naranja = lo que sale (pareja comprobada para daltonismo); rojo solo para «te pasas». */
@font-face {
  font-family: 'Archivo';
  src: url('/fuentes/archivo.woff2') format('woff2');
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

:root {
  color-scheme: light dark;
  --papel: #EEF2F7;
  --sup: #FFFFFF;
  --billete: #E3ECF8;
  --billete-borde: #CBDAEE;
  --tinta: #101A2B;
  --t2: #5A6577;
  --linea: #DDE3EC;
  --chip: #EEF2F7;
  --entra: #257de0;
  --sale: #f47230;
  --critico: #dc3c3d;
  --texto-entra: #1b64be;
  --texto-critico: #c42f30;
  --grid: #D5DCE6;
  --base: #A9B4C4;
  --sobre: #FFFFFF;
  --velo: rgba(16, 26, 43, .36);
  --guil: rgba(37, 125, 224, .34);
  --anillo-mas: var(--papel);
}
@media (prefers-color-scheme: dark) {
  :root {
    --papel: #0B111A;
    --sup: #131B27;
    --billete: #122036;
    --billete-borde: #1E3150;
    --tinta: #E9EEF5;
    --t2: #98A3B5;
    --linea: #232E3D;
    --chip: #1B2534;
    --entra: #338ced;
    --sale: #e76624;
    --texto-entra: #6aabf1;
    --texto-critico: #f07071;
    --grid: #253244;
    --base: #3E4C60;
    --sobre: #101A2B;
    --velo: rgba(0, 0, 0, .55);
    --guil: rgba(106, 171, 241, .30);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--papel);
  color: var(--tinta);
  font: 420 16px/1.45 'Archivo', system-ui, -apple-system, sans-serif;
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
:focus-visible { outline: 2px solid var(--tinta); outline-offset: 2px; }
.oculto { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ico-pq { width: 18px; height: 18px; }
.ico-gr { width: 28px; height: 28px; stroke-width: 2; }

/* ---------- estructura ---------- */
.pantalla {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 6px) 20px calc(env(safe-area-inset-bottom) + 120px);
  transition: opacity .2s;
}
.pantalla.cargando { opacity: .5; }
.cabecera { display: flex; align-items: center; justify-content: space-between; min-height: 48px; }
.marca { font-weight: 720; font-stretch: 125%; font-size: 16px; letter-spacing: -.01em; }
.boton-ico {
  width: 44px; height: 44px; margin-right: -10px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--tinta);
}

.mes { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.mes h1 { margin: 0; min-width: 0; font-size: clamp(22px, 7vw, 30px); line-height: 1.1; font-weight: 660; font-stretch: 112%; letter-spacing: -.022em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mes h1 span { color: var(--t2); font-weight: 430; }
.flechas { display: flex; gap: 6px; }
.flechas button {
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--linea); border-radius: 50%; background: var(--sup); color: var(--tinta);
}
.flechas button:disabled { opacity: .35; cursor: default; }

/* ---------- el billete ---------- */
.billete {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 20px 20px 18px;
  border-radius: 28px;
  background: var(--billete);
  border: 1px solid var(--billete-borde);
  touch-action: pan-y;
}
.billete .guilloche {
  position: absolute; z-index: -1; width: 360px; height: 360px; right: -138px; top: -104px; pointer-events: none;
  /* Se desvanece hacia la izquierda para que el texto se lea limpio. */
  -webkit-mask-image: linear-gradient(100deg, transparent 10%, #000 48%);
  mask-image: linear-gradient(100deg, transparent 10%, #000 48%);
}
.guilloche path { fill: none; stroke: var(--guil); stroke-width: .75; }
.guilloche.dibujar path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: trazar 1.5s cubic-bezier(.35, .6, .2, 1) forwards; }
@keyframes trazar { to { stroke-dashoffset: 0; } }

.etiqueta-cifra { margin: 0; font-size: 15px; font-weight: 560; color: var(--t2); }
.cifra {
  margin: 2px 0 14px;
  font-weight: 720; font-stretch: 125%;
  font-size: 60px; line-height: 1.04; letter-spacing: -.032em;
  white-space: nowrap; overflow: hidden;
}
.cifra .signo { font-weight: 520; margin-right: .02em; }
.cifra .dec { font-size: .4em; font-weight: 620; letter-spacing: -.01em; vertical-align: 1em; margin-left: .05em; }
.bajo-cifra { margin: 0; font-size: 15px; color: var(--t2); }
.bajo-cifra b { color: var(--tinta); font-weight: 640; }
.vacio-texto { margin: 10px 0 2px; max-width: 30ch; font-size: 17px; line-height: 1.4; }

.barra-mes { display: flex; gap: 2px; height: 28px; margin: 10px 0 12px; }
.bloque {
  flex: 1 1 0; min-width: 4px;
  display: flex; align-items: center; padding: 0 8px;
  border-radius: 4px;
  color: #FFFFFF; font-size: 13px; font-weight: 660; white-space: nowrap; overflow: hidden;
  transform-origin: left center;
}
.bloque.sale { background: var(--sale); }
.bloque.entra { background: var(--entra); }
.bloque.critico { background: var(--critico); }
.barra-mes.crecer .bloque { animation: crecer .8s .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes crecer { from { transform: scaleX(0); } }

.leyenda { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 0; padding: 0; list-style: none; font-size: 15px; }
.leyenda li { display: flex; align-items: center; gap: 8px; }
.leyenda b { font-weight: 640; }
.muestra { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.muestra.sale { background: var(--sale); }
.muestra.entra { background: var(--entra); }
.muestra.critico { background: var(--critico); }
.alerta { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; color: var(--texto-critico); font-weight: 600; font-size: 15px; }
.comparacion { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--billete-borde); font-size: 15px; color: var(--t2); }
.comparacion b { color: var(--tinta); font-weight: 640; }

/* ---------- secciones ---------- */
.seccion { margin-top: 36px; }
.seccion-cab { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.seccion h2 { margin: 0; font-size: 20px; line-height: 1.2; font-weight: 660; font-stretch: 112%; letter-spacing: -.014em; }
.enlace {
  border: 0; background: none; padding: 6px 0; flex: none;
  color: var(--t2); font-size: 14px; font-weight: 600;
  text-decoration: underline; text-decoration-color: var(--base); text-underline-offset: 3px;
}

/* En qué se va: barras ordenadas, un solo color */
.cats { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.cat {
  width: 100%; border: 0; background: none; text-align: left;
  display: grid; grid-template-columns: 44px 1fr auto; column-gap: 12px; row-gap: 7px; align-items: center;
  padding: 8px 0;
}
.cat .chip-ico { grid-row: 1 / span 2; background: var(--sup); }
.cat-nombre { font-weight: 560; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-importe { font-weight: 640; font-variant-numeric: tabular-nums; text-align: right; }
.cat-barra { display: block; height: 8px; }
.cat-barra span { display: block; height: 8px; min-width: 3px; background: var(--sale); border-radius: 0 4px 4px 0; }
.cat-pct { font-size: 13px; line-height: 1; color: var(--t2); text-align: right; font-variant-numeric: tabular-nums; }
.chip-ico { flex: none; width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: var(--tinta); background: var(--chip); }

/* Gráficas */
.lectura { min-height: 22px; margin: 0 0 6px; font-size: 15px; color: var(--t2); }
.lectura b { color: var(--tinta); font-weight: 650; }
.lienzo svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; border-radius: 6px; }
.lienzo svg:focus-visible { outline-offset: 4px; }
.grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.base { stroke: var(--base); stroke-width: 1; shape-rendering: crispEdges; }
.tick { fill: var(--t2); font-size: 12px; font-variant-numeric: tabular-nums; }
.tick.fuerte { fill: var(--tinta); font-weight: 680; }
.valor { fill: var(--tinta); font-size: 12px; font-weight: 680; font-variant-numeric: tabular-nums; }
.m-sale { fill: var(--sale); }
.m-entra { fill: var(--entra); }
.marca-hoy { fill: var(--tinta); }
.atenuada { opacity: .3; }
.leyenda-graf { margin-bottom: 8px; }
.tabla { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.tabla th, .tabla td { padding: 9px 0; border-bottom: 1px solid var(--linea); text-align: right; font-weight: 430; }
.tabla thead th { color: var(--t2); font-weight: 560; font-size: 14px; }
.tabla th:first-child { text-align: left; }
.tabla tbody th { font-weight: 560; }

/* Listas de movimientos */
.lista { list-style: none; margin: 0; padding: 4px 0; background: var(--sup); border-radius: 20px; }
.fila {
  position: relative; width: 100%; min-height: 64px;
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border: 0; background: none; text-align: left;
}
.lista li + li .fila::before { content: ''; position: absolute; top: 0; left: 72px; right: 0; border-top: 1px solid var(--linea); }
.fila-texto { flex: 1; min-width: 0; display: grid; }
.fila-titulo { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-sub { font-size: 14px; color: var(--t2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fila-importe { font-weight: 640; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fila-importe.entra { color: var(--texto-entra); }
.dia-cab { display: flex; justify-content: space-between; gap: 12px; margin: 24px 4px 8px; font-size: 14px; font-weight: 580; color: var(--t2); font-variant-numeric: tabular-nums; }
.dia-cab:first-child { margin-top: 8px; }
.vacio { margin: 24px 4px; color: var(--t2); }
.vacio b { color: var(--tinta); }

.buscador { position: relative; margin: 2px 0 12px; }
.buscador .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--t2); pointer-events: none; }
.buscador input {
  width: 100%; height: 48px; padding: 0 14px 0 46px;
  border: 1px solid var(--linea); border-radius: 14px; background: var(--sup); font-size: 16px;
  -webkit-appearance: none; appearance: none;
}
.filtros { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 4px; }

/* Controles */
.segmentado { display: inline-grid; grid-auto-flow: column; padding: 3px; border-radius: 13px; background: var(--chip); }
.segmentado button { border: 0; background: none; border-radius: 10px; padding: 8px 16px; font-weight: 600; color: var(--t2); }
.segmentado button[aria-pressed="true"] { background: var(--sup); color: var(--tinta); box-shadow: 0 1px 3px rgba(16, 26, 43, .14); }
.pastillas { display: flex; flex-wrap: wrap; gap: 8px; }
.pastilla {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--linea); border-radius: 999px; background: none; font-weight: 560; font-size: 15px;
}
.pastilla[aria-pressed="true"], .pastilla.activa { background: var(--tinta); color: var(--sobre); border-color: var(--tinta); }
.otro-dia { position: relative; overflow: hidden; }
.otro-dia input[type="date"] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0;
  border: 0; opacity: 0; cursor: pointer; font-size: 16px; -webkit-appearance: none; appearance: none;
}
.otro-dia:focus-within { outline: 2px solid var(--tinta); outline-offset: 2px; }
.boton {
  width: 100%; min-height: 54px; margin-top: 22px;
  border: 0; border-radius: 16px; background: var(--tinta); color: var(--sobre);
  font-weight: 660; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.boton:disabled { opacity: .5; }
.boton.secundario { background: var(--chip); color: var(--tinta); margin-top: 0; min-height: 48px; font-size: 16px; }
.boton.peligro { background: none; color: var(--texto-critico); border: 1px solid var(--linea); margin-top: 0; min-height: 48px; font-size: 16px; }
.texto {
  width: 100%; border: 1px solid var(--linea); border-radius: 12px; background: transparent;
  padding: 12px 14px; font-size: 16px; -webkit-appearance: none; appearance: none;
}
.error { margin: 10px 0 0; color: var(--texto-critico); font-weight: 560; font-size: 15px; }
.error:empty { display: none; }

/* ---------- barra de abajo ---------- */
.barra-tabs {
  position: fixed; z-index: 20; left: 0; right: 0; bottom: 0;
  padding: 6px 28px calc(env(safe-area-inset-bottom) + 4px);
  background: color-mix(in srgb, var(--papel) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(18px); backdrop-filter: saturate(1.4) blur(18px);
  border-top: 1px solid var(--linea);
}
.barra-tabs .dentro { max-width: 420px; margin: 0 auto; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; }
.tab { border: 0; background: none; display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 12px; font-weight: 560; color: var(--t2); }
.tab[aria-current="page"] { color: var(--tinta); font-weight: 680; }
.boton-mas {
  width: 60px; height: 60px; margin-top: -28px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--tinta); color: var(--sobre);
  box-shadow: 0 0 0 6px var(--anillo-mas), 0 10px 24px rgba(16, 26, 43, .25);
}

/* ---------- hoja para apuntar ---------- */
.velo { position: fixed; z-index: 40; inset: 0; background: var(--velo); opacity: 0; transition: opacity .25s; }
.velo.abierta { opacity: 1; }
.hoja {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-width: 560px; max-height: 94dvh; margin: 0 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 10px 20px calc(env(safe-area-inset-bottom) + 20px);
  border-radius: 28px 28px 0 0; background: var(--sup);
  box-shadow: 0 -10px 40px rgba(16, 26, 43, .18);
  transform: translateY(100%); transition: transform .32s cubic-bezier(.2, .8, .2, 1);
}
.hoja.abierta { transform: none; }
.asa { width: 38px; height: 5px; margin: 0 auto 10px; border-radius: 3px; background: var(--linea); }
.hoja-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hoja-cab h2 { margin: 0; font-size: 17px; font-weight: 660; }
.campo-importe { display: flex; align-items: baseline; gap: 8px; margin: 16px 0 4px; padding-bottom: 8px; border-bottom: 2px solid var(--linea); }
.campo-importe:focus-within { border-bottom-color: var(--tinta); }
.campo-importe input {
  width: 100%; min-width: 0; border: 0; background: none; padding: 0; outline: none;
  font-weight: 720; font-stretch: 125%; font-size: 46px; line-height: 1.1; letter-spacing: -.03em;
  caret-color: var(--entra);
}
.campo-importe input::placeholder { color: var(--base); }
.campo-importe span { font-weight: 640; font-stretch: 125%; font-size: 26px; color: var(--t2); }
.etiqueta { display: block; margin: 20px 0 8px; font-size: 14px; font-weight: 620; color: var(--t2); }
.rejilla-cats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 4px; }
.opcion-cat {
  border: 0; background: none; padding: 4px 0;
  display: grid; justify-items: center; align-content: start; gap: 6px;
  font-size: 12px; line-height: 1.2; color: var(--t2); text-align: center;
}
.opcion-cat .chip-ico { width: 50px; height: 50px; border-radius: 15px; }
.opcion-cat[aria-pressed="true"] { color: var(--tinta); font-weight: 680; }
.opcion-cat[aria-pressed="true"] .chip-ico { background: var(--tinta); color: var(--sobre); }
.comercio { margin: 10px 0 0; font-size: 15px; color: var(--t2); }
.recordar { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 15px; }
.recordar input { width: 22px; height: 22px; accent-color: var(--tinta); }
.borrar { width: 100%; margin-top: 8px; padding: 14px; border: 0; background: none; color: var(--texto-critico); font-weight: 620; }

/* ---------- avisos ---------- */
.aviso {
  position: fixed; z-index: 60; left: 20px; right: 20px; bottom: calc(env(safe-area-inset-bottom) + 98px);
  width: fit-content; max-width: 520px; margin-inline: auto;
  display: flex; align-items: center; gap: 16px; padding: 12px 16px;
  border-radius: 14px; background: var(--tinta); color: var(--sobre); font-weight: 560; font-size: 15px;
  opacity: 0; pointer-events: none; transform: translateY(14px); transition: opacity .2s, transform .2s;
}
.aviso.visible { opacity: 1; pointer-events: auto; transform: none; }
.aviso button { border: 0; background: none; padding: 4px 0; color: inherit; font-weight: 720; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- entrar ---------- */
.entrada { min-height: 100dvh; display: grid; justify-items: center; align-items: start; padding: calc(env(safe-area-inset-top) + 28px) 20px 40px; }
.entrada-caja { position: relative; isolation: isolate; width: min(400px, 100%); }
/* La roseta, entera y centrada; el nombre se monta sobre su borde de abajo, como en un billete. */
.guilloche-entrada { display: block; position: relative; z-index: -1; width: min(280px, 72vw); height: auto; aspect-ratio: 1; margin: 0 auto -58px; }
.entrada-marca { margin: 0 0 10px; font-size: clamp(28px, 9.4vw, 42px); line-height: 1.02; font-weight: 740; font-stretch: 125%; letter-spacing: -.035em; }
.entrada-texto { margin: 0 0 22px; color: var(--t2); font-size: 17px; }
.entrada-form { display: grid; gap: 8px; }
.entrada-form label { margin-top: 10px; font-weight: 620; font-size: 15px; }
.entrada-form label:first-of-type { margin-top: 0; }
.entrada-form .boton { margin-top: 14px; }
.entrada-form .error { margin: 4px 0 0; }
.ayuda { margin: 0; font-size: 14px; color: var(--t2); }
.texto.codigo { text-transform: uppercase; letter-spacing: .14em; font-weight: 640; }
.texto.codigo::placeholder { letter-spacing: .14em; color: var(--base); }

/* ---------- ajustes ---------- */
.volver { display: inline-flex; align-items: center; gap: 2px; margin-left: -8px; padding: 10px 8px; border: 0; background: none; font-weight: 600; color: var(--tinta); }
.ajustes h1 { margin: 6px 0 6px; font-size: 30px; font-weight: 660; font-stretch: 112%; letter-spacing: -.022em; }
.ajustes .intro { margin: 0 0 8px; color: var(--t2); }
.ajustes h2 { margin: 34px 0 12px; font-size: 20px; font-weight: 660; font-stretch: 112%; letter-spacing: -.014em; }
.caja { padding: 18px; margin-top: 12px; border-radius: 20px; background: var(--sup); }
.caja-cab { display: flex; gap: 12px; align-items: flex-start; }
.caja h3 { margin: 0 0 2px; font-size: 17px; font-weight: 660; }
.caja p { margin: 0; color: var(--t2); font-size: 15px; }
.caja .boton { margin-top: 14px; }
.caja details { margin-top: 12px; border-top: 1px solid var(--linea); padding-top: 4px; }
.caja summary { padding: 10px 0; font-weight: 620; cursor: pointer; }
.pasos { margin: 4px 0 6px; padding-left: 22px; display: grid; gap: 10px; font-size: 15px; line-height: 1.45; }
.pasos li::marker { font-weight: 680; color: var(--t2); }
.pasos b { font-weight: 660; }
.consejo { margin-top: 10px !important; font-size: 14px !important; }
.acciones { display: grid; gap: 10px; }
.acciones .boton.secundario { background: var(--sup); }
.desplegable { margin-top: 0; padding: 0 18px; }
.desplegable[open] { padding-bottom: 18px; }
.desplegable summary { padding: 14px 0; font-weight: 640; font-size: 16px; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .guilloche.dibujar path { stroke-dashoffset: 0; }
}
