:root {
    /* Main Design Tokens */
    --radius-sm: 3px;
    --radius-md: 4px;
    --radius-lg: 8px;
    --font-main: 'Outfit', sans-serif;

    /* Light Mode Palette */
    --primary-color: #00a65a;
    --primary-hover: #008d4c;
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --sidebar-bg: #1e293b;
    --sidebar-item-hover: rgba(255, 255, 255, 0.1);
    --text-main: #334155;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

html.dark {
    --bg-main: #020617;
    --bg-card: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #1e293b;
    --sidebar-bg: #020617;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.6);
}

/* PWA Navigation Spinner - Minimalist version */
#pwa-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: rgba(0, 150, 136, 0.1);
    z-index: 100000;
    display: none;
    pointer-events: none;
}

#pwa-loader.active {
    display: block;
}

#initial-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 1);
    z-index: 200000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

html.dark #initial-splash {
    background: #0f172a;
}

.pwa-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: linear-gradient(90deg, #00ff88, #00a65a, #3b82f6);
    background-size: 200% 100%;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.7);
    transition: width 0.4s cubic-bezier(0.1, 0.7, 1.0, 0.1);
    animation: pwa-loading-bar-glow 2s infinite linear;
}

.pwa-spinner-mini {
    position: fixed;
    top: 12px;
    right: 12px;
    left: auto;
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid #00ff88;
    border-radius: 50%;
    animation: pwa-spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    z-index: 100001;
    background: transparent;
}

.pwa-spinner-mid {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 0, 0, 0.05);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: pwa-spin 1s linear infinite;
    margin-top: 20px;
}

html.dark .pwa-spinner-mid {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: #00ff88;
}

.pwa-brand-text {
    font-size: 1.8rem;
    font-weight: 800;
    color: #1e293b;
    font-family: var(--font-main);
    letter-spacing: -0.02em;
    animation: pwa-text-glow 2s infinite ease-in-out;
}

@keyframes pwa-text-glow {

    0%,
    100% {
        opacity: 0.8;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

html.dark .pwa-brand-text {
    color: #f8fafc;
}

html.dark .pwa-spinner-mini {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: #00ff88;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.6);
}

@keyframes pwa-loading-bar-glow {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 100% 50%;
    }
}

@keyframes pwa-loading-bar {
    0% {
        width: 0%;
        left: 0;
    }

    50% {
        width: 70%;
        left: 0;
    }

    100% {
        width: 100%;
        left: 0;
        opacity: 0;
    }
}

@keyframes pwa-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Global Styles */
body,
h1,
h2,
h3,
h4,
h5,
h6,
.app-header,
.app-sidebar,
.tile,
.card,
.table,
.btn,
.form-control,
.app-title,
.app-nav__item {
    font-family: var(--font-main) !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    background-color: var(--bg-main) !important;
    color: var(--text-main) !important;
}

/* Sidebar Modernization */
.app-sidebar {
    background-color: #1e293b !important;
    box-shadow: var(--shadow-lg) !important;
    border: none !important;
}

/* Sidebar siempre igual: no cambia con el tema oscuro */
html.dark .app-sidebar {
    background-color: #1e293b !important;
}

/* --- SISTEMA DE MODALES Y PWA --- */
@media (min-width: 1200px) {
    .modal-xl {
        max-width: 95%;
    }
}

@media (min-width: 992px) {
    .modal-xl {
        max-width: 90%;
    }
}

.modal-xl {
    width: 95%;
    margin: 10px auto;
}

/* Centrar todos los modales verticalmente */
.modal-dialog:not(.modal-dialog-centered) {
    margin-top: 10vh;
    margin-bottom: auto;
}

/* Forzar centrado vertical de todos los modales */
.modal-dialog {
    display: flex !important;
    align-items: center !important;
    min-height: calc(70vh - 2rem) !important;
    margin: auto !important;
}

.modal-content {
    border: none;
    box-shadow: var(--shadow-lg);
}

/* Soporte Modo Oscuro para Modales */
html.dark .modal-content {
    background-color: #1e1e2d;
    color: #f8fafc;
}

html.dark .modal-header {
    border-bottom: 1px solid #334155;
    background-color: #1a1a27 !important;
}

html.dark .modal-body {
    background-color: #1e1e2d;
}

#modal_ajax_standard .app-content {
    margin: 0 !important;
    padding: 10px !important;
    min-height: auto !important;
    margin-left: 0 !important;
    width: 100% !important;
}

#modal_ajax_standard .tile {
    margin-bottom: 0 !important;
    border: none !important;
    box-shadow: none !important;
}

/* Ocultar cabeceras duplicadas dentro del modal */
#modal_ajax_standard .app-content>.tile-title-w-btn,
#modal_ajax_standard .tile>h3.text-capitalize {
    display: none !important;
}

/* FORZAR FONDO CLARO EN PREVISUALIZACIONES DE DOCUMENTOS (REPORTE/FACTURAS) */
/* Esto asegura que aunque el sistema esté en modo oscuro, el documento a imprimir/ver sea legible */
/* Forzar fondo blanco en previsualizaciones de documentos y reportes en modo oscuro */
html.dark #comprobanteViewerModal .modal-body,
html.dark #modal-print .modal-body,
html.dark .modal-print-layout .modal-body,
html.dark #modal-impresion .modal-body,
html.dark #modal-impresion .modal-content,
html.dark .print-preview-container,
html.dark .printable,
html.dark .modal-body iframe[src*="imprimir"],
html.dark .modal-body iframe[src*="reporte"],
html.dark #comprobanteViewerModal iframe,
html.dark #modal-print iframe,
html.dark #modal-impresion iframe {
    background-color: #ffffff !important;
    color: #000000 !important;
}

html.dark #comprobanteViewerModal .modal-body *,
html.dark #modal-print .modal-body *,
html.dark .modal-print-layout .modal-body *,
html.dark #modal-impresion .modal-body * {
    color: #000000 !important;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

html.dark .loading-overlay {
    background: rgba(30, 30, 45, 0.8);
}

/* Navegación PWA: Oculto por defecto, solo visible en Standalone */
.d-pwa-only {
    display: none !important;
}

.is-pwa .d-pwa-only {
    display: flex !important;
    align-items: center;
}

.app-header .d-pwa-only .btn-link,
.app-header .d-pwa-only .btn-link i {
    color: #0f172a !important;
    /* Azul muy oscuro casi negro para modo claro */
    font-size: 1.3rem;
    opacity: 0.9 !important;
}

.app-header .d-pwa-only .btn-link:focus,
.app-header .d-pwa-only .btn-link:active {
    text-decoration: none !important;
    outline: none !important;
}

html.dark .app-header .d-pwa-only .btn-link,
html.dark .app-header .d-pwa-only .btn-link i {
    color: #ffffff !important;
    /* Blanco puro para modo oscuro */
    opacity: 1 !important;
}

.is-pwa .app-header {
    display: flex;
    align-items: center;
}

/* --- FIN SISTEMA DE MODALES Y PWA --- */

/* --- ESTILOS DE COMPONENTES Y CORRECCIONES --- */
/* Ocultar elementos si estamos en modo iframe (visor interno) */
.is-iframe .app-header,
.is-iframe .app-sidebar,
.is-iframe .footer,
.is-iframe .shortcuts-bar {
    display: none !important;
}

.is-iframe .app-content {
    margin-left: 0 !important;
    margin-top: 0 !important;
    padding: 10px !important;
    background: var(--bg-main) !important;
}

.is-iframe body {
    background: var(--bg-main) !important;
}

html.dark.is-iframe body,
html.dark.is-iframe .app-content {
    background: #1a1a27 !important;
}

.dataTables_processing {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 10000 !important;
    background: var(--primary-color) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: var(--radius-lg) !important;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 166, 90, 0.4) !important;
    padding: 12px 25px !important;
    width: auto !important;
    text-align: center;
    transition: all 0.3s ease;
}

html.dark .dataTables_processing {
    background: #059669 !important;
    /* Verde un poco más oscuro para dark mode */
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
}

.status-dot {
    height: 8px;
    width: 8px;
    display: inline-block;
    border-radius: 50%;
    margin-right: 4px;
}









/* Widgets Coloured Icons (Premium) */
.widget-small.primary.coloured-icon .icon {
    background-color: #5d59eb !important;
}

.widget-small.warning.coloured-icon .icon {
    background-color: #ff9f43 !important;
}

.widget-small.info.coloured-icon .icon {
    background-color: #2e97f2 !important;
}

.widget-small.success.coloured-icon .icon {
    background-color: #28c76f !important;
}

.widget-small .info h4 {
    color: #fff !important;
    font-weight: 600;
}

.widget-small .info p {
    color: #fff !important;
}

.widget-small.coloured-icon {
    background-color: #343a40 !important;
    color: #fff !important;
    border: none;
}

