:root {
    --primary-color: #001d7a;
    --accent-color: #4cc9f0;
    --text-color: #333;
    --bg-gradient: #f8faff;
    --glass-bg: #ffffff;
    --glass-border: #e0e6ed;
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

[data-theme="dark"] {
    /* Opción C: Diseño Basado en Imagen (Dark Slate/Blue-Grey) */
    --bg-gradient: #1e1e2d;
    /* Fondo base oscuro (Gris Azulado profundo) */

    /* Text Colors */
    --text-color: #ffffff;
    /* Texto BLANCO PURO para todo */
    --primary-color: #3699ff;
    /* Azul brillante típico de este estilo */
    --accent-color: #7239ea;
    /* Púrpura (como el botón 'Nuevo' de la imagen) */

    /* Cajas (Cards/Containers) */
    --glass-bg: #2b2b40;
    /* Fondo de cajas más claro que el base */
    --glass-border: #3b3b55;
    /* Borde sutil */
    --glass-shadow: 0 4px 12px 0 rgba(0, 0, 0, 0.4);
}

/* Toggle Button Style */
.theme-toggle-btn {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    margin-top: 10px;
    width: 100%;
    justify-content: center;
}

.theme-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    font-size: clamp(13px, 0.8vw + 8px, 15px);
}

/* Unify Background */
/* Unify Background */
body {
    background: var(--bg-gradient);
    min-height: 100vh;
    min-height: 100dvh;
    color: var(--text-color);
    /* Body color is handled by var(--text-color) */
    /* Mobile browser friendly */
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    100% {
        transform: translate(30px, 50px);
    }
}

/* Login Page Styles */
.login-wrapper {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: var(--glass-shadow);
    padding: 2rem;
    width: 100%;
    max-width: 750px;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    transform: translateY(20px);
    opacity: 0;
    animation: slideUp 0.8s forwards ease-out;
}

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

.logo-section {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border-right: 1px solid rgba(0, 29, 122, 0.1);
    padding-right: 2rem;
}

.logo-section img {
    max-width: 200px;
    height: auto;
}

.form-section {
    flex: 1;
    padding-left: 1rem;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    color: var(--primary-color);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary-color);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 29, 122, 0.1);
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    color: #555;
    font-weight: 500;
    font-size: 0.9rem;
    margin-left: 5px;
}

.btn-login {
    width: 100%;
    padding: 11px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0033cc 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 29, 122, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 29, 122, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: 0.5s;
}

.btn-login:hover::after {
    left: 100%;
}

.footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.85rem;
    color: #666;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.footer a:hover {
    color: var(--accent-color);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .login-wrapper {
        flex-direction: column;
        padding: 2rem;
        margin: 1rem;
    }

    .logo-section {
        border-right: none;
        border-bottom: 1px solid rgba(0, 29, 122, 0.1);
        padding-right: 0;
        padding-bottom: 2rem;
        margin-bottom: 1rem;
    }

    .shape {
        opacity: 0.6;
    }
}

/* Animations */
.shake {
    animation: shake 0.5s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: translate3d(-1px, 0, 0);
    }

    20%,
    80% {
        transform: translate3d(2px, 0, 0);
    }

    30%,
    50%,
    70% {
        transform: translate3d(-4px, 0, 0);
    }

    40%,
    60% {
        transform: translate3d(4px, 0, 0);
    }
}

/* --- Dashboard Styles --- */

/* Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    /* Mobile friendly */
    width: 100%;
    background: var(--bg-gradient);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--glass-bg);
    border-right: 1px solid var(--glass-border);
    padding: 1.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    height: 100dvh;
    /* Mobile friendly */
    z-index: 1000;
    transition: transform 0.3s ease;
}

/* Sidebar uses glass variables in both modes now */
[data-theme="dark"] .sidebar {
    background: var(--glass-bg);
    /* Match the card color like the image */
    border-right: 1px solid var(--glass-border);
}

.sidebar-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.sidebar-brand img {
    max-width: 150px;
    height: auto;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 12px;
    margin-bottom: 5px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover {
    background: rgba(76, 201, 240, 0.1);
    color: var(--primary-color);
    transform: translateX(5px);
}

.nav-link.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0033cc 100%);
    color: white !important;
    box-shadow: 0 4px 15px rgba(0, 29, 122, 0.2);
}

