:root {
    --primary-color: #009fe3; /* Azul Cyan del logo */
    --primary-dark: #007bb5;
    --secondary-color: #b2d235; /* Verde Manzana del logo */
    --secondary-dark: #8da62a;
    --dark-bg: #1a1a1a;
    --dark-panel: #2a2a2a;
    --text-main: #333333;
    --text-muted: #777777;
    --bg-body: #f4f7f6;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    font-size: 14px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow);
    border-radius: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* ==========================================================================
   TOP HORIZONTAL NAVBAR (Departamental)
   ========================================================================== */
.top-navbar {
    background: #379A7C;
    background: linear-gradient(180deg, #3ea888 0%, #379A7C 100%);
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 3px 14px rgba(43, 122, 98, 0.25);
    border-bottom: 1px solid #2b7a62;
}

.nav-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    padding: 0 16px;
    width: 100%;
    box-sizing: border-box;
    gap: 10px;
}

.nav-brand-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.nav-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.32);
    color: #ffffff;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}
.nav-back-btn:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.5);
    color: #ffffff;
    transform: translateX(-2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.nav-back-btn:active {
    transform: scale(0.96);
}
.nav-back-btn i {
    font-size: 0.85rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    font-size: 1.15rem;
    font-weight: 800;
    color: #ffffff;
    flex-shrink: 0;
}

.nav-brand .brand-title {
    color: #ffffff;
}

.nav-brand .brand-accent {
    color: #e2f952;
}

.nav-brand .brand-badge {
    font-size: 0.60rem;
    font-weight: 700;
    background: #1e293b;
    color: #ffffff;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.nav-mobile-toggle {
    display: none;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
}

.mobile-drawer-header,
.mobile-drawer-meta {
    display: none !important;
}

.nav-menu-wrapper {
    display: flex;
    align-items: center;
    flex: 1;
    margin-left: 8px;
}

.nav-menu {
    display: flex;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 3px;
    height: 100%;
}

.nav-item {
    position: relative;
    list-style: none;
    height: 100%;
    display: flex;
    align-items: center;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 11px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.94);
    font-weight: 600;
    font-size: 0.83rem;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}

.nav-link:hover, 
.nav-dropdown-parent:hover .nav-link,
.nav-item.open .nav-link {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.18);
}

.nav-item.active .nav-link {
    color: #1e5c49 !important;
    background: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.nav-item.active .nav-link:hover {
    color: #134e3d !important;
    background: #f8fafc !important;
}

.nav-item.active .nav-caret {
    color: #1e5c49;
    opacity: 0.9;
}

.nav-caret {
    font-size: 0.60rem;
    margin-left: 2px;
    transition: transform 0.2s ease;
    opacity: 0.85;
}

.nav-item.open .nav-caret,
.nav-dropdown-parent:hover .nav-caret {
    transform: rotate(180deg);
}

/* Menú Desplegable */
.nav-dropdown-parent {
    position: relative;
}

.nav-dropdown-parent::after {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 0;
    right: 0;
    height: 15px;
    display: block;
    background: transparent;
}

.nav-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 235px;
    max-height: calc(100vh - 65px);
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 14px 35px -5px rgba(15, 23, 42, 0.16), 0 6px 16px -6px rgba(15, 23, 42, 0.08);
    padding: 8px 4px;
    display: none;
    z-index: 1100;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.nav-dropdown-menu::-webkit-scrollbar {
    width: 6px;
}
.nav-dropdown-menu::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 8px;
}
.nav-dropdown-menu::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.nav-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color, #009fe3);
}

/* Mega Menú en Columnas */
.nav-dropdown-menu.nav-mega-menu {
    min-width: auto;
    padding: 10px 8px;
}

.mega-menu-cols {
    display: flex;
    flex-direction: row;
    gap: 0;
}

.mega-col {
    min-width: 220px;
    display: flex;
    flex-direction: column;
}

.mega-col + .mega-col {
    border-left: 1px solid #e2e8f0;
}

.nav-dropdown-parent:hover .nav-dropdown-menu,
.nav-dropdown-parent.open .nav-dropdown-menu {
    display: block;
    animation: navMenuFadeIn 0.15s ease-out;
}

@keyframes navMenuFadeIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
    padding: 8px 14px 4px;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #24755c;
    letter-spacing: 0.6px;
}

