:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --panel-2: #f8f9fb;
  --linea: #e3e6ec;
  --texto: #1b2230;
  --texto-2: #5b6474;
  --texto-3: #8a93a3;
  --acento: #f2a900;
  --acento-osc: #c98a00;
  --lateral: #171d28;
  --lateral-2: #222a38;
  --azul: #2f6fde;
  --verde: #1f9d55;
  --rojo: #d64545;
  --ambar: #a4e000;
  --morado: #7c4dcc;
  --cian: #0f8f9f;
  --radio: 10px;
  --sombra: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --e-A: #dff5e8;   --e-A-t: #146c3b;
  --e-R: #fff0cc;   --e-R-t: #8a5a00;
  --e-F: #fde2e2;   --e-F-t: #a12a2a;
  --e-SC: #ffe4d1;  --e-SC-t: #9a4a0f;
  --e-D: #eef0f3;   --e-D-t: #8a93a3;
  --e-DL: #dde9ff;  --e-DL-t: #1f4fa8;
  --e-I: #ece3fb;   --e-I-t: #5b35a3;
  --e-ET: #d6f3f5;  --e-ET-t: #0b6d78;
  --e-P: #fff6e0;   --e-P-t: #8a6200;
  --e-PR: #ffffff;  --e-PR-t: #b1b8c4;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: var(--texto); background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--azul); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
