/* Ajustes exclusivos de Liquidación: no modificar los filtros compartidos. */
.liq-body #liqFilterHost .kre-filter-actions,
.liq-body #liqHistorialFilterPanel .kre-filter-actions {
  width: 100%;
}

/* El Historial usa los MISMOS botones que la Lista: mismo tamaño, color y tipografía (PROCESAR más ancho que Limpiar). */
.liq-body #btnProcesarFiltrosLiquidacion,
.liq-body #btnProcesarFiltrosHistorial {
  flex: 1.3 0 130px;
  min-width: 130px;
  padding-inline: 14px;
  white-space: nowrap;
}

/* El ancho de 340 px debe incluir el relleno y el borde del panel: con la caja por omisión (content-box) medía 362 px, se
   montaba sobre la grilla y la tapaba por la izquierda. */
.liq-body #liqFilterSidebar,
.liq-body #liqHistorialFilterPanel {
  box-sizing: border-box;
}

.liq-body #tabHistorial {
  gap: 14px;
}

/* Las barras y encabezados se acomodan en varias líneas en pantallas angostas. */
.liq-body .liq-toolbar {
  flex-wrap: wrap;
  gap: 10px 14px;
}

.liq-body .liq-toolbar-primary,
.liq-body .liq-toolbar-actions,
.liq-body .liq-section-heading {
  flex-wrap: wrap;
}

.liq-body .liq-counter {
  white-space: nowrap;
}

.liq-body #tblDetalleLiquidacion .liq-row-check,
.liq-body #chkAllDetalleLiquidacion {
  width: 18px;
  min-width: 18px;
  max-width: 18px;
  height: 18px;
  min-height: 18px;
  max-height: 18px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  vertical-align: middle;
  cursor: pointer;
}

.liq-body #tblDetalleLiquidacion .liq-select-column {
  min-width: 40px;
}

.liq-body .liq-history-actions {
  display: table-cell;
  text-align: left !important;
}

/* La tabla usa layout fijo: reservar botones (74px) y padding (24px). */
.liq-body #tblHistorialLiquidacion th:first-child {
  width: 104px;
}

.liq-body .liq-history-action-buttons {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
}

.liq-body .liq-history-action-buttons .liq-icon-btn {
  flex: 0 0 34px;
}

.liq-body .liq-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.liq-body .liq-icon-btn.danger:disabled:hover {
  background: #e8f1ff;
}

/* ----- Botones flotantes con varias acciones (columnas Póliza y Factura) ----- */
/* La burbuja es un grupo: «Ver estado de cuenta» y «Configurar comisión» salen juntos al pasar el mouse o al enfocar el número. */
.liq-body #tblDetalleLiquidacion .action-trigger:focus {
  outline: none;
}

.liq-body #tblDetalleLiquidacion .action-trigger:focus-visible .liq-trigger-label {
  border-radius: 3px;
  outline: 2px solid #347df5;
  outline-offset: 2px;
}

.liq-body #tblDetalleLiquidacion .floating-action-group {
  bottom: 100%;
  display: flex;
  gap: 6px;
  left: 0;
  opacity: 0;
  padding-bottom: 8px; /* puente invisible: el cursor puede subir del número a la burbuja sin que desaparezca */
  position: absolute;
  transform: translateY(2px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
  visibility: hidden;
  white-space: nowrap;
  z-index: 1000;
}

.liq-body #tblDetalleLiquidacion .action-trigger:hover .floating-action-group,
.liq-body #tblDetalleLiquidacion .action-trigger:focus-within .floating-action-group {
  opacity: 1;
  transform: none;
  transition-delay: 0s;
  visibility: visible;
}

.liq-body #tblDetalleLiquidacion .floating-action-group .floating-action-button {
  align-items: center;
  display: inline-flex;
  gap: 6px;
  margin: 0;
  min-width: 0;
  opacity: 1;
  position: static;
  text-decoration: none;
  transform: none;
  /* Hereda la visibilidad del grupo: con "visible" propio un botón seguiría recibiendo clics aunque la burbuja esté oculta */
  visibility: inherit;
}