.dropdown-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 6px 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 12px;
    margin: 1px 4px;
    border-radius: 6px;
    color: #334155;
    font-size: 0.83rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.15s ease;
}

.dropdown-item:hover {
    background: #ecfdf5;
    color: #1e5c49;
    padding-left: 16px;
}

.dropdown-item.active {
    background: #d1fae5;
    color: #065f46;
    font-weight: 700;
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    font-size: 0.88rem;
    color: #64748b;
    transition: color 0.15s ease;
}

.dropdown-item:hover i,
.dropdown-item.active i {
    color: #24755c;
}

.dropdown-item.logout-link {
    color: #dc2626;
}

.dropdown-item.logout-link i {
    color: #dc2626;
}

.dropdown-item.logout-link:hover {
    background: #fef2f2;
    color: #b91c1c;
}
.dropdown-item.logout-link:hover i {
    color: #b91c1c;
}

/* Herramientas y Usuario (Derecha) */
.nav-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.info-badge {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #1e293b;
    padding: 5px 10px;
    border-radius: 16px;
    font-size: 0.76rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.info-badge.bcv {
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #cbd5e1;
}

.info-badge.bcv i {
    color: #f59e0b;
}

.info-badge.clock {
    color: #24755c;
}

/* Botón Pantalla Completa en Barra Superior */
.btn-fullscreen-toggle {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.32);
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-fullscreen-toggle:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.5);
    color: #ffffff;
    transform: scale(1.05);
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.user-pill:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.user-pill i.fa-user-circle {
    font-size: 1.3rem;
    color: #379A7C;
}

.user-pill-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.user-name {
    font-size: 0.78rem;
    font-weight: 700;
    color: #0f172a;
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.62rem;
    color: #24755c;
    font-weight: 700;
}

.user-pill-caret {
    font-size: 0.65rem;
    color: #64748b;
    transition: transform 0.2s ease;
}

.nav-user-dropdown-parent {
    position: relative;
}

.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 190px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    box-shadow: 0 14px 35px -5px rgba(15, 23, 42, 0.16);
    padding: 6px 0;
    display: none;
    z-index: 1100;
}

.user-dropdown-menu::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 0;
    right: 0;
    height: 15px;
    display: block;
    background: transparent;
}

.nav-user-dropdown-parent:hover .user-dropdown-menu,
.nav-user-dropdown-parent.open .user-dropdown-menu {
    display: block;
    animation: navMenuFadeIn 0.15s ease-out;
}

.user-dropdown-header {
    padding: 10px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    color: #0f172a;
}
.user-dropdown-header div strong {
    color: #0f172a;
}
.user-dropdown-header div div {
    color: #64748b !important;
}

/* Main Content Area (Full Width) */
.main-content {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Content Wrapper */
.content-wrapper {
    padding: 14px 18px;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

/* Cards & Dashboards */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    padding: 25px;
    border-left: 5px solid var(--primary-color);
    display: flex;
    flex-direction: column;
}

.stat-card.green {
    border-left-color: var(--secondary-color);
}

.stat-card h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Tables */
.table-container, .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-top: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.data-table th, .data-table td {
    padding: 7px 9px;
    font-size: 0.82rem;
}

th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--text-main);
}

tbody tr:hover {
    background-color: #f1f5f9;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--secondary-dark);
    transform: translateY(-2px);
}

/* ==========================================================================
   OPTIMIZACIONES PARA CELULAR Y TABLET (RESPONSIVE SUITE)
   ========================================================================== */