.muted { color: var(--texto-2); }
.tenue { color: var(--texto-3); }
.num { font-variant-numeric: tabular-nums; }
.oculto { display: none !important; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.lateral { background: var(--lateral); color: #c9d0dc; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.marca { display: flex; gap: 10px; align-items: center; padding: 18px 18px 14px; color: #fff; }
.marca .logo { width: 34px; height: 34px; border-radius: 8px; background: var(--acento); display: grid; place-items: center; flex: none; }
.marca .logo svg { width: 18px; height: 18px; }
.marca b { display: block; font-size: 14px; line-height: 1.2; }
.marca small { color: #8e98aa; font-size: 12px; }
.menu { padding: 6px 10px 16px; flex: 1; }
.menu .sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6f7a8e; padding: 16px 10px 6px; }
.menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: #c9d0dc; text-decoration: none; margin: 1px 0; }
.menu a svg { width: 18px; height: 18px; opacity: .8; flex: none; }
.menu a:hover { background: var(--lateral-2); color: #fff; }
.menu a.activo { background: var(--acento); color: #1b1300; font-weight: 600; }
.menu a.activo svg { opacity: 1; }
.pie-lateral { border-top: 1px solid #2a3344; padding: 12px 14px; font-size: 13px; }
.pie-lateral .quien { color: #fff; font-weight: 600; }
.pie-lateral .rol { color: #8e98aa; font-size: 12px; }
.pie-lateral .acciones { display: flex; gap: 6px; margin-top: 8px; }
.pie-lateral button { background: var(--lateral-2); border: 0; color: #c9d0dc; padding: 5px 9px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.pie-lateral button:hover { color: #fff; background: #2d3749; }
.principal { min-width: 0; padding: 22px 26px 40px; }
.barra-movil { display: none; }

.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.encabezado p { margin: 4px 0 0; color: var(--texto-2); }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- componentes ---------- */
.panel { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); box-shadow: var(--sombra); }
.panel > .cab { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--linea); }
.panel > .cab h2 { font-size: 15px; }
.panel > .cuerpo { padding: 14px 16px; }
.panel + .panel { margin-top: 16px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--linea); background: #fff; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-weight: 550; white-space: nowrap; line-height: 1.2; }
.btn:hover { border-color: #c8cdd6; background: var(--panel-2); }
.btn svg { width: 16px; height: 16px; }
.btn.primario { background: var(--acento); border-color: var(--acento); color: #1b1300; }
.btn.primario:hover { background: #ffb81f; }
.btn.peligro { color: var(--rojo); }
.btn.peligro:hover { background: #fff3f3; border-color: #f2c3c3; }
.btn.chico { padding: 4px 9px; font-size: 13px; }
.btn.fantasma { border-color: transparent; background: transparent; }
.btn.fantasma:hover { background: #eef0f4; }
a.btn { text-decoration: none; color: inherit; }
.roles-grid > .panel, .disp-grid > .panel { margin-top: 0; }
.tabla td .tenue { white-space: nowrap; }
input[type=color] { width: 60px; height: 36px; padding: 2px; border: 1px solid #d5d9e1; border-radius: 8px; background: #fff; }
.btn:disabled { opacity: .55; cursor: default; }

.campo { display: flex; flex-direction: column; gap: 4px; }
.campo label { font-size: 12.5px; font-weight: 600; color: var(--texto-2); }
.campo .ayuda { font-size: 12px; color: var(--texto-3); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=time], input[type=datetime-local], input[type=search], select, textarea {
  border: 1px solid #d5d9e1; border-radius: 8px; padding: 7px 10px; background: #fff; min-height: 36px; width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(242, 169, 0, .35); border-color: var(--acento); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--acento-osc); }
.rejilla { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.rejilla .completo { grid-column: 1 / -1; }

.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filtros .campo { min-width: 140px; }
.filtros .campo.ancho { min-width: 220px; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { border: 1px solid var(--linea); background: #fff; border-radius: 999px; padding: 5px 11px; cursor: pointer; font-size: 13px; }
.chip:hover { background: var(--panel-2); }
.chip.activo { background: var(--texto); color: #fff; border-color: var(--texto); }

table.tabla { width: 100%; border-collapse: collapse; }
.tabla th { text-align: left; font-size: 12px; font-weight: 600; color: var(--texto-2); padding: 9px 12px; border-bottom: 1px solid var(--linea); background: var(--panel-2); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.tabla td { padding: 9px 12px; border-bottom: 1px solid #eef0f3; vertical-align: middle; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla tbody tr:hover td { background: #fafbfc; }
.tabla .der { text-align: right; }
.tabla td.acc { text-align: right; white-space: nowrap; }
.tabla tr.inactivo td { color: var(--texto-3); }
.tabla tr.anulada td { text-decoration: line-through; color: var(--texto-3); }
.desplazable { overflow: auto; max-height: calc(100vh - 250px); border-radius: 0 0 var(--radio) var(--radio); }
.vacio { padding: 36px 16px; text-align: center; color: var(--texto-3); }

.etiqueta { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef0f3; color: var(--texto-2); white-space: nowrap; }
.etiqueta.ok { background: var(--e-A); color: var(--e-A-t); }
.etiqueta.error { background: var(--e-F); color: var(--e-F-t); }
.etiqueta.aviso { background: var(--e-R); color: var(--e-R-t); }
.etiqueta.info { background: var(--e-DL); color: var(--e-DL-t); }
.etiqueta.morado { background: var(--e-I); color: var(--e-I-t); }

.aviso-banda { display: flex; gap: 12px; align-items: center; justify-content: space-between; background: #fff7e0; border: 1px solid #f6d98a; color: #6b4a00; padding: 10px 14px; border-radius: var(--radio); margin-bottom: 16px; }

/* ---------- inicio ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 14px 16px; box-shadow: var(--sombra); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c, var(--texto-3)); }
.kpi .v { font-size: 28px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi .t { font-size: 12.5px; color: var(--texto-2); margin-top: 2px; }
.dos-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dos-col > div > .panel + .panel { margin-top: 16px; }
.lista-simple { list-style: none; margin: 0; padding: 0; }
.lista-simple li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 16px; border-bottom: 1px solid #eef0f3; }
.lista-simple li:last-child { border-bottom: 0; }
.disp-mini { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #eef0f3; }
.disp-mini:last-child { border-bottom: 0; }
.punto { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--texto-3); margin-right: 6px; }
.punto.ok { background: var(--verde); }
.punto.error { background: var(--rojo); }

/* ---------- sábana de asistencia ---------- */
.sabana-cont { overflow: auto; max-height: calc(100vh - 290px); }
table.sabana { border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.sabana th, .sabana td { border-bottom: 1px solid #eef0f3; border-right: 1px solid #f1f3f6; padding: 0; }
.sabana thead th { position: sticky; top: 0; background: var(--panel-2); z-index: 2; font-weight: 600; color: var(--texto-2); padding: 6px 4px; text-align: center; }
.sabana thead th.dia { min-width: 34px; line-height: 1.15; }
.sabana thead th.dia small { display: block; font-weight: 500; color: var(--texto-3); font-size: 10.5px; }
.sabana thead th.dia.finde { background: #eef1f6; }
.sabana thead th.dia.hoy { background: var(--acento); color: #1b1300; }
.sabana thead th.dia.hoy small { color: #3d2c00; }
.sabana .fijo { position: sticky; left: 0; background: #fff; z-index: 1; text-align: left; padding: 6px 10px; min-width: 250px; max-width: 250px; }
.sabana thead .fijo { z-index: 3; background: var(--panel-2); }
.sabana .fijo b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sabana .fijo small { color: var(--texto-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sabana td.c { text-align: center; font-weight: 650; cursor: pointer; height: 38px; min-width: 34px; position: relative; font-size: 12px; }
.sabana td.c:hover { outline: 2px solid var(--texto); outline-offset: -2px; z-index: 1; }
.sabana td.c .aj { position: absolute; top: 2px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--morado); }
.sabana td.c .tn { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; }
.sabana td.tot { text-align: right; padding: 6px 8px; font-variant-numeric: tabular-nums; background: #fbfbfc; min-width: 46px; }
.sabana thead th.tot { min-width: 46px; }
.sabana tbody tr:hover .fijo { background: #fafbfc; }
.e-ASISTENCIA { background: var(--e-A); color: var(--e-A-t); }
.e-RETARDO { background: var(--e-R); color: var(--e-R-t); }
.e-FALTA { background: var(--e-F); color: var(--e-F-t); }
.e-INCOMPLETO { background: var(--e-SC); color: var(--e-SC-t); }
.e-DESCANSO { background: var(--e-D); color: var(--e-D-t); font-weight: 500 !important; }
.e-DESCANSO_LABORADO { background: var(--e-DL); color: var(--e-DL-t); }
.e-INCIDENCIA { background: var(--e-I); color: var(--e-I-t); }
.e-EN_TURNO { background: var(--e-ET); color: var(--e-ET-t); }
.e-PENDIENTE { background: var(--e-P); color: var(--e-P-t); }
.e-PROGRAMADO { background: var(--e-PR); color: var(--e-PR-t); }
.e-SIN_ROL, .e-NO_APLICA { background: #fff; color: var(--texto-3); font-weight: 400 !important; }
.leyenda { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--texto-2); padding: 10px 16px; border-top: 1px solid var(--linea); }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { display: inline-grid; place-items: center; min-width: 24px; height: 20px; border-radius: 4px; font-style: normal; font-weight: 700; font-size: 11px; padding: 0 3px; }

/* ---------- roles ---------- */
.roles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.rol-card { padding: 14px 16px; }
.rol-card .cab-rol { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.tira { display: flex; flex-wrap: wrap; gap: 2px; margin: 12px 0 8px; }
.tira span { width: 14px; height: 22px; border-radius: 3px; background: #e6e9ee; display: block; }
.tira.grande span { width: 22px; height: 30px; font-size: 10px; display: grid; place-items: center; color: rgba(255,255,255,.9); font-weight: 600; }
.tira.grande span.desc { color: var(--texto-3); }
.segmentos { display: flex; flex-direction: column; gap: 8px; }
.segmento { display: grid; grid-template-columns: 1fr 110px 36px; gap: 8px; align-items: center; }
.muestra-color { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }

/* ---------- dispositivos ---------- */
.disp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.disp-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.disp-card dl { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
.disp-card dt { color: var(--texto-3); }
.disp-card dd { margin: 0; word-break: break-word; }

/* ---------- modal ---------- */
.fondo-modal { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); display: grid; place-items: center; z-index: 50; padding: 16px; animation: aparecer .12s ease-out; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.ancho { max-width: 760px; }
.modal .cab { padding: 16px 20px 12px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--linea); }
.modal .cuerpo { padding: 16px 20px; overflow: auto; }
.modal .pie { padding: 12px 20px; border-top: 1px solid var(--linea); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.modal .cerrar { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--texto-3); padding: 2px 6px; }
.modal .error-form { color: var(--rojo); background: #fff3f3; border: 1px solid #f5caca; padding: 8px 10px; border-radius: 8px; margin-bottom: 12px; }
@keyframes aparecer { from { opacity: 0; } }
.detalle-dia dl { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
.detalle-dia dt { color: var(--texto-2); }
.detalle-dia dd { margin: 0; font-weight: 550; }

#toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--texto); color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: 380px; animation: aparecer .15s; }
.toast.error { background: var(--rojo); }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login .lado { background: linear-gradient(160deg, #1b2230 0%, #10151e 100%); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login .lado::after { content: ""; position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border: 60px solid rgba(242,169,0,.12); border-radius: 50%; }
.login .lado h1 { font-size: 34px; line-height: 1.15; max-width: 420px; }
.login .lado p { color: #aab4c5; max-width: 420px; }
.login form { align-self: center; justify-self: center; width: 100%; max-width: 360px; padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.cargando { padding: 40px; text-align: center; color: var(--texto-3); }

@media (max-width: 1100px) {
  .dos-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .app.menu-abierto .lateral { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .barra-movil { display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: var(--lateral); color: #fff; position: sticky; top: 0; z-index: 30; }
  .barra-movil button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }
  .principal { padding: 16px; }
  .rejilla { grid-template-columns: 1fr; }
  .login { grid-template-columns: 1fr; }
  .login .lado { display: none; }
  .sabana .fijo { min-width: 150px; max-width: 150px; }
}
@media print {
  .lateral, .barra-movil, .filtros, .acciones, .leyenda button { display: none !important; }
  .app { display: block; }
  .principal { padding: 0; }
  .sabana-cont, .desplazable { max-height: none; overflow: visible; }
  .panel { box-shadow: none; }
}
