/* --- 1. RESET & BASICS --- */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --accent: #ec4899;
    --bg-color: #f8fafc;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --recording-color: #ef4444;
    --success-color: #10b981;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 20%),
        radial-gradient(circle at 90% 80%, rgba(236, 72, 153, 0.08) 0%, transparent 20%);
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ===============================================
   WELCOME SCREEN - OVERDESIGNED ✨
   =============================================== */

.welcome-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    
    /* Gradiente Animado Ultra Vibrante */
    background: linear-gradient(
        135deg,
        #667eea 0%,
        #764ba2 25%,
        #f093fb 50%,
        #4facfe 75%,
        #00f2fe 100%
    );
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
    
    opacity: 0;
    transition: opacity 0.6s ease;
}

.welcome-screen.active {
    display: flex;
    opacity: 1;
}

.welcome-screen.fade-out {
    opacity: 0;
    transform: scale(1.1);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Partículas Flotantes */
.particles-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.particle {
    position: absolute;
    background: white;
    border-radius: 50%;
    opacity: 0;
    animation: floatUp 6s ease-in-out infinite;
}

@keyframes floatUp {
    0% {
        opacity: 0;
        transform: translateY(100vh) scale(0);
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-100px) scale(1.5);
    }
}

/* Contenido Principal */
.welcome-content {
    position: relative;
    z-index: 2;
    text-align: center;
    animation: zoomIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes zoomIn {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(50px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Icono con Glow Pulsante */
.welcome-icon-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0 auto 40px auto;
}

.icon-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 140px;
    height: 140px;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.6;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.3;
    }
}

.welcome-icon {
    position: relative;
    font-size: 80px;
    line-height: 120px;
    text-shadow: 
        0 0 20px rgba(255, 255, 255, 0.8),
        0 0 40px rgba(255, 255, 255, 0.6),
        0 0 60px rgba(255, 255, 255, 0.4);
    animation: rotateIcon 3s ease-in-out infinite;
}

@keyframes rotateIcon {
    0%, 100% { transform: rotate(0deg) scale(1); }
    25% { transform: rotate(-10deg) scale(1.1); }
    75% { transform: rotate(10deg) scale(1.1); }
}

/* Texto con Escritura Letra por Letra */
.welcome-text-wrapper {
    margin-bottom: 20px;
}

.welcome-greeting {
    font-family: 'Outfit', sans-serif;
    font-size: 32px;
    font-weight: 400;
    color: white;
    margin: 0;
    text-shadow: 
        0 2px 10px rgba(0,0,0,0.2),
        0 0 30px rgba(255,255,255,0.3);
    opacity: 0;
    animation: fadeInText 0.6s ease forwards;
    animation-delay: 0.5s;
}

.welcome-name {
    font-family: 'Outfit', sans-serif;
    font-size: 64px;
    font-weight: 900;
    color: white;
    margin: 10px 0 0 0;
    letter-spacing: -2px;
    text-shadow: 
        0 4px 20px rgba(0,0,0,0.3),
        0 0 40px rgba(255,255,255,0.5),
        0 0 80px rgba(255,255,255,0.3);
    opacity: 0;
    display: inline-block;
}

.welcome-name.typing {
    opacity: 1;
}

@keyframes fadeInText {
    to { opacity: 1; }
}

/* Cursor Parpadeante */
.welcome-name::after {
    content: '|';
    animation: blink 1s step-end infinite;
    margin-left: 5px;
}

