/* Reseteo básico y variables de color */
:root {
    --primary-color: #4F46E5;
    --bg-color: #F3F4F6;
    --card-bg: #FFFFFF;
    --text-main: #1F2937;
    --text-muted: #6B7280;
    --danger: #EF4444;
    --success: #10B981;
    --balance-grad-a: #4F46E5;
    --balance-grad-b: #3B82F6;
}

/* ══════════════════════════════════════════
   PALETAS DE COLOR — 5 temas
══════════════════════════════════════════ */

/* ── 1. COSMOS: oscuro, profundo, espacial ── */
body.theme-cosmos {
    --primary-color: #818CF8;
    --bg-color: #0B0F1E;
    --card-bg: #151929;
    --text-main: #E2E8F0;
    --text-muted: #94A3B8;
    --danger: #F87171;
    --success: #34D399;
    --balance-grad-a: #312E81;
    --balance-grad-b: #6D28D9;
}
body.theme-cosmos body { color: #E2E8F0; }
body.theme-cosmos .header { background: #151929; box-shadow: 0 2px 8px rgba(0,0,0,0.4); }
body.theme-cosmos .logo { color: #818CF8; }
body.theme-cosmos .container { background: transparent; }
body.theme-cosmos .card,
body.theme-cosmos .modal-content,
body.theme-cosmos .chart-section,
body.theme-cosmos .credits-panel { background-color: #151929 !important; color: #E2E8F0; }
body.theme-cosmos .transaction-list { background: #151929; }
body.theme-cosmos .transaction { border-bottom-color: #1E2A45; }
body.theme-cosmos .history-section h3 { color: #94A3B8; }
body.theme-cosmos .action-card--expense      { background: #1e1b4b; color: #a5b4fc; }
body.theme-cosmos .action-card--fixed        { background: #064e3b; color: #6ee7b7; }
body.theme-cosmos .action-card--credit       { background: #2e1065; color: #c4b5fd; }
body.theme-cosmos .action-card--income       { background: #431407; color: #fdba74; }
body.theme-cosmos .action-card--extra-income { background: #052e16; color: #86efac; }
body.theme-cosmos .sidebar { background: #151929; }
body.theme-cosmos .sidebar-header { background: #312E81; }
body.theme-cosmos .sidebar-item { background: #1E2A45; border-color: #2D3A55; color: #E2E8F0; }
body.theme-cosmos .sidebar-item:hover { background: #1e1b4b; }
body.theme-cosmos .sidebar-item-title { color: #E2E8F0; }
body.theme-cosmos .sidebar-item-sub { color: #94A3B8; }
body.theme-cosmos .theme-selector-label { color: #64748B; }
body.theme-cosmos .form-group input,
body.theme-cosmos .form-group select { background: #0B0F1E; border-color: #2D3A55; color: #E2E8F0; }
body.theme-cosmos .calc-widget { background: #0B0F1E; border-color: #2D3A55; }
body.theme-cosmos .calc-btn { background: #151929; color: #E2E8F0; }
body.theme-cosmos .calc-btn.operator { background: #1e1b4b; color: #818CF8; }
body.theme-cosmos .mes-badge { background: #1e1b4b; color: #818CF8; }
body.theme-cosmos .btn-secondary { background: #1E2A45; color: #E2E8F0; }
body.theme-cosmos .income-warning { background: #1c1a07; border-color: #854d0e; color: #fde68a; }
body.theme-cosmos .btn-ver-mas { background: #1E2A45; border-color: #312E81; color: #818CF8; }

/* ── 2. ARCTIC: azul glacial, frío y profesional ── */
body.theme-arctic {
    --primary-color: #0284C7;
    --bg-color: #EFF6FF;
    --card-bg: #FFFFFF;
    --text-main: #0F172A;
    --text-muted: #475569;
    --danger: #DC2626;
    --success: #0891B2;
    --balance-grad-a: #0369A1;
    --balance-grad-b: #0284C7;
}
body.theme-arctic .action-card--expense      { background: #EFF6FF; color: #1E40AF; }
body.theme-arctic .action-card--fixed        { background: #E0F2FE; color: #0369A1; }
body.theme-arctic .action-card--credit       { background: #DBEAFE; color: #1D4ED8; }
body.theme-arctic .action-card--income       { background: #F0FDF4; color: #166534; }
body.theme-arctic .action-card--extra-income { background: #ECFEFF; color: #0E7490; }
body.theme-arctic .mes-badge { background: #DBEAFE; color: #1D4ED8; }
body.theme-arctic .btn-ver-mas { border-color: #BAE6FD; color: #0284C7; }
body.theme-arctic .btn-ver-mas:hover { background: #EFF6FF; }

/* ── 3. FOREST: verde naturaleza, orgánico ── */
body.theme-forest {
    --primary-color: #15803D;
    --bg-color: #F0FDF4;
    --card-bg: #FFFFFF;
    --text-main: #14532D;
    --text-muted: #4B7A5E;
    --danger: #DC2626;
    --success: #15803D;
    --balance-grad-a: #14532D;
    --balance-grad-b: #15803D;
}
body.theme-forest .action-card--expense      { background: #DCFCE7; color: #14532D; }
body.theme-forest .action-card--fixed        { background: #D1FAE5; color: #065F46; }
body.theme-forest .action-card--credit       { background: #F0FDF4; color: #166534; }
body.theme-forest .action-card--income       { background: #FEF9C3; color: #713F12; }
body.theme-forest .action-card--extra-income { background: #ECFDF5; color: #064E3B; }
body.theme-forest .mes-badge { background: #D1FAE5; color: #065F46; }
body.theme-forest .btn-ver-mas { border-color: #86EFAC; color: #15803D; }
body.theme-forest .btn-ver-mas:hover { background: #F0FDF4; }

/* ── 4. SUNSET: naranja cálido, energético, amigable ── */
body.theme-sunset {
    --primary-color: #EA580C;
    --bg-color: #FFF7ED;
    --card-bg: #FFFFFF;
    --text-main: #1C1917;
    --text-muted: #78716C;
    --danger: #DC2626;
    --success: #16A34A;
    --balance-grad-a: #9A3412;
    --balance-grad-b: #EA580C;
}
body.theme-sunset .action-card--expense      { background: #FFF7ED; color: #9A3412; }
body.theme-sunset .action-card--fixed        { background: #FEF3C7; color: #92400E; }
body.theme-sunset .action-card--credit       { background: #FEE2E2; color: #991B1B; }
body.theme-sunset .action-card--income       { background: #FEF9C3; color: #713F12; }
body.theme-sunset .action-card--extra-income { background: #DCFCE7; color: #166534; }
body.theme-sunset .mes-badge { background: #FFEDD5; color: #9A3412; }
body.theme-sunset .btn-ver-mas { border-color: #FDBA74; color: #EA580C; }
body.theme-sunset .btn-ver-mas:hover { background: #FFF7ED; }

/* ── 5. ROSE: femenino, elegante, sofisticado ── */
body.theme-rose {
    --primary-color: #BE185D;
    --bg-color: #FFF1F5;
    --card-bg: #FFFFFF;
    --text-main: #500724;
    --text-muted: #9D4B6E;
    --danger: #E11D48;
    --success: #0D9488;
    --balance-grad-a: #831843;
    --balance-grad-b: #BE185D;
}
body.theme-rose .action-card--expense      { background: #FFF1F5; color: #881337; }
body.theme-rose .action-card--fixed        { background: #FCE7F3; color: #831843; }
body.theme-rose .action-card--credit       { background: #FDF2F8; color: #701A4A; }
body.theme-rose .action-card--income       { background: #CCFBF1; color: #134E4A; }
body.theme-rose .action-card--extra-income { background: #F0FDFA; color: #0D6B5E; }
body.theme-rose .mes-badge { background: #FCE7F3; color: #BE185D; }
body.theme-rose .btn-ver-mas { border-color: #FBCFE8; color: #BE185D; }
body.theme-rose .btn-ver-mas:hover { background: #FFF1F5; }
body.theme-rose .income-warning { background: #fff1f5; border-color: #fbcfe8; color: #881337; }

/* ── 6. MIDNIGHT: oscuro cyberpunk con cyan eléctrico ── */
body.theme-midnight {
    --primary-color: #06B6D4;
    --bg-color: #020617;
    --card-bg: #0F1929;
    --text-main: #E0F2FE;
    --text-muted: #7DD3FC;
    --danger: #FB7185;
    --success: #2DD4BF;
    --balance-grad-a: #0E7490;
    --balance-grad-b: #06B6D4;
}
body.theme-midnight .header { background: #0F1929; box-shadow: 0 2px 8px rgba(6,182,212,0.15); }
body.theme-midnight .logo { color: #22D3EE; text-shadow: 0 0 12px rgba(34,211,238,0.4); }
body.theme-midnight .card,
body.theme-midnight .modal-content,
body.theme-midnight .chart-section,
body.theme-midnight .credits-panel { background-color: #0F1929 !important; color: #E0F2FE; border: 1px solid rgba(6,182,212,0.15); }
body.theme-midnight .transaction-list { background: #0F1929; }
body.theme-midnight .transaction { border-bottom-color: #1E3A5F; }
body.theme-midnight .history-section h3 { color: #7DD3FC; }
body.theme-midnight .action-card--expense      { background: #164E63; color: #67E8F9; box-shadow: 0 0 0 1px rgba(34,211,238,0.2); }
body.theme-midnight .action-card--fixed        { background: #134E4A; color: #5EEAD4; }
body.theme-midnight .action-card--credit       { background: #1E1B4B; color: #A5B4FC; }
body.theme-midnight .action-card--income       { background: #422006; color: #FCD34D; }
body.theme-midnight .action-card--extra-income { background: #064E3B; color: #6EE7B7; }
body.theme-midnight .sidebar { background: #0F1929; }
body.theme-midnight .sidebar-header { background: #0E7490; }
body.theme-midnight .sidebar-item { background: #1E3A5F; border-color: #164E63; color: #E0F2FE; }
body.theme-midnight .sidebar-item:hover { background: #155E75; }
body.theme-midnight .sidebar-item-title { color: #E0F2FE; }
body.theme-midnight .sidebar-item-sub { color: #7DD3FC; }
body.theme-midnight .theme-selector-label { color: #7DD3FC; }
body.theme-midnight .form-group input,
body.theme-midnight .form-group select { background: #020617; border-color: #164E63; color: #E0F2FE; }
body.theme-midnight .calc-widget { background: #020617; border-color: #164E63; }
body.theme-midnight .calc-btn { background: #0F1929; color: #E0F2FE; }
body.theme-midnight .calc-btn.operator { background: #155E75; color: #67E8F9; }
body.theme-midnight .mes-badge { background: #155E75; color: #67E8F9; }
body.theme-midnight .btn-secondary { background: #1E3A5F; color: #E0F2FE; }
body.theme-midnight .income-warning { background: #1c1a07; border-color: #854d0e; color: #fde68a; }
body.theme-midnight .btn-ver-mas { background: #1E3A5F; border-color: #06B6D4; color: #67E8F9; }

/* ── 7. PEACH: durazno pastel suave y delicado ── */
body.theme-peach {
    --primary-color: #F97316;
    --bg-color: #FFF7F0;
    --card-bg: #FFFFFF;
    --text-main: #431407;
    --text-muted: #9A6B4D;
    --danger: #EF4444;
    --success: #84CC16;
    --balance-grad-a: #FB923C;
    --balance-grad-b: #FDBA74;
}
body.theme-peach .action-card--expense      { background: #FFEDD5; color: #9A3412; }
body.theme-peach .action-card--fixed        { background: #FFF7ED; color: #C2410C; }
body.theme-peach .action-card--credit       { background: #FFE4E6; color: #9F1239; }
body.theme-peach .action-card--income       { background: #FEF3C7; color: #854D0E; }
body.theme-peach .action-card--extra-income { background: #ECFCCB; color: #4D7C0F; }
body.theme-peach .mes-badge { background: #FFEDD5; color: #C2410C; }
body.theme-peach .btn-ver-mas { border-color: #FDBA74; color: #EA580C; }
body.theme-peach .btn-ver-mas:hover { background: #FFF7ED; }
body.theme-peach .income-warning { background: #FFEDD5; border-color: #FDBA74; color: #9A3412; }

/* ── 8. GRAPE: lavanda y púrpura, místico ── */
body.theme-grape {
    --primary-color: #7E22CE;
    --bg-color: #FAF5FF;
    --card-bg: #FFFFFF;
    --text-main: #3B0764;
    --text-muted: #7C5BA6;
    --danger: #E11D48;
    --success: #16A34A;
    --balance-grad-a: #581C87;
    --balance-grad-b: #9333EA;
}
body.theme-grape .action-card--expense      { background: #F3E8FF; color: #581C87; }
body.theme-grape .action-card--fixed        { background: #EDE9FE; color: #5B21B6; }
body.theme-grape .action-card--credit       { background: #FAE8FF; color: #6B21A8; }
body.theme-grape .action-card--income       { background: #FEF3C7; color: #854D0E; }
body.theme-grape .action-card--extra-income { background: #DCFCE7; color: #166534; }
body.theme-grape .mes-badge { background: #F3E8FF; color: #7E22CE; }
body.theme-grape .btn-ver-mas { border-color: #C4B5FD; color: #7E22CE; }
body.theme-grape .btn-ver-mas:hover { background: #F3E8FF; }
body.theme-grape .income-warning { background: #FAF5FF; border-color: #DDD6FE; color: #581C87; }


/* Clase utilitaria global */
.hidden { display: none !important; }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
}

/* Header */
.header {
    background-color: var(--card-bg);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.logo {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--primary-color);
}

.avatar {
    background-color: var(--primary-color);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Contenedor principal */
.container {
    padding: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

/* Tarjetas */
.summary-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.card {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.balance-card {
    text-align: center;
    background: linear-gradient(135deg, var(--balance-grad-a), var(--balance-grad-b));
    color: white;
}

.balance-card h3 {
    font-size: 1rem;
    font-weight: normal;
    margin-bottom: 0.5rem;
}

.balance-card .amount {
    font-size: 2rem;
    font-weight: bold;
}

.expenses-wrapper {
    display: flex;
    gap: 1rem;
}

.expense-card {
    flex: 1;
    padding: 1rem;
    text-align: center;
}

.expense-card h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.expense-card p {
    font-size: 1.2rem;
    font-weight: bold;
}

/* Botones */
.actions-section {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    margin-bottom: 2rem;
}

.btn {
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn:active {
    opacity: 0.8;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-secondary {
    background-color: #E5E7EB;
    color: var(--text-main);
}

/* Historial */
.history-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.transaction-list {
    list-style: none;
    background-color: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
}

.transaction {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid #E5E7EB;
}

.transaction:last-child {
    border-bottom: none;
}

.transaction-info {
    display: flex;
    flex-direction: column;
}

.transaction-info .category {
    font-weight: bold;
}

.transaction-info .date {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.transaction-info .desc {
    font-size: 0.82rem;
    color: #4B5563;
    font-style: italic;
}

.btn-ver-mas {
    width: 100%;
    padding: 0.85rem;
    background: #f8fafc;
    border: 1px dashed #c7d2fe;
    border-radius: 0 0 12px 12px;
    color: #4F46E5;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-ver-mas:hover { background: #eef2ff; }
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 99px;
    border: 1px solid #fde68a;
}

.transaction-amount.negative {
    color: var(--danger);
    font-weight: bold;
}

/* --- ESTILOS DEL MODAL --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    width: 92%;
    max-width: 380px;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-content h2 {
    margin-bottom: 1rem;
    font-size: 1.15rem;
    color: var(--primary-color);
}

.form-group {
    margin-bottom: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: bold;
}

.form-group input, .form-group select {
    padding: 0.65rem 0.8rem;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary-color);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
}

/* --- ESTILOS PARA EL BOTÓN DE ELIMINAR --- */
.transaction-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-delete {
    background-color: transparent;
    color: var(--danger);
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-delete:hover {
    background-color: #FEE2E2;
}

/* --- PANTALLA DE LOGIN --- */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.login-overlay.hidden {
    display: none;
}

.login-card {
    background-color: var(--card-bg);
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    text-align: center;
}

.login-card h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

#btn-logout {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
}

/* --- FOOTER THE MOMENT --- */
.footer-the-moment {
    background-color: #0F172A;
    color: #94A3B8;
    padding: 2.5rem 1rem;
    margin-top: 4rem;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.footer-item {
    text-transform: uppercase;
}

.footer-item.highlighted {
    color: #F8FAFC;
    font-weight: 700;
}

.footer-item.lowercase {
    text-transform: none;
}

.footer-item.italic {
    text-transform: none;
    font-style: italic;
    color: #64748B;
}

.footer-divider {
    color: #334155;
    user-select: none;
}

@media (max-width: 850px) {
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    .footer-divider {
        display: none;
    }
}

/* --- LANDING PAGE --- */
.landing-page {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #f8fafc;
    z-index: 9999;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.landing-page.hidden {
    display: none !important;
}

.landing-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 5%;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.landing-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: #4F46E5;
}
.landing-logo span { color: #10B981; }

.btn-outline {
    background: transparent;
    border: 2px solid #4F46E5;
    color: #4F46E5;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}
.btn-outline:hover {
    background: #4F46E5;
    color: white;
}

.hero-section {
    text-align: center;
    padding: 4rem 1.5rem 2rem;
    max-width: 800px;
    margin: 0 auto;
}

.badge-beta {
    background: #dbeafe;
    color: #1d4ed8;
    padding: 0.3rem 0.8rem;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
    margin-bottom: 1rem;
    display: inline-block;
}

.hero-section h1 {
    font-size: 2.8rem;
    color: #1e293b;
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

.hero-section p {
    font-size: 1.15rem;
    color: #64748b;
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

.google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #4285F4 !important;
    font-size: 1.1rem;
    padding: 1rem 2rem;
}
.google-icon {
    background: white;
    color: #4285F4;
    width: 24px; height: 24px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-right: 10px;
}

.features-section {
    display: flex;
    gap: 1.5rem;
    padding: 2rem 5%;
    max-width: 1100px;
    margin: 0 auto 3rem;
    flex-wrap: wrap;
}

.feature-card {
    flex: 1;
    min-width: 280px;
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    text-align: left;
    border-top: 4px solid #4F46E5;
}

.feature-card h3 {
    font-size: 1.2rem;
    color: #1e293b;
    margin-bottom: 1rem;
}
.feature-card p {
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.5;
}

.landing-footer {
    margin-top: auto;
    padding: 2rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.9rem;
    background: white;
}

@media (max-width: 768px) {
    .hero-section h1 { font-size: 2rem; }
    .features-section { flex-direction: column; }
}

/* --- DISEÑO RESPONSIVO --- */
@media (max-width: 768px) {
    body, html {
        overflow-x: hidden;
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .header { padding: 15px; }
    .logo { font-size: 1.2rem; }

    .container {
        padding: 15px;
        width: 100%;
        box-sizing: border-box;
    }

    .balance-card h3 { font-size: 1.1rem; }
    .balance-card .amount {
        font-size: 2.5rem;
        word-wrap: break-word;
    }

    .expenses-wrapper {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .expense-card { width: 100%; }

    .actions-section {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .actions-section .btn {
        width: 100%;
        margin: 0;
        padding: 15px;
        font-size: 1rem;
    }

    .chart-section { padding: 1rem; }
    .chart-section canvas {
        max-width: 100%;
        height: auto !important;
    }

    .modal-content {
        width: 90%;
        margin: 20% auto;
        padding: 20px;
    }
}

/* --- SELECTOR DE MÓDULO --- */
.module-selector {
    position: fixed;
    inset: 0;
    background: #f8fafc;
    z-index: 5000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.module-selector.hidden { display: none !important; }

.module-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 5%;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.module-selector-body {
    flex: 1;
    padding: 2.5rem 5%;
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
}

.module-selector-title {
    font-size: 1.9rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.module-selector-sub {
    color: #94a3b8;
    margin-bottom: 2rem;
    font-size: 1rem;
}

.module-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.module-card {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding: 1.4rem 1.5rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    position: relative;
}
.module-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.module-card:active { transform: scale(0.99); }

.module-card--personal  { border-color: #c7d2fe; }
.module-card--personal:hover  { border-color: #4F46E5; }
.module-card--family   { border-color: #e2e8f0; opacity: 0.75; cursor: default; }
.module-card--business { border-color: #e2e8f0; opacity: 0.75; cursor: default; }

.module-card-icon { font-size: 2.4rem; flex-shrink: 0; }

.module-card-content h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.3rem;
}
.module-card-content p {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.4;
}

.module-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 99px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.module-badge--active { background: #dcfce7; color: #166534; }
.module-badge--soon   { background: #f1f5f9; color: #94a3b8; }

/* --- PANTALLAS PRÓXIMAMENTE --- */
.coming-soon-screen {
    position: fixed;
    inset: 0;
    background: #f8fafc;
    z-index: 5000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
}
.coming-soon-screen.hidden { display: none !important; }

.coming-soon-card {
    background: white;
    border-radius: 20px;
    padding: 2.5rem 2rem;
    max-width: 480px;
    width: 100%;
    box-shadow: 0 8px 30px rgba(0,0,0,0.08);
    text-align: center;
}

.coming-soon-icon { font-size: 3.5rem; margin-bottom: 1rem; }

.coming-soon-card h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 0.75rem;
}

.coming-soon-desc {
    color: #64748b;
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.coming-soon-features {
    list-style: none;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.coming-soon-features li {
    font-size: 0.9rem;
    color: #475569;
    padding: 0.5rem 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
}

/* --- FIN MÓDULOS --- */
.hamburger-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 4px;
}
.hamburger-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--primary-color);
    border-radius: 2px;
    transition: all 0.2s;
}

/* --- SIDEBAR --- */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 3000;
    backdrop-filter: blur(2px);
}

.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 300px;
    max-width: 85vw;
    height: 100%;
    background: white;
    z-index: 3001;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    transform: translateX(0);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.sidebar.hidden {
    display: none !important;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    background: #4F46E5;
    color: white;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
}

.sidebar-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}
.sidebar-close:hover { background: rgba(255,255,255,0.2); }

.sidebar-nav {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: #f8fafc;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s, transform 0.1s;
    border: 1px solid #f1f5f9;
}
.sidebar-item:hover { background: #eef2ff; border-color: #c7d2fe; }
.sidebar-item:active { transform: scale(0.98); }

.sidebar-icon { font-size: 1.6rem; }

.sidebar-item-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}
.sidebar-item-sub {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-top: 2px;
}

/* --- TARJETAS DE ACCIÓN 2x2 --- */
.action-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9rem;
    margin-bottom: 2rem;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.4rem 1rem;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}
.action-card:active { transform: scale(0.96); }
.action-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.12); }

.action-card-icon { font-size: 1.8rem; }
.action-card-label {
    font-size: 0.85rem;
    font-weight: 700;
}

.action-card--expense  { background: #EEF2FF; color: #3730A3; }
.action-card--fixed    { background: #F0FDF4; color: #166534; }
.action-card--credit   { background: #F5F3FF; color: #5B21B6; }
.action-card--extra-income { background: #ECFDF5; color: #065f46; }

.extra-income-summary {
    margin-top: 0.6rem;
    font-size: 0.82rem;
    color: rgba(255,255,255,0.85);
    background: rgba(255,255,255,0.15);
    border-radius: 99px;
    padding: 0.25rem 0.75rem;
    display: inline-block;
}
.extra-income-summary strong { color: #fff; }

/* --- PANEL CRÉDITOS ACTUALIZADO --- */
.credits-panel {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border-top: 4px solid #7C3AED;
}

.credits-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.credits-header h3 {
    font-size: 1.1rem;
    color: #5B21B6;
    margin: 0;
}

.credits-close-btn {
    background: #f1f5f9;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 1rem;
    color: #64748b;
}
.credits-close-btn:hover { background: #e2e8f0; }

.credits-label {
    display: block;
    font-size: 0.72rem;
    color: #9CA3AF;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.credits-total-amount {
    font-size: 1.3rem;
    font-weight: bold;
    color: #7C3AED;
}

.credits-deuda-amount {
    font-size: 1.1rem;
    font-weight: 600;
    color: #EF4444;
}
.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.empty-state .empty-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.5rem;
}

/* --- MES ACTUAL EN HEADER --- */
.mes-badge {
    background-color: #EEF2FF;
    color: var(--primary-color);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 99px;
    text-transform: capitalize;
    white-space: nowrap;
}

/* --- INCOME WARNING --- */
.income-warning {
    background: #fffbeb;
    border: 1px dashed #f59e0b;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    text-align: center;
    font-size: 0.9rem;
    color: #92400e;
    margin-bottom: 1rem;
    cursor: pointer;
}
.income-warning:hover { background: #fef3c7; }
/* --- CALCULADORA --- */
.calc-wrapper {
    position: relative;
    width: 100%;
}

.calc-input {
    background-color: #f9fafb;
    cursor: pointer;
    width: 100%;
}

.calc-widget {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    background: #f1f5f9;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    margin-top: 5px;
    width: 100%;
}

.calc-widget.hidden {
    display: none !important;
}

.calc-btn {
    padding: 6px 0;
    font-size: 0.88rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background-color: #ffffff;
    color: #1f2937;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    /* Transición suave en todo */
    transition: background-color 0.1s ease,
                transform 0.08s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.1s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
    /* Evitar delays en touch */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.calc-btn:hover {
    background-color: #f8fafc;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

.calc-btn:active {
    background-color: #e2e8f0;
    transform: scale(0.92);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* Ripple effect */
.calc-btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(0,0,0,0.12);
    transform: scale(0);
    animation: ripple-anim 0.35s linear;
    pointer-events: none;
}

@keyframes ripple-anim {
    to { transform: scale(4); opacity: 0; }
}

.calc-btn.operator {
    background-color: #e0e7ff;
    color: #4F46E5;
}
.calc-btn.operator:active { background-color: #c7d2fe; }
.calc-btn.operator .ripple { background: rgba(79,70,229,0.15); }

.calc-btn.equals {
    background-color: #4F46E5;
    color: white;
}
.calc-btn.equals:active { background-color: #3730a3; }
.calc-btn.equals .ripple { background: rgba(255,255,255,0.25); }

.calc-btn.clear {
    background-color: #fee2e2;
    color: #ef4444;
}
.calc-btn.clear:active { background-color: #fecaca; }
.calc-btn.clear .ripple { background: rgba(239,68,68,0.15); }

/* Fila inferior: Aceptar + Cancelar */
.calc-btn.close-calc {
    grid-column: span 2;
    background-color: #10b981;
    color: white;
    margin-top: 2px;
    padding: 8px 0;
    font-size: 0.85rem;
}
.calc-btn.close-calc:active { background-color: #059669; }
.calc-btn.close-calc .ripple { background: rgba(255,255,255,0.25); }

.calc-btn.cancel-calc {
    grid-column: span 2;
    background-color: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
    margin-top: 2px;
    padding: 8px 0;
    font-size: 0.85rem;
}
.calc-btn.cancel-calc:active { background-color: #e2e8f0; }


/* --- ESTILOS DE IMPRESIÓN / PDF --- */
@media print {
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

    body > *:not(#pdf-preview) { display: none !important; }
    #pdf-preview { display: block !important; }

    #pdf-preview { margin: 0; padding: 0; }
}

/* --- PREVIEW PDF --- */
#pdf-preview {
    display: none;
    font-family: 'Segoe UI', sans-serif;
    max-width: 800px;
    margin: 0 auto;
    padding: 2.5rem;
    background: white;
    color: #1e293b;
}

.pdf-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3px solid #4F46E5;
    padding-bottom: 1.2rem;
    margin-bottom: 1.5rem;
}

.pdf-logo { font-size: 1.4rem; font-weight: 800; color: #4F46E5; }
.pdf-logo span { color: #10B981; }
.pdf-meta { text-align: right; font-size: 0.82rem; color: #64748b; line-height: 1.6; }

.pdf-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    text-transform: capitalize;
    margin-bottom: 1.5rem;
}

.pdf-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.8rem;
}

.pdf-summary-card {
    background: #f8fafc;
    border-radius: 10px;
    padding: 1rem;
    border-left: 4px solid #e2e8f0;
}

.pdf-summary-card.ingreso  { border-left-color: #10B981; }
.pdf-summary-card.gasto    { border-left-color: #EF4444; }
.pdf-summary-card.saldo    { border-left-color: #4F46E5; }
.pdf-summary-card.ahorro   { border-left-color: #F59E0B; }

.pdf-card-label { font-size: 0.72rem; text-transform: uppercase; font-weight: 600; color: #94a3b8; letter-spacing: 0.5px; margin-bottom: 0.35rem; }
.pdf-card-value { font-size: 1.25rem; font-weight: 800; color: #1e293b; }
.pdf-card-value.green { color: #10B981; }
.pdf-card-value.red   { color: #EF4444; }
.pdf-card-value.blue  { color: #4F46E5; }

.pdf-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.5px;
    margin: 1.5rem 0 0.75rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid #e2e8f0;
}

.pdf-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.pdf-table th {
    background: #f1f5f9;
    padding: 0.5rem 0.75rem;
    text-align: left;
    font-weight: 600;
    color: #475569;
    font-size: 0.78rem;
}
.pdf-table td { padding: 0.5rem 0.75rem; border-bottom: 1px solid #f1f5f9; color: #334155; }
.pdf-table tr:last-child td { border-bottom: none; }
.pdf-table .amount { text-align: right; font-weight: 600; color: #EF4444; }
.pdf-table .amount.green { color: #10B981; }

.pdf-footer {
    margin-top: 2.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
    font-size: 0.72rem;
    color: #94a3b8;
    text-align: center;
}

/* --- BANNER PWA iOS --- */
.ios-banner {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 9999;
    padding: 0.75rem 1rem;
    background: #1e293b;
    border-top: 1px solid #334155;
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.ios-banner-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 600px;
    margin: 0 auto;
}

.ios-banner-icon { font-size: 1.6rem; flex-shrink: 0; }

.ios-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: white;
    font-size: 0.82rem;
    line-height: 1.4;
}

.ios-banner-text strong { font-size: 0.88rem; }
.ios-share-icon { font-size: 0.9rem; }

#ios-banner-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    flex-shrink: 0;
}

/* --- FONDO DE EMERGENCIA --- */
.emergency-intro {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 0.85rem 1rem;
    font-size: 0.875rem;
    color: #78350f;
    line-height: 1.5;
}

.months-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.4rem;
}

.month-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    color: #374151;
}

.month-btn:hover { border-color: #4F46E5; color: #4F46E5; }
.month-btn.active {
    border-color: #4F46E5;
    background: #4F46E5;
    color: white;
}

.emergency-result {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1.25rem;
    margin-top: 1rem;
    border: 1px solid #e2e8f0;
}

.emergency-result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 0.875rem;
    color: #374151;
    border-bottom: 1px dashed #e5e7eb;
}

.emergency-result-row.total {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1f2937;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.75rem;
    margin-bottom: 0.5rem;
}

.emergency-target {
    text-align: center;
    padding: 1rem 0 0.5rem;
}

.emergency-target-label {
    font-size: 0.78rem;
    color: #6b7280;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 0.4rem;
}

.emergency-target-amount {
    font-size: 2rem;
    font-weight: 800;
    color: #4F46E5;
    line-height: 1;
}

.emergency-progress-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.emergency-progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #6b7280;
    margin-bottom: 0.4rem;
    font-weight: 600;
}

.emergency-progress-bar-bg {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.emergency-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4F46E5, #10B981);
    border-radius: 99px;
    transition: width 0.6s ease;
}

.emergency-saved-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.emergency-advice {
    margin-top: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.emergency-advice.good {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.emergency-advice.mid {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.emergency-advice.bad {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.emergency-plan {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.emergency-plan-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 0.75rem;
}

.emergency-plan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.ef-plan-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    text-align: center;
}

.ef-plan-card .ef-plan-pct {
    font-size: 0.7rem;
    color: #6b7280;
    text-transform: uppercase;
    font-weight: 600;
}

.ef-plan-card .ef-plan-amount {
    font-size: 0.95rem;
    font-weight: 700;
    color: #4F46E5;
    margin-top: 2px;
}

.ef-plan-card .ef-plan-time {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 2px;
}

/* --- SELECTOR DE TEMAS --- */
.theme-selector-wrapper {
    padding: 1rem;
    border-top: 1px solid #f1f5f9;
    margin-top: 0.5rem;
}

.theme-selector-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.theme-swatches {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.theme-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: 2px solid transparent;
    border-radius: 10px;
    padding: 6px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.15s;
}

.theme-swatch:hover { transform: translateY(-2px); }
.theme-swatch.active { border-color: var(--primary-color); }

.theme-swatch span {
    display: block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.08);
}

.swatch-name {
    font-size: 0.62rem;
    color: #9ca3af;
    font-weight: 600;
    text-align: center;
}

.theme-swatch.active .swatch-name { color: var(--primary-color); }