html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* ===================== KPI CARDS ===================== */
.kpi-card {
  background: #fff;
  border-radius: 1rem;
  padding: 0.9rem;
  box-shadow: 0 1px 2px rgba(15, 38, 71, 0.06);
  border: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.kpi-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.kpi-label {
  font-size: 0.72rem;
  color: #64748b;
  font-weight: 500;
  line-height: 1.1;
}
.kpi-value {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  font-variant-numeric: proportional-nums;
}

/* ===================== BADGES ===================== */
.badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-pending {
  background: #fef3c7;
  color: #92650a;
}
.badge-paid {
  background: #d1fae5;
  color: #006300;
}
.badge-enproceso {
  background: #e0f2fe;
  color: #0369a1;
}
.badge-feriado {
  background: #f3e8ff;
  color: #7e22ce;
}

/* ===================== CALENDAR DAY CELLS ===================== */
.dia-celda {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 0.6rem;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.dia-celda:hover {
  box-shadow: 0 0 0 2px #2b4d80 inset;
}
.dia-celda:active {
  transform: scale(0.95);
}
.dia-celda.estado-completo {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #065f46;
}
.dia-celda.estado-tardanza {
  background: #fffbeb;
  border-color: #fcd34d;
  color: #92400e;
}
.dia-celda.estado-falta {
  background: #fff1f2;
  border-color: #fda4af;
  color: #9f1239;
}
.dia-celda.estado-perdida_falta {
  background: #fee2e2;
  border-color: #f87171;
  color: #7f1d1d;
}
.dia-celda .dot-perdida {
  position: absolute;
  top: 2px;
  left: 3px;
  color: #b91c1c;
  display: flex;
}
.dia-celda.hoy {
  box-shadow: 0 0 0 2px #0f2647 inset;
}
.dia-celda .dot-campo {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #0ea5e9;
}
.dia-celda .dot-extra {
  position: absolute;
  bottom: 3px;
  right: 3px;
  font-size: 0.55rem;
  color: #059669;
  font-weight: 700;
}
.dia-celda.dia-fuera-mes {
  visibility: hidden;
  pointer-events: none;
}
.dia-celda .dot-recupera {
  position: absolute;
  bottom: 3px;
  right: 3px;
  font-size: 0.55rem;
  color: #b45309;
  font-weight: 700;
}
.dia-celda .tag-modalidad {
  position: absolute;
  top: 2px;
  left: 3px;
  font-size: 0.55rem;
  font-weight: 700;
  color: #94a3b8;
}
.dia-celda.dia-congelado {
  opacity: 0.6;
}
.dia-celda.dia-en-proceso {
  opacity: 0.75;
  border-style: dashed;
}
.dia-celda.dia-feriado {
  box-shadow: inset 0 3px 0 0 #a855f7;
}
.dia-celda.dia-quincena-foco.dia-feriado {
  box-shadow: inset 0 3px 0 0 #a855f7, 0 0 0 2px #2b4d80 inset;
}
.dia-celda .dot-proceso {
  position: absolute;
  bottom: 3px;
  left: 3px;
  color: #0369a1;
  display: flex;
}
.dia-celda .dot-lock {
  position: absolute;
  bottom: 3px;
  left: 3px;
  color: #64748b;
  display: flex;
}
.dia-celda.dia-quincena-foco {
  box-shadow: 0 0 0 2px #2b4d80 inset;
}
.dia-celda.dia-rango-picker {
  box-shadow: 0 0 0 2px #0ea5e9 inset;
  background: #e0f2fe;
}
.dia-celda.dia-rango-picker.dia-feriado {
  box-shadow: inset 0 3px 0 0 #a855f7, 0 0 0 2px #0ea5e9 inset;
}

/* ===================== NAVEGACIÓN POR PESTAÑAS ===================== */
.tab-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  background: #eef3f9;
  padding: 0.3rem;
  border-radius: 0.9rem;
}
.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.55rem 0.3rem;
  border-radius: 0.65rem;
  font-size: 0.66rem;
  font-weight: 600;
  line-height: 1.15;
  color: #3a639e;
  background: transparent;
  text-align: center;
  transition: all 0.15s;
}
.tab-btn:hover {
  color: #182b48;
}
.tab-btn.tab-btn-activo {
  background: #fff;
  color: #0f2647;
  box-shadow: 0 1px 3px rgba(15, 38, 71, 0.18);
}
@media (min-width: 640px) {
  .tab-btn {
    flex-direction: row;
    font-size: 0.82rem;
    padding: 0.65rem 0.85rem;
  }
}

/* ===================== BANCO DE HORAS ===================== */
.banco-horas-banner {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #92400e;
  border-radius: 0.85rem;
  padding: 0.65rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ===================== QUINCENAS FIJAS (botones directos) ===================== */
.quincena-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.85rem;
  padding: 0.7rem 0.9rem;
  background: #fff;
  text-align: left;
  transition: all 0.15s;
}
.quincena-toggle-btn:hover {
  border-color: #2b4d80;
}
.quincena-toggle-btn-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f2647;
}
.quincena-toggle-btn.quincena-toggle-btn-activo {
  border-color: #2b4d80;
  box-shadow: 0 0 0 1px #2b4d80;
  background: #eef3f9;
}