.widget-small {
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
}

.widget-small .icon {
    border-radius: 10px 0 0 10px;
}

/* Estilos de Notificaciones y Widgets */
.hover-scale {
    transition: transform 0.2s;
}

.hover-scale:hover {
    transform: scale(1.02);
}

.widget-active {
    border: 2px solid #009688;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.notif-unread {
    background-color: rgba(245, 158, 11, 0.08) !important;
    transition: all 0.2s ease;
}

.notif-unread:hover {
    background-color: rgba(245, 158, 11, 0.15) !important;
}

.notif-read {
    opacity: 0.8;
    transition: all 0.2s ease;
}

html.dark .notif-unread {
    background-color: rgba(245, 158, 11, 0.12) !important;
    color: #f8fafc !important;
}

html.dark .notif-unread:hover {
    background-color: rgba(245, 158, 11, 0.2) !important;
}

html.dark .notif-read {
    background-color: transparent !important;
    color: #94a3b8 !important;
}

/* Mejora en botones de acción */
.table .btn-info {
    background-color: #0ea5e9;
    border-color: #0ea5e9;
}

.table .btn-success {
    background-color: #10b981;
    border-color: #10b981;
}

.table .btn-danger {
    background-color: #ef4444;
    border-color: #ef4444;
}

/* --- MEJORA VISUAL: RESALTAR FILA EN FOCO (PREMIUM) --- */
.row-focused {
    background-color: #55c20c !important;
    transition: all 0.2s ease-in-out;
    transform: scale(1.01);
    z-index: 10;
    position: relative;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.row-focused td {
    background-color: #55c20c !important;
    border-top: 2px solid #856404 !important;
    border-bottom: 2px solid #856404 !important;
    color: #856404 !important;
    font-weight: bold;
}

.btn-agregar:focus {
    transform: scale(1.2) !important;
    outline: none !important;
    box-shadow: 0 0 15px #28a745 !important;
    border: 2px solid #1e7e34 !important;
    animation: pulse-green 1.5s infinite;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

.shortcuts-help span {
    margin-right: 5px;
    cursor: default;
}

/* Ocultar barra de accesos directos y etiquetas de teclado en mobile/tablet */
@media (max-width: 991px) {
    .shortcuts-bar {
        display: none !important;
    }

    .shortcut-label {
        display: none !important;
    }
}

html.dark .app-menu__item {
    color: #cbd5e1 !important;
}

html.dark .app-sidebar__user {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* Textos del sidebar siempre blancos */
html.dark .app-menu__item,
html.dark .app-menu__item i,
html.dark .app-menu__item .app-menu__label,
html.dark .app-menu__item .treeview-indicator,
html.dark .app-sidebar__user-name,
html.dark .app-sidebar a {
    color: #f8fafc !important;
    fill: #f8fafc;
}

.app-sidebar__user {
    padding: 25px 20px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 15px;
}

.app-sidebar__user-avatar {
    border-radius: var(--radius-md) !important;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
    background: #fff;
    padding: 5px;
}

.app-menu__item {
    border-radius: var(--radius-md) !important;
    margin: 4px 12px !important;
    padding: 12px 15px !important;
    color: #cbd5e1 !important;
    transition: all 0.2s ease !important;
}

.app-menu__item:hover,
.app-menu__item.active {
    background: var(--sidebar-item-hover) !important;
    color: #fff !important;
}

.app-menu__item.active {
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-hover) 100%) !important;
    box-shadow: 0 4px 12px rgba(0, 166, 90, 0.3);
}

/* Padre verde cuando un hijo está activo (Vali Admin usa .active o .is-expanded en el li padre) */
.treeview.active>.app-menu__item,
.treeview.is-expanded>.app-menu__item {
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-hover) 100%) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(0, 166, 90, 0.3);
}

.treeview.active>.app-menu__item i,
.treeview.is-expanded>.app-menu__item i {
    color: #fff !important;
}

/* Submenus Modernization - Global */

/* OVERRIDE UNIFORME: eliminar el fondo oscuro #0d1214 que aplica Vali Admin a submenús */
/* Cuando el treeview está expandido, el app-menu__item padre NO debe tener fondo propio */
.app-sidebar .treeview.is-expanded>.app-menu__item[data-toggle="treeview"] {
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--primary-hover) 100%) !important;
    border-left: none !important;
}

/* La lista de hijos: fondo transparente SOLO en sidebar expandido (no toggled) */
/* En sidenav-toggled el flyout necesita su propio fondo para ser legible */
body:not(.sidenav-toggled) .app-sidebar .treeview-menu,
body:not(.sidenav-toggled) .app-sidebar .treeview.is-expanded .treeview-menu {
    background: transparent !important;
}


.treeview-item {
    border-radius: var(--radius-md) !important;
    margin: 1px 0px 1px 10px !important;
    /* Muy pegados verticalmente */
    padding: 5px 10px !important;
    /* Padding interno reducido */
    color: #cbd5e1 !important;
    display: flex !important;
    align-items: center !important;
    transition: all 0.2s ease !important;
    font-size: 0.82rem !important;
}


.treeview-item:hover {
    background: var(--sidebar-item-hover) !important;
    color: #fff !important;
    padding-left: 18px !important;
    /* Efecto de desplazamiento al hover */
}

.treeview-item.active {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.1) 0%, rgba(16, 185, 129, 0.05) 100%) !important;
    color: #fff !important;
    font-weight: 600;
}

/* El punto del submenu activo debe resaltar */
.treeview-item.active i.icon {
    opacity: 1;
    color: #10b981 !important;
    transform: scale(1.4);
}



/* Jerarquía de Capas Críticas */

/* 1. Alertas Superiores (SweetAlert, Toasts) */
.swal2-container,
.sweet-alert,
.sweet-overlay,
#toast-container {
    z-index: 200000 !important;
    /* Aumentado para estar siempre arriba de todo */
}

/* 2. Modales (Deben tapar al Header) */
.modal {
    z-index: 10000 !important;
}

.modal-backdrop {
    z-index: 9999 !important;
}

/* 3. Dropdowns y Componentes Volátiles en Modal */
.select2-container--open,
.ui-datepicker,
.bootstrap-select.show {
    z-index: 101000 !important;
}

/* 4. Header (Fijo en Top) */
.app-header {
    background: var(--bg-card) !important;
    border-bottom: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow-sm) !important;
    height: 52px !important;
    display: flex !important;
    align-items: center !important;
    backdrop-filter: blur(12px);
    z-index: 10010 !important; /* Aumentado para estar sobre el sidebar */
    padding: 0 15px !important;
}

/* 5. Zoom (Capa de Contenido) */
.zoom {
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: zoom-in;
}

/* [FINAL_SEAL: ZOOM_SYSTEM] - MODIFICACION FINALIZADA - NO TOCAR */
.zoom:hover {
    transform: scale(3.5) !important;
    position: relative;
    z-index: 9999 !important;
    /* Límite bajo el Header (10000) */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 2px solid #fff;
    border-radius: var(--radius-sm);
    transform-origin: center center;
}

/* [/FINAL_SEAL] */

/* Zoom dentro de Modal - Sobre el Modal */
.modal .zoom:hover {
    z-index: 1000 !important;
    /* Sobre Modal (100000) */
}

/* 6. Desactivar Zoom del fondo cuando hay un modal abierto */
body.modal-open .app-content .zoom {
    pointer-events: none !important;
}

html.dark .app-header {
    background: rgba(15, 23, 42, 0.98) !important;
    border-bottom: 1px solid #1e293b !important;
}

@media (max-width: 767px) {
    .app-header {
        padding: 0 5px !important;
        display: flex !important;
        flex-wrap: nowrap !important;
        justify-content: space-between !important;
    }

    /* Ajustes para el select de empresa en móvil */
    #selectEmpresaHeader {
        max-width: 120px !important;
        font-size: 11px !important;
        height: 32px !important;
        padding: 2px 5px !important;
    }

    /* El nombre de la empresa ocupará menos espacio para dar lugar a los botones */
    .app-header .app-nav__item:nth-of-type(1) {
        max-width: 100px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex-shrink: 1;
    }

    .app-nav {
        margin-left: 0 !important;
        flex-shrink: 0;
    }
}

