/* Ajustes propios de SIGELOT sobre el sistema visual de APAFA. */

.brand-mark img {
    width: 38px;
    height: 38px;
}

.sidebar-project-summary {
    display: flex;
    min-height: 48px;
    align-items: center;
    gap: 12px;
    padding: 8px 11px;
    color: var(--app-sidebar-text);
    background: rgba(255, 255, 255, .04);
    border-radius: 11px;
}

.sidebar-project-summary > span:first-child {
    display: grid;
    width: 26px;
    flex: 0 0 26px;
    place-items: center;
    color: var(--app-accent);
}

.sidebar-project-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-project-copy small {
    color: var(--app-sidebar-muted);
    font-size: .68rem;
}

.sidebar-project-copy strong {
    margin-top: 2px;
    overflow: hidden;
    font-size: .78rem;
    text-overflow: ellipsis;
}

body.sidebar-collapsed .sidebar-project-copy {
    width: 0;
    opacity: 0;
    pointer-events: none;
}

body.sidebar-collapsed .sidebar-project-summary {
    justify-content: center;
    gap: 0;
    padding-inline: 8px;
}

@media (max-width: 991.98px) {
    body.sidebar-collapsed .sidebar-project-copy {
        width: auto;
        opacity: 1;
        pointer-events: auto;
    }

    body.sidebar-collapsed .sidebar-project-summary {
        justify-content: initial;
        gap: 12px;
    }
}

.app-module-view > .module-body > .card-body {
    padding: 0;
    background: transparent;
}

.app-module-view .card-body > .nav-tabs:first-child,
.app-module-view .card-body > .tabs-modern:first-child {
    margin-top: 0;
}

.sigelot-module-heading {
    display: flex;
    min-height: 88px;
    align-items: center;
    gap: 15px;
    margin-bottom: 17px;
    padding: 17px 20px;
    color: var(--app-text);
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-left: 4px solid var(--app-primary);
    border-radius: 15px;
    box-shadow: var(--app-shadow-sm);
}

.sigelot-module-heading-icon {
    display: grid;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    place-items: center;
    color: var(--app-primary);
    background: var(--app-primary-soft);
    border: 1px solid color-mix(in srgb, var(--app-primary) 25%, var(--app-border));
    border-radius: 13px;
    font-size: 1.06rem;
}

.sigelot-module-heading-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.sigelot-module-heading-copy small {
    color: var(--app-primary);
    font-size: .64rem;
    font-weight: 850;
    letter-spacing: .09em;
    text-transform: uppercase;
}

.sigelot-module-heading-copy h2 {
    margin: 3px 0 0;
    color: var(--app-text);
    font-size: clamp(1.02rem, 2vw, 1.28rem);
    font-weight: 850;
    letter-spacing: -.018em;
}

.sigelot-module-heading-copy p {
    margin: 3px 0 0;
    color: var(--app-text-muted);
    font-size: .73rem;
}

@media (max-width: 575.98px) {
    .sigelot-module-heading {
        min-height: 74px;
        gap: 11px;
        margin-bottom: 12px;
        padding: 13px;
    }

    .sigelot-module-heading-icon {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
    }

    .sigelot-module-heading-copy p {
        display: none;
    }
}

/* Los grupos con icono o acción lateral se comportan como un único campo. */
.label-over-border > .input-group {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 10px;
}

.label-over-border > .input-group > .form-control,
.label-over-border > .input-group > .form-select,
.label-over-border > .input-group > .ts-wrapper {
    min-width: 0;
    flex: 1 1 auto;
}

.label-over-border > .input-group > .form-control:first-child,
.label-over-border > .input-group > .form-select:first-child,
.label-over-border > .input-group > .ts-wrapper:first-child .ts-control {
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.label-over-border > .input-group > .ts-wrapper:first-child .ts-control {
    border-right: 0 !important;
}

.input-group-append,
.input-group-prepend {
    display: flex;
    flex: 0 0 auto;
    margin: 0;
}

.label-over-border .input-group-append > .btn,
.label-over-border .input-group-append > .input-group-text,
.label-over-border .input-group > .btn:last-child {
    min-width: 44px;
    min-height: 43px;
    padding: .5rem .72rem;
    color: var(--app-primary);
    background: var(--app-primary-soft);
    border: 1px solid var(--app-field-border);
    border-left-color: color-mix(in srgb, var(--app-primary) 28%, var(--app-field-border));
    border-radius: 0 10px 10px 0 !important;
}

.label-over-border .input-group-append > .btn:hover,
.label-over-border .input-group > .btn:last-child:hover {
    color: #fff;
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.password-field .password-input-shell {
    display: flex;
    flex-wrap: nowrap;
}

.password-input-shell > .form-control {
    min-width: 0;
    border-radius: 10px 0 0 10px !important;
}

.password-input-shell > .btn {
    min-width: 45px;
    color: var(--app-text-muted);
    background: var(--app-surface-muted);
    border: 1px solid var(--app-field-border);
    border-left: 0;
    border-radius: 0 10px 10px 0 !important;
}

/* Bootstrap 4 heredaba un botón .close sin estilos en Bootstrap 5. */
.modal-header .close {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    padding: 0;
    color: var(--app-text-muted);
    background: var(--app-surface-strong);
    border: 1px solid var(--app-border);
    border-radius: 10px;
    font-size: 1.35rem;
    line-height: 1;
}

.modal-header .close:hover {
    color: var(--app-danger);
    background: color-mix(in srgb, var(--app-danger) 9%, var(--app-surface-strong));
    border-color: color-mix(in srgb, var(--app-danger) 30%, var(--app-border));
}

/* Centrado vertical con scroll seguro: evita ventanas pegadas al encabezado. */
.modal:not(.modal-fullscreen) .modal-dialog:not(.modal-fullscreen) {
    display: flex;
    min-height: calc(100% - 3.5rem);
    align-items: center;
}

.modal:not(.modal-fullscreen) .modal-content {
    max-height: calc(100dvh - 3.5rem);
}

.modal:not(.modal-fullscreen) .modal-body {
    overflow-y: auto;
}

/* El formulario del perfil envuelve el body y el footer. Debe participar en
   la columna flexible del modal para que el body pueda reducirse y desplazarse. */
#m_perfil_usuario .modal-content {
    overflow: hidden;
}

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

#m_perfil_usuario .modal-body {
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

#m_perfil_usuario .modal-footer {
    flex: 0 0 auto;
}

.modal-dialog.was-dragged {
    min-height: 0 !important;
    align-items: initial !important;
}

@media (max-width: 575.98px) {
    .modal:not(.modal-fullscreen) .modal-dialog:not(.modal-fullscreen) {
        min-height: calc(100% - 24px);
    }

    .modal:not(.modal-fullscreen) .modal-content {
        max-height: calc(100dvh - 24px);
    }
}

.sigelot-fab-source {
    display: none !important;
}