/* FORZAR TEXTO BLANCO EN TODO LADO EN MODO OSCURO */
[data-theme="dark"] body,
[data-theme="dark"] .glass-card,
[data-theme="dark"] .sidebar,
[data-theme="dark"] .modern-card,
[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] p,
[data-theme="dark"] span,
[data-theme="dark"] label,
[data-theme="dark"] th,
[data-theme="dark"] td,
[data-theme="dark"] .nav-link,
[data-theme="dark"] .small,
[data-theme="dark"] .text-muted {
    color: #ffffff !important;
}

/* Excepciones necesarias (Inputs y Selects) para que se lea lo que escriben */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
}

[data-theme="dark"] .form-control::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
}

/* Nav Links in Dark Mode */
[data-theme="dark"] .sidebar .nav-link:not(.active) {
    color: #ffffff !important;
}

[data-theme="dark"] .sidebar .nav-link:not(.active):hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .sidebar-brand,
[data-theme="dark"] .tree-root,
[data-theme="dark"] .stat-title,
[data-theme="dark"] .modern-card-header h6 {
    color: #fff !important;
}

[data-theme="dark"] .sidebar p {
    color: #aaa !important;
}

.nav-icon {
    margin-right: 10px;
    font-size: 1.2rem;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 250px;
    padding: clamp(1.2rem, 4vw, 2.5rem);
    overflow-y: auto;
    height: 100vh;
    height: 100dvh;
    /* Mobile friendly */
}

/* Cards */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: clamp(1rem, 3vw, 1.2rem);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    margin-bottom: clamp(1rem, 3vw, 1.2rem);
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px 0 rgba(31, 38, 135, 0.1);
}

.stat-card {
    text-align: center;
    cursor: pointer;
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    background: rgba(76, 201, 240, 0.2);
    width: 50px;
    height: 50px;
    line-height: 50px;
    border-radius: 50%;
    margin: 0 auto 0.75rem;
    color: var(--primary-color);
}

.stat-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.4rem;
}

.stat-desc {
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.glass-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.glass-table th {
    background: rgba(0, 29, 122, 0.05);
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary-color);
    border-bottom: 2px solid rgba(0, 29, 122, 0.1);
}

.glass-table td {
    padding: 12px;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    color: #555;
}

.glass-table tr:hover td {
    background: rgba(255, 255, 255, 0.5);
}

/* Dark Mode Table Enhancements */
[data-theme="dark"] .glass-table th {
    background-color: rgba(255, 255, 255, 0.05);
    /* Slight separation for header */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff !important;
    white-space: nowrap;
    /* Prevent awkward wrapping in headers */
    font-weight: 700;
}

[data-theme="dark"] .glass-table td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #ffffff !important;
}

[data-theme="dark"] .glass-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.03);
    /* Subtle hover in dark mode */
}

/* para la direccion*/
.td-observacion {
    white-space: normal;
    /* permite salto de línea */
    word-break: break-word;
    /* rompe palabras largas */
    max-width: 380px;
    /* límite visual */
    line-height: 1.4;
}


/* Buttons */
.btn-primary-glass {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0033cc 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 29, 122, 0.2);
}

.btn-primary-glass:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 29, 122, 0.3);
}

.btn-logout {
    background: rgba(220, 53, 69, 0.1);
    color: #dc3545;
    border: 1px solid rgba(220, 53, 69, 0.2);
    padding: 10px;
    border-radius: 10px;
    width: 100%;
    text-align: center;
    text-decoration: none;
    display: block;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-logout:hover {
    background: #dc3545;
    color: white;
}

/* Responsive Dashboard */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 10000;
        /* High z-index for mobile overlay */
    }

    .main-content {
        margin-left: 0;
    }
}

/* Tree View Styles */
.tree-root {
    position: relative;
    margin-bottom: 20px;
    z-index: 2;
}

.tree-branches {
    position: relative;
    padding-left: 40px;
    border-left: 2px solid rgba(0, 29, 122, 0.2);
    margin-left: 20px;
}

.tree-node {
    position: relative;
    margin-bottom: 15px;
}

.tree-node::before {
    content: '';
    position: absolute;
    top: 50%;
    left: -40px;
    width: 40px;
    height: 2px;
    background: rgba(0, 29, 122, 0.2);
    transform: translateY(-50%);
}

