/* =========================================
   1. VARIABLES Y RESET GENERAL
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&family=Poppins:wght@300;400;600;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

:root {
    /* Colores Corporativos */
    --primary: #0066ff;
    --primary-hover: #0052cc;
    --secondary: #64748b;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    
    /* Fondos */
    --bg-light: #ffffff;
    --bg-alt: #f1f5f9;
    --border: #e2e8f0;
    
    /* Variables del Sidebar */
    --sidebar-bg: #11101d;
    --sidebar-hover: #1d1b31;
    --sidebar-text: #ffffff;
    --sidebar-closed: 78px;
    --sidebar-open: 250px;
}

body {
    background-color: var(--bg-alt);
    color: var(--text-dark);
    /* Importante para el Login centrado: */
    min-height: 100vh; 
}

a { text-decoration: none; }

/* =========================================
   2. ESTILOS DEL LOGIN (RESTAURADO Y MEJORADO)
   ========================================= */
/* Esto centra la caja de login en la pantalla */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
}

.login-container {
    background: white;
    width: 100%;
    max-width: 420px; /* Un poco más ancho para elegancia */
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.08); /* Sombra suave */
    border: 1px solid white;
    margin: 20px; /* Margen para móviles */
    text-align: center;
}

.login-header { margin-bottom: 30px; }
.login-header h2 { font-size: 24px; color: var(--text-dark); font-weight: 800; }
.login-header p { color: var(--text-muted); font-size: 14px; }

/* Inputs del Login */
.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    transition: 0.3s;
    background: #f8fafc;
}

.form-control:focus {
    border-color: var(--primary);
    background: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

/* Botón de Login */
.btn-full {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 10px;
}
.btn-full:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 102, 255, 0.3);
}

.auth-links { margin-top: 20px; font-size: 13px; }
.auth-links a { color: var(--primary); font-weight: 600; }

/* =========================================
   3. ESTILOS DE LA LANDING PAGE (PORTADA)
   ========================================= */

