/* ========================================= 
   1. VARIABLES & TEMAS (Paleta de Colores)
   ========================================= */
:root {
    /* --- TEMA PERSONAL (Base Blanca/Limpia) --- */
    --p-bg-main: #FFFFFF;          
    --p-bg-card: #F4F6FA;          
    --p-text-main: #0F172A;        
    --p-text-muted: #64748B;       
    --p-primary: #6366F1;          /* Indigo */
    --p-accent: #10B981;           /* Verde */

    /* --- TEMA EMPRESARIAL (Base Azulada/Seria) --- */
    --b-bg-main: #0B1220;          /* Dark Navy (más legible) */
    --b-bg-card: #111C2F;          /* Card dark (más pro, menos negro) */
    --b-text-main: #EAF2FF;        
    --b-text-muted: #A3B3CC;       
    --b-primary: #38BDF8;          /* Sky Blue */
    --b-accent: #34D399;           /* Verde Suave */
    --b-danger: #F87171;           /* Rojo Suave */

    /* --- DIMENSIONES Y RADIUS --- */
    --radius-card: 24px;
    --radius-btn: 16px;
    --shadow-soft: 0 12px 28px -12px rgba(15, 23, 42, 0.14);
    --border-soft: rgba(15, 23, 42, 0.08);
    --border-soft-dark: rgba(148, 163, 184, 0.14);
    --shadow-soft-dark: 0 18px 48px -18px rgba(0, 0, 0, 0.60);
    --focus-ring: 0 0 0 4px rgba(99, 102, 241, 0.25);
    --app-max-width: 480px; /* Variable para controlar el ancho máximo */
}

/* =========================================
   2. CONFIGURACIÓN BASE & SCROLLBARS
   ========================================= */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    margin: 0;
    padding: 0;
    transition: background-color 0.4s ease, color 0.4s ease;
    color: var(--text-primary);
    line-height: 1.4;
    letter-spacing: -0.01em;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    
    /* --- CORRECCIÓN PARA SIMULACIÓN --- */
    background-color: #e5e7eb; 
    
    /* 1. Usamos la altura exacta de la ventana */
    height: 100vh; 
    
    /* 2. Ocultamos el scrollbar "principal" del navegador */
    overflow: hidden; 
    
    /* 3. Centramos el celular perfectamente en el medio */
    display: flex;
    justify-content: center;
    align-items: center; 
}

/* --- SCROLLBARS VISIBLES Y ESTÉTICOS --- */
/* Estilo general para toda la app */
::-webkit-scrollbar {
    width: 6px;  /* Ancho vertical */
    height: 6px; /* Alto horizontal */
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.22);
    border-radius: 10px;
}
/* Scrollbar más sutil en modo oscuro */
body.mode-business ::-webkit-scrollbar-thumb {
    background: rgba(226, 232, 240, 0.26);
}

/* Modos de Color */
body.mode-personal {
    --bg-surface: var(--p-bg-card);
    --text-primary: var(--p-text-main);
    --text-secondary: var(--p-text-muted);
    --action-color: var(--p-primary);
    --app-bg: var(--p-bg-main);
    --border-soft: rgba(15, 23, 42, 0.08);
    --shadow-soft: 0 12px 28px -12px rgba(15, 23, 42, 0.14);
    --focus-ring: 0 0 0 4px rgba(99, 102, 241, 0.25);
}

body.mode-business {
    --bg-surface: var(--b-bg-card);
    --text-primary: var(--b-text-main);
    --text-secondary: var(--b-text-muted);
    --action-color: var(--b-primary);
    --app-bg: var(--b-bg-main);
    --border-soft: var(--border-soft-dark);
    --shadow-soft: var(--shadow-soft-dark);
    --focus-ring: 0 0 0 4px rgba(56, 189, 248, 0.22);
    background-color: #050814; /* Fondo escritorio oscuro */
}

/* =========================================
   3. LAYOUT & CONTENEDOR PRINCIPAL (PHONE FRAME)
   ========================================= */