/* Dark mode: verde más brillante para contrastar el sidebar oscuro */
html.dark .app-menu__item.active,
html.dark .treeview.active>.app-menu__item,
html.dark .treeview.is-expanded>.app-menu__item {
    background: linear-gradient(90deg, #10b981 0%, #059669 100%) !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4) !important;
    color: #fff !important;
}

html.dark .app-menu__item.active i,
html.dark .treeview.active>.app-menu__item i,
html.dark .treeview.is-expanded>.app-menu__item i {
    color: #fff !important;
}

@media (min-width: 768px) {
    .app-header__logo {
        background-color: var(--sidebar-bg) !important;
        font-family: var(--font-main) !important;
        font-weight: 700;
        height: 52px !important;
        width: 230px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 1.1rem !important;
        letter-spacing: -0.01em;
    }
}

@media (max-width: 767px) {
    .app-header__logo {
        width: auto !important;
        flex: 1 !important;
        background-color: transparent !important;
        justify-content: flex-start !important;
        padding-left: 10px !important;
        font-size: 0.9rem !important;
    }
}

.app-nav {
    display: flex !important;
    align-items: center !important;
    height: 100% !important;
    margin-left: auto !important;
}

@media (max-width: 767px) {
    .app-nav {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        white-space: nowrap !important;
        -webkit-overflow-scrolling: touch !important;
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
        flex: 1 !important;
        margin-left: 10px !important;
        justify-content: flex-start !important;
    }

    .app-nav::-webkit-scrollbar {
        display: none !important;
    }

    .app-nav li {
        display: block !important;
        flex-shrink: 0 !important;
    }

    /* Ocultar hora y búsqueda con máxima prioridad */
    .app-search,
    #txt,
    li.app-search {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        pointer-events: none !important;
    }
}

.app-nav__item {
    color: var(--text-main) !important;
    border-radius: var(--radius-md) !important;
    margin: 0 4px !important;
    padding: 6px 12px !important;
    font-weight: 700 !important;
    font-size: 0.8rem !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 3px !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    background: transparent !important;
    border: none !important;
    min-width: 55px !important;
}

@media (max-width: 767px) {
    .app-nav__item {
        font-size: 0.9rem !important;
        font-weight: 800 !important;
    }

    .dropdown-item {
        font-size: 1rem !important;
        padding: 12px 20px !important;
        font-weight: 600 !important;
    }
}

@media (min-width: 768px) {
    .app-nav__item {
        min-width: 80px !important;
    }
}

/* Visibility Utilities */
.d-mobile-only {
    display: none !important;
}

@media (max-width: 767px) {
    .d-mobile-only {
        display: flex !important;
    }

    .d-desktop-only {
        display: none !important;
    }

    .app-nav__item {
        padding: 6px 8px !important;
        min-width: 50px !important;
    }

    .app-nav__item span.badge {
        top: 2px;
        right: 2px;
        padding: 2px 4px !important;
        font-size: 0.6rem !important;
    }
}

.app-nav__item i {
    font-size: 1.2rem !important;
    margin: 0 !important;
}

.app-nav__item:hover {
    background: rgba(0, 0, 0, 0.04) !important;
    color: var(--primary-color) !important;
    transform: translateY(-2px);
}

html.dark .app-nav__item {
    color: #cbd5e1 !important;
}

html.dark .app-nav__item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #fff !important;
}

.app-sidebar__toggle {
    height: 40px !important;
    width: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--primary-color) !important; /* Fondo sólido para que se vea sí o sí */
    color: #ffffff !important;
    transition: all 0.2s ease !important;
    order: -20 !important;
    z-index: 100000 !important;
    text-decoration: none !important;
    position: relative !important;
    border-radius: 4px !important;
    margin-right: 15px !important;
}

.app-sidebar__toggle:before {
    content: "\f0c9" !important;
    font-family: FontAwesome !important;
    font-size: 20px !important;
    display: inline-block !important;
}

.app-sidebar__toggle:hover {
    background: var(--primary-color-dark) !important;
    transform: scale(1.05);
}

/* Header Elements Styling */
.app-search {
    margin: 0 15px !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
}

.app-search .bootstrap-select>.dropdown-toggle {
    border-radius: var(--radius-md) !important;
    border: 1.5px solid var(--border-color) !important;
    background: var(--bg-main) !important;
    padding: 8px 15px !important;
    font-size: 0.85rem !important;
    color: var(--text-main) !important;
}

/* Badges Globales y Modernos (Mejor Legibilidad) */
.badge {
    border-radius: var(--radius-sm) !important;
    font-weight: 800 !important;
    padding: 0.5em 0.9em !important;
    font-size: 0.7rem !important;
    /* Aumentado significativamente para leer desde lejos */
    letter-spacing: 0.01em !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12) !important;
    display: inline-block !important;
    min-width: 60px;
    text-align: center;
    vertical-align: middle;
}

/* Badges en Header (más compactos) */
.app-header .badge {
    border-radius: 50px !important;
    font-weight: 800 !important;
    padding: 0.15em 0.6em !important;
    font-size: 0.68rem !important;
    min-width: unset;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2) !important;
}

/* Colores Premium Sólidos (Modo Claro y Oscuro) */
.badge-primary {
    background-color: #6366f1 !important;
    color: #fff !important;
}

.badge-secondary {
    background-color: #64748b !important;
    color: #fff !important;
}

.badge-success {
    background-color: #10b981 !important;
    color: #fff !important;
}

.badge-info {
    background-color: #0ea5e9 !important;
    color: #fff !important;
}

.badge-warning {
    background-color: #f59e0b !important;
    color: #1f2937 !important;
}

.badge-danger {
    background-color: #ef4444 !important;
    color: #fff !important;
}

.badge-dark {
    background-color: #1e293b !important;
    color: #fff !important;
}

.badge-light {
    background: #f8fafc !important;
    color: #475569 !important;
    border: 1px solid #e2e8f0 !important;
}

/* Notification Bell Ring */
#li-notifications:hover .fa-bell-o {
    animation: bellRing 0.6s ease;
}

@keyframes bellRing {

    0%,
    100% {
        transform: rotate(0);
    }

    20% {
        transform: rotate(15deg);
    }

    40% {
        transform: rotate(-15deg);
    }

    60% {
        transform: rotate(10deg);
    }

    80% {
        transform: rotate(-10deg);
    }
}

/* Content Area & Cards */
.tile,
.card {
    background-color: var(--bg-card) !important;
    padding: 20px !important;
    /* Balanced: Professional but not cramped */
    transition: transform 0.3s ease, box-shadow 0.3s ease !important;
    margin-bottom: 25px !important;
}

.tile:hover {
    box-shadow: var(--shadow-lg) !important;
}

/* Widgets Modernization with Glassmorphism & Gradients */
.widget-small {
    border-radius: var(--radius-lg) !important;
    border: none !important;
    color: #fff !important;
    position: relative;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) !important;
}

.widget-small:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}

.widget-small .icon {
    border-radius: var(--radius-lg) 0 0 var(--radius-lg) !important;
    background-color: rgba(255, 255, 255, 0.2) !important;
    backdrop-filter: blur(4px);
    width: 80px !important;
    font-size: 2.2rem !important;
}

.widget-small .info h4 {
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 1px;
    font-size: 0.75rem;
    opacity: 0.9;
}

.widget-small .info .card-value {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Specific Widget Gradients */
.widget-small.primary {
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%) !important;
}

.widget-small.info {
    background: linear-gradient(135deg, #0ea5e9 0%, #22d3ee 100%) !important;
}

.widget-small.success {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%) !important;
}

.widget-small.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%) !important;
}

.widget-small.danger {
    background: linear-gradient(135deg, #ef4444 0%, #f87171 100%) !important;
}


/* Reglas comunes de cabecera */
.table thead th {
    background-color: #1e293b !important;
    color: #ffffff !important;
    border-bottom: 2px solid var(--primary-color) !important;
    font-weight: 700 !important;
}

html.dark .table thead th {
    background-color: #020617 !important;
    color: #f8fafc !important;
}

/* Tabla de pagos: permitir wrap en cabeceras para evitar scroll horizontal */
#tb_pagos_venta thead th {
    white-space: normal !important;
    word-break: break-word;
}

/* Contenedor principal: MARGEN TOP VITAL */
.app-content {
    padding: 10px 15px !important;
    /* Más estrecho */
    margin-top: 52px !important;
    min-height: calc(100vh - 52px);
}

/* Titles and Breadcrumbs */
.app-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    padding: 8px 19px 10px !important;
    /* Más compacto */
    background-color: var(--bg-card) !important;
    box-shadow: var(--shadow-sm);
}

.app-title h1 {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    margin: 0 !important;
    color: var(--text-main);
}


html.dark .table td {
    color: #e2e8f0 !important;
}

/* Forms & Inputs */
.form-control {
    border-radius: var(--radius-sm) !important;
    border: 1.5px solid var(--border-color) !important;
    background-color: var(--bg-card) !important;
    color: var(--text-main) !important;
}

/* Modals Dark Mode Text Fix */
html.dark .modal-content {
    color: var(--text-main) !important;
}

html.dark pre,
html.dark code {
    color: var(--text-main) !important;
    /* background-color: rgba(255, 255, 255, 0.05) !important; */
}

html.dark .btn-warning {
    color: #fff !important;
}

