dialog {
    width: calc(100% - 100px);
    max-width: 100%;
    margin: auto;
}

.dialog-close-button + .card > .card-header {
    padding-right: 3rem !important;
}

/*
 * A max-* class keeps the gutter tight at every screen width. Below its maximum it is the width
 * that bounds the dialog and the maximum never comes into play, so on a phone the class decides
 * nothing but how much room is left beside it. A dialog without a max-* class keeps the wider
 * gutter of the rule at the top of this file.
 */
dialog.max-1800 {
    max-width: 1800px;
    width: calc(100% - 10px);
}
dialog.max-1200 {
    max-width: 1200px;
    width: calc(100% - 10px);
}
dialog.max-1000 {
    max-width: 1000px;
    width: calc(100% - 10px);
}
dialog.max-800 {
    max-width: 800px;
    width: calc(100% - 10px);
}
dialog.max-600 {
    max-width: 600px;
    width: calc(100% - 10px);
}
dialog.max-500 {
    max-width: 500px;
    width: calc(100% - 10px);
}
dialog.max-400 {
    max-width: 400px;
    width: calc(100% - 10px);
}

/*
 * A phone dialog is only as tall as the viewport. Without a bound of its own the mail cards grow
 * the <dialog>, and the browser scrolls the dialog — the card title scrolls away with it. Keep the
 * dialog from scrolling and give the card body the leftover height, so the title stays put and the
 * list scrolls inside it. Desktop keeps the table's own scroll.
 */
@media (max-width: 767.98px) {
    dialog:has(.dialog-scroll-body) {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        max-height: calc(100dvh - 1rem);
    }

    dialog:has(.dialog-scroll-body) > .card {
        min-height: 0;
        overflow: hidden;
    }

    dialog:has(.dialog-scroll-body) > .card > .card-header {
        flex-shrink: 0;
    }

    dialog:has(.dialog-scroll-body) > .card > .card-body {
        min-height: 0;
        overflow-y: auto;
    }
}