.liq-body #tblDetalleLiquidacion .floating-action-group .floating-action-button::after {
  display: none;
}

.liq-body #tblDetalleLiquidacion .floating-action-group .floating-action-button:hover,
.liq-body #tblDetalleLiquidacion .floating-action-group .floating-action-button:focus-visible {
  filter: brightness(1.12);
}

.liq-body #tblDetalleLiquidacion .floating-action-group .btn-configurar-comision {
  background-color: #1f3b63;
}

/* ----- Aviso: la configuración de comisiones cambió en otra pestaña ----- */
/* Franja bajo el encabezado de la conciliación (misma sangría de 18 px que el encabezado) */
.liq-body .liq-config-aviso {
  align-items: center;
  background: #fff8e1;
  border: 0;
  border-bottom: 1px solid #f1d27a;
  color: #5f4700;
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 10px 12px;
  margin: 0;
  padding: 10px 18px;
}

.liq-body .liq-config-aviso[hidden] {
  display: none;
}

.liq-body .liq-config-aviso > span {
  flex: 1 1 280px;
  min-width: 0;
}

.liq-body .liq-config-aviso .liq-btn.small {
  font-size: 12px;
  padding: 6px 11px;
}

/* ----- Historial: anchos de columna (la tabla usa layout fijo) para que fechas, importes y estado se lean completos ----- */
/* Los anchos incluyen el relleno (border-box): la suma de columnas es el ancho real de la tabla y no se sale de su tarjeta. */
.liq-body #tblHistorialLiquidacion th {
  box-sizing: border-box;
}

.liq-body #tblHistorialLiquidacion th:nth-child(2) { width: 120px; }
.liq-body #tblHistorialLiquidacion th:nth-child(3) { width: 120px; }
.liq-body #tblHistorialLiquidacion th:nth-child(4) { width: 186px; }
.liq-body #tblHistorialLiquidacion th:nth-child(5) { width: 120px; }
.liq-body #tblHistorialLiquidacion th:nth-child(6) { width: 60px; }
.liq-body #tblHistorialLiquidacion th:nth-child(7) { width: 104px; }
.liq-body #tblHistorialLiquidacion th:nth-child(8) { width: 104px; }
.liq-body #tblHistorialLiquidacion th:nth-child(9) { width: 104px; }
.liq-body #tblHistorialLiquidacion th:nth-child(10) { width: 116px; }
.liq-body #tblHistorialLiquidacion th:nth-child(11) { width: 120px; }
.liq-body #tblHistorialLiquidacion th:nth-child(12) { width: 112px; }
.liq-body #tblHistorialLiquidacion th:nth-child(13) { width: 118px; }

/* ----- Constancia de liquidación (vista previa e impresión) ----- */
.liq-body .liq-print-content {
  height: 92vh;
  max-width: 1350px;
  width: min(98vw, 1350px);
}

.liq-body .liq-print-area {
  color: #333;
  padding: 34px 40px;
}

.liqaseg-receipt {
  color: #333;
  font-family: inherit;
  margin: 0 auto;
  max-width: 1250px;
}

/* Encabezado: logo (o nombre) a la izquierda; datos de la empresa a la derecha. */
.liqaseg-receipt-top {
  align-items: flex-start;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 15px;
}

.liqaseg-receipt-logo {
  align-items: center;
  display: flex;
  min-height: 56px;
}

.liqaseg-receipt-logo img {
  display: block;
  max-height: 72px;
  max-width: 260px;
  object-fit: contain;
}

.liqaseg-receipt-logo strong {
  color: #2c3e50;
  font-size: 2.2rem;
  line-height: 1.1;
}

.liqaseg-receipt-company {
  color: #7f8c8d;
  font-size: 0.8rem;
  line-height: 1.45;
  min-width: 240px;
  text-align: right;
}

