/* =============================================================================
   Reaplicación de Cobros — CSS propio y acotado, prefijo .rcb-
   =============================================================================
   Base: crudStyles.css + menu.css + las clases genéricas .facturas-* que ya
   usa toda la app (mismo patrón que control_reclamos.html / prima_x_aplicar).
   NO importa primaXAplicar.css a propósito — evita acoplar los dos módulos y
   evita que este archivo dependa de clases .pxa-* que podrían cambiar por
   razones ajenas a este módulo. Todo lo que sí se reutiliza visualmente de
   Prima x Aplicar (paleta, tipografía, densidad de tabla, totales) se
   reconstruye aquí con nombre propio.
   ============================================================================= */

.rcb-page { gap: 10px; }

.rcb-page > .rcb-tabs {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 2px;
  border-top: 1px solid #edf2f7;
  border-bottom: 1px solid #dbe5f1;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  scrollbar-width: thin;
}

.rcb-page > .rcb-tabs .nav-link {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 10px 18px;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.rcb-page > .rcb-tabs .nav-link.active { font-weight: 800; }

.rcb-page > .tab-content,
.rcb-page > .tab-content[hidden] { display: none !important; }

.rcb-page > #tab-lista.tab-content.active,
.rcb-page > #tab-aprobacion.tab-content.active,
.rcb-page > #tab-historial.tab-content.active {
  display: flex !important;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
}

.rcb-page > #tab-reaplicar.tab-content.active {
  display: block !important;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  margin: 0;
  padding: 0 4px 12px;
  border: 0;
  overflow: auto;
  box-sizing: border-box;
}

.rcb-page .facturas-toolbar { min-height: 48px; }

