@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* Paleta "obra": petróleo (del encabezado del grid) + neutros cálidos.
     Los colores de datos (ct-*) NO usan estos tokens: son fijos y
     coinciden con los exports a Excel. */
  --bg: #f2f1ed;
  --surface: #ffffff;
  --border: #ddd9d1;
  --border-strong: #c8c3b9;
  --text: #21272b;
  --text2: #5c6570;
  --primary: #104861;
  --primary-h: #0b3549;
  --primary-tint: #e7eef1;
  --accent: #b45309;
  --danger: #c2373b;
  --success: #2f7d4f;
  --warning: #b45309;
  --radius: 6px;
  --radius-lg: 10px;
  --font-ui: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --header-h: 60px;
  --legend-h: 40px;
  --footer-h: 40px;
  --info-w: 280px;
  font-size: 13px;
}
* { margin:0; padding:0; box-sizing:border-box; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  /* v118: usar 100dvh (dynamic viewport height) para que en mobile la altura
     se ajuste a la barra de URL dinámica. Fallback a 100vh para browsers viejos. */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  /* v118: respetar el notch / Dynamic Island en PWA installable (iOS Safari).
     El padding-top se aplica solo si viewport-fit=cover está activo. */
  padding-top: env(safe-area-inset-top, 0);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* TOP BAR */
.top-bar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
}
.top-left { display:flex; align-items:center; gap:8px; }
.app-title { font-size:15px; font-weight:600; letter-spacing:-0.01em; color: var(--primary); }.btn-back {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #5f6368;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 0.15s;
  line-height: 1;
  margin-right: -4px;
}
.btn-back:hover {
  background: #e8eaed;
  color: #1a1d23;
}
.btn-back:active {
  background: #d2d5da;
}
.undo-group {display:flex; gap:1px; margin-left:4px; align-items:center; }
.btn-undo {
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 16px;
  padding: 4px 8px;
  cursor: pointer;
  color: #5f6368;
  transition: all 0.15s;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  position: relative;
}
.btn-undo .undo-label {
  font-size: 11px;
  display: none;
}
.btn-undo .undo-icon {
  font-size: 16px;
  line-height: 1;
}
.btn-undo:hover { background: #e8eaed; border-color: #dadce0; color: #1a1d23; }
.btn-undo:active { background: #d2d5da; }
.btn-undo:disabled { opacity: 0.3; cursor: default; background: none; border-color: transparent; }
.emp-count {
  background: var(--primary-tint);
  color: var(--primary);
  border: 1px solid #c3d4dc;
  font-size:11px;
  padding:1px 8px;
  border-radius:10px;
  font-weight:600;
  font-variant-numeric: tabular-nums;
}
.top-center { display:flex; gap:6px; align-items:center; margin-left:auto; }
.sel-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.sel-label {
  font-size: 11px;
  color: var(--text2);
  font-weight: 500;
  display: none;
}
.top-center select {
  padding:4px 10px;
  border:1px solid var(--border-strong);
  border-radius:var(--radius);
  background:#fff;
  font-size:13px;
  font-family: inherit;
  color: var(--text);
  cursor:pointer;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  appearance: auto;
  -webkit-appearance: auto;
}
.top-center select:hover {
  border-color: #a49e92;
  background: #faf9f7;
}
.top-center select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(16,72,97,0.18);
  outline: none;
}
.top-right { display:flex; gap:6px; align-items:center; }

/* LEGEND BAR */
.legend-bar {
  height: var(--legend-h);
  background: #faf9f6;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
}
.lg-item { display:flex; align-items:center; gap:8px; font-size:12px; font-weight: 500; color:var(--text2); }
.external-project-only { display: none !important; }
body.external-project .external-project-only { display: flex !important; }
.lg-dot { width:12px; height:12px; border-radius:50%; display:inline-block; box-shadow: 0 1px 2px rgb(0 0 0 / 0.1); }

/* Hojas independientes de Proyectos Externos. */
.external-sheet-tabs {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: #faf9f6;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.external-sheet-tabs-list {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  min-width: 0;
  width: 100%;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.external-sheet-tab {
  display: inline-flex;
  align-items: center;
  padding: 7px 15px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}
.external-sheet-tab:hover { background: var(--primary-tint); border-color: #9db6c2; color: var(--primary); }
.external-sheet-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.external-sheet-add {
  flex: 0 0 auto;
  padding: 6px 11px;
  border: 1px dashed var(--border-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text2);
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}
.external-sheet-add:hover { background: var(--primary-tint); border-color: var(--primary); color: var(--primary); }
.external-sheet-input { min-width: 140px; padding: 6px 10px; border: 2px solid var(--primary); border-radius: 7px; outline: none; font-size: 12px; font-weight: 600; font-family: inherit; }
.external-sheet-context-menu { position: fixed; z-index: 1200; min-width: 170px; padding: 5px; background: #fff; border: 1px solid #d1d5db; border-radius: 8px; box-shadow: 0 10px 28px rgba(15,23,42,.2); }
.external-sheet-context-menu button { display: block; width: 100%; padding: 9px 11px; border: 0; border-radius: 5px; background: transparent; color: #334155; text-align: left; cursor: pointer; }
.external-sheet-context-menu button:hover { background: #f1f5f9; }
.external-sheet-context-menu button.danger { color: #dc2626; }
.external-sheet-context-menu button.danger:hover { background: #fee2e2; }

/* GRID */
.grid-wrap {
  flex: 1;
  overflow: auto;
  position: relative;
}
#gridTable {
  border-collapse: collapse;
  width: max-content;
  min-width: 100%;
  table-layout: auto;
}
#gridTable th {
  background: #efede8;
  border: 1px solid var(--border);
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  position: sticky;
  z-index: 2;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text2);
}
#gridTable thead { position: sticky; top: 0; z-index: 3; }
#gridTable thead th { top: 0; }
#gridTable thead tr:first-child th { top: 0; }
#gridTable thead tr:nth-child(2) th { top: 22px; }

/* Checkbox column for multi-select delete */
.sel-all-label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  user-select: none;
}
.sel-all-label input[type="checkbox"] {
  width: 13px;
  height: 13px;
  accent-color: #104861;
  cursor: pointer;
}
.emp-select-cb {
  width: 14px;
  height: 14px;
  accent-color: #104861;
  cursor: pointer;
  vertical-align: middle;
  margin-right: 2px;
}
.col-info-1:has(.emp-select-cb:checked) {
  background: #eef2ff !important;
}

/* Checkboxes ocultos por defecto, solo visibles en modo multi-eliminar */
.emp-select-cb,
.sel-all-label input[type="checkbox"] {
  display: none;
}
.multi-delete-active .emp-select-cb,
.multi-delete-active .sel-all-label input[type="checkbox"] {
  display: inline-block;
}
.multi-delete-active .sel-all-label {
  display: inline-flex;
}

/* v120: checkboxes de "Pegar a varios" en la celda de nombre.
   Mismo patrón que multi-delete: ocultos por defecto, visibles solo
   en modo multi-paste. Se renderizan a la izquierda del nombre. */
.emp-paste-cb {
  display: none;
  width: 16px;
  height: 16px;
  accent-color: #16a34a; /* verde para distinguir del azul de delete */
  cursor: pointer;
  vertical-align: middle;
  margin-right: 6px;
}
.emp-paste-cb:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}
.multi-paste-active .emp-paste-cb {
  display: inline-block;
}
/* v123: cuando el modo multi-paste está activo, deshabilitar el context menu
   de empleado para evitar que el usuario re-active el modo por accidente
   y pierda la selección actual. */
.multi-paste-active .context-menu,
.multi-paste-active .context-menu * {
  pointer-events: none !important;
  opacity: 0.5;
}

/* v123: reglas explícitas para el warning modal. Sin esto, el modal puede
   quedar "flotando" sin overlay cuando se cierra con animation/transform
   residual. Forzamos display:none por defecto y display:block solo cuando
   está activo, y reseteamos posición cuando se cierra. */
#pasteToManyWarningModal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1101;
  max-width: 480px;
  width: 90vw;
  opacity: 1;
  visibility: hidden;
  pointer-events: none;
}
#pasteToManyWarningModal.active {
  display: block;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 1101;
}
#pasteToManyWarningOverlay {
  z-index: 1100;
}
#pasteToManyWarningOverlay.active {
  display: block;
  z-index: 1100;
}
#pasteToManyWarningModal:not(.active) {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}
/* Cuando hay paste seleccionado, resaltar la fila suavemente */
.col-info-3:has(.emp-paste-cb:checked) {
  background: #f0fdf4 !important;
}
.multi-paste-active .col-info-3 {
  cursor: default; /* ya hay checkbox, no es para click derecho exclusivo */
}

#gridTable td {
  border: 1px solid var(--border);
  padding: 4px 6px;
  text-align: center;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
  min-width: 26px;
  height: 32px;
  line-height: 24px;
  touch-action: manipulation;
  -webkit-touch-callout: none;
  transition: filter 0.2s ease, background-color 0.2s ease;
}
#gridTable td:hover { filter: brightness(0.96); }
#gridTable td.col-info { cursor: default; }

