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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 240px;
    --enfermera: #8b5cf6;
    --tecnico-anestesia: #06b6d4;
    --tecnico-rotante: #f59e0b;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-700);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.nav-links {
    list-style: none;
    padding: 12px 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--gray-400);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.15s;
}

.nav-link:hover {
    color: white;
    background: rgba(255,255,255,0.05);
}

.nav-link.active {
    color: white;
    background: rgba(37, 99, 235, 0.3);
    border-right: 3px solid var(--primary);
}

.nav-link .icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* MAIN */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 32px;
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
}

.section {
    display: none;
}

.section.active {
    display: block;
}

.section > h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--gray-900);
}

/* STATS GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--gray-200);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}

.stat-card .stat-sub {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.danger { border-left: 4px solid var(--danger); }

/* CARDS */
.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--gray-200);
}

.card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--gray-800);
}

.dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* TABLES */
.table-container {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
}

tr:hover td {
    background: var(--gray-50);
}

/* BADGES */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 9999px;
    font-size: 12px;
    font-weight: 500;
}

.badge-enfermera { background: #ede9fe; color: #7c3aed; }
.badge-tecnico_enfermeria { background: #d1fae5; color: #059669; }
.badge-tecnico_anestesia { background: #cffafe; color: #0891b2; }
.badge-tecnico_rotante { background: #fef3c7; color: #d97706; }
.badge-activo { background: var(--success-light); color: var(--success); }
.badge-inactivo { background: var(--gray-100); color: var(--gray-500); }
.badge-vacaciones { background: var(--primary-light); color: var(--primary); }
.badge-licencia { background: var(--warning-light); color: var(--warning); }

/* BUTTONS */
.btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--gray-300);
    background: white;
    color: var(--gray-700);
    transition: all 0.15s;
}

.btn:hover {
    background: var(--gray-50);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    color: var(--danger);
    border-color: var(--danger-light);
}

.btn-danger:hover {
    background: var(--danger-light);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 12px;
}

/* FORMS */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-800);
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* SECTION ACTIONS */
.section-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.filter-group {
    display: flex;
    gap: 8px;
}

.filter-group select,
.filter-group input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    background: white;
}

/* DATE NAV */
.date-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.date-nav input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
}

/* TURNO TOGGLE */
.turno-toggle {
    display: flex;
    gap: 4px;
    background: var(--gray-100);
    padding: 4px;
    border-radius: 10px;
}

.turno-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* AREAS GRID */
.areas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.area-card {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.area-card-header {
    padding: 16px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.area-card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.area-card-body {
    padding: 16px 20px;
    min-height: 120px;
}

.asignado-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
}

.asignado-item:last-child {
    border-bottom: none;
}

.asignado-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.empty-state {
    color: var(--gray-400);
    font-size: 13px;
    text-align: center;
    padding: 20px 0;
}

/* PROGRAMACION GRID (Excel-style) */
.programacion-container {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--gray-200);
    overflow-x: auto;
}

.prog-table {
    border-collapse: collapse;
    width: 100%;
    min-width: 900px;
    font-size: 12px;
}

.prog-table th,
.prog-table td {
    border: 1px solid #bdc3c7;
    text-align: center;
    padding: 0;
    height: 32px;
    min-width: 32px;
}

/* Title row */
.prog-title {
    background: #20124d;
    color: white;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
    padding: 10px !important;
    height: auto !important;
}

/* Day-of-week row */
.prog-dow {
    background: #cfe2f3;
    color: #073763;
    font-weight: 700;
    font-size: 11px;
}

/* Day number row */
.prog-daynum {
    background: #073763;
    color: white;
    font-weight: 700;
    font-size: 12px;
}

/* Collaborator name */
.prog-name {
    text-align: left !important;
    padding: 4px 10px !important;
    font-weight: 700;
    font-size: 11px;
    white-space: nowrap;
    background: white;
    color: #1a1a1a;
    min-width: 180px;
    position: sticky;
    left: 0;
    z-index: 2;
}

.prog-name.group-b {
    background: #d9ead3;
}

/* Shift cells */
.prog-cell {
    font-weight: 700;
    font-size: 11px;
    padding: 2px !important;
}

.prog-cell-d {
    background: #fff2cc;
    color: #7f6000;
}

.prog-cell-n {
    background: #cfe2f3;
    color: #073763;
}

.prog-cell-dn {
    background: #f4cccc;
    color: #990000;
}

.prog-cell-empty {
    background: #f8f9fa;
    color: #ccc;
}

/* Weekend columns */
.prog-weekend {
    background: #f0f0f0;
}

/* Separator row between groups */
.prog-separator td {
    background: #e8e8e8;
    height: 6px !important;
    border-left-color: #e8e8e8;
    border-right-color: #e8e8e8;
}

/* Header cell for COLABORADOR */
.prog-collab-header {
    background: #073763;
    color: white;
    font-weight: 700;
    text-align: left !important;
    padding: 4px 10px !important;
    font-size: 11px;
    position: sticky;
    left: 0;
    z-index: 3;
}

/* Sticky header for day-of-week and day-number name cells */
.prog-dow-name,
.prog-daynum-name {
    position: sticky;
    left: 0;
    z-index: 3;
}

.prog-dow-name {
    background: #cfe2f3;
}

