/* =====================================================================
 * DFX UI 1.0 - CSS comun del framework.
 *
 * Clases de utilidad mobile-first pensadas para reusarse en cualquier
 * CRUD (Productos, y en el futuro Clientes/Proveedores/etc.), no solo
 * en la pantalla donde se escribieron por primera vez. No requieren
 * JS adicional -- son puramente CSS, compatibles con data-dfx-source/
 * Collection/render incremental de dfx-ui.js sin ningun cambio ahi.
 * ===================================================================== */

/* Sin esto, Chrome/Windows con tema oscuro del sistema pinta los
 * controles nativos (el listbox emergente de <select>, calendario de
 * <input type=date>, etc.) con su paleta oscura aunque la pagina sea
 * clara -- eso es el "destello negro" al abrir un combo. Declarar el
 * esquema de color de la pagina evita que el navegador improvise. */
:root { color-scheme: light; }

/* REQUIRED reactivo (ver applyRequired() en dfx-ui.js) marca el control
 * invalido con data-dfx-invalid="true" recien cuando el campo fue tocado
 * o se intento enviar -- nunca en una carga de pagina en blanco. Es el
 * unico lugar que pinta el borde rojo: el JS no toca estilos inline. */
.form-control[data-dfx-invalid="true"] {
  border-color: var(--bs-danger, #dc3545);
}
.form-control[data-dfx-invalid="true"]:focus {
  border-color: var(--bs-danger, #dc3545);
  box-shadow: 0 0 0 .25rem rgba(220, 53, 69, .25);
}

/* ---------------------------------------------------------------------
 * Paleta de un CRUD administrativo (cabecera con degrade, panel/toolbar,
 * cabecera de tabla con tinte azul, codigo como "chip"). Valores tomados
 * exactos de la referencia visual del usuario (catalogodemo.dfx /
 * styles.css) -- mismos nombres de clase para que coincida pixel a
 * pixel, reusable por cualquier CRUD futuro. Solo presentacion, ningun
 * componente JS nuevo.
 * --------------------------------------------------------------------- */
.erp-page-head {
  min-height: 54px;
  padding: 14px 16px;
  border: 1px solid #d7e2ea;
  border-radius: 8px;
  background: #f4f7fa;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}
.erp-invoice {
  max-width: 1220px;
  margin-right: auto;
  margin-left: auto;
}
.erp-page-head.card {
  overflow: hidden;
  padding: 0;
  border-radius: 8px;
  background: #ffffff;
}
.erp-page-head > .card-header {
  padding: 1.25rem 1.35rem;
  border-bottom: 1px solid #d7e2ea;
  background: #f4f7fa;
}
.erp-page-head > .card-body {
  padding: 1.25rem 1.35rem;
  background: #ffffff;
}
.erp-page-head .form-label { margin-bottom: 0.35rem; }
.erp-page-head .row.g-3 { align-items: end; }
.erp-page-head .form-control,
.erp-page-head .form-select,
.erp-page-head .form-control[readonly],
.erp-page-head .form-control:disabled,
.erp-panel .form-control,
.erp-panel .form-select,
.erp-panel .form-control[readonly],
.erp-panel .form-control:disabled {
  background-color: #ffffff !important;
}
.erp-page-head h1,
.erp-page-head .fw-semibold,
.erp-page-head .btn { color: #172033; }
.erp-page-head .btn-primary {
  background: #3867d6;
  border-color: #3867d6;
  color: #ffffff;
}
.erp-page-head .btn-primary:hover {
  background: #2f56b3;
  border-color: #2f56b3;
  color: #ffffff;
}
.erp-context-panel {
  background: #fbfcfe;
  border-color: #d7e2ea !important;
}
.erp-page-head .input-group-text {
  background-color: #ffffff !important;
}
.erp-context-panel .dfx-context-value {
  color: #172033;
  font-weight: 600;
}

.erp-stat {
  height: 38px;
  min-width: 108px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: #ffffff;
  border: 1px solid #d8dee6;
  border-radius: 6px;
  font-size: 0.875rem;
}

.erp-panel,
.erp-toolbar {
  border-color: #d8dee6 !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.erp-panel.card { overflow: visible; }
.erp-panel-head { background: #f7fafc; }
.erp-panel-head > .dfx-buscar {
  flex: 1 1 560px;
  min-width: 320px;
}
.erp-summary {
  max-width: 430px;
  margin-left: auto;
  padding: 0.75rem 1rem;
}
.erp-summary .border-bottom { border-color: #e4ebf1 !important; }
.erp-summary .h4 { color: #2563eb; font-weight: 700; }
#detalleWorkspace thead.table-light,
#detalleWorkspace thead.table-light th {
  background: #eaf2f8 !important;
}
#detalleWorkspace thead th {
  color: #172033;
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  border-bottom: 1px solid #c9d8e4;
}
#detalleWorkspace tbody td {
  padding-top: 0.62rem;
  padding-bottom: 0.62rem;
  border-color: #edf0f3;
}
#detalleWorkspace th:last-child,
#detalleWorkspace td:last-child {
  width: 54px;
  min-width: 54px;
  text-align: center;
}
#detalleWorkspace td:last-child .btn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  line-height: 1;
  color: transparent !important;
  text-indent: -9999px;
}
#detalleWorkspace td:last-child .btn::before {
  content: "\01F5D1";
  font-size: 16px;
  line-height: 1;
  color: var(--bs-danger, #dc3545);
  text-indent: 0;
}

.erp-table thead.table-light,
.erp-table thead.table-light th {
  background: #eaf2f8 !important;
}
.erp-table thead th {
  color: #172033;
  font-weight: 700;
  font-size: 0.76rem;
  text-transform: uppercase;
  border-bottom: 1px solid #c9d8e4;
}
.erp-table tbody td {
  background: #ffffff;
  padding-top: 0.62rem;
  padding-bottom: 0.62rem;
  border-color: #edf0f3;
}
.erp-table tbody,
.erp-table tbody tr,
.erp-table tbody td {
  background-color: #ffffff !important;
}
.erp-table tbody tr:hover { background: #f8fafc; }

/* The generated document-detail grid uses legacy ERP table styling above,
   including explicit light surfaces. Scope dark-theme corrections only to
   that generated component so light mode and unrelated ERP tables stay intact. */
html.dfx-theme-dark .dw-document-detail-grid.erp-table {
  --bs-table-color: var(--dfx-text);
  --bs-table-bg: var(--dfx-surface);
  --bs-table-border-color: var(--dfx-border);
  --bs-table-hover-color: var(--dfx-text);
  --bs-table-hover-bg: var(--dfx-surface-soft);
  color: var(--dfx-text);
  border-color: var(--dfx-border);
}

html.dfx-theme-dark .dw-document-detail-grid.erp-table thead.table-light,
html.dfx-theme-dark .dw-document-detail-grid.erp-table thead.table-light th {
  background: var(--dfx-surface-raised) !important;
  color: var(--dfx-text);
  border-color: var(--dfx-border);
}

html.dfx-theme-dark .dw-document-detail-grid.erp-table tbody,
html.dfx-theme-dark .dw-document-detail-grid.erp-table tbody tr,
html.dfx-theme-dark .dw-document-detail-grid.erp-table tbody tr > td {
  background-color: var(--dfx-surface) !important;
  color: var(--dfx-text);
  border-color: var(--dfx-border) !important;
}

html.dfx-theme-dark .dw-document-detail-grid.erp-table tbody tr:hover,
html.dfx-theme-dark .dw-document-detail-grid.erp-table tbody tr:hover > td {
  --bs-table-bg-state: var(--dfx-surface-soft);
  --bs-table-color-state: var(--dfx-text);
  background-color: var(--dfx-surface-soft) !important;
  color: var(--dfx-text);
}

html.dfx-theme-dark .dw-document-detail-grid.erp-table .form-control {
  border-color: var(--dfx-border);
  background-color: var(--dfx-surface-soft);
  color: var(--dfx-text);
}

html.dfx-theme-dark .dw-document-detail-grid.erp-table .input-group-text {
  border-color: var(--dfx-border);
  background-color: var(--dfx-surface-raised);
  color: var(--dfx-text);
}

html.dfx-theme-dark .dw-document-detail-grid.erp-table .btn-outline-secondary {
  --bs-btn-color: var(--dfx-muted);
  --bs-btn-border-color: var(--dfx-border);
  --bs-btn-hover-color: var(--dfx-text);
  --bs-btn-hover-bg: var(--dfx-surface-raised);
  --bs-btn-hover-border-color: var(--dfx-border);
  --bs-btn-active-color: var(--dfx-text);
  --bs-btn-active-bg: var(--dfx-surface-raised);
  --bs-btn-active-border-color: var(--dfx-border);
}

.erp-table [data-dfx-spinner] {
  display: inline-flex;
  width: 9.5rem;
  max-width: 100%;
  margin-inline: auto;
}
.erp-table [data-dfx-spinner] > .btn {
  flex: 0 0 2rem;
}
.erp-table [data-dfx-spinner] > .form-control {
  min-width: 0;
}

.erp-code {
  display: inline-block;
  min-width: 72px;
  padding: 2px 7px;
  border: 1px solid #d8dee6;
  border-radius: 5px;
  background: #f7f9fb;
  color: #172033;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}

/* Resultados del buscador reutilizable: el popup conserva la lectura de
 * la referencia de factura sin imponer markup adicional al programador. */
.dfx-buscar { position: relative; }
.dfx-lookup-results {
  position: absolute;
  z-index: 1050;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  min-width: min(520px, calc(100vw - 2rem));
  overflow: hidden;
  border: 1px solid #c9d8e4;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.14);
}
.dfx-lookup-row {
  display: flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
}
.dfx-lookup-header {
  min-height: 30px;
  background: #eaf2f8;
  border-bottom: 1px solid #c9d8e4;
  color: #172033;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}
.dfx-lookup-option {
  padding: 0;
  border: 0;
  border-bottom: 1px solid #edf0f3;
  background: #ffffff;
  color: #172033;
  text-align: left;
}
.dfx-lookup-option:last-child { border-bottom: 0; }
.dfx-lookup-option:hover,
.dfx-lookup-option:focus,
.dfx-lookup-option.active,
.dfx-lookup-option[data-dfx-active="true"] {
  background: #cfe2ff !important;
  color: #102a43 !important;
  outline: 0;
}
.dfx-lookup-cell {
  min-width: 0;
  overflow: hidden;
  padding: 7px 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dfx-lookup-left { text-align: left; }
.dfx-lookup-center { text-align: center; }
.dfx-lookup-right { text-align: right; }

html.dfx-theme-dark .dfx-lookup-results {
  border-color: #34465b;
  background: #172235;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
}
html.dfx-theme-dark .dfx-lookup-header {
  background: #22344b;
  border-color: #34465b;
  color: #e7eef8;
}
html.dfx-theme-dark .dfx-lookup-option {
  border-color: #2c3c50;
  background: #172235;
  color: #e7eef8;
}
html.dfx-theme-dark .dfx-lookup-option:hover,
html.dfx-theme-dark .dfx-lookup-option:focus,
html.dfx-theme-dark .dfx-lookup-option.active,
html.dfx-theme-dark .dfx-lookup-option[data-dfx-active="true"] {
  background: #345b86 !important;
  color: #ffffff !important;
}

@media (max-width: 575.98px) {
  .erp-invoice { padding-right: 0.75rem; padding-left: 0.75rem; }
  .erp-page-head > .card-header,
  .erp-page-head > .card-body { padding: 1rem; }
  .dfx-client-create-btn > span:not(.dfx-client-create-icon) { display: none; }
  .dfx-client-create-btn { min-width: 2.5rem; }
  .dfx-client-create-icon { margin-right: 0; }
  .dfx-lookup-results { min-width: 0; width: 100%; }
  .erp-panel-head > .dfx-buscar { min-width: 0; width: 100%; }
}

@media (max-width: 575.98px) {
  .erp-toolbar .d-flex { justify-content: stretch !important; }
  .erp-toolbar .btn { flex: 1 1 0; }
  .erp-stat { min-width: 0; }
}

/* ---------------------------------------------------------------------
 * .td-actions .btn: ancho minimo parejo para los botones de accion de
 * una fila (Editar/Eliminar/etc.), en escritorio -- sin esto, "Editar"
 * queda mas angosto que "Eliminar" solo porque el texto es mas corto,
 * lo que se ve inconsistente bajando por la columna. En movil ya se
 * igualan por flex:1 1 0 (regla de .table-cards-sm mas abajo); este
 * min-width no interfiere con eso, solo pone un piso.
 * --------------------------------------------------------------------- */
.td-actions .btn { min-width: 84px; }
.td-actions .dfx-ui-btn-icon {
  min-width: 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
}
.dfx-ui-sortable { cursor: pointer; }
.dfx-ui-sortable:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }

/* CRUD table sizing: keep descriptive columns readable and utility columns natural. */
.dfx-ui-table { width: 100%; table-layout: auto; }
.dfx-ui-table th.dfx-ui-sortable { white-space: nowrap; }
.dfx-ui-table th.dfx-ui-sortable [data-dfx-sort-indicator] {
  display: inline-block;
  margin-inline-start: .2em;
  white-space: nowrap;
  vertical-align: baseline;
}
.dfx-ui-table th.dfx-ui-column-primary { min-width: 18rem; }
.dfx-ui-table th.dfx-ui-column-secondary { min-width: 11rem; }
.dfx-ui-table th.dfx-ui-column-compact { width: 1%; white-space: nowrap; }
.dfx-ui-table th.dfx-ui-actions-column,
.dfx-ui-table td.td-actions { width: 1%; white-space: nowrap; }

.dfx-client-create-btn {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  white-space: nowrap;
  border-color: #0891b2;
  background-color: #0891b2;
  color: #fff !important;
  font-weight: 600;
}
.erp-page-head .dfx-client-create-btn:hover,
.erp-page-head .dfx-client-create-btn:focus-visible {
  border-color: #0e7490;
  background-color: #0e7490;
  color: #fff !important;
}
.dfx-client-create-icon {
  display: inline-block;
  margin-right: .25rem;
  font-size: 1.1rem;
  line-height: 1;
  vertical-align: -.08em;
}
.dfx-context-value {
  width: auto;
  max-width: calc(100% - 4.5rem);
  padding: 0;
  border: 0;
  background: transparent !important;
  color: inherit;
  font: inherit;
  display: inline-block;
}

/* ---------------------------------------------------------------------
 * .table-cards-sm: convierte una <table> normal en una lista de
 * tarjetas por debajo de 768px. Requiere que cada <td> del template
 * tenga data-label="Etiqueta" (excepto columnas de imagen/acciones,
 * que usan .td-image / .td-actions en su lugar). La tabla sigue siendo
 * la misma tabla -- solo cambia su presentacion visual.
 * --------------------------------------------------------------------- */
@media (max-width: 767.98px) {
  .table-cards-sm thead { display: none; }
  .table-cards-sm, .table-cards-sm tbody, .table-cards-sm tr, .table-cards-sm td { display: block; width: 100%; }
  .table-cards-sm tr:not([data-dfx-empty]) { margin-bottom: .75rem; border: 1px solid var(--bs-border-color, #dee2e6); border-radius: .5rem; padding: .5rem .75rem; }
  .table-cards-sm td { border: none; padding: .3rem 0; text-align: right; }
  .table-cards-sm td[data-label] { padding-left: 42%; position: relative; min-height: 1.75rem; }
  .table-cards-sm td[data-label]::before { content: attr(data-label); position: absolute; left: 0; width: 40%; text-align: left; font-weight: 600; color: var(--bs-secondary-color, #6c757d); }
  .table-cards-sm td.td-image { text-align: center; padding-bottom: .5rem; }
  .table-cards-sm td.td-image img { width: 64px; height: 64px; }
  .table-cards-sm td.td-actions { display: flex; gap: .5rem; padding-top: .5rem; }
  .table-cards-sm td.td-actions .btn { flex: 1 1 0; padding-top: .5rem; padding-bottom: .5rem; }
  .table-cards-sm td.td-actions .dfx-ui-btn-icon {
    flex: 0 0 1.75rem;
    padding: 0;
  }
  .table-cards-sm tr[data-dfx-empty] td { text-align: center; padding: 1.5rem 0; }
  /* Pie de totales (tfoot) también como tarjeta a todo el ancho y con los
     colores del tema. Antes no estaba en la lista de arriba: quedaba como una
     tabla angosta y, con .table-light, en blanco sobre el tema oscuro. */
  .table-cards-sm tfoot { display: block; width: 100%; }
  .table-cards-sm tfoot > tr { background: var(--bs-tertiary-bg, #f8f9fa); color: var(--bs-body-color, inherit); }
  .table-cards-sm tfoot > tr > td { background: transparent; color: inherit; box-shadow: none; }
  .table-cards-sm tfoot > tr > td:first-child { text-align: left; }
}

/* ---------------------------------------------------------------------
 * .modal-footer-mobile: botones del footer de un modal apilados a
 * ancho completo por debajo de 768px (mejor objetivo tactil que dos
 * botones angostos lado a lado).
 * --------------------------------------------------------------------- */
.dfx-ui-crud-dialog {
  width: calc(100% - 2rem);
  max-width: 860px;
}

/* The document payment workspace is configured as medium in the Wizard,
   but mixed-payment rows need a little more horizontal room. Keep this
   adjustment scoped to that modal and leave other medium dialogs unchanged. */
#modalPagoWorkspace .modal-dialog:not(.modal-sm):not(.modal-lg):not(.modal-xl) {
  width: calc(100% - 1rem);
  max-width: 900px;
}

@media (max-width: 575.98px) {
  #modalPagoWorkspace .modal-dialog:not(.modal-sm):not(.modal-lg):not(.modal-xl) {
    width: calc(100% - 1rem);
    max-width: none;
  }
}


/* Payment workspace visual treatment. Keep all color decisions connected to
   the active Site Foundation theme so both accent and light/dark mode remain
   user-configurable. */
#modalPagoWorkspace .modal-content {
  overflow: hidden;
  border: 1px solid var(--dfx-border);
  border-radius: calc(var(--dfx-radius) + 0.25rem);
  background: var(--dfx-surface);
  color: var(--dfx-text);
  box-shadow: var(--dfx-shadow);
}

#modalPagoWorkspace .modal-header {
  position: relative;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid color-mix(in srgb, var(--dfx-primary) 22%, var(--dfx-border));
}

#modalPagoWorkspace .modal-header::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0.22rem;
  background: var(--dfx-primary);
  content: "";
}

#modalPagoWorkspace .modal-title {
  color: var(--dfx-text);
  font-weight: 750;
  letter-spacing: -0.015em;
}

#modalPagoWorkspace .modal-body {
  padding: 1.2rem 1.25rem;
}

#modalPagoWorkspace .form-label {
  color: var(--dfx-muted);
  font-size: 0.84rem;
  font-weight: 650;
}

#modalPagoWorkspace .modal-body > .row:first-child > div:first-child,
#modalPagoWorkspace .modal-body > .row:first-child > div:last-child {
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  border: 1px solid color-mix(in srgb, var(--dfx-primary) 25%, var(--dfx-border));
  border-radius: var(--dfx-radius);
  background: color-mix(in srgb, var(--dfx-primary-soft) 72%, var(--dfx-surface));
}

#modalPagoWorkspace [data-dfx-payment-total],
#modalPagoWorkspace [data-dfx-payment-balance] {
  min-height: 2.75rem;
  border-color: color-mix(in srgb, var(--dfx-primary) 34%, var(--dfx-border));
  background: var(--dfx-surface);
  color: var(--dfx-text);
  font-size: 1.05rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#modalPagoWorkspace [data-dfx-payment-balance] {
  border-color: color-mix(in srgb, var(--dfx-primary) 58%, var(--dfx-border));
  box-shadow: inset 0.18rem 0 0 var(--dfx-primary);
}

#modalPagoWorkspace [data-dfx-payment-amount] {
  min-height: 3rem;
  border-color: color-mix(in srgb, var(--dfx-primary) 54%, var(--dfx-border));
  color: var(--dfx-text);
  font-size: 1.12rem;
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#modalPagoWorkspace [data-dfx-payment-amount]:focus {
  border-color: var(--dfx-primary);
  box-shadow: 0 0 0 0.22rem color-mix(in srgb, var(--dfx-primary) 22%, transparent);
}

#modalPagoWorkspace [data-dfx-payment-collected],
#modalPagoWorkspace [data-dfx-payment-financed],
#modalPagoWorkspace [data-dfx-payment-status] {
  border-color: var(--dfx-border);
  background: var(--dfx-surface-soft);
  color: var(--dfx-text);
  font-variant-numeric: tabular-nums;
}