/* Sticky info columns */
.col-info-1 { position: sticky; left: 0; z-index: 1; background: #fff !important; border-right: 2px solid var(--border-strong); min-width: 36px; width: 36px; }
.col-info-2 { position: sticky; left: 36px; z-index: 1; background: #fff !important; min-width: 110px; text-align: left !important; padding-left: 8px !important; font-size: 11px; }
.col-info-3 { position: sticky; left: 146px; z-index: 1; background: #fff !important; min-width: 130px; text-align: left !important; padding-left: 8px !important; }
.col-info-4 { position: sticky; left: 276px; z-index: 1; background: #fff !important; min-width: 95px; text-align: left !important; padding-left: 8px !important; }
.col-info-5 { position: sticky; left: 371px; z-index: 1; background: #fff !important; min-width: 82px; text-align: left !important; padding-left: 8px !important; }
#gridTable thead .col-info-1,
#gridTable thead .col-info-2,
#gridTable thead .col-info-3,
#gridTable thead .col-info-4,
#gridTable thead .col-info-5 { background: #104861 !important; color: #fff !important; z-index: 4; }

/* Header styling */
.header-weekday { background: #104861 !important; color: #fff !important; }
.header-weekend { background: #b4443c !important; color: #fff !important; }
.header-daynum { background: #6e6a61 !important; color: #fff !important; }

/* Weekend columns (body) */
.col-weekend { background: #f3f1ec; }

/* COLORES REALES — matchean con los radio cards del modal (.radio-card:has(input[value="X"]:checked))
   Aplican a: celdas del grid del proyecto, leyenda (.lg-dot), celdas del grid del roster.
   Se mantienen las 4 clases del roster (medical, paternidad, martillo, cambio-dia) que son
   específicas de ese módulo y no aparecen en la leyenda del project grid. */
.ct-medical            { background: #FFFF00; color: #4A4A00; }   /* Roster y project grid: Medical */
.ct-paternidad         { background: #BAD4ED; color: #1a3550; }   /* Roster: Licencia paternidad */
.ct-martillo           { background: #4C6390; color: #ffffff; }   /* Roster: Martillo */
.ct-cambio-dia         { background: #9BC57E; color: #1a3a08; }   /* Roster: Cambio de día */

/* 12 tipos del project grid — deben ser IGUALES a los radio cards del modal */
.ct-normal              { background: #A9D08E; color: #2D5A1A; }   /* Normal */
.ct-en-casa             { background: #B4C6E7; color: #1F4E78; }   /* En casa: 4 horas normales */
.ct-fin-semana          { background: #FF5050; color: #FFFFFF; }   /* Proyecto externo: Fin de Semana */
.ct-doble               { background: #F4B084; color: #7A3A0A; }   /* Doble */
.ct-noche               { background: #BDD7EE; color: #1A3A6A; }   /* Noche */
.ct-noche-doble         { background: #418CF1; color: #FFFFFF; }   /* Noche Doble */
.ct-feriado             { background: #EB6B1D; color: #FFFFFF; }   /* Feriado */
.ct-feriado-noche       { background: #8B5A3C; color: #FFFFFF; }   /* Feriado Noche (v91) */
.ct-libre               { background: #FFC000; color: #5A3E00; }   /* Libre (Sin Coordinar / Día Libre) */
.ct-licencia            { background: #FFE699; color: #6A5200; }   /* Licencia Médica */
/* Medical: mismo color yellow #FFFF00 en project grid y roster */
body.app-body .ct-medical { background: #FFFF00; color: #4A4A00; }   /* Project grid: Medical */
.ct-inasistencia        { background: #D1A7CC; color: #4A1A4A; }   /* Inasistencia */
.ct-vacaciones          { background: #40E0D0; color: #004A40; }   /* Vacaciones */
.ct-bloqueado           { background: #BFBFBF; color: #444444; }   /* Bloqueado */
.ct-suspension-temporal { background: #186A22; color: #FFFFFF; }   /* Suspensión Temporal */
.ct-muerte-familiar     { background: #333333; color: #FFFFFF; }   /* Muerte Familiar */

/* COMMENT INDICATOR (red dot top-right) */
.has-comment {
  position: relative;
  cursor: help;
}
.has-comment::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 6px;
  height: 6px;
  background: #ef4444;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(239,68,68,0.5);
  pointer-events: none;
}

/* PENDING SYNC INDICATOR (orange dot top-left + dashed border) */
.cell-pending {
  position: relative;
  box-shadow: inset 0 0 0 2px rgba(245, 158, 11, 0.7);
}
.cell-pending::before {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 6px;
  height: 6px;
  background: #f59e0b;
  border-radius: 50%;
  box-shadow: 0 0 3px rgba(245,158,11,0.7);
  pointer-events: none;
  z-index: 2;
  animation: pending-pulse 1.5s ease-in-out infinite;
}
@keyframes pending-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* PENDING SYNC INDICATOR (admin tables: projects/employees created offline) */
.row-pending {
  background: rgba(245, 158, 11, 0.06) !important;
}
.row-pending:hover td {
  background: rgba(245, 158, 11, 0.10) !important;
}
.badge-pending {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 10px;
  vertical-align: middle;
  white-space: nowrap;
  animation: pending-pulse 1.5s ease-in-out infinite;
}

/* CUSTOM TOOLTIP (JS-managed, at body level for z-index supremacy) */
.cell-tooltip {
  position: fixed;
  z-index: 2147483647;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  background: #16323f;
  color: #f0f0f0;
  font-size: 12.5px;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 280px;
  min-width: 80px;
  width: max-content;
  text-align: left;
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  font-weight: 400;
  transform: scale(0.92);
}
.cell-tooltip.visible {
  opacity: 1;
  transform: scale(1);
}

/* TOTALS COLUMNS */
.col-total { font-weight: 600; background: #f7f6f2; min-width: 38px; font-variant-numeric: tabular-nums; }
#gridTable td.col-total { cursor: default; }
#gridTable thead .col-total { background: #104861 !important; color: #fff !important; z-index: 2; }
.col-external-lunch-total { min-width: 68px; }

/* Recupera parte del espacio de la columna Almuerzo solo en proyectos externos. */
body.external-project .col-info-2 { min-width: 96px; width: 96px; }
@media (min-width: 601px) {
  body.external-project .col-info-3 { left: 132px; }
  body.external-project .col-info-4 { left: 262px; }
  body.external-project .col-info-5 { left: 357px; }
}

/* FOOTER */
.footer-bar {
  height: var(--footer-h);
  background: #0c2e3e;
  color: #c8d8e0;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 12px;
  gap: 16px;
  flex-shrink: 0;
  border-top: 1px solid #10425a;
}
.footer-bar .ft-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.footer-bar .ft-label { color: #7e99a6; font-size: 11px; }
.footer-bar .ft-value { color: #fff; font-weight: 600; font-variant-numeric: tabular-nums; }
.footer-bar .ft-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

/* MODALS */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 100;
  display: none;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.behind { background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
/* Confirm dialog debe estar ENCIMA de cualquier otro modal (z-index 200 vs modal 101).
   Sin esto, cuando se abre desde el modal "Reemplazar Pendiente" (definido
   después en el HTML), el picker queda encima y ocluye los botones del confirm. */
#rosterConfirmOverlay, #rosterConfirmModal { z-index: 200; }
.modal-overlay.active { display: block; animation: overlayIn 0.3s ease; }
@keyframes overlayIn {
  from { opacity: 0; backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); }
  to { opacity: 1; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
}

.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -48%) scale(0.96);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px -16px rgb(23 32 38 / 0.3);
  z-index: 101;
  display: none;
  min-width: 420px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal.active { display: block; opacity: 1; transform: translate(-50%, -50%) scale(1); }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--primary);
}
.btn-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #94a3b8;
  padding: 4px;
  transition: color 0.2s, transform 0.2s;
}
.btn-close:hover { color: #0f172a; transform: rotate(90deg); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  background: #faf9f6;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* Form elements */
.form-row {
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.form-row label { font-size: 12px; font-weight: 500; color: var(--text2); }
.form-input {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  outline: none;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(16,72,97,0.16); }
.search-info {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  margin-top: 4px;
  line-height: 1.5;
}
.search-info:not(:empty)::before {
  content: '';
  display: inline;
}

/* LIVE SEARCH DROPDOWN (Añadir Empleado en grid) */
.search-dropdown {
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
  /* v118: subir z-index para que el dropdown siempre quede por encima del
     contenido scrolleable del modal, evitando clipping al hacer scroll
     dentro del modal con la lista abierta. */
  z-index: 9999;
}
.search-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1efe9;
  font-size: 13px;
  line-height: 1.35;
  transition: background 0.1s;
}
.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-item:hover,
.search-dropdown-item.active {
  background: var(--primary-tint);
}
.search-dropdown-item .ddi-main {
  font-weight: 600;
  color: #1e293b;
}
.search-dropdown-item .ddi-sub {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}
.search-dropdown-item .ddi-cargo {
  color: #475569;
  font-style: italic;
}
.search-dropdown-item .ddi-warn {
  margin-left: 4px;
  color: #d97706;
}
.search-dropdown-item .ddi-dup {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
  color: #7c2d12;
  background: #fed7aa;
  border: 1px solid #fdba74;
  border-radius: 8px;
  vertical-align: middle;
  line-height: 1.4;
}
.search-dropdown-item mark {
  background: #fef3c7;
  color: #92400e;
  padding: 0 2px;
  border-radius: 2px;
  font-weight: 700;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 12px;
  background: #faf9f6;
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
  border-radius: 6px;
}
.form-textarea:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,72,97,0.12);
}
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.external-lunch-row {
  padding: 10px 0;
  margin-bottom: 8px;
  border-top: 1px solid var(--border);
}
.external-lunch-row.is-disabled {
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #e5e7eb;
  color: #6b7280;
}
.external-lunch-row.is-disabled .checkbox-label,
.external-lunch-row.is-disabled input {
  cursor: not-allowed;
}
.external-project .diet-options-row.is-disabled {
  padding: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #e5e7eb;
  color: #6b7280;
}
.external-project .diet-options-row.is-disabled .checkbox-label,
.external-project .diet-options-row.is-disabled input {
  cursor: not-allowed;
}
.external-time-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.external-time-row .form-row { min-width: 0; }
.external-duration-preview {
  margin: -2px 0 12px;
  padding: 8px 10px;
  border: 1px solid #c3d4dc;
  border-radius: 6px;
  background: var(--primary-tint);
  color: var(--primary);
  font-size: 12px;
  font-weight: 600;
}
.external-duration-preview.is-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}
#gridTable td.has-external-lunch {
  position: relative;
  padding: 1px 4px 12px !important;
  line-height: 14px !important;
}
#gridTable td.external-hours-cell {
  position: relative;
  padding: 1px 4px !important;
  line-height: 14px !important;
}
#gridTable td.external-hours-cell.has-external-lunch {
  padding-bottom: 12px !important;
}
.external-hours-value {
  position: absolute;
  top: 2px;
  left: 4px;
  line-height: 14px;
  text-align: left;
}
#gridTable td.external-hours-cell:not(.has-external-lunch) .external-hours-value {
  position: static;
  display: inline;
  line-height: inherit;
  text-align: center;
}
.external-lunch-badge {
  position: absolute;
  left: 2px;
  bottom: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  padding: 1px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.16);
  font-size: 10px;
  line-height: 1;
  pointer-events: none;
  z-index: 2;
}

/* Radio grid */
.radio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 12px;
}
.radio-card {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
  background: #faf9f6;
}
.radio-card:hover { border-color: var(--primary); background: #f4f2ee; }
.radio-card input[type="radio"] { accent-color: var(--primary); cursor: pointer; }
.radio-card:has(input:checked) {
  font-weight: 600;
}
.radio-card:has(input[value="normal"]:checked) {
  background: #a9d08e;
  border-color: #8fbc6e;
  color: #2d5a1a;
}
.radio-card:has(input[value="doble"]:checked) {
  background: #f4b084;
  border-color: #e08a5e;
  color: #7a3a0a;
}
.radio-card:has(input[value="noche"]:checked) {
  background: #bdd7ee;
  border-color: #8fb8d8;
  color: #1a3a6a;
}
.radio-card:has(input[value="noche-doble"]:checked) {
  background: #418cf1;
  border-color: #2563eb;
  color: #fff;
}
.radio-card:has(input[value="feriado"]:checked) {
  background: #eb6b1d;
  border-color: #cc5510;
  color: #fff;
}
.radio-card:has(input[value="feriado-noche"]:checked) {
  background: #8B5A3C;
  border-color: #6e4730;
  color: #fff;
}
.radio-card:has(input[value="libre"]:checked) {
  background: #FFC000;
  border-color: #e0a800;
  color: #5a3e00;
}
.radio-card:has(input[value="licencia"]:checked) {
  background: #ffe699;
  border-color: #e6cc70;
  color: #6a5200;
}
.radio-card:has(input[value="medical"]:checked) {
  background: #FFFF00;
  border-color: #d4d400;
  color: #4a4a00;
}
.radio-card:has(input[value="inasistencia"]:checked) {
  background: #d1a7cc;
  border-color: #b888b3;
  color: #4a1a4a;
}
.radio-card:has(input[value="vacaciones"]:checked) {
  background: #40e0d0;
  border-color: #30c0b0;
  color: #004a40;
}
.radio-card:has(input[value="bloqueado"]:checked) {
  background: #bfbfbf;
  border-color: #999;
  color: #444;
}
.radio-card:has(input[value="suspension-temporal"]:checked) {
  background: #186A22;
  border-color: #0f4a16;
  color: #fff;
}
.radio-card:has(input[value="muerte-familiar"]:checked) {
  background: #333;
  border-color: #222;
  color: #fff;
}

/* Buttons */
.btn {
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); }
.btn-secondary { background: #fff; color: #3d4650; border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: #f4f2ee; border-color: #a49e92; }
.btn-punches {
  background: #fff;
  color: #1d5c40;
  border: 1px solid #7fb59a;
}
.btn-punches:hover { background: #eef6f1; border-color: #2f7d4f; }
.punches-icon {
  display: inline-block;
  margin-right: 2px;
  font-size: 14px;
  line-height: 1;
}
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #a12c30; border-color: #a12c30; }

/* Context menu */
.context-menu {
  position: fixed;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 25px -5px rgb(0 0 0 / 0.15), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  z-index: 200;
  display: none;
  width: min(320px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px;
  overscroll-behavior: contain;
}
.context-menu.active { display: block; animation: ctxMenuIn 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes ctxMenuIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 10px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 8px;
  margin-bottom: 2px;
  transition: all 0.15s;
}
.ctx-item > span:last-child { min-width: 0; }
.ctx-icon { width: 18px; flex: 0 0 18px; text-align: center; font-size: 14px; }
.ctx-header { padding: 8px 10px 10px; border-bottom: 1px solid #e2ded6; }
.ctx-header strong { display: block; color: #0f172a; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-header span { display: block; margin-top: 2px; color: #64748b; font-size: 11px; }
.ctx-section { padding: 5px 0; border-bottom: 1px solid #e8edf3; }
.ctx-section:last-child { border-bottom: 0; }
.ctx-section-label { padding: 3px 10px 5px; color: #64748b; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.ctx-grid { display: grid; gap: 2px; }
.ctx-grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ctx-grid-2 .ctx-item { font-size: 12px; }
.ctx-item.danger { color: #b91c1c; }
.ctx-item.danger:hover { color: #991b1b; background: #fef2f2; }
.ctx-item.danger-subtle { color: #9f1239; }
.context-menu-backdrop { display: none; }
.ctx-item:last-child { margin-bottom: 0; }
.ctx-item:hover { background: #f4f2ee; color: var(--primary); font-weight: 500; }
.ctx-item.ctx-item-disabled {
  opacity: 0.45;
  cursor: not-allowed;
  color: #94a3b8;
}
.ctx-item.ctx-item-disabled:hover {
  background: transparent;
  color: #94a3b8;
}
.ctx-paste-info {
  display: inline;
  font-size: 11px;
  color: #6b7280;
  margin-left: 4px;
  font-weight: 400;
}
.ctx-item.ctx-item-disabled .ctx-paste-info {
  color: #b0b8c1;
}
/* v96: cursor pointer en celdas de nombre para indicar que son click-derechables */
.emp-name-cell { cursor: context-menu; }

/* v107: "Pegar a varios" modal — lista con checkboxes */
.paste-to-many-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
  font-size: 13px;
}
.paste-to-many-item:hover {
  background: var(--primary-tint);
}
.paste-to-many-item.ctx-item-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.paste-to-many-item.ctx-item-disabled:hover {
  background: transparent;
}
.paste-to-many-cedula {
  display: inline-block;
  min-width: 50px;
  font-weight: 600;
  color: var(--primary);
  font-size: 12px;
}
.paste-to-many-name {
  color: #1e3a5f;
  flex: 1;
}
.paste-to-many-item input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}
.paste-to-many-item.ctx-item-disabled input[type="checkbox"] {
  cursor: not-allowed;
}
.ctx-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* SELECTED CELLS (range selection) */
.cell-selected {
  outline: 2px solid #0b3549 !important;
  outline-offset: -1px;
  position: relative;
  z-index: 1;
}

/* BATCH SELECTION PANEL */
.batch-panel {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-bottom: 2px solid var(--primary);
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  z-index: 50;
  display: none;
  min-width: 100%;
}
.batch-panel.active { display: block; }
.batch-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--primary-tint);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
}
.batch-body {
  padding: 10px 14px;
}
.batch-body .radio-grid {
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin-bottom: 8px;
}
.batch-body .radio-card {
  padding: 4px 6px;
  font-size: 11px;
  gap: 4px;
}
.batch-inline {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 8px;
}
.batch-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.batch-field label { font-size: 11px; font-weight: 500; color: var(--text2); }
.batch-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* SELECTION MODE CURSOR */
.grid-wrap.select-mode #gridBody td {
  cursor: crosshair !important;
}

/* --- SORT ICON --- */
.sort-icon {
  display: inline-block;
  font-size: 10px;
  vertical-align: middle;
  line-height: 1;
  color: #9ca3af;
  transition: color 0.15s;
  user-select: none;
}
.sort-icon.asc { color: #d9a441; }
.sort-icon.desc { color: #d9a441; }
.sort-icon-wrap {
  display: inline-block;
  width: 12px;
  text-align: center;
  margin-right: 2px;
}
th.sortable {
  cursor: pointer !important;
}
th.sortable:hover .sort-icon {
  color: #d9a441;
}

/* --- FILTER ICON --- */
.filter-icon {
  display: inline-block;
  font-size: 8px;
  margin-left: 3px;
  vertical-align: middle;
  cursor: pointer;
  color: #9ca3af;
  transition: color 0.15s, transform 0.15s;
  user-select: none;
  line-height: 1;
}
.filter-icon:hover {
  color: #d9a441;
  transform: scale(1.2);
}
.filter-icon.active {
  color: #d9a441;
}
th:hover .filter-icon {
  color: #b8c4cc;
}
th:hover .filter-icon.active {
  color: #d9a441;
}

/* --- FILTER DROPDOWN --- */
.filter-dropdown {
  position: fixed;
  z-index: 300;
  background: #fff;
  border: 1px solid #e0e3e8;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  width: 240px;
  max-height: 340px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: filterFadeIn 0.15s ease;
}
@keyframes filterFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.filter-dd-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px;
  border-bottom: 1px solid #f0f2f5;
  font-weight: 600;
  font-size: 13px;
}
.filter-dd-title {
  color: #1a1d23;
}
.filter-dd-search {
  margin: 6px 10px;
  padding: 6px 10px;
  border: 1px solid #e0e3e8;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  background: #fafbfc;
}
.filter-dd-search:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(16,72,97,0.14);
  background: #fff;
}
.filter-dd-select-all {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
  border-bottom: 1px solid #f0f2f5;
}
.filter-dd-select-all:hover {
  color: var(--primary);
}
.filter-dd-list {
  flex: 1;
  overflow-y: auto;
  max-height: 180px;
  padding: 4px 0;
}
.filter-dd-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.filter-dd-item:hover {
  background: var(--primary-tint);
}
.filter-dd-item input[type="checkbox"] {
  accent-color: #104861;
  cursor: pointer;
  flex-shrink: 0;
}
.filter-dd-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.filter-dd-empty {
  padding: 16px;
  text-align: center;
  color: #9ca3af;
  font-size: 12px;
}
.filter-dd-footer {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid #f0f2f5;
}
.filter-dd-footer .btn {
  flex: 1;
  text-align: center;
  font-size: 11px;
  padding: 6px 8px;
}

/* --- EMPLOYEE BADGES (Dieta Fija / Dieta Nómina) --- */
.emp-badges {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 2px;
  align-items: center;
  pointer-events: none;
}
.emp-badges .emp-badge {
  pointer-events: auto;
}
.emp-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  vertical-align: middle;
  line-height: 1;
  cursor: help;
  transition: transform 0.15s;
}
.emp-badge:hover {
  transform: scale(1.25);
}
.emp-badge.df {
  background: #fed7aa;
  color: #9a3412;
  border: 1px solid #fb923c;
}
.emp-badge.df300 {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #16a34a;
}
.emp-badge.dn {
  background: #bfdbfe;
  color: var(--admin-accent);
  border: 1px solid #60a5fa;
}
.emp-badge.inactive {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #dc2626;
}
.emp-badge.other-project {
  background: #facc15;
  color: #111827;
  border: 1px solid #111827;
}

/* --- ROW SELECTED - conserva los colores de asistencia y marca toda la linea --- */
#gridBody tr.row-selected td.col-info-1,
#gridBody tr.row-selected td.col-info-2,
#gridBody tr.row-selected td.col-info-3,
#gridBody tr.row-selected td.col-info-4,
#gridBody tr.row-selected td.col-info-5,
#gridBody tr.row-selected td.col-total {
  background-color: #dde9ef !important;
}
.emp-badge.other-sheet {
  background: #facc15;
  color: #111827;
  border: 1px solid #111827;
}

@media (max-width: 600px) {
  .external-sheet-tabs { padding: 8px; }
  .external-sheet-tabs-list { gap: 6px; }
  .external-sheet-tab { padding: 7px 12px; font-size: 12px; }
}
.radio-card:has(input[value="fin-semana"]:checked) {
  background: #FF5050;
  border-color: #dc2626;
  color: #fff;
}
#gridBody tr.row-selected td {
  box-shadow: inset 0 2px 0 #4b81a0, inset 0 -2px 0 #4b81a0;
}
#gridBody tr.row-selected td:first-child {
  box-shadow: inset 3px 0 0 #104861, inset 0 2px 0 #4b81a0, inset 0 -2px 0 #4b81a0;
}

/* --- CLEAR FILTERS BUTTON --- */
.btn-filter-clear {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  color: #92400e;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn-filter-clear:hover {
  background: #fde68a;
  border-color: #d97706;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: #fff;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

/* --- OFFLINE INDICATOR (footer bar) --- */
.offline-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid #fbbf24;
  white-space: nowrap;
  animation: fadeIn 0.3s ease;
  /* v115: cuando esta fuera del footerBar, posicionarlo fixed bottom */
  position: fixed;
  bottom: 12px;
  right: 12px;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.offline-icon {
  font-size: 14px;
}
.offline-msg {
  flex: 0 1 auto;
}
.offline-pending {
  font-size: 10px;
  color: #92400e;
  background: #fffbeb;
  padding: 1px 6px;
  border-radius: 10px;
  border: 1px solid #fbbf24;
}

/* Sync button in offline indicator */
.offline-sync-btn {
  background: #f59e0b;
  border: none;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 4px;
  transition: background 0.15s;
}
.offline-sync-btn:hover {
  background: #d97706;
}

/* v119: discard button — descarta todas las mutaciones pendientes manualmente.
   Estilo similar al sync-btn pero con color de peligro para que el usuario
   entienda que la acción es destructiva. */
.offline-discard-btn {
  background: transparent;
  border: 1px solid #dc2626;
  color: #dc2626;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  cursor: pointer;
  margin-left: 2px;
  transition: all 0.15s;
  line-height: 1;
}
.offline-discard-btn:hover {
  background: #dc2626;
  color: #fff;
}

/* Export Modal */
.export-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 8px 0;
}
.export-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  background: #faf9f6;
  user-select: none;
}
.export-card:hover {
  border-color: var(--primary);
  background: var(--primary-tint);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(16,72,97,0.14);
}
.export-card:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(16,72,97,0.1);
}
.export-icon { font-size: 36px; line-height: 1; }
.export-name { font-size: 16px; font-weight: 700; color: var(--text); }
.export-desc { font-size: 11px; color: var(--text2); line-height: 1.4; }

@media (max-width: 600px) {
  .export-grid { grid-template-columns: 1fr; gap: 8px; }
  .export-card { padding: 14px 12px; flex-direction: row; text-align: left; gap: 10px; }
  .export-icon { font-size: 28px; }
  .export-name { font-size: 14px; }
  .export-desc { font-size: 10px; }
}

/* Scrollbar */
.grid-wrap::-webkit-scrollbar { width: 8px; height: 8px; }
.grid-wrap::-webkit-scrollbar-track { background: #f0f0f0; }
.grid-wrap::-webkit-scrollbar-thumb { background: #c0c4cc; border-radius: 4px; }
.grid-wrap::-webkit-scrollbar-thumb:hover { background: #a0a4aa; }

/* ============================================================
   LOGIN PAGE STYLES — panel de marca + formulario
   ============================================================ */
.login-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  font-family: var(--font-ui);
  overflow: hidden;
}
.login-container {
  width: 100%;
  max-width: 780px;
  padding: 20px;
}
.login-card {
  display: grid;
  grid-template-columns: 300px 1fr;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 40px -18px rgba(16, 42, 56, 0.35);
  overflow: hidden;
  min-height: 440px;
}
.login-brand {
  background:
    linear-gradient(160deg, rgba(255,255,255,0.045) 0%, rgba(255,255,255,0) 55%),
    #0e3c51;
  color: #fff;
  padding: 34px 30px 26px;
  display: flex;
  flex-direction: column;
  position: relative;
}
.login-brand::after {
  /* retícula sutil, guiño a la hoja de asistencia */
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 26px 26px;
  pointer-events: none;
}
.login-brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.28);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
}
.login-brand-title {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0 0 8px;
}
.login-brand-sub {
  font-size: 12.5px;
  line-height: 1.55;
  color: #a8c1cd;
  margin: 0;
}
.login-brand-foot {
  margin-top: auto;
  font-size: 11px;
  color: #6f93a3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  position: relative;
}
.login-header {
  padding: 34px 36px 6px;
}
.login-icon { display: none; }
.login-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 4px;
}
.login-subtitle {
  font-size: 13px;
  color: var(--text2);
  margin: 0;
}
.login-form {
  padding: 18px 36px 34px;
}
.login-field {
  margin-bottom: 16px;
}
.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #3d4650;
  margin-bottom: 6px;
}
.login-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  background: #fff;
}
.login-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,72,97,0.14);
}
.login-input::placeholder { color: #a8a294; }
.login-btn {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}
.login-btn:hover { background: var(--primary-h); }
.login-btn:active { transform: translateY(1px); }
.login-btn:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.login-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.login-error {
  background: #fbefee;
  color: #a12c30;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  display: none;
  text-align: center;
  border: 1px solid #e5b6b4;
}

/* Remember Me checkbox */
.login-remember {
  margin-bottom: 16px;
}
.remember-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #3d4650;
  user-select: none;
}
.remember-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #104861;
  cursor: pointer;
}

@media (max-width: 640px) {
  .login-container { max-width: 420px; padding: 16px; }
  .login-card { grid-template-columns: 1fr; min-height: 0; }
  .login-brand { padding: 22px 24px 18px; }
  .login-brand-mark { margin-bottom: 14px; width: 34px; height: 34px; }
  .login-brand-title { font-size: 18px; }
  .login-brand-foot { display: none; }
  .login-header { padding: 24px 24px 4px; }
  .login-form { padding: 14px 24px 26px; }
}

/* ============================================================
   ADMIN PANEL STYLES — misma identidad petróleo del resto de la app
   ============================================================ */
.admin-body {
  --admin-primary: #123a4c;
  --admin-primary-light: #1c4c61;
  --admin-accent: #104861;
  --admin-accent-hover: #0b3549;
  --admin-accent-light: #cfdfe7;
  --admin-accent-bg: #e7eef1;
  --admin-bg: #f2f1ed;
  --admin-surface: #ffffff;
  --admin-text: #21272b;
  --admin-text-muted: #5c6570;
  --admin-text-light: #9aa2ab;
  --admin-border: #e2ded6;
  --admin-radius: 10px;
  --admin-radius-sm: 6px;
  --admin-shadow: 0 1px 2px rgba(33,39,43,0.05);
  --admin-shadow-hover: 0 6px 18px rgba(33,39,43,0.08);
  --admin-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0;
  font-family: var(--font-ui);
  background: var(--admin-bg);
  color: var(--admin-text);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* --- Admin Nav --- */
.admin-nav {
  background: #ffffff;
  color: var(--admin-text);
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 60px;
  flex-shrink: 0;
}
.admin-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--admin-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.admin-nav-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--admin-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.admin-nav-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.admin-nav-title {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 800;
  margin: 0;
  letter-spacing: -0.3px;
  color: var(--admin-primary);
}
.admin-nav-badge {
  background: var(--admin-accent-bg);
  color: var(--admin-accent-hover);
  border: 1px solid #c3d4dc;
  font-size: 9px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.admin-nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.admin-nav-user {
  font-size: 13px;
  color: var(--admin-text);
  font-weight: 700;
}
.admin-nav-logout {
  background: #f4f2ee;
  border: 1px solid var(--admin-border);
  color: #64748b;
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--admin-transition);
}
.admin-nav-logout:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}

/* --- Admin Layout --- */
.admin-layout {
  display: flex;
  height: calc(100vh - 60px);
  height: calc(100dvh - 60px);
}

/* v89 (C5): hamburger button hidden on desktop */
.admin-hamburger { display: none; }
.admin-sidebar-overlay { display: none; }

/* --- Admin Sidebar --- */
.admin-sidebar {
  width: 240px;
  background: var(--admin-surface);
  border-right: 1px solid var(--admin-border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex-shrink: 0;
}
.admin-sidebar-btn {
  padding: 11px 16px;
  border: none;
  background: none;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--admin-text-muted);
  cursor: pointer;
  text-align: left;
  transition: var(--admin-transition);
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.admin-sidebar-btn:hover {
  background: #f4f2ee;
  color: var(--admin-primary);
}
.admin-sidebar-btn.active {
  background: var(--admin-accent-bg);
  color: var(--admin-accent);
  font-weight: 600;
}
.admin-sidebar-btn.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--admin-accent);
  border-radius: 0 3px 3px 0;
}

/* --- Admin Content --- */
.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px;
}

/* --- Admin Section --- */
.admin-section {
  display: none;
}
.admin-section.active {
  display: block;
  animation: sectionFadeIn 0.3s ease;
}
@keyframes sectionFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.admin-section-header h2 {
  font-family: var(--font-ui);
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  color: var(--admin-primary);
  letter-spacing: -0.6px;
}

/* --- Reportes externos aislados --- */
.admin-report-section.active {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.admin-report-header {
  flex: 0 0 auto;
  margin-bottom: 16px;
}
.admin-report-header p {
  margin: 4px 0 0;
  color: var(--admin-text-muted);
  font-size: 13px;
}
.admin-report-header .btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}
.admin-embedded-app {
  position: relative;
  flex: 1 1 auto;
  min-height: 440px;
  overflow: hidden;
  border: 1px solid var(--admin-border);
  border-radius: 8px;
  background: #fff;
}
.admin-embedded-app iframe {
  width: 100%;
  height: 100%;
  min-height: 440px;
  border: 0;
  display: block;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.admin-embedded-app iframe.loaded { opacity: 1; }
.admin-embedded-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--admin-text-muted);
  font-size: 13px;
  background: #faf9f6;
}
.admin-embedded-loading.hidden { display: none; }
.admin-component-app {
  position: relative;
  flex: 0 0 auto;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  overflow: visible;
}
.radio-card:has(input[value="en-casa"]:checked) {
  background: #b4c6e7;
  border-color: #7896c5;
  color: #1f4e78;
}
.admin-component-app payment-vouchers-app {
  display: block;
  min-height: 0;
}
.admin-payment-vouchers-section.active {
  height: auto;
  min-height: 100%;
}
.admin-time-pairs-section.active {
  height: auto;
  min-height: 100%;
}

/* --- Sub-tabs (Arkonstruccion dentro de Lista Empleados) --- */
.arkon-subtabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #e5e7eb;
  margin-bottom: 16px;
}
.arkon-tab {
  background: none;
  border: none;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 14px;
  color: #6b7280;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}
.arkon-tab:hover {
  color: var(--admin-accent);
}
.arkon-tab.active {
  color: var(--admin-accent);
  border-bottom-color: var(--admin-accent);
  font-weight: 600;
}
.admin-card-actions {
  display: flex;
  gap: 8px;
  padding: 0 0 12px;
  flex-wrap: wrap;
}

/* --- Dashboard Cards --- */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.dash-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: 16px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  transition: var(--admin-transition);
  box-shadow: var(--admin-shadow);
  position: relative;
  overflow: hidden;
}
.dash-card::before { content: none; }
.dash-card:hover {
  box-shadow: var(--admin-shadow-hover);
  transform: translateY(-2px);
  border-color: var(--admin-border);
}
.dash-card-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--admin-accent-bg);
  color: var(--admin-accent);
  border-radius: 12px;
  flex-shrink: 0;
  margin-bottom: 18px;
  transition: transform 0.2s;
}
.dash-card:hover .dash-card-icon {
  transform: scale(1.1);
}
.dash-card-info {
  display: flex;
  flex-direction: column;
}
.dash-card-number {
  font-family: var(--font-ui);
  font-size: 34px;
  font-weight: 800;
  color: var(--admin-primary);
  line-height: 1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.dash-card-label {
  font-size: 12px;
  color: var(--admin-text-muted);
  margin-top: 5px;
  font-weight: 500;
}

/* --- Quick Action Links --- */
.admin-quick-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--admin-accent-bg);
  border: 1px solid var(--admin-accent);
  color: var(--admin-accent);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--admin-transition);
}
.quick-action-btn:hover {
  background: var(--admin-accent);
  color: #fff;
}

/* --- Admin Table Card --- */
.admin-card {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--admin-shadow);
  transition: box-shadow 0.2s;
}
.admin-card:hover {
  box-shadow: var(--admin-shadow-hover);
}
.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--admin-border);
  gap: 12px;
}
.admin-card-header h3 {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 800;
  margin: 0;
  color: var(--admin-primary);
}
.admin-card-body {
  overflow-x: auto;
}
.admin-search {
  flex: 0 0 200px;
}
.admin-filters {
  display: flex;
  gap: 8px;
}
.admin-filters .form-input,
.admin-search .form-input {
  padding: 7px 12px;
  font-size: 12px;
  border-radius: 8px;
  border: 1px solid var(--admin-border);
  background: #faf9f6;
}
.admin-filters .form-input:focus,
.admin-search .form-input:focus {
  border-color: var(--admin-accent);
  box-shadow: 0 0 0 3px rgba(16,72,97,0.12);
  background: #fff;
}

/* --- Admin Table --- */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-table th {
  text-align: left;
  padding: 12px 18px;
  font-size: 10.5px;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  background: #104861;
  border-top: 1px solid #0b3549;
  border-bottom: 1px solid #0b3549;
  white-space: nowrap;
}

/* Proyecto Horas: encabezado independiente del grid de asistencia. */
.ph-body #gridTable thead th {
  background: #104861;
  color: #fff;
  border-color: #2c6076;
}
.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1efe9;
  vertical-align: middle;
  color: var(--admin-text);
}
.admin-table tbody tr {
  transition: background 0.15s;
}
.admin-table tbody tr:hover td {
  background: #faf9f6;
}
.admin-table tbody tr:last-child td {
  border-bottom: none;
}
#gridEmployeesTable,
#inactiveGridEmployeesTable {
  min-width: 1180px;
}
.employee-hire-date {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.employee-service-time {
  min-width: 190px;
  white-space: nowrap;
  color: #475569 !important;
}
.table-empty {
  text-align: center !important;
  color: var(--admin-text-light) !important;
  padding: 40px 16px !important;
  font-style: normal !important;
}
.table-actions {
  white-space: nowrap;
  display: flex;
  gap: 6px;
}

/* --- Status Badge --- */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  gap: 4px;
}
.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.status-active {
  background: #dcfce7;
  color: #166534;
}
.status-active::before { background: #16a34a; }
.status-inactive {
  background: #f4f2ee;
  color: var(--admin-text-muted);
}
.status-inactive::before { background: #94a3b8; }

/* --- Small Button --- */
.btn-sm {
  padding: 5px 10px;
  font-size: 13px;
  min-width: 32px;
  text-align: center;
  border-radius: 6px;
}

/* --- App page user info --- */
.app-user-info {
  font-size: 12px;
  color: #6b7280;
  margin-left: 8px;
  padding-left: 8px;
  border-left: 1px solid #e0e3e8;
}
.app-project-info {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid #e0e3e8;
  position: relative;
}
.app-project-current {
  cursor: pointer;
  user-select: none;
  transition: opacity 0.15s;
}
.app-project-current:hover {
  opacity: 0.75;
}
.project-dropdown-arrow {
  font-size: 10px;
  margin-left: 4px;
  color: #94a3b8;
  transition: transform 0.15s;
}
.app-project-current:hover .project-dropdown-arrow {
  transform: rotate(180deg);
}
.project-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  background: #fff;
  border: 1px solid #e0e3e8;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 200px;
  max-width: 280px;
  z-index: 300;
  overflow: hidden;
  animation: ddFadeIn 0.15s ease;
}
@keyframes ddFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.project-dd-item {
  padding: 10px 14px;
  font-size: 13px;
  color: #374151;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-dd-item:last-child {
  border-bottom: none;
}
.project-dd-item:hover {
  background: var(--primary-tint);
  color: var(--primary);
}
.project-dd-item.active {
  background: var(--primary-tint);
  color: var(--primary);
  font-weight: 600;
}

/* ============================================================
   SKELETON LOADERS
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, #e6e3dc 25%, #f1efe9 50%, #e6e3dc 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease-in-out infinite;
  border-radius: 6px;
  display: inline-block;
  line-height: 1;
}
@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 14px; width: 100%; margin-bottom: 8px; }
.skeleton-text-sm { height: 12px; width: 60%; }
.skeleton-text-lg { height: 18px; width: 80%; }
.skeleton-number { height: 32px; width: 60px; border-radius: 8px; }
.skeleton-button { height: 32px; width: 80px; border-radius: 8px; }
.skeleton-avatar { height: 48px; width: 48px; border-radius: 12px; }
.skeleton-badge { height: 22px; width: 70px; border-radius: 20px; }
.skeleton-row {
  display: flex;
  gap: 16px;
  padding: 12px 16px;
  align-items: center;
  border-bottom: 1px solid #f1efe9;
}
.skeleton-cell { height: 14px; border-radius: 4px; flex: 1; }
.skeleton-cell-sm { flex: 0.5; }
.skeleton-cell-lg { flex: 2; }

/* Loading spinner */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--admin-border);
  border-top-color: var(--admin-accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.7;
}
.empty-state-title {
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 600;
  color: var(--admin-text);
  margin-bottom: 8px;
}
.empty-state-desc {
  font-size: 13px;
  color: var(--admin-text-muted);
  max-width: 360px;
  line-height: 1.5;
  margin-bottom: 20px;
}
.empty-state .btn {
  padding: 8px 20px;
  font-size: 13px;
}