.welcome-name.typing-complete::after {
    display: none;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Subtítulo */
.welcome-subtitle {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    margin: 20px 0 40px 0;
    font-weight: 500;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    opacity: 0;
}

.welcome-subtitle.visible {
    animation: fadeInText 0.8s ease forwards;
}

/* Barra de Carga con Glow */
.loading-bar-container {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    margin: 0 auto;
    overflow: hidden;
    box-shadow: 
        0 0 10px rgba(255,255,255,0.3),
        inset 0 1px 2px rgba(0,0,0,0.2);
    opacity: 0;
}

.loading-bar-container.visible {
    animation: fadeInText 0.6s ease forwards;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, 
        rgba(255,255,255,0.8) 0%, 
        rgba(255,255,255,1) 50%, 
        rgba(255,255,255,0.8) 100%);
    border-radius: 10px;
    box-shadow: 
        0 0 20px rgba(255,255,255,0.8),
        0 0 40px rgba(255,255,255,0.5);
    animation: loadProgress 4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes loadProgress {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* Responsive */
@media (max-width: 640px) {
    .welcome-icon-container {
        width: 100px;
        height: 100px;
    }
    
    .icon-glow {
        width: 120px;
        height: 120px;
    }
    
    .welcome-icon {
        font-size: 64px;
        line-height: 100px;
    }
    
    .welcome-greeting {
        font-size: 24px;
    }
    
    .welcome-name {
        font-size: 48px;
    }
    
    .welcome-subtitle {
        font-size: 16px;
        padding: 0 20px;
    }
}

/* ===============================================
   FIN WELCOME SCREEN
   =============================================== */

/* --- 2. HEADER --- */
#header {
    height: 65px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo-img {
    height: 32px;
    width: auto;
    display: block;
}

.brand-text {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: #1e293b;
    letter-spacing: -0.5px;
}

/* Navegación Tabs */
.nav-tabs {
    display: flex;
    gap: 8px;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
}

.nav-btn {
    border: none;
    background: transparent;
    color: #94a3b8;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-btn.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* --- 3. MAIN VIEWPORT & TRANSICIONES DE CAPAS --- */
#main-viewport {
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-areas: "stack";
    perspective: 1000px;
}

.view-container {
    grid-area: stack;
    height: 100%;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;

    /* Estado Inactivo */
    opacity: 0;
    pointer-events: none;
    transform: scale(0.92) translateY(30px);
    filter: blur(12px);

    transition:
        opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
        filter 0.4s ease;

    background: transparent;
}

.view-container.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1) translateY(0);
    filter: blur(0);
    z-index: 10;
    transition-delay: 0.1s;
}

/* --- ANIMACIONES SWIPE (Mensual <-> Semanal) --- */
.slide-exit-left {
    animation: slideOutLeft 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.slide-enter-right {
    animation: slideInRight 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.slide-exit-right {
    animation: slideOutRight 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.slide-enter-left {
    animation: slideInLeft 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes slideOutLeft {
    to {
        opacity: 0;
        transform: translateX(-40px) scale(0.95);
        filter: blur(4px);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px) scale(0.95);
        filter: blur(4px);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
        filter: blur(0);
    }
}

@keyframes slideOutRight {
    to {
        opacity: 0;
        transform: translateX(40px) scale(0.95);
        filter: blur(4px);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px) scale(0.95);
        filter: blur(4px);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
        filter: blur(0);
    }
}

/* Chat Container */
#chat-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px 15px;
    padding-bottom: 100px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
}

/* Mensajes */
.message {
    max-width: 88%;
    padding: 12px 16px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
    white-space: pre-wrap;
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    transition: all 0.5s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.message.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.bot {
    background: #ffffff;
    color: #334155;
    border-radius: 18px 18px 18px 4px;
    border: 1px solid rgba(226, 232, 240, 0.8);
}

.user {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    align-self: flex-end;
    border-radius: 18px 18px 4px 18px;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.message b {
    font-weight: 700;
    color: var(--primary-dark);
}

.bot b {
    color: var(--primary-dark);
}

.message.bot.processing {
    padding: 0 !important;
    min-width: 60px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.typing-dots {
    display: flex;
    gap: 6px;
}

.typing-dots .dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: bounceDots 1.4s infinite ease-in-out both;
}

.typing-dots .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots .dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounceDots {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

.message.bot.success-state {
    background: #ecfdf5;
    border-color: #34d399;
    color: var(--success-color);
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(1.05);
    padding: 0 !important;
}

.checkmark-svg {
    width: 32px;
    height: 32px;
    display: block;
}

.checkmark-path-new {
    fill: none;
    stroke: var(--success-color);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: drawCheckNew 1.2s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

@keyframes drawCheckNew {
    0% {
        stroke-dashoffset: 100;
    }

    100% {
        stroke-dashoffset: 0;
    }
}

.message.bot.final-text {
    background: #ffffff;
    border-color: rgba(226, 232, 240, 0.8);
    color: #334155;
    transform: scale(1);
    height: auto;
    padding: 12px 16px !important;
}

/* --- 4. INPUT AREA (CORREGIDO MÓVIL) --- */
#input-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.6);
    padding: 10px 8px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
    box-sizing: border-box;
}

#file-preview {
    display: none;
    background: #eff6ff;
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    border: 1px dashed #bfdbfe;
    align-self: flex-start;
    margin-left: 4px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.input-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    flex-wrap: nowrap;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.secondary-btn {
    background: #f1f5f9;
    color: #64748b;
    border-radius: 14px;
}

.secondary-btn.active {
    color: var(--primary);
    background: #e0e7ff;
}

#send-btn {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

#mic-btn {
    background: #f1f5f9;
    color: #64748b;
}

#mic-btn.recording {
    background: var(--recording-color);
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

#recording-ui {
    display: none;
    flex-grow: 1;
    align-items: center;
    gap: 10px;
    padding-left: 10px;
    color: var(--recording-color);
    font-weight: 600;
    white-space: nowrap;
}

#message-input {
    flex: 1;
    min-width: 0;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 22px;
    padding: 10px 14px;
    font-size: 16px;
    outline: none;
    transition: all 0.2s;
    color: #1e293b;
}

#message-input:focus {
    background: #fff;
    border-color: var(--primary);
}