.tree-node:last-child {
    margin-bottom: 0;
}

.tree-branches::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -2px;
    width: 2px;
    height: calc(100% - 25px);
    background: #fff;
    display: none;
}

/* Sidebar Specific Tree View Styles (Compact) */
.sidebar .tree-branches {
    padding-left: 15px !important;
    margin-left: 10px !important;
    border-left-width: 1px;
}

.sidebar .tree-node {
    margin-bottom: 2px;
}

.sidebar .tree-node::before {
    width: 12px;
    left: -16px;
}

.sidebar .nav-link {
    padding: 8px 12px;
    font-size: 0.9rem;
}

.sidebar .tree-root {
    margin-bottom: 10px;
    padding-left: 10px;
}

/* Contact Page Specific */
.contacts-area {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

/* Modal Styles */
.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

.modal-header {
    border-bottom: 1px solid rgba(0, 29, 122, 0.1);
}

.modal-footer {
    border-top: 1px solid rgba(0, 29, 122, 0.1);
}

/* Card Headers in Modals */
.card-header {
    background: rgba(66, 135, 245, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1rem;
}

.card-body {
    padding: 1rem;
}

/* Utility Classes */
.text-primary {
    color: var(--primary-color) !important;
}

.fw-bold {
    font-weight: 700 !important;
}

.fw-semibold {
    font-weight: 600 !important;
}

.small {
    font-size: 0.875rem !important;
}

/* Modal Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.modal.show .modal-dialog {
    animation: fadeIn 0.3s ease-out;
}

.modal.show .card {
    animation: fadeInUp 0.5s ease-out backwards;
}

.modal.show .row:nth-child(1) .card:nth-child(1) {
    animation-delay: 0.1s;
}

.modal.show .row:nth-child(1) .card:nth-child(2) {
    animation-delay: 0.2s;
}

.modal.show .row:nth-child(2) .card:nth-child(1) {
    animation-delay: 0.3s;
}

.modal.show .row:nth-child(2) .card:nth-child(2) {
    animation-delay: 0.4s;
}

.modal.show .row:nth-child(3) .card {
    animation-delay: 0.5s;
}

/* --- Premium Modal & Execution Styles --- */

.modern-card {
    background: var(--glass-bg);
    border: none;
    border-radius: 16px;
    padding: 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.modern-card-header h6 {
    font-size: 0.95rem;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

/* Floating Labels Upgrade */
.modern-floating>.form-control,
.modern-floating>.form-select {
    padding: 1.625rem 0.75rem 0.625rem !important;
    height: calc(3.5rem + 2px) !important;
    line-height: 1.25 !important;
}

.modern-floating>label {
    padding: 1rem 0.75rem !important;
    color: #6c757d !important;
}

.modern-floating>.form-control:focus~label,
.modern-floating>.form-control:not(:placeholder-shown)~label,
.modern-floating>.form-select~label {
    transform: scale(0.85) translateY(-0.75rem) translateX(0.15rem) !important;
    color: #0061f2 !important;
}

/* Premium Buttons */
.btn-premium-success {
    background: #28a745;
    color: white;
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-premium-success:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(40, 167, 69, 0.3);
    color: white;
}

.btn-premium-outline-danger {
    background: transparent;
    color: #dc3545;
    border: 2px solid #dc3545;
    border-radius: 12px;
    padding: 12px 20px;
    font-weight: 700;
    transition: all 0.3s ease;
}

.btn-premium-outline-danger:hover {
    background: #dc3545;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(220, 53, 69, 0.2);
}

.btn-premium-green {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    transition: all 0.3s ease;
}

.btn-premium-green:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.4);
    color: white;
}

.btn-light-secondary {
    background: #f1f5f9;
    color: #64748b;
    border: none;
    transition: all 0.3s ease;
}

.btn-light-secondary:hover {
    background: #e2e8f0;
    color: #475569;
}

/* Scrollbar Styling for Dark Mode */
@media (min-width: 768px) {
    [data-theme="dark"] ::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }

    [data-theme="dark"] ::-webkit-scrollbar-track {
        background: #1e1e2d;
    }

    [data-theme="dark"] ::-webkit-scrollbar-thumb {
        background: #3b3b55;
        border-radius: 4px;
    }

    [data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
        background: #565674;
    }
}

/* ==================================== 
   FIX FOR TECHNICAL PORTAL (DARK MODE) 
   ==================================== */
[data-theme="dark"] .hero-card {
    background: var(--glass-bg);
    /* Use the dark card color */
    border-color: var(--glass-border);
}

[data-theme="dark"] .nav-card {
    background: var(--glass-bg);
    border-color: var(--glass-border);
}

[data-theme="dark"] .nav-card:hover {
    background: #3b3b55;
    /* Slightly lighter on hover */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    border-color: var(--primary-color);
}

[data-theme="dark"] .nav-card .icon-wrapper {
    background: rgba(255, 255, 255, 0.05);
    /* Darker icon background */
    box-shadow: none;
    color: #fff;
}

[data-theme="dark"] .nav-card:hover .icon-wrapper {
    background: var(--primary-color);
    color: #fff;
}

[data-theme="dark"] .hero-content h2,
[data-theme="dark"] .hero-content p,
[data-theme="dark"] .nav-card h3,
[data-theme="dark"] .nav-card p {
    color: #fff !important;
    /* Ensure text is white */
}

/* Background circles for hero card in dark mode - make them subtle */
[data-theme="dark"] .hero-card::before,
[data-theme="dark"] .hero-card::after {
    opacity: 0.1;
}

/* Custom Scrollbar for Modal Body */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f8fafc;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.modal.show .table-container {
    animation: fadeInUp 0.5s ease-out 0.6s backwards;
}

.modal-body .badge {
    transition: transform 0.2s ease;
}

.btn-logout:hover {
    background: #dc3545;
    color: white;
}

/* Custom Modal Enhancements */
.modal.show h6 {
    animation: fadeIn 0.5s ease-out 0.5s backwards;
}

.modal.show h6 {
    animation: fadeIn 0.5s ease-out 0.5s backwards;
}

/* Elegant Card Borders for Modal */
.modal-body .card {
    border: 2px solid transparent;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5)),
        linear-gradient(135deg, rgba(0, 29, 122, 0.3), rgba(76, 201, 240, 0.3));
    background-origin: border-box;
    background-clip: padding-box, border-box;
    box-shadow:
        0 4px 20px rgba(0, 29, 122, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: all 0.3s ease;
}