.prog-daynum-name {
    background: #073763;
}

/* Legend */
.prog-legend {
    display: flex;
    gap: 20px;
    padding: 12px 16px;
    font-size: 12px;
    color: var(--gray-600);
    border-top: 1px solid var(--gray-200);
}

.prog-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.prog-legend-swatch {
    width: 20px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #ddd;
    display: inline-block;
}

/* MODAL */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--gray-400);
    padding: 0;
    line-height: 1;
}

/* CHECKLIST */
.checklist {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
}

.checklist-item:hover {
    background: var(--gray-50);
}

.checklist-item:last-child {
    border-bottom: none;
}

.checklist-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* REPORTES */
.reportes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 16px;
}

.reporte-card p {
    color: var(--gray-500);
    font-size: 13px;
    margin-bottom: 16px;
}

.reporte-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.reporte-controls input {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
}

.reporte-resultado-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 13px;
}

.reporte-resultado-table th,
.reporte-resultado-table td {
    padding: 8px 12px;
    border: 1px solid var(--gray-200);
    text-align: left;
}

.reporte-resultado-table th {
    background: var(--gray-50);
}

/* RESUMEN HE */
.resumen-he {
    margin-top: 16px;
}

.resumen-he-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.resumen-he-item {
    text-align: center;
    padding: 12px;
    background: var(--gray-50);
    border-radius: 8px;
}

.resumen-he-item .he-nombre {
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
}

.resumen-he-item .he-total {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.resumen-he-item .he-label {
    font-size: 11px;
    color: var(--gray-400);
}

/* TURNO HOY */
.turno-hoy-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
}

.turno-hoy-item:last-child {
    border-bottom: none;
}

.turno-hoy-area {
    font-weight: 600;
    color: var(--gray-700);
}

.turno-hoy-names {
    color: var(--gray-500);
}

/* LOGIN */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e3a5f 0%, #111827 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 500;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo-img {
    max-width: 260px;
    width: 100%;
    margin: 0 auto 12px;
    display: block;
}

.sidebar-logo {
    width: 100%;
    max-width: 180px;
    display: block;
    margin-bottom: 4px;
}

.login-header h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.login-header p {
    font-size: 14px;
    color: var(--gray-500);
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
    min-height: 18px;
}

.btn-block {
    width: 100%;
    padding: 10px;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary-light);
}

.login-footer {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
    text-align: center;
}

.login-footer p {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 10px;
}

/* USER INFO */
.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 12px;
}

.user-info span {
    color: var(--gray-400);
}

.btn-logout {
    background: none;
    border: 1px solid var(--gray-600);
    color: var(--gray-400);
    padding: 3px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* PRIVACY / COMMUNICATION */
.privacy-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.privacy-option {
    padding: 16px;
    background: var(--gray-50);
    border-radius: 10px;
    border: 1px solid var(--gray-200);
}

.privacy-option h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--gray-800);
}

.privacy-option p {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

/* FICHAS PRINT */
.ficha-individual {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
    page-break-after: always;
}

.ficha-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--gray-800);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.ficha-header h3 {
    font-size: 18px;
    margin: 0;
}

.ficha-header .ficha-periodo {
    font-size: 13px;
    color: var(--gray-500);
}

.ficha-nombre {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.ficha-rol {
    font-size: 13px;
    color: var(--gray-500);
    margin-bottom: 16px;
}

.ficha-tabla {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-bottom: 16px;
}

.ficha-tabla th,
.ficha-tabla td {
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    text-align: center;
}

.ficha-tabla th {
    background: var(--gray-100);
    font-weight: 600;
}

.ficha-tabla td.turno-d {
    background: #fef3c7;
    color: #92400e;
    font-weight: 600;
}

.ficha-tabla td.turno-n {
    background: #dbeafe;
    color: #1e40af;
    font-weight: 600;
}

.ficha-tabla td.turno-dn {
    background: #fce7f3;
    color: #9d174d;
    font-weight: 600;
}

.ficha-codigo {
    font-size: 12px;
    color: var(--gray-400);
    text-align: right;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px dashed var(--gray-300);
}

.codigos-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.codigos-table th,
.codigos-table td {
    padding: 10px 16px;
    border: 1px solid var(--gray-200);
    font-size: 13px;
}

.codigos-table th {
    background: var(--gray-50);
    font-weight: 600;
}

.codigos-table .codigo {
    font-family: monospace;
    font-size: 13px;
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

/* CONSULTA RESULTADO */
.consulta-resultado {
    margin-top: 24px;
    text-align: left;
}

.consulta-resultado h3 {
    font-size: 16px;
    margin-bottom: 12px;
}

@media print {
    .sidebar, .section-actions, .login-screen, #app-container > nav { display: none !important; }
    .main-content { margin: 0 !important; width: 100% !important; padding: 0 !important; }
    .ficha-individual { border: none; box-shadow: none; margin: 0; padding: 20px; }
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    .sidebar-header h2,
    .nav-link span:not(.icon) {
        display: none;
    }
    .nav-link {
        justify-content: center;
        padding: 14px;
    }
    .main-content {
        margin-left: 60px;
        width: calc(100% - 60px);
        padding: 16px;
    }
    .dashboard-row {
        grid-template-columns: 1fr;
    }
    .areas-grid {
        grid-template-columns: 1fr;
    }
}
