:root {
    --primary-color: #003f7f; --secondary-color: #0066cc; --accent-color: #00a651;
    --text-color: #1f2937; --bg-color: #f3f4f6; --card-bg: #ffffff;
    --border-color: #e5e7eb; --font-family: 'Inter', sans-serif;
    --status-completed: #10b981; --status-pending: #f59e0b; --status-failed: #ef4444;
    --status-in-progress: #3b82f6; --kanban-column-bg: #f8fafc;
}

body { font-family: var(--font-family); background-color: var(--bg-color); color: var(--text-color); margin: 0; }
.hidden { display: none !important; }

/* Header */
.main-header { background: var(--primary-color); color: white; padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.logo-container { display: flex; align-items: center; gap: 1rem; }
.logo { height: 40px; }
#user-info { display: flex; align-items: center; gap: 1rem; }
#logout-button { background: var(--secondary-color); color: white; border: none; padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; transition: all 0.2s ease; }
#logout-button:hover { background: #0052a3; }

/* Contenido Principal */
#portal-main { max-width: 1400px; margin: 2rem auto; padding: 0 1rem; }
.controls-container { background: var(--card-bg); padding: 1rem; border-radius: 8px; margin-bottom: 2rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.filter-group { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.filter-input { padding: 0.7rem; font-size: 0.9rem; border: 1px solid var(--border-color); border-radius: 6px; }
#search-bar { flex-grow: 1; min-width: 250px; }
#reset-filters-btn { background: #64748b; color: white; border: none; padding: 0.7rem 1rem; border-radius: 6px; cursor: pointer; transition: all 0.2s ease; }
#reset-filters-btn:hover { background: #475569; }

/* Controles de Vista */
.view-controls { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.view-buttons { display: flex; background: #f1f5f9; border-radius: 8px; padding: 4px; gap: 4px; }
.view-btn { background: transparent; border: none; padding: 0.7rem 1.2rem; border-radius: 6px; cursor: pointer; font-weight: 500; color: #64748b; transition: all 0.2s ease; font-size: 0.9rem; }
.view-btn:hover { background: #e2e8f0; color: var(--text-color); }
.view-btn.active { background: var(--primary-color); color: white; box-shadow: 0 2px 4px rgba(0,63,127,0.2); }
#results-counter-header { font-size: 0.9rem; color: #64748b; font-weight: 500; }

/* VISTA TABLA */
.view-container { width: 100%; }
#reports-container { background: var(--card-bg); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.table-wrapper { overflow-x: auto; }
#reports-table { width: 100%; border-collapse: collapse; }
#reports-table th, #reports-table td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border-color); white-space: nowrap; }
#reports-table th { background: #f9fafb; font-weight: 600; font-size: 0.75rem; text-transform: uppercase; color: #6b7280; position: relative; }
#reports-table th[data-sort] { cursor: pointer; user-select: none; }
#reports-table th[data-sort]:hover { background-color: #f1f5f9; }
#reports-table th .sort-indicator { margin-left: 0.5rem; opacity: 0.5; }

/* Estados */
.status-badge { padding: 0.25rem 0.6rem; border-radius: 12px; font-size: 0.75rem; font-weight: 600; color: white; display: inline-block; }
.status-completed { background-color: var(--status-completed); }
.status-pending_pdf, .status-pending_upload { background-color: var(--status-pending); }
.status-failed { background-color: var(--status-failed); }
.status-in_progress { background-color: var(--status-in-progress); }

/* Botones de acción */
.action-btn { 
    background: var(--secondary-color); 
    color: white; 
    border: none; 
    padding: 0.5rem 1rem; 
    border-radius: 6px; 
    cursor: pointer; 
    text-decoration: none; 
    display: inline-block; 
    transition: all 0.2s ease;
    font-size: 0.85rem;
    font-weight: 500;
}
.action-btn:hover { 
    background: #0052a3; 
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,102,204,0.3);
}
a.action-btn[disabled] { 
    background: #9ca3af; 
    cursor: not-allowed; 
    pointer-events: none; 
}
.action-btn:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Botón específico para "Unir con Report" */
.merge-btn { 
    background: #10b981 !important; 
    white-space: nowrap;
}
.merge-btn:hover { 
    background: #059669 !important; 
}

.contributors-cell { display: flex; align-items: center; }
.contributor-avatar { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; color: white; font-weight: 600; font-size: 0.75rem; border: 2px solid white; box-shadow: 0 0 0 1px #ccc; }
.contributor-avatar:not(:first-child) { margin-left: -10px; }
.avatar-more { background-color: #64748b; }

/* Paginación */
.pagination-controls { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border-top: 1px solid var(--border-color); flex-wrap: wrap; gap: 1rem; }
.page-buttons { display: flex; align-items: center; gap: 0.5rem; }
.pagination-controls button { background: var(--secondary-color); color: white; border: none; padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; }
.pagination-controls button:disabled { background: #9ca3af; cursor: not-allowed; }
#results-counter { font-size: 0.9rem; color: #64748b; }
#empty-state { text-align: center; padding: 3rem; color: #64748b; }

/* VISTA KANBAN */
.kanban-board { display: flex; gap: 1.5rem; overflow-x: auto; padding: 1rem 0; min-height: 70vh; }
.kanban-column { background: var(--kanban-column-bg); border-radius: 12px; min-width: 300px; max-width: 320px; flex-shrink: 0; border: 1px solid var(--border-color); }
.kanban-header { padding: 1rem 1.2rem 0.8rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.kanban-header h3 { margin: 0; font-size: 1rem; font-weight: 600; color: var(--text-color); }
.kanban-count { background: #e5e7eb; color: #6b7280; padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.8rem; font-weight: 600; }
.kanban-cards { padding: 1rem; display: flex; flex-direction: column; gap: 0.8rem; min-height: 400px; }

/* KANBAN CARDS */
.kanban-card { background: white; border: 1px solid var(--border-color); border-radius: 8px; padding: 1rem; cursor: pointer; transition: all 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.kanban-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); transform: translateY(-2px); }
.kanban-card-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 0.8rem; }
.kanban-card-title { font-weight: 600; color: var(--text-color); font-size: 0.95rem; line-height: 1.3; }
.kanban-card-id { background: #f1f5f9; color: #64748b; padding: 0.2rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 500; }
.kanban-card-info { display: flex; flex-direction: column; gap: 0.5rem; }
.kanban-card-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.85rem; }
.kanban-card-label { color: #6b7280; font-weight: 500; }
.kanban-card-value { color: var(--text-color); font-weight: 400; }
.kanban-card-footer { margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px solid #f1f5f9; }
.kanban-card-avatars { display: flex; align-items: center; gap: 0.3rem; }

/* VISTA CALENDARIO */
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2rem; padding: 1rem; background: var(--card-bg); border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.calendar-nav { background: var(--secondary-color); color: white; border: none; padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; font-size: 1.2rem; transition: background 0.2s; }
.calendar-nav:hover { background: var(--primary-color); }
#calendar-month-year { margin: 0; font-size: 1.5rem; font-weight: 600; color: var(--text-color); }
.calendar-today { background: var(--accent-color); color: white; border: none; padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; font-weight: 500; }

.calendar-grid { background: var(--card-bg); border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.calendar-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); background: #f9fafb; }
.calendar-weekday { padding: 1rem 0.5rem; text-align: center; font-weight: 600; font-size: 0.85rem; color: #6b7280; text-transform: uppercase; border-right: 1px solid var(--border-color); }
.calendar-weekday:last-child { border-right: none; }

.calendar-days { display: grid; grid-template-columns: repeat(7, 1fr); }
.calendar-day { min-height: 120px; border-right: 1px solid var(--border-color); border-bottom: 1px solid var(--border-color); padding: 0.5rem; cursor: pointer; transition: background 0.2s; position: relative; overflow: hidden; }
.calendar-day:hover { background: #f8fafc; }
.calendar-day:last-child { border-right: none; }
.calendar-day.other-month { background: #f9fafb; color: #9ca3af; }
.calendar-day.today { background: #eff6ff; border: 2px solid var(--secondary-color); }
.calendar-day.has-reports { background: #f0f9ff; }

.calendar-day-number { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.calendar-day-reports { display: flex; flex-direction: column; gap: 0.2rem; }
.calendar-report-dot { width: 100%; height: 18px; border-radius: 3px; font-size: 0.7rem; padding: 0.1rem 0.3rem; color: white; font-weight: 500; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
.calendar-report-dot.completed { background: var(--status-completed); }
.calendar-report-dot.in_progress { background: var(--status-in-progress); }
.calendar-report-dot.pending_pdf { background: var(--status-pending); }
.calendar-report-dot.pending_upload { background: var(--status-pending); }
.calendar-report-dot.failed { background: var(--status-failed); }
.calendar-reports-count { position: absolute; top: 0.3rem; right: 0.3rem; background: var(--secondary-color); color: white; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 600; }

/* MODALES */
.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: white; border-radius: 12px; max-width: 600px; width: 90%; max-height: 80vh; overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.2); }
.modal-header { padding: 1.5rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 1.3rem; color: var(--text-color); }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #6b7280; padding: 0; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: all 0.2s ease; }
.modal-close:hover { background: #f1f5f9; color: var(--text-color); }
.modal-body { padding: 1.5rem; max-height: 60vh; overflow-y: auto; }
.modal-report-item { display: flex; justify-content: space-between; align-items: center; padding: 1rem; border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 0.8rem; }
.modal-report-info h4 { margin: 0 0 0.3rem 0; font-size: 1rem; color: var(--text-color); }
.modal-report-info p { margin: 0; font-size: 0.85rem; color: #6b7280; }

/* Estilos específicos para el modal de fusión de PDFs */
.file-input-section { margin-bottom: 1.5rem; }
.file-input-section label { display: block; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-color); }
.file-input-section input[type="file"] { 
    width: 100%; 
    padding: 0.7rem; 
    border: 2px dashed #cbd5e1; 
    border-radius: 8px; 
    cursor: pointer; 
    transition: all 0.2s ease;
}
.file-input-section input[type="file"]:hover { 
    border-color: var(--secondary-color); 
    background: #f8fafc;
}

/* SKELETON */
.skeleton-row td { padding: 1.5rem 1rem; }
.skeleton-row td::after { content: ''; display: block; width: 80%; height: 20px; background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%); background-size: 200% 100%; animation: skeleton-loading 1.5s infinite linear; border-radius: 4px; }
@keyframes skeleton-loading { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* RESPONSIVE */
@media (max-width: 768px) {
    .controls-container { padding: 0.8rem; }
    .filter-group { flex-direction: column; align-items: stretch; }
    .filter-input { width: 100%; }
    .view-controls { flex-direction: column; align-items: stretch; }
    .view-buttons { justify-content: center; }
    
    .kanban-board { gap: 1rem; padding: 0.5rem; }
    .kanban-column { min-width: 250px; max-width: 280px; }
    
    .calendar-header { flex-direction: column; gap: 1rem; text-align: center; }
    .calendar-day { min-height: 80px; }
    .calendar-day-number { font-size: 0.8rem; }
    .calendar-report-dot { height: 15px; font-size: 0.6rem; }
    
    #reports-table td { white-space: normal; }
}

/* LOGIN */
#login-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #f1f5f9; display: flex; justify-content: center; align-items: center; z-index: 100; }
.login-box { background: white; padding: 2rem; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center; width: 90%; max-width: 400px; }
.login-logo { max-width: 150px; margin-bottom: 1rem; }
#login-form input { display: block; width: 100%; margin-bottom: 1rem; padding: 0.8rem; box-sizing: border-box; border: 1px solid var(--border-color); border-radius: 6px; }
#login-form button { width: 100%; padding: 0.8rem; background: var(--primary-color); color: white; border: none; border-radius: 6px; cursor: pointer; font-weight: 600; transition: all 0.2s ease; }
#login-form button:hover { background: #002d5c; }