:root {
    /* --- PALETA MODO CLARO (GLASS) --- */
    --bg-body: #F3F4F6;
    
    /* Cristal Blanco Esmerilado */
    --bg-card: rgba(255, 255, 255, 0.75); 
    --bg-input: rgba(255, 255, 255, 0.5);
    --bg-header-section: rgba(249, 250, 251, 0.85);
    
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-inverse: #FFFFFF;
    
    --border-light: rgba(255, 255, 255, 0.6);
    --shadow-card: 0 8px 32px 0 rgba(31, 38, 135, 0.07);
    
    /* Colores Fijos */
    --card-blue: #1E40AF;
    --card-blue-light: #3B82F6;
    --danger-red: #DC2626;
    --success-green: #10B981;
    --radius: 20px;
    
    /* FUENTE INTER */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    --blur-strength: 12px;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* --- PALETA MODO OSCURO (SMOKED GLASS) --- */
        --bg-body: #000000;
        
        /* Cristal Ahumado Oscuro */
        --bg-card: rgba(28, 28, 30, 0.75); 
        --bg-input: rgba(44, 44, 46, 0.6);
        --bg-header-section: rgba(17, 24, 39, 0.85);
        
        --text-primary: #F3F4F6;
        --text-secondary: #9CA3AF;
        --text-inverse: #FFFFFF;
        
        --border-light: rgba(255, 255, 255, 0.1);
        --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    }
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }

body { 
    margin: 0; 
    font-family: var(--font-family); 
    background: var(--bg-body); 
    color: var(--text-primary); 
    padding: 0; 
    overflow: hidden; 
    /* Fondo sutil para potenciar el efecto cristal */
    background-image: radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.05) 0%, transparent 20%),
                      radial-gradient(circle at 90% 80%, rgba(220, 38, 38, 0.05) 0%, transparent 20%);
    background-attachment: fixed;
}

/* --- GESTIÓN DE VISTAS --- */
.view {
    display: none; height: 100vh; width: 100vw; overflow-y: auto;
    background: transparent;
    padding-bottom: 40px; animation: fadeIn 0.3s ease;
}
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* --- HOME HEADER (Estilo iOS Centrado) --- */
.home-header { 
    display: flex; 
    justify-content: center; /* CENTRADO TOTAL */
    align-items: center; 
    padding: 15px 24px;
    padding-top: 20px; /* Un poco más de aire arriba */
}

.app-title { 
    font-size: 1.1rem; /* Tamaño más elegante, menos tosco */
    font-weight: 600; 
    color: var(--text-primary); /* Se adapta al tema (negro en light, blanco en dark) */
    margin: 0; 
    letter-spacing: -0.01em;
}

/* --- TARJETA PRINCIPAL AZUL (Glassy Blue) --- */
.main-card {
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.9) 0%, rgba(37, 99, 235, 0.85) 100%);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    color: white; margin: 0 20px 25px 20px; border-radius: 24px; padding: 24px;
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.4); text-align: center;
    border: 1px solid rgba(255,255,255,0.2);
}
.account-selector-wrapper {
    display: flex; justify-content: center; align-items: center; gap: 5px; opacity: 0.9; margin-bottom: 10px;
}
.account-select-transparent {
    background: transparent; border: none; color: white;
    font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
    text-align: right; cursor: pointer; appearance: none;
    font-family: var(--font-family);
}
.balance-wrapper h2 { 
    font-size: 2.8rem; margin: 0; font-weight: 700; letter-spacing: -1.5px; 
    text-shadow: 0 2px 4px rgba(0,0,0,0.1); 
}

.card-stats {
    display: flex; background: rgba(0,0,0,0.15); border-radius: 16px; margin-top: 20px; padding: 12px;
    backdrop-filter: blur(5px);
}
.stat-item { flex: 1; text-align: center; }
.stat-divider { width: 1px; background: rgba(255,255,255,0.2); }
.stat-label { font-size: 0.75rem; display: block; opacity: 0.8; margin-bottom: 4px; font-weight: 500; }
.stat-val { font-size: 1rem; font-weight: 600; }
.income-val { color: #6EE7B7; } 
.expense-val { color: #FCA5A5; } 

/* --- GRID DE NAVEGACIÓN (GLASS) --- */
.nav-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 0 20px 40px 20px; }
.nav-card {
    background: var(--bg-card); 
    backdrop-filter: blur(var(--blur-strength)); -webkit-backdrop-filter: blur(var(--blur-strength));
    border: 1px solid var(--border-light);
    border-radius: var(--radius); padding: 20px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 12px; box-shadow: var(--shadow-card); cursor: pointer; transition: transform 0.2s, background 0.2s;
    color: var(--text-primary);
}
.nav-card:active { transform: scale(0.96); background: var(--bg-input); }
.nav-icon-bg {
    width: 48px; height: 48px; background: rgba(59, 130, 246, 0.1); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}
@media (prefers-color-scheme: dark) { .nav-icon-bg { background: rgba(30, 58, 138, 0.4); } }
.nav-card span { font-weight: 600; font-size: 0.95rem; }

/* --- PANTALLAS SECUNDARIAS --- */
.sub-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 20px; 
    background: rgba(var(--bg-header-section), 0.9); /* Más sólido para que no se mezcle al hacer scroll */
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    position: sticky; top: 0; z-index: 10;
    border-bottom: 1px solid transparent;
    transition: border-color 0.3s;
}
/* Al hacer scroll se podría añadir borde, pero lo dejamos limpio */

