/* Mi Tablero · listas agrupadas al estilo iOS, tinte bordó ITM, verde menta para lo que suma. */

:root {
  color-scheme: light dark;
  --fondo: #F2F2F7;
  --superficie: #FFFFFF;
  --superficie-2: #E9E9EE;
  --texto: #1C1C1E;
  --texto-2: #66666C;
  --texto-3: #8A8A90;
  --separador: rgba(60, 60, 67, 0.17);
  --tinte: #7A2349;
  --tinte-suave: rgba(122, 35, 73, 0.1);
  --sobre-tinte: #FFFFFF;
  --positivo: #1C7443;
  --negativo: #C0322B;
  --pista: rgba(120, 120, 128, 0.16);
  --barra-material: rgba(249, 249, 249, 0.86);
  --sombra-hoja: 0 -8px 30px rgba(0, 0, 0, 0.12);
  --radio: 12px;
  --fuente: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  --fuente-titulo: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
  --arriba: env(safe-area-inset-top, 0px);
  --abajo: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #000000;
    --superficie: #1C1C1E;
    --superficie-2: #2C2C2E;
    --texto: #F2F2F7;
    --texto-2: #A4A4AB;
    --texto-3: #85858C;
    --separador: rgba(84, 84, 88, 0.6);
    --tinte: #EBA3C4;
    --tinte-suave: rgba(235, 163, 196, 0.14);
    --sobre-tinte: #3A0D21;
    --positivo: #9AD9A8;
    --negativo: #FF7A70;
    --pista: rgba(120, 120, 128, 0.32);
    --barra-material: rgba(22, 22, 24, 0.84);
    --sombra-hoja: 0 -8px 30px rgba(0, 0, 0, 0.5);
  }
}
:root[data-theme="dark"] {
  --fondo: #000000; --superficie: #1C1C1E; --superficie-2: #2C2C2E; --texto: #F2F2F7;
  --texto-2: #A4A4AB; --texto-3: #85858C; --separador: rgba(84, 84, 88, 0.6); --tinte: #EBA3C4;
  --tinte-suave: rgba(235, 163, 196, 0.14); --sobre-tinte: #3A0D21; --positivo: #9AD9A8;
  --negativo: #FF7A70; --pista: rgba(120, 120, 128, 0.32); --barra-material: rgba(22, 22, 24, 0.84);
  --sombra-hoja: 0 -8px 30px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 17px/1.35 var(--fuente);
  letter-spacing: -0.01em;
  padding: var(--arriba) 0 calc(64px + var(--abajo));
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
::selection { background: var(--tinte-suave); color: var(--texto); }
input, select, textarea, button { font: inherit; color: inherit; letter-spacing: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--tinte); outline-offset: 2px; border-radius: 6px; }
input, textarea { caret-color: var(--tinte); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* Encabezado con título grande */
.pantalla { max-width: 640px; margin: 0 auto; padding: 0 16px 24px; }
.cabecera { display: flex; align-items: center; justify-content: flex-end; gap: 4px; min-height: 44px; margin: 0 -8px; }
.cabecera .btn-icono { color: var(--tinte); }
h1 { font: 700 34px/1.12 var(--fuente-titulo); letter-spacing: -0.02em; margin: 2px 0 2px; text-wrap: balance; }
.bajada { color: var(--texto-2); font-size: 15px; margin: 0 0 6px; }
.estado-sync { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; color: var(--texto-2); font-size: 13px; }
.estado-sync svg { width: 17px; height: 17px; }
.estado-sync.alerta { color: var(--negativo); }

.btn-icono { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 22px; }
.btn-icono:active { background: var(--pista); }
.btn-texto { color: var(--tinte); min-height: 44px; padding: 0 8px; }
.btn-texto.fuerte { font-weight: 600; }
.btn-texto:disabled { color: var(--texto-3); }

/* Listas agrupadas */
.grupo { margin-top: 22px; }
.grupo > h3 { font: 400 13px/1.3 var(--fuente); text-transform: uppercase; letter-spacing: 0.02em; color: var(--texto-2); margin: 0 16px 7px; display: flex; justify-content: space-between; gap: 8px; }
.grupo > h3 .btn-texto { min-height: 0; padding: 0; text-transform: none; font-size: 13px; letter-spacing: 0; }
.lista { background: var(--superficie); border-radius: var(--radio); overflow: hidden; }
.pie { color: var(--texto-2); font-size: 13px; margin: 7px 16px 0; }
.fila {
  position: relative; display: flex; align-items: center; gap: 12px;
  min-height: 46px; padding: 10px 16px; width: 100%; text-align: left;
}
.fila + .fila::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--separador); }
.fila.con-check + .fila::before, .fila + .fila.con-check::before { left: 56px; }
button.fila:active, .fila.tocable:active { background: var(--superficie-2); }
.fila-texto { flex: 1; min-width: 0; }
.fila-titulo { overflow-wrap: anywhere; }
.fila-sub { color: var(--texto-2); font-size: 14px; margin-top: 1px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.fila-sub svg { width: 14px; height: 14px; }
.fila-valor { color: var(--texto-2); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.fila-valor.fuerte { color: var(--texto); font-weight: 600; }
.fila .chev { width: 18px; height: 18px; color: var(--texto-3); margin-right: -4px; }
.fila.accion { color: var(--tinte); justify-content: center; }
.fila.peligro { color: var(--negativo); justify-content: center; }
.vacio { padding: 18px 16px; color: var(--texto-2); text-align: center; font-size: 15px; }
.positivo { color: var(--positivo) !important; }
.negativo { color: var(--negativo) !important; }
.vencido { color: var(--negativo); }

/* Check redondo de recordatorios */
.check {
  width: 44px; height: 44px; margin: -10px -6px -10px -10px; display: grid; place-items: center; flex: none;
}
.check i {
  width: 24px; height: 24px; border-radius: 50%; border: 1.6px solid var(--texto-3);
  display: grid; place-items: center; transition: background-color 160ms cubic-bezier(.2,.8,.2,1), border-color 160ms;
}
.check svg { width: 15px; height: 15px; stroke-width: 2.6; color: transparent; }
.check.hecho i { background: var(--tinte); border-color: var(--tinte); }
.check.hecho svg { color: var(--sobre-tinte); }

/* Barras de avance */
.barra { height: 6px; border-radius: 3px; background: var(--pista); overflow: hidden; margin-top: 8px; }
.barra > b { display: block; height: 100%; border-radius: 3px; background: var(--tinte); transform-origin: left; transition: width 420ms cubic-bezier(.16,1,.3,1); }
.barra.ok > b { background: var(--positivo); }
.barra.pasada > b { background: var(--negativo); }

/* Control segmentado */
.segmentos { display: flex; background: var(--pista); border-radius: 9px; padding: 2px; margin-top: 14px; }
.segmentos button { flex: 1; min-height: 32px; border-radius: 7px; font-size: 14px; font-weight: 500; color: var(--texto); }
.segmentos button[aria-pressed="true"] { background: var(--superficie); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12); font-weight: 600; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .segmentos button[aria-pressed="true"] { background: #636366; } }
.hoja .segmentos { margin: 0 0 4px; }

/* Navegación de mes */
.mes-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.mes-nav strong { font-weight: 600; text-transform: capitalize; }
.mes-nav .btn-icono { color: var(--tinte); }
.mes-nav .btn-icono:disabled { color: var(--texto-3); }

/* Barra de pestañas */
.pestanas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(4px + var(--abajo));
  background: var(--barra-material);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separador);
}
.pestanas button { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; font-size: 11px; font-weight: 500; color: var(--texto-3); }
.pestanas button[aria-current="page"] { color: var(--tinte); }
.pestanas svg { width: 27px; height: 27px; }

/* Hoja que sube desde abajo */
#hoja-capa { position: fixed; inset: 0; z-index: 30; }
.hoja-fondo { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.32); opacity: 0; transition: opacity 260ms ease-out; }
.hoja {
  position: absolute; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto;
  max-height: calc(100dvh - var(--arriba) - 12px); display: flex; flex-direction: column;
  background: var(--fondo); border-radius: 14px 14px 0 0; box-shadow: var(--sombra-hoja);
  transform: translateY(100%); transition: transform 380ms cubic-bezier(.16,1,.3,1);
}
#hoja-capa.abierta .hoja-fondo { opacity: 1; }
#hoja-capa.abierta .hoja { transform: none; }
.hoja-barra { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 8px; border-bottom: 0.5px solid var(--separador); }
.hoja-barra h2 { font-size: 17px; font-weight: 600; margin: 0; text-align: center; }
.hoja-barra [data-hoja="cancelar"] { justify-self: start; }
.hoja-barra [data-hoja="guardar"] { justify-self: end; }
.hoja-cuerpo { overflow-y: auto; padding: 0 16px calc(28px + var(--abajo)); -webkit-overflow-scrolling: touch; }
.hoja-cuerpo .grupo:first-child { margin-top: 18px; }

