html {
  /* Reduce el tamaño de fuente base para que los 'rem' no crezcan tanto.
     Puedes probar con valores entre 14px y 15.5px hasta que te guste el resultado. */
  font-size: 14.5px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ================================================================== */
/* === PALETA DE COLORES CORREGIDA (ESTILO SIIGO/ALEGRA) === */
/* ================================================================== */
:root {
    /* Paleta Dark (Modo Oscuro Profesional) */
    --primary-color: #0d6efd; /* Azul corporativo primario */
    --primary-hover: #0b5ed7;
    --success-color: #198754; /* Verde para éxito */
    --danger-color: #dc3545;  /* Rojo para peligro/cancelar */
    --warning-color: #ffc107; /* Amarillo para advertencia */
    
    --bg-gradient: linear-gradient(135deg, #1c1c1c 0%, #2a2a2a 100%);
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --header-bg: rgba(33, 37, 41, 0.85);
    --header-border: rgba(255, 255, 255, 0.1);
    --card-bg: #212529;
    --card-border: rgba(255, 255, 255, 0.15);
    --card-hover-border: var(--primary-color);
    --card-hover-shadow: 0 10px 30px rgba(13, 110, 253, 0.2);
    --input-bg: #343a40;
    --input-border: #495057;
    --input-focus-border: var(--primary-color);
    --input-focus-shadow: 0 0 15px rgba(13, 110, 253, 0.25);
    --logo-gradient: linear-gradient(45deg, #b12626, #0028ff);
    --hero-title-gradient: linear-gradient(45deg, #b12626, #0028ff);
    --hero-shadow: 0 0 50px rgba(13, 110, 253, 0.2);
    --particle-bg: rgba(13, 110, 253, 0.3);

    /* ✅ SOLUCIÓN: Variable de fondo para las vistas definida */
    --view-bg-color: #1c1c1c; 
}

/* === SCROLLBAR GLOBAL MÁS SUAVE Y MODERNA === */
html::-webkit-scrollbar, 
body::-webkit-scrollbar {
    width: 10px; /* Un poco más delgada */
}

html::-webkit-scrollbar-track, 
body::-webkit-scrollbar-track {
    background: #f4f5fb; /* Fondo gris súper clarito que combina con tu app */
}

html::-webkit-scrollbar-thumb, 
body::-webkit-scrollbar-thumb {
    background-color: #cbd5e1; /* Gris suave para la barra */
    border-radius: 10px;       /* Bordes redondeados */
    border: 2px solid #f4f5fb; /* Un borde del mismo color del fondo para que parezca flotar */
}

html::-webkit-scrollbar-thumb:hover, 
body::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8; /* Un gris un pelín más oscuro cuando le pasas el mouse */
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased; /* <-- El secreto para la elegancia */
    background: var(--bg-gradient);
    color: var(--text-primary);
    overflow-x: hidden;
    transition: background 0.5s ease, color 0.5s ease;
}

body, input, button, select, textarea {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif !important;
}
/* --- Estilos Modo Claro (Estilo Corporativo Limpio) --- */
body.light-mode {
    --bg-gradient: #f4f5fb; /* Fondo gris muy claro, casi blanco */
    --text-primary: #000000da; /* Texto oscuro para máxima legibilidad */
    --text-secondary: #060606be; /* Texto secundario gris */
    --header-bg: #ffffff;
    --header-border: #e5e7eb;
    --card-bg: #ffffff; /* Tarjetas blancas */
    --card-border: #e5e7eb;
    --card-hover-border: var(--primary-color);
    --card-hover-shadow: 0 10px 30px rgba(235, 238, 244, 0.1);
    --input-bg: #f7f7f7;
    --input-border: #ced4da;
    --input-focus-border: var(--primary-color);
    --input-focus-shadow: 0 0 15px rgba(13, 110, 253, 0.2);
    --logo-gradient: linear-gradient(45deg, #b12626, #0028ff);
    --hero-title-gradient: linear-gradient(45deg, #b12626, #0028ff);
    --hero-shadow: 0 0 50px rgba(13, 110, 253, 0.15);
    --particle-bg: rgba(13, 110, 253, 0.3);

    /* ✅ SOLUCIÓN: Variable de fondo para las vistas definida para el modo claro */
    --view-bg-color: #F6FBFF;
}

/* =============================================================== */
/* === FIN DE LA CORRECCIÓN DE LA PALETA DE COLORES === */
/* =============================================================== */


.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    z-index: 1010;
    transition: all 0.3s ease;
}

.nav {
    display: flex;
    justify-content: space-between; /* Alinea .nav-left y .nav-links */
    align-items: center;
    height: 100%;
    padding: 0 6.4rem;
    max-width: 2000px;
    margin: 0 auto;
}

/* === REGLAS DE ESTILO REINTRODUCIDAS PARA EL LOGO EN EL HEADER === */
/* Estas reglas solo se aplican cuando el logo está dentro de .nav-left */
.nav-left .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.nav-left .logo img {
    height: 45px;
    width: auto;
}


.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
}

body.light-mode .nav-link {
    color: var(--text-primary);
    font-weight: 500;
}

.nav-link:hover {
    color: var(--primary-color);
    transform: translateY(-2px);
}

body.light-mode .nav-link:hover {
    color: var(--primary-color);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

/* --- Theme Switcher --- */
.theme-switcher {
    position: relative;
    margin-left: 2rem;
}
.theme-switcher input {
    display: none;
}
.theme-switcher label {
    cursor: pointer;
    width: 50px;
    height: 26px;
    background: #343a40;
    display: block;
    border-radius: 50px;
    position: relative;
    transition: background 0.4s ease;
}
body.light-mode .theme-switcher label {
    background: #cbd5e1;
}
.theme-switcher label::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background-color: #f1f5f9;
    border-radius: 50%;
    transition: 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
.theme-switcher input:checked + label::after {
    transform: translateX(24px);
}
.theme-switcher .sun, .theme-switcher .moon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    transition: opacity 0.4s ease, transform 0.4s ease;
}
.theme-switcher .sun {
    left: 6px;
    opacity: 0;
    color: #f8f9fa; /* Color del ícono del sol */
}
.theme-switcher .moon {
    right: 6px;
    color: #f8f9fa; /* Color del ícono de la luna */
}
.theme-switcher input:checked + label .sun {
    opacity: 1;
    transform: translateY(-50%) rotate(15deg);
}
.theme-switcher input:checked + label .moon {
    opacity: 0;
    transform: translateY(-50%) rotate(-15deg);
}

/* =============================================================== */
/* === LÓGICA DE VISUALIZACIÓN DE VISTAS (CORREGIDO) === */
/* =============================================================== */
.page-view {
    display: none; /* Oculta todas las vistas por defecto */
    animation: fadeIn 0.5s ease-out;
    padding: 2rem 2rem 2rem;
}

@media (max-width: 768px) {
    .page-view {
        padding: 0;
    }
}
.page-view.active {
    display: block; /* Muestra solo la vista activa */
}

/* La vista 'hero' usa flexbox, así que necesita una regla especial */
#hero.page-view.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
/* =============================================================== */


.hero {
    min-height: 90vh;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 20%, rgba(13, 110, 253, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(13, 202, 240, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

body.light-mode .hero::before {
     background: radial-gradient(circle at 30% 20%, rgba(13, 110, 253, 0.08) 0%, transparent 60%),
                radial-gradient(circle at 70% 80%, rgba(13, 202, 240, 0.08) 0%, transparent 60%);
}

.hero-title {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 900;
    margin-bottom: 1rem;
    background: var(--hero-title-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: var(--hero-shadow);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.hero-subtitle {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    color: var(--text-secondary);
    max-width: 600px;
    line-height: 1.6;
    transition: color 0.5s ease;
}

.level-selector {
    display: flex;
    gap: 2rem;
    margin: 3rem 0;
    flex-wrap: wrap;
    justify-content: center;
}

.level-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 2rem;
    width: 300px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.level-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.6s ease;
}

body.light-mode .level-card::before {
     background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.03), transparent);
}

.level-card:hover {
    transform: translateY(-15px) scale(1.05);
    border-color: var(--card-hover-border);
    box-shadow: var(--card-hover-shadow);
}

.level-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #fff;
}

.basic .level-icon {
    background: linear-gradient(45deg, var(--success-color), #20c997);
}

.intermediate .level-icon {
    background: linear-gradient(45deg, var(--warning-color), #fd7e14);
}

.advanced .level-icon {
    background: linear-gradient(45deg, var(--primary-color), #3f86fc);
}

.level-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
    transition: color 0.5s ease;
}

.level-description {
    color: var(--text-secondary);
    line-height: 1.5;
    font-size: 0.95rem;
    transition: color 0.5s ease;
}

/* ======================================================================= */
/* === ✅ 1. ELIMINAR LÍMITES EXTERNOS FANTASMAS DE TODAS LAS VISTAS === */
/* ======================================================================= */
.page-view,
.balance-view,
.calendar-view,
.inventory-view,
.savings-view,
.cashflow-view,
.agenda-view,
.crm-view,
.form-view,
.analysis-report-view {
    max-width: none !important; /* Rompemos la jaula externa */
    width: 100% !important;
}

/* ======================================================================= */
/* === ✅ 2. TU CONTENEDOR PRINCIPAL ÚNICO (EL ÚNICO QUE MANDA) === */
/* ======================================================================= */
.main-view-container,
.analysis-container.main-view-container,
.cashflow-main-container,
.calendar-container.main-view-container,
.savings-container,
#inventory-view .main-view-container,
#cashflow-view .main-view-container,
#calendar-view .main-view-container,
#agenda-view .main-view-container,
#crm-view .main-view-container {
    background-color: var(--card-bg) !important; 
    padding: 2rem !important;
    border-radius: 20px !important;
    border: 1px solid var(--card-border) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.081) !important;
    
    /* 🔥 AQUÍ CONTROLAS EL ANCHO DE TODA LA APP (Cambia este valor si lo quieres más ancho o más angosto) */
    width: 100% !important;
    max-width: 1700px !important; 
    
    /* Centrado automático en la pantalla */
    margin: 0 auto 2rem auto !important; 
    
    box-sizing: border-box !important;
    position: relative !important;
}

.dashboard {
    /* min-height: 100vh; */ /* Removido para consistencia */
    padding: 100px 2rem 2rem;
}

.dashboard-header {
    text-align: center;
    padding: 2rem;
    margin-bottom: 1rem;
}

.dashboard-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.dashboard-header p {
     color: var(--text-secondary);
}

.back-btn {
    position: fixed;
    top: 100px;
    right: 2rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100;
    font-weight: 600;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: var(--input-focus-shadow);
}

body.light-mode .back-btn {
    background-color: var(--card-bg);
}

body.light-mode .back-btn:hover {
    background: #e9ecef;
}

.functions-grid {
    display: grid;
    /* Ajuste responsivo automático sin que las tarjetas se deformen */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 0 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.function-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px; /* Radio ligeramente más sobrio */
    padding: 1.5rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    /* Mantenemos la tarjeta estática y sólida */
    transform: none !important;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.function-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

body.light-mode .function-card:hover {
    border-color: var(--card-hover-border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.function-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

body.light-mode .function-title {
    color: var(--primary-color);
}

.function-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.floating-elements {
    display: none;
    position: fixed;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: -1;
}

.floating-element {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--particle-bg);
    border-radius: 50%;
    animation: float-particle 15s infinite linear;
}

@keyframes float-particle {
    0% {
        transform: translateY(100vh) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-100px) rotate(360deg);
        opacity: 0;
    }
}

.search-container {
    position: relative;
    max-width: 500px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.search-input {
    width: 100%;
    padding: 1rem 1.5rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 50px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.search-input:focus {
    border-color: var(--input-focus-border);
    box-shadow: var(--input-focus-shadow);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .level-selector {
        flex-direction: column;
        align-items: center;
    }
    
    .level-card {
        width: 100%;
        max-width: 350px;
    }
    
    .functions-grid {
        grid-template-columns: 1fr;
        padding: 0 1rem;
    }
    
    .nav {
        padding: 1rem;
    }
    
    .nav-links {
        gap: 1rem;
    }

    .dashboard {
        padding: 80px 1rem 1rem;
    }
}
/* === SECCIÓN DE LAYOUT ELIMINADA DE AQUÍ === */
/* Todas las reglas para .sidebar, .page-content, .hamburger-menu, etc., se han movido a layout.css */


/* === ✅ INICIO: NUEVOS ESTILOS PARA LAS VISTAS DE LECTURA === */
.reading-view {
    padding: 2rem;
}

.reading-container {
    max-width: 900px;
    margin: 2rem auto;
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 2rem 3rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05); /* --shadow-lg */
    position: relative;
}

.back-btn-reading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: absolute;
    top: 2rem;
    right: 3rem;
    background: var(--input-bg);
    color: var(--text-secondary);
    border: 1px solid var(--input-border);
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.back-btn-reading:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.reading-title {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    line-height: 1.3;
    max-width: 80%; /* Para no chocar con el botón de volver */
}

.reading-image {
    width: 100%;
    height: 350px;
    object-fit: cover;
    border-radius: 12px;
    margin-bottom: 2rem;
    border: 1px solid var(--card-border);
}

.reading-content {
    color: var(--text-secondary);
    font-size: 1.1rem;
    line-height: 1.8;
}

.reading-content p {
    margin-bottom: 1.5rem;
}

.reading-content h3 {
    color: var(--primary-color);
    font-size: 1.4rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    border-left: 3px solid var(--primary-color);
    padding-left: 1rem;
}

.reading-content ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 1.5rem;
}

.reading-content ul li {
    padding-left: 2rem;
    position: relative;
    margin-bottom: 1rem;
}

.reading-content ul li::before {
    content: '✓';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--success-color);
    font-weight: bold;
    font-size: 1.2rem;
}

@media (max-width: 768px) {
    .reading-container {
        padding: 1.5rem;
        margin: 1rem;
    }
    .back-btn-reading {
        position: static;
        margin-bottom: 1.5rem;
        width: 100%;
        justify-content: center;
    }
    .reading-title {
        font-size: 1.8rem;
        max-width: 100%;
    }
    .reading-image {
        height: 200px;
    }
}
/* === ✅ FIN: NUEVOS ESTILOS PARA LAS VISTAS DE LECTURA === */

/* ========================================================= */
/* === ESTILOS DEL REPORTE DIARIO (NUEVO DISEÑO AZUL/VERDE) === */
/* ========================================================= */

.report-modal-container {
    padding: 0 !important;
    background: #eef2f5 !important; 
    position: relative;
    display: flex;
    flex-direction: column;
    /* Cambiamos a dvh */
    height: 95dvh !important;       
    max-height: 95dvh !important;
    width: 100% !important;        
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important; 
    margin: 0;
    
    /* Añadimos protección contra parpadeos */
    will-change: transform;
    overscroll-behavior: none;
}

.report-close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: #666 !important;
    z-index: 100;
}

.report-scroll-wrapper {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;              /* Añadido para centrar */
    justify-content: center;    /* Añadido para centrar horizontalmente */
    align-items: flex-start;    /* Para que haga scroll correctamente y no se estire */
}

.report-print-area {
    background: #ffffff;
    width: 100%;
    max-width: 850px !important;   /* Evita que se estire demasiado en PC */
    margin: 0 auto !important;     /* Centra la hoja blanca horizontalmente */
    padding: 30px 40px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    border-radius: 8px;
    color: #333; 
}

/* === BOTÓN FLOTANTE DE DESCARGA === */
.floating-download-btn {
    position: absolute;
    bottom: 40px;
    right: 40px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.2s ease;
    z-index: 1000; /* Lo mantiene siempre por encima del texto */
}

.floating-download-btn:hover {
    transform: scale(1.1);
    background-color: var(--primary-hover);
}

.floating-download-btn .lucide {
    width: 26px;
    height: 26px;
    margin: 0; /* Quita márgenes heredados */
}

/* Ajuste para celular */
@media (max-width: 768px) {
    .floating-download-btn {
        bottom: 20px;
        right: 20px;
        width: 55px;
        height: 55px;
    }
}

/* Cabecera Azul Corporativo */
.report-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #1e3a8a; /* Azul Profundo */
    padding-bottom: 20px;
    margin-bottom: 25px;
}

.report-main-title {
    font-size: 2.2rem;
    font-weight: 900;
    color: #1e3a8a;
    margin: 0 0 5px 0;
}

.report-date-text { font-size: 1.1rem; color: #555; margin: 0; font-weight: bold; }
.report-logo { height: 50px; object-fit: contain; }

.report-section-title {
    font-size: 1.25rem;
    color: #1e3a8a;
    margin: 0 0 15px 0;
    font-weight: 800;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
}

/* Tablas */
.report-summary-table, .report-transactions-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.report-summary-table th, .report-transactions-table th {
    background-color: #f1f5f9;
    color: #334155;
    padding: 12px 15px;
    text-align: left;
    font-size: 0.95rem;
    border-bottom: 2px solid #cbd5e1;
}

.report-summary-table td, .report-transactions-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.95rem;
}

.report-highlight-row td {
    background-color: #f0fdf4 !important; /* Verde muy claro */
    font-size: 1.05rem;
    border-top: 1px solid #bbf7d0;
    border-bottom: 1px solid #bbf7d0;
}

/* Contenedor con Scroll para la tabla de transacciones */
.report-table-scroll-container {
    max-height: 300px; /* Limita la altura visual */
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 25px;
}

/* Mantiene el encabezado fijo al hacer scroll */
.report-transactions-table thead th {
    position: sticky;
    top: 0;
    z-index: 5;
    background-color: #f1f5f9; 
}

.val-income { color: #059669; font-weight: bold; text-align: right; } /* Verde Esmeralda */
.val-expense { color: #dc2626; font-weight: bold; text-align: right; } /* Rojo Suave */
.val-balance { color: #1e3a8a; font-weight: 900; text-align: right; }

/* Gráficas */
.report-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.report-chart-box {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    background: #ffffff;
}

.report-chart-title { text-align: center; font-size: 0.95rem; color: #475569; margin: 0 0 15px 0; font-weight: bold; }
.canvas-wrapper-report { position: relative; height: 200px; width: 100%; }

.report-modal-footer {
    padding: 15px 25px;
    background: #fff;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: center;       /* Centra los botones para que se vean simétricos */
    gap: 15px;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .report-print-area { padding: 20px 15px; }
    .report-header-flex { flex-direction: column; text-align: center; gap: 10px; }
    .report-charts-grid { grid-template-columns: 1fr; }
}

/* Forzar que el modal del reporte no tenga márgenes y se pegue al piso */
#daily-report-modal {
    padding: 0 !important;
    align-items: flex-end !important; 
}

/* Asegurar que el modal principal no genere scrolls extra */
.report-modal-container {
    max-height: 100vh !important;
    width: 100% !important;
    overflow: hidden !important; 
}

/* Previene el scroll horizontal en toda el área de impresión */
.report-print-area {
    box-sizing: border-box;
    max-width: 100%;
    overflow-x: hidden;
}

/* Evita que las gráficas rompan el ancho de su contenedor */
/* Gráficas con bordes más definidos y profesionales */
.report-chart-box {
    border: 1px solid #cbd5e1 !important; /* Gris pizarra un poco más oscuro y elegante */
    border-radius: 8px;
    padding: 15px;
    background: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03) !important; /* Sombra sutil para despegarlo del fondo */
    min-width: 0; 
    width: 100%;
    box-sizing: border-box;
}

.canvas-wrapper-report { 
    position: relative; 
    height: 200px; 
    width: 100%; 
    max-width: 100%;
}

/* =================================================================== */
/* === CORRECCIÓN DEFINITIVA: DISEÑO FLUIDO EN MÓVILES === */
/* =================================================================== */
@media (max-width: 768px) {
    /* 1. Unificar paddings en todas las vistas principales */
    .page-view {
        padding: 0 !important; 
    }
    
    /* Le pasamos la lista completa con los IDs para obligarlos a obedecer en móvil */
    .main-view-container,
    .analysis-container.main-view-container,
    .cashflow-main-container,
    .calendar-container.main-view-container,
    .savings-container,
    #inventory-view .main-view-container,
    #cashflow-view .main-view-container,
    #calendar-view .main-view-container,
    #agenda-view .main-view-container,
    #crm-view .main-view-container {
        /* MAGIA: Reducimos el padding drásticamente (1rem arriba/abajo, 0.6rem a los lados) */
        /* Esto lo dejará pegadito al borde pero con un ligerísimo respiro para que las letras no toquen el marco del teléfono */
        padding: 1rem 1rem !important; 
        margin: 0 !important; 
        border-radius: 0 !important; 
        border-left: none !important; 
        border-right: none !important;
        
        /* Evitamos que la caja crezca más que la pantalla y se salga */
        max-width: 100vw !important; 
        box-sizing: border-box !important;
        overflow-x: hidden;
    }

    /* 2. Solución al desbordamiento */
    .analysis-container, 
    .analysis-charts-grid, 
    .category-tables-grid {
        min-width: 0 !important; 
        width: 100% !important;
    }

    .table-wrapper-modal,
    .analysis-chart-container {
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: auto !important; /* Permite deslizar a los lados */
        -webkit-overflow-scrolling: touch; /* Deslizamiento suave en celulares */
    }
    
    /* Previene que el texto se vea borroso al abrir modales */
    .modal.is-open .modal-content {
        transform: translateY(0) translateZ(0);
        -webkit-font-smoothing: antialiased;
    }

    /* 3. Títulos más compactos */
    .analysis-header h2,
    .balance-header h2,
    .inventory-header h2 {
        font-size: 1.3rem !important; 
        flex-wrap: wrap !important;   
        width: 100%;
    }

    /* 4. Tarjetas de Resumen forzadas a 1 SOLA COLUMNA */
    #full-analysis-view .daily-stats-grid,
    .balance-content-view .daily-stats-grid {
        grid-template-columns: 1fr !important; 
        gap: 12px !important;
    }
    
    #full-analysis-view .daily-stat-card,
    .balance-content-view .daily-stat-card {
        flex-direction: row !important; 
        text-align: left !important;
        align-items: center !important;
        padding: 15px !important;
        width: 100%;
        box-sizing: border-box;
    }

    .stat-icon {
        width: 45px !important;
        height: 45px !important;
        margin: 0 !important;
        flex-shrink: 0;
    }

    .stat-details {
        width: calc(100% - 60px) !important;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }

    .stat-value {
        font-size: 1.35rem !important;
    }
    
    /* 5. Ajustes para modales en móvil */
    .modal-content.details-modal-container {
        border-radius: 15px 15px 0 0 !important; 
    }
    .balance-print-area {
        padding: 15px 10px; 
    }
}

/* =================================================================== */
/* === CORRECCIÓN FINAL: MODALES DE DETALLE Y REPORTE (HOJAS) === */
/* =================================================================== */

/* 1. Fondo gris asegurado para ambos contenedores principales */
.report-modal-container,
#weekly-details-modal .details-modal-container {
    /* CORRECCIÓN 1: Usamos % en lugar de vh/dvh. Esto es infalible en móviles */
    height: 95dvh !important;       
    max-height: 95dvh !important;
    width: 100% !important;        
    max-width: 100% !important;  
    border-radius: 20px 20px 0 0 !important; 
    margin: 0 !important;
    background-color: #eef2f5 !important;
    position: relative;
    overflow: hidden !important;
    
    /* CORRECCIÓN 2: Las líneas mágicas para que el contenido no empuje el modal hacia arriba */
    display: flex !important;
    flex-direction: column !important;
    
    /* Protección contra parpadeos */
    will-change: transform;
    overscroll-behavior: none;
}

/* 2. Diseño de la "Hoja Blanca" idéntico y centrado para ambos */
.report-print-area,
.balance-print-area {
    background: #ffffff !important;
    width: calc(100% - 24px) !important; /* Deja un margen limpio a los lados en celular */
    max-width: 900px !important;
    /* 50px de margen arriba para no chocar con la X */
    /* 90px de margen abajo para no chocar con el botón azul flotante */
    /*margin: 50px auto 90px auto !important;*/
    padding: 25px 20px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05) !important;
    border-radius: 16px !important;
}

/* 3. Desaparecer ABSOLUTAMENTE TODAS las barras de scroll internas molestas */
.report-scroll-wrapper::-webkit-scrollbar,
.details-modal-container::-webkit-scrollbar,
.table-wrapper-modal::-webkit-scrollbar,
.report-table-scroll-container::-webkit-scrollbar {
    display: none !important;
}

.report-scroll-wrapper,
.details-modal-container,
.table-wrapper-modal,
.report-table-scroll-container {
    -ms-overflow-style: none !important; /* Para IE y Edge */
    scrollbar-width: none !important;    /* Para Firefox */
}

/* =================================================================== */
/* === AJUSTE PERFECTO DE TABLAS EN MÓVIL (SIN DESBORDAMIENTO) === */
/* =================================================================== */
@media (max-width: 768px) {
    /* 1. Evitar que el centrado empuje el contenido hacia la izquierda fuera de la pantalla */
    .report-scroll-wrapper {
        justify-content: flex-start !important; 
    }

    /* 2. Reducir márgenes internos de la hoja para darle más espacio a la tabla */
    .report-print-area,
    .balance-print-area {
        padding: 20px 10px 20px 10px !important; 
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    /* 3. Hacer la tabla elástica y quitarle los anchos mínimos forzados (ej: 550px o 700px) */
    .report-transactions-table,
    #weekly-details-modal table {
        min-width: 100% !important; 
        width: 100% !important;
        font-size: 0.8rem !important; /* Letra un pelín más pequeña para que quepa bien */
    }

    /* 4. Restaurar espacios y mantener texto en 1 línea ya que ahora hay scroll horizontal */
    .report-transactions-table th, 
    .report-transactions-table td,
    #weekly-details-modal table th,
    #weekly-details-modal table td {
        padding: 12px 15px !important; 
        white-space: nowrap !important; /* Mantiene el texto en 1 sola línea */
        word-wrap: normal !important;
    }
    
}