.liqaseg-receipt-company strong,
.liqaseg-receipt-company span {
  display: block;
}

.liqaseg-receipt-divider {
  border-bottom: 3px solid #3498db;
  margin-bottom: 15px;
}

.liqaseg-receipt-title {
  border-left: 4px solid #3498db;
  color: #2c3e50;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 15px;
  padding-left: 10px;
  text-transform: uppercase;
}

.liqaseg-receipt-anulada {
  background: #fdecea;
  border: 2px solid #e74c3c;
  border-radius: 4px;
  color: #c0392b;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 15px;
  padding: 8px 12px;
  text-align: center;
}

/* Cuadro de datos: 2 filas x 3 pares etiqueta / valor. «Fecha de Corte» va resaltada en verde. */
.liqaseg-receipt-info {
  border-left: 1px solid #e2e8f0;
  border-top: 1px solid #e2e8f0;
  display: grid;
  font-size: 0.85rem;
  grid-template-columns: 13.5% 19.5% 13.5% 19.5% 13.5% 20.5%;
  margin-bottom: 25px;
}

.liqaseg-receipt-info > div {
  align-items: center;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
  color: #1e293b;
  display: flex;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 8px 10px;
}

.liqaseg-receipt-info .etiqueta {
  background: #f1f5f9;
  color: #475569;
  font-weight: 600;
}

.liqaseg-receipt-info .valor.negrita {
  font-weight: 700;
}

.liqaseg-receipt-info .etiqueta.corte {
  background: #eafaf1;
  color: #27ae60;
}

.liqaseg-receipt-info .valor.corte {
  color: #27ae60;
  font-weight: 700;
}

/* Detalle: una sola tabla de 12 columnas. */
.liqaseg-receipt-table {
  border-collapse: collapse;
  font-size: 0.75rem;
  margin-bottom: 20px;
  table-layout: fixed;
  width: 100%;
}

.liqaseg-receipt-table th {
  background: #2c3e50;
  color: #fff;
  font-size: inherit;
  font-weight: 700;
  line-height: 1.4;
  max-width: none;
  overflow: visible;
  overflow-wrap: normal;
  padding: 10px 6px;
  text-align: center;
  text-overflow: clip;
  vertical-align: middle;
  white-space: normal;
}