.screen-container {
    width: 100%;
    max-width: var(--app-max-width);
    
    /* --- CORRECCIÓN DE ALTURA Y SCROLL --- */
    
    /* 1. Altura fija relativa a la pantalla */
    height: calc(100vh - 40px); 
    max-height: 850px; 
    
    /* 2. El scroll ocurre AQUÍ ADENTRO */
    overflow-y: auto; 
    overflow-x: hidden;
    
    /* 3. Estética de "Celular" */
    margin: 0 auto;
    border-radius: 35px; /* Bordes redondeados del dispositivo */
    background-color: var(--app-bg);
    position: relative; /* VITAL: Para que los modales se peguen aquí */
    box-shadow: 0 0 50px rgba(0,0,0,0.15); 
    
    padding: 20px;
    border: 1px solid var(--border-soft);
    background-image: radial-gradient(900px 600px at 10% 0%, rgba(99, 102, 241, 0.06), transparent 55%);

    padding-bottom: 120px;
}

body.mode-business .screen-container {
    border-color: var(--border-soft-dark);
    background-image: radial-gradient(900px 600px at 10% 0%, rgba(56, 189, 248, 0.10), transparent 55%),
                      radial-gradient(800px 520px at 95% 10%, rgba(52, 211, 153, 0.06), transparent 60%);
}

/* Logo */
.app-logo-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 18px;
    padding-top: 4px;
}

.app-logo {
    width: clamp(100px, 32vw, 140px);
    max-width: 60%;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 6px 12px rgba(15, 23, 42, 0.12));
}

.welcome-body .app-logo {
    width: clamp(120px, 40vw, 170px);
    max-width: 70%;
}

.profile-avatar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 30px;
}

.profile-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #E0E7FF;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar__emoji {
    font-size: 40px;
}

.profile-avatar__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

/* =========================================
   COMPONENTES UI GLOBALES
   ========================================= */
/* Tarjetas */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-card);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-soft);
    transition: transform 0.2s;
}
.card:active { transform: scale(0.98); }
body.mode-business .card { border-color: rgba(148, 163, 184, 0.14); }

/* Tipografía */
.text-h1 { font-size: clamp(26px, 5.5vw, 32px); font-weight: 850; margin: 0; letter-spacing: -0.04em; line-height: 1.08; }
.text-h2 { font-size: clamp(18px, 4.2vw, 22px); font-weight: 780; margin: 0 0 10px 0; letter-spacing: -0.02em; line-height: 1.15; }
.text-body { font-size: 16px; line-height: 1.65; }
.text-small { font-size: 12.5px; color: var(--text-secondary); font-weight: 550; }
.text-money { font-family: 'Roboto Mono', monospace; font-weight: 700; }

/* Botones */
.btn-primary {
    background-color: var(--action-color);
    color: #fff;
    width: 100%;
    padding: 18px;
    border: none;
    border-radius: var(--radius-btn);
    font-size: 16px;
    font-weight: 750;
    cursor: pointer;
    margin-top: 20px;
    box-shadow: 0 8px 20px -5px rgba(99, 102, 241, 0.35);
    transition: transform 0.1s, filter 0.2s;
    user-select: none;
}
.btn-primary:active { transform: scale(0.97); }
body.mode-business .btn-primary { color: #0F172A; box-shadow: 0 8px 20px -5px rgba(56, 189, 248, 0.25); }
.offer-btn--checkout {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 55%, #15803d 100%);
    box-shadow: 0 18px 36px rgba(34, 197, 94, 0.35);
}
.offer-btn--checkout:hover {
    filter: brightness(1.05);
}
/* Inputs */
.input-clean {
    background: transparent;
    border: none;
    border-bottom: 2px solid rgba(15, 23, 42, 0.10);
    color: var(--text-primary);
    font-size: 20px;
    width: 100%;
    padding: 12px 0;
    outline: none;
    transition: border-color 0.3s;
    border-radius: 0; 
    caret-color: var(--action-color);
}
.input-clean:focus { border-bottom-color: var(--action-color); }
.input-clean::placeholder { color: var(--text-secondary); opacity: 0.55; }
body.mode-business .input-clean { border-bottom-color: rgba(226, 232, 240, 0.16); }

/* Iconos */
.icon-box {
    width: 48px; height: 48px; min-width: 48px;
    background-color: var(--bg-surface);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
}
body.mode-business .icon-box { background-color: rgba(255,255,255, 0.1); }

/* --- FAB (BOTÓN FLOTANTE) --- */
.fab {
    position: fixed;
    bottom: 30px;
    left: 50%; 
    margin-left: 160px; /* Centrado relativo */
    
    width: 60px; height: 60px;
    background-color: var(--action-color);
    border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    color: white; font-size: 30px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.25);
    cursor: pointer;
    transition: transform 0.2s, background-color 0.4s;
    z-index: 90; 
}
.fab:active { transform: scale(0.9); }