/* 1. TABLETS Y PANTALLAS TÁCTILES (Hasta 1100px) */
@media (max-width: 1100px) {
    .top-navbar {
        height: 54px;
    }
    
    .nav-container {
        height: 54px;
        padding: 0 12px;
        gap: 8px;
    }

    .nav-brand-group {
        gap: 6px;
    }

    .nav-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border-radius: 8px;
        background: rgba(255, 255, 255, 0.18);
        border: 1px solid rgba(255, 255, 255, 0.35);
        color: #ffffff;
        font-size: 1.15rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    .nav-mobile-toggle:active {
        background: rgba(255, 255, 255, 0.3);
        transform: scale(0.95);
    }

    .nav-brand .brand-title {
        font-size: 1.05rem;
    }
    .nav-brand .brand-badge {
        font-size: 0.55rem;
        padding: 1px 4px;
    }

    .nav-tools {
        gap: 6px;
        display: flex;
        align-items: center;
    }
    .nav-tools .clock {
        display: none !important;
    }

    .btn-notification-bell {
        width: 32px;
        height: 32px;
        font-size: 0.85rem;
    }

    .info-badge.bcv {
        display: flex !important;
        align-items: center;
        gap: 4px;
        background: #ffffff;
        border: 1px solid #cbd5e1;
        color: #0f172a;
        padding: 3px 8px;
        border-radius: 14px;
        font-size: 0.74rem;
        font-weight: 700;
        white-space: nowrap;
    }

    .notification-dropdown-menu {
        position: fixed !important;
        top: 56px !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: calc(100vw - 20px) !important;
        border-radius: 12px !important;
        box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25), 0 0 0 1px #cbd5e1 !important;
        z-index: 99999 !important;
    }

    .user-pill {
        padding: 0;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #ffffff;
        border: 1px solid #cbd5e1;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    }
    .user-pill i.fa-user-circle {
        font-size: 1.45rem;
        color: #379A7C;
        margin: 0;
    }
    .user-pill-text {
        display: none !important;
    }
    .user-pill-caret {
        display: none !important;
    }
    .user-dropdown-menu {
        right: 8px;
        min-width: 200px;
        top: 56px;
    }

    /* Cajón de navegación lateral / pantalla completa táctil */
    .nav-menu-wrapper {
        display: none;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        width: 100vw !important;
        height: 100% !important;
        height: 100dvh !important;
        max-height: 100% !important;
        background: #ffffff !important;
        overflow-y: scroll !important; /* Fuerza contexto nativo de desplazamiento en Android/iOS */
        -webkit-overflow-scrolling: touch !important;
        touch-action: pan-y !important;
        padding: max(16px, env(safe-area-inset-top, 16px)) 16px max(140px, calc(100px + env(safe-area-inset-bottom, 30px))) !important;
        z-index: 999999 !important;
        box-sizing: border-box !important;
    }
    .nav-menu-wrapper.mobile-open {
        display: block !important;
        animation: navMenuFadeIn 0.2s ease-out;
    }
    .nav-menu-wrapper * {
        touch-action: pan-y !important;
    }

    .mobile-drawer-header {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 14px;
        margin-bottom: 12px;
        border-bottom: 1px solid #e2e8f0;
    }
    .mobile-user-card {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .mobile-user-avatar {
        font-size: 2.2rem;
        color: #379A7C;
    }
    .mobile-user-info strong {
        display: block;
        font-size: 0.95rem;
        color: #0f172a;
        font-weight: 700;
    }
    .mobile-user-info span {
        font-size: 0.78rem;
        color: #64748b;
    }
    .mobile-drawer-close {
        background: #f1f5f9;
        border: 1px solid #cbd5e1;
        color: #0f172a;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.15rem;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    .mobile-drawer-close:active {
        background: #e2e8f0;
        transform: scale(0.95);
    }

    .mobile-drawer-meta {
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 16px;
        padding-bottom: 12px;
        border-bottom: 1px solid #e2e8f0;
    }
    .mobile-action-chip {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: #f0fdf4;
        border: 1px solid #bbf7d0;
        color: #166534;
        padding: 7px 12px;
        border-radius: 16px;
        font-size: 0.80rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    .mobile-action-chip.pwa-install {
        background: #f7fee7;
        border-color: #bef264;
        color: #4d7c0f;
    }
    .mobile-action-chip:active {
        transform: scale(0.96);
    }
    .mobile-logout-btn {
        background: #fef2f2;
        color: #dc2626;
        border: 1px solid #fecaca;
        padding: 7px 14px;
        border-radius: 16px;
        font-size: 0.80rem;
        font-weight: 600;
        text-decoration: none;
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .nav-menu {
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
        margin: 0 !important;
        padding: 0 0 50px 0 !important;
        list-style: none !important;
        touch-action: pan-y !important;
    }
    .nav-item {
        width: 100% !important;
        height: auto !important;
        display: block !important;
        touch-action: pan-y !important;
    }
    /* Enlaces y Títulos de Departamento en el Cajón Móvil */
    .nav-link,
    .nav-menu .nav-link,
    .nav-dropdown-parent .nav-link {
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 12px !important;
        padding: 12px 14px !important;
        font-size: 0.95rem !important;
        font-weight: 600 !important;
        background: #f8fafc !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 8px !important;
        color: #1e293b !important;
        box-sizing: border-box !important;
        box-shadow: none !important;
        text-decoration: none !important;
        cursor: pointer !important;
    }

    /* Ícono principal del departamento */
    .nav-link > i:first-child,
    .nav-menu .nav-link > i:first-child {
        font-size: 1.15rem !important;
        color: #379A7C !important;
        width: 22px !important;
        text-align: center !important;
        flex-shrink: 0 !important;
    }

    /* Texto del título del departamento */
    .nav-link > span,
    .nav-menu .nav-link > span {
        color: #1e293b !important;
        font-size: 0.95rem !important;
        font-weight: 700 !important;
        flex: 1 !important;
        text-align: left !important;
        white-space: normal !important;
    }

    /* Flecha / Caret indicadora de despliegue */
    .nav-link .nav-caret,
    .nav-caret {
        margin-left: auto !important;
        font-size: 0.85rem !important;
        color: #64748b !important;
        transition: transform 0.22s ease !important;
        opacity: 1 !important;
        flex-shrink: 0 !important;
    }

    /* Estado Hover / Focus táctil */
    .nav-link:hover,
    .nav-link:focus,
    .nav-link:active,
    .nav-dropdown-parent:hover .nav-link {
        background: #f1f5f9 !important;
        border-color: #cbd5e1 !important;
    }
    .nav-link:hover > span,
    .nav-link:focus > span,
    .nav-link:active > span,
    .nav-dropdown-parent:hover .nav-link > span {
        color: #0f172a !important;
    }

    /* Estado Desplegado / Abierto (Acordeón) */
    .nav-item.open .nav-link,
    .nav-dropdown-parent.open .nav-link {
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        background: #f1f5f9 !important;
        border-color: #cbd5e1 !important;
    }
    .nav-item.open .nav-link > span,
    .nav-dropdown-parent.open .nav-link > span {
        color: #0f172a !important;
    }
    .nav-item.open .nav-link > i:first-child,
    .nav-dropdown-parent.open .nav-link > i:first-child {
        color: #24755c !important;
    }
    .nav-dropdown-parent.open .nav-caret,
    .nav-item.open .nav-caret {
        transform: rotate(180deg) !important;
        color: #24755c !important;
    }

    /* Estado Activo (Módulo actual en el que está el usuario) */
    .nav-item.active .nav-link,
    .nav-dropdown-parent.active .nav-link {
        background: #ecfdf5 !important;
        border-color: #a7f3d0 !important;
        box-shadow: none !important;
    }
    .nav-item.active .nav-link > span,
    .nav-dropdown-parent.active .nav-link > span {
        color: #065f46 !important;
    }
    .nav-item.active .nav-link > i:first-child,
    .nav-dropdown-parent.active .nav-link > i:first-child {
        color: #065f46 !important;
    }
    .nav-item.active .nav-caret {
        color: #065f46 !important;
    }

    /* Estado Activo Y Abierto a la vez */
    .nav-item.active.open .nav-link,
    .nav-dropdown-parent.active.open .nav-link {
        background: #d1fae5 !important;
        border-color: #6ee7b7 !important;
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
    }
    .nav-item.active.open .nav-link > span,
    .nav-dropdown-parent.active.open .nav-link > span {
        color: #064e3b !important;
    }
    .nav-item.active.open .nav-link > i:first-child,
    .nav-dropdown-parent.active.open .nav-link > i:first-child {
        color: #064e3b !important;
    }
    .nav-item.active.open .nav-caret,
    .nav-dropdown-parent.active.open .nav-caret {
        transform: rotate(180deg) !important;
        color: #064e3b !important;
    }

    /* Submenús en formato Acordeón en el cajón */
    .nav-dropdown-menu,
    .nav-dropdown-menu.nav-mega-menu {
        position: static !important;
        display: none;
        box-shadow: none !important;
        border: 1px solid #e2e8f0 !important;
        border-top: none !important;
        background: #ffffff !important;
        margin-top: 0 !important;
        padding: 8px 6px 16px !important;
        border-bottom-left-radius: 8px !important;
        border-bottom-right-radius: 8px !important;
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
        overflow-y: visible !important;
        overscroll-behavior: auto !important;
        min-width: 100% !important;
        width: 100% !important;
        touch-action: pan-y !important;
    }
    .nav-dropdown-parent.open .nav-dropdown-menu {
        display: block !important;
        animation: navMenuFadeIn 0.2s ease-out;
    }
    .mega-menu-cols {
        flex-direction: column !important;
        gap: 8px;
        touch-action: pan-y !important;
    }
    .mega-col {
        min-width: 100% !important;
        touch-action: pan-y !important;
    }
    .mega-col + .mega-col {
        border-left: none !important;
        border-top: 1px solid #e2e8f0 !important;
        padding-top: 8px !important;
        margin-top: 8px !important;
    }
    .dropdown-item {
        padding: 10px 14px !important;
        font-size: 0.90rem !important;
        min-height: 42px;
        border-radius: 6px;
        margin: 2px 0;
    }
    .dropdown-header {
        padding: 10px 14px 4px !important;
        font-size: 0.72rem !important;
    }
}

/* 2. CELULARES Y TABLETS MEDIANAS (Hasta 768px) */
@media (max-width: 768px) {
    /* Prevención del zoom automático molesto en iOS Safari/Chrome */
    input, select, textarea, .form-control {
        font-size: 16px !important;
        min-height: 40px;
        box-sizing: border-box;
    }

    .content-wrapper {
        padding: 10px 8px !important;
    }

    .glass-panel {
        padding: 14px 12px !important;
        border-radius: 10px !important;
        margin-bottom: 14px !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Grids en Formularios apilados verticalmente */
    div[style*="grid-template-columns: 2.2fr 1fr"],
    div[style*="grid-template-columns: 2fr 1fr 1fr"],
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr 1fr"],
    div[style*="grid-template-columns: 1fr 2fr"],
    div[style*="grid-template-columns: 3fr 1fr"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Formularios Flex apilados verticalmente */
    form[style*="display: flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .form-row, .order-section .form-row {
        flex-direction: column !important;
        gap: 10px !important;
    }

    /* Barras de Filtros fluidas en columna */
    .filter-bar, .cxc-filter-grid {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
        padding: 12px 14px !important;
    }

    .filter-bar .filter-group, .cxc-filter-grid > * {
        width: 100% !important;
        min-width: 100% !important;
    }

    .filter-bar .btn, .filter-bar button {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Pestañas / Tabs horizontales con desplazamiento táctil sin salto de línea */
    .cxc-tabs, .nav-tabs, .tabs-container {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        flex-wrap: nowrap !important;
        padding-bottom: 4px !important;
        scrollbar-width: thin;
    }

    .cxc-tab-btn, .nav-tabs > li, .nav-tabs .nav-link {
        flex-shrink: 0 !important;
        white-space: nowrap !important;
    }

    /* Tablas con scroll horizontal suave sin romper anchos de columnas */
    .table-container, .table-responsive, .detalles-container, .table-wrapper {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .data-table, table.detalles, table.items, table.table-striped, .table-responsive > table, table:not(.table-summary):not(.kpi-table) {
        min-width: 620px;
    }

    /* Botones de acción en tablas cómodos al tacto */
    .data-table td a.btn, 
    .data-table td button.btn,
    table td a.btn,
    table td button.btn {
        min-height: 36px;
        min-width: 36px;
        padding: 6px 10px !important;
        margin: 2px 1px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.90rem !important;
        border-radius: 6px;
    }

    /* Modales adaptados a pantalla completa móvil en todos los módulos */
    .modal-overlay, .modal-caja, .modal-backdrop {
        padding: 8px !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 999999 !important;
    }

    .modal-dialog, .modal-content, .modal-caja > div, .modal-box, .modal-card, [class*="modal-dialog"], [class*="modal-content"] {
        width: 96% !important;
        max-width: 96% !important;
        margin: auto !important;
        max-height: 92vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 16px 12px !important;
        border-radius: 12px !important;
        box-sizing: border-box !important;
    }

    .invoice-box {
        padding: 12px !important;
        font-size: 13px !important;
        line-height: 20px !important;
    }
    .invoice-box table {
        font-size: 12px !important;
    }
    .invoice-box .title {
        font-size: 18px !important;
    }
}

/* 3. CELULARES COMPACTOS (Hasta 576px) */
@media (max-width: 576px) {
    .top-navbar {
        height: 50px;
    }
    .nav-container {
        height: 50px;
        padding: 0 8px;
        gap: 4px;
    }
    .nav-brand-group {
        gap: 4px;
    }
    .nav-mobile-toggle {
        width: 32px;
        height: 32px;
        font-size: 1.05rem;
    }

    /* Ocultar texto "Volver" y dejar solo la flecha en pantallas chicas */
    .nav-back-btn {
        padding: 5px 8px;
    }
    .nav-back-btn span {
        display: none !important;
    }

    .nav-brand .brand-title {
        font-size: 0.94rem;
    }
    .nav-brand .brand-badge {
        font-size: 0.50rem;
        padding: 1px 3px;
    }

    .nav-tools {
        gap: 4px;
    }

    .btn-notification-bell {
        width: 28px;
        height: 28px;
        font-size: 0.78rem;
    }

    .currency-segmented-control {
        height: 24px !important;
        padding: 1px !important;
        gap: 1px !important;
        margin-right: 0 !important;
    }
    .currency-seg-btn {
        height: 20px !important;
        padding: 0 4px !important;
        font-size: 9px !important;
    }

    /* Badge de Tasa compacto en móvil */
    .info-badge.bcv {
        padding: 2px 5px !important;
        font-size: 0.68rem !important;
        gap: 2px !important;
    }
    .info-badge.bcv .bcv-label,
    .info-badge.bcv .bcv-curr {
        display: none !important;
    }

    .user-pill {
        width: 28px;
        height: 28px;
    }
    .user-pill i.fa-user-circle {
        font-size: 1.25rem;
    }

    /* Cabeceras con botones adaptadas a columna sin desbordamiento */
    .glass-panel > div[style*="display: flex"][style*="justify-content: space-between"],
    .glass-panel[style*="display: flex"][style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px !important;
    }
    .glass-panel > div[style*="display: flex"][style*="justify-content: space-between"] > div,
    .glass-panel[style*="display: flex"][style*="justify-content: space-between"] > div {
        width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .kpi-grid, .cxc-kpi-grid, .caja-stats-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
}

/* 4. CELULARES ULTRA PEQUEÑOS (Hasta 375px) */
@media (max-width: 375px) {
    .info-badge.bcv {
        display: none !important;
    }
    .nav-brand .brand-badge {
        display: none !important;
    }
}

/* ==========================================================================
   MOBILE ACTION TOOLTIP (Toast flotante para pantallas táctiles)
   ========================================================================== */
.mobile-touch-tooltip {
    position: absolute;
    display: none;
    align-items: center;
    gap: 8px;
    background: #0f172a;
    color: #ffffff;
    padding: 7px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.18);
    z-index: 99999;
    pointer-events: none;
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.18s ease, transform 0.18s ease;
    white-space: nowrap;
    backdrop-filter: blur(8px);
}

.mobile-touch-tooltip.visible {
    opacity: 1;
    transform: scale(1);
}

.mobile-touch-tooltip .mtt-icon {
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}

.mobile-touch-tooltip .mtt-text {
    line-height: 1.2;
}

/* Optimización de botones de acción en móviles */
@media (max-width: 768px) {
    .data-table td a.btn, 
    .data-table td button.btn,
    table td a.btn,
    table td button.btn {
        min-height: 34px;
        min-width: 34px;
        padding: 6px 10px !important;
        margin: 2px 1px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 0.88rem !important;
        border-radius: 6px;
    }
}

/* ==========================================================================
   CAMPANA DE NOTIFICACIONES Y GESTOR DE TAREAS
   ========================================================================== */
.nav-notification-parent {
    position: relative;
}

.btn-notification-bell {
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.32);
    color: #ffffff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.90rem;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-notification-bell:hover {
    background: rgba(255, 255, 255, 0.28);
    border-color: rgba(255, 255, 255, 0.5);
    color: #fef08a;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 0.60rem;
    font-weight: 800;
    min-width: 16px;
    height: 16px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
    border: 2px solid #379A7C;
}

/* Animación de Campana Sonando / Alerta */
.bell-ringing-animation {
    color: #f59e0b !important;
    animation: bellSwing 1.5s infinite ease-in-out;
    transform-origin: top center;
}

@keyframes bellSwing {
    0% { transform: rotate(0); }
    10% { transform: rotate(20deg); }
    20% { transform: rotate(-20deg); }
    30% { transform: rotate(14deg); }
    40% { transform: rotate(-14deg); }
    50% { transform: rotate(6deg); }
    60% { transform: rotate(0); }
    100% { transform: rotate(0); }
}

.notification-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 320px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    box-shadow: 0 14px 35px -5px rgba(15, 23, 42, 0.16);
    display: none;
    z-index: 1150;
    overflow: hidden;
}

.nav-notification-parent.open .notification-dropdown-menu {
    display: block;
    animation: navMenuFadeIn 0.18s ease-out;
}

.notification-dropdown-header {
    padding: 10px 14px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e2e8f0;
}

.notification-list {
    max-height: 280px;
    overflow-y: auto;
}

.notification-item {
    display: block;
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    text-decoration: none;
    color: #334155;
    transition: background 0.15s ease;
}

.notification-item:hover {
    background: #f8fafc;
}

.notification-item.unread {
    background: #f0f9ff;
    border-left: 3px solid #009fe3;
}

.notification-footer {
    padding: 8px;
    background: #f8fafc;
    text-align: center;
    border-top: 1px solid #e2e8f0;
}

.btn-ver-todas {
    display: block;
    color: #0284c7;
    font-size: 0.78rem;
    font-weight: 700;
    text-decoration: none;
    padding: 4px;
}

/* Toast Emergente */
.toast-task-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0f172a;
    color: white;
    border-left: 4px solid #f59e0b;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 14px 18px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastSlideIn 0.3s ease-out;
    max-width: 360px;
    cursor: pointer;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.nav-badge-pill {
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

/* ==========================================================================
   GLOBAL PROCESSING OVERLAY & ANTI-DOUBLE CLICK
   ========================================================================== */
.global-processing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    pointer-events: all;
}

.global-processing-overlay.active {
    opacity: 1;
    visibility: visible;
}

.processing-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 26px 30px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 159, 227, 0.15);
    transform: scale(0.92);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    overflow: hidden;
}

.global-processing-overlay.active .processing-card {
    transform: scale(1);
}

.processing-spinner-wrapper {
    position: relative;
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.processing-spinner {
    width: 64px;
    height: 64px;
    border: 4px solid #e2e8f0;
    border-top-color: #009fe3;
    border-right-color: #b2d235;
    border-radius: 50%;
    animation: proc-spin 0.85s linear infinite;
    position: absolute;
    top: 0;
    left: 0;
}

.processing-lock-icon {
    font-size: 1.30rem;
    color: #009fe3;
    animation: proc-pulse 1.5s ease-in-out infinite;
}

@keyframes proc-spin {
    to { transform: rotate(360deg); }
}

@keyframes proc-pulse {
    0%, 100% { transform: scale(1); opacity: 0.85; }
    50% { transform: scale(1.18); opacity: 1; }
}

.processing-text h4 {
    margin: 0 0 6px 0;
    font-size: 1.12rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.2px;
}

.processing-text p {
    margin: 0 0 16px 0;
    font-size: 0.84rem;
    color: #64748b;
    line-height: 1.45;
}

.processing-bar-container {
    width: 100%;
    height: 4px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.processing-bar-indeterminate {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 40%;
    background: linear-gradient(90deg, #009fe3, #b2d235);
    border-radius: 4px;
    animation: proc-bar 1.3s ease-in-out infinite;
}

@keyframes proc-bar {
    0% { left: -40%; width: 40%; }
    50% { left: 30%; width: 60%; }
    100% { left: 100%; width: 40%; }
}

/* Estilos de botones procesando */
.btn-processing,
.btn:disabled,
button:disabled,
input[type="submit"]:disabled {
    opacity: 0.70 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
    transform: none !important;
    box-shadow: none !important;
    user-select: none !important;
}

.btn-processing {
    position: relative;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
}

/* Ocultar encabezados y pies de página automáticos del navegador al imprimir */
@page {
    margin: 0;
}
@media print {
    @page {
        margin: 0;
    }
    body {
        margin: 0 !important;
        padding: 10mm 15mm !important;
        background: #ffffff !important;
        color: #000000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    .sidebar, .top-header, .top-navbar, .nav-brand, .no-print, .btn, .action-buttons, nav, header {
        display: none !important;
    }
    .main-content, .content-wrapper {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        background: transparent !important;
        box-shadow: none !important;
        border: none !important;
    }
    .glass-panel {
        box-shadow: none !important;
        border: none !important;
        background: transparent !important;
        padding: 0 !important;
    }
}