#modalPagoWorkspace [data-dfx-payment-collected],
#modalPagoWorkspace [data-dfx-payment-financed] {
  font-weight: 650;
  text-align: right;
}

#modalPagoWorkspace [data-dfx-payment-status] {
  font-weight: 650;
}

#modalPagoWorkspace .modal-body > section.mt-4 {
  margin-top: 1.35rem !important;
  padding-top: 1.1rem;
  border-top: 1px solid var(--dfx-border);
}

#modalPagoWorkspace .modal-body > section.mt-4 h3 {
  color: var(--dfx-text);
  font-weight: 700;
}

#modalPagoWorkspace .modal-body > section.mt-4 .table {
  --bs-table-bg: var(--dfx-surface);
  --bs-table-color: var(--dfx-text);
  --bs-table-border-color: var(--dfx-border);
  --bs-table-hover-bg: color-mix(in srgb, var(--dfx-primary) 6%, var(--dfx-surface));
  margin-bottom: 0;
  color: var(--dfx-text);
}

#modalPagoWorkspace .modal-body > section.mt-4 thead th {
  padding-top: 0.7rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid color-mix(in srgb, var(--dfx-primary) 30%, var(--dfx-border));
  background: color-mix(in srgb, var(--dfx-primary) 9%, var(--dfx-surface));
  color: var(--dfx-text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}