/* Header */
.nav-header { display: flex; align-items: center; margin-bottom: 25px; color: var(--text-primary); }
.back-btn {
    font-size: 26px; margin-right: 15px;
    cursor: pointer; background: none; border: none;
    color: inherit; padding: 10px; margin-left: -10px;
}

/* =========================================
   4. HOME & LISTAS
   ========================================= */
.header-top { display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.home-header-intro {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.home-summary-line {
    display: flex;
    align-items: center;
    gap: 10px;
}
.home-summary-icon {
    font-size: 16px;
    opacity: 0.6;
}
.home-goal {
    color: var(--p-primary);
    margin-top: 4px;
}
.home-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.home-action-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
    font-size: 18px;
    border: 1px solid rgba(0,0,0,0.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.home-action-btn--primary {
    background: var(--p-primary);
    color: white;
    border: none;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
    font-family: serif;
}
.home-action-btn--secondary {
    background: var(--bg-surface);
}
.home-action-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.02);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}
.month-badge:hover {
    filter: brightness(1.03);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}
.fab:hover {
    filter: brightness(1.05);
    transform: translateY(-2px);
}
.month-badge {
    background-color: var(--bg-surface);
    padding: 8px 16px; border-radius: 20px;
    font-size: 13px; font-weight: 650;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap;
    border: 1px solid rgba(15, 23, 42, 0.06);
}
body.mode-business .month-badge { border-color: rgba(148, 163, 184, 0.16); background-color: rgba(255,255,255,0.06); }

@media (max-width: 480px) {
    .home-action-btn {
        width: 52px;
        height: 52px;
        font-size: 20px;
    }

    .month-badge {
        width: 100%;
        justify-content: space-between;
        padding: 10px 14px;
        font-size: 14px;
    }

    .header-top {
        gap: 16px;
    }
}

/* Transición divertida con logo al navegar */
.page-transition {
    position: fixed;
    inset: 0;
    background: rgba(248, 250, 252, 0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.3s ease;
}
.page-transition.is-active {
    opacity: 1;
    pointer-events: all;
}
.page-transition__logo {
    width: clamp(120px, 35vw, 180px);
    animation: logoPulse 0.9s ease-in-out infinite alternate;
    filter: drop-shadow(0 10px 18px rgba(15, 23, 42, 0.18));
}
@keyframes logoPulse {
    from { transform: scale(0.95) rotate(-2deg); }
    to { transform: scale(1.05) rotate(2deg); }
}
/* Switch Visual */
.switch-container {
    background-color: var(--bg-surface);
    border-radius: 30px; padding: 4px;
    display: flex; position: relative; margin-bottom: 24px;
    border: 1px solid rgba(0,0,0,0.05);
}
body.mode-business .switch-container { border: 1px solid rgba(255,255,255,0.1); }

.switch-btn {
    flex: 1; padding: 10px; text-align: center;
    font-size: 13px; font-weight: 700; z-index: 2;
    cursor: pointer; border: none; background: none;
    color: var(--text-secondary); transition: color 0.3s;
}
.switch-btn.active { color: var(--text-primary); }

.switch-bg {
    position: absolute; top: 4px; left: 4px;
    width: 50%; height: calc(100% - 8px);
    background-color: var(--app-bg); 
    border-radius: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
}
body.mode-business .switch-bg { background-color: rgba(56, 189, 248, 0.22); box-shadow: 0 10px 25px rgba(0,0,0,0.35); }

/* Transacciones */
.section-title {
    font-size: 18px; font-weight: 750;
    margin-bottom: 16px; margin-top: 30px;
    color: var(--text-primary);
    display: flex; justify-content: space-between; align-items: center;
}
.transaction-item {
    display: flex; align-items: center;
    padding: 16px 0; border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}
body.mode-business .transaction-item { border-bottom-color: rgba(148, 163, 184, 0.12); }
.trans-info { flex: 1; margin-left: 16px; overflow: hidden; }
.trans-cat { font-weight: 650; color: var(--text-primary); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trans-date { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.trans-amount { font-weight: 750; font-size: 15px; color: var(--text-primary); white-space: nowrap; }
.trans-amount.income { color: var(--p-accent); }
body.mode-business .trans-amount.income { color: var(--b-accent); }

/* =========================================
   5. INPUT SCREEN
   ========================================= */
.type-segment {
    display: flex; background-color: var(--bg-surface);
    border-radius: 16px; padding: 5px; margin-bottom: 30px;
    border: 1px solid rgba(15, 23, 42, 0.06);
}
body.mode-business .type-segment { border-color: rgba(148, 163, 184, 0.14); }

.type-btn {
    flex: 1; padding: 14px; text-align: center;
    border-radius: 12px; font-weight: 650; font-size: 14px;
    cursor: pointer; transition: all 0.2s; color: var(--text-secondary);
}
.type-btn.active.expense { background-color: var(--app-bg); color: var(--b-danger); box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.type-btn.active.income { background-color: var(--app-bg); color: var(--p-accent); box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
body.mode-business .type-btn.active.expense,
body.mode-business .type-btn.active.income { background-color: rgba(255,255,255,0.06); color: var(--b-text-main); border: 1px solid rgba(148, 163, 184, 0.14); }

.amount-wrapper { text-align: center; margin-bottom: 40px; }
.currency-symbol { font-size: 24px; color: var(--text-secondary); vertical-align: super; margin-right: 5px; }
.input-huge {
    font-size: clamp(36px, 15vw, 56px);
    font-weight: 850; width: 100%; text-align: center;
    border: none; background: transparent; color: var(--text-primary);
    outline: none; font-family: 'Roboto Mono', monospace; letter-spacing: -2px; padding: 0;
}

.cat-label { font-size: 14px; color: var(--text-secondary); margin-bottom: 15px; font-weight: 750; letter-spacing: 0.5px; text-transform: uppercase;}

.cat-grid {
    display: grid; 
    grid-template-columns: repeat(4, 1fr); /* Default 4 */
    gap: 15px; margin-bottom: 30px;
}
@media (max-width: 360px) {
    .cat-grid { grid-template-columns: repeat(3, 1fr); }
}

.cat-item {
    display: flex; flex-direction: column; align-items: center;
    cursor: pointer; opacity: 0.6; transition: all 0.2s;
}
.cat-item.selected { opacity: 1; transform: scale(1.05); }
.cat-item.selected .icon-box { background-color: var(--action-color); color: white; box-shadow: 0 5px 15px rgba(0,0,0,0.15); }
.cat-name { font-size: 11px; text-align: center; color: var(--text-primary); margin-top: 6px; line-height: 1.2; }

.invoice-card {
    background-color: var(--bg-surface); border-radius: 16px; padding: 16px;
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; border: 2px solid transparent; transition: all 0.3s;
    margin-bottom: 20px;
}
.invoice-card.active { border-color: var(--b-primary); background-color: rgba(56, 189, 248, 0.1); }
.check-circle {
    width: 24px; height: 24px; border-radius: 50%;
    border: 2px solid var(--text-secondary);
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.invoice-card.active .check-circle { background-color: var(--b-primary); border-color: var(--b-primary); color: var(--b-bg-main); }
.check-circle::after { content: '✓'; font-weight: bold; font-size: 14px; display: none; }
.invoice-card.active .check-circle::after { display: block; }

/* =========================================
   6. BUDGET & TABLAS
   ========================================= */
.month-nav { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; margin-bottom: 20px; }
.nav-arrow {
    width: 44px; height: 44px; border-radius: 50%;
    background-color: var(--bg-surface);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 18px; color: var(--text-primary);
    border: 1px solid rgba(15, 23, 42, 0.06);
}
body.mode-business .nav-arrow { border-color: rgba(148, 163, 184, 0.14); background-color: rgba(255,255,255,0.06); }

.month-title { font-size: 18px; font-weight: 750; color: var(--text-primary); }
.add-month-btn {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--bg-surface); color: var(--action-color);
    border: 1px dashed var(--action-color);
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; margin-left: 10px; cursor: pointer;
}

.summary-card {
    background-color: var(--action-color);
    border-radius: var(--radius-card); padding: 30px 20px;
    color: white; margin-bottom: 30px;
    display: flex; flex-direction: column; align-items: center; text-align: center;
    box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.35);
}
body.mode-business .summary-card {
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25);
    background-color: rgba(255,255,255,0.06); border: 1px solid rgba(56, 189, 248, 0.35);
}

.budget-list { display: flex; flex-direction: column; gap: 12px; }
.budget-row {
    background-color: var(--bg-surface); border-radius: 16px; padding: 16px;
    display: flex; align-items: center; justify-content: space-between;
    cursor: pointer; border: 1px solid transparent; transition: transform 0.1s;
}
.budget-row:active { transform: scale(0.98); }

.b-icon {
    width: 40px; height: 40px; background-color: var(--app-bg);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 20px; margin-right: 15px; flex-shrink: 0;
}
body.mode-business .b-icon { background-color: rgba(255,255,255,0.05); }

.b-info { flex: 1; min-width: 0; }
.b-name { font-weight: 650; font-size: 15px; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;}
.b-bar-bg { height: 6px; background-color: rgba(0,0,0,0.05); border-radius: 3px; margin-top: 8px; width: 100%; overflow: hidden; }
body.mode-business .b-bar-bg { background-color: rgba(255,255,255,0.1); }
.b-bar-fill { height: 100%; background-color: color-mix(in srgb, var(--action-color) 70%, var(--text-secondary)); width: 0%; transition: width 0.5s;}
.b-amount { font-weight: 750; color: var(--text-primary); font-size: 14px; }

@supports not (background: color-mix(in srgb, red 50%, white)) {
    .b-bar-fill { background-color: var(--action-color); }
}

/* =========================================
   7. MODALES (BOTTOM SHEETS) - CORREGIDO
   ========================================= */

/* El overlay debe cubrir TODA la pantalla visual del dispositivo (.screen-container) */
.overlay {
    position: fixed; /* Fixed para que no dependa del scroll del padre */
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    
    /* Centrado y limitado al ancho de la app en escritorio */
    max-width: var(--app-max-width);
    left: 50%;
    transform: translateX(-50%);
    
    /* Si la altura del body es menor (móvil), se adapta */
    background: rgba(2, 6, 23, 0.6); 
    z-index: 100; 
    backdrop-filter: blur(4px); 
    
    opacity: 0; 
    visibility: hidden; 
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    
    /* En escritorio, ajustamos la altura al contenedor simulado */
    height: calc(100vh - 40px);
    max-height: 850px;
    top: 50%;
    transform: translate(-50%, -50%);
    border-radius: 32px;
}

/* El modal se pega abajo del dispositivo */
.bottom-sheet {
    position: fixed;
    bottom: 50%; /* Punto de partida (se ajusta con transform) */
    left: 50%;
    width: 100%;
    max-width: var(--app-max-width);
    
    /* Ajuste fino para pegarlo al borde inferior del simulador */
    /* Calculamos: 50% viewport + mitad altura simulador - padding borde */
    transform: translate(-50%, calc(50vh + 425px)); /* Estado cerrado (muy abajo) */
    
    max-height: 80%; /* Un poco menos alto para seguridad */
    
    background-color: var(--app-bg);
    border-top-left-radius: 28px; 
    border-top-right-radius: 28px;
    
    padding: 26px 20px calc(24px + env(safe-area-inset-bottom)) 20px;
    box-sizing: border-box; 
    z-index: 101; 
    
    visibility: hidden;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.35s;
    
    overflow-y: auto; 
    display: flex; flex-direction: column;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.25);
    border-top: 1px solid var(--border-soft);
}

body.mode-business .bottom-sheet { 
    background-color: #0B1220; 
    border-top-color: rgba(255,255,255,0.1);
}

/* --- CLASE ACTIVA --- */
.sheet-active .overlay { 
    opacity: 1; 
    visibility: visible; 
    transition: opacity 0.3s ease, visibility 0s;
}

.sheet-active .bottom-sheet { 
    /* Estado Abierto: Lo colocamos visualmente en el bottom del contenedor simulado */
    /* El cálculo exacto depende de la altura de .screen-container */
    /* Usamos un truco: bottom: 20px (margen del container) */
    bottom: 20px; 
    transform: translate(-50%, 0); 
    
    visibility: visible; 
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
}

/* --- TRUCO VITAL: Bloquear scroll de fondo --- */
body.sheet-active .screen-container {
    overflow: hidden;
}

/* Elementos dentro del Modal */
.modal-type-switch {
    display: flex; background: var(--bg-surface);
    padding: 4px; border-radius: 12px; margin-bottom: 25px;
    border: 1px solid rgba(15, 23, 42, 0.06);
}
body.mode-business .modal-type-switch { border-color: rgba(148, 163, 184, 0.14); background: rgba(255,255,255,0.05); }

.m-switch-btn {
    flex: 1; padding: 10px; text-align: center;
    font-size: 13px; font-weight: 700; border-radius: 9px;
    cursor: pointer; color: var(--text-secondary);
    transition: all 0.2s;
}
.m-switch-btn.active { background-color: var(--app-bg); color: var(--text-primary); box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
body.mode-business .m-switch-btn.active { background-color: rgba(255,255,255,0.06); }

.icon-picker-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; font-weight: 650; }
.icon-scroll {
    display: flex; gap: 12px; overflow-x: auto; padding: 5px 5px 15px 5px; margin-bottom: 15px;
    scrollbar-width: auto; scroll-behavior: smooth;
}
.icon-scroll::-webkit-scrollbar { display: block; height: 6px; }

.icon-option {
    min-width: 56px; height: 56px; border-radius: 18px;
    background-color: var(--bg-surface);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; cursor: pointer; border: 2px solid transparent; transition: all 0.2s;
    flex-shrink: 0;
}
.icon-option.selected { transform: scale(1.1); box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.icon-option.income-style { background-color: #FFFBEB; border-color: #FCD34D; font-size: 28px; }
.icon-option.income-style.selected { background-color: #F59E0B; box-shadow: 0 5px 15px rgba(245, 158, 11, 0.3); border-color: transparent; }
.icon-option.expense-style { opacity: 0.7; filter: grayscale(20%); }
.icon-option.expense-style.selected { opacity: 1; filter: grayscale(0%); background-color: var(--text-primary); color: var(--bg-surface); }

.icon-help-text { text-align: center; font-size: 14px; color: var(--action-color); font-weight: 650; margin-bottom: 15px; opacity: 0; transition: opacity 0.3s; height: 20px; }
.icon-help-text.visible { opacity: 1; }

.flow-header {
    display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr;
    padding: 10px; font-size: 12px; color: var(--text-secondary);
    font-weight: 750; border-bottom: 1px solid rgba(0,0,0,0.1);
}
#flowRowsContainer { max-height: 400px; overflow-y: auto; padding-right: 5px; }
.flow-row {
    display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr;
    padding: 15px 10px; font-size: 13px; align-items: center;
    border-bottom: 1px solid var(--bg-surface);
}
.flow-cell { font-family: 'Roboto Mono', monospace; overflow: hidden; text-overflow: ellipsis; }
.flow-net { font-weight: 750; }
.net-positive { color: var(--p-accent); }
.net-negative { color: var(--b-danger); }

/* =========================================
   8. REPORTE TAX & GRAFICOS
   ========================================= */
.tax-receipt {
    background-color: var(--b-bg-card); border-radius: 20px;
    padding: 24px; border: 1px solid rgba(148, 163, 184, 0.14);
    margin-bottom: 20px; position: relative;
}
.receipt-divider { border-bottom: 2px dashed rgba(255,255,255,0.1); margin: 20px 0; }
.tax-detail-row { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 14px; color: var(--b-text-muted); }
.tax-detail-row.highlight { color: var(--b-text-main); font-weight: 650; font-size: 16px; margin-top: 10px; }
.tax-positive { color: var(--b-accent); }
.tax-negative { color: var(--b-danger); }

.igv-bar-container { height: 12px; background-color: rgba(255,255,255,0.1); border-radius: 6px; margin: 15px 0; display: flex; overflow: hidden; }

.rate-selector { display: flex; gap: 10px; margin-top: 10px; overflow-x: auto; padding-bottom: 5px; scrollbar-width: none; }
.rate-chip { padding: 8px 16px; border-radius: 20px; font-size: 13px; border: 1px solid rgba(255,255,255,0.2); color: var(--b-text-muted); cursor: pointer; transition: all 0.2s; white-space: nowrap; flex-shrink: 0; }
.rate-chip.active { background-color: var(--b-primary); color: var(--b-bg-main); border-color: var(--b-primary); font-weight: 750; }

.save-alert {
    background-color: rgba(248, 113, 113, 0.15); border-left: 4px solid var(--b-danger);
    padding: 15px; border-radius: 8px; font-size: 13px; color: #FCA5A5;
    margin-top: 20px; display: flex; align-items: center; gap: 10px;
}

.chart-container { display: flex; flex-direction: column; align-items: center; margin: 30px 0; position: relative; }
.donut-chart {
    width: 200px; height: 200px; border-radius: 50%;
    position: relative; display: flex; align-items: center; justify-content: center;
    background: conic-gradient(var(--p-primary) 0% 60%, #F59E0B 60% 85%, #EF4444 85% 100%);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}
.donut-hole {
    width: 160px; height: 160px; background-color: var(--app-bg);
    border-radius: 50%; display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 2;
    border: 1px solid rgba(15, 23, 42, 0.06);
}
body.mode-business .donut-hole { border-color: rgba(148, 163, 184, 0.14); }

.chart-legend { display: flex; justify-content: center; gap: 15px; margin-top: 20px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; font-size: 12px; color: var(--text-secondary); margin-bottom: 5px;}
.legend-dot { width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; }

.insight-card {
    background-color: #FEF2F2; border-left: 4px solid #EF4444;
    padding: 15px; border-radius: 12px; margin-bottom: 25px;
    display: flex; gap: 15px; align-items: flex-start;
}
.insight-icon { font-size: 24px; }

.btn-danger {
    background-color: transparent; color: var(--b-danger); border: 1px solid var(--b-danger);
    width: 100%; padding: 16px; border-radius: var(--radius-btn);
    font-size: 14px; font-weight: 750; cursor: pointer; margin-top: 15px; transition: all 0.2s;
}
.btn-danger:active { background-color: rgba(248, 113, 113, 0.1); }

/* =========================================
   MEDIA QUERY PARA MOVIL REAL
   (Cuando se ve en un celular de verdad, quitamos la "simulación")
   ========================================= */
@media (max-width: 480px) {
    body {
        height: auto;      
        overflow: auto;    
        display: block;    
    }
    .screen-container {
        height: auto;      
        max-height: none;
        overflow-y: visible;
        border-radius: 0;
        box-shadow: none;
        padding-bottom: 80px;
        margin: 0;
        /* En móvil real, no necesitamos 'relative' estricto para el modal */
    }
    .fab {
        left: auto;
        right: 20px;
        margin-left: 0;
    }
    
    /* MODALES EN MÓVIL REAL: Fixed para cubrir viewport real */
.overlay {
        position: fixed;
        width: 100%; height: 100%;
        max-width: none;
        top: 0; left: 0;
        transform: none;
        border-radius: 0;
        max-height: none;
    }
.bottom-sheet {
        position: fixed;
        bottom: 0; left: 0;
        width: 100%; max-width: none;
        transform: translateY(100%); /* Estado cerrado simple */
        border-radius: 28px 28px 0 0;
        max-height: 90vh;
    }
    
    .sheet-active .bottom-sheet {
        transform: translateY(0);
        bottom: 0;
    }
}

/* =========================================
   9. ACCESIBILIDAD & ESTADOS (FOCUS/HOVER)
   ========================================= */
a, button, input, .switch-btn, .type-btn, .cat-item, .budget-row, .transaction-item, .fab {
    outline: none;
}
a:focus-visible, button:focus-visible, input:focus-visible, .switch-btn:focus-visible, .type-btn:focus-visible, .fab:focus-visible {
    box-shadow: var(--focus-ring);
    border-radius: 14px;
}
@media (hover:hover) {
    .card:hover { transform: translateY(-1px); }
    .btn-primary:hover { filter: brightness(1.03); }
    .nav-arrow:hover, .month-badge:hover { filter: brightness(1.02); }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}
