/* Matriz de Accesos - estilos */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: #f4f6f8; color: #1f2937; font-size: 14px; }
a { color: #1d4ed8; text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: #0f172a; color: #fff; padding: 10px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,.15);
}
.topbar .brand a { color: #fff; font-weight: 700; font-size: 16px; }
.topnav { display: flex; gap: 18px; }
.topnav a { color: #cbd5e1; font-weight: 500; }
.topnav a:hover { color: #fff; text-decoration: none; }
.userbox { display: flex; align-items: center; gap: 10px; }
.user-name { color: #fff; font-weight: 600; }
.user-rol  { color: #fbbf24; font-size: 12px; padding: 2px 8px; background: rgba(251,191,36,.15); border-radius: 4px; text-transform: uppercase; }
.btn-logout { color: #fff; padding: 4px 10px; background: #dc2626; border-radius: 4px; font-size: 12px; }
.btn-logout:hover { text-decoration: none; background: #b91c1c; }

.container { max-width: 1400px; margin: 24px auto; padding: 0 20px; }
.card { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); padding: 20px; margin-bottom: 20px; }
h1 { font-size: 22px; margin: 0 0 16px; color: #0f172a; }
h2 { font-size: 18px; margin: 0 0 12px; color: #0f172a; }

.flash { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-weight: 500; }
.flash-ok    { background: #d1fae5; color: #065f46; border-left: 4px solid #059669; }
.flash-err   { background: #fee2e2; color: #991b1b; border-left: 4px solid #dc2626; }
.flash-info  { background: #dbeafe; color: #1e40af; border-left: 4px solid #2563eb; }

form label { display: block; font-weight: 600; margin-bottom: 4px; color: #374151; }
form input[type=text], form input[type=email], form input[type=password],
form select, form textarea {
    width: 100%; padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 4px; font-size: 14px;
    background: #fff;
}
form input:focus, form select:focus, form textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
form .field { margin-bottom: 14px; }
form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.btn {
    display: inline-block; padding: 8px 16px; border: none; border-radius: 4px;
    background: #2563eb; color: #fff; cursor: pointer; font-weight: 600; font-size: 14px;
}
.btn:hover { background: #1d4ed8; text-decoration: none; }
.btn-secondary { background: #6b7280; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

table.data { width: 100%; border-collapse: collapse; background: #fff; }
table.data th, table.data td { border-bottom: 1px solid #e5e7eb; padding: 10px 12px; text-align: left; }
table.data thead th { background: #f3f4f6; font-weight: 600; color: #374151; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.data tr:hover { background: #f9fafb; }
table.data .actions { white-space: nowrap; text-align: right; }

/* Vista matriz */
/* overflow visible (no scroll container) para que los th sticky se anclen a la VENTANA,
   no a la caja. Así al bajar con la barra de la página, los títulos se quedan fijos. */
.matrix-wrap { background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
table.matrix { border-collapse: collapse; font-size: 12px; }
table.matrix th, table.matrix td { border: 1px solid #e5e7eb; padding: 6px 8px; }
table.matrix thead th {
    background: #0f172a; color: #fff; position: sticky; top: 0; z-index: 2;
    writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap;
    min-width: 32px; max-width: 32px; height: 140px; font-weight: 500;
}
table.matrix thead th.corner { writing-mode: horizontal-tb; transform: none; height: auto; width: 220px; min-width: 220px; max-width: 220px; text-align: left; padding: 10px 14px; left: 0; z-index: 3; }
/* Ancho FIJO: nombres/correos largos envuelven a doble fila en vez de empujar la matriz a la derecha. */
table.matrix tbody th { background: #f3f4f6; text-align: left; font-weight: 600; width: 220px; min-width: 220px; max-width: 220px; position: sticky; left: 0; z-index: 1; white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
table.matrix td.has { background: #ecfdf5; text-align: center; color: #047857; font-weight: 600; font-family: ui-monospace, Menlo, Consolas, monospace; }
table.matrix td.no  { color: #d1d5db; text-align: center; }
table.matrix td.baja { background: #fef3c7; text-align: center; color: #92400e; font-weight: 600; font-family: ui-monospace, Menlo, Consolas, monospace; text-decoration: line-through; }
table.matrix td.missing { background: #fed7aa; text-align: center; color: #9a3412; font-weight: 700; font-size: 10px; letter-spacing: .5px; }
table.matrix td.extra   { background: #fef3c7; text-align: center; color: #92400e; font-weight: 600; font-family: ui-monospace, Menlo, Consolas, monospace; }
.nav-sep { color: #475569; padding: 0 2px; user-select: none; }

/* Celda de hueco con seguimiento en proceso */
table.matrix td.missing.en-proceso { background: #ffedd5; color: #9a3412; font-size: 12px; }
/* Celda de hueco cuya solicitud fue rechazada (conserva el folio) */
table.matrix td.missing.rechazado { background: #fee2e2; color: #b91c1c; font-size: 12px; }
table.matrix td.js-hueco { cursor: pointer; }
table.matrix td.js-hueco:hover { outline: 2px solid #0f172a; outline-offset: -2px; }

/* Modal de seguimiento */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-overlay[hidden] { display: none; }
.modal { background: #fff; border-radius: 10px; padding: 22px 24px; width: 100%; max-width: 440px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 6px; color: #0f172a; font-size: 18px; }
.modal .modal-ctx { margin: 0 0 16px; color: #6b7280; font-size: 13px; }
.modal .field { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.modal h4.modal-h4 { margin: 16px 0 8px; font-size: 14px; color: #0f172a; }
.modal-sep { border: none; border-top: 1px solid #e5e7eb; margin: 18px 0 14px; }
.modal-sub { font-size: 13px; color: #374151; margin: 0 0 12px; }
.btn-ok { background: #059669; }
.btn-ok:hover { background: #047857; }

/* Nombre clicable en la matriz */
table.matrix tbody th .emp-link { color: #1d4ed8; cursor: pointer; font-weight: 600; }
table.matrix tbody th .emp-link:hover { text-decoration: underline; }

/* Modal detalle empleado */
.emp-meta { display: grid; gap: 8px; font-size: 13px; }
.emp-meta > div { display: flex; gap: 8px; }
.emp-meta-l { color: #6b7280; min-width: 110px; font-weight: 600; }
.faltantes-list { margin: 0; padding-left: 18px; max-height: 240px; overflow: auto; font-size: 13px; }
.faltantes-list li { margin-bottom: 4px; }
.faltantes-list li.sin-faltantes { list-style: none; margin-left: -18px; color: #15803d; font-weight: 600; }
.tag-proceso { margin-left: 8px; font-size: 11px; background: #ffedd5; color: #9a3412; padding: 1px 6px; border-radius: 10px; }
.tag-rechazado { margin-left: 8px; font-size: 11px; background: #fee2e2; color: #b91c1c; padding: 1px 6px; border-radius: 10px; }

.filters { display: flex; gap: 14px; align-items: end; margin-bottom: 16px; flex-wrap: wrap; }
.filters .field { margin-bottom: 0; min-width: 200px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.badge-ok   { background: #d1fae5; color: #065f46; }
.badge-off  { background: #fee2e2; color: #991b1b; }

.footer { text-align: center; padding: 20px; color: #6b7280; font-size: 12px; }

/* Chips para filtros (puestos_alias.php) */
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    display: inline-block; padding: 4px 12px; border-radius: 14px;
    background: #f3f4f6; color: #374151; font-size: 12px; font-weight: 600;
    border: 1px solid #e5e7eb;
}
.chip:hover { background: #e5e7eb; text-decoration: none; }
.chip-on { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.chip-on:hover { background: #1e3a8a; color: #fff; }

.hint { color: #4b5563; font-size: 13px; line-height: 1.5; margin: 0 0 16px; }

/* Login */
.login-wrap { max-width: 400px; margin: 80px auto; }
.login-wrap .card { padding: 32px; }
.login-wrap h1 { text-align: center; margin-bottom: 24px; }
.login-wrap .btn { width: 100%; padding: 10px; font-size: 15px; }