/* =================================================================== */
/* === SCROLL HORIZONTAL PARA TABLAS EN MODALES (CELULAR) === */
/* =================================================================== */

.table-wrapper-modal,
.report-table-scroll-container,
.table-wrapper {
    width: 100%;
    overflow-x: auto !important; /* Fuerza el scroll horizontal */
    -webkit-overflow-scrolling: touch; /* Desplazamiento suave en iOS */
}

/* Asegurar que las tablas dentro de estos contenedores tengan un ancho mínimo para forzar el scroll si es necesario */
.table-wrapper-modal table,
.report-table-scroll-container table,
.table-wrapper table {
    min-width: 600px !important; /* Ajusta este valor según necesites */
    width: 100%;
}

@media (max-width: 768px) {
    /* Permitir scroll dentro del modal body/scroll wrapper pero ocultando la barra principal del modal */
    #weekly-details-modal .modal-body,
    .report-scroll-wrapper,
    .details-modal-container {
       overflow-x: hidden !important; /* Evita que todo el modal se mueva a los lados */
    }

    /* Asegurarse de que las tablas SÍ puedan hacer scroll horizontal */
    .table-wrapper-modal,
    .report-table-scroll-container,
    .table-wrapper {
        overflow-x: auto !important;
        /* IMPORTANTE: Desactivar la ocultación de scrollbars para estos contenedores en móvil si quieres que el usuario las vea */
        -ms-overflow-style: auto !important; 
        scrollbar-width: auto !important; 
    }
    
   /* Mostrar la barra de scroll sutilmente en móvil para estos contenedores */
    .table-wrapper-modal::-webkit-scrollbar,
    .report-table-scroll-container::-webkit-scrollbar,
    .table-wrapper::-webkit-scrollbar {
        display: block !important;
        height: 4px !important; /* <--- Barra más delgada y elegante */
    }
    .table-wrapper-modal::-webkit-scrollbar-thumb,
    .report-table-scroll-container::-webkit-scrollbar-thumb,
    .table-wrapper::-webkit-scrollbar-thumb {
        background-color: #cbd5e1;
        border-radius: 10px;
    }
}