html.dark .btn-warning i {
    color: #fff !important;
}

/* Buttons */
.btn {
    border-radius: var(--radius-sm) !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}

/* Theme Toggle styles */
#themeToggle {
    background: var(--bg-card) !important;
    border: 1.5px solid var(--border-color) !important;
    border-radius: var(--radius-md) !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    cursor: pointer;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    margin: 0 5px !important;
    box-shadow: var(--shadow-sm) !important;
}

@media (min-width: 768px) {
    #themeToggle {
        margin: 0 10px !important;
    }
}

#themeToggle:hover {
    background-color: var(--bg-main) !important;
    transform: rotate(15deg) scale(1.1) !important;
    border-color: var(--primary-color) !important;
}

html.dark #themeToggle:hover {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

#themeToggle svg .moon {
    display: none;
    fill: #94a3b8;
}

#themeToggle svg .sun {
    display: block;
    fill: #f59e0b;
}

html.dark #themeToggle svg .sun {
    display: none;
}

html.dark #themeToggle svg .moon {
    display: block;
}

/* Custom Scrollbar - Modern & Slim */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

html.dark ::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
    background-clip: content-box;
}

/* Transitions */
* {
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}

/* ====== RESPONSIVE ENHANCEMENTS & HEIGHT FIXES ====== */
/* Header y nav un poco más cortos y cómodos */
.app-header {
    height: 52px !important;
}

.app-header__logo {
    height: 52px !important;
    line-height: 52px !important;
}

/* Sidebar Tooltip Check */
.tooltip {
    z-index: 11000 !important;
    /* Above header (10000) and dropdowns, but below modals (101000) */
}

/* PWA Internal Tabs Condensed */
.nav-pwa-tabs {
    border-bottom: 2px solid #009688;
    margin-bottom: 15px;
}

.nav-pwa-tabs .nav-link {
    padding: 6px 12px !important;
    font-size: 13px !important;
    border-radius: 4px 4px 0 0 !important;
    margin-right: 4px !important;
    display: flex !important;
    align-items: center !important;
    background: #f1f3f5;
    border: 1px solid #ced4da;
    border-bottom: none !important;
    color: #495057;
    transition: all 0.2s;
    margin-bottom: -2px;
    /* Overlap the container border-bottom */
}

.nav-pwa-tabs .nav-link.active {
    background-color: #009688 !important;
    color: white !important;
    border-color: #009688 !important;
    border-bottom: 2px solid #009688 !important;
    font-weight: 600 !important;
    z-index: 2;
}

.nav-pwa-tabs .nav-link .fa {
    margin-right: 5px !important;
    font-size: 12px !important;
}

.nav-pwa-tabs .btn-close-tab {
    margin-left: 8px !important;
    font-size: 14px !important;
    line-height: 1 !important;
    opacity: 0.5;
    cursor: pointer;
}

.nav-pwa-tabs .btn-close-tab:hover {
    opacity: 1;
    color: #fff !important;
}

.nav-pwa-tabs .nav-link:not(.active) .btn-close-tab:hover {
    color: #dc3545 !important;
}

.nav-pwa-tabs .nav-link-add {
    padding: 8px 10px !important;
    color: #28a745 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center !important;
    opacity: 0.8;
}

.nav-pwa-tabs .nav-link-add:hover {
    background: transparent !important;
    opacity: 1;
    transform: scale(1.1);
}

.nav-pwa-tabs .nav-link-add i {
    margin: 0 !important;
}

/* ====== RESPONSIVE ENHANCEMENTS AND SIDEBAR TOGGLED ADJUSTMENTS ====== */
/* Header Width and Items Spacing */
/* Sidebar Minimizado (Sidenav Toggled) - SOLO PARA DESKTOP */
@media (min-width: 768px) {
    .app-header__logo {
        width: 250px;
        flex: 0 0 250px;
    }

    .sidebar-mini.sidenav-toggled .app-header__logo {
        width: 80px !important;
        padding: 0 !important;
        font-size: 0 !important;
        text-indent: -9999px;
        justify-content: center !important;
        overflow: hidden;
    }

    .sidebar-mini.sidenav-toggled .app-sidebar {
        width: 80px !important;
        flex: 0 0 80px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        transition: width 0.3s ease !important;
        z-index: 10000 !important;
        scrollbar-width: none;
    }

    .sidebar-mini.sidenav-toggled .app-sidebar::-webkit-scrollbar {
        width: 0px !important;
        display: none !important;
    }

    .sidebar-mini.sidenav-toggled .app-sidebar__user {
        display: none !important;
    }

    .sidebar-mini.sidenav-toggled .app-menu__item,
    .sidebar-mini.sidenav-toggled .treeview {
        position: relative !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 80px !important;
        height: 50px !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
    }

    .sidebar-mini.sidenav-toggled .app-menu__icon {
        margin: 0 !important;
        font-size: 1.4rem !important;
    }

    .sidebar-mini.sidenav-toggled .app-sidebar__user,
    .sidebar-mini.sidenav-toggled .app-sidebar__user-avatar,
    .sidebar-mini.sidenav-toggled .app-sidebar__user-name,
    .sidebar-mini.sidenav-toggled .app-sidebar__user-designation {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar-mini.sidenav-toggled .app-menu__label,
    .sidebar-mini.sidenav-toggled .treeview-menu {
        display: none !important;
    }

    .sidebar-mini.sidenav-toggled .app-menu__label,
    .sidebar-mini.sidenav-toggled .treeview-menu {
        display: none !important;
        position: fixed !important;
        left: 80px !important;
        width: 250px !important;
        background: #1e293b !important;
        z-index: 100000 !important;
        box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.5) !important;
        border-radius: 0 4px 4px 0 !important;
        border: 1px solid rgba(255, 255, 255, 0.1) !important;
        border-left: none !important;
    }

    .sidebar-mini.sidenav-toggled .app-menu__label {
        padding: 12px 20px !important;
        font-weight: 700 !important;
        text-transform: uppercase !important;
        font-size: 0.75rem !important;
        color: #fff !important;
    }

    .sidebar-mini.sidenav-toggled .treeview-menu {
        padding: 5px 0 !important;
    }

    .sidebar-mini.sidenav-toggled .treeview:hover .app-menu__label,
    .sidebar-mini.sidenav-toggled .treeview:hover .treeview-menu {
        display: block !important;
    }

    /* Puente transparente más ancho para que el mouse no pierda el hover al moverse al submenu */
    .sidebar-mini.sidenav-toggled .treeview-menu::before {
        content: "";
        position: absolute;
        top: -50px;
        left: -30px;
        width: 40px;
        height: calc(100% + 100px);
        background: transparent;
        z-index: -1;
    }

    /* Mostrar al pasar el mouse por el item del padre */
    .sidebar-mini.sidenav-toggled .treeview:hover .app-menu__label,
    .sidebar-mini.sidenav-toggled .treeview:hover .treeview-menu {
        visibility: visible !important;
        opacity: 1 !important;
        transition-delay: 0s !important;
    }

    .sidebar-mini.sidenav-toggled .app-menu__label {
        padding: 15px 20px !important;
        font-weight: 700 !important;
        color: #fff !important;
        text-transform: uppercase !important;
        letter-spacing: 1px !important;
        font-size: 0.75rem !important;
    }

    .sidebar-mini.sidenav-toggled .app-menu__label::before {
        content: "";
        position: absolute;
        top: 0;
        left: -20px;
        width: 20px;
        height: 100%;
        background: transparent;
    }

    .sidebar-mini.sidenav-toggled .treeview-menu {
        padding: 10px 0 !important;
        min-width: 220px !important;
    }

    .sidebar-mini.sidenav-toggled .treeview-item {
        padding: 10px 20px !important;
        font-size: 0.85rem !important;
        color: #cbd5e1 !important;
        transition: all 0.2s ease !important;
        border: none !important;
    }

    .sidebar-mini.sidenav-toggled .treeview-item:hover {
        background: rgba(255, 255, 255, 0.05) !important;
        color: var(--primary-color) !important;
        padding-left: 25px !important;
    }

    .sidebar-mini.sidenav-toggled .treeview-item i.icon {
        display: none !important;
    }

    .sidebar-mini.sidenav-toggled .treeview-indicator {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .sidebar-mini.sidenav-toggled .app-content {
        margin-left: 80px !important;
    }
}

/* ====== HOTFIX MOBILE & WIDTH / MODAL HEIGHT ====== */
@media (max-width: 768px) {

    /* Ocultar textos no esenciales para ahorrar espacio en cabecera */
    .app-header .app-nav__item,
    .app-header .badge {
        font-size: 11px !important;
        padding: 5px !important;
    }

    .app-header__logo {
        width: auto !important;
        /* Cambiado de 100% para no empujar botones */
        height: 52px !important;
        line-height: 52px !important;
        text-align: left;
        padding-left: 10px !important;
        flex: 1 !important;
    }
}


/* Corrección visual en Modo Oscuro - Header Items Texts */
/* Todos los items de menu principal nav (arriba), su tooltip container, dropdowns o links dentro del header que deben ser blancos puros */
html.dark .app-header .app-nav__item,
html.dark .app-header .dropdown-menu,
html.dark .app-header .app-search select {
    color: #ffffff !important;
}

html.dark .app-header .app-nav__item i {
    color: #ffffff !important;
}

/* Evitar que en dropdown menu el texto se confunda con el fondo claro original si no hemos adaptado bg */
html.dark .dropdown-menu {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}

html.dark .dropdown-item {
    color: #f8fafc !important;
}

html.dark .dropdown-item:hover,
html.dark .dropdown-item:active {
    background-color: #0f172a !important;
}

/* Dashboard Dark Mode Fixes */
html.dark .card-title,
html.dark .card-subtitle,
html.dark .text-muted,
html.dark .chart-legend,
html.dark .chart-label {
    color: #f8fafc !important;
}

html.dark text,
html.dark .apexcharts-text,
html.dark .apexcharts-legend-text {
    fill: #f8fafc !important;
    color: #f8fafc !important;
}

html.dark .apexcharts-xaxis-label,
html.dark .apexcharts-yaxis-label {
    fill: #f8fafc !important;
}

/* Dashboard Dark Mode - Global Text visibility */
html.dark .tile,
html.dark .tile-title,
html.dark .tile-footer,
html.dark .tile p,
html.dark .tile span:not([class*="text-"]),
html.dark .tile div:not([class*="text-"]) {
    color: #f8fafc !important;
}

/* Preservar colores de utilidad (Status) en modo oscuro */
html.dark .text-success {
    color: #10b981 !important;
}

/* Verde esmeralda más brillante */
html.dark .text-danger {
    color: #ef4444 !important;
}

/* Rojo más suave */
html.dark .text-warning {
    color: #f59e0b !important;
}

/* Ámbar */
html.dark .text-info {
    color: #0ea5e9 !important;
}

/* Cyan */
html.dark .text-primary {
    color: #6366f1 !important;
}

/* Indigo */
html.dark .text-secondary {
    color: #94a3b8 !important;
}

html.dark .text-dark {
    color: #cbd5e1 !important;
}

/* Fix legibilidad bloques de resumen (Nóminas, etc) en Modo Oscuro */
html.dark .table-secondary {
    background-color: rgba(148, 163, 184, 0.2) !important;
}

html.dark .table-success {
    background-color: rgba(16, 185, 129, 0.25) !important;
}

html.dark .table-danger {
    background-color: rgba(239, 68, 68, 0.25) !important;
}

html.dark .table-primary {
    background-color: rgba(99, 102, 241, 0.25) !important;
}

html.dark .table-info {
    background-color: rgba(14, 165, 233, 0.25) !important;
}

html.dark .table-warning {
    background-color: rgba(245, 158, 11, 0.25) !important;
}

/* Forzar que el texto herede el color claro del tema en estas celdas oscurecidas */
html.dark .table-secondary td,
html.dark .table-secondary th,
html.dark .table-success td,
html.dark .table-success th,
html.dark .table-danger td,
html.dark .table-danger th,
html.dark .table-primary td,
html.dark .table-primary th {
    color: #f8fafc !important;
}

/* Alertas y Badges legibles en Dark Mode */
html.dark .alert-info {
    background-color: rgba(14, 165, 233, 0.15) !important;
    border-color: rgba(14, 165, 233, 0.3) !important;
    color: #38bdf8 !important;
}

html.dark .badge-warning {
    background-color: #f59e0b !important;
    color: #000 !important;
    /* Mantener texto oscuro para visibilidad en amarillo */
}

/* Specific Chart.js legend fix if they are using HTML legends */
html.dark .chart-legend li span {
    color: #f8fafc !important;
}

/* Target any possible SVG text (some libraries use SVG) */
html.dark svg text {
    fill: #f8fafc !important;
}

/* Encabezados de tarjetas con utilidades en Modo Oscuro */
html.dark .card-header.bg-primary {
    background-color: #4f46e5 !important;
}

html.dark .card-header.bg-success {
    background-color: #059669 !important;
}

html.dark .card-header.bg-danger {
    background-color: #dc2626 !important;
}

html.dark .card-header.bg-warning {
    background-color: #d97706 !important;
}

/* WhatsApp Info Grid Modernization */
.info-grid-compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.info-item-card {
    background: var(--bg-main) !important;
    padding: 12px !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border-color) !important;
    display: flex !important;
    flex-direction: column !important;
    transition: all 0.3s ease !important;
}