/* --- AUTH --- */
#auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

#auth-overlay.unlocked {
    opacity: 0;
    transform: scale(1.1);
    pointer-events: none;
}

.auth-box {
    background: white;
    padding: 40px 30px;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(99, 102, 241, 0.25);
    text-align: center;
    width: 85%;
    max-width: 340px;
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: transform 0.2s;
}

.auth-box.error {
    animation: shake 0.4s both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

.auth-box h3 {
    margin: 10px 0 8px 0;
    color: #1e293b;
    font-weight: 800;
    font-size: 22px;
}

.auth-box p {
    margin: 0 0 25px 0;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
}

#pin-input {
    width: 100%;
    padding: 16px;
    font-size: 32px;
    text-align: center;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    margin-bottom: 20px;
    outline: none;
    letter-spacing: 8px;
    font-weight: 800;
    color: var(--primary);
    background: #f8fafc;
    transition: all 0.3s ease;
}

#pin-input:focus {
    border-color: var(--primary);
    background: #fff;
}

#pin-input.input-error {
    border-color: #ef4444 !important;
    background: #fef2f2 !important;
}

#auth-btn {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 16px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#auth-btn.success {
    background: #10b981 !important;
    transform: scale(1.05);
    pointer-events: none;
}

/* --- DASHBOARD STYLES --- */
#stats-view {
    overflow-y: auto;
    scroll-behavior: smooth;
}

.stats-content {
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-bottom: 40px;
}

.stat-card {
    background: white;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(226, 232, 240, 0.8);
}

/* Toggle Switch */
.period-toggle-container {
    display: flex;
    justify-content: center;
    margin-bottom: 0px;
}

.period-toggle {
    background: #e2e8f0;
    border-radius: 12px;
    padding: 4px;
    display: flex;
    position: relative;
    width: 100%;
    max-width: 280px;
}

.toggle-option {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    z-index: 2;
    transition: color 0.3s;
    font-family: inherit;
}

.toggle-option.active {
    color: #1e293b;
}

.toggle-bg {
    position: absolute;
    top: 4px;
    left: 4px;
    width: calc(50% - 4px);
    height: calc(100% - 8px);
    background: white;
    border-radius: 9px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 1;
}

.period-toggle.weekly-mode .toggle-bg {
    transform: translateX(100%);
}

/* Balance Doble */
.balance-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.balance-item {
    flex: 1;
    text-align: center;
}

.divider-vertical {
    width: 1px;
    height: 40px;
    background: #e2e8f0;
}

.stat-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-amount {
    font-family: 'Outfit', sans-serif;
    margin: 5px 0 0 0;
    font-weight: 800;
}

.stat-amount.income {
    color: #10b981;
    font-size: 22px;
}

.stat-amount.expense {
    color: #ef4444;
    font-size: 22px;
}

/* Chart */
.chart-card h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #334155;
}

.chart-wrapper {
    position: relative;
    height: 220px;
    width: 100%;
    display: flex;
    justify-content: center;
}

/* --- OVERDESIGNED ACORDEÓN --- */
.stat-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.category-details {
    background: white;
    border-radius: 16px;
    border: 1px solid #f1f5f9;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.01);
    transition: box-shadow 0.3s ease, transform 0.2s;
}

.category-details:active {
    transform: scale(0.99);
}

.category-details[open] {
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.05);
    border-color: rgba(99, 102, 241, 0.15);
}

.category-summary {
    padding: 14px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    list-style: none;
    user-select: none;
}

.category-summary::-webkit-details-marker {
    display: none;
}

.chevron {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0.4;
}

details[open] .chevron {
    transform: rotate(180deg);
    color: var(--primary);
    opacity: 1;
}

.transaction-list-wrapper {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

details[open] .transaction-list-wrapper {
    grid-template-rows: 1fr;
}

.transaction-list-inner {
    overflow: hidden;
}

.transaction-list {
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    padding: 0;
    margin: 0;
}

.transaction-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s;
}

details[open] .transaction-item {
    opacity: 1;
    transform: translateY(0);
}