.modal-body .card:hover {
    border: 2px solid transparent;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.6)),
        linear-gradient(135deg, rgba(0, 29, 122, 0.5), rgba(76, 201, 240, 0.5));
    box-shadow:
        0 8px 30px rgba(0, 29, 122, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 1),
        0 0 20px rgba(76, 201, 240, 0.2);
    transform: translateY(-2px);
}

/* --- Mobile Sidebar Toggle Fix --- */
.btn-menu {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    display: none;
    /* Hidden by default on desktop */
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.btn-menu:hover {
    background: #0033cc;
    transform: scale(1.05);
}

@media (max-width: 992px) {
    .btn-menu {
        display: block;
    }

    .sidebar.active {
        transform: translateX(0) !important;
    }
}

/* Sidebar Overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

/* ======================================================
   ENHANCED MOBILE RESPONSIVENESS
   ====================================================== */

/* Better Table Scrolling on Mobile */
@media (max-width: 768px) {
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -1.2rem;
        padding: 0 1.2rem;
    }

    .glass-table {
        min-width: 800px;
    }

    .glass-table th,
    .glass-table td {
        white-space: nowrap;
        padding: 10px 8px;
        font-size: 0.85rem;
    }
}

/* Modal Improvements for Mobile */
@media (max-width: 576px) {
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem);
    }

    .modal-body {
        padding: 1rem;
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-footer {
        padding: 1rem;
    }

    /* Better form spacing on mobile */
    .row.g-3 {
        row-gap: 0.75rem !important;
    }

    .col-md-6,
    .col-md-4,
    .col-md-3 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }

    /* Larger touch targets for buttons */
    .btn,
    .btn-primary-glass,
    .btn-logout {
        min-height: 44px;
        padding: 12px 16px;
    }

    .form-control {
        min-height: 44px;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Stack buttons vertically on very small screens */
    .d-flex.gap-2 {
        flex-direction: column;
        gap: 0.5rem !important;
    }

    .d-flex.gap-2 .btn,
    .d-flex.gap-2 .form-control {
        width: 100%;
    }
}