.info-item-card:hover {
    border-color: var(--primary-color) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm) !important;
}

.info-label {
    font-size: 0.65rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    color: var(--text-muted) !important;
    font-weight: 600 !important;
    margin-bottom: 4px !important;
}

.info-value {
    font-size: 0.9rem !important;
    font-weight: 700 !important;
    color: var(--text-main) !important;
}

/* Notification Bar Fixes - Dark Mode */
html.dark .app-notification__title {
    background-color: #1e293b !important;
    color: #ffffff !important;
    border-bottom: 1px solid #334155 !important;
}

html.dark .app-notification__footer {
    background-color: #1e293b !important;
    border-top: 1px solid #334155 !important;
}

html.dark .app-notification__footer a {
    color: #ffffff !important;
    font-weight: 600 !important;
}

html.dark .app-notification__item {
    border-bottom: 1px solid #1e293b !important;
}

html.dark .app-notification__item:hover {
    background-color: #1e293b !important;
}

html.dark .app-notification__message {
    color: #f8fafc !important;
    /* Título y contenido principal */
}

html.dark .app-notification__meta {
    color: #94a3b8 !important;
    /* Tiempotranscurrido */
}

/* SweetAlert2 Modern Dark Mode Fixes - Aggressive Overrides */
html.dark .swal2-popup,
html.dark div.swal2-popup {
    background: #1e293b !important;
    color: #f8fafc !important;
    border: 1px solid #334155 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
}

html.dark .swal2-title,
html.dark .swal2-html-container,
html.dark .swal2-content {
    color: #f8fafc !important;
}