.rcb-workspace {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* En este módulo el host de filtros y el panel son el mismo <aside>. */
.rcb-page .facturas-filter-host.kre-filter-panel.filter-sidebar {
  width: 0;
  max-width: 320px;
  height: 100%;
  max-height: none;
  margin-left: -20px;
  opacity: 0;
  border: 1px solid #dbe5f0;
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: #fff;
  overflow: hidden;
  box-sizing: border-box;
  transition: width .4s cubic-bezier(.25, .8, .25, 1),
              margin-left .4s cubic-bezier(.25, .8, .25, 1),
              opacity .3s ease,
              border-width 0s linear .4s;
}

.rcb-page .facturas-filter-host.kre-filter-panel.filter-sidebar.open {
  width: 320px;
  margin-left: 0;
  opacity: 1;
  transition: width .4s cubic-bezier(.25, .8, .25, 1),
              margin-left .4s cubic-bezier(.25, .8, .25, 1),
              opacity .3s ease;
}

.rcb-page .facturas-filter-host.kre-filter-panel.filter-sidebar:not(.open) {
  border-width: 0;
  padding: 0;
}

.rcb-page .facturas-filter-host .sidebar-header {
  min-height: auto;
  padding: 12px;
}

.rcb-page .facturas-filter-host .sidebar-body {
  min-height: 0;
  overflow-y: auto;
}

.rcb-page .facturas-results-card,
.rcb-tab-results {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  height: auto;
}

.rcb-page .facturas-workspace.filters-collapsed .facturas-results-card {
  width: 100%;
  border-radius: 8px;
}

.rcb-page .facturas-table-wrap {
  flex: 1 1 0;
  min-height: 0;
  overflow: auto;
}

.rcb-page .pagination-container {
  min-height: 52px;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-top: 1px solid #e8eef5;
  background: #fff;
  box-sizing: border-box;
}

.rcb-nav-disabled {
  opacity: .46;
  cursor: not-allowed !important;
  pointer-events: none;
}

.rcb-placeholder {
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 3rem;
  color: #64748b;
  text-align: center;
}
.rcb-placeholder i { font-size: 2.2rem; color: #94a3b8; }

/* ---------------------------------------------------------------------
   Pestaña 1 — Lista de Cobros Aplicados
   --------------------------------------------------------------------- */
.rcb-grid-table {
  min-width: 1180px;
  table-layout: fixed;
}

.rcb-grid-table th:nth-child(1), .rcb-grid-table td:nth-child(1) { width: 6%; text-align: center; }
.rcb-grid-table th:nth-child(2), .rcb-grid-table td:nth-child(2) { width: 22%; }
.rcb-grid-table th:nth-child(3), .rcb-grid-table td:nth-child(3) { width: 23%; }
.rcb-grid-table th:nth-child(4), .rcb-grid-table td:nth-child(4) { width: 22%; }
.rcb-grid-table th:nth-child(5), .rcb-grid-table td:nth-child(5) { width: 19%; }
.rcb-grid-table th:nth-child(6), .rcb-grid-table td:nth-child(6) { width: 8%; text-align: center; }

.rcb-grid-table tbody td {
  min-width: 0;
  vertical-align: middle;
}

.rcb-payment-cell,
.rcb-chronology-cell,
.rcb-insured-cell,
.rcb-team-list {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  line-height: 1.25;
}

.rcb-payment-reference,
.rcb-payment-detail,
.rcb-insured-name,
.rcb-insurer-name {
  display: block;
  width: 100%;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.rcb-payment-reference { color: var(--primary-color); font-weight: 700; }
.rcb-payment-detail,
.rcb-insurer-name { color: #64748b; font-size: 11px; }
.rcb-insured-name { color: #17324d; font-weight: 700; }

/* Se reutiliza el botón absoluto de .facturas-table en crudStyles.css.
   No añade alto ni separaciones: cada wrapper sustituye al texto original. */
.rcb-page .rcb-action-trigger {
  display: block;
  min-width: 0;
  max-width: 100%;
  overflow: visible;
}

.rcb-page .rcb-action-label {
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: inherit;
}

.rcb-page .rcb-action-trigger:focus-within .floating-action-button {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

.rcb-page .rcb-grid-table tbody td:nth-child(2),
.rcb-page .rcb-grid-table tbody td:nth-child(4),
.rcb-page .rcb-approval-table tbody td:nth-child(2),
.rcb-page .rcb-approval-table tbody td:nth-child(4),
.rcb-page .rcb-history-table tbody td:nth-child(2),
.rcb-page .rcb-history-table tbody td:nth-child(4) { overflow: visible; }

.rcb-inline-pair {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: baseline;
  gap: 4px;
  width: 100%;
  min-width: 0;
  margin: 0;
}

.rcb-inline-pair .data-label,
.rcb-chronology-request .data-label {
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
}

.rcb-inline-pair .data-value,
.rcb-chronology-request .data-value {
  min-width: 0;
  max-width: none;
  margin: 0;
  overflow: visible;
  color: #17324d;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.25;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}

.rcb-chronology-cell .rcb-inline-pair .data-value { white-space: nowrap; }
.rcb-chronology-cell > .rcb-inline-pair { grid-template-columns: 42px minmax(0, 1fr); }

.rcb-chronology-request {
  display: grid;
  grid-template-columns: max-content max-content max-content max-content minmax(0, 1fr);
  align-items: baseline;
  gap: 4px;
  width: 100%;
  min-width: 0;
}

.rcb-pair-separator { color: #94a3b8; font-size: 10px; }
.rcb-amount-pair { margin-top: 2px; }
.rcb-amount-pair .data-label { text-transform: uppercase; }
.rcb-amount-pair .data-value { font-size: 12px; }

.rcb-team-list .data-label {
  color: #17324d;
  font-weight: 700;
}

.rcb-team-list .rcb-inline-pair { grid-template-columns: 28px minmax(0, 1fr); }

.rcb-team-list .data-value {
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.rcb-estado-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
  margin-top: 2px;
}
.rcb-estado-badge.disponible { background: #10b981; }
.rcb-estado-badge.pendiente { background: #94a3b8; }
.rcb-estado-badge.aprobado { background: #19a966; }

.rcb-age-badge {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  padding: 3px 7px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #f8fafc;
  color: #334155;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.rcb-age-badge.urgente {
  color: #b91c1c;
  border-color: #f5c6cb;
  background: #fdf0f0;
}

.rcb-monto-monospace {
  font-family: 'Consolas', monospace;
  font-weight: 700;
}

.rcb-btn-accion {
  padding: 0.4rem 0.8rem;
  border-radius: 0.3rem;
  font-weight: 700;
  font-size: 0.82rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  cursor: pointer;
  color: #fff;
  white-space: nowrap;
  transition: filter .15s, transform .15s;
}
.rcb-btn-accion:hover:not(:disabled) { filter: brightness(1.08); }
.rcb-btn-accion.solicitar { background: var(--warning-color, #f39c12); }
.rcb-btn-accion.reaplicar { background: var(--success-color, #19a966); }
.rcb-btn-accion.pendiente {
  background: #95a5a6;
  cursor: not-allowed;
  opacity: .85;
}

/* ---------------------------------------------------------------------
   Pestaña 2 — Solicitud / Ejecución
   --------------------------------------------------------------------- */
.rcb-application-card {
  display: block;
  width: min(1400px, calc(100% - 36px));
  max-width: 1400px;
  margin: 14px auto;
  padding: 28px 40px 34px;
  overflow: visible;
  box-sizing: border-box;
}

.rcb-application-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 34px;
  padding-bottom: 10px;
  border-bottom: 2px solid #eee;
  color: #17324d;
  font-size: 23px;
  line-height: 1.2;
}
.rcb-application-title > i { color: var(--warning-color, #f39c12); }

#rcbFormularioPrincipal { display: flex; flex-direction: column; gap: 20px; }

.rcb-context-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 28px;
  margin: 0;
  padding: 17px 20px;
  border: 1px solid #dbe2ea;
  border-radius: 8px;
  background: #fbfcfd;
}
.rcb-context-grid .data-pill {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.rcb-context-grid .data-pill .label {
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
}
.rcb-context-grid .data-pill .value {
  overflow-wrap: anywhere;
  color: #17324d;
  font-size: 16px;
  font-weight: 800;
}
.rcb-monto-inalterable { color: var(--success-color, #27ae60) !important; }

.rcb-clean-section {
  margin: 0;
  padding: 22px 20px 20px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
}
.rcb-form-section h4 {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin: 0 0 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e5e7eb;
  color: #278fe3;
  font-size: 16px;
}
.rcb-clean-section .form-group { margin: 0; }
.rcb-clean-section .form-label {
  display: block;
  margin: 0 0 7px;
  color: #27384a;
  font-size: 14px;
}
.rcb-clean-section .form-control {
  width: 100%;
  min-height: 40px;
  margin: 0;
  padding: 9px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #fff;
  color: #263442;
  font: inherit;
  box-sizing: border-box;
}
.rcb-clean-section textarea.form-control {
  min-height: 80px;
  resize: vertical;
}
.rcb-clean-section .form-control:focus {
  border-color: var(--primary-color, #347df5);
  outline: 2px solid rgba(52, 125, 245, .14);
  outline-offset: 0;
}
.rcb-clean-section .form-control[readonly] { background: #f1f5f9; color: #475569; }

.rcb-form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.rcb-main-form-actions {
  justify-content: flex-end;
  margin-top: 0;
  padding-top: 20px;
  border-top: 1px solid #e5e7eb;
}
.rcb-submit-request-btn {
  border-color: var(--warning-color, #f39c12) !important;
  background: var(--warning-color, #f39c12) !important;
  color: #fff !important;
}

.rcb-distribution-lead {
  margin: 0 0 18px;
  color: #64748b;
  font-size: 13px;
  line-height: 1.45;
}
.rcb-current-distribution {
  margin-bottom: 18px;
  border: 1px solid #dbe5f0;
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
}
.rcb-current-distribution summary {
  padding: 11px 13px;
  background: #f8fafc;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}
.rcb-current-distribution[open] summary { border-bottom: 1px solid #dbe5f0; }
.rcb-current-distribution .rcb-application-table-wrap { border: 0; border-radius: 0; }
.rcb-form-help {
  display: flex;
  align-items: flex-start;
  gap: .4rem;
  color: #64748b;
  font-size: .85rem;
  margin: -.4rem 0 .8rem;
}

.rcb-required { color: #dc2626; font-size: 14px; font-weight: 900; }

.rcb-application-table-wrap { max-height: 320px; overflow: auto; border: 1px solid var(--border-color); border-radius: 6px; }
.rcb-application-table { width: 100%; min-width: 1040px; }
.rcb-application-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--primary-color);
  color: #fff;
}
/* .facturas-table (clase base, compartida por toda la app) trunca con "…"
   cualquier th/td más ancho de 220px (crudStyles.css) — pensado para celdas
   cortas típicas, pero corta títulos como "Balance pendiente"/"Monto a
   aplicar"/"Saldo después" en esta tabla de 9 columnas. Como esta tabla ya
   tiene su propio wrapper con scroll horizontal y un min-width generoso,
   se deja que el contenido respire — nada se recorta, el scroll (si hace
   falta) lo resuelve el wrapper, no el ellipsis. */
.rcb-application-table th,
.rcb-application-table td {
  max-width: none;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: break-word;
}
/* Los valores numéricos/fecha se ven mejor en una sola línea siempre (nunca
   son largos) — solo estas columnas mantienen nowrap. */
.rcb-application-table td[style*="text-align:right"] { white-space: nowrap; }
.rcb-application-table tbody td { vertical-align: middle; }
/* #tblRcbFacturasDestino tiene 9 columnas y, sin anchos explícitos,
   table-layout:auto le dio muy poco espacio a "Monto a aplicar" (su título
   quedaba recortado aunque overflow ya esté en visible arriba — el texto
   simplemente no cabía en la caja). table-layout:fixed + porcentajes fijos
   garantiza que cada columna tenga sitio de sobra siempre. */
#tblRcbFacturasDestino.rcb-application-table { table-layout: fixed; }
#tblRcbFacturasDestino th:nth-child(1), #tblRcbFacturasDestino td:nth-child(1) { width: 4%; }
#tblRcbFacturasDestino th:nth-child(2), #tblRcbFacturasDestino td:nth-child(2) { width: 12%; }
#tblRcbFacturasDestino th:nth-child(3), #tblRcbFacturasDestino td:nth-child(3) { width: 12%; }
#tblRcbFacturasDestino th:nth-child(4), #tblRcbFacturasDestino td:nth-child(4) { width: 11%; }
#tblRcbFacturasDestino th:nth-child(5), #tblRcbFacturasDestino td:nth-child(5) { width: 9%; }
#tblRcbFacturasDestino th:nth-child(6), #tblRcbFacturasDestino td:nth-child(6) { width: 8%; }
#tblRcbFacturasDestino th:nth-child(7), #tblRcbFacturasDestino td:nth-child(7) { width: 14%; }
#tblRcbFacturasDestino th:nth-child(8), #tblRcbFacturasDestino td:nth-child(8) { width: 16%; }
#tblRcbFacturasDestino th:nth-child(9), #tblRcbFacturasDestino td:nth-child(9) { width: 14%; }
.rcb-application-table input[type="number"] {
  width: 100%;
  box-sizing: border-box;
  padding: 4px 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  text-align: right;
  font-family: 'Consolas', monospace;
}
.rcb-application-table tr.rcb-fila-seleccionada { background: #ecfdf5; }
.rcb-application-table tr.rcb-fila-excedida input[type="number"] { border-color: #dc2626; background: #fdf0f0; }

.rcb-resumen-panel {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  background: #f8fafc;
}
.rcb-resumen-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: .75rem 1.5rem;
}
.rcb-resumen-item { display: flex; flex-direction: column; gap: 2px; }
.rcb-resumen-item .lbl { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: #64748b; font-weight: 700; }
.rcb-resumen-item .val { font-family: 'Consolas', monospace; font-size: 1.05rem; font-weight: 800; color: #17324d; }

.rcb-resumen-indicador {
  margin-top: .85rem;
  padding: .6rem .85rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: .88rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.rcb-resumen-indicador.ok { background: #ecfdf5; color: #047857; border: 1px solid #19a966; }
.rcb-resumen-indicador.pendiente { background: #eef2f7; color: #475569; border: 1px solid #cbd5e1; }
.rcb-resumen-indicador.error { background: #fdf0f0; color: #b91c1c; border: 1px solid #f5c6cb; }

.rcb-secondary-btn { background: #fff; color: #555; border: 1px solid #ccc; }
.rcb-secondary-btn:hover { background: #f4f4f4; }

/* ---------------------------------------------------------------------
   Pestaña 3 — Aprobación Gerencial
   --------------------------------------------------------------------- */
.rcb-approval-table {
  width: 100%;
  min-width: 1450px;
  table-layout: fixed;
}

.rcb-approval-table th, .rcb-approval-table td {
  padding: 10px 14px;
}
.rcb-approval-table th:nth-child(1), .rcb-approval-table td:nth-child(1) { width: 6%; text-align: center; }
.rcb-approval-table th:nth-child(2), .rcb-approval-table td:nth-child(2) { width: 22%; }
.rcb-approval-table th:nth-child(3), .rcb-approval-table td:nth-child(3) { width: 23%; }
.rcb-approval-table th:nth-child(4), .rcb-approval-table td:nth-child(4) { width: 19%; }
.rcb-approval-table th:nth-child(5), .rcb-approval-table td:nth-child(5) { width: 14%; }
.rcb-approval-table th:nth-child(6), .rcb-approval-table td:nth-child(6) { width: 230px; text-align: center; }

.rcb-approval-table tbody td {
  min-width: 0;
  vertical-align: middle;
}

.rcb-currency-cell {
  color: #555;
  font-weight: 700;
}

.rcb-approval-document-cell,
.rcb-approval-chronology-cell,
.rcb-approval-insured-cell,
.rcb-approval-team-list {
  min-width: 0;
}

.rcb-approval-document-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  line-height: 1.25;
}

.rcb-approval-document-cell .rcb-document-cobro {
  grid-template-columns: max-content minmax(0, 1fr);
}

.rcb-approval-chronology-cell .rcb-inline-pair .data-value,
.rcb-approval-chronology-cell .rcb-chronology-request > .data-value:first-of-type {
  white-space: nowrap;
}

.rcb-approval-team-list .data-value,
.rcb-approval-document-cell .data-value {
  overflow-wrap: anywhere;
}

.rcb-manager-action-cell { text-align: center; }

.rcb-manager-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: nowrap;
  width: 100%;
  min-width: 0;
}

.rcb-manager-btn {
  flex: 0 0 auto;
  padding: .35rem .65rem;
  font-size: .78rem;
  white-space: nowrap;
}

.rcb-manager-waiting {
  max-width: 100%;
  justify-content: center;
  margin-inline: auto;
  text-align: center;
  white-space: normal;
}

.rcb-balance-box {
  min-width: 110px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid #19a966;
  border-radius: 6px;
  background: #ecfdf5;
  color: #047857;
  text-align: center;
  box-sizing: border-box;
}
.rcb-balance-box .lbl { margin-bottom: 2px; color: #059669; font-size: 10px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.rcb-balance-box .val { color: #047857; font-family: Consolas, monospace; font-size: 14px; font-weight: 800; }

/* ---------------------------------------------------------------------
   Pestaña 4 — Historial / Trazabilidad
   --------------------------------------------------------------------- */
.rcb-history-table {
  width: 100%;
  min-width: 1400px;
  table-layout: fixed;
}

.rcb-history-table th,
.rcb-history-table td { padding: 10px 14px; }

.rcb-history-table th:nth-child(1), .rcb-history-table td:nth-child(1) { width: 6%; text-align: center; }
.rcb-history-table th:nth-child(2), .rcb-history-table td:nth-child(2) { width: 22%; }
.rcb-history-table th:nth-child(3), .rcb-history-table td:nth-child(3) { width: 23%; }
.rcb-history-table th:nth-child(4), .rcb-history-table td:nth-child(4) { width: 21%; }
.rcb-history-table th:nth-child(5), .rcb-history-table td:nth-child(5) { width: 16%; }
.rcb-history-table th:nth-child(6), .rcb-history-table td:nth-child(6) { width: 160px; text-align: center; }

.rcb-history-table tbody td {
  min-width: 0;
  vertical-align: middle;
}

.rcb-history-table .rcb-currency-cell.usd { color: #07883f; }

.rcb-history-document-cell,
.rcb-history-chronology-cell,
.rcb-history-insured-cell,
.rcb-history-team-list { min-width: 0; }

.rcb-history-document-cell .rcb-document-cobro {
  grid-template-columns: max-content minmax(0, 1fr);
}

.rcb-history-chronology-cell .rcb-inline-pair .data-value,
.rcb-history-resolution-row .data-value { white-space: nowrap; }

.rcb-history-resolution-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  flex-wrap: wrap;
}

.rcb-history-resolution-row .rcb-inline-pair { width: auto; }

.rcb-history-team-list .data-value,
.rcb-history-document-cell .data-value { overflow-wrap: anywhere; }

.rcb-history-status-cell { text-align: center; }

.rcb-history-status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  max-width: 100%;
  padding: 5px 11px;
  border-radius: 999px;
  color: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.rcb-history-status-badge.reasentado { background: #19a966; }
.rcb-history-status-badge.rechazado { background: #dc3545; }

/* Resalta por un momento la fila que se acaba de ejecutar, para que el
   usuario la reconozca de inmediato en la tabla (se agrega/quita la clase
   desde JS — ver resaltarFilaHistorial). */
@keyframes rcbDestelloFilaHistorial {
  0%   { background-color: #d1fae5; }
  100% { background-color: transparent; }
}
#rcbHistBody tr.rcb-fila-recien-ejecutada {
  animation: rcbDestelloFilaHistorial 3.2s ease-out;
  box-shadow: inset 3px 0 0 var(--success-color, #27ae60);
}

/* El pie de esta tabla (totales por moneda) usa las MISMAS reglas
   compartidas de crudStyles.css que ya usa Lista de Saldos de Prima x
   Aplicar (.facturas-table tfoot td / tfoot tr.facturas-total-usd td) —
   sin ninguna regla propia — para que el negro del total en pesos y el
   verde del total en dólares salgan pixel-idénticos entre ambos módulos. */

/* ---------------------------------------------------------------------
   Modales de detalle (Aprobación / Historial forense)
   --------------------------------------------------------------------- */
.rcb-modal-detalle { max-width: 720px; }
/* 2026-09-04: agrandado bastante mas alla de un ancho comodo tipico de
   modal (820px) a pedido explicito del usuario — informacion financiera
   delicada (que se aprueba/rechaza con dinero real de por medio) debe
   leerse grande y claro, no entrecerrando los ojos. Todo el contenido de
   abajo escala junto con este ancho. */
.rcb-modal-resolver { max-width: 1180px; }
#rcbResolverTitulo {
  font-size: 1.55rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Franja de identidad — lo mínimo para confirmar de un vistazo QUÉ se está
   aprobando/rechazando (cobro, cliente, aseguradora, monto), agrupado en
   una tarjeta propia para separarlo visualmente del resto del modal. */
.rcb-resolver-identidad {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem 1.5rem;
  margin: 1.1rem 0 0;
  padding: 1.15rem 1.4rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}
.rcb-resolver-id-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.rcb-resolver-id-item .data-label {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .02em;
}
.rcb-resolver-id-item .data-value {
  color: #17324d;
  font-size: 1.2rem;
  font-weight: 600;
  max-width: none;
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  overflow-wrap: anywhere;
}
.rcb-resolver-id-monto .data-value {
  color: var(--primary-color);
  font-size: 1.5rem;
  font-weight: 800;
}

/* Datos secundarios (referencia, solicitante, fecha) — presentes pero sin
   competir visualmente con la identidad principal ni con la comparación. */
.rcb-resolver-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem 1.5rem;
  margin: .9rem 0 0;
  padding: 0 .1rem;
}
.rcb-resolver-meta-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  font-size: 1rem;
}
.rcb-resolver-meta-item .data-label {
  color: #94a3b8;
  font-weight: 600;
  white-space: nowrap;
}
.rcb-resolver-meta-item .data-value {
  color: #475569;
  max-width: none;
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  overflow-wrap: anywhere;
}

.rcb-resolver-section-label {
  display: block;
  margin: 1.6rem 0 .7rem;
  color: var(--primary-color);
  font-size: 1.05rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.rcb-resolver-section-label i { margin-right: 7px; }

.rcb-resolver-motivo {
  margin: 1.3rem 0 0;
  padding: 1.1rem 1.3rem;
  background: #fffbea;
  border: 1px solid #f5e3a3;
  border-left: 5px solid #d4a017;
  border-radius: 10px;
}
.rcb-resolver-motivo .rcb-resolver-section-label { margin: 0 0 .4rem; color: #8a6d1a; }
.rcb-resolver-motivo p {
  margin: 0;
  color: #333;
  font-size: 1.12rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.rcb-modal-distribuciones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.3rem;
  margin-bottom: 1.3rem;
}
.rcb-resolver-dist-heading { margin-bottom: .8rem; }

.rcb-dist-col {
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}
.rcb-dist-col h4 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: .7rem .9rem;
  font-size: 1.05rem;
  line-height: 1.3;
}
.rcb-dist-original h4 { background: #fdf0f0; color: #a12631; }
.rcb-dist-propuesta h4 { background: #eafaf1; color: #157347; }
.rcb-dist-tag {
  margin-left: auto;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.65);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .02em;
  white-space: nowrap;
}

.rcb-modal-mini-table-wrap {
  max-width: 100%;
  overflow-x: auto;
}

.rcb-modal-mini-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 1.02rem;
}
/* crudStyles.css (global, compartido por toda la app) trae, dentro de
   @media(max-width:768px): "table, thead, tbody, th, td, tr { display:
   table; width:100% }" — pensada para OTRO módulo, pero por ser un
   selector de etiqueta desnuda alcanza a CUALQUIER tabla del sitio,
   incluida esta. El efecto en celda: th/td pasan a comportarse como
   display:table (un contenedor de bloque independiente) en vez de
   table-cell, así que las 3 columnas dejan de alinearse lado a lado y el
   texto de una columna se dibuja encima de la siguiente. Nunca toco ese
   CSS compartido (afectaría otras páginas) — en su lugar reafirmo aquí,
   con selector de clase (más específico que la etiqueta desnuda, gana sin
   necesitar !important), los roles reales de tabla para que esta tabla se
   vea igual en cualquier ancho de pantalla. */
.rcb-modal-mini-table { display: table; }
.rcb-modal-mini-table thead { display: table-header-group; }
.rcb-modal-mini-table tbody { display: table-row-group; }
.rcb-modal-mini-table tr { display: table-row; }
.rcb-modal-mini-table th,
.rcb-modal-mini-table td { display: table-cell; }
/* table-layout:fixed reparte el ancho por columna según estos porcentajes,
   sin importar qué tan largo sea el contenido — así una factura o póliza
   con un nombre inusualmente largo se AJUSTA (overflow-wrap) dentro de su
   columna en vez de estirar la tabla o forzar scroll horizontal. */
.rcb-modal-mini-table th:nth-child(1),
.rcb-modal-mini-table td:nth-child(1) { width: 38%; }
.rcb-modal-mini-table th:nth-child(2),
.rcb-modal-mini-table td:nth-child(2) { width: 38%; }
.rcb-modal-mini-table th:nth-child(3),
.rcb-modal-mini-table td:nth-child(3) { width: 24%; }
/* crudStyles.css (global, compartido por toda la app) trae, SIN media
   query, dos reglas de etiqueta desnuda que alcanzan cualquier tabla del
   sitio: "th, td { white-space:nowrap; overflow:hidden; text-overflow:
   ellipsis; max-width:220px; text-align:center; ... }" y, más fuerte
   todavía sobre la 2da columna, "tbody td:nth-child(2) { white-space:
   nowrap; overflow:hidden; text-overflow:ellipsis; text-align:center; }".
   Es el MISMO problema, ya diagnosticado y resuelto antes en esta misma
   hoja para .rnc-notes-table (ver ese bloque): una factura/póliza con
   nombre largo no se ajustaba, se recortaba con "…" o se montaba sobre la
   columna vecina. Nunca se tocan esas reglas globales (afectaría el resto
   del sistema) — se sobrescriben aquí, con más especificidad. */
.rcb-modal-mini-table th,
.rcb-modal-mini-table td,
.rcb-modal-mini-table tbody td:nth-child(2) {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  max-width: none;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.rcb-modal-mini-table th {
  background: #f8fafc;
  color: #334155;
  text-align: left;
  padding: 10px 14px;
  font-size: .92rem;
  border-bottom: 2px solid var(--border-color);
}
.rcb-modal-mini-table td,
.rcb-modal-mini-table tbody td:nth-child(2) {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
}
.rcb-modal-mini-table th.rcb-col-monto,
.rcb-modal-mini-table td.rcb-col-monto,
.rcb-modal-mini-table tbody td.rcb-col-monto:nth-child(3) {
  text-align: right;
}
.rcb-modal-mini-table td.rcb-mini-table-vacia {
  text-align: center;
  color: #94a3b8;
  font-style: italic;
}

/* Botones de este modal en particular, un poco más grandes para hacer
   juego con el resto del contenido agrandado (sin tocar .facturas-btn
   global, que usan decenas de otras pantallas). */
.rcb-modal-resolver .form-actions .facturas-btn {
  padding: 11px 20px;
  font-size: 14px;
}

.rcb-resolver-observacion { margin-top: 1.4rem; }
.rcb-resolver-observacion .form-label { font-size: 1.02rem; }
.rcb-resolver-observacion textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1.02rem;
  resize: vertical;
}

.rcb-forense-seccion { margin-bottom: 1.1rem; }
.rcb-forense-seccion h4 { margin: 0 0 .4rem; color: var(--primary-color); font-size: .92rem; }
.rcb-forense-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: .4rem 1.5rem;
}

/* ---------------------------------------------------------------------
   Responsive — mismo comportamiento que Prima x Aplicar: al ocultar
   filtros la tabla se expande; en pantallas angostas el grid de contexto
   y el resumen matemático colapsan a una columna.
   --------------------------------------------------------------------- */
@media (max-width: 900px) {
  .rcb-context-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rcb-resumen-grid { grid-template-columns: 1fr 1fr; }
  .rcb-modal-distribuciones { grid-template-columns: 1fr; }
  .rcb-resolver-identidad { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rcb-resolver-meta { grid-template-columns: 1fr; }
}

@media (max-width: 1200px) {
  .rcb-body { overflow: auto; }
  .rcb-body #main-content { height: auto; min-height: 100vh; overflow: visible; }
  .rcb-page > #tab-lista.tab-content.active,
  .rcb-page > #tab-aprobacion.tab-content.active,
  .rcb-page > #tab-historial.tab-content.active { overflow: visible; }
  .rcb-workspace { flex-direction: column; overflow: visible; }
  .rcb-page .facturas-filter-host.kre-filter-panel.filter-sidebar {
    width: 100%;
    max-width: none;
    height: auto;
    max-height: 0;
    margin-left: 0;
    border-right: 1px solid #dbe5f0;
    border-radius: 8px 8px 0 0;
    transition: max-height .4s cubic-bezier(.25, .8, .25, 1), opacity .3s ease, border-width 0s linear .4s;
  }
  .rcb-page .facturas-filter-host.kre-filter-panel.filter-sidebar.open {
    width: 100%;
    max-height: 3000px;
    transition: max-height .4s cubic-bezier(.25, .8, .25, 1), opacity .3s ease;
  }
  .rcb-page .facturas-results-card { min-height: 520px; border-radius: 0 0 8px 8px; }
}

@media (max-width: 760px) {
  .rcb-page > .rcb-tabs .nav-link { min-height: 40px; padding: 8px 12px; }
  .rcb-page .facturas-toolbar,
  .rcb-page .pagination-container { flex-direction: column; align-items: stretch; }
  .rcb-page .facturas-toolbar-left,
  .rcb-page .facturas-toolbar-right { width: 100%; flex-wrap: wrap; }
  .rcb-page .facturas-toolbar-right .facturas-btn { flex: 1 1 0; }
  .rcb-page .facturas-quick-search { min-width: 0; width: 100%; max-width: none; }
  .rcb-page .pagination-controls { justify-content: center; flex-wrap: wrap; }
  .rcb-application-card { width: 100%; margin: 0; padding: 16px !important; }
  .rcb-application-title { margin-bottom: 20px; font-size: 19px; flex-wrap: wrap; }
  .rcb-context-grid { grid-template-columns: 1fr; gap: 12px; }
  .rcb-clean-section { padding: 16px 14px; }
  .rcb-clean-section h4 { font-size: 14px; }
  .rcb-main-form-actions .facturas-btn { flex: 1 1 100%; justify-content: center; }
}
