html,
body {
    margin: 0;
    max-width: 100%;
    overflow-x: clip;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img,
svg,
video,
canvas,
iframe {
    height: auto;
    max-width: 100%;
}

.container,
.container-fluid,
.row,
[class*="col-"],
.card,
.card-body,
.card-header,
.app-main,
.app-content,
.app-content-header,
.app-wrapper {
    min-width: 0;
}

pre,
code,
.text-break-mobile {
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    word-break: break-word;
}

.table-responsive {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767.98px) {
    body {
        width: 100%;
    }

    .container,
    .container-fluid {
        max-width: 100%;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .row {
        margin-left: -0.375rem;
        margin-right: -0.375rem;
    }

    .row > * {
        min-width: 0;
        padding-left: 0.375rem;
        padding-right: 0.375rem;
    }

    .app-content-header {
        padding: 1rem 0 0.6rem;
    }

    .app-content {
        padding-bottom: 1rem;
    }

    .card {
        max-width: 100%;
    }

    .card-body,
    .card-header {
        overflow-wrap: anywhere;
        padding: 0.9rem;
    }

    .card-header.d-flex {
        align-items: stretch !important;
        flex-wrap: wrap;
        gap: 0.65rem;
    }

    .card-header.d-flex > * {
        min-width: 0;
        max-width: 100%;
    }

    .input-group {
        max-width: 100%;
    }

    .form-control,
    .form-select,
    textarea,
    input,
    select {
        max-width: 100%;
        min-width: 0;
    }

    .btn-group,
    .btn-toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        max-width: 100%;
    }

    .btn-group > .btn,
    .btn-toolbar .btn {
        border-radius: 0.45rem !important;
        flex: 1 1 auto;
    }

    .dropdown-menu {
        max-width: calc(100vw - 1.5rem);
    }

    .app-header .container-fluid {
        flex-wrap: nowrap;
    }

    .app-header .navbar-nav {
        min-width: 0;
    }

    .app-header .nav-link {
        padding-left: 0.55rem;
        padding-right: 0.55rem;
    }

    .app-footer {
        padding: 0.85rem;
        text-align: center;
    }

    .small-box .inner {
        padding: 1rem;
    }

    .small-box h3 {
        font-size: 1.75rem;
    }

    .card-title {
        float: none !important;
        line-height: 1.3;
        margin-bottom: 0.5rem;
    }

    .card-title + .card-text,
    .card-title + p {
        clear: both;
    }

    .table-responsive {
        border-radius: 0.5rem;
        overflow-x: auto !important;
        overflow-y: auto;
        width: 100%;
    }

    .table-responsive > .table {
        margin-bottom: 0;
        min-width: 100%;
        width: max-content;
    }

    .table-responsive th,
    .table-responsive td {
        white-space: nowrap;
    }

    .table-responsive td .form-control,
    .table-responsive td .form-select {
        min-width: 5.5rem;
    }

    .table-responsive.mobile-card-wrapper {
        max-height: none !important;
        overflow: visible !important;
    }

    .table-cards-mobile thead {
        display: none;
    }

    .table-cards-mobile,
    .table-cards-mobile tbody,
    .table-cards-mobile tfoot,
    .table-cards-mobile tr,
    .table-cards-mobile td,
    .table-cards-mobile th {
        display: block;
        width: 100% !important;
        min-width: 0 !important;
        white-space: normal;
    }

    .table-cards-mobile > tbody,
    .table-cards-mobile > tfoot {
        display: flex;
        flex-direction: column;
        gap: 0.85rem;
    }

    .table-cards-mobile tr {
        border: 1px solid var(--bs-border-color, #dee2e6);
        border-radius: 0.75rem;
        box-shadow: 0 4px 14px rgba(84, 61, 47, 0.08);
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0;
    }

    .table-cards-mobile td,
    .table-cards-mobile th {
        border: 0;
        border-bottom: 1px solid #eee8e4;
        display: block;
        padding: 0.7rem 0.85rem;
        text-align: left;
    }

    .table-cards-mobile tr > :last-child {
        border-bottom: 0;
    }

    .table-cards-mobile td[data-label]::before,
    .table-cards-mobile th[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 0.72rem;
        font-weight: 600;
        letter-spacing: 0.035em;
        line-height: 1.35;
        margin-bottom: 0.3rem;
        color: var(--bs-secondary-color, #6c757d);
        text-transform: uppercase;
    }

    .table-cards-mobile td[data-label=""]::before,
    .table-cards-mobile td:not([data-label])::before,
    .table-cards-mobile th[data-label=""]::before,
    .table-cards-mobile th:not([data-label])::before {
        content: none;
    }

    .table-cards-mobile td.card-title-cell {
        background: #f7f5f3;
        font-weight: 700;
        font-size: 1rem;
        border-bottom: 1px solid var(--bs-border-color, #dee2e6);
        order: -2;
        padding: 0.8rem 0.85rem;
    }

    .table-cards-mobile td.card-title-cell::before {
        content: none;
    }

    .table-cards-mobile td:first-child:not(.card-title-cell) {
        order: -1;
    }

    .table-cards-mobile .form-control,
    .table-cards-mobile .form-select,
    .table-cards-mobile .input-group {
        margin: 0;
        min-width: 0 !important;
        width: 100%;
    }

    .table-cards-mobile .btn {
        max-width: 100%;
        white-space: normal;
    }

    .table-cards-mobile tr.collapse:not(.show) {
        display: none;
    }

    .table-cards-mobile tr.collapse.show {
        display: flex;
    }

    .table-cards-mobile td[colspan]::before,
    .table-cards-mobile th[colspan]::before {
        display: none;
    }

    .mobile-action-row {
        display: grid;
        gap: 0.65rem;
        grid-template-columns: 1fr;
    }

    .mobile-action-row > * {
        min-width: 0;
        text-align: left !important;
    }

    .mobile-action-row .btn {
        margin: 0;
        width: 100%;
    }
}

@media (max-width: 399.98px) {
    .container,
    .container-fluid {
        padding-left: 0.55rem;
        padding-right: 0.55rem;
    }

}