.sigelot-generated-fab .fab-btn {
    color: #fff;
    background: var(--app-primary);
    border: 1px solid color-mix(in srgb, var(--app-primary) 72%, #fff);
}

.sigelot-generated-fab .fab-item:nth-child(2n) .fab-btn {
    background: var(--app-info);
}

.sigelot-generated-fab .fab-item:nth-child(3n) .fab-btn {
    background: var(--app-success);
}

.company-preview {
    display: grid;
    min-height: 220px;
    place-items: center;
    overflow: hidden;
    padding: 20px;
    background: var(--app-surface-muted);
    border: 1px dashed var(--app-border-strong);
    border-radius: 15px;
}

.company-preview img {
    width: 100%;
    max-width: 260px;
    max-height: 190px;
    object-fit: contain;
}

.btn-default {
    color: var(--app-text);
    background: var(--app-surface-muted);
    border-color: var(--app-border-strong);
}

.btn-app {
    color: var(--app-primary);
    background: var(--app-primary-soft);
    border: 1px solid color-mix(in srgb, var(--app-primary) 30%, var(--app-border));
}

.text-maroon { color: #a33668 !important; }
.text-indigo { color: #6254b8 !important; }
.text-orange { color: #d36b22 !important; }
.bg-maroon { color: #fff !important; background: #8e315c !important; }
.bg-indigo { color: #fff !important; background: #6254b8 !important; }

.bootstrap-switch {
    max-width: 100%;
    border-color: var(--app-border-strong) !important;
    border-radius: 9px !important;
}

.bootstrap-switch .bootstrap-switch-label {
    color: var(--app-text);
    background: var(--app-surface-muted) !important;
}

/* Dashboard ampliado conservando la composición del panel de APAFA. */
.dashboard-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.dashboard-toolbar .form-select {
    width: auto;
    min-width: 118px;
    color: #eef3ff;
    background-color: #2d416c;
    border-color: #405784;
}

.dashboard-toolbar .btn {
    min-height: 38px;
    color: #eef3ff;
    background: #2d416c;
    border-color: #405784;
}

.dashboard-metrics.dashboard-metrics-six {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dashboard-metric.metric-cash { --metric-color: var(--app-primary); }
.dashboard-metric.metric-sales { --metric-color: var(--app-success); }
.dashboard-metric.metric-receivable { --metric-color: var(--app-accent); }
.dashboard-metric.metric-commission { --metric-color: #7659bd; }
.dashboard-metric.metric-lots { --metric-color: var(--app-info); }
.dashboard-metric.metric-clients { --metric-color: #a15d79; }

.dashboard-chart-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(300px, .7fr);
    gap: 14px;
}

.dashboard-chart-shell {
    position: relative;
    min-height: 320px;
    padding: 14px 16px 17px;
}

.dashboard-chart-shell canvas {
    width: 100% !important;
    height: 290px !important;
}

.dashboard-status-legend {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 0 16px 16px;
}

.dashboard-status-legend > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    color: var(--app-text-muted);
    background: var(--app-surface-muted);
    border: 1px solid var(--app-border);
    border-radius: 9px;
    font-size: .68rem;
}

.dashboard-status-legend strong {
    color: var(--app-text);
    font-size: .82rem;
}

.dashboard-operations-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
    gap: 14px;
}

.dashboard-due-list {
    max-height: 335px;
    overflow-y: auto;
}

.dashboard-due-item {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-bottom: 1px solid var(--app-border);
}

.dashboard-due-item:last-child {
    border-bottom: 0;
}

.dashboard-due-icon {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    color: var(--app-accent);
    background: var(--app-accent-soft);
    border-radius: 10px;
}

.dashboard-due-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.dashboard-due-copy strong,
.dashboard-due-copy small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-due-copy strong {
    color: var(--app-text);
    font-size: .76rem;
}

.dashboard-due-copy small {
    margin-top: 3px;
    color: var(--app-text-muted);
    font-size: .64rem;
}

.dashboard-due-amount {
    text-align: right;
}

.dashboard-due-amount strong,
.dashboard-due-amount small {
    display: block;
    white-space: nowrap;
}

.dashboard-due-amount strong {
    color: var(--app-danger);
    font-size: .75rem;
}

.dashboard-due-amount small {
    margin-top: 2px;
    color: var(--app-text-muted);
    font-size: .61rem;
}

.dashboard-recent-sales .table-responsive {
    border: 0 !important;
    border-radius: 0;
    box-shadow: none;
}

.dashboard-recent-sales .table > thead > tr > th {
    padding-block: .68rem !important;
    font-size: .62rem;
}

.dashboard-recent-sales .table > tbody > tr > td {
    padding: .7rem .65rem;
    font-size: .72rem;
    vertical-align: middle;
}

.dashboard-empty-state {
    display: grid;
    min-height: 150px;
    place-items: center;
    align-content: center;
    gap: 7px;
    padding: 22px;
    color: var(--app-text-muted);
    text-align: center;
}

.dashboard-empty-state i {
    color: var(--app-success);
    font-size: 1.35rem;
}

@media (max-width: 1199.98px) {
    .dashboard-metrics.dashboard-metrics-six {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-chart-grid,
    .dashboard-operations-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767.98px) {
    .dashboard-toolbar {
        justify-content: flex-start;
    }

    .dashboard-toolbar .form-select {
        flex: 1;
    }
}

@media (max-width: 575.98px) {
    .dashboard-metrics.dashboard-metrics-six {
        grid-template-columns: 1fr;
    }

    .dashboard-chart-shell {
        min-height: 270px;
        padding-inline: 8px;
    }

    .dashboard-chart-shell canvas {
        height: 245px !important;
    }

    .dashboard-due-item {
        grid-template-columns: 34px minmax(0, 1fr);
    }

    .dashboard-due-amount {
        grid-column: 2;
        text-align: left;
    }
}

/* ==========================================================
   Componentes de datos y formularios alineados con APAFA
   ========================================================== */

.app-module-view .table-responsive.table-shell {
    width: 100%;
    max-width: 100%;
    padding: 12px;
    overflow: auto;
    background: var(--app-surface);
    border: 1px solid var(--app-table-line) !important;
    border-radius: 14px;
    box-shadow: 0 1px 0 rgba(23, 32, 51, .025);
}

.app-module-view .table-modern,
.app-module-view table.dataTable {
    width: 100% !important;
    margin: 0 !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
}

.app-module-view .table-modern > thead > tr > th,
.app-module-view table.dataTable > thead > tr > th {
    padding: .82rem .7rem !important;
    color: var(--app-table-head-text) !important;
    text-align: center !important;
    vertical-align: middle !important;
    background: var(--app-table-head) !important;
    border-width: 0 1px 2px 0 !important;
    border-color: color-mix(in srgb, var(--app-table-head-text) 12%, transparent) !important;
    border-bottom-color: color-mix(in srgb, var(--app-primary) 42%, var(--app-table-line)) !important;
    font-size: .69rem !important;
    font-weight: 800 !important;
    letter-spacing: .045em;
    line-height: 1.2;
    text-transform: uppercase;
}

.app-module-view .table-modern > tbody > tr > td,
.app-module-view table.dataTable > tbody > tr > td {
    padding: .72rem .68rem !important;
    color: var(--app-text);
    vertical-align: middle !important;
    border-color: var(--app-table-line) !important;
    border-width: 0 0 1px !important;
    font-size: .75rem;
}

.app-module-view .table-modern > tbody > tr:nth-of-type(odd) > *,
.app-module-view table.dataTable.stripe > tbody > tr:nth-child(odd) > *,
.app-module-view table.dataTable.display > tbody > tr:nth-child(odd) > * {
    background: var(--app-table-row-alt) !important;
    box-shadow: none !important;
}

.app-module-view .table-modern > tbody > tr:hover > *,
.app-module-view table.dataTable.hover > tbody > tr:hover > *,
.app-module-view table.dataTable.display > tbody > tr:hover > * {
    background: var(--app-primary-soft) !important;
    box-shadow: none !important;
}

.app-module-view .table-modern > tbody > tr:hover > td:first-child,
.app-module-view table.dataTable > tbody > tr:hover > td:first-child {
    box-shadow: inset 3px 0 0 var(--app-primary) !important;
}

.app-module-view div.dt-container .dt-layout-row:first-child,
.app-module-view .dataTables_wrapper > .row:first-child {
    min-height: 52px;
    align-items: center;
    margin: 0 0 10px !important;
    padding: 9px 11px !important;
    background: var(--app-surface-muted);
    border: 1px solid var(--app-border);
    border-radius: 11px;
}

.app-module-view div.dt-container .dt-layout-row:last-child,
.app-module-view .dataTables_wrapper > .row:last-child {
    align-items: center;
    margin: 10px 0 0 !important;
    padding: 8px 2px 0;
    border-top: 1px solid var(--app-border);
}

.app-module-view div.dt-container .dt-search input,
.app-module-view div.dt-container .dt-length select,
.app-module-view .dataTables_wrapper .dataTables_filter input,
.app-module-view .dataTables_wrapper .dataTables_length select {
    min-height: 36px;
    color: var(--app-text) !important;
    background: var(--app-surface-strong) !important;
    border: 1px solid var(--app-field-border) !important;
    border-radius: 9px !important;
}

/* Superficie, espaciado y estados coherentes para todos los formularios. */
.form-modern .row {
    --bs-gutter-x: 1rem;
}

.form-modern .form-field {
    min-width: 0;
    margin-bottom: 1.05rem;
}

.form-modern .form-control,
.form-modern .form-select,
.form-modern .ts-control {
    min-height: 43px;
    font-size: .82rem;
}

.form-modern textarea.form-control {
    min-height: 96px;
    resize: vertical;
}

.form-modern .form-text,
.form-modern .text-muted {
    color: var(--app-text-muted) !important;
    font-size: .69rem;
}

.form-modern .form-control:required:not(:placeholder-shown):valid,
.form-modern .form-select:required:valid {
    border-color: color-mix(in srgb, var(--app-success) 54%, var(--app-field-border));
}

.modal .form-modern > .row,
.modal .form-modern > .card-body,
.modal .form-modern > fieldset {
    min-width: 0;
}

.modal-body > .card-body {
    padding: 4px 2px;
}

.modal .form-actions,
.form-modern + .form-actions {
    gap: 8px;
    padding: 14px 18px;
    background: var(--app-surface-muted);
    border-top: 1px solid var(--app-border);
}

.form-actions .btn,
.sales-form-actions .btn {
    min-height: 40px;
    padding-inline: 16px;
    border-radius: 9px;
    font-weight: 750;
}

/* Campo compuesto: el control y el botón conservan una sola geometría. */
.label-over-border.has-input-action {
    isolation: isolate;
    width: 100%;
}

.label-over-border.has-input-action > label {
    z-index: 8;
    max-width: calc(100% - 70px);
    background: var(--field-label-bg, var(--app-surface)) !important;
}

.label-over-border > .compound-control {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    overflow: visible;
}

.label-over-border > .compound-control > .form-control,
.label-over-border > .compound-control > .form-select,
.label-over-border > .compound-control > .ts-wrapper {
    width: 100% !important;
    min-width: 0;
    grid-column: 1;
}

.label-over-border > .compound-control > .input-group-append,
.label-over-border > .compound-control > .input-group-prepend,
.label-over-border > .compound-control > .btn {
    grid-column: 2;
}

.label-over-border > .compound-control > .ts-wrapper .ts-control,
.label-over-border > .compound-control > .form-control,
.label-over-border > .compound-control > .form-select {
    height: 43px !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
}

.label-over-border > .compound-control .input-group-append > .btn,
.label-over-border > .compound-control > .btn:last-child {
    width: 46px;
    height: 43px;
    min-width: 46px;
    min-height: 43px;
    margin-left: -1px;
    padding: 0;
    border-radius: 0 10px 10px 0 !important;
}

.label-over-border.has-input-action:focus-within > .compound-control {
    border-radius: 10px;
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--app-primary) 14%, transparent);
}

.label-over-border.has-input-action:focus-within .ts-control,
.label-over-border.has-input-action:focus-within .form-control,
.label-over-border.has-input-action:focus-within .form-select {
    box-shadow: none !important;
}

/* Caja y comisiones */
.cash-selector.cash-selector-five {
    grid-template-columns: repeat(5, minmax(180px, 1fr));
    overflow-x: auto;
    padding: 2px 2px 8px;
    scrollbar-width: thin;
}

.cash-selector-five .cash-selector-card {
    min-width: 180px;
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    padding: 13px;
}

.cash-selector-card.cash-commissions { --cash-color: var(--app-purple); }
.cash-selector-card.cash-refunds { --cash-color: var(--app-accent); }

.cash-selector-five .cash-selector-card .badge {
    grid-column: 1 / -1;
    width: 100%;
    padding: 6px 9px;
    text-align: right;
    font-size: .71rem;
}

.finance-toolbar {
    display: grid;
    grid-template-columns: auto repeat(3, minmax(150px, 1fr)) auto;
    align-items: end;
    gap: 10px;
    margin-bottom: 15px;
    padding: 13px;
    background: var(--app-surface-muted);
    border: 1px solid var(--app-border);
    border-radius: 13px;
}

.finance-toolbar .finance-filter {
    margin: 9px 0 0;
}

.finance-toolbar > .btn {
    min-height: 43px;
    white-space: nowrap;
}

.lot-filter-toolbar {
    display: flex;
    justify-content: flex-end;
    margin: 10px 0 0;
}

.lot-filter-toolbar .form-group {
    width: min(100%, 280px);
}

.commission-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.commission-summary-item {
    --commission-color: var(--app-primary);
    display: grid;
    min-width: 0;
    grid-template-columns: 38px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    background: linear-gradient(135deg,
        color-mix(in srgb, var(--commission-color) 11%, var(--app-surface)),
        var(--app-surface));
    border: 1px solid color-mix(in srgb, var(--commission-color) 28%, var(--app-border));
    border-radius: 13px;
    box-shadow: var(--app-shadow-sm);
}

.commission-summary-generated { --commission-color: var(--app-primary); }
.commission-summary-paid { --commission-color: var(--app-success); }
.commission-summary-pending { --commission-color: var(--app-accent); }

.commission-summary-icon {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    color: var(--commission-color);
    background: color-mix(in srgb, var(--commission-color) 14%, var(--app-surface-strong));
    border-radius: 11px;
    font-size: .9rem;
}

.commission-summary-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.commission-summary-copy small {
    overflow: hidden;
    color: var(--app-text-muted);
    font-size: clamp(.56rem, .9vw, .68rem);
    font-weight: 750;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.commission-summary-copy strong {
    overflow: hidden;
    margin-top: 3px;
    color: var(--commission-color) !important;
    font-size: clamp(.76rem, 1.55vw, 1.05rem);
    font-weight: 850;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 575.98px) {
    .commission-summary {
        gap: 5px;
    }

    .commission-summary-item {
        grid-template-columns: 1fr;
        gap: 5px;
        padding: 9px 7px;
        text-align: center;
    }

    .commission-summary-icon {
        width: 30px;
        height: 30px;
        margin-inline: auto;
        border-radius: 9px;
        font-size: .76rem;
    }
}

/* Área de alta de ventas. */
.sales-workspace {
    padding: 0;
}

.sales-workspace-intro {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 4px 0 12px;
    padding: 13px 15px;
    color: var(--app-text);
    background: linear-gradient(135deg, var(--app-primary-soft), var(--app-surface));
    border: 1px solid color-mix(in srgb, var(--app-primary) 24%, var(--app-border));
    border-radius: 13px;
}

.sales-intro-copy {
    flex: 1 1 auto;
}

.sales-process {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
    margin-left: auto;
}

.sales-process > span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 9px;
    color: var(--app-text-muted);
    background: color-mix(in srgb, var(--app-surface-strong) 82%, transparent);
    border: 1px solid var(--app-border);
    border-radius: 999px;
    font-size: .65rem;
    font-weight: 750;
    white-space: nowrap;
}

.sales-process b {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    color: var(--app-primary);
    background: var(--app-primary-soft);
    border-radius: 50%;
    font-size: .62rem;
}

.sales-process > .is-active {
    color: #fff;
    background: var(--app-primary);
    border-color: var(--app-primary);
}

.sales-process > .is-active b {
    color: var(--app-primary);
    background: #fff;
}

.sales-process > .is-complete {
    color: var(--app-success);
    background: color-mix(in srgb, var(--app-success) 9%, var(--app-surface-strong));
    border-color: color-mix(in srgb, var(--app-success) 30%, var(--app-border));
}

.sales-process > .is-complete b {
    color: #fff;
    background: var(--app-success);
}

.sales-workspace-intro > span {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    color: #fff;
    background: var(--app-primary);
    border-radius: 11px;
}

.sales-workspace-intro > .sales-intro-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.sales-workspace-intro strong {
    font-size: .87rem;
    font-weight: 800;
}

.sales-workspace-intro small {
    margin-top: 2px;
    color: var(--app-text-muted);
    font-size: .7rem;
}

.sales-entry-form {
    padding: 16px 16px 6px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--app-shadow-sm);
}

.sales-section-heading,
.sales-cart-heading {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sales-section-heading {
    margin-bottom: -2px;
    padding-bottom: 9px;
    border-bottom: 1px solid var(--app-border);
}

.sales-section-heading-payment {
    margin-top: 5px;
}

.sales-section-heading > span,
.sales-cart-heading > span {
    display: grid;
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    place-items: center;
    color: var(--app-primary);
    background: var(--app-primary-soft);
    border-radius: 9px;
    font-size: .78rem;
}

.sales-section-heading > div,
.sales-cart-heading > div {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.sales-section-heading strong,
.sales-cart-heading strong {
    color: var(--app-text);
    font-size: .76rem;
    font-weight: 850;
}

.sales-section-heading small,
.sales-cart-heading small {
    margin-top: 1px;
    color: var(--app-text-muted);
    font-size: .65rem;
}

.sales-cart-heading {
    margin-top: 15px;
    padding: 11px 13px;
    background: var(--app-surface-muted);
    border: 1px solid var(--app-border);
    border-radius: 12px 12px 0 0;
}

.sales-entry-form .form-field,
.sales-entry-form .form-field.has-tom-select,
.sales-entry-form .form-field:has(.ts-wrapper) {
    margin-top: .4rem;
}

.sales-form-actions {
    display: flex;
    min-height: 58px;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 3px;
    padding-top: 12px;
    border-top: 1px solid var(--app-border);
}

.sales-cart-shell {
    margin-top: 0;
    border-top-left-radius: 0 !important;
    border-top-right-radius: 0 !important;
}

#carrito_cards > .card {
    margin-top: 10px;
    border-left: 4px solid var(--app-primary);
}

/* Visor de reportes con la experiencia de APAFA. */
.report-dialog {
    width: min(1180px, calc(100vw - 28px));
    max-width: none !important;
}

.report-modal-content {
    height: min(860px, calc(100dvh - 38px));
    overflow: hidden;
}

.report-modal-content .modal-header {
    flex: 0 0 auto;
}

.report-modal-body {
    min-height: 0;
    padding: 0 !important;
    overflow: hidden !important;
    background: var(--app-surface-muted);
}

.report-frame-shell {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 520px;
}

.report-frame {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 520px;
    background: var(--app-surface-muted);
    border: 0;
}

.report-frame-shell.is-ready .pdf-report-loader,
.report-frame-shell.has-error .pdf-report-loader {
    display: none !important;
}

@media (max-width: 1199.98px) {
    .cash-selector.cash-selector-five {
        grid-template-columns: repeat(3, minmax(190px, 1fr));
    }

    .finance-toolbar {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .finance-toolbar > .btn:first-child,
    .finance-toolbar > .btn:last-child {
        width: 100%;
    }
}

@media (max-width: 767.98px) {
    .app-module-view .table-responsive.table-shell {
        padding: 8px;
        border-radius: 12px;
    }

    .cash-selector.cash-selector-five {
        display: flex;
        gap: 10px;
        scroll-snap-type: x proximity;
    }

    .cash-selector-five .cash-selector-card {
        width: min(82vw, 270px);
        flex: 0 0 min(82vw, 270px);
        scroll-snap-align: start;
    }

    .finance-toolbar {
        grid-template-columns: 1fr 1fr;
    }

    .finance-toolbar > .btn,
    .finance-toolbar .finance-filter:last-of-type {
        grid-column: 1 / -1;
    }

    .sales-entry-form {
        padding: 13px 12px 4px;
    }

    .sales-process {
        display: none;
    }

    .report-dialog {
        width: calc(100vw - 16px);
        margin: 8px auto;
    }

    .report-modal-content {
        height: calc(100dvh - 16px);
    }

    .report-frame-shell,
    .report-frame {
        min-height: 420px;
    }
}

@media (max-width: 575.98px) {
    .tabs-modern .nav-link {
        min-height: 38px !important;
        padding: 8px 10px !important;
    }

    .finance-toolbar {
        grid-template-columns: 1fr;
    }

    .finance-toolbar > *,
    .finance-toolbar .finance-filter:last-of-type {
        grid-column: 1;
    }

    .sales-workspace-intro small {
        display: none;
    }

    .sales-form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .sales-form-actions .btn {
        width: 100%;
    }
}

/* ==========================================================
   Revisión 4.0.2: densidad, exportación, tabs y formularios
   ========================================================== */

/* Las tablas conservan ancho natural y compactan columnas de datos breves. */
.app-module-view .table-modern > thead > tr > th,
.app-module-view table.dataTable > thead > tr > th {
    padding: .68rem .56rem !important;
}

.app-module-view .table-modern > tbody > tr > td,
.app-module-view table.dataTable > tbody > tr > td {
    min-width: 0 !important;
    padding: .6rem .56rem !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
}

.app-module-view .table-modern .col-index,
.app-module-view table.dataTable .col-index {
    width: 52px !important;
    min-width: 46px !important;
    max-width: 62px !important;
    text-align: center !important;
    white-space: nowrap !important;
}

.app-module-view .table-modern .col-date,
.app-module-view table.dataTable .col-date {
    width: 106px !important;
    min-width: 94px !important;
    max-width: 118px !important;
    text-align: center !important;
    white-space: nowrap !important;
}

.app-module-view .table-modern .col-status,
.app-module-view table.dataTable .col-status {
    width: 112px !important;
    min-width: 92px !important;
    max-width: 132px !important;
    text-align: center !important;
}

.app-module-view .table-modern .col-amount,
.app-module-view table.dataTable .col-amount {
    width: 112px !important;
    min-width: 94px !important;
    max-width: 128px !important;
    text-align: right !important;
    white-space: nowrap !important;
}

.app-module-view .table-modern th.col-amount,
.app-module-view table.dataTable th.col-amount {
    text-align: center !important;
}

.app-module-view .table-modern .col-identity,
.app-module-view table.dataTable .col-identity {
    width: 118px !important;
    min-width: 98px !important;
    max-width: 138px !important;
    white-space: nowrap !important;
}

.app-module-view .table-modern .col-actions,
.app-module-view table.dataTable .col-actions {
    width: 76px !important;
    min-width: 56px !important;
    max-width: 104px !important;
    text-align: center !important;
    white-space: nowrap !important;
}

.sig-column-filters {
    display: none !important;
}

/* Solo Excel y PDF, reconocibles por color y alineados a la izquierda. */
.app-module-view .dt-buttons,
.app-module-view .dataTables_wrapper .dt-buttons {
    display: flex !important;
    width: 100%;
    align-items: center;
    justify-content: flex-start !important;
    gap: 7px !important;
    margin: 0 0 9px !important;
}

.app-module-view div.dt-container .dt-layout-row:has(.dt-buttons) {
    justify-content: flex-start !important;
    margin: -2px 0 10px !important;
    padding: 0 !important;
}

.app-module-view div.dt-container .dt-layout-row:has(.dt-buttons) > .dt-layout-start {
    width: 100%;
    justify-content: flex-start !important;
    margin: 0 !important;
}

.app-module-view .dt-buttons .btn-export,
.app-module-view .dataTables_wrapper .btn-export {
    display: inline-flex !important;
    width: 36px !important;
    min-width: 36px !important;
    height: 34px !important;
    min-height: 34px !important;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0 !important;
    color: #fff !important;
    border: 0 !important;
    border-radius: 9px !important;
    box-shadow: 0 5px 12px rgba(24, 38, 64, .12);
    font-size: .72rem !important;
    font-weight: 800;
}

.app-module-view .dt-buttons .btn-export i,
.app-module-view .dataTables_wrapper .btn-export i {
    margin: 0 !important;
    font-size: .9rem;
}

.app-module-view .dt-buttons .btn-export > span,
.app-module-view .dataTables_wrapper .btn-export > span {
    display: inline-flex !important;
    align-items: center;
    gap: 7px;
}

.app-module-view .dt-buttons .export-excel,
.app-module-view .dataTables_wrapper .export-excel {
    background: #198754 !important;
}

.app-module-view .dt-buttons .export-pdf,
.app-module-view .dataTables_wrapper .export-pdf {
    background: #d9485f !important;
}

.app-module-view .dt-buttons .btn-export:hover {
    color: #fff !important;
    filter: brightness(1.08);
    transform: translateY(-1px);
}

/* Tabs: mismo componente segmentado de APAFA, sin colores heredados por enlace. */
.app-module-view .tabs-modern {
    position: sticky;
    top: calc(var(--topbar-height) + 10px);
    z-index: 1015;
    display: flex;
    width: 100%;
    gap: 6px !important;
    margin: 0 0 20px !important;
    padding: 7px !important;
    overflow-x: auto;
    background: var(--app-surface);
    border: 1px solid var(--app-border) !important;
    border-radius: 14px;
    box-shadow: var(--app-shadow-sm);
    scrollbar-width: thin;
}

.app-module-view .tabs-modern .nav-item {
    flex: 0 0 auto;
}

.app-module-view .tabs-modern .nav-link {
    display: inline-flex;
    min-height: 40px !important;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 14px !important;
    color: var(--app-text-muted) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 9px !important;
    box-shadow: none !important;
    font-size: .8rem;
    font-weight: 750;
    white-space: nowrap;
}

.app-module-view .tabs-modern .nav-link:hover {
    color: var(--app-text) !important;
    background: var(--app-surface-muted) !important;
}

.app-module-view .tabs-modern .nav-link.active {
    color: #fff !important;
    background: var(--app-primary) !important;
    box-shadow: 0 6px 15px color-mix(in srgb, var(--app-primary) 24%, transparent) !important;
}

.app-module-view .tabs-modern .nav-link.active i {
    color: #fff !important;
}

/* Caja usa tarjetas horizontales como APAFA; nunca se apilan en una sola columna. */
.app-module-caja .cash-selector.cash-selector-five {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(230px, 1fr)) !important;
    gap: 14px !important;
    overflow: visible;
    padding: 0;
}

.app-module-caja .cash-selector-five .cash-selector-card {
    display: grid !important;
    width: 100%;
    min-width: 0;
    min-height: 92px;
    grid-template-columns: 46px minmax(0, 1fr) auto !important;
    align-items: center;
    gap: 12px;
    padding: 15px;
}

.app-module-caja .cash-selector-five .cash-selector-card .badge {
    width: auto;
    min-width: 76px;
    grid-column: auto !important;
    padding: 6px 9px;
    text-align: center;
}

/* Búsqueda explícita en Tom Select y desplegable siempre debajo del campo. */
body > .ts-dropdown {
    z-index: 1095 !important;
    margin: 0 !important;
    overflow: hidden;
    border: 1px solid var(--app-border-strong) !important;
    border-radius: 10px !important;
    box-shadow: 0 14px 30px rgba(15, 29, 52, .22) !important;
}

.ts-dropdown.plugin-dropdown_input .dropdown-input,
.ts-dropdown .dropdown-input {
    display: block !important;
    width: calc(100% - 16px) !important;
    min-height: 38px;
    margin: 8px !important;
    padding: 7px 10px !important;
    color: var(--app-text) !important;
    background: var(--app-surface-strong) !important;
    border: 1px solid var(--app-field-border) !important;
    border-radius: 8px !important;
    box-shadow: none !important;
    font-size: .8rem;
}

.ts-dropdown.plugin-dropdown_input .dropdown-input:focus,
.ts-dropdown .dropdown-input:focus {
    border-color: var(--app-primary) !important;
    outline: 0;
    box-shadow: 0 0 0 .18rem color-mix(in srgb, var(--app-primary) 14%, transparent) !important;
}

.ts-dropdown .ts-dropdown-content {
    overscroll-behavior: contain;
}

.ts-wrapper:not(.disabled) .ts-control {
    cursor: text !important;
}

/* Formularios con superficies y jerarquía uniforme. */
.modal-form-modern .modal-body {
    padding: 18px;
    background: var(--app-surface-muted);
}

.form-modern.form-modal-surface,
.form-modern.form-page-surface {
    width: 100%;
    min-width: 0;
    padding: 17px 17px 5px;
    background: var(--app-surface);
    border: 1px solid var(--app-border);
    border-radius: 14px;
    box-shadow: var(--app-shadow-sm);
}

.form-modern .form-field {
    margin-top: .35rem;
    margin-bottom: 1rem;
}

/* Los formularios operativos comparten la misma superficie visual de los
   formularios de pago: tarjeta clara, borde suave y campos bien agrupados. */
.form-modern.sig-standard-form:not(.sig-pago-form) {
    position: relative;
    width: 100%;
    min-width: 0;
    padding: 17px 18px 6px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.form-modern.sig-standard-form:not(.sig-pago-form)::before {
    position: absolute;
    top: -1px;
    right: 18px;
    left: 18px;
    height: 3px;
    content: "";
    background: linear-gradient(90deg, var(--app-primary), color-mix(in srgb, var(--app-primary) 30%, transparent));
    border-radius: 0 0 3px 3px;
    opacity: .75;
}

.form-modern.sig-standard-form .sig-form-header {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 0 0 17px;
    padding: 0 0 13px;
    border-bottom: 1px dashed #cbd5e1;
}

.form-modern.sig-standard-form .sig-form-header-icon {
    display: grid;
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--app-primary), color-mix(in srgb, var(--app-primary) 68%, #0f172a));
    border-radius: 10px;
    box-shadow: 0 6px 14px color-mix(in srgb, var(--app-primary) 22%, transparent);
}

.form-modern.sig-standard-form .sig-form-header-copy {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.form-modern.sig-standard-form .sig-form-header-copy strong {
    color: var(--app-text);
    font-size: .86rem;
    font-weight: 850;
    line-height: 1.25;
}

.form-modern.sig-standard-form .sig-form-header-copy small {
    margin-top: 2px;
    color: var(--app-text-muted);
    font-size: .69rem;
    line-height: 1.35;
}

.form-modern.sig-standard-form .form-group > label {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--app-text-muted);
    font-weight: 750;
}

.form-modern.sig-standard-form .form-group > label .sig-field-ico {
    width: 14px;
    color: #94a3b8;
    text-align: center;
    font-size: .9em;
}

.form-modern.sig-standard-form .sig-form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 9px;
    margin-top: 5px;
    padding-top: 11px;
    border-top: 1px dashed #cbd5e1;
}

.form-modern.sig-standard-form .btn[type="submit"] {
    min-height: 40px;
    padding-inline: 17px;
    border-radius: 9px;
    font-weight: 750;
}

[data-theme="dark"] .form-modern.sig-standard-form:not(.sig-pago-form) {
    background: rgba(255, 255, 255, .03);
    border-color: rgba(255, 255, 255, .09);
    box-shadow: none;
}

[data-theme="dark"] .form-modern.sig-standard-form .sig-form-header,
[data-theme="dark"] .form-modern.sig-standard-form .sig-form-actions {
    border-color: rgba(255, 255, 255, .12);
}

.sig-table-actions {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 6px;
    min-width: max-content;
    white-space: nowrap;
}

.table tbody td .sig-table-actions .sig-action-button {
    display: inline-grid !important;
    width: 34px;
    min-width: 34px;
    height: 34px;
    min-height: 34px;
    place-items: center;
    padding: 0 !important;
    border-radius: 9px !important;
    box-shadow: 0 3px 8px rgba(15, 23, 42, .1);
    transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}

.table tbody td .sig-table-actions .sig-action-button:hover,
.table tbody td .sig-table-actions .sig-action-button:focus-visible {
    z-index: 1;
    filter: brightness(.98);
    transform: translateY(-1px);
    box-shadow: 0 6px 13px rgba(15, 23, 42, .16);
}

#tb_comisionesPagar.table-natural-width .col-actions,
#tb_fraccionesCom.table-natural-width .col-actions {
    width: 1% !important;
    min-width: 126px !important;
}

@media (max-width: 575.98px) {
    .form-modern.sig-standard-form .sig-form-header-copy small {
        display: none;
    }

    .form-modern.sig-standard-form:not(.sig-pago-form) {
        padding-inline: 13px;
    }
}

.form-modern .label-over-border > label {
    color: var(--app-text-muted);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .01em;
}

.form-modern .form-control,
.form-modern .form-select,
.form-modern .ts-control {
    min-height: 44px !important;
    color: var(--app-text) !important;
    background-color: var(--app-surface-strong) !important;
    border: 1px solid var(--app-field-border) !important;
    border-radius: 10px !important;
    box-shadow: inset 0 1px 1px rgba(18, 31, 52, .025);
}

.form-modern .form-control:hover,
.form-modern .form-select:hover,
.form-modern .ts-control:hover {
    border-color: color-mix(in srgb, var(--app-primary) 40%, var(--app-field-border)) !important;
}

.form-modern .form-control:focus,
.form-modern .form-select:focus,
.form-modern .ts-wrapper.focus .ts-control {
    border-color: var(--app-primary) !important;
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--app-primary) 14%, transparent) !important;
}

.form-modern textarea.form-control {
    min-height: 104px !important;
    padding-top: 12px;
    line-height: 1.45;
}

.form-modern input[type="file"].form-control {
    padding: .42rem .55rem;
}

.form-modern .custom-control,
.form-modern .form-check {
    min-height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    background: var(--app-surface-muted);
    border: 1px solid var(--app-border);
    border-radius: 10px;
}

/* Alinea el estado de la mora con el campo de porcentaje. ui-polish añade
   .form-field y deja el margen efectivo del input en .35rem. */
#frm_configMora .mora-switch-column {
    align-items: flex-start !important;
}

#frm_configMora .mora-switch-control {
    width: 100%;
    margin-top: .35rem !important;
}