html.dark .swal2-icon {
    background-color: transparent !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

/* Fix for success icon circular white lines and fix element */
html.dark .swal2-icon.swal2-success [class^='swal2-success-circular-line'],
/* Global Bootstrap Alert Overrides for Dark Mode - High Priority */
html.dark .alert,
html.dark div.alert {
    border-width: 1px !important;
    backdrop-filter: blur(4px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2) !important;
}

html.dark .alert-success {
    background-color: rgba(16, 185, 129, 0.15) !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    color: #34d399 !important;
}

html.dark .alert-primary {
    background-color: rgba(99, 102, 241, 0.15) !important;
    border-color: rgba(99, 102, 241, 0.4) !important;
    color: #818cf8 !important;
}

html.dark .alert-info {
    background-color: rgba(14, 165, 233, 0.15) !important;
    border-color: rgba(14, 165, 233, 0.4) !important;
    color: #38bdf8 !important;
}

html.dark .alert-warning {
    background-color: rgba(245, 158, 11, 0.15) !important;
    border-color: rgba(245, 158, 11, 0.4) !important;
    color: #fbbf24 !important;
}

html.dark .alert-danger {
    background-color: rgba(239, 68, 68, 0.15) !important;
    border-color: rgba(239, 68, 68, 0.4) !important;
    color: #f87171 !important;
}

html.dark .alert-secondary {
    background-color: rgba(148, 163, 184, 0.15) !important;
    border-color: rgba(148, 163, 184, 0.4) !important;
    color: #cbd5e1 !important;
}

html.dark .alert-light {
    background-color: rgba(248, 250, 252, 0.1) !important;
    border-color: rgba(248, 250, 252, 0.2) !important;
    color: #f8fafc !important;
}

html.dark .alert-dark {
    background-color: rgba(15, 23, 42, 0.5) !important;
    border-color: rgba(30, 41, 59, 0.8) !important;
    color: #f1f5f9 !important;
}



html.dark .alert strong,
html.dark .alert b {
    color: currentColor !important;
    filter: brightness(1.2);
}

/* SweetAlert2 Modern Dark Mode Fixes - Aggressive Overrides */
html.dark .swal2-popup,
html.dark div.swal2-popup {
    background: #1e293b !important;
    color: #f8fafc !important;
    border: 1px solid #334155 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
}

html.dark .swal2-title,
html.dark .swal2-html-container,
html.dark .swal2-content {
    color: #f8fafc !important;
}

/* Fix for success icon circular white lines and fix element */
html.dark .swal2-icon {
    background-color: transparent !important;
}

html.dark .swal2-icon.swal2-success [class^='swal2-success-circular-line'],
html.dark .swal2-icon.swal2-success .swal2-success-fix,
html.dark .swal2-success-fix,
html.dark .swal2-success-circular-line-left,
html.dark .swal2-success-circular-line-right {
    background-color: transparent !important;
}

html.dark .swal2-icon.swal2-success .swal2-success-ring {
    border: .25em solid rgba(16, 185, 129, 0.3) !important;
}

html.dark .swal2-icon.swal2-info,
html.dark .swal2-icon.swal2-warning,
html.dark .swal2-icon.swal2-error,
html.dark .swal2-icon.swal2-question {
    background-color: transparent !important;
}

html.dark .swal2-timer-progress-bar {
    background: #10b981 !important;
}

/* DataTables Buttons & Controls Dark Mode Fixes - Aggressive */
html.dark .dt-buttons .dt-button,
html.dark .dt-buttons .btn,
html.dark .buttons-excel,
html.dark .buttons-print,
html.dark .button-excel,
html.dark .button-print {
    background: #1e293b !important;
    background-color: #1e293b !important;
    border: 1px solid #334155 !important;
    color: #f8fafc !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3) !important;
    padding: 6px 15px !important;
    border-radius: 6px !important;
}

html.dark .dt-buttons .dt-button:hover,
html.dark .dt-buttons .btn:hover {
    background: #334155 !important;
    background-color: #334155 !important;
    border-color: #475569 !important;
}


html.dark .dataTables_info,
html.dark .dataTables_paginate {
    color: #94a3b8 !important;
}

html.dark .page-link {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

html.dark .page-item.active .page-link {
    background-color: var(--primary-color) !important;
    border-color: var(--primary-color) !important;
}

html.dark .page-item.disabled .page-link {
    background-color: #0f172a !important;
    border-color: #1e293b !important;
    color: #475569 !important;
}

/* Bootstrap Select (SelectPicker) Dark Mode Fixes */
html.dark .bootstrap-select>.dropdown-toggle,
html.dark .bootstrap-select>.dropdown-toggle.bs-placeholder,
html.dark .bootstrap-select>.dropdown-toggle.bs-placeholder:hover,
html.dark .bootstrap-select>.dropdown-toggle.bs-placeholder:focus,
html.dark .bootstrap-select>.dropdown-toggle.bs-placeholder:active {
    background-color: #1e293b !important;
    background: #1e293b !important;
    border: 1px solid #334155 !important;
    color: #f8fafc !important;
    box-shadow: none !important;
}

html.dark .bootstrap-select .filter-option {
    color: #f8fafc !important;
}

html.dark .bootstrap-select .dropdown-toggle .caret {
    border-top-color: #94a3b8 !important;
}

/* Datepicker & Inputs Dark Mode Fixes */
html.dark input[type="date"],
html.dark input.datepicker,
html.dark .datepicker input {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

/* Specific fix for the white background in the image */
html.dark .bootstrap-select .btn-light,
html.dark .bootstrap-select .btn-default {
    background-color: #1e293b !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

/* Global Select fix */
html.dark select,
html.dark .form-control {
    background-color: #1e293b !important;
    color: #f8fafc !important;
    border-color: #334155 !important;
}

/* CSS imported from head.php */

/* Modern Premium Dashboard Widgets */
.widget-small {
    display: flex;
    border-radius: 12px !important;
    color: #fff !important;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    /* Sombra más suave */
    transition: all 0.3s ease;
    overflow: hidden;
    border: none !important;
    min-height: 75px;
    /* Un poco más bajo */
}

.widget-small:hover {
    transform: translateY(-4px);
    /* Salto menos pronunciado */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.widget-small .icon {
    display: flex;
    min-width: 60px;
    /* Más estrecho */
    align-items: center;
    justify-content: center;
    font-size: 24px;
    /* Icono más pequeño */
    background-color: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(2px);
}

.widget-small .info {
    padding: 10px 15px;
    /* Menos padding */
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    /* Evitar desbordes */
}

.widget-small .info h4,
.widget-small .info h5 {
    text-transform: uppercase;
    margin: 0;
    margin-bottom: 2px;
    font-weight: 600;
    font-size: 0.65rem;
    /* Título más pequeño */
    letter-spacing: 0.3px;
    color: rgba(255, 255, 255, 0.85);
    white-space: nowrap;
}

.widget-small .info p {
    margin: 0;
    font-size: 1.15rem;
    /* Fuente reducida para que entren números largos */
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-break: break-all;
    /* Permitir quiebre en casos extremos */
}

/* Ajuste para números muy largos con pipes */
.widget-small .info p .count-me {
    font-size: 1.15rem;
}

/* Pastel Gradient Themes */
.widget-small.primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.widget-small.info {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.widget-small.success {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

.widget-small.warning {
    background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
}

.widget-small.danger {
    background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
}

/* Dark Mode Compatibility */
html.dark .widget-small {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

/* Animation Classes */
@keyframes countUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Zoom centralizado arriba en la sección de capas críticas */

/* Fix table clipping: horizontal scroll is more important than zoom escape */
.table-responsive {
    overflow-x: auto !important;
    /* Cambiado de hidden a auto para evitar que se corte la última columna */
    /* overflow-y: hidden !important; */
    width: 100% !important;
    display: block !important;
}

#tbproductos {
    width: 100% !important;
}


/* El truco mágico: si hay un zoom activo, permitimos que el contenedor sea visible */
/* Solo cuando el mouse está quieto sobre la imagen */
.table-responsive:has(.zoom:hover) {
    overflow: visible !important;
}



/* Reducir escala para que no rompa tanto el layout en pantallas chicas */
@media (max-width: 1400px) {
    .zoom:hover {
        transform: scale(2.5) !important;
        transform-origin: center center;
    }
}


/* Compactar tabla en pantallas medianas/chicas */
@media (max-width: 1400px) {

    .table td,
    .table th {
        padding: 6px 6px !important;
        font-size: 0.75rem !important;
    }

    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1rem;
        border-radius: 8px;
    }
}

/* Force border-box to prevent fractional pixel overflow causing unnecessary scrollbars */
.table,
.table *,
table.dataTable,
table.dataTable * {
    box-sizing: border-box !important;
}

table.dataTable {
    width: 100% !important;
    margin: 0 !important;
}

.dataTable td:last-child {
    white-space: nowrap !important;
}


/* Fix para Timeline y Listas en Modo Oscuro */
html.dark .bg-light {
    background-color: rgba(255, 255, 255, 0.05) !important;
    color: #f8fafc !important;
}

html.dark .list-group-item {
    background-color: transparent !important;
    border-color: #334155 !important;
    color: #f8fafc !important;
}

html.dark .border-left {
    border-left-color: #475569 !important;
}

/* Asegurar contraste en el historial de OT */
html.dark .list-group-item .bg-light {
    border: 1px solid #334155 !important;
}

/* --- GLOBAL TABLE COLUMN HELPERS --- */
/* Estas clases se usan en Vender, Gestionar Venta, Compras, etc. */

.col-id-cod {
    width: 1% !important;
    white-space: nowrap !important;
    font-weight: 700 !important;
    min-width: 60px !important;
    text-align: center !important;
}

.col-number,
.col-cant,
.col-umed {
    width: 1% !important;
    white-space: nowrap !important;
    text-align: center !important;
    min-width: 50px !important;
}

.col-producto {
    width: auto !important;
    min-width: 200px !important;
    text-align: left !important;
}

.col-tax {
    width: 1% !important;
    white-space: nowrap !important;
    min-width: 65px !important;
    /* Reducido para evitar desbordes */
    text-align: right !important;
}

.col-punit,
.col-desc {
    width: 1% !important;
    white-space: nowrap !important;
    min-width: 90px !important;
    text-align: right !important;
}

.col-quitar {
    width: 1% !important;
    min-width: 45px !important;
    text-align: center !important;
}

/* Specific for Gestionar Venta / POS tables */
.table-pos thead th {
    color: #f8fafc !important;
    letter-spacing: 0.5px;
    padding: 8px 4px !important;
    white-space: nowrap;
}



/* === RESPONSIVE TABLE-POS: Scroll horizontal en móvil/tablet ===
 * El wrapper .table-responsive ya maneja el scroll.
 * Cancelamos table-layout:fixed + width:100% inline del controlador
 * hasta 1024px (cubre móvil y tablet portrait+landscape).
 * Desktop (>1024px) no se toca.
 */
@media (max-width: 1024px) {

    #tb_nueva_compra,
    #tb_nueva_venta,
    #tb_nuevo_presupuesto,
    .table-pos {
        table-layout: auto !important;
        width: auto !important;
        min-width: 680px !important;
        /* ancho mínimo legible, forza scroll */
    }
}

.table-pos tbody tr {
    transition: background-color 0.2s ease !important;
}

.table-pos tbody tr:hover {
    background-color: rgba(0, 166, 90, 0.03) !important;
}

/* Cells */
.table-pos td {
    padding: 4px 4px !important;
    /* border-bottom: 1px solid #e2e8f0 !important; */
    /* border-right: 1px solid #e2e8f0 !important; */
    /* font-size: 0.75rem !important; */
    color: #334155 !important;
    vertical-align: middle !important;
    /* word-break: break-word !important; */
}



html.dark .table-pos td {
    border-color: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

/* Zebra striping en modo oscuro con bordes claros */
html.dark .table-pos tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Specific product column */
/* .table-pos td:nth-child(3) {
    min-width: 120px !important;
    max-width: 250px !important;
    font-weight: 500;
} */

/* Inputs en la Tabla POS */
.table-pos .form-control {
    /* border: 1px solid #28a745 !important; */
    background: rgba(0, 0, 0, 0.01) !important;
    text-align: center;
    font-weight: 700;
    padding: 2px 2px !important;
    /* height: 30px !important; */
    /* min-width: 45px !important; */
    /* max-width: 90px !important; */
    margin: 0 auto !important;
}

html.dark .table-pos .form-control {
    border-color: rgba(255, 255, 255, 0.3) !important;
    background: rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
}

.table-pos .form-control:focus {
    background: #fff !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(0, 166, 90, 0.1) !important;
}

.table-pos textarea.form-control {
    text-align: left;
    /* min-width: 150px; */
    /* font-size: 0.75rem !important; */
    font-weight: 400;
}

/* Totals in footer */
.table-pos tfoot {
    background: #f8fafc !important;
}

html.dark .table-pos tfoot {
    background: rgba(255, 255, 255, 0.02) !important;
}


html.dark .table-pos tfoot td {
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.table-pos .text-primary b {
    /* font-size: 1.25rem !important; */
    color: var(--primary-color) !important;
}

/* Zebra striping for bordered table */
.table-pos tbody tr:nth-of-type(odd) {
    background-color: rgba(0, 0, 0, 0.02) !important;
}

html.dark .table-pos tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.02) !important;
}

/* Fin de Archivo - Estabilización Final */

/* Loader DataTables - Pequeño y discreto */
div.dataTables_processing {
    background: rgba(255, 255, 255, 0.85) !important;
    border-radius: 4px !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15) !important;
    max-width: 120px !important;
    margin: 0 auto !important;
    color: var(--text-muted) !important;
}

html.dark div.dataTables_processing {
    background: rgba(15, 23, 42, 0.9) !important;
    color: var(--text-muted) !important;
}

div.dataTables_processing:after {
    display: inline-block;
    content: "" !important;
}

/* Fix table-secondary en dark mode */
html.dark .table-secondary,
html.dark .table-secondary>td,
html.dark .table-secondary>th {
    background-color: #334155 !important;
    color: #f8fafc !important;
    border: none !important;
}

/* Fix flip indicator off en dark mode */
html.dark .toggle-flip input[type="checkbox"]+.flip-indecator:before {
    background-color: #475569 !important;
    color: #f8fafc !important;
    border: none !important;
}

/* Clase unificada para textarea obskude en tablas */
.textarea-obskude {
    margin: 0 auto !important;
    display: inline-block !important;
    resize: vertical !important;
    overflow-y: hidden !important;
    min-height: 32px !important;
    /* height: 32px !important; */
    width: 100% !important;
    padding: 2px !important;
}

/* Clases para Cart Tables (Vender, Pedir, Presupuestos) */
.table-cart-pos {
    font-size: 0.85rem !important;
    table-layout: auto !important;
    width: 100% !important;
}

.table-cart-pos thead th {
    padding: 4px !important;
    vertical-align: middle !important;
    white-space: nowrap !important;
}

.td-cart-middle {
    vertical-align: middle !important;
}

.input-cart-qty {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    margin: 0 auto !important;
    display: inline-block !important;
    padding: 2px !important;
}

.input-cart-price {
    width: 80px !important;
    min-width: 80px !important;
    max-width: 80px !important;
    margin: 0 auto !important;
    display: inline-block !important;
    padding: 2px !important;
}

.input-cart-desc {
    width: 65px !important;
    min-width: 65px !important;
    max-width: 65px !important;
    margin: 0 auto !important;
    display: inline-block !important;
    padding: 2px !important;
}

.input-cart-descp {
    width: 45px !important;
    min-width: 45px !important;
    max-width: 45px !important;
    margin: 0 auto !important;
    display: inline-block !important;
    padding: 2px !important;
}



.td-cart-tax-info {
    font-size: 0.8rem !important;
    padding: 4px !important;
    line-height: 1.2 !important;
}

/* User request: "Ese total arriba" and "Grande de nuevo" */
.total-amount-bar {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: var(--radius-lg);
    /* padding: 15px; */
    /* margin-bottom: 20px; */
    box-shadow: var(--shadow-md);
    border-left: 5px solid var(--primary-color);
}

.total-amount-bar .main-amount {
    font-size: 2.5rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    font-family: var(--font-main);
    display: block;
    line-height: 1;
}

.total-amount-bar .total-amount-inner {
    padding: 10px;
}

@media (max-width: 768px) {
    .total-amount-bar .main-amount {
        font-size: 2.2rem;
    }
}

/* --- SISTEMA DE FILTROS PREMIUM (DataTable Filters) --- */
.filter-container {
    background-color: #f1f5f9;
    padding: 4px;
    border-radius: 8px;
    display: inline-flex;
    gap: 2px;
}

html.dark .filter-container {
    background-color: #1e252b !important;
}

.filter-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #1e293b;
}

html.dark .filter-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
}

.filter-btn.active {
    background-color: #fff;
    color: #009688;
    border-bottom-color: #009688;
    box-shadow: none;
}

html.dark .filter-btn.active {
    background-color: #2d3748;
    color: #4fd1c5;
}

.filter-btn .badge {
    margin-left: 6px;
    font-size: 0.75rem;
    padding: 3px 6px;
}

.filter-scroll-wrapper::-webkit-scrollbar {
    height: 4px;
}

.filter-scroll-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 2px;
}

.filter-scroll-wrapper::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
}

.filter-tabs {
    border-bottom: 1px solid #e2e8f0;
}

.filter-tabs .d-flex {
    min-width: max-content;
}

@media (max-width: 767.98px) {
    .filter-tabs {
        margin-left: -1rem;
        margin-right: -1rem;
        padding-left: 0.5rem;
    }
}

.dt-filter-tabs .d-flex {
    min-width: max-content;
}

.dt-filter-tabs .filter-btn {
    border-radius: 0;
    border-bottom: 2px solid transparent;
    background: none;
    padding: 8px 12px;
}

.dt-filter-tabs .filter-btn.active {
    color: #009688;
    border-bottom-color: #009688;
    background: none;
    box-shadow: none;
}

.dt-filter-tabs {
    margin-left: -1rem;
    padding-left: 1rem;
    margin-right: -1rem;
    padding-right: 1rem;
}

@media (max-width: 767.98px) {

    .filter-btn .badge {
        padding: 2px 5px;
        font-size: 0.7rem;
    }
}

/* --- FIN SISTEMA DE FILTROS PREMIUM --- */

/* --- SISTEMA DE METRICAS (Dashboard Widgets Equal Height) --- */
.metric-row {
    display: flex;
    flex-wrap: wrap;
}

.metric-row>[class*="col-"] {
    display: flex;
}

.metric-row .widget-small {
    width: 100%;
    display: flex;
    align-items: stretch;
    cursor: pointer;
}

.metric-row .widget-small .info {
    flex: 1;
    min-width: 0;
    justify-content: center;
}

/* Fix para iconos en widget-small premium */
.widget-small .icon {
    margin: 0 !important;
    /* Eliminar márgenes manuales */
    padding: 0 15px;
    /* Espacio interno corregido */
}

/* --- FIN SISTEMA DE METRICAS --- */

/* --- DataTable Responsive Mobile --- */
@media (max-width: 767.98px) {
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table#tbDE,
    table#tbsuscripciones {
        min-width: 700px;
    }

    table#tbDE th,
    table#tbDE td,
    table#tbsuscripciones th,
    table#tbsuscripciones td {
        white-space: nowrap;
    }

    .filter-btn .badge {
        padding: 2px 5px;
        font-size: 0.7rem;
    }
}