/* Improved Main Content Padding on Mobile */
@media (max-width: 768px) {
    .main-content {
        padding: 1.5rem 1rem;
        padding-top: 4rem;
        /* Extra space for menu button */
    }

    .glass-card {
        padding: 1rem;
        margin-bottom: 1rem;
    }

    /* Better stat cards on mobile */
    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        line-height: 40px;
        font-size: 1.5rem;
    }

    .stat-title {
        font-size: 0.9rem;
    }

    .stat-desc {
        font-size: 0.8rem;
    }
}

/* Extra Small Devices (320px and up) */
@media (max-width: 375px) {
    body {
        font-size: 13px;
    }

    .sidebar {
        width: 100%;
    }

    .btn-menu {
        top: 10px;
        left: 10px;
        padding: 6px 10px;
        font-size: 1.1rem;
    }

    .glass-card h5,
    .glass-card h6 {
        font-size: 1rem;
    }

    .modal-title {
        font-size: 1.1rem;
    }
}

/* Landscape Orientation Fixes for Mobile */
@media (max-width: 992px) and (orientation: landscape) {
    .sidebar {
        width: 250px;
    }

    .main-content {
        padding: 1rem;
    }
}

/* Print Styles */
@media print {

    .sidebar,
    .btn-menu,
    .sidebar-overlay,
    .btn-logout {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 0 !important;
    }

    .glass-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* ======================================================
   TECNICO PORTAL REDESIGN
   ====================================================== */

/* Hero Card */
.hero-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.6) 100%);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 24px;
    padding: clamp(1.2rem, 5vw, 2.5rem);
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.05),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.hero-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(76, 201, 240, 0.2) 0%, transparent 70%);
    filter: blur(40px);
    z-index: 0;
}

.hero-card::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, rgba(0, 29, 122, 0.1) 0%, transparent 70%);
    filter: blur(40px);
    z-index: 0;
}

.hero-content {
    position: relative;
    z-index: 1;
}

/* Nav Cards Premium */
.nav-card {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 20px;
    padding: 2rem;
    height: 100%;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.nav-card:hover {
    transform: translateY(-8px) scale(1.02);
    background: rgba(255, 255, 255, 0.95);
    box-shadow:
        0 20px 40px rgba(0, 29, 122, 0.12),
        0 0 0 1px rgba(76, 201, 240, 0.3);
    border-color: rgba(76, 201, 240, 0.5);
}

.nav-card .icon-wrapper {
    width: 70px;
    height: 70px;
    border-radius: 20px;
    background: linear-gradient(135deg, #f0f4ff 0%, #e6eeff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    font-size: 1.8rem;
    transition: all 0.4s ease;
    box-shadow:
        0 8px 20px rgba(0, 29, 122, 0.1),
        inset 0 2px 5px rgba(255, 255, 255, 1);
}

.nav-card:hover .icon-wrapper {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0033cc 100%);
    color: white;
    transform: rotateY(10deg) scale(1.1);
    box-shadow: 0 10px 25px rgba(0, 29, 122, 0.3);
}

.nav-card h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 0.5rem;
    transition: color 0.3s ease;
}

.nav-card:hover h3 {
    color: var(--primary-color);
}

.nav-card p {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 1.5rem;
    line-height: 1.5;
}

.nav-card .action-arrow {
    margin-top: auto;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: rgba(0, 29, 122, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-color);
    transition: all 0.3s ease;
    opacity: 0.7;
}

.nav-card:hover .action-arrow {
    background: var(--accent-color);
    color: white;
    transform: translateX(5px);
    opacity: 1;
}

/* Staggered Animation for Cards */
.animate-up {
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

.delay-1 {
    animation-delay: 0.1s;
}

.delay-2 {
    animation-delay: 0.2s;
}

.delay-3 {
    animation-delay: 0.3s;
}

.delay-4 {
    animation-delay: 0.4s;
}

.delay-5 {
    animation-delay: 0.5s;
}

/* ==================================== 
   KPI & BADGE STYLES (Maintenance Page) 
   ==================================== */

/* KPI Cards */
.kpi-card {
    border-radius: 16px;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid #eef2f7;
    text-align: center;
    transition: transform 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-5px);
}

.kpi-val {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.2rem;
}