.liqaseg-receipt-table th.izq { text-align: left; }
.liqaseg-receipt-table th.der { text-align: right; }
.liqaseg-receipt-table th.destacado { background: #34495e; }

/* Dos clases de especificidad: gana a `tbody td:nth-child(2)` de crudStyles (centrado, sin saltos y con puntos suspensivos). */
.liqaseg-receipt .liqaseg-receipt-table td {
  border-bottom: 1px solid #e2e8f0;
  color: #1e293b;
  font-size: inherit;
  line-height: 1.3;
  max-width: none;
  overflow: visible;
  overflow-wrap: anywhere;
  padding: 8px 6px;
  text-align: left;
  text-overflow: clip;
  vertical-align: middle;
  white-space: normal;
}

.liqaseg-receipt-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

/* Importes y porcentajes nunca se parten a media cifra. */
.liqaseg-receipt-table td.num { text-align: right; }
.liqaseg-receipt-table td.centro { text-align: center; }
.liqaseg-receipt-table td.num,
.liqaseg-receipt-table td.centro {
  overflow-wrap: normal;
  white-space: nowrap;
}
.liqaseg-receipt-table .negrita { font-weight: 700; }
.liqaseg-receipt-table td.azul { color: #2980b9; }

/* Nota a la izquierda y totales a la derecha. */
.liqaseg-receipt-bottom {
  align-items: flex-start;
  display: flex;
  gap: 24px;
  justify-content: space-between;
}

.liqaseg-receipt-nota {
  color: #64748b;
  font-size: 0.8rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  width: 55%;
}

.liqaseg-receipt-totals {
  border: 1px solid #e2e8f0;
  border-collapse: collapse;
  font-size: 0.88rem;
  margin-left: auto;
  min-width: 340px;
  width: 33%;
}

.liqaseg-receipt-totals td {
  border-bottom: 1px solid #e2e8f0;
  padding: 8px 12px;
}

.liqaseg-receipt-totals td:first-child {
  color: #475569;
  font-weight: 600;
  text-align: left;
}

.liqaseg-receipt-totals td:last-child {
  color: #1e293b;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}

.liqaseg-receipt-totals tr.rojo td {
  color: #c0392b;
}

.liqaseg-receipt-totals tr.total {
  background: #eafaf1;
  border-bottom: 2px solid #27ae60;
  border-top: 2px solid #27ae60;
}

.liqaseg-receipt-totals tr.total td {
  color: #27ae60;
  font-size: 1.05rem;
  font-weight: 700;
  padding: 10px 12px;
}

.liqaseg-receipt-signatures {
  color: #64748b;
  display: grid;
  font-size: 0.75rem;
  gap: 32px;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 40px;
  padding: 0 16px;
  text-align: center;
}

.liqaseg-receipt-signatures > div {
  min-width: 0;
}

.liqaseg-receipt-signatures span {
  border-top: 1px solid #94a3b8;
  display: block;
  overflow-wrap: anywhere;
  padding-top: 5px;
  text-transform: uppercase;
}

.liqaseg-receipt-footer {
  color: #999;
  font-size: 0.7rem;
  margin-top: 40px;
  text-align: center;
}

@media screen and (max-width: 1200px) {
  .liqaseg-receipt-bottom {
    flex-direction: column;
  }

  .liqaseg-receipt-nota,
  .liqaseg-receipt-totals {
    width: 100%;
  }
}

@media screen and (max-width: 760px) {
  .liq-body .liq-print-area {
    padding: 18px 14px;
  }

  .liqaseg-receipt-top {
    flex-direction: column;
  }

  .liqaseg-receipt-company {
    text-align: left;
  }

  .liqaseg-receipt-info {
    grid-template-columns: 38% 62%;
  }

  .liqaseg-receipt-signatures {
    grid-template-columns: 1fr;
  }
}

/* crudStyles convierte table, thead, tbody, tr, th y td en bloques de ancho completo por debajo de 768 px: aquí se restituye la tabla
   (solo en pantalla) y se deja desplazar a los lados, porque 12 columnas no caben en un teléfono. */
@media screen and (max-width: 768px) {
  .liq-body .liq-print-area {
    overflow-x: auto;
  }

  .liqaseg-receipt-table {
    display: table;
    min-width: 860px;
    width: 100%;
  }

  .liqaseg-receipt-table thead {
    display: table-header-group;
    width: auto;
  }

  .liqaseg-receipt-table tbody {
    display: table-row-group;
    width: auto;
  }

  .liqaseg-receipt-table tr {
    display: table-row;
    width: auto;
  }

  .liqaseg-receipt-table th,
  .liqaseg-receipt .liqaseg-receipt-table td {
    display: table-cell;
    width: auto;
  }

  /* Los totales conservan rótulo e importe en la misma línea. */
  .liqaseg-receipt-totals {
    display: table;
    min-width: 0;
    width: 100%;
  }

  .liqaseg-receipt-totals tbody {
    display: table-row-group;
    width: auto;
  }

  .liqaseg-receipt-totals tr {
    display: table-row;
    width: auto;
  }

  .liqaseg-receipt-totals td {
    display: table-cell;
    width: auto;
  }

  .liqaseg-receipt-totals td:first-child {
    white-space: normal;
  }
}

@media print {
  .liq-body .liq-print-content {
    border-radius: 0;
    box-shadow: none;
    height: auto;
    max-width: none;
    overflow: visible;
    width: 100%;
  }

  .liq-body .liq-print-area {
    flex: none;
    overflow: visible;
    padding: 0;
  }

  /* En papel los espacios se compactan para que el documento (y su pie) quepa en una hoja. */
  .liqaseg-receipt-top,
  .liqaseg-receipt-divider,
  .liqaseg-receipt-title {
    margin-bottom: 10px;
  }

  .liqaseg-receipt-info {
    font-size: 0.8rem;
    margin-bottom: 16px;
  }

  .liqaseg-receipt-info > div {
    padding: 6px 8px;
  }

  .liqaseg-receipt-table {
    font-size: 0.7rem;
    margin-bottom: 14px;
  }

  .liqaseg-receipt-table th {
    padding: 8px 4px;
  }

  .liqaseg-receipt .liqaseg-receipt-table td {
    padding: 6px 4px;
  }

  .liqaseg-receipt-signatures {
    margin-top: 28px;
  }

  .liqaseg-receipt-footer {
    break-inside: avoid;
    margin-top: 18px;
  }

  .liqaseg-receipt {
    max-width: none;
  }

  .liqaseg-receipt-table thead {
    display: table-header-group;
  }

  .liqaseg-receipt-table tr,
  .liqaseg-receipt-nota,
  .liqaseg-receipt-totals,
  .liqaseg-receipt-signatures {
    break-inside: avoid;
  }

  .liqaseg-receipt-table th,
  .liqaseg-receipt-table tbody tr:nth-child(even),
  .liqaseg-receipt-totals tr.total,
  .liqaseg-receipt-anulada,
  .liqaseg-receipt-info > div {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  @page {
    margin: 8mm;
    size: landscape;
  }
}

/* ----- Relación de cobros: vista de solo lectura que se abre desde Registro / Conciliación ----- */
/* Reutiliza el marcado y los estilos de Registro de Cobros (barra, tabla, totales, paginación); aquí solo lo propio. */
.liq-body .liq-context-header,
.liq-body .liq-context-actions {
  flex-wrap: wrap;
}

.liq-body .liq-relacion-header h2 {
  align-items: center;
  display: flex;
  gap: 10px;
}

.liq-body .liq-relacion-header h2 i {
  color: #256ee8;
}

/* Botón X de la esquina superior derecha: discreto y rojo al pasar el mouse. */
.liq-body .liq-relacion-cerrar {
  background: #fff;
  border: 1px solid #cbd5e1;
  color: #475569;
  flex: 0 0 36px;
  font-size: 24px;
  font-weight: 400;
  height: 36px;
  line-height: 1;
  padding: 0 0 2px;
  width: 36px;
}

.liq-body .liq-relacion-cerrar:hover {
  background: #fee2e2;
  border-color: #fecaca;
  color: #dc2626;
}

.liq-body .liq-relacion-cerrar:focus-visible {
  outline: 2px solid #347df5;
  outline-offset: 2px;
}

/* Filtros aplicados, como etiquetas: se ve de un vistazo qué se está relacionando. */
.liq-body .liq-relacion-filtros {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 18px;
}

.liq-body .liq-relacion-filtros:empty {
  display: none;
}

.liq-body .liq-chip {
  align-items: center;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  color: #17324d;
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
  max-width: 100%;
  padding: 4px 11px;
}

.liq-body .liq-chip-etiqueta {
  color: #64748b;
  font-weight: 600;
  white-space: nowrap;
}

.liq-body .liq-chip strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* La barra de herramientas de Registro de Cobros, dentro de la tarjeta. */
.liq-body .liq-relacion-toolbar {
  flex-wrap: wrap;
  margin: 10px 18px;
  width: auto;
}

.liq-body .liq-relacion-toolbar .facturas-toolbar-left {
  flex-wrap: wrap;
}

.liq-body .liq-relacion-wrap {
  border-top: 1px solid #e2e8f0;
}

.liq-body .liq-relacion-card .facturas-pagination {
  border-radius: 0 0 12px 12px;
}