/* Campos dentro de listas */
.campo { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 4px 16px; position: relative; }
.campo + .campo::before, .fila + .campo::before, .campo + .fila::before { content: ""; position: absolute; top: 0; left: 16px; right: 0; border-top: 0.5px solid var(--separador); }
.campo > span { flex: none; }
.campo input, .campo select, .campo textarea {
  flex: 1; min-width: 0; border: 0; background: none; outline: none; text-align: right; padding: 8px 0;
  font-size: 17px; color: var(--texto);
}
.campo select { appearance: none; -webkit-appearance: none; color: var(--texto-2); text-align-last: right; direction: rtl; }
.campo select option { direction: ltr; }
.campo input[type="date"], .campo input[type="time"], .campo input[type="month"] { color: var(--texto-2); -webkit-appearance: none; display: flex; justify-content: flex-end; }
.campo input::-webkit-date-and-time-value { text-align: right; }
.campo.texto-libre input, .campo.texto-libre textarea { text-align: left; }
.campo textarea { resize: none; min-height: 76px; line-height: 1.35; }
.campo input::placeholder, .campo textarea::placeholder { color: var(--texto-3); }
.campo.monto { min-height: 76px; }
.campo.monto input { font: 600 36px/1.1 var(--fuente-titulo); text-align: left; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.campo.monto .moneda { font: 600 36px/1 var(--fuente-titulo); color: var(--texto-3); }
.interruptor { appearance: none; -webkit-appearance: none; flex: none !important; width: 51px; height: 31px; border-radius: 16px; background: var(--pista); position: relative; transition: background-color 200ms; padding: 0 !important; cursor: pointer; }
.interruptor::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.16); transition: transform 220ms cubic-bezier(.2,.8,.2,1); }
.interruptor:checked { background: var(--positivo); }
.interruptor:checked::after { transform: translateX(20px); }