/* --- FIN DataTable Responsive Mobile --- */

/* --- SAAS PREMIUM DATATABLES UI --- */
#tbclientes_filter {
    display: none !important;
}

.dt-premium-wrapper {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

/* --- AVATAR & UTILITIES --- */
:root {
    --primary-light: rgba(0, 150, 136, 0.1);
    --danger-light: rgba(244, 67, 54, 0.1);
}

.avatar-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
}

.bg-primary-light {
    background-color: var(--primary-light);
    color: #009688;
}

.bg-danger-light {
    background-color: var(--danger-light);
    color: #f44336;
}

/* Fix Select de Cantidad de Registros en modo Oscuro */
html.dark .dataTables_length select {
    background-color: var(--bg-hover);
    color: var(--text-main);
    border-color: var(--border-color);
}

html.dark .avatar-circle.bg-primary-light {
    background-color: rgba(0, 150, 136, 0.2);
    color: #009688;
}

html.dark .avatar-circle.bg-danger-light {
    background-color: rgba(244, 67, 54, 0.2);
    color: #f44336;
}


.dt-custom-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Tabs Estilo SaaS */
.filter-tabs-wrapper {
    display: flex;
    background: rgba(0, 0, 0, 0.03);
    padding: 4px;
    border-radius: 12px;
    gap: 2px;
}