@media (max-width: 767.98px) {
    #frm_configMora .mora-switch-control {
        margin-top: 0 !important;
    }
}

.modal-form-modern .modal-footer.form-actions {
    gap: 8px;
    padding: 13px 18px;
    background: var(--app-surface);
    border-top: 1px solid var(--app-border);
}

@media (max-width: 1199.98px) {
    .app-module-caja .cash-selector.cash-selector-five {
        grid-template-columns: repeat(2, minmax(230px, 1fr)) !important;
    }
}

@media (max-width: 767.98px) {
    .app-module-caja .cash-selector.cash-selector-five {
        display: flex !important;
        gap: 10px !important;
        overflow-x: auto;
        padding: 2px 2px 10px;
        scroll-snap-type: x mandatory;
        scrollbar-width: thin;
    }

    .app-module-caja .cash-selector-five .cash-selector-card {
        width: min(84vw, 310px);
        min-width: min(84vw, 310px);
        flex: 0 0 min(84vw, 310px);
        scroll-snap-align: start;
    }

    .app-module-view .tabs-modern {
        top: calc(var(--topbar-height) + 5px);
        margin-bottom: 14px !important;
        padding: 5px !important;
    }

    .form-modern.form-modal-surface,
    .form-modern.form-page-surface {
        padding: 14px 12px 3px;
    }
}