/* ============================================================
   TOAST IMPROVEMENTS
   ============================================================ */
.toast {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #0c2e3e;
  color: #fff;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  pointer-events: none;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: #dc2626; }
.toast.toast-success { background: #059669; }

/* ============================================================
   RESPONSIVE ADMIN
   ============================================================ */
@media (max-width: 768px) {
  .admin-nav { padding: 0 10px; height: 54px; gap: 8px; overflow: hidden; }
  .admin-nav-left { flex: 1 1 auto; min-width: 0; gap: 8px; }
  .admin-nav-right { flex: 0 0 auto; min-width: 0; gap: 8px; }
  .admin-nav-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
  }
  .admin-nav-logout { padding: 7px 10px; white-space: nowrap; }
  .admin-nav-user { display: none; }
  /* v89 (C5): hamburger button visible en mobile */
  .admin-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-right: 8px;
    background: transparent;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    color: #1e3a5f;
    font-size: 22px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
  }
  .admin-hamburger:hover { background: #f1f5f9; }
  /* v89 (C5): sidebar oculta por defecto en mobile, se muestra como drawer */
  .admin-sidebar {
    position: fixed;
    top: 54px;
    left: 0;
    width: 240px;
    height: calc(100vh - 54px);
    height: calc(100dvh - 54px);
    background: #fff;
    z-index: 1500;
    padding: 16px 12px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    border-right: 1px solid #e2ded6;
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-sidebar-btn {
    font-size: 14px;
    padding: 12px 14px;
    text-align: left;
    justify-content: flex-start;
    border-radius: 8px;
  }
  .admin-sidebar-btn.active::before { display: none; }
  /* v89 (C5): overlay oscuro cuando la sidebar está abierta en mobile */
  .admin-sidebar-overlay {
    display: none;
    position: fixed;
    top: 54px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1400;
  }
  .admin-sidebar-overlay.open { display: block; }
  .admin-content { padding: 20px 16px; }
  .dashboard-cards { grid-template-columns: 1fr; }
  .admin-section-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .admin-filters { flex-direction: column; width: 100%; }
  .admin-table { font-size: 12px; }
  .admin-table th, .admin-table td { padding: 10px 12px; }
  .admin-card-header { flex-direction: column; align-items: flex-start; }
  .admin-search { flex: 1; width: 100%; }
  .admin-section-header h2 { font-size: 19px; }
  .admin-report-section.active { height: auto; min-height: calc(100dvh - 94px); }
  .admin-report-header { flex-direction: row; align-items: center; width: 100%; }
  .admin-report-header .btn { white-space: nowrap; }
  .admin-embedded-app,
  .admin-embedded-app iframe { min-height: calc(100dvh - 170px); }
  .admin-payment-vouchers-section.active { min-height: calc(100dvh - 94px); }
  .admin-time-pairs-section.active { min-height: calc(100dvh - 94px); }
}

@media (max-width: 480px) {
  .admin-nav-badge { display: none; }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  body {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
    overflow: visible !important;
    height: auto !important;
  }
  .app {
    height: auto !important;
    overflow: visible !important;
  }
  .grid-wrap {
    overflow: visible !important;
    height: auto !important;
  }
  #gridTable td,
  #gridTable th {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  .top-bar,
  .footer-bar,
  .legend-bar {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }
  .modal-overlay,
  .modal,
  .context-menu,
  .toast,
  .batch-panel,
  .cell-tooltip,
  .btn-undo,
  .btn-back,
  #addEmpBtn,
  #masivosBtn,
  #punchesBtn {
    display: none !important;
  }
}

/* ============================================================
   RESPONSIVE DESIGN (Grid page)
   ============================================================ */
@media (max-width: 900px) {
  .top-bar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .top-left { flex: 1 1 auto; min-width: 0; }
  .app-title { font-size: 14px; }
  .emp-count { font-size: 10px; padding: 1px 6px; }
  .btn-undo { font-size: 14px; padding: 1px 4px; }
  .top-center { margin-left: 0; order: 3; flex: 0 0 100%; justify-content: flex-start; }
  .top-center select { font-size: 12px; padding: 3px 8px; flex: 1; min-width: 0; }
  .top-right { order: 2; flex: 0 0 auto; }
  .top-right .btn { font-size: 11px; padding: 5px 10px; }
  .legend-bar { height: auto; min-height: var(--legend-h); padding: 4px 10px; gap: 6px; flex-wrap: nowrap; }
  .lg-item { font-size: 11px; }
  .lg-dot { width: 12px; height: 12px; }
  .modal { min-width: 0; width: 94vw; max-height: 90vh; }
  .modal-header { padding: 12px 14px; font-size: 14px; }
  .modal-body { padding: 12px 14px; }
  .modal-footer { padding: 10px 14px; flex-wrap: wrap; gap: 6px; }
  .modal-footer .btn { flex: 1; text-align: center; min-width: 80px; }
  .radio-grid { gap: 4px; }
  .radio-card { padding: 5px 8px; font-size: 11px; }
  .form-input { font-size: 12px; padding: 5px 8px; }
  .form-textarea { font-size: 12px; padding: 8px 10px; min-height: 60px; }
  #gridTable td { font-size: 11px; padding: 4px 6px; min-width: 34px; height: 30px; line-height: 22px; touch-action: manipulation; }
  #gridTable th { font-size: 10px; padding: 3px 5px; }
  .header-weekday { background: #0d3b5a !important; }
  .header-daynum { background: #6b7280 !important; }
  .top-bar { background: var(--surface); border-bottom: 1px solid var(--border); }
  #gridTable th { font-size: 10px; padding: 3px 5px; }
  .col-info-1 { min-width: 34px; width: 34px; }
  .col-info-2 { left: 34px; min-width: 100px; }
  .col-info-3 { left: 134px; min-width: 120px; }
  .col-info-4 { left: 254px; min-width: 90px; }
  .col-info-5 { left: 344px; min-width: 78px; }
  #gridTable thead tr:nth-child(2) th { top: 20px; }
  .col-total { min-width: 36px; }
  .footer-bar { height: auto; min-height: var(--footer-h); padding: 6px 12px; gap: 8px; flex-wrap: wrap; }
  .footer-bar .ft-item { font-size: 11px; }
  .batch-header { flex-wrap: wrap; gap: 6px; padding: 6px 10px; font-size: 12px; }
  .batch-body { padding: 8px 10px; }
  .batch-body .radio-grid { grid-template-columns: repeat(3, 1fr); }
  .batch-body .radio-card { font-size: 10px; padding: 3px 5px; }
  .batch-inline { flex-direction: column; align-items: stretch; gap: 6px; }
  .export-grid { grid-template-columns: repeat(2, 1fr); }
  .context-menu { min-width: 140px; }
  .ctx-item { padding: 6px 10px; font-size: 12px; }
  .cell-tooltip { font-size: 11px; padding: 8px 10px; max-width: 200px; }
  /* Scroll gradient hints for mobile */
  .grid-wrap::after {
    content: '';
    position: sticky;
    right: 0;
    top: 0;
    width: 24px;
    height: 100%;
    background: linear-gradient(to right, transparent, rgba(0,0,0,0.08));
    pointer-events: none;
    z-index: 5;
    flex-shrink: 0;
  }
}

@media (max-width: 600px) {
  :root { font-size: 12px; --header-h: auto; --legend-h: 28px; --footer-h: 32px; }
  .top-bar { padding: 6px 10px; gap: 6px; }
  .app-title { font-size: 13px; }
  .top-center { order: 2; flex: 0 0 100%; gap: 4px; justify-content: center; }
  .sel-label { display: inline; font-size: 10px; }
  .sel-group { gap: 2px; }
  .top-center select { font-size: 11px; padding: 6px 8px; min-height: 36px; border-radius: 8px; }
  .top-right { order: 3; flex: 0 0 100%; justify-content: flex-start; }
  .top-right .btn { flex: 1; font-size: 11px; padding: 5px 8px; text-align: center; min-height: 36px; }
  .top-left { flex-wrap: wrap; gap: 2px 6px; }
  .btn-back { order: 1; }
  .app-title { order: 2; }
  .emp-count { order: 3; }
  .btn-filter-clear { order: 4; }
  .app-user-info { order: 5; border-left: none; padding-left: 0; margin-left: 0; }
  .app-project-info { order: 6; border-left: none; padding-left: 0; margin-left: 0; }
  .undo-group { order: 7; margin-left: 0; gap: 8px; flex: 0 0 100%; justify-content: center; padding: 6px 0 2px; border-top: 1px solid #e0e3e8; margin-top: 2px; }
  .btn-undo { font-size: 12px; padding: 6px 10px; min-width: 38px; min-height: 36px; border-radius: 8px; background: #f4f2ee; border-color: #ddd9d1; color: #4a5258; }
  .btn-undo .undo-label { display: inline; font-size: 11px; }
  .btn-undo .undo-icon { font-size: 14px; }
  .btn-undo:hover { background: var(--primary-tint); border-color: #9db6c2; color: #1a1d23; }
  .btn-undo:active { background: #d5e2e9; transform: scale(0.95); }
  .btn-undo:disabled { background: #f0f0f0; border-color: #e0e0e0; opacity: 0.3; transform: none; }
  .modal { width: 96vw; max-height: 92vh; border-radius: 6px; }
  /* v118: pasteToMany modals — los max-width inline se movieron a CSS para que el
     responsive en mobile los deje fluir. En desktop mantienen su ancho. */
  /* v123: reglas movidas al bloque base para evitar duplicación y bug de
     modal flotante cuando cambia el viewport. */
  .modal-header { padding: 10px 12px; font-size: 13px; }
  .modal-body { padding: 10px 12px; }
  .modal-footer { padding: 8px 12px; }
  .modal-footer .btn { min-width: 0; padding: 10px 16px; font-size: 12px; min-height: 40px; border-radius: 8px; }
  .radio-grid { grid-template-columns: 1fr 1fr; gap: 3px; }
  .radio-card { padding: 8px 8px; font-size: 11px; min-height: 40px; min-width: 0; overflow: hidden; }
  .radio-card > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .radio-card input[type="radio"] { width: 16px; height: 16px; flex-shrink: 0; }
  .form-row { margin-bottom: 10px; }
  .form-row label { font-size: 11px; }
  .form-input { font-size: 14px; padding: 8px 10px; min-height: 40px; }
  .form-textarea { font-size: 13px; padding: 8px 10px; min-height: 60px; }
  #hoursInput { width: 70px; }
  .external-time-row { gap: 8px; }
  .external-time-row .form-input { width: 100%; }
  .checkbox-label { font-size: 12px; }
  .checkbox-label input[type="checkbox"] { width: 18px; height: 18px; }
  .legend-bar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 16px;
    gap: 16px;
    height: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    align-items: center;
  }
  .lg-item { font-size: 11px; gap: 6px; display: inline-flex; align-items: center; flex-shrink: 0; font-weight: 500; }
  .lg-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 1px 2px rgb(0 0 0 / 0.1); }
  #gridTable td { font-size: 11px; padding: 5px 7px; min-width: 36px; height: 36px; line-height: 26px; touch-action: manipulation; }
  #gridTable th { font-size: 10px; padding: 3px 5px; }
  .header-weekday { background: #0d3b5a !important; }
  .header-daynum { background: #6b7280 !important; }
  .top-bar { background: var(--surface); border-bottom: 1px solid var(--border); }
  .legend-bar { background: #faf9f6; border-bottom: 1px solid var(--border); }
  #gridTable th { font-size: 10px; padding: 4px 6px; }
  .col-info-1 { min-width: 38px; width: 38px; }
  .col-info-2 { left: 38px; min-width: 100px; }
  .col-info-3 { left: 138px; min-width: 115px; padding-left: 6px !important; padding-right: 48px !important; }
  .col-info-4 { left: 253px; min-width: 90px; }
  .col-info-5 { left: 343px; min-width: 78px; }
  .col-total { min-width: 38px; }
  .emp-badges { position: static; display: inline-flex; margin-left: 6px; transform: none; vertical-align: middle; }
  .emp-badge { width: 14px; height: 14px; font-size: 8px; }
  .footer-bar { padding: 4px 10px; gap: 4px 8px; }
  .footer-bar .ft-item { font-size: 10px; }
  .batch-header { padding: 5px 8px; font-size: 11px; }
  .batch-body { padding: 6px 8px; }
  .batch-body .radio-grid { grid-template-columns: repeat(2, 1fr); }
  .batch-body .radio-card { font-size: 9px; padding: 2px 4px; }
  .batch-field label { font-size: 10px; }
  .batch-actions { flex-wrap: wrap; }
  .batch-actions .btn { font-size: 10px; padding: 4px 8px; flex: 1; text-align: center; }
  .context-menu { min-width: 120px; }
  .ctx-item { padding: 5px 8px; font-size: 11px; }
  .toast { bottom: 40px; font-size: 12px; padding: 6px 14px; max-width: 90vw; }
  .cell-tooltip { font-size: 10px; padding: 6px 10px; max-width: 160px; min-width: 60px; }
  #gridTable thead tr:nth-child(2) th { top: 24px; }
  .grid-wrap::-webkit-scrollbar { width: 4px; height: 4px; }

  /* En móvil las columnas informativas NO son sticky — se mueven con el scroll */
  .col-info-1,
  .col-info-2,
  .col-info-3,
  .col-info-4,
  .col-info-5 {
    position: static !important;
    left: auto !important;
  }
}

/* ============================================================
   MOBILE-SPECIFIC: Show undo labels on tablet hover
   ============================================================ */
@media (hover: hover) {
  .btn-undo:hover .undo-label {
    display: inline;
  }
}

/* ============================================================
   MOBILE-SPECIFIC: Bottom sheet context menu
   v118: combinar (pointer: coarse) con (max-width: 1024px) para
   evitar que laptops con touch (Surface, XPS 2-in-1) activen el
   bottom sheet cuando se usan con mouse.
   ============================================================ */
@media (pointer: coarse) and (max-width: 1024px) {
  /* Touch feedback (no hover, use active instead) */
  #gridTable td:hover { filter: none; }
  #gridTable td:active { filter: brightness(0.88); }
  #gridBody,
  #gridBody * {
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
  }
  body.context-menu-open { overflow: hidden; }
  .context-menu-backdrop.active {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 249;
    background: rgba(15, 23, 42, 0.28);
    touch-action: none;
  }

  /* Bottom sheet context menu */
  .context-menu.active {
    position: fixed;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: auto !important;
    min-width: 0 !important;
    max-height: min(78dvh, 680px);
    overflow-y: auto;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
    animation: bottomSheetUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border);
    padding: 6px 10px max(10px, env(safe-area-inset-bottom));
    z-index: 250;
  }
  .context-menu.active::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 6px auto 8px;
  }
  @keyframes bottomSheetUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }
  .ctx-item {
    min-height: 46px;
    padding: 10px 12px;
    font-size: 14px;
  }
  .ctx-grid-2 .ctx-item { font-size: 13px; }
  .ctx-header { position: sticky; top: -6px; z-index: 1; padding: 8px 12px 10px; background: rgba(255,255,255,0.98); }
  .ctx-header strong { font-size: 15px; }
  .ctx-section-label { padding-left: 12px; }
}

/* ============================================================
   SCROLL INDICATORS (Mobile)
   ============================================================ */
.grid-wrap {
  position: relative;
}
.grid-wrap::after {
  display: none;
}
@media (max-width: 900px) {
  .grid-wrap::after {
    display: block;
  }
}

/* ============================================================
   LONG-PRESS INDICATOR
   ============================================================ */
#gridBody td.long-pressing {
  background: rgba(37, 99, 235, 0.12) !important;
  transition: background 0.05s;
}

/* ============================================================
   IMPORT SECTION (Admin - Excel Upload)
   ============================================================ */
.import-dropzone {
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: transparent;
}
.import-dropzone:hover {
  border-color: #2563eb;
  background: #eff6ff;
}
.import-dropzone-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.import-dropzone-text {
  font-size: 16px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}
.import-dropzone-hint {
  font-size: 12px;
  color: #9ca3af;
}

@media (max-width: 400px) {
  .app-title { font-size: 12px; }
  .top-center select { font-size: 10px; padding: 2px 4px; }
  .top-right .btn { font-size: 10px; padding: 4px 6px; min-height: 32px; }
  .modal { width: 98vw; }
  .radio-grid { grid-template-columns: 1fr 1fr; gap: 2px; }
  .radio-card { font-size: 9px; padding: 3px 4px; }
  .col-info-1 { min-width: 32px; width: 32px; }
  .col-info-2 { left: 32px; min-width: 82px; }
  .col-info-3 { left: 114px; min-width: 90px; padding-right: 48px !important; }
  .col-info-4 { left: 204px; min-width: 70px; }
  .col-info-5 { left: 274px; min-width: 62px; }
  .footer-bar .ft-item { font-size: 9px; }
  #gridTable td { min-width: 32px; height: 32px; line-height: 24px; padding: 4px 6px; }
}

/* ==========================================================================
   UPDATE BANNER — nueva versión del SW disponible
   ========================================================================== */

.update-banner {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0c2e3e;
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  max-width: 90vw;
  white-space: nowrap;
}
.update-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.update-banner-icon {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}
.update-banner-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.update-banner-btn {
  background: #d97706;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.update-banner-btn:hover {
  background: #b45309;
}
.update-banner-btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.update-banner-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}
.update-banner-close:hover {
  color: #fff;
}

@media (max-width: 600px) {
  .update-banner {
    bottom: 70px;
    padding: 10px 14px;
    font-size: 12px;
    gap: 8px;
    border-radius: 10px;
    flex-wrap: wrap;
    justify-content: center;
    white-space: normal;
    text-align: center;
  }
  .update-banner-text {
    flex: 0 0 100%;
  }
  .update-banner-btn {
    padding: 8px 20px;
    font-size: 11px;
  }
}

/* ==========================================================================
   NOTIFICATION MODAL — replaces toast notifications
   ========================================================================== */

.notif-modal {
  max-width: 420px;
  text-align: center;
  padding: 0;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  border: none;
  background: #fff;
  overflow: hidden;
}

.notif-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 20px 0;
  border-bottom: none;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.notif-modal .modal-body {
  padding: 12px 24px 24px;
}

.notif-icon {
  font-size: 42px;
  line-height: 1;
  margin-bottom: 10px;
  display: block;
}

.notif-icon.error { color: #dc2626; }
.notif-icon.success { color: #16a34a; }
.notif-icon.info { color: #104861; }
.notif-icon.warning { color: #d97706; }

.notif-message {
  font-size: 14px;
  line-height: 1.5;
  color: #374151;
  margin: 0;
}

.notif-sub {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 4px;
}

.notif-modal .modal-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 0 20px 20px;
  border-top: none;
}

@media (max-width: 600px) {
  .notif-modal { max-width: 90vw; }
  .notif-icon { font-size: 34px; }
  .notif-message { font-size: 13px; }
}

/* ============================================================
   ROSTER — popover con colores sincronizados con la leyenda
   ============================================================ */
/* Cada radio-card del cellModal del roster lleva una clase ct-X
   (misma que la leyenda y las celdas) → el preview se ve igual
   que en la grilla, sin repetir la paleta. */
#rosterTipoGrid .radio-card {
  font-weight: 600;
  border: 2px solid transparent;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
  cursor: pointer;
}
#rosterTipoGrid .radio-card:hover { transform: translateY(-1px); }
#rosterTipoGrid .radio-card:has(input:checked) {
  border-color: #1e3a5f;
  box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.25);
  font-weight: 700;
}
#rosterTipoGrid .radio-card input[type="radio"] { transform: scale(1.1); }

/* ============================================================
   ROSTER — abreviaturas en celdas (mejor legibilidad)
   ============================================================ */
#gridTable.roster td .code {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 18px;
}
#gridTable.roster td.has-comment {
  /* Asegurar que el dot rojo del .has-comment (existente) se vea */
  outline: 1.5px dashed rgba(239, 68, 68, 0.45);
  outline-offset: -2px;
}
#gridTable.roster td .note-icon {
  position: absolute;
  bottom: 1px;
  left: 2px;
  font-size: 9px;
  line-height: 1;
  cursor: help;
  opacity: 0.85;
  pointer-events: auto;
}