.kpi-label {
    font-size: 0.85rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Dark Mode KPI */
[data-theme="dark"] .kpi-card {
    background: var(--glass-bg);
    border-color: var(--glass-border);
}

[data-theme="dark"] .kpi-val {
    color: #fff !important;
    /* Force white for value */
}

[data-theme="dark"] .kpi-label {
    color: #a1a5b7 !important;
    /* Muted white for label */
}

/* Dark Mode Badges (Fixing readability) */
[data-theme="dark"] .badge {
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

/* Specific Badge Adjustments for Dark Mode */
[data-theme="dark"] .badge.bg-warning {
    background-color: rgba(255, 193, 7, 0.2) !important;
    /* Dark transparent yellow */
    color: #ffc107 !important;
    /* Bright yellow text */
}

[data-theme="dark"] .badge.bg-success {
    background-color: rgba(25, 135, 84, 0.2) !important;
    color: #20c997 !important;
}

[data-theme="dark"] .badge.bg-info-subtle {
    background-color: rgba(13, 202, 240, 0.2) !important;
    color: #0dcaf0 !important;
}

[data-theme="dark"] .badge.bg-danger-subtle {
    background-color: rgba(220, 53, 69, 0.2) !important;
    color: #ff6b6b !important;
}

[data-theme="dark"] .badge.bg-secondary {
    background-color: rgba(108, 117, 125, 0.2) !important;
    color: #adb5bd !important;
}

[data-theme="dark"] .badge.bg-light {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
    border-color: #3b3b55 !important;
}

/* ==================================== 
   MODAL DARK MODE FIX
   ==================================== */
[data-theme="dark"] .modal-content {
    background-color: #2b2b40;
    /* Dark Slate background */
    border: 1px solid #3b3b55;
    color: #ffffff;
}

[data-theme="dark"] .modal-header {
    border-bottom: 1px solid #3b3b55;
    background-color: #2b2b40 !important;
    /* Force dark background */
    color: white !important;
}

[data-theme="dark"] .modal-footer {
    border-top: 1px solid #3b3b55;
    background-color: #2b2b40 !important;
    /* Force dark background */
}

[data-theme="dark"] .modal-title {
    color: #ffffff !important;
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
    /* Make 'X' white */
}

/* Fix Labels in Modals */
[data-theme="dark"] .modal-body label {
    color: #e2e5e9 !important;
}

/* Ensure inputs in modals are definitely dark */
[data-theme="dark"] .modal-body .form-control,
[data-theme="dark"] .modal-body .form-select {
    background-color: #1e1e2d !important;
    /* Slightly darker than modal bg */
    border-color: #3b3b55 !important;
    color: #fff !important;
}

[data-theme="dark"] .modal-body .form-control:focus,
[data-theme="dark"] .modal-body .form-select:focus {
    border-color: var(--primary-color) !important;
    background-color: #1e1e2d !important;
    box-shadow: 0 0 0 0.25rem rgba(54, 153, 255, 0.25) !important;
}

/* ==================================== 
   MAPA MODAL & PRESUPUESTOS DARK FIX 
   ==================================== */
[data-theme="dark"] .modal-body {
    background-color: #2b2b40 !important;
    color: #fff !important;
}

[data-theme="dark"] .detail-box {
    background-color: #1e1e2d !important;
    /* Darker inset */
    border-color: #3b3b55 !important;
    color: #fff !important;
}

[data-theme="dark"] .detail-box h5,
[data-theme="dark"] .section-title {
    color: #fff !important;
}

[data-theme="dark"] .info-label {
    color: #a1a5b7 !important;
    /* Muted text */
}

[data-theme="dark"] .info-value,
[data-theme="dark"] .detail-box .row,
[data-theme="dark"] .detail-box dl {
    color: #fff !important;
}

/* Customer Badge */
[data-theme="dark"] .customer-badge {
    background-color: #1e1e2d !important;
    color: #fff !important;
    border: 1px solid #3b3b55;
}

[data-theme="dark"] .customer-badge .text-muted {
    color: #a1a5b7 !important;
}

[data-theme="dark"] .customer-badge .avatar {
    color: #ffffff !important;
    background: var(--primary-color) !important;
    /* Ensure visible background */
}

/* Modal Table */
[data-theme="dark"] .modal-body .table {
    color: #fff !important;
    border-color: #3b3b55 !important;
    --bs-table-color: #fff;
    --bs-table-bg: transparent;
    --bs-table-border-color: #3b3b55;
    --bs-table-hover-color: #fff;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.05);
}

/* ==================================== 
   CREATE TICKET DARK MODE FIX 
   ==================================== */
[data-theme="dark"] .form-label-premium {
    color: #e2e5e9 !important;
    /* Make labels light grey */
}

/* Fix specific inputs in Create Ticket that might not be caught globally */
[data-theme="dark"] .glass-card .form-control,
[data-theme="dark"] .glass-card .form-select {
    background-color: #1e1e2d !important;
    border-color: #3b3b55 !important;
    color: #fff !important;
}

/* Fix Section Header in Create Ticket */
[data-theme="dark"] .section-header {
    color: #fff !important;
    border-bottom: 2px solid #3b3b55 !important;
}

/* ==================================== 
   MODAL CREATE TICKET (CONTACT.HTML) FIX 
   ==================================== */
[data-theme="dark"] #createTicketModal .modal-content {
    background-color: #2b2b40 !important;
    color: #fff !important;
}

[data-theme="dark"] #createTicketModal .modal-header {
    background-color: #2b2b40 !important;
    border-bottom: 1px solid #3b3b55 !important;
}