@media (max-width: 575.98px) {
    .app-module-view .table-modern > thead > tr > th,
    .app-module-view .table-modern > tbody > tr > td,
    .app-module-view table.dataTable > thead > tr > th,
    .app-module-view table.dataTable > tbody > tr > td {
        padding-inline: .48rem !important;
    }

    .app-module-view .tabs-modern .nav-link {
        min-height: 38px !important;
        padding: 8px 11px !important;
    }

    .modal-form-modern .modal-body {
        padding: 12px;
    }
}

/* ==========================================================
   Revisión 4.0.6: selects, anchos naturales, tabs y Caja
   ========================================================== */

/* DataTables calcula los anchos a partir del contenido real. */
.app-module-view .table-natural-width,
.app-module-view table.dataTable.table-natural-width {
    width: 100% !important;
    min-width: 100% !important;
    table-layout: auto !important;
}

.app-module-view .table-natural-width > thead > tr > th,
.app-module-view .table-natural-width > tbody > tr > td,
.app-module-view table.dataTable.table-natural-width > thead > tr > th,
.app-module-view table.dataTable.table-natural-width > tbody > tr > td {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    white-space: nowrap !important;
    overflow-wrap: normal;
}

.app-module-view .table-natural-width .col-index,
.app-module-view .table-natural-width .col-date,
.app-module-view .table-natural-width .col-status,
.app-module-view .table-natural-width .col-amount,
.app-module-view .table-natural-width .col-identity,
.app-module-view .table-natural-width .col-actions {
    width: 1% !important;
    min-width: 0 !important;
    max-width: none !important;
    white-space: nowrap !important;
}