#modalPagoWorkspace .modal-body > section.mt-4 tbody td {
  border-color: var(--dfx-border);
  color: var(--dfx-text);
}

#modalPagoWorkspace .modal-body > section.mt-4 [data-dfx-payment-amount-cell] {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

#modalPagoWorkspace .btn-primary,
#modalPagoWorkspace .modal-footer .btn-success {
  border-color: var(--dfx-primary);
  background: var(--dfx-primary);
  color: var(--dfx-primary-contrast);
  font-weight: 650;
}

#modalPagoWorkspace .btn-primary:hover,
#modalPagoWorkspace .btn-primary:focus-visible,
#modalPagoWorkspace .modal-footer .btn-success:hover,
#modalPagoWorkspace .modal-footer .btn-success:focus-visible {
  border-color: var(--dfx-primary-hover);
  background: var(--dfx-primary-hover);
  color: var(--dfx-primary-contrast);
}

#modalPagoWorkspace .modal-footer {
  padding: 0.9rem 1.25rem 1.1rem;
  border-top: 1px solid var(--dfx-border);
}

@media (max-width: 575.98px) {
  #modalPagoWorkspace .modal-body {
    padding: 1rem;
  }

  #modalPagoWorkspace .modal-body > .row:first-child > div:first-child,
  #modalPagoWorkspace .modal-body > .row:first-child > div:last-child {
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
  }
}

/* Approved payment modal presentation. The generated DFX contract remains
   untouched; these classes only arrange and decorate existing controls. */
#modalPagoWorkspace .modal-dialog:not(.modal-sm):not(.modal-lg):not(.modal-xl) {
  width: calc(100% - 2rem);
  max-width: 900px;
}

#modalPagoWorkspace .modal-content {
  max-height: calc(100vh - 2rem);
}

#modalPagoWorkspace #frmPagoWorkspace {
  display: flex;
  min-height: 0;
  flex-direction: column;
}

#modalPagoWorkspace .modal-body {
  min-height: 0;
  overflow-y: auto;
}

#modalPagoWorkspace .modal-header {
  padding: 1rem 1.25rem;
  background: var(--dfx-surface);
}

#modalPagoWorkspace .modal-header::before {
  width: 0.18rem;
  opacity: 0.8;
}

#modalPagoWorkspace .dfx-payment-heading,
#modalPagoWorkspace .dfx-payment-section-title {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

#modalPagoWorkspace .dfx-payment-heading {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 750;
}

#modalPagoWorkspace .dfx-payment-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: calc(var(--dfx-radius) * 0.85);
  background: color-mix(in srgb, var(--dfx-primary) 10%, var(--dfx-surface));
  color: var(--dfx-primary);
}

#modalPagoWorkspace .dfx-payment-icon svg,
#modalPagoWorkspace .dfx-payment-label-icon svg,
#modalPagoWorkspace .dfx-payment-button-icon svg,
#modalPagoWorkspace .dfx-payment-empty-icon svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
}

#modalPagoWorkspace .dfx-payment-icon--header {
  width: 2.75rem;
  height: 2.75rem;
  background: var(--dfx-primary);
  color: var(--dfx-primary-contrast);
}

#modalPagoWorkspace .dfx-payment-overview > .dfx-payment-card {
  min-width: 0;
  padding: 0.8rem 0.95rem;
  border: 1px solid color-mix(in srgb, var(--dfx-primary) 22%, var(--dfx-border));
  border-radius: var(--dfx-radius);
  background: color-mix(in srgb, var(--dfx-primary-soft) 48%, var(--dfx-surface));
}

#modalPagoWorkspace .dfx-payment-overview .dfx-payment-label,
#modalPagoWorkspace .dfx-payment-amount-field .dfx-payment-label,
#modalPagoWorkspace .dfx-payment-note-field .dfx-payment-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
  font-size: 0.9rem;
  font-weight: 650;
}

#modalPagoWorkspace .dfx-payment-label-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--dfx-primary);
}

#modalPagoWorkspace .dfx-payment-label-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

#modalPagoWorkspace .dfx-payment-overview [data-dfx-payment-total],
#modalPagoWorkspace .dfx-payment-overview [data-dfx-payment-balance] {
  min-height: 2.9rem;
  margin: 0;
  border: 0;
  background: transparent;
  font-size: 1.45rem;
  font-weight: 750;
}

#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--total {
  background: color-mix(in srgb, var(--dfx-primary) 7%, var(--dfx-surface));
}

#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--method {
  border-color: transparent;
  background: transparent;
}

#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--method .form-select {
  min-height: 2.9rem;
  background-color: var(--dfx-surface);
  color: var(--dfx-text);
}

#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--balance {
  border-color: var(--dfx-primary);
  background: var(--dfx-primary);
  color: var(--dfx-primary-contrast);
}

#modalPagoWorkspace .dfx-payment-card--balance .dfx-payment-label,
#modalPagoWorkspace .dfx-payment-card--balance .dfx-payment-label-icon,
#modalPagoWorkspace .dfx-payment-card--balance [data-dfx-payment-balance] {
  color: var(--dfx-primary-contrast);
}

#modalPagoWorkspace .dfx-payment-entry {
  align-items: start;
}

#modalPagoWorkspace .dfx-payment-amount-field [data-dfx-payment-amount] {
  min-height: 3.2rem;
  font-size: 1.35rem;
  font-weight: 750;
}

#modalPagoWorkspace .dfx-payment-note-field textarea {
  min-height: 3.2rem;
  background: var(--dfx-surface-soft);
}

#modalPagoWorkspace .dfx-payment-summary {
  align-items: stretch;
}

#modalPagoWorkspace .dfx-payment-stat {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--dfx-border);
  border-radius: var(--dfx-radius);
  background: var(--dfx-surface-soft);
}