/* Navbar Transparente */
.nav-bar {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
}
.nav-content {
    max-width: 1200px; margin: 0 auto; padding: 0 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.nav-links { display: flex; gap: 25px; align-items: center; }
.nav-links a { color: var(--text-dark); font-weight: 500; transition: 0.3s; }
.nav-links a:hover { color: var(--primary); }

.btn-login-nav {
    background: var(--primary); color: white !important;
    padding: 10px 20px; border-radius: 50px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(rgba(15, 23, 42, 0.7), rgba(15, 23, 42, 0.8)), url('https://images.unsplash.com/photo-1599809275671-b5942cabc7a2?q=80&w=2070&auto=format&fit=crop');
    background-size: cover; background-position: center;
    height: 90vh;
    display: flex; align-items: center; justify-content: center;
    text-align: center; color: white;
}
.hero-title { font-size: 3.5rem; font-weight: 800; line-height: 1.2; margin-bottom: 20px; }
.text-gradient { color: #4ade80; }

.hero-buttons { display: flex; gap: 20px; justify-content: center; margin-top: 30px; }
.btn-hero { padding: 15px 35px; border-radius: 50px; font-weight: 700; transition: 0.3s; }
.btn-hero.primary { background: #f59e0b; color: white; border: none; }
.btn-hero.secondary { background: rgba(255,255,255,0.1); color: white; border: 1px solid white; }

/* Tarjetas de Proyectos */
.features-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px; max-width: 1200px; margin: 50px auto; padding: 0 20px;
}
.feature-card {
    background: white; border-radius: 20px; overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05); border: 1px solid var(--border);
    transition: 0.3s;
}
.feature-card:hover { transform: translateY(-10px); }
.feature-card img { width: 100%; height: 240px; object-fit: cover; }
.card-body { padding: 25px; }

/* =========================================
   4. ESTILOS DEL DASHBOARD / SIDEBAR (SISTEMA)
   ========================================= */
.sidebar {
    position: fixed; top: 0; left: 0; height: 100%; width: 78px;
    background: var(--sidebar-bg); z-index: 100; transition: all 0.5s ease;
    padding: 6px 0; overflow-x: hidden;
}
.sidebar.open { width: 250px; }

/* Contenido Principal del Dashboard */
.home-section {
    position: relative; background: var(--bg-alt); min-height: 100vh;
    top: 0; left: 78px; width: calc(100% - 78px);
    transition: all 0.5s ease; z-index: 2; padding: 30px;
}
.sidebar.open ~ .home-section { left: 250px; width: calc(100% - 250px); }

/* Tablas y Elementos del Sistema */
.table-container {
    background: #fff; padding: 25px; border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02); border: 1px solid var(--border);
}
.custom-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.custom-table th { padding: 15px; border-bottom: 2px solid #f1f5f9; color: var(--text-muted); }
.custom-table td { padding: 15px; border-bottom: 1px solid #f1f5f9; }

/* Tarjetas de Estadísticas */
.stat-card {
    background: white; padding: 20px; border-radius: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.03); border: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-bottom: 30px; }
/* =========================================
   SIDEBAR PROFESIONAL - CORRECCIÓN TOTAL
   ========================================= */
:root {
    --sidebar-bg: #11101d;
    --sidebar-hover: #1d1b31;
    --sidebar-text: #ffffff;
    --sidebar-closed: 78px;
    --sidebar-open: 250px;
    --primary-color: #0066ff;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--sidebar-closed);
    background: var(--sidebar-bg);
    z-index: 100;
    transition: all 0.5s ease;
    padding: 6px 0;
    overflow-x: hidden;
}

.sidebar.open {
    width: var(--sidebar-open);
}

/* --- LOGO Y BOTÓN --- */
.sidebar .logo-details {
    height: 60px;
    display: flex;
    align-items: center;
    position: relative;
}

.sidebar .logo-details .icon {
    opacity: 0;
    transition: all 0.5s ease;
    font-size: 28px;
    color: var(--sidebar-text);
    min-width: var(--sidebar-closed);
    display: flex;
    justify-content: center;
}

.sidebar.open .logo-details .icon {
    opacity: 1;
}

.sidebar .logo-details .logo_name {
    color: var(--sidebar-text);
    font-size: 20px;
    font-weight: 600;
    opacity: 0;
    transition: all 0.5s ease;
    white-space: nowrap;
    margin-left: 10px;
}

.sidebar.open .logo-details .logo_name {
    opacity: 1;
}

#btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 23px;
    cursor: pointer;
    transition: all 0.5s ease;
    color: var(--sidebar-text);
}

.sidebar.open #btn {
    left: auto;
    right: 15px;
    transform: translateY(-50%);
}

/* --- LISTA DE NAVEGACIÓN --- */
.sidebar .nav-list {
    margin-top: 20px;
    padding: 0;
}

.sidebar li {
    position: relative;
    list-style: none;
    width: 100%;
    height: 50px;
    margin-bottom: 5px;
}

.sidebar li a {
    display: flex;
    align-items: center;
    text-decoration: none;
    height: 100%;
    width: 100%;
    transition: all 0.4s ease;
    background: transparent;
}

.sidebar li a:hover {
    background: var(--sidebar-hover);
}

.sidebar li a.active {
    background: var(--primary-color);
}

.sidebar li a i {
    min-width: var(--sidebar-closed);
    height: 50px;
    line-height: 50px;
    text-align: center;
    color: var(--sidebar-text);
    font-size: 20px;
}

.sidebar li a .links_name {
    color: var(--sidebar-text);
    font-size: 15px;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: 0.4s;
}

.sidebar.open li a .links_name {
    opacity: 1;
    pointer-events: auto;
}

/* --- TOOLTIP (Cerrado) --- */
.sidebar li .tooltip {
    position: absolute;
    top: 0;
    left: calc(var(--sidebar-closed) + 15px);
    z-index: 3;
    background: #fff;
    box-shadow: 0 5px 10px rgba(0,0,0,0.3);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 15px;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
    color: #333;
}

