:root {
    /* Tema Claro (por defecto) */
    --primary: #3498db;
    --secondary: #2ecc71;
    --danger: #e74c3c;
    --light: #f8f9fa;
    --warning: #f39c12; /* Naranja/amarillo para advertencias */
    --dark: #343a40;
    --gray: #6c757d;
    --info: #17a2b8;
    --bg-gradient-start: #f5f7fa;
    --bg-gradient-end: #e4edf5;
    --container-bg: white;
    --card-bg: white;
    --card-shadow: rgba(0, 0, 0, 0.1);
    --input-bg: white;
    --input-border: #ddd;
    --table-border: #eee;
    --table-row-even-bg: #f8f9fa;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--container-bg);
    border-radius: 12px;
    box-shadow: 0 10px 30px var(--card-shadow);
    overflow: hidden;
    padding: 25px;
}

header {
    text-align: center;
    padding: 20px 0;
    position: relative;
    margin-bottom: 30px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header #theme-toggle {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    padding: 0;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

.card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.card-title {
    font-size: 1.4rem;
    margin-bottom: 15px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    font-size: 1.6rem;
}

.connection-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .connection-panel {
        grid-template-columns: 1fr;
    }
}

.p2p-section, .data-section {
    padding: 20px;
    border-radius: 8px;
    background: var(--light);
}

.input-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

input, select, button, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 1rem;
    background-color: var(--input-bg);
    color: var(--dark);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

button {
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.icon-btn {
    width: 40px !important; /* Usamos !important para sobreescribir la regla general */
    height: 40px;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

button.secondary {
    background: var(--secondary);
}

button.danger {
    background: var(--danger);
}

button.info {
    background: var(--info);
}

.status-indicator {
    padding: 10px;
    text-align: center;
    border-radius: 6px;
    margin-top: 15px;
    font-weight: 500;
}

.status-offline {
    background: #ffebee;
    color: var(--danger);
}

.status-online {
    background: #e8f5e9;
    color: #2e7d32;
}

.month-selector {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    align-items: flex-end;
}

.schedule-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

th, td {
    padding: 12px 15px;
    text-align: center;
    border: 1px solid var(--table-border);
}

th {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

tr:nth-child(even) {
    background: var(--table-row-even-bg);
}

tr:hover {
    background: #e3f2fd;
}

.day-header {
    min-width: 120px;
}

.worker-row td:first-child {
    font-weight: 600;
    text-align: left;
    padding: 5px 15px;
}

.worker-cell-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.delete-worker-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    opacity: 0.4;
    transition: opacity 0.2s;
    width: auto;
}

.delete-worker-btn:hover {
    opacity: 1;
    transform: none; /* Override general button hover */
}

.time-cell {
    cursor: pointer;
    transition: all 0.2s;
}

.time-cell:hover {
    background: #d1e7ff;
}

.signature-pad {
    border: 1px solid #ddd;
    border-radius: 6px;
    background: var(--input-bg);
    margin-bottom: 10px;
    cursor: crosshair;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--container-bg);
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-title {
    font-size: 1.5rem;
    color: var(--primary);
}

.close {
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--gray);
}

.modal-body {
    margin-bottom: 20px;
}

.buttons-group {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.buttons-group button {
    flex: 1;
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2000;
    transform: translateX(150%);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    background: var(--secondary);
}

.notification.error {
    background: var(--danger);
}

footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    color: var(--dark);
    font-size: 0.9rem;
}

.info-badge {
    display: inline-block;
    background: #e3f2fd;
    color: var(--primary);
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.85rem;
    margin: 5px 0;
}

.highlight {
    background: linear-gradient(120deg, rgba(52, 152, 219, 0.2), rgba(46, 204, 113, 0.2));
    padding: 3px 6px;
    border-radius: 4px;
}

.time-input {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
}

.time-input input[type="time"] {
    width: 120px;
    padding: 8px;
}

.report-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.report-table th, .report-table td {
    padding: 10px;
    border: 1px solid #ddd;
    text-align: left;
}

.report-table th {
    background-color: #3498db;
    color: white;
}

.report-table tr:nth-child(even) {
    background-color: #f2f2f2;
}

/* --- MODO OSCURO --- */
body.dark-mode {
    --primary: #3498db;
    --secondary: #2ecc71;
    --danger: #e74c3c;
    --light: #4a4a4a;
    --warning: #f39c12;
    --dark: #f5f5f5;
    --gray: #9e9e9e;
    --info: #17a2b8;
    --bg-gradient-start: #2c3e50;
    --bg-gradient-end: #34495e;
    --container-bg: #424242;
    --card-bg: #3a3a3a;
    --card-shadow: rgba(0, 0, 0, 0.4);
    --input-bg: #525252;
    --input-border: #616161;
    --table-border: #515151;
    --table-row-even-bg: #424242;
}

body.dark-mode tr:hover {
    background: #535c68;
}

body.dark-mode .p2p-section, 
body.dark-mode .data-section {
    background: var(--card-bg);
}

body.dark-mode .info-badge {
    background: #2c3e50;
    color: var(--primary);
}

body.dark-mode .highlight {
    background: linear-gradient(120deg, rgba(52, 152, 219, 0.3), rgba(46, 204, 113, 0.3));
}

body.dark-mode .report-section,
body.dark-mode .report-table tr:nth-child(even) {
    background-color: #3a3a3a;
}

/* --- ESTILOS PARA EL DASHBOARD Y CALENDARIO --- */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.summary-card {
    display: flex;
    align-items: center;
    background: var(--light);
    padding: 20px;
    border-radius: 8px;
    border-left: 5px solid var(--primary);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.08);
}