/* ========================================================= */
/* === MODO ESTÁTICO: ELIMINAR ANIMACIONES (EXCEPTO MODALES) === */
/* ========================================================= */

/* 1. Eliminar animaciones de entrada (fadeIn) y elementos flotantes */
.page-view, 
.form-view, 
.options-dropdown,
.hero-title, 
.floating-element,
.agenda-card .agenda-details-panel,
.balance-content-view.active {
    animation: none !important;
}

/* 2. Congelar TODOS los saltos y escalas (Hover) en la aplicación entera */
/* -> Tarjetas, paneles y celdas */
.function-card:hover, 
.level-card:hover, 
.daily-stat-card:hover, 
.insight-column:hover, 
.insight-item:hover, 
.kpi-card:hover, 
.week-card:hover, 
.month-card:hover, 
.year-card:hover, 
.modern-breakdown-card:hover, 
.summary-card:hover,
.savings-goal-card:hover, 
.agenda-card:hover,
.calendar-day:hover,
/* -> Botones de acción principales y secundarios */
.btn-main-action:hover, 
.pdf-btn-main:hover, 
.btn-submit:hover,
.btn-add-contribution:hover, 
.save-btn:hover, 
.save-btn:hover:not(:disabled),
.pdf-btn-week:hover,
.template-btn:hover, 
.save-template-btn-solid:hover, 
.floating-download-btn:hover,
.modern-btn:hover, 
.modern-btn:hover:not(:disabled),
.view-details-btn:hover, 
.pdf-download-card:hover,
.btn-delete-item:hover, 
.btn-add-item:hover,
.options-menu-btn:hover,
/* -> Enlaces y botones de navegación */
.nav-link:hover, 
.back-btn:hover, 
.back-btn-reading:hover, 
.back-btn-form:hover,
.modal .close-btn:hover, 
.report-close-btn:hover {
    transform: none !important;
}