.back-btn {
    background: var(--bg-card); width: 40px; height: 40px; border-radius: 12px;
    border: 1px solid var(--border-light); font-size: 1.2rem;
    display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-primary);
    backdrop-filter: blur(var(--blur-strength));
}
.sub-header h2 { font-size: 1.1rem; margin: 0; font-weight: 600; color: var(--text-primary); }
.icon-header { background: none; border: none; font-size: 1.2rem; cursor: pointer; }

/* --- CONTROLES Y FORMULARIOS --- */
.content-wrapper { padding: 20px; }
.segmented-control {
    display: flex; background: var(--bg-input); padding: 4px; border-radius: 14px;
    margin-bottom: 25px; box-shadow: inset 0 1px 3px rgba(0,0,0,0.06);
}
.seg-btn {
    flex: 1; padding: 10px; border: none; background: transparent;
    border-radius: 10px; font-weight: 600; color: var(--text-secondary);
    font-size: 0.85rem; cursor: pointer; transition: all 0.2s;
}
.seg-btn.active { 
    background: var(--bg-card); 
    color: var(--text-primary); 
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
    border: 1px solid var(--border-light);
}

.form-label {
    display: block; font-size: 0.75rem; font-weight: 700; color: var(--text-secondary);
    margin-bottom: 8px; letter-spacing: 0.5px; text-transform: uppercase;
}
.modern-input {
    width: 100%; padding: 16px; 
    background: var(--bg-input); 
    border: 1px solid var(--border-light);
    border-radius: 14px; font-family: var(--font-family); font-size: 1rem;
    color: var(--text-primary); margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.01); -webkit-appearance: none;
    transition: border-color 0.2s;
}
select.modern-input {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 1rem center; background-size: 1em; padding-right: 2.5rem;
}
.modern-input:focus { border-color: var(--card-blue-light); outline: none; }
.input-with-icon { position: relative; display: flex; gap: 10px; }
.icon-addon {
    width: 50px; background: var(--bg-input); border: 1px solid var(--border-light); border-radius: 14px;
    font-size: 1.2rem; display: flex; align-items: center; justify-content: center;
    margin-bottom: 20px; cursor: pointer; color: var(--text-primary);
}

.save-btn {
    width: 100%; padding: 18px; border-radius: 16px; border: none;
    color: white; font-weight: 600; font-size: 1.1rem; cursor: pointer;
    box-shadow: 0 8px 20px -5px rgba(0,0,0,0.2); transition: transform 0.1s;
}
.save-btn:active { transform: scale(0.98); }
.btn-red { background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%); }
.btn-green { background: linear-gradient(135deg, #10B981 0%, #059669 100%); }
.cancel-text-btn { width: 100%; background: none; border: none; color: var(--danger-red); margin-top: 15px; font-weight: 500; }

/* --- FILTROS (GLASS) --- */
.history-controls-container {
    padding: 20px;
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur-strength)); -webkit-backdrop-filter: blur(var(--blur-strength));
    border: 1px solid var(--border-light);
    border-radius: 24px;
    margin: 20px;
    color: var(--text-primary);
    box-shadow: var(--shadow-card);
}
.filters-row { display: flex; gap: 12px; margin-bottom: 15px; }
.filter-group { flex: 1; display: flex; flex-direction: column; gap: 6px; }

.history-input-dark {
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 12px 14px;
    border-radius: 12px;
    width: 100%; font-size: 0.9rem; font-family: var(--font-family); -webkit-appearance: none; margin-bottom: 0;
}
select.history-input-dark {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat; background-position: right 1rem center; background-size: 1em; padding-right: 2.5rem;
}
@media (prefers-color-scheme: dark) {
    select.history-input-dark {
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    }
}
#histSearchInput { margin-bottom: 15px; }

/* --- TARJETAS DE MOVIMIENTOS (GLASS) --- */
.history-card, .account-card {
    background: var(--bg-card);
    backdrop-filter: blur(var(--blur-strength)); -webkit-backdrop-filter: blur(var(--blur-strength));
    border: 1px solid var(--border-light);
    border-radius: 18px; padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-card);
    color: var(--text-primary);
}