/* ============================================================
   ROSTER — Toast notifications
   ============================================================ */
.roster-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #16323f;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}
.roster-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}
.roster-toast.error { background: #dc2626; }
.roster-toast.success { background: #16a34a; }

/* ============================================================
   ROSTER — Mobile responsive (forced via container queries + JS class)
   Topbar layout is fully controlled in roster.html <style>.
   Here we only handle grid/table, modals, and components.
   ============================================================ */
body.is-mobile .roster-topbar .roster-meta { display: none; }
body.is-mobile .roster-topbar .emp-count { font-size: 11px !important; }

/* Sheet tabs: compact pill-style, horizontal scroll */
body.is-mobile .roster-sheet-tabs {
  padding: 8px 12px !important;
  gap: 6px !important;
  -webkit-overflow-scrolling: touch;
}
body.is-mobile .roster-sheet-tab {
  font-size: 12px !important;
  padding: 6px 12px !important;
  border-radius: 16px !important;
}

/* Legend: slim horizontal scroll */
body.is-mobile .legend-bar {
  padding: 6px 12px !important;
  gap: 12px !important;
  height: auto !important;
  min-height: 0 !important;
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
}
body.is-mobile .legend-bar .lg-item { font-size: 10px !important; flex-shrink: 0; }

/* Grid table cells */
body.is-mobile #gridTable.roster td { min-width: 32px; height: 32px; line-height: 32px; font-size: 11px; padding: 2px 3px; }
body.is-mobile #gridTable.roster td .code { font-size: 11px; }
body.is-mobile #gridTable.roster thead th { font-size: 10px !important; padding: 4px 2px !important; }

/* Modals: full-width on mobile */
body.is-mobile .modal#cellModal,
body.is-mobile .modal#pwModalInner,
body.is-mobile .modal#empPickerModalInner {
  width: 96vw !important;
  max-width: 96vw !important;
  left: 2vw !important;
  transform: none !important;
  top: 2vh !important;
  max-height: 96vh;
  overflow-y: auto;
}
body.is-mobile .modal#cellModal.active { transform: none !important; }
body.is-mobile .modal .modal-body { padding: 12px !important; }
body.is-mobile .modal .modal-footer { flex-wrap: wrap; gap: 6px; }
body.is-mobile .modal .modal-footer .btn { flex: 1 1 auto; min-width: 80px; }
body.is-mobile #rosterTipoGrid { grid-template-columns: repeat(2, 1fr) !important; gap: 6px !important; }
body.is-mobile #rosterTipoGrid .radio-card { padding: 8px 6px !important; font-size: 12px !important; }
body.is-mobile .roster-notes textarea { font-size: 14px !important; }
body.is-mobile .footer-bar { padding: 8px 12px !important; font-size: 11px !important; }
body.is-mobile.is-narrow #rosterTipoGrid { grid-template-columns: 1fr !important; }

/* ============================================================
   ADMIN REDESIGN — Light Corporate refinements
   (scoped to .admin-body; class names unchanged, JS-safe)
   ============================================================ */
/* Sidebar group label */
.admin-sidebar-group {
  font-size: 10px;
  font-weight: 800;
  color: #a29c90;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  padding: 14px 14px 8px;
}
.admin-sidebar-group:first-child { padding-top: 6px; }
.admin-sidebar-btn svg { flex-shrink: 0; }
.admin-sidebar-btn.active { font-weight: 700; }

/* Primary buttons → solid emerald in admin (overrides global blue gradient) */
.admin-body .btn { border-radius: 10px; }
.admin-body .btn-primary {
  background: var(--admin-accent);
  box-shadow: none;
}
.admin-body .btn-primary:hover {
  background: var(--admin-accent-hover);
  filter: none;
  box-shadow: none;
}

/* Form inputs → emerald focus */
.admin-body .form-input:focus,
.admin-body .form-textarea:focus {
  border-color: var(--admin-accent);
  box-shadow: 0 0 0 3px rgba(16,72,97,0.12);
}

/* Dashboard stat-card label spacing */
.dash-card-label { margin-top: 6px; }

/* Table cells a touch more air */
.admin-table td { padding: 13px 18px; }

/* Row action buttons → neat icon chips */
.admin-body .table-actions { gap: 6px; }
.admin-body .btn-sm {
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: none;
}
.admin-body .btn-sm.btn-secondary {
  background: #f4f2ee;
  border: 1px solid var(--admin-border);
  color: #64748b;
}
.admin-body .btn-sm.btn-secondary:hover {
  background: var(--admin-accent-bg);
  border-color: #c3d4dc;
  color: var(--admin-accent-hover);
}
.admin-body .btn-sm.btn-danger {
  background: #f4f2ee;
  border: 1px solid var(--admin-border);
  color: #64748b;
}
.admin-body .btn-sm.btn-danger:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #dc2626;
}