/* 3. Evitar que la línea decorativa del menú lateral se deslice */
.nav-link::after {
    transition: none !important;
}

/* ========================================================= */
/* === CORRECCIÓN PESTAÑAS ACTIVAS (BALANCE E INVENTARIO) === */
/* ========================================================= */

.balance-view-toggle button.active,
.balance-view-toggle button.active:hover,
.balance-view-toggle button.active:focus,
.balance-view-toggle button.active:active {
    background-color: rgb(0, 150, 136) !important; /* Mantiene tu azul verdoso intacto */
    color: #ffffff !important;
}

/* Evitar el parpadeo gris nativo que hacen los celulares al tocar un botón */
.balance-view-toggle button {
    -webkit-tap-highlight-color: transparent !important;
}

/* ========================================================= */
/* === CORRECCIÓN MENÚS DESPLEGABLES (TRES PUNTOS) === */
/* ========================================================= */

/* 1. Forzar que los menús ignoren cualquier efecto "hover" fantasma del celular */
.options-menu-container:hover .options-dropdown:not(.active),
.options-dropdown:hover:not(.active) {
    display: none !important; 
    opacity: 0 !important;
    visibility: hidden !important;
}

/* 2. El menú SOLO debe aparecer cuando tiene la clase .active (controlada por el toque/clic) */
.options-dropdown.active {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* 3. Asegurar que el menú flote por encima de todo sin parpadear al tocar una opción */
.options-dropdown {
    z-index: 9999 !important;
    pointer-events: auto !important;
}

/* 4. Evitar el parpadeo gris nativo de Android/iOS en estos botones específicos */
.options-menu-btn {
    -webkit-tap-highlight-color: transparent !important;
}

/* ========================================================= */
/* === DISEÑO TIPO "PÍLDORA" PARA EL SELECTOR DE NEGOCIOS == */
/* ========================================================= */
.business-selector-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--card-bg);
    padding: 6px 18px;
    border-radius: 50px; /* Hace que tenga forma de píldora redonda */
    border: 1px solid var(--card-border);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.business-selector-container:hover {
    box-shadow: 0 4px 15px rgba(13, 110, 253, 0.12); /* Brillo azul sutil al pasar el mouse */
    border-color: rgba(13, 110, 253, 0.4);
}