.app-module-view .table-natural-width .col-flex {
    width: auto !important;
    min-width: 140px !important;
    max-width: 320px !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
}

/* Ningún complemento heredado puede añadir exportaciones adicionales. */
.app-module-view .dt-buttons .buttons-copy,
.app-module-view .dt-buttons .buttons-csv,
.app-module-view .dt-buttons .buttons-print,
.app-module-view .dt-buttons .buttons-colvis,
.app-module-view .dataTables_wrapper .buttons-copy,
.app-module-view .dataTables_wrapper .buttons-csv,
.app-module-view .dataTables_wrapper .buttons-print,
.app-module-view .dataTables_wrapper .buttons-colvis {
    display: none !important;
}

/* Pestañas APAFA: barra segmentada, icono contenido y selección inequívoca. */
.app-module-view .tabs-apafa {
    position: relative !important;
    top: auto !important;
    z-index: 5;
    display: flex !important;
    width: 100% !important;
    gap: 5px !important;
    margin: 0 0 18px !important;
    padding: 6px !important;
    overflow-x: auto;
    background: var(--app-surface-muted) !important;
    border: 1px solid var(--app-border-strong) !important;
    border-radius: 14px !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), var(--app-shadow-sm) !important;
}

/* Ventas y Configuracion conservan siempre sus pestañas bajo la barra superior. */
.app-module-ventas .sales-tabs,
.app-module-config .config-tabs {
    position: sticky !important;
    top: calc(var(--topbar-height, 76px) + 8px) !important;
    z-index: 1020;
}