/* Sub-tabs → emerald active (match theme) */
.arkon-tab:hover { color: var(--admin-primary); }
.arkon-tab.active {
  color: var(--admin-accent-hover);
  border-bottom-color: var(--admin-accent);
}

/* Import dropzone → emerald-tinted */
.admin-body .import-dropzone:hover {
  border-color: #9db6c2;
  background: var(--primary-tint);
}

/* ============================================================
   APP RESPONSIVE POLISH
   Scopeado a .app-body para no tocar el Admin Panel.
   ============================================================ */
body.app-body .app,
body.app-body .top-bar,
body.app-body .legend-bar,
body.app-body .footer-bar,
body.app-body .grid-wrap {
  min-width: 0;
}

body.app-body .top-left,
body.app-body .top-center,
body.app-body .top-right {
  min-width: 0;
}

body.app-body .app-title,
body.app-body .app-project-current,
body.app-body .app-user-info {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.app-body .top-center,
body.app-body .top-right {
  flex-wrap: wrap;
}

body.app-body .top-center .sel-group {
  min-width: 0;
}

body.app-body .top-center select,
body.app-body .top-right .btn,
body.app-body .top-right button {
  max-width: 100%;
}

@media (max-width: 900px) {
  body.app-body .top-bar {
    align-content: flex-start;
  }
  body.app-body .top-left {
    flex: 1 1 280px;
    max-width: 100%;
  }
  body.app-body .top-center,
  body.app-body .top-right {
    flex: 1 1 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  body.app-body .top-center {
    justify-content: flex-start;
  }
  body.app-body .top-right {
    justify-content: flex-start;
  }
  body.app-body .top-right .btn,
  body.app-body .top-right button {
    flex: 0 0 auto;
    min-height: 36px;
    white-space: nowrap;
  }
  body.app-body .grid-wrap {
    width: 100%;
    max-width: 100vw;
    overscroll-behavior: contain;
  }
}

@media (max-width: 600px) {
  body.app-body {
    font-size: 12px;
  }
  body.app-body .top-bar {
    padding-left: 10px;
    padding-right: 10px;
  }
  body.app-body .top-left {
    flex: 1 1 100%;
  }
  body.app-body .app-title {
    max-width: min(62vw, 260px);
  }
  body.app-body .top-center .sel-group {
    flex: 0 0 auto;
  }
  body.app-body .top-center select {
    min-width: 96px;
  }
  body.app-body .top-right {
    flex-wrap: nowrap;
  }
  body.app-body .footer-bar {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 420px) {
  body.app-body .app-title {
    max-width: 54vw;
  }
  body.app-body .top-center select {
    min-width: 86px;
    padding-left: 6px;
    padding-right: 6px;
  }
  body.app-body .top-right .btn,
  body.app-body .top-right button {
    min-width: 92px;
  }
}

/* ============================================================
   v178: RESPONSIVE PROJECT GRID — Nombre sticky en móvil + anchos con tope
   Solo afecta al grid de proyectos (#gridTable sin la clase .roster);
   el roster maneja sus columnas en roster.html y app-ph no usa col-info.
   - ≤900px: topes de ancho con ellipsis (nombres/ocupaciones largos
     ya no ensanchan la tabla entera).
   - ≤600px: # y Nombre vuelven a ser sticky (compactos); ID, Ocupación
     y Proyecto se desplazan con el scroll y quedan bajo el Nombre.
     Así las columnas de días son visibles en el teléfono sin perder
     de vista a quién pertenece cada fila.
   ============================================================ */
@media (max-width: 900px) {
  body.app-body #gridTable:not(.roster) .col-info-2 { max-width: 100px; overflow: hidden; text-overflow: ellipsis; }
  body.app-body #gridTable:not(.roster) .col-info-3 { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
  body.app-body #gridTable:not(.roster) .col-info-4 { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
  body.app-body #gridTable:not(.roster) .col-info-5 { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
}

@media (max-width: 600px) {
  body.app-body #gridTable:not(.roster) .col-info-1 {
    position: sticky !important;
    left: 0 !important;
    min-width: 34px; width: 34px;
  }
  body.app-body #gridTable:not(.roster) .col-info-2 {
    min-width: 0; max-width: 84px;
    font-size: 10px;
  }
  body.app-body #gridTable:not(.roster) .col-info-3 {
    position: sticky !important;
    left: 34px !important;
    min-width: 108px; max-width: 136px;
    padding-right: 10px !important;
    box-shadow: 4px 0 6px -4px rgba(15, 23, 42, 0.35);
  }
  body.app-body #gridTable:not(.roster) .col-info-4 {
    min-width: 0; max-width: 92px;
    font-size: 10px;
  }
  body.app-body #gridTable:not(.roster) .col-info-5 {
    min-width: 0; max-width: 80px;
    font-size: 10px;
  }
}

