/* Global responsive safety layer for cross-platform consistency */
html,
body {
    max-width: 100%;
    overflow-x: clip;
}

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

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

input,
select,
textarea,
button {
    max-width: 100%;
}

.overflow-x-auto,
.table-container,
.table-responsive,
.dataTables_wrapper {
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1024px) {
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .sidebar {
        max-width: min(88vw, 320px);
    }
}

@media (max-width: 768px) {
    body {
        font-size: 15px;
    }

    .container,
    .site-shell,
    .topbar-inner {
        width: min(100%, 100vw);
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .main-content,
    .content-wrapper main,
    main.main-content {
        padding: 1rem !important;
    }

    .main-content > header > div {
        display: flex !important;
        flex-wrap: wrap;
        gap: 0.5rem;
        align-items: flex-start !important;
        justify-content: space-between !important;
    }

    .main-content > header h1 {
        font-size: 1.25rem !important;
        line-height: 1.4 !important;
    }

    .main-content > header p {
        font-size: 0.8rem !important;
    }

    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-warning,
    .btn-danger,
    .btn-purple {
        width: 100%;
        justify-content: center;
    }

    .overflow-x-auto > table,
    .table-container > table {
        min-width: 640px;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter,
    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        float: none !important;
        text-align: left !important;
        margin-bottom: 0.5rem;
    }

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

@media (max-width: 480px) {
    .container,
    .site-shell,
    .topbar-inner {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .main-content,
    .content-wrapper main,
    main.main-content {
        padding: 0.75rem !important;
    }

    .sidebar {
        max-width: 92vw;
    }

    .btn,
    .btn-primary,
    .btn-secondary,
    .btn-success,
    .btn-warning,
    .btn-danger,
    .btn-purple {
        min-height: 42px;
        font-size: 0.9rem;
        padding-top: 0.625rem;
        padding-bottom: 0.625rem;
    }
}