.sidebar li:hover .tooltip {
    opacity: 1;
    top: 50%;
    transform: translateY(-50%);
}

.sidebar.open li .tooltip {
    display: none;
}

/* --- PERFIL --- */
.sidebar li.profile {
    position: fixed;
    height: 60px;
    width: var(--sidebar-closed);
    left: 0;
    bottom: 0;
    background: var(--sidebar-hover);
    transition: all 0.5s ease;
    padding: 10px 0;
    overflow: hidden;
}

.sidebar.open li.profile {
    width: var(--sidebar-open);
}

.sidebar .profile-details {
    display: flex;
    align-items: center;
    opacity: 0;
    transition: 0.5s;
    padding-left: 15px;
}

.sidebar.open .profile-details {
    opacity: 1;
}

.sidebar .profile .name { font-size: 15px; color: #fff; }
.sidebar .profile .job { font-size: 12px; color: #ccc; }

.sidebar #log_out {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: var(--sidebar-closed);
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: var(--sidebar-hover);
    transition: 0.5s;
}

.sidebar.open #log_out {
    width: 50px;
    background: transparent;
}

/* =========================================
   4. CONTENIDO PRINCIPAL Y TARJETAS
   ========================================= */
.home-section {
    position: relative;
    background: var(--bg-alt);
    min-height: 100vh;
    top: 0;
    left: 78px;
    width: calc(100% - 78px);
    transition: all 0.5s ease;
    z-index: 2;
    padding: 30px;
}
.sidebar.open ~ .home-section {
    left: 250px;
    width: calc(100% - 250px);
}

/* =========================================
   TARJETAS DEL DASHBOARD (CORREGIDO)
   ========================================= */

.overview-boxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.box {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    display: flex;
    align-items: center; /* Esto alinea verticalmente el texto y el icono */
    justify-content: space-between; /* Esto separa texto a la izq e icono a la der */
    border: 1px solid var(--border);
}

.box-topic { font-size: 14px; color: var(--text-muted); }
.number { font-size: 28px; font-weight: 700; color: var(--text-dark); margin-top: 5px; }

/* =========================================
   ICONOS DE TARJETAS (SOLUCIÓN DEFINITIVA)
   ========================================= */
.cart {
    height: 50px !important;
    width: 50px !important;
    min-width: 50px !important;
    border-radius: 12px;
    
    /* FORZAMOS EL CENTRADO FLEXIBLE */
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    
    /* AJUSTES DE FUENTE */
    font-size: 24px !important;
    margin: 0 !important; /* Elimina márgenes fantasma */
    padding: 0 !important; /* Elimina padding fantasma */
}

/* Aseguramos que el "dibujo" del icono no tenga desplazamientos */
.cart::before {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1 !important;
    display: block !important;
}