@media (max-width: 400px) {
  body.app-body #gridTable:not(.roster) .col-info-2 { max-width: 72px; }
  body.app-body #gridTable:not(.roster) .col-info-3 { min-width: 96px; max-width: 120px; }
}

/* Scrollbars finos en las barras horizontales (leyenda, pestañas de
   hojas, footer) — en Windows el scrollbar por defecto es muy grueso
   y "salta" el layout. Solo estética, no cambia el scroll. */
.legend-bar::-webkit-scrollbar,
.roster-sheet-tabs::-webkit-scrollbar,
.footer-bar::-webkit-scrollbar {
  height: 5px;
}
.legend-bar::-webkit-scrollbar-track,
.roster-sheet-tabs::-webkit-scrollbar-track,
.footer-bar::-webkit-scrollbar-track {
  background: transparent;
}
.legend-bar::-webkit-scrollbar-thumb,
.roster-sheet-tabs::-webkit-scrollbar-thumb,
.footer-bar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* Modales: usar dvh donde exista (la barra de URL móvil achica el
   viewport real; con vh el footer del modal quedaba fuera de pantalla) */
@media (max-width: 900px) {
  .modal { max-height: 90dvh; }
}
@media (max-width: 600px) {
  .modal { max-height: 92dvh; }
}