#modalPagoWorkspace .dfx-payment-icon--success {
  background: color-mix(in srgb, var(--dfx-success) 12%, var(--dfx-surface));
  color: var(--dfx-success);
}

#modalPagoWorkspace .dfx-payment-icon--info {
  background: color-mix(in srgb, var(--dfx-primary) 10%, var(--dfx-surface));
  color: var(--dfx-primary);
}

#modalPagoWorkspace .dfx-payment-icon--status {
  background: color-mix(in srgb, var(--dfx-warning) 14%, var(--dfx-surface));
  color: var(--dfx-warning);
}

#modalPagoWorkspace .dfx-payment-stat__content {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  gap: 0.15rem;
}

#modalPagoWorkspace .dfx-payment-stat .form-label {
  margin: 0;
  color: var(--dfx-muted);
  font-size: 0.84rem;
  font-weight: 650;
}

#modalPagoWorkspace .dfx-payment-stat .form-control {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dfx-text);
  font-size: 1.1rem;
  font-weight: 750;
}

#modalPagoWorkspace .dfx-payment-stat--status .form-control {
  padding: 0.2rem 0.55rem;
  border-radius: 0.45rem;
  background: color-mix(in srgb, var(--dfx-warning) 14%, var(--dfx-surface));
  color: var(--dfx-text);
  letter-spacing: 0.025em;
}

#modalPagoWorkspace .dfx-payment-grid {
  margin-top: 1.1rem !important;
  padding-top: 1rem;
  border-top: 1px solid var(--dfx-border);
}

#modalPagoWorkspace .dfx-payment-grid-heading {
  margin-bottom: 0.8rem !important;
}

#modalPagoWorkspace .dfx-payment-section-title {
  align-items: flex-start;
  gap: 0.7rem;
}

#modalPagoWorkspace .dfx-payment-section-title h3 {
  margin-top: 0.12rem;
  color: var(--dfx-text);
  font-size: 1.15rem;
  font-weight: 750;
}

#modalPagoWorkspace .dfx-payment-section-title p {
  color: var(--dfx-muted);
  font-size: 0.9rem;
}

#modalPagoWorkspace .dfx-payment-add {
  display: inline-flex;
  min-height: 2.8rem;
  align-items: center;
  gap: 0.55rem;
  padding-inline: 1rem;
  border-radius: calc(var(--dfx-radius) * 0.9);
  box-shadow: none;
}

#modalPagoWorkspace .dfx-payment-button-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#modalPagoWorkspace .dfx-payment-table {
  table-layout: fixed;
  border: 1px solid var(--dfx-border);
  border-radius: var(--dfx-radius);
  overflow: hidden;
}

#modalPagoWorkspace .dfx-payment-table .dfx-payment-col-method { width: 30%; }
#modalPagoWorkspace .dfx-payment-table .dfx-payment-col-value { width: 15%; }
#modalPagoWorkspace .dfx-payment-table .dfx-payment-col-detail { width: 40%; }
#modalPagoWorkspace .dfx-payment-table .dfx-payment-col-action { width: 15%; }

#modalPagoWorkspace .dfx-payment-table thead th {
  padding: 0.78rem 0.85rem;
  background: color-mix(in srgb, var(--dfx-primary) 9%, var(--dfx-surface));
  color: var(--dfx-text);
  font-size: 0.88rem;
  letter-spacing: 0;
  text-transform: none;
}

#modalPagoWorkspace .dfx-payment-table tbody td {
  padding: 0.72rem 0.85rem;
  overflow-wrap: anywhere;
  vertical-align: middle;
}

#modalPagoWorkspace .dfx-payment-empty {
  display: grid;
  min-height: 7rem;
  place-content: center;
  justify-items: center;
  gap: 0.3rem;
  color: var(--dfx-muted);
  text-align: center;
}

#modalPagoWorkspace .dfx-payment-empty-icon {
  display: inline-flex;
  margin-bottom: 0.2rem;
  color: color-mix(in srgb, var(--dfx-muted) 75%, transparent);
}

#modalPagoWorkspace .dfx-payment-empty strong {
  color: var(--dfx-text);
  font-weight: 700;
}

#modalPagoWorkspace .modal-footer {
  position: sticky;
  bottom: 0;
  padding: 0.9rem 1.25rem;
  background: var(--dfx-surface);
}

#modalPagoWorkspace .modal-footer .btn-success {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--dfx-primary);
  border-color: var(--dfx-primary);
  color: var(--dfx-primary-contrast);
}

#modalPagoWorkspace .modal-footer .btn-success:hover,
#modalPagoWorkspace .modal-footer .btn-success:focus-visible {
  background: var(--dfx-primary-hover);
  border-color: var(--dfx-primary-hover);
  color: var(--dfx-primary-contrast);
}

@media (max-width: 767.98px) {
  #modalPagoWorkspace .modal-dialog {
    width: calc(100% - 1rem) !important;
    max-width: none !important;
    margin: 0.5rem auto;
  }

  #modalPagoWorkspace .modal-content {
    max-height: calc(100vh - 1rem);
  }

  #modalPagoWorkspace .dfx-payment-overview > .dfx-payment-card {
    padding: 0.7rem 0.8rem;
  }

  #modalPagoWorkspace .dfx-payment-overview [data-dfx-payment-total],
  #modalPagoWorkspace .dfx-payment-overview [data-dfx-payment-balance] {
    font-size: 1.25rem;
  }

  #modalPagoWorkspace .dfx-payment-grid-heading {
    align-items: flex-start !important;
  }

  #modalPagoWorkspace .dfx-payment-add {
    min-height: 2.55rem;
    white-space: nowrap;
  }

  #modalPagoWorkspace .dfx-payment-table {
    min-width: 38rem;
  }

  #modalPagoWorkspace .modal-footer {
    padding: 0.75rem 1rem;
  }
}

@media (max-width: 479.98px) {
  #modalPagoWorkspace .dfx-payment-grid-heading {
    flex-direction: column;
  }

  #modalPagoWorkspace .dfx-payment-add {
    width: 100%;
    justify-content: center;
  }

  #modalPagoWorkspace .dfx-payment-table {
    min-width: 34rem;
  }

  #modalPagoWorkspace .modal-footer .btn {
    flex: 1 1 auto;
  }
}

/* Compact payment modal refinement. Wrappers stay transparent; only controls
   receive surfaces. All colors come from Site Foundation theme tokens. */
#modalPagoWorkspace .modal-dialog {
  width: calc(100% - 2rem);
  max-width: 900px;
  margin-right: auto;
  margin-left: auto;
  box-sizing: border-box;
}

#modalPagoWorkspace .modal-content {
  width: 100%;
  min-width: 0;
  max-height: calc(100vh - 2rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--dfx-radius);
}

#modalPagoWorkspace #frmPagoWorkspace {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}

#modalPagoWorkspace .modal-header,
#modalPagoWorkspace .modal-footer {
  flex: 0 0 auto;
}

#modalPagoWorkspace .modal-header {
  min-height: 4.25rem;
  padding: 0.75rem 1.25rem;
  background: var(--dfx-surface);
  border-bottom-color: var(--dfx-border);
}

#modalPagoWorkspace .modal-header::before {
  width: 0.12rem;
  opacity: 0.55;
}

#modalPagoWorkspace .dfx-payment-heading {
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
}

#modalPagoWorkspace .dfx-payment-icon--header {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.65rem;
  background: color-mix(in srgb, var(--dfx-primary) 10%, var(--dfx-surface));
  color: var(--dfx-primary);
}

#modalPagoWorkspace .modal-body {
  min-width: 0;
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

#modalPagoWorkspace .form-label {
  margin-bottom: 0.4rem;
  color: var(--dfx-muted);
  font-size: 0.875rem;
  font-weight: 600;
}

#modalPagoWorkspace .dfx-payment-overview {
  --bs-gutter-y: 0.75rem;
  margin-bottom: 1rem !important;
}

#modalPagoWorkspace .modal-body > .row:first-child > div:first-child,
#modalPagoWorkspace .modal-body > .row:first-child > div:last-child,
#modalPagoWorkspace .modal-body > .dfx-payment-overview > .dfx-payment-card {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

#modalPagoWorkspace .dfx-payment-overview .dfx-payment-label {
  gap: 0.4rem;
  margin-bottom: 0.35rem;
  font-size: 0.875rem;
}

#modalPagoWorkspace .dfx-payment-label-icon svg {
  width: 1rem;
  height: 1rem;
}

#modalPagoWorkspace .dfx-payment-overview [data-dfx-payment-total],
#modalPagoWorkspace .dfx-payment-overview [data-dfx-payment-balance],
#modalPagoWorkspace [data-dfx-payment-total],
#modalPagoWorkspace [data-dfx-payment-balance] {
  min-height: 2.55rem;
  margin: 0;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--dfx-border);
  border-radius: calc(var(--dfx-radius) * 0.8);
  background: var(--dfx-surface-soft);
  color: var(--dfx-text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: right;
  font-variant-numeric: tabular-nums;
  opacity: 1;
  box-shadow: none;
}

#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--balance,
#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--total,
#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--method {
  border: 0;
  background: transparent;
  color: var(--dfx-text);
}

#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--balance .dfx-payment-label,
#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--balance .dfx-payment-label-icon,
#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--balance [data-dfx-payment-balance] {
  color: var(--dfx-text);
}