[data-theme="dark"] #createTicketModal .modal-title {
    color: #fff !important;
}

/* Override bootstrap text-dark and text-muted inside this modal */
[data-theme="dark"] #createTicketModal .text-dark {
    color: #fff !important;
}

[data-theme="dark"] #createTicketModal .text-muted {
    color: #a1a5b7 !important;
}

/* Fix the inline-styled icon */
[data-theme="dark"] #createTicketModal .bi-gear-fill {
    color: var(--primary-color) !important;
}

/* Fix textareas and selects with inline borders */
[data-theme="dark"] #createTicketModal textarea,
[data-theme="dark"] #createTicketModal select {
    background-color: transparent !important;
    color: #fff !important;
    border-color: #3b3b55 !important;
}

[data-theme="dark"] #createTicketModal select option {
    background-color: #1e1e2d;
    color: #fff;
}

/* ==================================== 
   SEARCHABLE DROPDOWN (CANAL) 
   ==================================== */
/* LIGHT MODE (DEFAULT) STYLES FOR CANAL DROPDOWN */
#canal-results {
    background-color: #ffffff !important;
    border: 1px solid #dee2e6;
    color: #2b2b2b;
    z-index: 1050;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    opacity: 1 !important;
}

.canal-result-item {
    background-color: #ffffff !important;
    color: #2b2b2b;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.1s ease;
    opacity: 1 !important;
}

.canal-result-item:hover {
    background-color: #f8f9fa !important;
    color: #000 !important;
}

/* FORCE SOLIDITY IN DARK MODE ONLY */
[data-theme="dark"] #canal-results,
[data-theme="dark"] .super-opaque-dropdown {
    background-color: #1e1e2d !important;
    border: 1px solid #3b3b55 !important;
    color: #ffffff !important;
    opacity: 1 !important;
    z-index: 1050 !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.75) !important;
    isolation: isolate !important;
}

[data-theme="dark"] .canal-result-item {
    background-color: #1e1e2d !important;
    color: #ffffff !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
    transition: background-color 0.1s ease !important;
}

[data-theme="dark"] .canal-result-item:hover,
[data-theme="dark"] .canal-result-item:focus {
    background-color: #3699ff !important;
    color: #ffffff !important;
    opacity: 1 !important;
}

[data-theme="dark"] .modal-body .table thead,
[data-theme="dark"] .modal-body .table thead.bg-light {
    background-color: #1e1e2d !important;
    /* Darker header */
}

[data-theme="dark"] .modal-body .table thead th {
    background-color: #1e1e2d !important;
    color: #fff !important;
    border-bottom: 2px solid #3b3b55 !important;
}

[data-theme="dark"] .modal-body .table-container {
    border-color: #3b3b55 !important;
}

/* Fix Inputs inside Detail Box */
[data-theme="dark"] .task-input,
[data-theme="dark"] .task-textarea {
    background-color: #1e1e2d !important;
    border-color: #3b3b55 !important;
    color: #fff !important;
}