.business-selector-container select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-weight: 700;
    outline: none;
    cursor: pointer;
    max-width: 150px;
    font-family: inherit;
    font-size: 0.95rem;
}

.business-selector-container button {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: bold;
    transition: transform 0.2s ease;
}

.business-selector-container button:hover {
    transform: scale(1.1); /* Efecto de rebote al tocar los botones */
}

.business-divider {
    width: 1px;
    height: 24px;
    background: var(--input-border);
    margin: 0 4px;
}

/* ========================================================= */
/* === ESTILOS RESPONSIVOS PARA EL GESTOR DE NEGOCIOS === */
/* ========================================================= */

@media (min-width: 769px) {
    /* Centrado vertical perfecto en escritorio */
    .business-modal {
        align-items: center !important; 
    }
    
    /* Más ancho, altura dinámica y bordes curvos completos */
    .business-modal-content {
        max-width: 800px !important; 
        height: auto !important; 
        min-height: 500px;
        border-radius: 20px !important; 
    }
}

/* Contenedor del logo para que ícono y texto queden perfectamente alineados */
.logo {
    display: flex;
    align-items: center;
    gap: 12px; /* Separación ideal entre la P y el texto */
    text-decoration: none;
    border: none;
    outline: none;
}

.logo-text-prospera {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.4rem;
    font-weight: 800; /* Extra negrita para darle fuerza al logo */
    letter-spacing: 1px; /* Reducimos un poco el espaciado para un look más moderno */
    color: #000000;
    text-transform: uppercase;
    margin-top: 4px;
}