.summary-card:nth-child(2) {
    border-left-color: var(--secondary);
}

.summary-card:nth-child(3) {
    border-left-color: var(--info);
}

.summary-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    margin-right: 15px;
    flex-shrink: 0;
}

.summary-content {
    display: flex;
    flex-direction: column;
}

.summary-title {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 5px;
    font-weight: 500;
}

.summary-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
}

/* --- ESTILOS PARA LA VISTA DE CALENDARIO --- */
#dashboard-schedule-table .calendar-day {
    height: 100px;
    vertical-align: top;
    padding: 5px;
    position: relative;
}

#dashboard-schedule-table .day-number {
    font-weight: 600;
    font-size: 0.9rem;
    text-align: left;
}

#dashboard-schedule-table .day-content {
    font-size: 0.85rem;
    margin-top: 5px;
}

/* Estilo para el día firmado en el calendario */
.day-filled-signed {
    background-color: #ffecb3; /* Amarillo más intenso */
}

/* NUEVO: Estilo para el día relleno pero SIN firmar */
.day-pending-signature {
    background-color: #ffcdd2; /* Rojo más intenso */
}

body.dark-mode .day-filled-signed {
    background-color: #6d5f2b; /* Amarillo oscuro más visible */
}

body.dark-mode .day-pending-signature {
    background-color: #7f1d1d; /* Rojo oscuro más intenso */
}

.incident-icon {
    opacity: 0.7;
    transition: opacity 0.2s;
}
/* ...tu CSS actual... */

/* Adaptación para tablets */
@media (max-width: 1024px) {
    /* reglas */
}

/* Adaptación para móviles */
@media (max-width: 600px) {
    /* reglas */
}
/* =======================================================
   NUEVOS ESTILOS: CORRECCIONES DE INTERFAZ (AUDITORÍA Y LOGIN)
   ======================================================= */

/* 1. ARREGLO DE PANTALLA DE LOGIN (Fondo Opaco y Elegante) */
/* Sobrescribe la transparencia para que no se vea la app rota detrás */
#login-modal {
    background-color: #2c3e50; /* Color base por si falla el degradado */
    background-image: linear-gradient(135deg, #2c3e50 0%, #2980b9 100%);
    z-index: 100000; /* Asegura que esté por encima de TODO */
}