.h-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.h-card-cat { font-size: 1rem; font-weight: 700; color: var(--text-primary); display: block; }
.h-card-desc { font-size: 0.85rem; color: var(--text-secondary); display: block; margin-top: 2px; }
.h-card-right { text-align: right; }
.h-card-date { font-size: 0.75rem; color: var(--text-secondary); display: block; margin-bottom: 2px; }
.h-card-amount { font-size: 1.1rem; font-weight: 700; }
.h-card-actions { display: flex; gap: 10px; margin-top: 15px; border-top: 1px solid var(--border-light); padding-top: 15px; }
.h-btn {
    flex: 1; padding: 10px; border-radius: 10px; border: none; font-weight: 600;
    color: white; font-size: 0.9rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    backdrop-filter: blur(5px);
}
.h-btn-edit { background: rgba(16, 185, 129, 0.9); }
.h-btn-delete { background: rgba(239, 68, 68, 0.9); }

/* --- RESUMENES AGRUPADOS --- */
.summary-blue-card {
    background: linear-gradient(180deg, rgba(30, 58, 138, 0.9) 0%, rgba(37, 99, 235, 0.85) 100%);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 20px; padding: 25px; text-align: center; color: white;
    margin: 20px; margin-bottom: 10px; box-shadow: 0 10px 20px -5px rgba(30, 58, 138, 0.4);
}
.sum-label { font-size: 0.85rem; opacity: 0.9; font-weight: 500; display: block; margin-bottom: 5px; }
.summary-blue-card h2 { font-size: 2.2rem; margin: 0; font-weight: 700; letter-spacing: -1px; text-shadow: 0 2px 5px rgba(0,0,0,0.2); }

.grouped-section { 
    background: transparent; 
    margin-bottom: 16px; 
    border-radius: 18px; 
    overflow: hidden; 
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
}

.group-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 15px 20px;
    background: var(--bg-header-section);
    backdrop-filter: blur(var(--blur-strength));
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
.group-info { display: flex; align-items: center; gap: 10px; }
.group-cat-name { font-size: 1.05rem; font-weight: 700; color: var(--text-primary); }
.group-total { font-weight: 700; font-size: 1.05rem; }

.group-items { background: var(--bg-card); padding: 5px 20px; backdrop-filter: blur(var(--blur-strength)); }
.group-item-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 0; border-bottom: 1px solid var(--border-light); font-size: 0.9rem;
}
.group-item-row:last-child { border-bottom: none; }
.g-item-desc { color: var(--text-secondary); font-weight: 500; }
.g-item-amount { font-weight: 600; font-size: 0.95rem; }

/* --- ESTILO CUENTAS --- */
.account-card.active-account { border: 2px solid var(--success-green); background: rgba(16, 185, 129, 0.05); }
.acc-header { display: flex; justify-content: space-between; margin-bottom: 12px; }
.acc-alias { font-size: 1.2rem; font-weight: 700; color: var(--text-primary); }
.acc-tag {
    font-size: 0.75rem; background: var(--bg-input); color: var(--text-secondary);
    padding: 4px 8px; border-radius: 6px; font-weight: 600; border: 1px solid var(--border-light);
}
.active-account .acc-tag { background: var(--success-green); color: white; border:none; }
.acc-details { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; font-size: 0.9rem; margin-bottom: 15px; }
.acc-detail-item { display: flex; flex-direction: column; }
.acc-label { font-size: 0.7rem; color: var(--text-secondary); font-weight: 700; text-transform: uppercase; margin-bottom: 2px; }
.acc-val { color: var(--text-primary); }

/* --- MODAL (GLASS) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 2000;
    display: none; justify-content: center; align-items: center; 
    backdrop-filter: blur(8px);
}
.modal-overlay.active { display: flex; animation: fadeIn 0.2s; }
.modal-content {
    background: var(--bg-card); width: 90%; max-width: 350px;
    padding: 24px; border-radius: 24px; 
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
    color: var(--text-primary);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
}
.modal-header h2 { color: var(--text-primary); }
.small-btn { color: var(--text-secondary); background: transparent; border:none; font-size: 1.2rem; cursor: pointer; }

/* --- AJUSTES --- */
.settings-list { 
    padding: 20px; background: var(--bg-card); border-radius: 20px; margin: 20px; 
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(var(--blur-strength));
    border: 1px solid var(--border-light);
}
.setting-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 0; border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
}
.setting-item:last-child { border-bottom: none; }
.setting-item span { font-weight: 500; }
.setting-action {
    background: var(--bg-input); border: 1px solid var(--border-light);
    padding: 8px 12px; border-radius: 8px; font-weight: 600; color: var(--text-primary); cursor: pointer;
}
.text-red { color: var(--danger-red); background: rgba(220, 38, 38, 0.1); border:none; }
.list-container { padding: 0 20px; padding-bottom: 80px; }
.transaction-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 0; border-bottom: 1px solid var(--border-light); cursor: pointer;
}
.row-left { display: flex; flex-direction: column; gap: 4px; }
.row-cat { font-weight: 600; font-size: 1rem; color: var(--text-primary); }
.row-date { font-size: 0.75rem; color: var(--text-secondary); }
.row-amt { font-weight: 700; font-size: 1rem; }
.amount-income { color: var(--success-green); }
.amount-expense { color: var(--text-primary); }
@media (prefers-color-scheme: dark) { .amount-expense { color: #F3F4F6; } }