html.dark .filter-tabs-wrapper {
    background: rgba(255, 255, 255, 0.05);
}

.filter-tab-btn {
    border: none;
    background: transparent;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.filter-tab-btn span {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
}

html.dark .filter-tab-btn span {
    background: rgba(255, 255, 255, 0.1);
}

.filter-tab-btn:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.02);
}

.filter-tab-btn.active {
    background: var(--bg-card);
    color: var(--primary-color) !important;
    box-shadow: var(--shadow-sm);
}

html.dark .filter-tab-btn.active {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 0.5px solid var(--primary-color);
    box-shadow: 0 0 10px rgba(0, 166, 90, 0.2);
}

.filter-tab-btn.active span {
    background: rgba(0, 166, 90, 0.1);
    color: var(--primary-color);
}

/* Buscador Moderno */
.premium-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 250px;
}

.premium-search-wrapper i {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.premium-search-input {
    width: 100%;
    padding: 10px 12px 10px 38px !important;
    background: rgba(0, 0, 0, 0.02) !important;
    border: 1.5px solid transparent !important;
    border-radius: 10px !important;
    font-size: 0.9rem !important;
    transition: all 0.2s ease !important;
}

html.dark .premium-search-input {
    background: rgba(255, 255, 255, 0.03) !important;
}

.premium-search-input:focus {
    background: var(--bg-card) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 4px rgba(0, 166, 90, 0.1) !important;
}

/* Indicadores de Filtros Activos */
.active-filters-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    min-height: 32px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(0, 166, 90, 0.08);
    color: var(--primary-color);
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid rgba(0, 166, 90, 0.1);
}

.filter-chip i {
    cursor: pointer;
    font-size: 0.8rem;
    opacity: 0.7;
}

.filter-chip i:hover {
    opacity: 1;
}

/* Ajuste específico para barras de filtros (Clientes/Ventas) en móvil */
@media (max-width: 767px) {

    /* Menú Notificaciones centrado en móvil */
    .app-notification {
        position: fixed !important;
        top: 55px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: 95vw !important;
        max-width: 350px !important;
        z-index: 10001 !important;
    }
}
/* --- UNIVERSAL SENDER MODULE --- */
:root {
    --sender-bg: var(--bg-card);
    --sender-text: var(--text-main);
    --sender-border: var(--border-color);
    --sender-input-bg: var(--bg-card);
    --sender-input-text: var(--text-main);
    --sender-history-bg: rgba(0,0,0,0.02);
}

/* Modo Oscuro (Valid Admin & Standard) */
body.dark-mode, body.dark-skin, html.dark {
    --sender-bg: #1e1e2d;
    --sender-text: #f8fafc;
    --sender-border: #334155;
    --sender-input-bg: #1a1a27;
    --sender-input-text: #f8fafc;
    --sender-history-bg: rgba(255,255,255,0.02);
}

.sender-adaptive-content {
    background-color: var(--sender-bg) !important;
    color: var(--sender-text) !important;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    border-radius: var(--radius-lg) !important;
    overflow: hidden;
}

.sender-adaptive-content .modal-header,
.sender-adaptive-content .modal-footer {
    border-color: var(--sender-border) !important;
    background-color: rgba(0,0,0,0.02);
}

.sender-adaptive-content .form-control,
.sender-adaptive-content .input-group-text {
    background-color: var(--sender-input-bg) !important;
    border-color: var(--sender-border) !important;
    color: var(--sender-input-text) !important;
}

.sender-adaptive-content .form-control[readonly] {
    opacity: 0.7;
    cursor: not-allowed;
}

.sender-adaptive-content .bg-light {
    background-color: var(--sender-history-bg) !important;
    color: var(--sender-text) !important;
}

.sender-adaptive-content .table-hover tbody tr:hover {
    background-color: rgba(255,255,255,0.05);
}

.method-selector-bar {
    background: rgba(0,0,0,0.03);
    border-bottom: 1px solid var(--sender-border);
}

body.dark-mode .method-selector-bar,
body.dark-skin .method-selector-bar,
html.dark .method-selector-bar {
    background: rgba(0,0,0,0.1);
}

/* Scrollbar sutil */
.history-table-container::-webkit-scrollbar { width: 5px; }
.history-table-container::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }
body.dark-mode .history-table-container::-webkit-scrollbar-thumb { background: #3c4b53; }

/* Ajustes para SweetAlert en Modo Oscuro */
body.dark-mode .sweet-alert, body.dark-skin .sweet-alert, html.dark .sweet-alert {
    background-color: #1e1e2d !important;
    color: #f8fafc !important;
}
body.dark-mode .sweet-alert p, body.dark-skin .sweet-alert p, html.dark .sweet-alert p { color: #94a3b8 !important; }
body.dark-mode .sweet-alert .btn-info, html.dark .sweet-alert .btn-info { background-color: var(--primary-color) !important; border-color: var(--primary-color) !important; }

/* [/UNIVERSAL SENDER MODULE] */

/* Utility classes for Universal Sender Logs */
.log-message-box {
    font-size: 11px;
    background: rgba(0,0,0,0.02);
    color: inherit;
    border: 1px solid var(--sender-border);
    padding: 10px;
    border-radius: var(--radius-md);
    max-height: 150px;
    overflow-y: auto;
    text-align: left;
}

.log-response-box {
    font-size: 10px;
    background: rgba(0,0,0,0.02);
    color: inherit;
    border: 1px solid var(--sender-border);
    padding: 8px;
    border-radius: var(--radius-md);
    text-align: left;
}

.log-json-pre {
    font-size: 10px;
    text-align: left;
    background: rgba(0,0,0,0.05);
    color: inherit;
    border: 1px solid rgba(0,0,0,0.1);
    padding: 5px;
    margin-top: 5px;
    max-height: 150px;
    overflow-y: auto;
    font-family: monospace;
}

/* Universal Sender Card Selectors */
.channel-card {
    background: rgba(0,0,0,0.02) !important;
    border: 1.5px solid var(--sender-border) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.channel-card.active {
    background: rgba(40, 167, 69, 0.08) !important;
    border-color: #28a745 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
}

.channel-card#card_email.active {
    background: rgba(23, 162, 184, 0.08) !important;
    border-color: #17a2b8 !important;
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.15);
}

/* Custom Square Checkbox */
.channel-card .custom-switch {
    padding-left: 0 !important;
}

.channel-card .custom-control-label::before {
    display: none !important;
}

.channel-card .custom-control-label::after {
    display: none !important;
}

.channel-card .chk-channel {
    position: absolute;
    width: 24px;
    height: 24px;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid var(--sender-border);
    border-radius: 6px;
    cursor: pointer;
    background: var(--sender-bg);
    transition: all 0.2s;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.channel-card .chk-channel:checked {
    background: #28a745;
    border-color: #28a745;
}

.channel-card#card_email .chk-channel:checked {
    background: #17a2b8;
    border-color: #17a2b8;
}

.channel-card .chk-channel:checked::after {
    content: "\f00c";
    font-family: FontAwesome;
    color: white;
    font-size: 12px;
}

.channel-card .check-icon { display: none !important; }

/* --- OPTIMIZACIÓN PARA PANTALLAS PEQUEÑAS (ALTURA) --- */
@media (max-height: 800px) {
    .app-sidebar__user {
        padding: 10px 20px !important;
        margin-bottom: 5px !important;
    }
    .app-sidebar__user-avatar {
        width: 60px !important;
    }
    .app-menu__item {
        padding: 8px 15px !important;
        margin: 2px 12px !important;
    }
    .treeview-item {
        padding: 4px 10px !important;
    }
}

@media (max-height: 650px) {
    .app-sidebar__user {
        display: none !important;
    }
    .app-menu__item {
        padding: 6px 15px !important;
        margin: 1px 12px !important;
    }
    .app-sidebar {
        padding-top: 50px !important;
    }
}