#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--balance [data-dfx-payment-balance] {
  border-color: color-mix(in srgb, var(--dfx-primary) 42%, var(--dfx-border));
  box-shadow: inset 0.16rem 0 0 var(--dfx-primary);
}

#modalPagoWorkspace .dfx-payment-overview .dfx-payment-card--method .form-select {
  min-height: 2.55rem;
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
  border-color: var(--dfx-border);
  background-color: var(--dfx-surface);
  color: var(--dfx-text);
}

#modalPagoWorkspace .dfx-payment-entry {
  --bs-gutter-y: 0.85rem;
}

#modalPagoWorkspace .dfx-payment-amount-field .dfx-payment-label,
#modalPagoWorkspace .dfx-payment-note-field .dfx-payment-label {
  gap: 0.4rem;
  margin-bottom: 0.4rem;
}

#modalPagoWorkspace .dfx-payment-amount-field [data-dfx-payment-amount],
#modalPagoWorkspace .dfx-payment-note-field textarea {
  min-height: 2.55rem;
  padding: 0.45rem 0.7rem;
  border-color: var(--dfx-border);
  border-radius: calc(var(--dfx-radius) * 0.8);
  background: var(--dfx-surface);
  color: var(--dfx-text);
  font-size: 1rem;
}

#modalPagoWorkspace .dfx-payment-amount-field [data-dfx-payment-amount] {
  font-weight: 700;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#modalPagoWorkspace [data-dfx-payment-amount]:focus {
  border-color: var(--dfx-primary);
  box-shadow: 0 0 0 0.18rem color-mix(in srgb, var(--dfx-primary) 20%, transparent);
}

#modalPagoWorkspace .dfx-payment-note-field textarea {
  min-height: 2.55rem;
  resize: vertical;
}

#modalPagoWorkspace .dfx-payment-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 0;
}

#modalPagoWorkspace .dfx-payment-summary > .dfx-payment-stat {
  width: auto;
  max-width: none;
  margin: 0;
  padding: 0.45rem 0.6rem;
  align-items: center;
}

#modalPagoWorkspace .dfx-payment-stat {
  min-height: 4rem;
  gap: 0.55rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--dfx-border);
  border-radius: calc(var(--dfx-radius) * 0.8);
  background: var(--dfx-surface-soft);
}

#modalPagoWorkspace .dfx-payment-stat .dfx-payment-icon {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--dfx-primary) 9%, var(--dfx-surface));
  color: var(--dfx-primary);
}

#modalPagoWorkspace .dfx-payment-stat .dfx-payment-icon--success {
  background: color-mix(in srgb, var(--dfx-success) 9%, var(--dfx-surface));
  color: var(--dfx-success);
}

#modalPagoWorkspace .dfx-payment-stat .dfx-payment-icon--status {
  background: var(--dfx-surface);
  color: var(--dfx-muted);
}

#modalPagoWorkspace .dfx-payment-stat .dfx-payment-icon svg {
  width: 1.1rem;
  height: 1.1rem;
}

#modalPagoWorkspace .dfx-payment-stat .form-label {
  margin: 0;
  font-size: 0.78rem;
}

#modalPagoWorkspace .dfx-payment-stat .form-control {
  min-height: 1.45rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--dfx-text);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  opacity: 1;
}

#modalPagoWorkspace .dfx-payment-stat--status .form-control {
  padding: 0.1rem 0.4rem;
  border-radius: 0.35rem;
  background: color-mix(in srgb, var(--dfx-warning) 10%, var(--dfx-surface));
  color: var(--dfx-text);
  letter-spacing: 0;
}

#modalPagoWorkspace .dfx-payment-grid {
  margin-top: 0.95rem !important;
  padding-top: 0.85rem;
  border-top: 1px solid var(--dfx-border);
}

#modalPagoWorkspace .dfx-payment-grid-heading {
  margin-bottom: 0.55rem !important;
}

#modalPagoWorkspace .dfx-payment-section-title {
  gap: 0.55rem;
  align-items: center;
}

#modalPagoWorkspace .dfx-payment-section-title .dfx-payment-icon {
  width: 2rem;
  height: 2rem;
  background: color-mix(in srgb, var(--dfx-primary) 8%, var(--dfx-surface));
}

#modalPagoWorkspace .dfx-payment-section-title .dfx-payment-icon svg {
  width: 1rem;
  height: 1rem;
}

#modalPagoWorkspace .dfx-payment-section-title h3 {
  margin: 0 0 0.1rem;
  font-size: 1.05rem;
  font-weight: 700;
}

#modalPagoWorkspace .dfx-payment-section-title p {
  font-size: 0.82rem;
}

#modalPagoWorkspace .dfx-payment-add {
  min-height: 2.4rem;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
}

#modalPagoWorkspace .dfx-payment-button-icon svg {
  width: 1rem;
  height: 1rem;
}

#modalPagoWorkspace .dfx-payment-table {
  width: 100%;
  min-width: 0;
  border-color: var(--dfx-border);
}

#modalPagoWorkspace .dfx-payment-grid,
#modalPagoWorkspace .dfx-payment-grid .table-responsive {
  width: 100%;
  min-width: 0;
}

#modalPagoWorkspace .dfx-payment-table thead th {
  padding: 0.6rem 0.75rem;
  background: color-mix(in srgb, var(--dfx-primary) 5%, var(--dfx-surface));
  font-size: 0.82rem;
}

#modalPagoWorkspace .dfx-payment-table thead,
#modalPagoWorkspace .dfx-payment-table tbody tr {
  display: table;
  width: 100%;
  table-layout: fixed;
}

#modalPagoWorkspace .dfx-payment-table tbody {
  display: block;
  width: 100%;
  min-height: 6rem;
  max-height: 13rem;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

#modalPagoWorkspace .dfx-payment-table th:nth-child(1),
#modalPagoWorkspace .dfx-payment-table td:nth-child(1) { width: 30%; }
#modalPagoWorkspace .dfx-payment-table th:nth-child(2),
#modalPagoWorkspace .dfx-payment-table td:nth-child(2) { width: 15%; }
#modalPagoWorkspace .dfx-payment-table th:nth-child(3),
#modalPagoWorkspace .dfx-payment-table td:nth-child(3) { width: 45%; }
#modalPagoWorkspace .dfx-payment-table th:nth-child(4),
#modalPagoWorkspace .dfx-payment-table td:nth-child(4) { width: 10%; }

#modalPagoWorkspace .dfx-payment-table tbody tr[data-dfx-empty] {
  height: 6rem;
}

#modalPagoWorkspace .dfx-payment-table tbody tr[data-dfx-empty] td {
  width: 100%;
  height: 6rem;
}

#modalPagoWorkspace .dfx-payment-table tbody tr[data-dfx-empty] td:nth-child(1) {
  width: 100%;
}

#modalPagoWorkspace .dfx-payment-table tbody td {
  padding: 0.7rem 0.75rem;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
  vertical-align: middle;
}

#modalPagoWorkspace .dfx-payment-empty {
  min-height: 0;
  height: 100%;
  gap: 0.2rem;
  font-size: 0.86rem;
}

#modalPagoWorkspace .dfx-payment-empty-icon {
  margin-bottom: 0.05rem;
}

#modalPagoWorkspace .dfx-payment-empty-icon svg {
  width: 1.15rem;
  height: 1.15rem;
}

#modalPagoWorkspace .modal-footer {
  position: static;
  padding: 0.7rem 1.5rem 0.8rem;
  border-top: 1px solid var(--dfx-border);
  background: var(--dfx-surface);
}

#modalPagoWorkspace .modal-footer .btn {
  min-height: 2.4rem;
  padding: 0.35rem 0.85rem;
}

#modalPagoWorkspace .dfx-payment-col-action,
#modalPagoWorkspace .dfx-payment-table tbody td:nth-child(4) {
  text-align: center;
  vertical-align: middle;
}

#modalPagoWorkspace .dfx-payment-remove {
  display: inline-grid;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  place-items: center;
  border-radius: 0.5rem;
}

#modalPagoWorkspace .dfx-payment-remove svg {
  width: 1rem;
  height: 1rem;
}

@media (max-width: 767.98px) {
  #modalPagoWorkspace .modal-dialog {
    width: calc(100% - 1rem);
    max-width: none;
    margin: 0.5rem auto;
  }

  #modalPagoWorkspace .modal-content {
    max-height: calc(100vh - 1rem);
  }

  #modalPagoWorkspace .modal-body {
    overflow-y: auto;
    padding: 1rem;
  }

  #modalPagoWorkspace .dfx-payment-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #modalPagoWorkspace .dfx-payment-stat--status {
    grid-column: 1 / -1;
  }

  #modalPagoWorkspace .dfx-payment-table {
    min-width: 34rem;
  }

  #modalPagoWorkspace .dfx-payment-table tbody {
    min-height: 5.25rem;
    max-height: 11rem;
  }

  #modalPagoWorkspace .dfx-payment-table tbody tr[data-dfx-empty],
  #modalPagoWorkspace .dfx-payment-table tbody tr[data-dfx-empty] td {
    height: 5.25rem;
  }

  #modalPagoWorkspace .modal-footer {
    padding: 0.65rem 1rem;
  }
}