.app-module-view .tabs-apafa .nav-item {
    min-width: 0;
    flex: 1 0 max-content;
}

.app-module-view .tabs-apafa .nav-link {
    display: flex !important;
    width: 100%;
    min-height: 44px !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 15px !important;
    color: var(--app-text-muted) !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 10px !important;
    font-size: .79rem;
    font-weight: 800;
    white-space: nowrap;
}

.app-module-view .tabs-apafa .nav-link i {
    display: grid;
    width: 27px;
    height: 27px;
    flex: 0 0 27px;
    place-items: center;
    color: var(--app-primary) !important;
    background: var(--app-primary-soft);
    border-radius: 8px;
}

.app-module-view .tabs-apafa .nav-link:hover {
    color: var(--app-text) !important;
    background: var(--app-surface) !important;
}

.app-module-view .tabs-apafa .nav-link.active {
    color: #fff !important;
    background: linear-gradient(135deg, var(--app-primary), color-mix(in srgb, var(--app-primary) 76%, #101c38)) !important;
    box-shadow: 0 7px 16px color-mix(in srgb, var(--app-primary) 25%, transparent) !important;
}

.app-module-view .tabs-apafa .nav-link.active i {
    color: #fff !important;
    background: rgba(255, 255, 255, .17);
}

/* Caja y comisiones permanece en una sola banda horizontal como APAFA. */
.app-module-caja .cash-selector.cash-selector-five.cash-nav-apafa {
    display: grid !important;
    grid-template-columns: none !important;
    grid-auto-flow: column;
    grid-auto-columns: minmax(235px, 1fr);
    gap: 12px !important;
    margin-bottom: 20px;
    padding: 2px 2px 10px !important;
    overflow-x: auto !important;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}

.app-module-caja .cash-nav-apafa .cash-selector-card {
    display: grid !important;
    min-width: 0 !important;
    min-height: 96px;
    grid-template-columns: 46px minmax(0, 1fr) !important;
    grid-template-rows: auto auto;
    gap: 5px 12px !important;
    padding: 14px !important;
    scroll-snap-align: start;
    border-width: 1px 1px 1px 4px !important;
}

.app-module-caja .cash-nav-apafa .cash-selector-icon {
    grid-row: 1 / span 2;
}

.app-module-caja .cash-nav-apafa .cash-selector-copy {
    grid-column: 2;
    align-self: end;
}

.app-module-caja .cash-nav-apafa .cash-selector-card .badge {
    width: max-content;
    min-width: 0;
    grid-column: 2 !important;
    justify-self: start;
    align-self: start;
    padding: 5px 8px;
}

.app-module-caja .cash-nav-apafa .cash-selector-card.is-active {
    box-shadow: 0 9px 22px color-mix(in srgb, var(--cash-color, var(--app-primary)) 20%, transparent) !important;
    transform: translateY(-2px);
}

@media (min-width: 1500px) {
    .app-module-caja .cash-selector.cash-selector-five.cash-nav-apafa {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
        grid-auto-flow: row;
        grid-auto-columns: auto;
        overflow: visible !important;
    }
}

@media (max-width: 575.98px) {
    .app-module-view .tabs-apafa .nav-item {
        flex: 0 0 auto;
    }

    .app-module-view .tabs-apafa .nav-link {
        min-height: 42px !important;
        padding: 7px 11px !important;
    }

    .app-module-caja .cash-selector.cash-selector-five.cash-nav-apafa {
        grid-auto-columns: minmax(245px, 82vw);
    }
}

/* ==========================================================
   Revisión 4.0.14: selects anclados, campos de venta y avisos
   ========================================================== */

/* Tom Select aporta la estructura; solo .ts-control dibuja el campo. */
body .ts-wrapper.form-control,
body .ts-wrapper.form-select,
body .ts-wrapper {
    position: relative;
    height: auto;
    min-height: 0;
    padding: 0 !important;
    background: transparent !important;
    border: 0 !important;
    border-radius: 0;
    box-shadow: none !important;
}

body .ts-wrapper .ts-control,
body .ts-wrapper.form-control .ts-control,
body .ts-wrapper.form-select .ts-control {
    box-sizing: border-box;
    min-height: 43px !important;
    padding: .5rem 2.25rem .5rem .75rem !important;
    color: var(--app-text) !important;
    background: var(--app-surface-strong) !important;
    border: 1px solid var(--app-field-border) !important;
    border-radius: 10px !important;
    box-shadow: none !important;
}

body .ts-wrapper.focus .ts-control,
body .ts-wrapper.dropdown-active .ts-control {
    border-color: var(--app-primary) !important;
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--app-primary) 16%, transparent) !important;
}

