table.dataTable.no-footer {
    border-bottom: 1px solid var(--bs-border-color);
}

.d-footer {
    margin-top: 16px;
}

.dataTables_wrapper .dataTables_length>label {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 16px;
}

.dataTables_wrapper .dataTables_length select {
    display: block;
    width: 100%;
    padding: .375rem .75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--bs-body-color);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: var(--bs-body-bg);
    background-image: var(--bs-form-select-bg-img), var(--bs-form-select-bg-icon, none);
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 16px 12px;
    border: var(--bs-border-width) solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.dataTables_wrapper .dataTables_paginate {
    border: 1px solid var(--bs-border-color);
    padding: 4px;
    display: flex;
    gap: 16px;
    align-items: center;
    border-radius: 40px;
}

.dataTables_wrapper .dataTables_paginate>ul {
    margin-bottom: 0;
}

.dataTables_wrapper .dataTables_paginate>span {
    display: flex;
    gap: 2px;
    align-items: center;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: 0 !important;
    padding: 4px 14px !important;
    border-radius: 40px !important;
    margin: 0 !important;
}

.dataTables_wrapper .dataTables_paginate>span .paginate_button {
    border: 0 !important;
    margin: 0 !important;
    border-radius: 40px !important;
    min-width: 2rem;
    min-height: 2rem;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover,
.dataTables_wrapper .dataTables_paginate .paginate_button.active:hover {
    background: rgba(var(--bs-primary-rgb), .6);
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    border: 0 !important;
    background: var(--bs-primary);
    color: var(--bs-white) !important;
}

.dataTables_wrapper .dataTables_length {
    color: var(--bs-body-color);
    /* width: 100%; */
}

table.dataTable thead th,
table.dataTable thead td {
    border-color: var(--bs-primary);
}

table.dataTable.dtr-inline.collapsed tbody td:first-child:before,
table.dataTable.dtr-inline.collapsed tbody th:first-child:before {
    background-color: var(--bs-primary);
    transform: translateY(-50%);
    top: 50%;
}

.dataTables_filter input {
    border: var(--bs-border-width) solid var(--bs-border-color);
    border-radius: var(--bs-border-radius);
    background-color: var(--bs-body-bg);
    background-clip: padding-box;
    color: var(--bs-body-color);
    padding: .375rem .75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
}

table.dataTable.display tbody tr.odd>.sorting_1,
table.dataTable.order-column.stripe tbody tr.odd>.sorting_1,
table.dataTable.display tbody tr.even>.sorting_1,
table.dataTable.order-column.stripe tbody tr.even>.sorting_1 {
    background-color: var(--bs-border-color);
}

table.dataTable.row-border tbody th,
table.dataTable.row-border tbody td,
table.dataTable.display tbody th,
table.dataTable.display tbody td {
    border-color: var(--bs-border-color);
}

table.dataTable thead th,
table.dataTable thead td {
    padding: 12px 20px 12px 10px;
}

table.dataTable tbody th,
table.dataTable tbody td {
    padding: 12px 10px;
}

table.dataTable tr.child ul li {
    border-color: var(--bs-border-color);
}

/* Phase 3: DataTables and table responsive hardening */
.dataTables_wrapper {
    min-width: 0;
}

.dataTables_wrapper .row,
.dataTables_wrapper .col-sm-12,
.dataTables_wrapper .col-md-5,
.dataTables_wrapper .col-md-6,
.dataTables_wrapper .col-md-7 {
    min-width: 0;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    max-width: 100%;
}

.table,
table.dataTable {
    min-width: 0;
}

.table td,
.table th,
table.dataTable tbody td,
table.dataTable thead th {
    vertical-align: middle;
}

.table td,
table.dataTable tbody td {
    overflow-wrap: anywhere;
}

@media (max-width: 991.98px) {
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        width: 100%;
        text-align: left !important;
    }

    .dataTables_wrapper .dataTables_filter {
        margin-top: .75rem;
    }

    .dataTables_wrapper .dataTables_paginate {
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .dataTables_wrapper .dataTables_paginate > span {
        flex: 0 0 auto;
    }
}

@media (max-width: 767.98px) {
    .dataTables_wrapper {
        overflow-x: hidden;
    }

    .dataTables_wrapper .dataTables_length > label {
        align-items: stretch;
        flex-direction: column;
        gap: .35rem;
        margin-bottom: 0;
    }

    .dataTables_wrapper .dataTables_length select {
        width: 100% !important;
    }

    .dataTables_wrapper .dataTables_filter label {
        display: flex;
        align-items: stretch;
        flex-direction: column;
        gap: .35rem;
        width: 100%;
        margin-bottom: 0;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
    }

    .dataTables_wrapper .dataTables_info {
        padding-top: .75rem;
        font-size: .875rem;
    }

    .dataTables_wrapper .dataTables_paginate {
        border-radius: 1rem;
        gap: .25rem;
        margin-top: .75rem;
        padding: .35rem;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        min-height: 2.25rem;
        padding: .35rem .65rem !important;
    }

    .dataTables_wrapper .dataTables_paginate > span .paginate_button {
        min-width: 2.25rem;
        min-height: 2.25rem;
    }

    table.dataTable thead th,
    table.dataTable thead td,
    table.dataTable tbody th,
    table.dataTable tbody td {
        padding: .75rem .65rem;
    }

    table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control,
    table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control,
    table.dataTable.dtr-inline.collapsed tbody td:first-child,
    table.dataTable.dtr-inline.collapsed tbody th:first-child {
        padding-left: 2rem !important;
    }

    table.dataTable tr.child td.child {
        padding: .85rem !important;
    }

    table.dataTable tr.child ul.dtr-details {
        display: block;
        width: 100%;
    }

    table.dataTable tr.child ul.dtr-details > li {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: .75rem;
        padding: .5rem 0;
    }

    table.dataTable tr.child span.dtr-title {
        flex: 0 0 42%;
        min-width: 0;
        white-space: normal;
    }

    table.dataTable tr.child span.dtr-data {
        flex: 1 1 auto;
        min-width: 0;
        text-align: right;
        overflow-wrap: anywhere;
    }
}

@media (max-width: 575.98px) {
    .dataTables_wrapper .dataTables_paginate {
        justify-content: flex-start;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button.previous,
    .dataTables_wrapper .dataTables_paginate .paginate_button.next {
        padding-left: .75rem !important;
        padding-right: .75rem !important;
    }
}

/* Phase 4: dense admin table polish */
@media (max-width: 767.98px) {
    table.dataTable,
    .table {
        font-size: .92rem;
    }

    .dataTables_wrapper .row {
        --bs-gutter-y: .75rem;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        background: rgba(var(--bs-secondary-rgb), .035);
        border: 1px solid var(--bs-border-color);
        border-radius: 1rem;
        padding: .75rem;
    }

    table.dataTable tr.child ul.dtr-details > li {
        flex-direction: column;
        align-items: stretch;
        gap: .25rem;
    }

    table.dataTable tr.child span.dtr-title,
    table.dataTable tr.child span.dtr-data {
        flex: 1 1 auto;
        width: 100%;
        text-align: left;
    }

    table.dataTable tr.child span.dtr-title {
        color: var(--bs-secondary-color);
        font-size: .8rem;
        text-transform: uppercase;
        letter-spacing: .02em;
    }

    table.dataTable tbody td .btn,
    table.dataTable tbody td button,
    table.dataTable tbody td a.btn {
        white-space: nowrap;
    }
}

@media (max-width: 575.98px) {
    table.dataTable,
    .table {
        font-size: .88rem;
    }

    .dataTables_wrapper .dataTables_paginate {
        max-width: 100%;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        font-size: .875rem;
    }
}

/* Phase 15: mobile DataTables action hardening */
table.dataTable tr.child,
table.dataTable tr.child td.child,
table.dataTable tr.child ul.dtr-details,
table.dataTable tr.child span.dtr-data,
table.dataTable tr.child .actions-cell {
    position: relative;
    z-index: 2;
    pointer-events: auto;
}

table.dataTable tr.child .actions-cell {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: flex-start !important;
    gap: .45rem;
}

table.dataTable tr.child .actions-cell .btn,
table.dataTable tr.child .actions-cell button,
table.dataTable tr.child .actions-cell a {
    pointer-events: auto !important;
    position: relative;
    z-index: 3;
    touch-action: manipulation;
}

table.dataTable.dtr-inline.collapsed tbody td.dtr-control:before,
table.dataTable.dtr-inline.collapsed tbody th.dtr-control:before,
table.dataTable.dtr-inline.collapsed tbody td:first-child:before,
table.dataTable.dtr-inline.collapsed tbody th:first-child:before {
    pointer-events: none;
}

@media (max-width: 767.98px) {
    table.dataTable tr.child span.dtr-data {
        text-align: left !important;
    }

    table.dataTable tr.child .actions-cell .btn,
    table.dataTable tr.child .actions-cell button,
    table.dataTable tr.child .actions-cell a {
        min-width: 38px;
        min-height: 38px;
        border-radius: 999px !important;
    }
}