/* 2. CONTENEDOR DE LA BARRA DE AUDITORÍA */
/* Crea la caja flexible para que los elementos se pongan en fila */
.audit-toolbar {
    background: var(--light); /* Usa tus variables para modo oscuro/claro */
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 20px;
    display: flex; /* ESTO ES LA CLAVE: Pone los elementos lado a lado */
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    border-left: 4px solid var(--danger); /* Borde rojo estético */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* Texto de la barra */
.audit-info h4 { 
    margin: 0; 
    font-size: 1rem; 
    color: var(--dark); 
    display: flex; 
    align-items: center; 
}
.audit-info p { 
    margin: 2px 0 0 0; 
    font-size: 0.8rem; 
    color: var(--gray); 
}

/* Grupo de botones a la derecha */
.audit-actions { 
    display: flex; 
    gap: 8px; 
    align-items: center; 
}

/* 3. ARREGLO DE BOTONES (Antídoto para el botón gigante) */
.audit-btn {
    width: auto !important; /* CRÍTICO: Anula el width:100% global de tu CSS */
    padding: 8px 15px !important;
    font-size: 0.85rem !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: 5px;
    margin: 0 !important;
    font-weight: 600;
    text-transform: none;
}

/* Colores específicos usando tus variables */
.btn-pdf { 
    background-color: var(--danger) !important; 
    color: white; 
}
.btn-pdf:hover { 
    filter: brightness(0.9); 
}

.btn-json { 
    background-color: var(--secondary) !important; 
    color: white; 
}
.btn-json:hover { 
    filter: brightness(0.9); 
}

/* Botón de borrar (estilo minimalista) */
.btn-trash {
    background-color: transparent !important;
    color: var(--gray);
    border: 1px solid var(--input-border) !important;
    padding: 8px 12px !important;
}
.btn-trash:hover {
    background-color: #fadbd8 !important; /* Rojo muy suave al pasar ratón */
    color: var(--danger) !important;
    border-color: var(--danger) !important;
}

/* Etiqueta del contador */
.log-badge {
    background: rgba(0,0,0,0.05); 
    color: var(--dark); 
    padding: 2px 8px; 
    border-radius: 10px; 
    font-size: 0.75rem; 
    margin-left: 8px;
    border: 1px solid var(--input-border);
}

/* SOPORTE MODO OSCURO (Automático gracias a tus variables) */
body.dark-mode .audit-toolbar {
    background: var(--card-bg);
    border-color: var(--table-border);
}
body.dark-mode .log-badge {
    background: rgba(255,255,255,0.1);
    color: var(--light);
}
/* =======================================================
   PARCHES DE CORRECCIÓN DE DISEÑO (Pegar al final)
   ======================================================= */

/* 1. SOLUCIÓN AL PANEL "GESTIÓN DE DATOS" (Para que ocupe todo el ancho) */
/* Le decimos: "Ignora las columnas y expándete de principio a fin" */
#data-management-panel {
    grid-column: 1 / -1 !important; 
    width: 100% !important;
    max-width: none !important;
}

/* 2. SOLUCIÓN AL PANEL "P2P" (Para hacerlo más pequeño y compacto) */
#p2p-panel {
    padding: 10px 15px !important; /* Reducimos el relleno (antes era 20px) */
    height: fit-content !important; /* Que se ajuste al contenido, no estire */
}

/* Reducimos el título del P2P */
#p2p-panel .card-title {
    font-size: 1.1rem !important; 
    margin-bottom: 10px !important;
}

/* Hacemos los inputs del P2P más finos */
#p2p-panel select, 
#p2p-panel input {
    padding: 6px 10px !important;
    font-size: 0.9rem !important;
    height: auto !important;
}

/* Juntamos más los elementos del P2P */
#p2p-panel .input-group {
    margin-bottom: 8px !important;
}

#p2p-panel button {
    margin-top: 5px !important;
    padding: 8px !important;
}
/* =======================================================
   FIJAR COLUMNA DE NOMBRES (SCROLL HORIZONTAL)
   ======================================================= */

/* Fijar la primera celda del encabezado y de cada fila */
#schedule-table th:first-child,
#schedule-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2; /* Asegura que pase por encima de los días al hacer scroll */
    box-shadow: 3px 0 5px rgba(0, 0, 0, 0.08); /* Sombra elegante para separar la columna */
}

/* El encabezado "Trabajador" necesita un nivel más alto para no ser tapado */
#schedule-table th:first-child {
    background-color: var(--primary); /* Mantiene tu azul original */
    z-index: 3;
}

/* Respetar el color de las filas impares para que no se vea transparente */
#schedule-table tr:nth-child(odd) td:first-child {
    background-color: var(--container-bg);
}

/* Respetar el color de las filas pares (efecto cebra) */
#schedule-table tr:nth-child(even) td:first-child {
    background-color: var(--table-row-even-bg);
}

/* --- Ajuste específico para cuando el usuario active el MODO OSCURO --- */
body.dark-mode #schedule-table tr:nth-child(odd) td:first-child {
    background-color: var(--card-bg);
}