/* El menú sale del área recortable del modal, pero conserva geometría de campo. */
body > .ts-dropdown {
    position: absolute !important;
    z-index: 1095 !important;
    margin: 0 !important;
    transform: none !important;
    border: 1px solid var(--app-field-border) !important;
    border-radius: 9px !important;
    box-shadow: 0 9px 22px rgba(15, 29, 52, .16) !important;
}

/* La búsqueda vive en el propio input; no se muestra un segundo campo. */
.ts-dropdown .dropdown-input-wrap,
.ts-dropdown .dropdown-input {
    display: none !important;
}

.ts-wrapper.single.input-active .ts-control > input {
    display: block !important;
    min-width: 4rem !important;
    flex: 1 1 4rem !important;
}

/* Todos los selects nativos conservan la misma geometría de los inputs. */
select.form-control:not(.ts-hidden-accessible),
select.form-select:not(.ts-hidden-accessible) {
    min-height: 43px;
    color: var(--app-text) !important;
    background-color: var(--app-surface-strong) !important;
    border: 1px solid var(--app-field-border) !important;
    border-radius: 10px !important;
    box-shadow: none !important;
}

/* En Ventas las etiquetas quedan limpias, sin una placa de fondo. */
.app-module-ventas .sales-entry-form .label-over-border {
    margin-top: 0;
}