@media (max-width: 479.98px) {
  #modalPagoWorkspace .dfx-payment-summary {
    grid-template-columns: 1fr;
  }

  #modalPagoWorkspace .dfx-payment-stat--status {
    grid-column: auto;
  }

  #modalPagoWorkspace .modal-footer .btn {
    flex: 1 1 auto;
  }
}

.dfx-ui-crud-dialog .modal-content {
  max-height: calc(100vh - 3.5rem);
}

.dfx-ui-crud-dialog .modal-content > form {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
}

.dfx-ui-crud-dialog .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

@media (max-width: 767.98px) {
  .modal-footer-mobile { flex-direction: column-reverse; }
  .modal-footer-mobile .btn { width: 100%; }
}

/* ---------------------------------------------------------------------
 * Cualquier modal data-dfx-modal que use una clase modal-fullscreen-*-down
 * de Bootstrap: por debajo de ese breakpoint, Bootstrap deja el .modal
 * externo con su overflow-y:auto por defecto (pensado para el dialogo
 * centrado normal). Con contenido mas alto que el viewport, eso hace
 * que sea el .modal el que scrollea -- desplazando TODO el dialogo
 * hacia arriba y exponiendo la pagina detras -- en vez de que scrollee
 * .modal-body como se espera. min-height:0 con flex-basis:auto no
 * alcanza para forzar el scroll donde corresponde (probado); flex-basis
 * en 0 tampoco (rompe el layout). Un max-height explicito en .modal-body
 * si funciona de forma confiable, verificado con scroll real (scroll_to,
 * no una captura en reposo -- el bug solo aparece al scrollear).
 * 190px = alto tipico de header (~63px) + footer con dos botones
 * apilados en movil (~127px); es generoso a proposito, un formulario
 * con footer mas bajo simplemente no llega a mostrar scrollbar.
 * --------------------------------------------------------------------- */
@media (max-width: 575.98px) {
  .dfx-ui-crud-dialog {
    width: 100%;
    max-width: none;
  }

  .modal[data-dfx-modal] .modal-dialog[class*="modal-fullscreen"] {
    height: 100vh;
    margin: 0;
  }
  .modal[data-dfx-modal]:has(.modal-dialog[class*="modal-fullscreen"]) {
    overflow-y: hidden;
  }
  .modal[data-dfx-modal] .modal-dialog[class*="modal-fullscreen"] .modal-content {
    height: 100%;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
  }
  .modal[data-dfx-modal] .modal-dialog[class*="modal-fullscreen"] .modal-header,
  .modal[data-dfx-modal] .modal-dialog[class*="modal-fullscreen"] .modal-footer {
    flex: 0 0 auto;
  }
  .modal[data-dfx-modal] .modal-dialog[class*="modal-fullscreen"] .modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    max-height: none;
  }
}

/* Keep the payment action row reachable on short/mobile viewports. The form
   owns both the scrolling body and the footer, so it must be a constrained
   flex column inside the dialog rather than an intrinsically tall block. */
#modalPagoWorkspace .modal-content {
  display: flex;
  min-height: 0;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  flex-direction: column;
  overflow: hidden;
}

#modalPagoWorkspace .modal-header {
  flex: 0 0 auto;
}

#modalPagoWorkspace #frmPagoWorkspace {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
}

#modalPagoWorkspace .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
}

#modalPagoWorkspace .modal-footer {
  flex: 0 0 auto;
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: var(--dfx-surface);
}

@media (max-width: 767.98px) {
  #modalPagoWorkspace .modal-dialog {
    max-height: calc(100vh - 2rem);
    max-height: calc(100dvh - 2rem);
  }
}


/* ---------------------------------------------------------------------
 * Lista de documentos (Document Studio): mismo diseño del CRUD. El estado
 * llega como data-status desde data-dfx-status; los iconos de acción se
 * acomodan en una rejilla compacta y Anular se oculta en filas anuladas.
 * --------------------------------------------------------------------- */
.dfx-ui-status {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--dfx-surface-soft);
  color: var(--dfx-muted);
}
.dfx-ui-status[data-status="ACTIVA"],
.dfx-ui-status[data-status="PAGADA"] { background: color-mix(in srgb, var(--dfx-success) 16%, transparent); color: var(--dfx-success); }
.dfx-ui-status[data-status="PARCIAL"],
.dfx-ui-status[data-status="PENDIENTE"] { background: color-mix(in srgb, var(--dfx-warning) 18%, transparent); color: var(--dfx-warning); }
.dfx-ui-status[data-status="ANULADA"] { background: color-mix(in srgb, var(--bs-danger) 14%, transparent); color: var(--bs-danger); }
.dfx-ui-document-actions {
  display: inline-grid;
  grid-template-columns: repeat(3, 1.75rem);
  gap: .25rem;
  justify-content: end;
}
.dfx-ui-document-list .td-actions .btn { min-width: 0; }
.dfx-ui-document-list tr[data-status="ANULADA"] .dfx-ui-doc-anular { visibility: hidden; }
.dfx-ui-document-list tr[data-status="ANULADA"] td:not(.td-actions) { opacity: .6; }

/* Lista de documentos: tabla más compacta para que quepan más columnas, y
   acciones con color propio (PDF rojo, correo azul, pagos verde, anular rojo). */
