@media (max-width: 1399.98px) {
    :root {
        --content-max-width: 1440px;
    }

    .quick-links {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    .master-chart-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 1199.98px) {
    .page-shell {
        padding-inline: 1rem;
    }

    .topbar-main,
    .topbar-main-minimal,
    .page-toolbar {
        gap: 0.85rem;
    }

    .roster-planner-content,
    .settings-workspace {
        grid-template-columns: 1fr;
    }

    .roster-cell-editor {
        position: static;
    }
}

@media (max-width: 991.98px) {
    body.sidebar-open {
        overflow: hidden;
    }

    .app-shell-active .content-shell,
    body.sidebar-collapsed.app-shell-active .content-shell {
        margin-left: 0;
    }

    .topbar {
        padding-inline: 1rem;
    }

    .topbar-main,
    .topbar-tools,
    .topbar-search-cluster,
    .topbar-action-cluster,
    .page-toolbar,
    .attendance-focus-hero,
    .roster-planner-toolbar,
    .roster-pattern-toolbar,
    .roster-copy-toolbar,
    .roster-planner-statusbar {
        flex-wrap: wrap;
    }

    .topbar-main {
        align-items: flex-start;
    }

    .topbar-tools {
        width: 100%;
        justify-content: space-between;
    }

    .topbar-search-cluster,
    .topbar-action-cluster {
        flex: 1 1 100%;
    }

    .topbar-search {
        width: 100%;
    }

    .topbar-search input {
        width: 100%;
    }

    .page-toolbar > *:last-child {
        flex-shrink: 1;
    }

    .quick-links,
    .master-module-grid,
    .master-health-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .chat-layout {
        grid-template-columns: 1fr;
    }

    .chat-window {
        min-height: 22rem;
    }
}

@media (max-width: 767.98px) {
    .page-shell {
        padding: 0.95rem 0.8rem 1.5rem;
    }

    .page-hero-card,
    .app-card .card-body,
    .modal-body,
    .modal-header,
    .modal-footer,
    .filter-panel,
    .metric-card,
    .quick-link-card {
        padding: 0.95rem;
    }

    .page-title {
        font-size: 1.2rem;
    }

    .quick-links,
    .master-module-grid,
    .master-health-grid {
        grid-template-columns: 1fr;
    }

    .table-action-group,
    .d-flex.flex-wrap.gap-2,
    .d-flex.flex-wrap.gap-2.align-items-end,
    .d-flex.flex-wrap.justify-content-center.gap-2 {
        width: 100%;
    }

    .table-action-group > *,
    .d-flex.flex-wrap.gap-2 > .btn,
    .d-flex.flex-wrap.gap-2.align-items-end > .btn {
        flex: 1 1 auto;
    }

    .attendance-focus-meta {
        grid-template-columns: 1fr;
    }

    .notification-list .list-group-item {
        align-items: stretch !important;
        flex-direction: column;
    }

    .notification-list .table-action-group {
        justify-content: flex-start;
    }
}

@media (max-width: 575.98px) {
    .btn,
    .btn-sm,
    .btn-lg {
        width: 100%;
    }

    .topbar-main-minimal {
        grid-template-columns: auto 1fr;
        row-gap: 0.75rem;
    }

    .topbar-minimal-tools {
        grid-column: 1 / -1;
        justify-content: space-between;
        width: 100%;
    }

    .topbar-logout-button {
        flex: 1 1 auto;
    }

    .table-stack-mobile td[data-label]::before {
        color: var(--secondary);
        font-weight: 800;
    }

    .modal-dialog {
        margin: 0.8rem;
    }

    .profile-photo-uploader-copy {
        flex-direction: column;
        align-items: stretch;
    }

    .profile-photo-preview-inline {
        justify-items: flex-start;
        text-align: left;
    }
}