.app-module-ventas .sales-entry-form .label-over-border > label {
    position: static !important;
    display: block;
    width: max-content;
    max-width: 100%;
    margin: 0 0 .42rem;
    padding: 0 !important;
    overflow: visible;
    color: var(--app-text-muted);
    background: transparent !important;
    border-radius: 0;
    text-overflow: clip;
    white-space: normal;
}

/* Acciones de cliente, lote y agente integradas dentro del selector. */
.app-module-ventas .sales-select-action-shell {
    position: relative;
    display: block;
}

.app-module-ventas .sales-select-action-shell > .ts-wrapper .ts-control {
    padding-right: 5rem !important;
    border-radius: 10px !important;
    border-right: 1px solid var(--app-field-border) !important;
}

.app-module-ventas .sales-select-action-shell > .ts-wrapper.single .ts-control::after {
    right: 3.45rem;
}

.app-module-ventas .sales-select-action {
    position: absolute;
    z-index: 6;
    top: 50%;
    right: 6px;
    display: block;
    margin: 0;
    transform: translateY(-50%);
}

.app-module-ventas .sales-select-action > .btn {
    display: grid;
    width: 34px;
    min-width: 34px;
    height: 32px;
    min-height: 32px;
    place-items: center;
    padding: 0;
    color: var(--app-primary);
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transition: color .16s ease, transform .16s ease;
}

.app-module-ventas .sales-select-action > .btn:hover,
.app-module-ventas .sales-select-action > .btn:focus-visible {
    color: color-mix(in srgb, var(--app-primary) 76%, #0d172b);
    background: transparent !important;
    outline: 0;
}

.app-module-ventas .sales-select-action > .btn:active {
    color: var(--app-primary);
    background: transparent !important;
    transform: scale(.9);
}

/* El tema Bootstrap de Alertify añadía una sombra que simulaba texto doble. */
.alertify-notifier .ajs-message,
.alertify-notifier .ajs-message.ajs-success,
.alertify-notifier .ajs-message.ajs-error,
.alertify-notifier .ajs-message.ajs-warning {
    text-shadow: none !important;
}

/* Modal de acceso del agente: etiquetas y controles alineados por filas. */
#frm_usuarioAgente .row {
    align-items: flex-start;
}

#frm_usuarioAgente .agent-user-field,
#frm_usuarioAgente .password-field {
    margin-top: 0 !important;
    margin-bottom: 1rem;
}

#frm_usuarioAgente .agent-user-field > label,
#frm_usuarioAgente .password-field > label {
    position: static !important;
    display: inline-flex;
    min-height: 18px;
    align-items: center;
    gap: .38rem;
    margin: 0 0 .42rem;
    padding: 0 !important;
    color: var(--app-text-muted);
    background: transparent !important;
    font-size: .76rem;
    font-weight: 750;
    line-height: 1.2;
}

#frm_usuarioAgente .agent-user-field:focus-within > label,
#frm_usuarioAgente .password-field:focus-within > label {
    color: var(--app-primary);
}

#frm_usuarioAgente .agent-user-field > .form-control,
#frm_usuarioAgente .agent-user-field > .form-select,
#frm_usuarioAgente .agent-user-field > .ts-wrapper .ts-control,
#frm_usuarioAgente .password-input-shell {
    box-sizing: border-box;
    height: 46px !important;
    min-height: 46px !important;
}

#frm_usuarioAgente .agent-user-state .bootstrap-switch {
    display: block;
    margin-top: 0;
}
