/* =====================================================================
   Finanzas Personal Pro · Estilos propios
   ---------------------------------------------------------------------
   Se carga DESPUÉS de tailwind.css. Prioridad (de menor a mayor):
     1. @layer base        -> estilos base del documento
     2. @layer components  -> componentes (tarjetas, navegación, íconos...).
                              Las utilidades de Tailwind pueden ajustarlos.
     3. Sin capa (final)   -> anti-zoom móvil, modales y modo oscuro:
                              siempre tienen prioridad sobre Tailwind.
   ===================================================================== */

@layer base {
    /* Compatibilidad: estos valores eran los predeterminados de Tailwind v3 (CDN) */
    *, ::after, ::before, ::backdrop, ::file-selector-button { border-color: #e5e7eb; }
    input::placeholder, textarea::placeholder { color: #9ca3af; }
    button:not(:disabled), [role="button"]:not(:disabled) { cursor: pointer; }

    html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
    body { padding-bottom: env(safe-area-inset-bottom); }
    body.app-activa { padding-bottom: calc(6.5rem + env(safe-area-inset-bottom)); }
    .font-mono { font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
    button, a, select, input, label, [onclick] { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
    :focus-visible { outline: 2px solid #14B8A6; outline-offset: 2px; }
}

@layer components {
    /* TRANSICIÓN SUAVE EN NAVEGACIÓN DE PESTAÑAS */
    .tab-pane {
        opacity: 0;
        transform: translateY(8px);
        transition: opacity 0.25s ease-out, transform 0.25s ease-out;
        will-change: opacity, transform;
    }
    .tab-pane-active { opacity: 1; transform: translateY(0); }

    /* CABECERA FIJA */
    .header-sticky {
        position: sticky;
        top: 0;
        z-index: 40;
        background-color: rgba(250, 248, 243, 0.95);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    /* TARJETAS */
    .fintech-card, .cream-card {
        background: #FFFFFF;
        border: 1px solid rgba(226, 232, 240, 0.8);
        box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.03);
        transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .fintech-card-glow:hover, .fintech-card:hover, .cream-card-hover:hover {
        transform: translateY(-2px);
        border-color: rgba(13, 148, 136, 0.35);
        box-shadow: 0 12px 25px -5px rgba(13, 148, 136, 0.12), 0 8px 10px -6px rgba(13, 148, 136, 0.04);
    }

    /* BOTÓN SALIR */
    .btn-salir {
        background-color: #FAF8F3;
        color: #44403C;
        border: 1px solid #E7E5E4;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .btn-salir:hover { background-color: #FFE4E6; color: #E11D48; border-color: #FECDD3; }
    .btn-salir:active { background-color: #E11D48; color: #FFFFFF; transform: scale(0.95); box-shadow: 0 2px 8px rgba(225, 29, 72, 0.3); }

    /* BOTONES PRIMARIOS Y NAVEGACIÓN */
    .btn-fintech-primary {
        background: linear-gradient(135deg, #0D9488 0%, #0F766E 100%);
        color: #FFFFFF;
        box-shadow: 0 4px 14px rgba(13, 148, 136, 0.25);
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .btn-fintech-primary:hover {
        background: linear-gradient(135deg, #0F766E 0%, #115E59 100%);
        transform: translateY(-1px);
        box-shadow: 0 6px 20px rgba(13, 148, 136, 0.35);
    }
    .btn-fintech-primary:active { transform: scale(0.97); }
    button:disabled { opacity: 0.6; cursor: not-allowed; }

    .nav-tab-btn { transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); position: relative; }
    .nav-tab-btn:hover { color: #0D9488; background-color: rgba(13, 148, 136, 0.06); }
    .nav-tab-btn:active { transform: scale(0.92); }

    /* TABLAS & SCROLLBAR */
    ::-webkit-scrollbar { width: 6px; height: 6px; }
    ::-webkit-scrollbar-track { background: #F1ECE1; }
    ::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 9999px; }

    input[type="date"] { max-width: 100% !important; box-sizing: border-box !important; -webkit-appearance: none; }

    /* MAPA DE CALOR */
    .heatmap-cell { transition: all 0.25s ease-in-out; border-radius: 6px; }
    .heatmap-cell:hover { transform: scale(1.08); z-index: 30; box-shadow: 0 4px 14px -2px rgba(0, 0, 0, 0.2); }
    @keyframes pulsePeak {
        0%, 100% { box-shadow: 0 0 0 0 rgba(225, 29, 72, 0.5); }
        50% { box-shadow: 0 0 0 6px rgba(225, 29, 72, 0); }
    }


    /* HERO DEL MES */
    .hero-card {
        position: relative; overflow: hidden; color: #fff;
        background: radial-gradient(120% 140% at 0% 0%, #14B8A6 0%, #0F766E 45%, #134E4A 100%);
        border: 1px solid rgba(255,255,255,.12);
        box-shadow: 0 22px 44px -22px rgba(15,118,110,.6);
    }
    .hero-card::after {
        content: ""; position: absolute; width: 280px; height: 280px; right: -90px; top: -130px; border-radius: 50%;
        background: radial-gradient(circle, rgba(255,255,255,.20), transparent 70%); pointer-events: none;
    }
    .glass-chip { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.22); color: #fff; backdrop-filter: blur(6px); }
    .glass-chip:hover { background: rgba(255,255,255,.24); }

    /* ÍCONOS DE CATEGORÍA */
    .cat-icon {
        display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
        width: 2.4rem; height: 2.4rem; border-radius: .95rem; font-size: 1.15rem; line-height: 1;
        background: hsl(var(--h, 170) 65% 93%);
    }
    .cat-icon-sm { width: 1.7rem; height: 1.7rem; border-radius: .65rem; font-size: .9rem; }
    .emoji-opt {
        font-size: 1.45rem; aspect-ratio: 1; border-radius: .9rem; display: flex; align-items: center; justify-content: center;
        border: 1px solid transparent; transition: transform .12s, background-color .12s;
    }
    .emoji-opt:hover { background: rgba(13,148,136,.10); transform: scale(1.08); }
    .emoji-opt.selected { background: rgba(13,148,136,.16); border-color: #0D9488; }

    /* NAVEGACIÓN: barra inferior en móvil, cápsula flotante en tablet/escritorio */
    .nav-bar {
        left: 0; right: 0; bottom: 0;
        padding: .45rem .75rem calc(.45rem + env(safe-area-inset-bottom));
        background: rgba(250,248,243,.86);
        backdrop-filter: blur(18px) saturate(160%); -webkit-backdrop-filter: blur(18px) saturate(160%);
        border-top: 1px solid rgba(120,113,108,.16);
    }
    @media (min-width: 768px) {
        .nav-bar {
            left: 50%; right: auto; bottom: 1rem; transform: translateX(-50%); width: 34rem;
            border-radius: 1.75rem; border: 1px solid rgba(120,113,108,.18); padding: .45rem .75rem;
            box-shadow: 0 18px 40px -18px rgba(0,0,0,.28);
        }
    }
    .fab-btn {
        width: 3.5rem; height: 3.5rem; margin-top: -1.6rem; border-radius: 1.25rem; color: #fff;
        display: flex; align-items: center; justify-content: center;
        background: linear-gradient(135deg, #14B8A6, #0F766E);
        box-shadow: 0 10px 24px -8px rgba(13,148,136,.65), 0 0 0 4px #FAF8F3;
        transition: transform .2s, box-shadow .2s;
    }
    .fab-btn:hover { transform: translateY(-2px); }
    .fab-btn:active { transform: scale(.94); }
    .fab-btn.fab-active { box-shadow: 0 10px 24px -8px rgba(13,148,136,.65), 0 0 0 4px #FAF8F3, 0 0 0 7px rgba(13,148,136,.35); }


    /* NOTIFICACIONES (TOASTS) */
    #toastZone {
        position: fixed; top: calc(.75rem + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
        z-index: 10050; display: flex; flex-direction: column; gap: .5rem; width: min(92vw, 24rem); pointer-events: none;
    }
    .toast {
        pointer-events: auto; display: flex; gap: .6rem; align-items: flex-start; cursor: pointer;
        padding: .75rem .9rem; border-radius: 1rem; font-size: .8rem; font-weight: 700;
        background: rgba(28,25,23,.94); color: #fff; box-shadow: 0 14px 30px -12px rgba(0,0,0,.45);
        animation: toastIn .25s ease-out;
    }
    .toast.salida { animation: toastOut .2s ease-in forwards; }
    @keyframes toastIn { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
    @keyframes toastOut { to { opacity: 0; transform: translateY(-8px) scale(.98); } }
}

/* Fuera de @layer: en las capas, !important le gana a los ajustes de modo oscuro */
.sticky-col { position: sticky; left: 0; z-index: 20; background-color: #F8F5EE !important; }
.heat-low { background-color: #ECFDF5 !important; color: #047857 !important; }
.heat-mid-low { background-color: #FEF3C7 !important; color: #B45309 !important; }
.heat-mid { background-color: #FFEDD5 !important; color: #C2410C !important; }
.heat-high { background-color: #FEE2E2 !important; color: #B91C1C !important; font-weight: 800 !important; }
.heat-peak { background-color: #E11D48 !important; color: #FFFFFF !important; font-weight: 900 !important; animation: pulsePeak 2s infinite ease-in-out; }

/* =====================================================================
   Reglas sin capa: siempre por encima de las utilidades de Tailwind
   ===================================================================== */
/* [FIX] Evita el zoom automático del navegador móvil al escribir:
   iOS/Android hacen zoom si el campo tiene fuente menor a 16px */
@media (max-width: 767px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not(.text-3xl):not(.text-2xl):not(.text-xl):not(.monto-input),
    select, textarea { font-size: 16px !important; }
}


/* MODALES: hoja inferior en móvil, ventana centrada en pantallas grandes */
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes popIn { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
.modal-overlay:not(.hidden) > .modal-panel { animation: popIn .2s ease-out; }
@media (max-width: 639px) {
    .modal-overlay { align-items: flex-end !important; padding: 0 !important; }
    .modal-overlay > .modal-panel {
        width: 100% !important; max-width: 100% !important; max-height: 92dvh; overflow-y: auto;
        border-radius: 1.75rem 1.75rem 0 0 !important;
        padding-bottom: calc(1.25rem + env(safe-area-inset-bottom)) !important;
    }
    .modal-overlay:not(.hidden) > .modal-panel { animation: sheetUp .28s cubic-bezier(.2,.8,.2,1); }
    .modal-overlay > .modal-panel::before {
        content: ""; display: block; width: 2.5rem; height: .3rem; border-radius: 9999px;
        background: rgba(120,113,108,.35); margin: -.25rem auto .75rem;
    }
}


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


/* =========================================================
   MODO OSCURO
   ========================================================= */
html.dark { color-scheme: dark; background: #0E1113 !important; }
html.dark body { background: #0E1113 !important; color: #E7E5E4; }
html.dark #loginSection { background: radial-gradient(120% 80% at 50% 0%, #11302C 0%, #0E1113 60%) !important; }

html.dark .cream-card, html.dark .fintech-card, html.dark .bg-white, html.dark .bg-white\/90, html.dark .bg-white\/95 {
    background-color: #161A1D !important; border-color: rgba(255,255,255,.07) !important;
    box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 12px 30px -20px rgba(0,0,0,.9) !important;
}
html.dark .bg-\[\#FAF8F3\], html.dark .bg-\[\#F8F5EE\], html.dark .sticky-col,
html.dark .bg-stone-50, html.dark .bg-stone-100, html.dark .bg-stone-200\/70 { background-color: #1D2226 !important; }
html.dark .bg-\[\#F3EFE6\], html.dark .bg-\[\#EFECE4\], html.dark .bg-stone-200 { background-color: #252B30 !important; }
html.dark .hover\:bg-stone-200:hover, html.dark .hover\:bg-stone-300:hover, html.dark .hover\:bg-stone-50:hover,
html.dark .hover\:bg-\[\#F3EFE6\]:hover, html.dark .hover\:bg-\[\#FAF8F3\]:hover, html.dark .hover\:bg-slate-100:hover {
    background-color: #2C3339 !important;
}
html.dark .hover\:bg-teal-50:hover, html.dark .hover\:bg-teal-100:hover, html.dark .hover\:bg-teal-50\/80:hover,
html.dark .hover\:bg-teal-50\/50:hover, html.dark .hover\:bg-amber-50:hover, html.dark .hover\:bg-indigo-50:hover,
html.dark .hover\:bg-indigo-100:hover, html.dark .hover\:bg-sky-50:hover, html.dark .hover\:bg-rose-50:hover,
html.dark .hover\:bg-rose-100:hover, html.dark .hover\:bg-rose-50\/50:hover { background-color: rgba(45,212,191,.12) !important; }
html.dark .focus\:bg-white:focus { background-color: #1D2226 !important; }

html.dark .header-sticky { background-color: rgba(14,17,19,.82) !important; }
html.dark .nav-bar { background: rgba(14,17,19,.86); border-color: rgba(255,255,255,.08); }
html.dark .fab-btn { box-shadow: 0 10px 24px -8px rgba(13,148,136,.6), 0 0 0 4px #0E1113; }
html.dark .fab-btn.fab-active { box-shadow: 0 10px 24px -8px rgba(13,148,136,.6), 0 0 0 4px #0E1113, 0 0 0 7px rgba(45,212,191,.35); }

html.dark .text-stone-900, html.dark .text-stone-800, html.dark .text-slate-800 { color: #F5F5F4 !important; }
html.dark .text-stone-700 { color: #D6D3D1 !important; }
html.dark .text-stone-600 { color: #B4AEA9 !important; }
html.dark .text-stone-500 { color: #9A948F !important; }
html.dark .text-stone-400 { color: #7C7671 !important; }
html.dark .text-stone-300 { color: #57534E !important; }
html.dark [class*="border-stone-"], html.dark .border-slate-300 { border-color: rgba(255,255,255,.09) !important; }
html.dark [class*="divide-stone-"] > :not([hidden]) ~ :not([hidden]) { border-color: rgba(255,255,255,.07) !important; }

html.dark .bg-teal-50, html.dark .bg-teal-50\/80, html.dark .bg-teal-50\/90, html.dark .bg-emerald-50 { background-color: rgba(20,184,166,.11) !important; }
html.dark .bg-teal-100 { background-color: rgba(20,184,166,.20) !important; }
html.dark .bg-rose-50, html.dark .bg-rose-50\/90, html.dark .bg-rose-50\/50 { background-color: rgba(244,63,94,.11) !important; }
html.dark .bg-rose-100 { background-color: rgba(244,63,94,.20) !important; }
html.dark .bg-amber-50, html.dark .bg-amber-50\/80 { background-color: rgba(245,158,11,.11) !important; }
html.dark .bg-amber-100 { background-color: rgba(245,158,11,.20) !important; }
html.dark .bg-indigo-50, html.dark .bg-indigo-50\/80 { background-color: rgba(99,102,241,.13) !important; }
html.dark .bg-indigo-100 { background-color: rgba(99,102,241,.22) !important; }
html.dark .bg-sky-50, html.dark .bg-sky-100 { background-color: rgba(14,165,233,.16) !important; }
html.dark .bg-slate-200 { background-color: rgba(148,163,184,.18) !important; }
html.dark .bg-emerald-100 { background-color: rgba(16,185,129,.20) !important; }
html.dark .bg-violet-100 { background-color: rgba(139,92,246,.22) !important; }
html.dark .bg-violet-50 { background-color: rgba(139,92,246,.10) !important; }
html.dark .hover\:bg-emerald-50:hover, html.dark .hover\:bg-violet-50:hover { background-color: rgba(45,212,191,.12) !important; }
html.dark .border-violet-200, html.dark .border-teal-200 { border-color: rgba(255,255,255,.10) !important; }
html.dark .text-violet-700, html.dark .text-violet-800 { color: #C4B5FD !important; }
html.dark .text-emerald-800 { color: #6EE7B7 !important; }

html.dark .text-teal-600, html.dark .text-teal-700, html.dark .text-teal-800, html.dark .text-teal-900 { color: #5EEAD4 !important; }
html.dark .text-emerald-600, html.dark .text-emerald-700 { color: #6EE7B7 !important; }
html.dark .text-rose-500, html.dark .text-rose-600, html.dark .text-rose-700, html.dark .text-rose-800, html.dark .text-rose-900 { color: #FDA4AF !important; }
html.dark .text-amber-600, html.dark .text-amber-700, html.dark .text-amber-800, html.dark .text-amber-900 { color: #FCD34D !important; }
html.dark .text-indigo-600, html.dark .text-indigo-700, html.dark .text-indigo-800, html.dark .text-indigo-900 { color: #A5B4FC !important; }
html.dark .text-sky-700, html.dark .text-sky-800 { color: #7DD3FC !important; }
html.dark .text-slate-700 { color: #CBD5E1 !important; }

html.dark input::placeholder { color: #6B6560 !important; }
html.dark ::-webkit-scrollbar-track { background: #14181B; }
html.dark ::-webkit-scrollbar-thumb { background: #2E363C; }
html.dark .btn-salir { background: #1D2226; color: #D6D3D1; border-color: rgba(255,255,255,.1); }
html.dark .cat-icon { background: hsl(var(--h, 170) 35% 22% / .75); }
html.dark .emoji-opt.selected { background: rgba(45,212,191,.16); border-color: #2DD4BF; }
html.dark .toast { background: rgba(245,245,244,.96); color: #1C1917; }
html.dark .modal-overlay > .modal-panel::before { background: rgba(255,255,255,.2); }
html.dark .heat-low { background-color: rgba(16,185,129,.14) !important; color: #6EE7B7 !important; }
html.dark .heat-mid-low { background-color: rgba(245,158,11,.15) !important; color: #FCD34D !important; }
html.dark .heat-mid { background-color: rgba(249,115,22,.18) !important; color: #FDBA74 !important; }
html.dark .heat-high { background-color: rgba(239,68,68,.22) !important; color: #FCA5A5 !important; }


/* =====================================================================
   REGISTRO: tarjeta de monto con color según el tipo, fichas y celebraciones
   ===================================================================== */
.registro-hero {
    position: relative; overflow: hidden; isolation: isolate;
    border-radius: 1.75rem; padding: 1.1rem 1.1rem 1.25rem;
    box-shadow: 0 18px 40px -18px rgba(225, 29, 72, .55);
    transition: box-shadow .4s ease;
}
.registro-hero::before, .registro-hero::after {
    content: ""; position: absolute; inset: 0; z-index: -2; transition: opacity .45s ease;
}
.registro-hero::before { background: radial-gradient(120% 90% at 0% 0%, #FB7185 0%, transparent 55%), linear-gradient(140deg, #F43F5E 0%, #E11D48 45%, #9F1239 100%); }
.registro-hero::after { background: radial-gradient(120% 90% at 0% 0%, #5EEAD4 0%, transparent 55%), linear-gradient(140deg, #14B8A6 0%, #0D9488 45%, #115E59 100%); opacity: 0; }
.registro[data-tipo="INGRESOS"] .registro-hero::after { opacity: 1; }
.registro[data-tipo="INGRESOS"] .registro-hero { box-shadow: 0 18px 40px -18px rgba(13, 148, 136, .6); }

.registro-burbuja { position: absolute; z-index: -1; border-radius: 9999px; background: rgba(255,255,255,.12); pointer-events: none; }
.registro-burbuja.b1 { width: 9rem; height: 9rem; right: -2.5rem; top: -3rem; animation: flotar 7s ease-in-out infinite; }
.registro-burbuja.b2 { width: 5rem; height: 5rem; left: -1.5rem; bottom: -1.75rem; background: rgba(255,255,255,.09); animation: flotar 9s ease-in-out infinite reverse; }
@keyframes flotar { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-8px, 10px); } }

.registro-glass { background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.28); backdrop-filter: blur(6px); }
.registro-glass:hover { background: rgba(255,255,255,.26); }

.tipo-switch { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 1.1rem; background: rgba(0,0,0,.16); }
.tipo-indicador {
    position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: .85rem;
    background: #fff; box-shadow: 0 6px 16px -6px rgba(0,0,0,.35);
    transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
}
.registro[data-tipo="INGRESOS"] .tipo-indicador { transform: translateX(100%); }
.tipo-btn { position: relative; z-index: 1; padding: .6rem 0; font-size: .8rem; font-weight: 900; color: rgba(255,255,255,.85); border-radius: .85rem; transition: color .25s; }
.tipo-btn[aria-pressed="true"] { color: #9F1239; }
.registro[data-tipo="INGRESOS"] .tipo-btn[aria-pressed="true"] { color: #115E59; }

.monto-caja { display: flex; align-items: baseline; justify-content: center; gap: .15rem; margin-top: .15rem; }
.monto-signo { font-size: 1.9rem; font-weight: 900; color: rgba(255,255,255,.75); }
.monto-input {
    width: 4.6ch; min-width: 3.2ch; max-width: 100%; background: transparent; border: 0; outline: none; text-align: center;
    font-size: 2.9rem; line-height: 1.1; font-weight: 900; letter-spacing: -.02em; color: #fff; caret-color: #fff;
    font-variant-numeric: tabular-nums; transition: width .15s ease;
    border-bottom: 2px dashed rgba(255,255,255,.35); padding: .1rem 0 .2rem; border-radius: 0;
}
.monto-input::placeholder { color: rgba(255,255,255,.45) !important; }
.monto-input:focus { border-bottom-color: rgba(255,255,255,.85); }
.monto-animo { margin-top: .5rem; font-size: .75rem; font-weight: 700; color: rgba(255,255,255,.9); min-height: 1.2em; }
#montoEmoji { font-size: 1rem; }
.rebote { animation: rebote .5s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes rebote { 0% { transform: scale(.4) rotate(-12deg); } 60% { transform: scale(1.35) rotate(6deg); } 100% { transform: scale(1); } }

.chip-rapido {
    min-width: 2.75rem; padding: .4rem .65rem; border-radius: 9999px; font-size: .75rem; font-weight: 900; color: #fff;
    background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); transition: transform .15s, background .15s;
}
.chip-rapido:hover { background: rgba(255,255,255,.26); }
.chip-rapido:active { transform: scale(.9); }

.registro-panel { background: #fff; border: 1px solid rgba(214,211,209,.8); border-radius: 1.75rem; padding: 1.1rem; box-shadow: 0 10px 30px -22px rgba(28,25,23,.35); }
.registro-label { display: flex; align-items: center; gap: .35rem; margin-bottom: .35rem; font-size: .68rem; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; color: #57534E; }
.registro-campo {
    width: 100%; padding: .7rem .85rem; border-radius: .95rem; background: #FAF8F3; border: 1.5px solid #E7E5E4;
    color: #292524; font-size: .8rem; transition: border-color .2s, box-shadow .2s, background .2s;
}
.registro-campo:focus { outline: none; background: #fff; border-color: #0D9488; box-shadow: 0 0 0 4px rgba(13,148,136,.14); }
.registro[data-tipo="GASTOS"] .registro-campo:focus { border-color: #E11D48; box-shadow: 0 0 0 4px rgba(225,29,72,.12); }

.chips-categoria {
    display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, auto); grid-auto-columns: max-content; gap: .45rem;
    overflow-x: auto; padding: .15rem .1rem .5rem; scroll-snap-type: x proximity; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent);
}
.chips-categoria::-webkit-scrollbar { display: none; }
.chip-cat {
    display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .75rem .3rem .3rem; border-radius: 9999px;
    background: #FAF8F3; border: 1.5px solid #E7E5E4; font-size: .75rem; font-weight: 800; color: #44403C;
    scroll-snap-align: start; transition: transform .15s, border-color .2s, background .2s, box-shadow .2s; white-space: nowrap;
}
.chip-cat:active { transform: scale(.94); }
.chip-cat.activo { background: #FFF1F2; border-color: #E11D48; color: #9F1239; box-shadow: 0 6px 14px -8px rgba(225,29,72,.6); }
.registro[data-tipo="INGRESOS"] .chip-cat.activo { background: #F0FDFA; border-color: #0D9488; color: #115E59; box-shadow: 0 6px 14px -8px rgba(13,148,136,.6); }
.chip-cat.activo .cat-icon { animation: rebote .45s cubic-bezier(.34, 1.56, .64, 1); }

.chip-fecha { padding: .3rem .7rem; border-radius: 9999px; font-size: .7rem; font-weight: 800; color: #57534E; background: #F5F5F4; border: 1px solid #E7E5E4; transition: transform .15s; }
.chip-fecha:active { transform: scale(.92); }
.chip-fecha.activo { background: #1C1917; border-color: #1C1917; color: #fff; }

.btn-guardar-registro {
    width: 100%; padding: 1rem; border-radius: 1.25rem; font-size: .85rem; font-weight: 900; letter-spacing: .02em; color: #fff;
    background: linear-gradient(135deg, #F43F5E, #BE123C); box-shadow: 0 14px 28px -14px rgba(225,29,72,.8);
    transition: transform .15s, box-shadow .2s, filter .2s;
}
.registro[data-tipo="INGRESOS"] .btn-guardar-registro { background: linear-gradient(135deg, #14B8A6, #0F766E); box-shadow: 0 14px 28px -14px rgba(13,148,136,.8); }
.btn-guardar-registro:hover { filter: brightness(1.06); }
.btn-guardar-registro:active { transform: scale(.97); }

/* Confeti y tarjeta de éxito */
.confeti-capa { position: fixed; inset: 0; pointer-events: none; z-index: 10001; overflow: hidden; }
.confeti {
    position: absolute; top: 62%; width: .55rem; height: .85rem; border-radius: 2px; opacity: 0;
    animation: confeti 1.6s cubic-bezier(.15, .7, .3, 1) forwards;
}
.confeti-emoji { width: auto; height: auto; font-size: 1.35rem; background: none !important; }
@keyframes confeti {
    0% { opacity: 1; transform: translate(0, 0) rotate(0); }
    45% { opacity: 1; transform: translate(calc(var(--dx) * .6), var(--dy)) rotate(calc(var(--giro) * .5)); }
    100% { opacity: 0; transform: translate(var(--dx), calc(var(--dy) * -.2 + 40vh)) rotate(var(--giro)); }
}
.exito-icono { width: 4.5rem; height: 4.5rem; margin: 0 auto .25rem; display: grid; place-items: center; font-size: 2.4rem; border-radius: 1.4rem; background: linear-gradient(135deg, #CCFBF1, #FEF3C7); }
.exito-pop { animation: exitoPop .45s cubic-bezier(.34, 1.56, .64, 1); }
.exito-pop .exito-icono { animation: rebote .6s .1s cubic-bezier(.34, 1.56, .64, 1) both; }
@keyframes exitoPop { from { opacity: 0; transform: scale(.8) translateY(10px); } to { opacity: 1; transform: none; } }

/* Registro en modo oscuro */
html.dark .monto-input::placeholder { color: rgba(255,255,255,.45) !important; }
.chips-categoria.pocas { display: flex; flex-wrap: wrap; -webkit-mask-image: none; mask-image: none; }
html.dark .registro-panel { background: #171B1E; border-color: rgba(255,255,255,.08); }
html.dark .registro-label { color: #A8A29E; }
html.dark .registro-campo { background: #1D2226; border-color: rgba(255,255,255,.09); color: #F5F5F4; }
html.dark .registro-campo:focus { background: #1D2226; }
html.dark .chip-cat { background: #1D2226; border-color: rgba(255,255,255,.09); color: #D6D3D1; }
html.dark .chip-cat.activo { background: rgba(244,63,94,.16); border-color: #FB7185; color: #FECDD3; }
html.dark .registro[data-tipo="INGRESOS"] .chip-cat.activo { background: rgba(20,184,166,.16); border-color: #2DD4BF; color: #CCFBF1; }
html.dark .chip-fecha { background: #1D2226; border-color: rgba(255,255,255,.09); color: #B4AEA9; }
html.dark .chip-fecha.activo { background: #F5F5F4; border-color: #F5F5F4; color: #1C1917; }
html.dark .exito-icono { background: linear-gradient(135deg, rgba(20,184,166,.25), rgba(245,158,11,.22)); }
html.dark .registro-hero { box-shadow: 0 18px 40px -22px rgba(225, 29, 72, .7); }

/* =====================================================================
   BITÁCORA: resumen del período, filtros como fichas y lista agrupada por día
   ===================================================================== */
.bitacora-hero {
    position: relative; overflow: hidden; isolation: isolate; border-radius: 1.75rem; padding: 1.1rem 1.1rem 1.2rem;
    background: radial-gradient(120% 90% at 100% 0%, rgba(45,212,191,.35) 0%, transparent 55%),
                radial-gradient(90% 80% at 0% 100%, rgba(99,102,241,.35) 0%, transparent 60%),
                linear-gradient(150deg, #1F2937 0%, #111827 55%, #0B1220 100%);
    box-shadow: 0 18px 40px -20px rgba(17,24,39,.75);
}
.bitacora[data-balance="negativo"] .bitacora-hero {
    background: radial-gradient(120% 90% at 100% 0%, rgba(251,113,133,.38) 0%, transparent 55%),
                radial-gradient(90% 80% at 0% 100%, rgba(245,158,11,.25) 0%, transparent 60%),
                linear-gradient(150deg, #2A1A22 0%, #1A1116 55%, #12090D 100%);
}
.bit-balance { font-size: 2.35rem; line-height: 1.05; font-weight: 900; letter-spacing: -.03em; color: #fff; font-variant-numeric: tabular-nums; }
.bit-barra { display: flex; height: .55rem; border-radius: 9999px; overflow: hidden; background: rgba(255,255,255,.12); gap: 2px; }
.bit-barra-ing { background: linear-gradient(90deg, #34D399, #2DD4BF); border-radius: 9999px; transition: width .7s cubic-bezier(.2,.8,.2,1); }
.bit-barra-gas { background: linear-gradient(90deg, #FB7185, #F43F5E); border-radius: 9999px; transition: width .7s cubic-bezier(.2,.8,.2,1); }
.bit-mini { display: flex; align-items: center; gap: .55rem; padding: .55rem .65rem; border-radius: 1rem; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); transition: background .15s, transform .15s; min-width: 0; }
.bit-mini:hover { background: rgba(255,255,255,.14); }
.bit-mini:active { transform: scale(.97); }
.bit-mini-icono { width: 1.9rem; height: 1.9rem; border-radius: .7rem; display: grid; place-items: center; color: #fff; font-weight: 900; flex-shrink: 0; }

.bit-top { padding: .15rem 0; border-radius: .75rem; }
.bit-top:hover .bit-top-barra span { filter: brightness(1.1); }
.bit-top-barra { display: block; height: .4rem; border-radius: 9999px; background: #F1EFEA; overflow: hidden; }
.bit-top-barra span { display: block; height: 100%; width: var(--p); border-radius: inherit; background: linear-gradient(90deg, hsl(var(--h) 75% 62%), hsl(calc(var(--h) + 30) 80% 55%)); animation: crecer .8s cubic-bezier(.2,.8,.2,1); }
@keyframes crecer { from { width: 0; } }

.bit-tipos { display: grid; grid-template-columns: repeat(3, 1fr); gap: .3rem; padding: .25rem; border-radius: 1rem; background: #F1EFEA; }
.bit-tipo { padding: .5rem 0; border-radius: .75rem; font-size: .72rem; font-weight: 900; color: #78716C; transition: all .2s; }
.bit-tipo.activo { background: #fff; color: #1C1917; box-shadow: 0 4px 12px -6px rgba(28,25,23,.35); }
.bit-tipo.activo[data-tipo="INGRESOS"] { color: #0F766E; }
.bit-tipo.activo[data-tipo="GASTOS"] { color: #BE123C; }

.chips-mes { display: flex; gap: .35rem; overflow-x: auto; scrollbar-width: none; padding: .1rem; -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
.chips-mes::-webkit-scrollbar { display: none; }
.chip-mes { flex-shrink: 0; padding: .35rem .7rem; border-radius: 9999px; font-size: .72rem; font-weight: 800; color: #57534E; background: #FAF8F3; border: 1px solid #E7E5E4; transition: transform .15s; }
.chip-mes:active { transform: scale(.92); }
.chip-mes.activo { background: #0F766E; border-color: #0F766E; color: #fff; box-shadow: 0 6px 14px -8px rgba(15,118,110,.8); }

.bit-peligro summary { list-style: none; }
.bit-peligro summary::-webkit-details-marker { display: none; }
.bit-peligro summary::after { content: "▾"; float: right; transition: transform .2s; }
.bit-peligro[open] summary::after { transform: rotate(180deg); }

.bit-lista { display: flex; flex-direction: column; gap: 1rem; }
.bit-dia-cabecera {
    position: sticky; top: var(--alto-cabecera, 5.5rem); z-index: 5; display: flex; align-items: center; justify-content: space-between;
    margin: 0 -.25rem .5rem; padding: .45rem .75rem; border-radius: 9999px;
    background: rgba(250,248,243,.88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border: 1px solid rgba(231,229,228,.9);
}
.bit-dia-nombre { font-size: .72rem; font-weight: 900; letter-spacing: .04em; text-transform: uppercase; color: #44403C; }
.bit-dia-neto { font-size: .72rem; font-weight: 900; font-variant-numeric: tabular-nums; }

.bit-item {
    position: relative; display: flex; align-items: flex-start; gap: .75rem; padding: .8rem .85rem .8rem 1rem; border-radius: 1.25rem;
    background: #fff; border: 1px solid rgba(231,229,228,.9); box-shadow: 0 6px 18px -16px rgba(28,25,23,.5); overflow: hidden;
    animation: entrarItem .45s var(--retraso, 0ms) cubic-bezier(.2,.8,.2,1) both; transition: transform .15s, box-shadow .2s;
}
.bit-item::before { content: ""; position: absolute; left: 0; top: .7rem; bottom: .7rem; width: 4px; border-radius: 0 4px 4px 0; background: #F43F5E; }
.bit-item.es-ingreso::before { background: #14B8A6; }
.bit-item:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -18px rgba(28,25,23,.55); }
.bit-item.pendiente { border-color: #FCD34D; background: linear-gradient(0deg, rgba(254,243,199,.35), rgba(254,243,199,.35)), #fff; }
@keyframes entrarItem { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.bit-monto { padding: .2rem .55rem; border-radius: 9999px; font-size: .8rem; font-weight: 900; font-variant-numeric: tabular-nums; white-space: nowrap; background: #FFF1F2; color: #BE123C; }
.bit-item.es-ingreso .bit-monto { background: #F0FDFA; color: #0F766E; }
.bit-marca { font-size: .6rem; font-weight: 800; padding: .12rem .45rem; border-radius: 9999px; letter-spacing: .01em; white-space: nowrap; }
.bit-accion { width: 1.9rem; height: 1.9rem; border-radius: .7rem; display: grid; place-items: center; font-size: .8rem; background: #F5F5F4; transition: background .15s, transform .15s; }
.bit-accion:hover { background: #CCFBF1; }
.bit-accion.peligro:hover { background: #FFE4E6; }
.bit-accion:active { transform: scale(.88); }

.bit-vacio { text-align: center; padding: 2.5rem 1rem; border-radius: 1.75rem; border: 2px dashed #E7E5E4; display: flex; flex-direction: column; align-items: center; gap: .4rem; }
.bit-vacio-emoji { font-size: 3rem; animation: flotar 4s ease-in-out infinite; }

/* Bitácora en modo oscuro */
html.dark .bitacora-hero { box-shadow: 0 18px 40px -22px rgba(0,0,0,.9); border: 1px solid rgba(255,255,255,.06); }
html.dark .bit-top-barra { background: rgba(255,255,255,.08); }
html.dark .bit-tipos { background: #1D2226; }
html.dark .bit-tipo { color: #A8A29E; }
html.dark .bit-tipo.activo { background: #2A3136; color: #F5F5F4; }
html.dark .bit-tipo.activo[data-tipo="INGRESOS"] { color: #5EEAD4; }
html.dark .bit-tipo.activo[data-tipo="GASTOS"] { color: #FDA4AF; }
html.dark .chip-mes { background: #1D2226; border-color: rgba(255,255,255,.09); color: #B4AEA9; }
html.dark .chip-mes.activo { background: #14B8A6; border-color: #14B8A6; color: #04201D; }
html.dark .bit-dia-cabecera { background: rgba(14,17,19,.85); border-color: rgba(255,255,255,.08); }
html.dark .bit-dia-nombre { color: #D6D3D1; }
html.dark .bit-item { background: #171B1E; border-color: rgba(255,255,255,.07); box-shadow: none; }
html.dark .bit-item.pendiente { border-color: rgba(252,211,77,.5); background: linear-gradient(0deg, rgba(245,158,11,.08), rgba(245,158,11,.08)), #171B1E; }
html.dark .bit-monto { background: rgba(244,63,94,.15); color: #FDA4AF; }
html.dark .bit-item.es-ingreso .bit-monto { background: rgba(20,184,166,.15); color: #5EEAD4; }
html.dark .bit-accion { background: #22282C; }
html.dark .bit-accion:hover { background: rgba(45,212,191,.18); }
html.dark .bit-accion.peligro:hover { background: rgba(244,63,94,.2); }
html.dark .bit-vacio { border-color: rgba(255,255,255,.1); }

@media (min-width: 1024px) {
    .bit-layout { display: grid; grid-template-columns: minmax(0, 22rem) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
    .bit-aside { position: sticky; top: var(--alto-cabecera, 6rem); }
}