/* ============================================================
   TOP BAR RESPONSIVE — organización de acciones por pantalla
   Desktop: todos los botones inline (el menú "Más" no existe).
   ≤900px: acciones secundarias (Masivos, Ponches, Cerrar Sesión)
   se agrupan en el menú "Más"; las primarias quedan visibles.
   ≤600px: título+deshacer en fila 1, selects en cuadrícula de 3,
   acciones en fila propia. Va al FINAL del archivo a propósito:
   debe ganar la cascada sobre los bloques responsive anteriores.
   ============================================================ */
.more-toggle { display: none; }
.more-menu { display: contents; }

/* El menú "Más" se activa ya en anchos intermedios (tablets/ventanas
   angostas): con todos los botones inline la barra se parte en dos filas. */
@media (max-width: 1100px) {
  .more-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
  }
  body.app-body .top-right { position: relative; overflow: visible; }
  .more-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 400;
    min-width: 210px;
    background: #fff;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(16, 42, 56, 0.18);
    padding: 6px;
    flex-direction: column;
    gap: 2px;
  }
  .more-menu.open { display: flex; }
  .more-menu .btn {
    display: block;
    width: 100%;
    flex: none;
    text-align: left;
    background: #fff;
    border: none;
    border-radius: 6px;
    padding: 11px 12px;
    font-size: 13px;
    min-height: 44px;
    box-shadow: none;
    color: var(--text);
  }
  .more-menu .btn:hover,
  .more-menu .btn:active { background: #f4f2ee; }
  .more-menu .btn-punches { color: #1d5c40; }
}

@media (max-width: 900px) {
  body.app-body .top-bar { row-gap: 8px; }
  /* el dropdown se ancla al top-right: sin overflow que lo recorte */
  body.app-body .top-center,
  body.app-body .top-right {
    overflow: visible;
    flex-wrap: wrap;
    padding-bottom: 0;
  }
}

@media (max-width: 600px) {
  /* Deshacer/Rehacer: compactos al final de la fila del título
     (antes ocupaban una fila entera con borde) */
  body.app-body .undo-group {
    order: 7;
    flex: 0 0 auto;
    border-top: none;
    margin: 0 0 0 auto;
    padding: 0;
    gap: 4px;
    justify-content: flex-end;
  }
  body.app-body .btn-undo { min-width: 36px; min-height: 34px; padding: 4px 8px; }
  body.app-body .btn-undo .undo-label { display: none; }

  /* Selects: cuadrícula de 3 columnas con etiqueta arriba */
  body.app-body .top-center {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
    justify-content: stretch;
  }
  body.app-body .top-center .sel-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    min-width: 0;
    flex: none;
  }
  body.app-body .sel-label { display: block; font-size: 10px; }
  body.app-body .top-center select { width: 100%; min-width: 0; max-width: none; }

  /* Acciones: primarias a lo ancho + toggle "Más" compacto.
     Las contextuales (Eliminar / Pegar) toman fila completa al aparecer. */
  body.app-body .top-right { display: flex; flex-wrap: wrap; gap: 6px; }
  body.app-body .top-right .btn { min-width: 0; flex: 1 1 auto; }
  body.app-body .top-right .more-toggle { flex: 0 0 auto; }
  body.app-body .top-right #deleteSelectedBtn,
  body.app-body .top-right #pasteSelectedBtn { flex: 1 1 100%; }
  body.app-body .more-menu { left: 0; right: 0; min-width: 0; }
}

/* Admin: botón de acción de cada sección a lo ancho en móvil */
@media (max-width: 768px) {
  .admin-body .admin-section-header .btn {
    width: 100%;
    text-align: center;
    min-height: 42px;
  }
}
