/* Shared layout and scrolling for accounting and administration views. */
#balanceAudit .audit-table {
    min-width: 55rem;
}

#balanceAudit .audit-table td,
#auditDetailContext,
.audit-change-card {
    overflow-wrap: anywhere;
}

.audit-change-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
    gap: 1rem;
}

.audit-change-card {
    min-width: 0;
    padding: 1rem;
    border: 1px solid #dee2e6;
    border-left: 3px solid #009150;
    border-radius: .75rem;
}

.audit-change-values {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .75rem;
    font-variant-numeric: tabular-nums;
}

.audit-change-values dt {
    margin-bottom: .25rem;
    color: #667085;
    font-size: .875rem;
}

.audit-change-values > :last-child dd {
    color: #006b3b;
    font-weight: 600;
}

.audit-table-container .dt-search input {
    max-width: 100%;
}

#balanceAudit .audit-table-container {
    border: 1px solid #e4ebe7;
    border-radius: 1rem;
    box-shadow: 0 6px 24px rgba(20, 60, 40, .06);
}

#balanceAudit .dt-container > .dt-layout-row:not(.dt-layout-table) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0;
    padding: 1.25rem;
}

#balanceAudit .dt-layout-table {
    margin: 0;
}

#balanceAudit .dt-length,
#balanceAudit .dt-search {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: #52645a;
    font-size: .875rem;
}

#balanceAudit .dt-search input,
#balanceAudit .dt-length select {
    min-height: 44px;
    margin: 0;
    padding: .6rem .85rem;
    border: 1px solid #d7e1da;
    border-radius: .65rem;
    background-color: #fff;
    color: #24392c;
}

#balanceAudit .dt-search input {
    width: clamp(12rem, 24vw, 24rem);
}

#balanceAudit .dt-search input:focus,
#balanceAudit .dt-length select:focus {
    border-color: #009150;
    outline: 2px solid rgba(0, 145, 80, .2);
    outline-offset: 1px;
}

#balanceAudit .audit-table caption {
    padding: .75rem 1.25rem;
    border-top: 1px solid #edf1ee;
    color: #66776d;
    font-size: .875rem;
}

#balanceAudit #auditTable thead {
    --bs-table-bg: #f0f6f2;
    --bs-table-color: #3a5444;
}

#balanceAudit #auditTable thead th {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #dde7e0;
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap;
}

#balanceAudit #auditTable tbody td {
    padding: 1rem 1.25rem;
    border-color: #edf1ee;
    font-size: .925rem;
}

#balanceAudit .audit-company {
    color: #243d2e;
    font-weight: 600;
}

#balanceAudit .audit-date,
#balanceAudit .audit-user {
    color: #66776d;
}

#balanceAudit .audit-period {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.audit-action {
    display: inline-block;
    padding: .35rem .7rem;
    border-radius: 2rem;
    background: #eef1f4;
    color: #495869;
    font-size: .8rem;
    font-weight: 600;
    white-space: nowrap;
}

.audit-action-created { background: #e7f5ed; color: #087443; }
.audit-action-updated { background: #eaf1fc; color: #305f9b; }
.audit-action-deleted { background: #fcecec; color: #a8343c; }

#balanceAudit .audit-count-button {
    min-height: 40px;
    padding: .45rem .85rem;
    border: 1px solid #d1e7da;
    border-radius: .65rem;
    background: #f2f9f5;
    color: #087443;
    font-weight: 600;
    white-space: nowrap;
}

#balanceAudit .audit-count-button:hover {
    border-color: #009150;
    background: #e3f2e9;
}

#balanceAudit .dt-info {
    color: #66776d;
    font-size: .875rem;
}

#balanceAudit .dt-paging .dt-paging-button {
    min-width: 40px;
    min-height: 40px;
    margin: .15rem;
    border: 1px solid #e0e7e2;
    border-radius: .6rem;
    background: #fff;
    color: #40594a !important;
    box-shadow: none;
}

#balanceAudit .dt-paging .dt-paging-button:hover {
    border-color: #b4d7c3;
    background: #eef7f2;
}

#balanceAudit .dt-paging .dt-paging-button.current {
    border-color: #009150;
    background: #009150;
    color: #fff !important;
}

#balanceAudit .dt-paging .dt-paging-button.disabled {
    opacity: .4;
}