.paso { display: flex; align-items: center; background: var(--pista); border-radius: 9px; }
.paso button { width: 46px; height: 34px; font-size: 22px; line-height: 1; color: var(--texto); }
.paso button:active { background: var(--superficie-2); border-radius: 9px; }
.paso b { min-width: 44px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
.chips button { min-height: 36px; padding: 0 14px; border-radius: 18px; background: var(--pista); font-size: 15px; }
.chips button[aria-pressed="true"] { background: var(--tinte); color: var(--sobre-tinte); font-weight: 600; }

.hito { display: flex; align-items: center; gap: 10px; padding: 2px 16px 2px 6px; min-height: 46px; position: relative; }
.hito + .hito::before, .hito + .fila::before { content: ""; position: absolute; top: 0; left: 50px; right: 0; border-top: 0.5px solid var(--separador); }
.hito input[type="text"] { flex: 1; border: 0; background: none; outline: none; padding: 10px 0; font-size: 17px; min-width: 0; }
.hito .check { margin: 0; }
.hito .quitar { color: var(--texto-3); width: 36px; height: 44px; font-size: 22px; }

.boton-grande { display: block; width: 100%; min-height: 50px; border-radius: 12px; background: var(--tinte); color: var(--sobre-tinte); font-weight: 600; margin-top: 18px; }
.boton-grande:active { filter: brightness(0.92); }
.boton-grande:disabled { opacity: 0.45; }
.nota-hoja { color: var(--texto-2); font-size: 13px; margin: 7px 16px 0; }

/* Entrada */
.entrar { min-height: calc(100dvh - var(--arriba) - var(--abajo)); display: flex; flex-direction: column; justify-content: center; max-width: 420px; margin: 0 auto; padding: 24px 16px 80px; }
.entrar img { width: 72px; height: 72px; border-radius: 17px; margin-bottom: 18px; box-shadow: 0 4px 14px rgba(0,0,0,.14); }
.entrar p { color: var(--texto-2); margin: 6px 0 0; }
.entrar .error { color: var(--negativo); font-size: 15px; min-height: 22px; margin-top: 10px; }
body.sin-pestanas { padding-bottom: 0; }
body.sin-pestanas .pestanas { display: none; }

/* Aviso con deshacer */
#aviso {
  position: fixed; z-index: 40; left: 16px; right: 16px; bottom: calc(74px + var(--abajo)); max-width: 480px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 8px 6px 16px; border-radius: 14px; background: #2C2C2E; color: #F2F2F7; font-size: 15px;
  box-shadow: 0 8px 24px rgba(0,0,0,.22); animation: subir 320ms cubic-bezier(.16,1,.3,1);
}
#aviso .btn-texto { color: #EBA3C4; font-weight: 600; }
@keyframes subir { from { transform: translateY(16px); opacity: 0; } }

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