details[open] .transaction-item:nth-child(1) {
    transition-delay: 0.1s;
}

details[open] .transaction-item:nth-child(2) {
    transition-delay: 0.15s;
}

details[open] .transaction-item:nth-child(3) {
    transition-delay: 0.2s;
}

details[open] .transaction-item:nth-child(4) {
    transition-delay: 0.25s;
}

.stat-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-cat-name {
    font-weight: 700;
    color: #334155;
    font-size: 14px;
}

.stat-cat-amount {
    font-weight: 700;
    color: #1e293b;
    font-family: 'Outfit', sans-serif;
}

.t-company {
    font-weight: 600;
    color: #1e293b;
    font-size: 14px;
}

.t-desc {
    font-size: 12px;
    color: #64748b;
    font-weight: 400;
    line-height: 1.3;
}

.t-date {
    font-size: 10px;
    color: #94a3b8;
    margin-top: 2px;
}

.t-amount {
    font-weight: 700;
    color: #1e293b;
}

/* Cascada inicial */
#stats-view.active .stat-card,
#stats-view.active .period-toggle-container,
#stats-view.active .stat-list {
    animation: slideInUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    opacity: 0;
    transform: translateY(20px);
}

#stats-view.active .period-toggle-container {
    animation-delay: 0.1s;
}

#stats-view.active .balance-group {
    animation-delay: 0.2s;
}

#stats-view.active .chart-card {
    animation-delay: 0.3s;
}

#stats-view.active .stat-list {
    animation-delay: 0.4s;
}

@keyframes slideInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* --- NUEVOS ESTILOS (Legal & Animaciones) --- */

/* 1. Estilo del Checkbox Personalizado */
.terms-container { margin: 20px 0; text-align: left; display: flex; justify-content: center; }
.custom-checkbox { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.custom-checkbox input { display: none; }

.checkmark { 
    height: 22px; width: 22px; background-color: #f1f5f9; border: 2px solid #cbd5e1; 
    border-radius: 6px; display: flex; align-items: center; justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.custom-checkbox:hover .checkmark { border-color: var(--primary); }
.custom-checkbox input:checked ~ .checkmark { background-color: var(--primary); border-color: var(--primary); transform: scale(1.1); }
.checkmark svg { width: 14px; height: 14px; fill: none; stroke: white; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: 0.2s; }
.custom-checkbox input:checked ~ .checkmark svg { opacity: 1; }

.label-text { font-size: 13px; color: #64748b; font-weight: 500; }
.label-text a { color: var(--primary); text-decoration: none; font-weight: 700; border-bottom: 1px solid transparent; transition: 0.2s; }
.label-text a:hover { border-color: var(--primary); }

/* 2. Animación "Overdesigned" de Éxito (PIN Correcto) */
.pin-success {
    border-color: #10b981 !important;
    background-color: #ecfdf5 !important;
    color: #047857 !important;
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.15) !important;
    transform: scale(1.05);
    letter-spacing: 12px !important;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 3. Estilos del Modal (Glassmorphism) */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(8px); z-index: 10000;
    display: none; align-items: center; justify-content: center; opacity: 0; transition: 0.3s;
}
.modal-overlay.show { opacity: 1; }
.modal-card {
    background: rgba(255, 255, 255, 0.95); width: 90%; max-width: 400px; 
    border-radius: 24px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    position: relative; overflow: hidden; transform: translateY(20px); transition: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid white;
}
.modal-overlay.show .modal-card { transform: translateY(0); }
.modal-header { padding: 25px 25px 10px; text-align: center; }
.shield-icon { font-size: 40px; margin-bottom: 10px; animation: float 3s ease-in-out infinite; }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
.modal-header h3 { margin: 0; color: #1e293b; font-weight: 800; font-size: 20px; }
.modal-body-scroll { max-height: 50vh; overflow-y: auto; padding: 10px 25px; }
.legal-text { font-size: 13px; color: #475569; line-height: 1.5; }
.legal-point { background: #f8fafc; padding: 12px; border-radius: 12px; margin-bottom: 12px; border: 1px solid #e2e8f0; }
.legal-point h4 { margin: 0 0 4px; color: var(--primary); font-size: 14px; }
.legal-point p { margin: 0; }
.close-modal-btn { position: absolute; top: 15px; right: 15px; background: transparent; border: none; font-size: 18px; color: #94a3b8; cursor: pointer; }
.modal-footer { padding: 20px 25px; border-top: 1px solid #f1f5f9; }
.accept-btn { width: 100%; padding: 14px; background: #1e293b; color: white; border:none; border-radius: 14px; font-weight: 700; cursor: pointer; }