@media (max-width: 767.98px) {
    #balanceAudit .dt-container > .dt-layout-row:not(.dt-layout-table) {
        padding: 1rem;
    }

    #balanceAudit .dt-layout-cell,
    #balanceAudit .dt-search {
        width: 100%;
    }

    #balanceAudit .dt-search input {
        width: 100%;
        min-width: 0;
        flex: 1;
    }

    #balanceAudit #auditTable thead {
        padding: .25rem .5rem .75rem;
        color: #52645a;
        background: #f7faf8;
    }

    #balanceAudit #auditTable thead th {
        padding: .65rem 1.5rem .65rem .75rem;
        border: 1px solid #dde7e0;
        border-radius: .6rem;
        background: #fff;
        font-size: .8rem;
    }

    #balanceAudit #auditTable tbody {
        padding: .75rem;
        background: #f7faf8;
    }

    #balanceAudit #auditTable tbody tr {
        border-color: #e0e9e3;
        border-radius: .85rem;
        padding: 1rem;
        box-shadow: 0 2px 6px rgba(20, 60, 40, .03);
    }

    #balanceAudit #auditTable td[data-label]::before {
        color: #78877d;
        font-size: .75rem;
    }
}

#layoutSidenav_content main,
#layoutSidenav_content .card,
#layoutSidenav_content .card-body,
#layoutSidenav_content .row > *,
.modal-content,
.modal-body {
    min-width: 0;
}

#layoutSidenav_content .table-responsive,
.modal .table-responsive,
.users-table-container,
.users-table-container .dt-container,
.audit-table-container,
.audit-table-container .dt-container {
    max-width: 100%;
    min-width: 0;
}

.table-responsive {
    overscroll-behavior-x: contain;
    scrollbar-width: auto;
    scrollbar-color: #8b99a8 #edf1f5;
}

.table-responsive:focus-visible {
    outline: 2px solid #009150;
    outline-offset: -2px;
}

.table-scroll-hint {
    margin: 0;
    padding: .5rem .75rem;
    color: #465065;
    background: #eef5f1;
    font-size: .875rem;
}

#layoutSidenav_content .balance-table,
#layoutSidenav_content .history-table {
    min-width: 48rem;
    font-size: 1rem;
    border-collapse: separate;
    border-spacing: 0;
}

#layoutSidenav_content .balance-table input {
    min-width: 9rem;
    font-variant-numeric: tabular-nums;
}

#layoutSidenav_content .history-table .dynamic-year,
#layoutSidenav_content .history-table .year-column,
.comparative-table td:not(:first-child),
.comparative-table th:not(:first-child) {
    min-width: 9rem;
    white-space: nowrap;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

#layoutSidenav_content .history-table td:nth-child(2),
#layoutSidenav_content .balance-table td:nth-child(2) {
    min-width: 17rem;
}

.table-responsive:has(> .balance-table),
.table-responsive:has(> .history-table) {
    max-height: 70vh;
}

.balance-table thead th,
.history-table thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #212529;
    color: #fff;
}

.balance-table tr > :first-child:not([colspan]),
.history-table tr > :first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background-color: var(--bs-table-bg, #fff);
    box-shadow: 1px 0 #dee2e6;
}

.balance-table thead tr > :first-child,
.history-table thead tr > :first-child {
    z-index: 4;
}

.table-responsive > .comparative-table {
    min-width: 40rem;
}

.comparative-table td:first-child {
    min-width: 12rem;
}

.users-table-container,
.audit-table-container {
    overflow-x: auto;
}

.users-table-container:has(.table-responsive),
.audit-table-container:has(.table-responsive) {
    overflow: visible;
}

#layoutSidenav_content canvas {
    max-width: 100%;
}

.users-table-container #usersTable {
    min-width: 64rem;
}

.users-table-container .dt-layout-row,
.users-table-container .dt-paging,
.audit-table-container .dt-layout-row,
.audit-table-container .dt-paging {
    flex-wrap: wrap;
    gap: .5rem;
}

@media (max-width: 991.98px) {
    .sb-topnav .navbar-brand {
        width: auto;
        flex-shrink: 0;
    }

    .sb-topnav #sidebarToggle {
        min-width: 44px;
        min-height: 44px;
        margin-right: .5rem !important;
    }

    .sb-topnav .navbar-nav,
    .sb-topnav .nav-item {
        min-width: 0;
    }

    .sb-topnav #navbarDropdown {
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }

    #layoutSidenav_content .btn,
    .modal .btn,
    #layoutSidenav_content .form-control,
    #layoutSidenav_content .form-select {
        min-height: 44px;
    }

    #layoutSidenav_content .form-control,
    #layoutSidenav_content .form-select {
        font-size: 1rem;
    }

    #layoutSidenav_content .select2-container {
        max-width: 100%;
    }

    #layoutSidenav_content .table-responsive > .analysis-table:has(thead) {
        min-width: 36rem;
    }

    #layoutSidenav_content .ebitda-table td:first-child {
        width: 65%;
        overflow-wrap: anywhere;
    }

    #layoutSidenav_content .ebitda-table td:last-child:not([colspan]) {
        width: 35%;
        white-space: nowrap;
        font-variant-numeric: tabular-nums;
    }

    #financialDashboard .table-responsive > table {
        min-width: 42rem;
    }

    .modal-body {
        overflow-wrap: anywhere;
    }
}

