/* ERP modal viewport contract: desktop dialogs are 20% smaller and always scroll inside the viewport. */
.modal-dialog:not(.modal-fullscreen):not(.modal-fullscreen-sm-down):not(.modal-fullscreen-md-down):not(.modal-fullscreen-lg-down):not(.modal-fullscreen-xl-down):not(.modal-fullscreen-xxl-down) {
    --bs-modal-margin: max(.5rem, 10vh);
    max-width: min(calc(100vw - 1rem), 400px);
}

.modal-dialog.modal-sm { max-width: min(calc(100vw - 1rem), 240px) !important; }
.modal-dialog.modal-lg { max-width: min(calc(100vw - 1rem), 640px) !important; }
.modal-dialog.modal-xl { max-width: min(calc(100vw - 1rem), 912px) !important; }

.modal-dialog-scrollable .modal-content,
.modal-dialog:not(.modal-fullscreen) .modal-content {
    max-height: 80vh;
}

.modal-dialog:not(.modal-dialog-scrollable) .modal-body {
    overflow-y: auto;
}

.qg-dialog {
    width: min(80vw, 720px) !important;
    max-height: 80vh !important;
}

@media (max-width: 575.98px) {
    .modal-dialog:not(.modal-fullscreen) {
        --bs-modal-margin: .5rem;
        max-width: calc(100vw - 1rem) !important;
    }

    .modal-dialog:not(.modal-fullscreen) .modal-content {
        max-height: calc(100vh - 1rem);
    }

    .qg-dialog {
        width: calc(100vw - 1rem) !important;
        max-height: calc(100vh - 1rem) !important;
    }
}