.quincena-accion-bar {
  background: #eef3f9;
  border: 1px solid #adc5e1;
  border-radius: 0.85rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.proceso-rango-panel {
  background: #f0f9ff;
  border: 1px solid #7fa3ce;
  border-radius: 0.85rem;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

/* ===================== CONTEXTO KPI (quincena en foco) ===================== */
.contexto-kpi {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #eef3f9;
  border: 1px solid #adc5e1;
  color: #182b48;
  border-radius: 0.75rem;
  padding: 0.55rem 0.85rem;
  font-size: 0.8rem;
}
.contexto-kpi span:nth-child(2) { flex: 1; }

/* ===================== ADELANTOS / CAJA CHICA ===================== */
.resumen-fila {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: #475569;
  padding: 0.2rem 0;
}
.resumen-fila .val { font-weight: 600; color: #0f2647; font-variant-numeric: tabular-nums; }
.progreso-adelanto {
  width: 100%;
  background: #f1f5f9;
  border-radius: 999px;
  height: 0.4rem;
  overflow: hidden;
  margin: 0.4rem 0;
}
.progreso-adelanto > div {
  background: #2b4d80;
  height: 100%;
}
.historial-lista {
  max-height: 9rem;
  overflow-y: auto;
  border-top: 1px dashed #e2e8f0;
  margin-top: 0.5rem;
  padding-top: 0.4rem;
}
.historial-fila {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: #64748b;
  padding: 0.15rem 0;
}

/* ===================== MODALS ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 24, 48, 0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}
.modal-overlay.hidden {
  display: none;
}
.modal-panel {
  background: #fff;
  width: 100%;
  border-radius: 1.25rem 1.25rem 0 0;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease-out;
}
@media (min-width: 640px) {
  .modal-overlay {
    align-items: center;
    padding: 1rem;
  }
  .modal-panel {
    border-radius: 1.25rem;
    max-height: 88vh;
  }
}
@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.modal-close {
  color: #94a3b8;
  padding: 0.25rem;
  border-radius: 0.5rem;
}
.modal-close:hover {
  background: #f1f5f9;
  color: #334155;
}
.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}
.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  flex-shrink: 0;
}

/* ===================== MODO SOLO LECTURA (día/quincena cerrados) ===================== */
.aviso-solo-lectura {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #7f1d1d;
  background: #fee2e2;
  border: 1px solid #f87171;
  border-radius: 0.65rem;
  padding: 0.55rem 0.8rem;
}
.field-input:disabled,
.modalidad-btn:disabled,
.estado-btn:disabled,
.modo-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f1f5f9;
}
input:disabled[type="checkbox"] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ===================== FORM FIELDS ===================== */
.field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 0.3rem;
}
.field-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 0.6rem;
  padding: 0.5rem 0.7rem;
  font-size: 0.9rem;
  color: #0f2647;
  background: #fff;
}
.field-input:focus {
  outline: none;
  border-color: #2b4d80;
  box-shadow: 0 0 0 3px rgba(43, 77, 128, 0.15);
}

/* ===================== BUTTONS ===================== */
.btn-primary {
  background: #0f2647;
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 1.1rem;
  border-radius: 0.65rem;
  transition: background 0.15s;
}
.btn-primary:hover { background: #182b48; }
.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.6rem 1.1rem;
  border-radius: 0.65rem;
}
.btn-secondary:hover { background: #e2e8f0; }

.estado-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.6rem 0.4rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.65rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
  background: #fff;
  transition: all 0.15s;
}
.estado-btn.activo[data-estado="completo"] {
  background: #ecfdf5; border-color: #10b981; color: #065f46;
}
.estado-btn.activo[data-estado="tardanza"] {
  background: #fffbeb; border-color: #f59e0b; color: #92400e;
}
.estado-btn.activo[data-estado="falta"] {
  background: #fff1f2; border-color: #f43f5e; color: #9f1239;
}

.modalidad-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.55rem 0.3rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.65rem;
  font-size: 0.68rem;
  font-weight: 600;
  color: #475569;
  background: #fff;
  transition: all 0.15s;
}
.modalidad-btn.activo {
  background: #eef3f9;
  border-color: #2b4d80;
  color: #182b48;
}

.modo-btn {
  padding: 0.45rem 0.5rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #475569;
  background: #fff;
  transition: all 0.15s;
}
.modo-btn.activo {
  background: #eef3f9;
  border-color: #2b4d80;
  color: #182b48;
}

/* tramo row (config de tardanza) */
.tramo-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 0.4rem;
  align-items: center;
}
.tramo-row input {
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
  padding: 0.4rem 0.4rem;
  font-size: 0.78rem;
}
.tramo-remove {
  color: #cbd5e1;
  padding: 0.3rem;
}
.tramo-remove:hover { color: #f43f5e; }

/* ===================== PRE-BOLETA ===================== */
.boleta-row {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.87rem;
  border-bottom: 1px dashed #e2e8f0;
}
.boleta-row .label { color: #475569; }
.boleta-row .val { font-weight: 600; font-variant-numeric: tabular-nums; }
.boleta-row .val.positivo { color: #006300; }
.boleta-row .val.negativo { color: #b91c1c; }

/* ===================== PRINT ===================== */
@media print {
  body * { visibility: hidden; }
  #boletaPanel, #boletaPanel * { visibility: visible; }
  #boletaPanel {
    position: absolute; inset: 0; width: 100%; max-height: none;
    box-shadow: none; border-radius: 0;
  }
  .no-print { display: none !important; }
}
