* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background-color: #f4f6f9; color: #333; text-transform: uppercase; display: flex; height: 100vh; overflow: hidden; }

/* MENÚ LATERAL (SIDEBAR) */
.sidebar { width: 280px; background-color: #2c3e50; color: #ecf0f1; display: flex; flex-direction: column; box-shadow: 2px 0 5px rgba(0,0,0,0.1); z-index: 1000; transition: transform 0.3s ease; }
.sidebar-header { padding: 25px 20px; background-color: #1a252f; text-align: center; border-bottom: 1px solid #34495e; }
.sidebar-header h1 { font-size: 18px; color: #1abc9c; letter-spacing: 1px; }
.sidebar-menu { list-style: none; padding: 15px 0; flex-grow: 1; overflow-y: auto; }
.sidebar-menu::-webkit-scrollbar { width: 6px; }
.sidebar-menu::-webkit-scrollbar-track { background: #2c3e50; }
.sidebar-menu::-webkit-scrollbar-thumb { background: #7f8c8d; border-radius: 10px; }
.sidebar-menu::-webkit-scrollbar-thumb:hover { background: #1abc9c; }
.sidebar-menu li { margin-bottom: 5px; }
.sidebar-menu a { display: block; padding: 15px 25px; color: #bdc3c7; text-decoration: none; font-weight: bold; font-size: 13px; transition: all 0.3s; border-left: 4px solid transparent; cursor: pointer; }
.sidebar-menu a:hover, .sidebar-menu a.active { background-color: #34495e; color: #ffffff; border-left-color: #1abc9c; }

/* BARRA SUPERIOR MÓVIL */
.mobile-header { display: none; background-color: #1a252f; color: white; padding: 15px 20px; align-items: center; justify-content: space-between; box-shadow: 0 2px 5px rgba(0,0,0,0.2); z-index: 999; }
.mobile-header h1 { font-size: 18px; color: #1abc9c; margin: 0; letter-spacing: 1px; }
.hamburger-btn { background: none; border: none; color: white; font-size: 26px; cursor: pointer; }

/* CONTENEDOR PRINCIPAL DE VISTAS */
.main-content { flex-grow: 1; padding: 30px; overflow-y: auto; display: flex; flex-direction: column; width: calc(100% - 280px); }
.view-section { animation: fadeIn 0.4s ease-in-out forwards; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* COMPONENTES GENERALES */
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; margin-top: 20px; }
.card-metric { background: white; padding: 25px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; border-left: 5px solid #ccc; }
.card-metric h4 { color: #7f8c8d; font-size: 12px; margin-bottom: 10px; }
.card-metric .value { font-size: 28px; font-weight: bold; color: #2c3e50; }
.box { background: white; padding: 25px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); margin-bottom: 25px; }
h2 { color: #2c3e50; margin-top: 0; border-bottom: 2px solid #eceff1; padding-bottom: 10px; text-transform: uppercase; font-size: 20px; }
h3 { color: #34495e; margin-top: 20px; text-transform: uppercase; }
.form-group { margin-bottom: 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
label { font-weight: bold; min-width: 120px; text-transform: uppercase; font-size: 12px; }
input[type="text"], input[type="password"], input[type="date"], input[type="time"], input[type="number"], select, textarea { padding: 8px 12px; border: 1px solid #cccccc; border-radius: 4px; font-size: 14px; box-sizing: border-box; text-transform: uppercase; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: #3498db; outline: none; }

/* BOTONES */
.btn { color: white; padding: 9px 18px; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; font-weight: bold; transition: background 0.2s; text-decoration: none; text-transform: uppercase; display: inline-block; text-align: center; }
.btn-success { background: #2ecc71; } .btn-success:hover { background: #27ae60; }
.btn-danger { background: #e74c3c; padding: 5px 10px; font-size: 12px; } .btn-danger:hover { background: #c0392b; }
.btn-primary { background: #1abc9c; padding: 12px; font-size: 16px; margin-top: 15px; } .btn-primary:hover { background: #16a085; }
.btn-blue { background: #2980b9; } .btn-blue:hover { background: #1f618d; }
.export-actions { display: flex; gap: 10px; margin-top: 15px; margin-bottom: 10px; justify-content: flex-end; flex-wrap: wrap; }
.btn-export { padding: 7px 14px; font-size: 13px; font-weight: bold; border-radius: 4px; border: none; cursor: pointer; color: white; text-transform: uppercase; }
.btn-excel { background-color: #1f7246; } .btn-pdf { background-color: #ca392b; }

/* TABLAS RESPONSIVAS */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; margin-top: 10px; }
table { width: 100%; border-collapse: collapse; background: #fff; text-transform: uppercase; font-size: 12px; min-width: 600px; }
th, td { border: 1px solid #e0e0e0; padding: 10px; text-align: left; }
th { background-color: #f8f9fa; color: #2c3e50; }
.text-right { text-align: right; } .text-center { text-align: center; }

/* MODALES */
.modal-custom { position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 10px; box-sizing: border-box; }
.modal-content-custom { background-color: #fefefe; border-radius: 8px; width: 100%; max-width: 900px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); display: flex; flex-direction: column; max-height: 95vh; }
.modal-header-custom { background-color: #2c3e50; padding: 15px 20px; display: flex; justify-content: space-between; align-items: center; border-radius: 8px 8px 0 0; }
.close-modal { color: #ecf0f1; font-size: 28px; font-weight: bold; cursor: pointer; }
.modal-body-custom { padding: 20px; overflow-y: auto; flex-grow: 1; }

/* ========================================================================= */
/* MEDIA QUERIES PARA CELULARES (Adaptabilidad Móvil Corregida)              */
/* ========================================================================= */
@media (max-width: 768px) {
    body { flex-direction: column; }
    .mobile-header { display: flex; }
    
    /* CORRECCIÓN DE LA BARRA LATERAL PARA CELULARES */
    .sidebar { 
        position: fixed; 
        left: -280px; 
        top: 0; 
        bottom: 0; /* Se pega abajo sin importar la barra del navegador */
        height: 100%; /* Fallback */
        height: 100dvh; /* Altura dinámica del viewport */
        z-index: 1001;
    }
    .sidebar.active-mobile { left: 0; }
    
    /* El contenedor del botón Cerrar Sesión necesita espacio para no pisar el borde */
    .sidebar > div:last-child {
        padding-bottom: 30px !important; 
    }

    .main-content { width: 100%; padding: 15px; }
    .box { padding: 15px; }
    .doc-body, .form-group-inline { display: flex !important; flex-direction: column; gap: 10px !important; }
    .btn { width: 100%; margin-top: 5px; margin-left: 0 !important; }
    .export-actions .btn { width: 100%; }
    .doc-section { overflow-x: auto; }
    table { min-width: 500px; }
    input[type="text"]#buscarLiquidacion, .search-container { max-width: 100% !important; }
    .date-filter-bar-val { flex-direction: column; align-items: stretch; }
}

.sidebar-overlay { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.5); z-index: 999; }
.sidebar-overlay.active { display: block; }