@media (max-width: 767.98px) {
    .table-responsive:has(> .table-mobile-cards) {
        max-height: none;
    }

    #layoutSidenav_content .table-mobile-cards,
    .modal .table-mobile-cards {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
    }

    .table-mobile-cards > thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .table-mobile-cards > caption {
        display: block;
    }

    .table-mobile-cards > tbody,
    .table-mobile-cards > tfoot {
        display: block;
        padding: .5rem;
    }

    .table-mobile-cards > tbody > tr,
    .table-mobile-cards > tfoot > tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: .75rem;
        margin-bottom: .75rem;
        padding: .75rem;
        border: 1px solid #dee2e6;
        border-radius: .75rem;
        background-color: #fff;
    }

    #layoutSidenav_content .table-mobile-cards > :is(tbody, tfoot) > tr > td,
    .modal .table-mobile-cards > :is(tbody, tfoot) > tr > td {
        position: static;
        display: block;
        width: auto !important;
        min-width: 0 !important;
        padding: 0 !important;
        border: 0;
        box-shadow: none;
        background: transparent;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: left;
    }

    .table-mobile-cards td[data-label]::before {
        content: attr(data-label);
        display: block;
        margin-bottom: .25rem;
        font-size: .875rem;
        font-weight: 600;
    }

    .table-mobile-cards td[data-label=""]::before {
        display: none;
    }

    .table-mobile-cards td[colspan],
    .table-mobile-cards.analysis-table td,
    .table-mobile-cards.balance-table td:first-child,
    .table-mobile-cards.balance-table td:nth-child(2),
    .table-mobile-cards.history-table td:first-child,
    .table-mobile-cards.history-table td:nth-child(2),
    .table-mobile-cards.comparative-table td:first-child,
    #usersTable.table-mobile-cards td:nth-child(4),
    #usersTable.table-mobile-cards td:last-child {
        grid-column: 1 / -1;
    }

    #balanceAudit .table-mobile-cards td:nth-child(2),
    #balanceAudit .table-mobile-cards td:nth-child(4),
    #balanceAudit .table-mobile-cards td:last-child {
        grid-column: 1 / -1;
    }

    #layoutSidenav_content .balance-table.table-mobile-cards input {
        width: 100%;
        min-width: 0;
        padding: .5rem .25rem;
    }

    .table-mobile-cards.balance-table td:nth-child(2)::before,
    .table-mobile-cards.history-table td:nth-child(2)::before {
        display: none;
    }

    .table-mobile-cards.balance-table td:nth-child(2),
    .table-mobile-cards.history-table td:nth-child(2) {
        font-weight: 600;
    }

    :is(#usersTable, #auditTable).table-mobile-cards > thead {
        position: static;
        display: block;
        width: auto;
        height: auto;
        clip-path: none;
        white-space: normal;
    }

    :is(#usersTable, #auditTable).table-mobile-cards > thead::before {
        content: 'Ordenar por';
        display: block;
        padding: .5rem;
        font-weight: 600;
    }

    :is(#usersTable, #auditTable).table-mobile-cards > thead > tr {
        display: flex;
        flex-wrap: wrap;
        gap: .5rem;
        padding: .5rem;
    }

    :is(#usersTable, #auditTable).table-mobile-cards > thead th {
        flex: 1 1 40%;
        width: auto !important;
        min-height: 44px;
    }

    :is(#usersTable, #auditTable).table-mobile-cards > thead th.dt-orderable-none {
        display: none;
    }
}

@media (max-width: 575.98px) {
    #layoutSidenav_content main > .container-fluid,
    #layoutSidenav_content footer > .container-fluid {
        padding-right: .75rem !important;
        padding-left: .75rem !important;
    }

    .page-hero-content,
    .period-card .card-header > div {
        min-width: 0;
        overflow-wrap: anywhere;
    }

    #layoutSidenav_content .page-hero,
    #layoutSidenav_content .analysis-hero {
        padding: 1.25rem;
    }

    #layoutSidenav_content .period-card > .card-body {
        padding: 1rem;
    }

    #layoutSidenav_content .card-header.d-flex {
        align-items: stretch !important;
    }

    #layoutSidenav_content .card-header > .btn,
    #layoutSidenav_content #csvButton,
    #layoutSidenav_content #downloadBalanceContainer {
        width: 100%;
    }

    .modal-header,
    .modal-footer {
        flex-wrap: wrap;
        gap: .5rem;
    }

    .modal-header .modal-title {
        flex: 1;
        min-width: 0;
    }

    .modal-footer > .btn,
    .modal-footer > form {
        flex: 1 1 100%;
        margin: 0;
    }

    .modal-footer > form > .btn {
        width: 100%;
    }

    .users-table-container .dt-search input,
    .audit-table-container .dt-search input {
        width: 100%;
        margin-left: 0;
    }

    .users-table-container .dt-paging .dt-paging-button,
    .audit-table-container .dt-paging .dt-paging-button {
        min-width: 44px;
        min-height: 44px;
    }
}