/* COLORES (Se mantienen igual) */
.cart.one { color: #0066ff; background: #e0eaff; }
.cart.two { color: #10b981; background: #d1fae5; }
.cart.three { color: #f59e0b; background: #fef3c7; }
.cart.four { color: #ef4444; background: #fee2e2; }

/* Tabla */
.recent-sales {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border);
}
table { width: 100%; border-collapse: collapse; margin-top: 15px; }
table th { text-align: left; padding: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
table td { padding: 12px; border-bottom: 1px solid #f8f8f8; color: var(--text-dark); }
.badge { padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge.success { background: #d1fae5; color: #065f46; }
.badge.pending { background: #fef3c7; color: #92400e; }

/* =========================================
   ESTILOS DE MÓDULOS (CLIENTES, PAGOS, ETC)
   ========================================= */

/* Barra de Herramientas (Buscador + Botón) */
.toolbar-box {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    border: 1px solid var(--border);
}

.search-box {
    display: flex;
    align-items: center;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 15px;
    width: 350px;
    height: 45px;
}

.search-box i { font-size: 20px; color: var(--text-muted); }
.search-box input {
    border: none;
    background: transparent;
    width: 100%;
    padding: 10px;
    font-size: 14px;
    outline: none;
    color: var(--text-dark);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: 0.3s;
    font-size: 14px;
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-2px); }

/* Tabla Profesional */
.table-container {
    background: #fff;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    border: 1px solid var(--border);
}

.custom-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.custom-table th {
    text-align: left;
    padding: 15px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    border-bottom: 2px solid #f1f5f9;
}
.custom-table td {
    padding: 15px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-dark);
    font-size: 14px;
    vertical-align: middle;
}
.custom-table tr:last-child td { border-bottom: none; }
.custom-table tr:hover { background-color: #f8fafc; }

/* Badges y Botones de Acción */
.dni-badge {
    background: #eff6ff;
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.btn-action {
    text-decoration: none;
    padding: 6px;
    border-radius: 6px;
    font-size: 18px;
    transition: 0.2s;
    display: inline-flex;
}
.btn-action.edit { color: #f59e0b; background: #fffbeb; margin-right: 5px; }
.btn-action.delete { color: #ef4444; background: #fef2f2; }
.btn-action:hover { transform: scale(1.1); }

/* =========================================
   ESTILOS DE LA VENTANA MODAL (POPUP)
   ========================================= */
.modal {
    display: none; /* Oculto por defecto */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* Fondo oscuro semitransparente */
    backdrop-filter: blur(4px); /* Efecto borroso profesional */
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #fff;
    width: 100%;
    max-width: 600px; /* Ancho máximo elegante */
    border-radius: 12px;
    box-shadow: 0 15px 30px rgba(0,0,0,0.2);
    animation: slideDown 0.3s ease-out;
    overflow: hidden;
}

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

.modal-header {
    background: #f8fafc;
    padding: 15px 25px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 { margin: 0; font-size: 18px; color: var(--text-dark); }
.close { font-size: 28px; font-weight: bold; cursor: pointer; color: #aaa; }
.close:hover { color: #000; }

.modal-body { padding: 25px; }

/* Grid del Formulario */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Dos columnas */
    gap: 20px;
}

.full-width { grid-column: span 2; } /* Campos que ocupan todo el ancho */

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-dark);
}

.input-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
}
.input-group input:focus {
    border-color: var(--primary);
    outline: none;
}

.modal-footer {
    padding: 15px 25px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8fafc;
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-dark);
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
.btn-secondary:hover { background: #cbd5e1; }

/* Estilos Futuristas para el Footer del Dashboard */
.bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-top: 25px;
}
@media (max-width: 800px) { .bottom-grid { grid-template-columns: 1fr; } }

.oracle-card {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    border-radius: 15px;
    padding: 25px;
    color: white;
    position: relative;
    border: 1px solid #334155;
    box-shadow: 0 10px 30px -10px rgba(0,0,0,0.5);
}

.oracle-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.neon-text { color: #22d3ee; text-shadow: 0 0 10px rgba(34, 211, 238, 0.5); font-weight: 700; letter-spacing: 1px; }

/* Barra de Progreso Holográfica */
.progress-container {
    height: 20px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #06b6d4, #3b82f6);
    width: 0%; /* Se anima con JS */
    transition: width 1.5s ease-out;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

/* Bloc de Notas */
.notepad-card {
    background: #fff;
    border-radius: 15px;
    border: 1px solid #e2e8f0;
    padding: 20px;
    display: flex;
    flex-direction: column;
}
.notepad-area {
    width: 100%;
    height: 100px;
    border: none;
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px;
    resize: none;
    font-family: 'Courier New', monospace;
    color: #334155;
    outline: none;
    margin-top: 10px;
}
.notepad-area:focus { background: #f1f5f9; }

/* =========================================
   ESTILOS DE GESTIÓN DE USUARIOS
========================================= */
.user-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px; margin-top: 20px;
}
.user-card {
    background: #fff; border-radius: 12px; padding: 25px;
    text-align: center; border: 1px solid #e2e8f0;
    transition: 0.3s; position: relative;
}
.user-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.05); }

.avatar {
    width: 80px; height: 80px; background: #e0e7ff; color: #4f46e5;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 35px; margin: 0 auto 15px;
}
.role-badge {
    display: inline-block; padding: 4px 12px; border-radius: 20px;
    font-size: 12px; font-weight: 600; margin-top: 10px;
}
.role-admin { background: #fef3c7; color: #d97706; }
.role-vendedor { background: #dcfce7; color: #166534; }

.delete-btn {
    position: absolute; top: 15px; right: 15px;
    color: #ef4444; cursor: pointer; transition: 0.2s;
}
.delete-btn:hover { transform: scale(1.2); }

/* --- MODAL DE ELIMINACIÓN MRX --- */
.mrx-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(10, 10, 15, 0.8); backdrop-filter: blur(5px);
    display: none; justify-content: center; align-items: center; z-index: 100000;
    opacity: 0; transition: opacity 0.3s ease;
}
.mrx-modal-card {
    background: #1e1e2d; border: 1px solid rgba(255, 75, 75, 0.3);
    padding: 30px; border-radius: 15px; width: 90%; max-width: 400px;
    text-align: center; box-shadow: 0 10px 40px rgba(255, 75, 75, 0.15);
    transform: translateY(20px); transition: transform 0.3s ease;
}
.mrx-modal-card h3 { color: #ff4b4b; margin-bottom: 15px; font-family: 'Segoe UI', sans-serif; font-size: 20px; }
.mrx-modal-card p { color: #a0a0b0; margin-bottom: 25px; font-size: 15px; }
.mrx-modal-btn-group { display: flex; gap: 15px; justify-content: center; }
.mrx-btn {
    padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer;
    font-weight: 600; transition: all 0.2s; flex: 1;
}
.btn-cancelar { background: #2b2b40; color: #fff; }
    .btn-cancelar:hover { background: #3b3b55; }
.btn-eliminar { background: linear-gradient(135deg, #ff4b4b, #d93838); color: white; }
.btn-eliminar:hover { box-shadow: 0 0 15px rgba(255, 75, 75, 0.4); transform: translateY(-2px); }


/* =========================================
   RESPONSIVE PARA PANEL DE ADMINISTRACIÓN (V3 DEFINITIVA)
   ========================================= */
   /* BOTÓN DE MENÚ MÓVIL (Oculto en PC) */
.mobile-menu-toggle { display: none !important; }
/* =========================================
   RESPONSIVE PARA PANEL DE ADMINISTRACIÓN (REPARADO)
   ========================================= */
@media (max-width: 768px) {
    body.admin-body { overflow-x: hidden !important; width: 100vw !important; }

    /* 1. SIDEBAR MÓVIL PERFECTO */
    .sidebar {
        left: -100% !important; /* Oculto fuera de pantalla */
        width: 250px !important; /* Tamaño ancho por defecto para que se vean las letras */
        z-index: 99999 !important;
        box-shadow: 5px 0 15px rgba(0,0,0,0.5) !important;
    }
    
    /* Cuando presionas el botón flotante, usamos tu clase original .open */
    .sidebar.open {
        left: 0 !important;
    }

    /* 2. REPARACIÓN DEL BOTÓN "SALIR" (Para que no flote solo) */
    .sidebar li.profile {
        position: absolute !important; /* Relativo a la barra, no a la pantalla */
        width: 100% !important;
        bottom: 0 !important;
        left: 0 !important;
    }
    .sidebar.open li.profile {
        width: 100% !important;
    }

    /* 3. BOTÓN FLOTANTE MÓVIL (Solo visible aquí) */
    .mobile-menu-toggle {
        display: flex !important;
        position: fixed;
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
        background: #11101d;
        color: white;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        font-size: 28px;
        z-index: 100000;
        box-shadow: 0 4px 10px rgba(0,0,0,0.15);
        cursor: pointer;
    }

    /* 4. CONTENEDORES PRINCIPALES (Blindaje Anti-Desborde) */
    html, body.admin-body { 
        overflow-x: hidden !important; /* Prohíbe totalmente el scroll horizontal de la página entera */
        width: 100vw !important; 
        max-width: 100vw !important;
        margin: 0 !important; 
    }

    .home-section {
        width: 100vw !important; 
        max-width: 100vw !important;
        min-height: 100vh !important; 
        left: 0 !important;
        padding: 15px 10px !important; 
        box-sizing: border-box !important;
        overflow-x: hidden !important; 
    }

    .home-content {
        width: 100% !important; 
        max-width: 100% !important; 
        box-sizing: border-box !important;
        overflow-x: hidden !important; /* Atrapa cualquier elemento rebelde */
    }

    nav { flex-direction: column !important; align-items: flex-start !important; gap: 10px !important; }
    .home-content > div:first-child { justify-content: center !important; width: 100% !important; flex-wrap: wrap !important; }
    form { width: 100% !important; justify-content: center !important; }

    /* 5. EL ESCUDO DE LA TABLA (Solo desliza por dentro) */
    .table-container {
        width: 100% !important; 
        max-width: calc(100vw - 20px) !important; /* La clave: El ancho de la pantalla menos un margen de seguridad */
        padding: 10px !important;
        overflow-x: auto !important; /* Activa el deslizado con el dedo */
        -webkit-overflow-scrolling: touch !important;
        box-sizing: border-box !important;
        display: block !important;
        margin: 0 auto !important;
    }
    
    .custom-table { 
        width: 100% !important; 
        min-width: 650px !important; /* Mantiene la tabla ancha por dentro para no aplastar el texto */
        display: table !important; 
    }

    /* 6. ARREGLAR CAJAS DE FILTRO Y BUSCADORES (Mapa y Lotes) */
    .toolbar-box, 
    .home-content > div[style*="display: flex"], 
    .home-content > div[style*="display:flex"] {
        flex-direction: column !important; /* Obliga a que se apilen hacia abajo */
        align-items: stretch !important; /* Obliga a que ocupen todo el ancho */
        height: auto !important;
        gap: 12px !important;
        padding: 15px !important;
    }

    /* Hacer que los selectores, inputs y botones internos se adapten al 100% */
    .toolbar-box select,
    .toolbar-box input,
    .toolbar-box .btn-primary,
    .toolbar-box button,
    .search-box,
    .home-content form select,
    .home-content form button {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        box-sizing: border-box !important;
        justify-content: center !important;
    }

    /* 7. APILAR LAS 3 TARJETAS DE RESUMEN (MAPAS Y LOTES) */
    .overview-boxes, 
    .home-content > div > div[style*="display: flex"],
    .home-content > div > div[style*="display:flex"] {
        display: flex !important;
        flex-direction: column !important; /* Obliga a que vayan hacia abajo */
        width: 100% !important;
        gap: 15px !important;
    }

    .box, 
    .stat-card, 
    .card-resumen {
        width: 100% !important;
        min-width: 100% !important; /* Evita que se encojan o se desborden */
        box-sizing: border-box !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-bottom: 0 !important;
    }
}

/* =========================================
   8. FORZAR CUADRÍCULA DE LOTES TIPO CALENDARIO
   ========================================= */
/* Para PC y Pantallas Grandes */
.lotes-grid { 
    display: grid !important; 
    grid-template-columns: repeat(auto-fill, 120px) !important; /* El secreto: 120px fijos, eliminamos el 1fr que los estiraba */
    gap: 15px !important; 
    justify-content: start !important; /* Alineados a la izquierda */
}

/* Para Celulares y Pantallas Pequeñas */
@media (max-width: 768px) {
    .lotes-grid {
        grid-template-columns: repeat(auto-fill, 100px) !important; /* Cuadros más compactos en móvil */
        gap: 10px !important;
        justify-content: center !important; /* Centraditos para que se vean elegantes */
    }
}