.dfx-ui-document-list .dfx-ui-table { font-size: .78rem; }
.dfx-ui-document-list .dfx-ui-table thead th { font-size: .72rem; white-space: nowrap; }
.dfx-ui-document-list .dfx-ui-table > :not(caption) > * > * { padding: .4rem .45rem; }
.dfx-ui-document-list .dfx-ui-status { font-size: .68rem; padding: .1rem .45rem; }
.dfx-ui-document-list .dfx-ui-document-actions { grid-template-columns: repeat(3, 1.6rem); grid-auto-rows: 1.6rem; gap: .2rem; align-items: center; justify-items: center; }
.dfx-ui-document-list .td-actions .dfx-ui-doc-anular { grid-row: 2; grid-column: 1; }
/* dfx-ui-theme.css separa los iconos del CRUD con margin-left; aquí separa la rejilla. */
.dfx-ui-document-list .td-actions .dfx-ui-btn-icon + .dfx-ui-btn-icon { margin-left: 0; }
.dfx-ui-document-list .td-actions .dfx-ui-btn-icon { margin: 0; padding: 0; display: inline-flex; align-items: center; justify-content: center; vertical-align: middle; }
.dfx-ui-document-list .td-actions .dfx-ui-btn-icon { width: 1.6rem; min-width: 1.6rem; height: 1.6rem; border: 0; color: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .18); transition: transform .12s, filter .12s; }
.dfx-ui-document-list .td-actions .dfx-ui-btn-icon:hover,
.dfx-ui-document-list .td-actions .dfx-ui-btn-icon:focus-visible { color: #fff; filter: brightness(1.12); transform: translateY(-1px); }
.dfx-ui-document-list .td-actions .dfx-ui-doc-pdf { background: #e5383b; }
.dfx-ui-document-list .td-actions .dfx-ui-doc-correo { background: #1e88e5; }
.dfx-ui-document-list .td-actions .dfx-ui-doc-pagos { background: #16a34a; }
.dfx-ui-document-list .td-actions .dfx-ui-doc-whatsapp { background: #25d366; }
.dfx-ui-document-list .td-actions .dfx-ui-doc-anular { background: #fff0f0; color: #e5383b; box-shadow: inset 0 0 0 1.5px #e5383b; }
.dfx-ui-document-list .td-actions .dfx-ui-doc-anular:hover { background: #e5383b; color: #fff; }
[data-bs-theme="dark"] .dfx-ui-document-list .td-actions .dfx-ui-doc-anular { background: transparent; color: #ff6b6e; box-shadow: inset 0 0 0 1.5px #ff6b6e; }

/* Modales largos (2026-10-22): los CRUD envuelven cuerpo y pie en un <form>,
   que Bootstrap no contempla en .modal-dialog-scrollable; el pie con
   «Guardar» quedaba fuera de la pantalla y sin scroll. El form ocupa el
   alto disponible y el cuerpo hace scroll; el pie queda siempre visible. */
.modal-dialog-scrollable .modal-content > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow: hidden;
}
.modal-dialog-scrollable .modal-content > form > .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* =====================================================================
 * Capa adaptativa DFX UI (14/11/2026)
 *
 * Una misma pagina DFX se adapta sola a escritorio, navegador movil y
 * Nexo Mobile. Todo va por media queries del dispositivo, no por la app:
 * la hoja nexo-mobile.css de Nexo Mobile (contrato v1) sigue aplicando
 * solo bajo html.nexo-shell y no hace falta para que la pagina funcione
 * en el telefono. No cambia nombres, tipos, datos ni la logica VFP.
 *
 * Marcas opcionales (las pone el generador o la pagina):
 *   - table.table-cards-sm / table[data-dfx-mobile="cards"]: lista de
 *     tarjetas en el telefono. Sin la marca, la tabla conserva el
 *     desplazamiento horizontal de .table-responsive.
 *   - [data-dfx-mobile-keep-cols]: la fila de un formulario conserva sus
 *     columnas en pantallas angostas.
 *   - .modal-dialog[data-dfx-mobile="dialog"]: el modal no pasa a
 *     pantalla completa en el telefono.
 * ===================================================================== */

/* Sin desbordamiento horizontal de la pagina: las columnas flexibles del
   armazon pueden encogerse y lo ancho (tablas) se desplaza en su marco. */
.dfx-shell-main,
.dfx-content,
.dfx-content > *,
.dfx-ui-crud-grid,
.dfx-ui-table-frame {
  min-width: 0;
}

.table-responsive {
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

/* Campos: 16 px en pantallas tactiles para que el navegador no amplie la
   pagina al enfocarlos (iOS/Android), en cualquier navegador. */
@media (pointer: coarse) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]),
  select,
  textarea {
    font-size: max(16px, 1rem);
  }

  .form-switch .form-check-input {
    width: 2.6em;
    height: 1.45em;
    margin-top: 0;
  }

  .form-check {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding-left: 0;
  }

  .form-check.form-check-inline {
    display: inline-flex;
  }

  .form-check .form-check-input {
    float: none;
    margin-left: 0;
    flex: 0 0 auto;
  }

  .form-check .form-check-label {
    padding-top: .1rem;
  }
}

/* Telefono (< 576 px). */
@media (max-width: 575.98px) {
  /* Formularios en una columna: los pares col-6/col-md-* de los
     generadores no dejan campos de 150 px en un telefono angosto. */
  form[data-dfx-form] .row:not([data-dfx-mobile-keep-cols]) > [class*="col-"]:not([class*="col-sm-"]) {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
  }

  /* Modales DFX con formulario o grandes (modal-lg/xl/scrollable) a
     pantalla completa: el teclado no tapa el pie y el cuerpo es lo unico
     que se desplaza. Las confirmaciones cortas (Eliminar) y los marcados con
     data-dfx-mobile="dialog" siguen como dialogo centrado. */
  .modal[data-dfx-modal] .modal-dialog:not([data-dfx-mobile="dialog"]):is(.modal-lg, .modal-xl, .modal-dialog-scrollable, :has(form)) {
    width: 100%;
    max-width: none;
    height: 100%;
    margin: 0;
  }

  .modal[data-dfx-modal]:not(:has(.modal-dialog[data-dfx-mobile="dialog"])):has(.modal-lg, .modal-xl, .modal-dialog-scrollable, .modal-dialog form) {
    overflow-y: hidden;
  }

  .modal[data-dfx-modal] .modal-dialog:not([data-dfx-mobile="dialog"]):is(.modal-lg, .modal-xl, .modal-dialog-scrollable, :has(form)) > .modal-content {
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .modal[data-dfx-modal] .modal-dialog:not([data-dfx-mobile="dialog"]):is(.modal-lg, .modal-xl, .modal-dialog-scrollable, :has(form)) > .modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
  }

  .modal[data-dfx-modal] .modal-dialog:not([data-dfx-mobile="dialog"]):is(.modal-lg, .modal-xl, .modal-dialog-scrollable, :has(form)) .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .modal[data-dfx-modal] .modal-dialog:not([data-dfx-mobile="dialog"]):is(.modal-lg, .modal-xl, .modal-dialog-scrollable, :has(form)) .modal-header,
  .modal[data-dfx-modal] .modal-dialog:not([data-dfx-mobile="dialog"]):is(.modal-lg, .modal-xl, .modal-dialog-scrollable, :has(form)) .modal-footer {
    flex: 0 0 auto;
  }

  .modal[data-dfx-modal] .modal-dialog:not([data-dfx-mobile="dialog"]):is(.modal-lg, .modal-xl, .modal-dialog-scrollable, :has(form)) .modal-footer {
    padding-bottom: calc(.75rem + env(safe-area-inset-bottom, 0px));
    background: var(--dfx-surface, var(--bs-body-bg));
  }

  /* Pie de modal: botones repartidos a lo ancho, la accion principal a la
     derecha como en escritorio. */
  .modal[data-dfx-modal] .modal-footer,
  .dfx-confirm-dialog .modal-footer {
    flex-wrap: nowrap;
    gap: .5rem;
  }

  .modal[data-dfx-modal] .modal-footer > .btn,
  .dfx-confirm-dialog .modal-footer > .btn {
    flex: 1 1 0;
    margin: 0;
  }

  .dfx-confirm-dialog .modal-dialog {
    width: calc(100% - 2rem);
    margin-inline: auto;
  }

  /* Notificaciones arriba y a lo ancho. Abajo tapaban el pie de los
     modales y la barra de Guardar (z-index 1090 sobre 1055) y se comian el
     toque en "Eliminar". El contenedor no captura toques; solo el aviso. */
  .toast-container.position-fixed {
    top: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    left: 0 !important;
    width: 100%;
    padding: calc(.5rem + env(safe-area-inset-top, 0px)) .75rem .5rem !important;
    pointer-events: none;
  }

  .toast-container .toast {
    width: 100%;
    pointer-events: auto;
  }

  /* Diálogos centrados (confirmaciones): ancho del telefono con margen. */
  .modal[data-dfx-modal] .modal-dialog:not(.modal-lg):not(.modal-xl):not(.modal-dialog-scrollable):not(:has(form)) {
    width: calc(100% - 2rem);
    margin-inline: auto;
  }

  /* Casilla en columna propia (CRUD): alineada a la izquierda con su
     etiqueta, como el resto de campos en una columna. */
  form[data-dfx-form] .form-label.text-center {
    text-align: left !important;
  }

  form[data-dfx-form] .form-check.justify-content-center {
    justify-content: flex-start !important;
  }
}

/* Tarjetas tambien con la marca declarativa data-dfx-mobile="cards". */
@media (max-width: 767.98px) {
  table[data-dfx-mobile="cards"] thead { display: none; }
  table[data-dfx-mobile="cards"],
  table[data-dfx-mobile="cards"] tbody,
  table[data-dfx-mobile="cards"] tr,
  table[data-dfx-mobile="cards"] td { display: block; width: 100%; }
  table[data-dfx-mobile="cards"] tr:not([data-dfx-empty]) { margin-bottom: .75rem; border: 1px solid var(--bs-border-color, #dee2e6); border-radius: .5rem; padding: .5rem .75rem; }
  table[data-dfx-mobile="cards"] td { border: none; padding: .3rem 0; text-align: right; }
  table[data-dfx-mobile="cards"] td[data-label] { padding-left: 42%; position: relative; min-height: 1.75rem; }
  table[data-dfx-mobile="cards"] td[data-label]::before { content: attr(data-label); position: absolute; left: 0; width: 40%; text-align: left; font-weight: 600; color: var(--bs-secondary-color, #6c757d); }
  table[data-dfx-mobile="cards"] td.td-actions { display: flex; gap: .5rem; padding-top: .5rem; }

  /* Tarjeta seleccionada: el mismo estado que la fila en escritorio. */
  :is(.table-cards-sm, table[data-dfx-mobile="cards"]) tr[aria-selected="true"],
  :is(.table-cards-sm, table[data-dfx-mobile="cards"]) tr.table-active {
    border-color: var(--dfx-primary, var(--bs-primary));
    box-shadow: inset 3px 0 0 var(--dfx-primary, var(--bs-primary));
  }

  /* Valores largos sin romper la tarjeta. */
  :is(.table-cards-sm, table[data-dfx-mobile="cards"]) td[data-label] {
    overflow-wrap: anywhere;
  }
}

/* Estados de carga: la fuente que recarga se atenua sin saltar de alto y
   el boton de envio muestra que el formulario esta trabajando. */
[data-dfx-source][aria-busy="true"]:not(select) {
  opacity: .6;
  transition: opacity 150ms ease;
}

form[data-dfx-busy="true"] [data-dfx-submit],
form[data-dfx-busy="true"] button[type="submit"] {
  position: relative;
  cursor: progress;
}

form[data-dfx-busy="true"] [data-dfx-submit]::after,
form[data-dfx-busy="true"] button[type="submit"]::after {
  content: "";
  display: inline-block;
  width: 1em;
  height: 1em;
  margin-inline-start: .5em;
  vertical-align: -.15em;
  border: .15em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: dfx-ui-busy-spin .75s linear infinite;
}

@keyframes dfx-ui-busy-spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  [data-dfx-source][aria-busy="true"]:not(select) { transition: none; }
  form[data-dfx-busy="true"] [data-dfx-submit]::after,
  form[data-dfx-busy="true"] button[type="submit"]::after { animation-duration: 1.5s; }
}

/* Mensajes de validacion: FormComponent los muestra quitando [hidden] y
   escribiendo el texto. Bootstrap oculta .invalid-feedback salvo junto a
   .is-invalid, asi que sin esta regla el error del Form Wizard no se veia.
   Un error vacio u oculto sigue sin ocupar lugar. */
[data-dfx-error-for]:not([hidden]):not(:empty),
[data-dfx-generated-error-for]:not([hidden]):not(:empty) {
  display: block;
}

[data-dfx-error-for]:empty {
  display: none;
}

/* El borde de error tambien en selects (antes solo .form-control). */
.form-select[data-dfx-invalid="true"],
.form-check-input[data-dfx-invalid="true"] {
  border-color: var(--dfx-danger, var(--bs-danger, #dc3545));
}

.form-select[data-dfx-invalid="true"]:focus {
  box-shadow: 0 0 0 .2rem rgba(220, 53, 69, .25);
}

/* Barra de Guardar/Cancelar de un formulario de pagina: en el telefono
   queda fija al pie de la pantalla, siempre alcanzable, con el fondo de la
   superficie para no transparentar los campos que pasan por detras. El
   espacio inferior evita que tape el ultimo campo. */
@media (max-width: 575.98px) {
  form[data-dfx-form] .dfx-ui-form-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    flex-wrap: nowrap;
    justify-content: stretch !important;
    gap: .5rem;
    margin-top: 1rem;
    padding: .75rem .75rem calc(.75rem + env(safe-area-inset-bottom, 0px));
    background: var(--dfx-surface, var(--bs-body-bg));
    border-top: 1px solid var(--dfx-border, var(--bs-border-color));
  }

  form[data-dfx-form] .dfx-ui-form-actions > .btn {
    flex: 1 1 0;
  }

  /* La tarjeta del formulario recorta sus esquinas con overflow:hidden, que
     anula position:sticky. overflow:clip recorta igual sin crear un
     contenedor de desplazamiento, asi la barra queda pegada al pie. */
  .dfx-ui-card:has(form[data-dfx-form] .dfx-ui-form-actions) {
    overflow: clip;
  }
}

/* Al enfocar un campo (validacion, teclado), su etiqueta queda a la vista. */
.modal-body :is(input, select, textarea),
form[data-dfx-form] :is(input, select, textarea) {
  scroll-margin-top: 2.75rem;
  scroll-margin-bottom: 5rem;
}

/* Selector "Ordenar por" de la vista de tarjetas: solo donde la tabla se
   muestra como tarjetas (cabecera oculta). */
.dfx-ui-mobile-sort {
  display: none;
}

@media (max-width: 767.98px) {
  .dfx-ui-mobile-sort {
    display: block;
    margin: 0 0 .75rem;
  }

  .dfx-ui-mobile-sort .form-label {
    margin-bottom: .25rem;
    font-weight: 600;
  }
}

/* ---------------------------------------------------------------------
 * Componente de imagen (data-dfx-image) y miniaturas de la hoja de detalle.
 * - Las clases de Bootstrap como d-block usan display con !important y le
 *   ganaban al atributo [hidden]; esta regla lo devuelve a su sitio.
 * - Vista previa y recuadro vacio comparten el mismo tamano (4:3) para que
 *   al elegir o quitar la imagen el formulario no salte.
 * - El estado vacio (icono, "Sin imagen" y la ayuda con formatos y tamano)
 *   lo crea dfx-ui.js; los colores salen de los tokens del tema (claro y
 *   oscuro), sin degradados.
 * --------------------------------------------------------------------- */
[data-dfx-image] [hidden],
.dfx-image-thumb[hidden] {
  display: none !important;
}

[data-dfx-image] [data-dfx-image-preview] {
  display: block;
  width: 100%;
  max-width: 15rem;
  height: auto;
  max-height: none !important;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  margin: 0 auto .5rem;
  background: var(--dfx-surface-soft, #f3f7fc);
}

[data-dfx-image] [data-dfx-image-placeholder] {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  box-sizing: border-box;
  width: 100%;
  max-width: 15rem;
  aspect-ratio: 4 / 3;
  margin: 0 auto .5rem;
  padding: .75rem;
  border: 2px dashed color-mix(in srgb, var(--dfx-muted, #566375) 60%, transparent);
  border-radius: .5rem;
  background: var(--dfx-surface-soft, #f3f7fc);
  color: var(--dfx-muted, #566375);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}

[data-dfx-image] [data-dfx-image-placeholder]:hover,
[data-dfx-image].is-dragover [data-dfx-image-placeholder] {
  border-color: var(--dfx-primary, #1f4e8c);
  background: var(--dfx-primary-soft, #eef3f9);
  color: var(--dfx-primary, #1f4e8c);
}

[data-dfx-image] [data-dfx-image-placeholder]:focus-visible {
  outline: 2px solid var(--dfx-focus-ring, var(--dfx-primary, #1f4e8c));
  outline-offset: 2px;
}

[data-dfx-image] .dfx-image-empty-icon {
  width: 2.25rem;
  height: 2.25rem;
  flex: none;
}

[data-dfx-image] .dfx-image-empty-title {
  font-weight: 600;
  font-size: .9375rem;
  line-height: 1.2;
}

[data-dfx-image] .dfx-image-empty-help {
  font-size: .75rem;
  line-height: 1.3;
}

/* Miniatura de la hoja de detalle: clicable para verla grande. */
.dfx-image-thumb {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 7.5rem;
  max-width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--dfx-border, #e2e7ee);
  border-radius: .5rem;
  background: var(--dfx-surface-soft, #f3f7fc);
  color: var(--dfx-muted, #566375);
}

button.dfx-image-thumb {
  cursor: zoom-in;
}

button.dfx-image-thumb:focus-visible {
  outline: 2px solid var(--dfx-focus-ring, var(--dfx-primary, #1f4e8c));
  outline-offset: 2px;
}

.dfx-image-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dfx-image-thumb.is-empty {
  flex-direction: column;
  gap: .25rem;
  border-style: dashed;
  font-size: .75rem;
  cursor: default;
}

.dfx-image-thumb .dfx-image-empty-icon {
  width: 1.75rem;
  height: 1.75rem;
}

/* Imagen en grande (se cierra con Esc, con el fondo o con la X). */
.dfx-image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1090;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(8, 11, 20, .82);
}

.dfx-image-lightbox img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: .5rem;
  object-fit: contain;
  background: var(--dfx-surface, #ffffff);
}

.dfx-image-lightbox-close {
  position: absolute;
  top: .75rem;
  right: .75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
  border-radius: 50%;
  background: var(--dfx-surface, #ffffff);
  color: var(--dfx-text, #1b2430);
  cursor: pointer;
}

.dfx-image-lightbox-close:focus-visible {
  outline: 2px solid var(--dfx-focus-ring, var(--dfx-primary, #1f4e8c));
  outline-offset: 2px;
}

/* ---------------------------------------------------------------------
 * Formulario del modal en cuadricula (.dfx-form-grid, desde la Base 1.0.8).
 * Se usa solo cuando algun campo ocupa varias filas (form_rows) o tiene
 * posicion fija (form_col / form_row); si no, el modal sigue con .row y
 * .col-md-N de Bootstrap.
 * - Celular (< 768 px): una sola columna, en el orden del formulario; el alto
 *   y la posicion se ignoran.
 * - Escritorio: 12 columnas con colocacion densa (grid-auto-flow: row dense):
 *   un campo alto deja que los siguientes llenen las filas a su lado.
 *   .dfx-span-N = ancho, .dfx-start-N = columna de inicio, .dfx-rows-N = alto
 *   y --dfx-row = fila de inicio.
 * - Una celda alta (.dfx-form-cell-tall) hace crecer su textarea o su imagen
 *   hasta llenar la altura.
 * --------------------------------------------------------------------- */
.dfx-form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.dfx-form-cell {
  min-width: 0;
}

@media (min-width: 768px) {
  .dfx-form-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-flow: row dense;
  }

  .dfx-form-cell {
    grid-row-start: var(--dfx-row, auto);
  }

  .dfx-span-1 { grid-column-end: span 1; }
  .dfx-span-2 { grid-column-end: span 2; }
  .dfx-span-3 { grid-column-end: span 3; }
  .dfx-span-4 { grid-column-end: span 4; }
  .dfx-span-5 { grid-column-end: span 5; }
  .dfx-span-6 { grid-column-end: span 6; }
  .dfx-span-7 { grid-column-end: span 7; }
  .dfx-span-8 { grid-column-end: span 8; }
  .dfx-span-9 { grid-column-end: span 9; }
  .dfx-span-10 { grid-column-end: span 10; }
  .dfx-span-11 { grid-column-end: span 11; }
  .dfx-span-12 { grid-column-end: span 12; }
  .dfx-start-1 { grid-column-start: 1; }
  .dfx-start-2 { grid-column-start: 2; }
  .dfx-start-3 { grid-column-start: 3; }
  .dfx-start-4 { grid-column-start: 4; }
  .dfx-start-5 { grid-column-start: 5; }
  .dfx-start-6 { grid-column-start: 6; }
  .dfx-start-7 { grid-column-start: 7; }
  .dfx-start-8 { grid-column-start: 8; }
  .dfx-start-9 { grid-column-start: 9; }
  .dfx-start-10 { grid-column-start: 10; }
  .dfx-start-11 { grid-column-start: 11; }
  .dfx-start-12 { grid-column-start: 12; }
  .dfx-rows-2 { grid-row-end: span 2; }
  .dfx-rows-3 { grid-row-end: span 3; }
  .dfx-rows-4 { grid-row-end: span 4; }
  .dfx-rows-5 { grid-row-end: span 5; }
  .dfx-rows-6 { grid-row-end: span 6; }

  .dfx-form-cell-tall {
    display: flex;
    flex-direction: column;
  }

  .dfx-form-cell-tall > textarea.form-control {
    flex: 1 1 auto;
    height: 100%;
    min-height: 4.5rem;
    resize: none;
  }

  .dfx-form-cell-tall > [data-dfx-image] {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
  }

  .dfx-form-cell-tall [data-dfx-image] [data-dfx-image-preview],
  .dfx-form-cell-tall [data-dfx-image] [data-dfx-image-placeholder] {
    flex: 1 1 9rem;
    height: 0;
    min-height: 9rem;
    max-width: none;
    aspect-ratio: auto;
    object-fit: cover;
    margin: 0 0 .5rem;
  }
}
