@media screen and (max-width:1199.98px) {
    html body .bkg-mobile-modal {
        box-sizing:border-box !important;
        position:fixed !important;
        top:var(--bkg-modal-top,0px) !important;
        right:0 !important;
        bottom:auto !important;
        left:0 !important;
        width:100% !important;
        max-width:100vw !important;
        height:var(--bkg-modal-height,100dvh) !important;
        max-height:var(--bkg-modal-height,100dvh) !important;
        padding:8px max(8px,env(safe-area-inset-right)) max(8px,env(safe-area-inset-bottom)) max(8px,env(safe-area-inset-left)) !important;
        overflow:hidden !important;
        overscroll-behavior:contain;
    }
    html body .bkg-mobile-modal .bkg-modal-shell {
        box-sizing:border-box !important;
        display:flex !important;
        align-items:center;
        width:100% !important;
        min-width:0 !important;
        max-width:100% !important;
        height:100% !important;
        min-height:0 !important;
        max-height:100% !important;
        margin:0 !important;
        padding:0 !important;
        transform:none !important;
    }
    html body .bkg-mobile-modal .bkg-modal-card,
    html body dialog.bkg-mobile-native[open] {
        box-sizing:border-box !important;
        position:relative;
        display:flex !important;
        flex-direction:column !important;
        width:100% !important;
        min-width:0 !important;
        max-width:100% !important;
        max-height:calc(var(--bkg-modal-height,100dvh) - 16px - env(safe-area-inset-bottom)) !important;
        margin:0 auto !important;
        border-radius:8px !important;
        overflow:hidden !important;
    }
    html body dialog.bkg-mobile-native[open] {
        position:fixed !important;
        top:calc(var(--bkg-modal-top,0px) + 8px) !important;
        bottom:auto !important;
        left:8px !important;
        right:8px !important;
        width:calc(100% - 16px) !important;
        max-width:calc(100% - 16px) !important;
        margin:0 auto !important;
        padding:0 !important;
    }
    html body .bkg-modal-card > form:has(.bkg-modal-body),
    html body dialog.bkg-mobile-native > form:has(.bkg-modal-body) {
        display:flex; flex-direction:column; flex:1 1 auto; min-height:0; overflow:hidden;
    }
    html body .bkg-modal-card.bkg-modal-content-fit { height:auto !important; min-height:0 !important; }
    html body .bkg-modal-content-fit > .bkg-modal-body,
    html body .bkg-modal-content-fit > form > .bkg-modal-body { height:auto !important; }
    html body .bkg-mobile-modal .bkg-modal-card *,
    html body dialog.bkg-mobile-native * { box-sizing:border-box; min-width:0; }
    html body .bkg-modal-card :is(input,select,textarea,fieldset,.input-group,.row),
    html body dialog.bkg-mobile-native :is(input,select,textarea,fieldset,.input-group,.row) { max-width:100% !important; }
    html body .bkg-modal-card :is(input,select,textarea):not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]) { min-width:0 !important; }
    html body .bkg-modal-header {
        display:flex; align-items:center;
        flex:0 0 auto !important; min-width:0; max-width:100%;
        padding:10px 12px !important; gap:8px; flex-wrap:wrap;
    }
    html body .bkg-modal-header > .d-flex { flex-wrap:wrap !important; max-width:100%; }
    html body .bkg-modal-header > * { min-width:0; max-width:100%; }
    html body .bkg-modal-header > :is(button,.btn) { white-space:normal !important; overflow-wrap:anywhere; flex-shrink:1; }
    html body .bkg-modal-header :is(h1,h2,h3,h4,h5,h6,.modal-title,.quick-modal-title) {
        min-width:0 !important; max-width:100%; margin:0; font-size:17px !important;
        white-space:normal !important; overflow-wrap:anywhere; line-height:1.4;
    }
    html body .bkg-modal-header :is(.btn-close,.close-btn,.close,.bam-close,.bkg-table-details-close,[aria-label="ปิด"],[aria-label="Close"]),
    html body .bkg-modal-card > .close-btn {
        box-sizing:border-box; display:inline-flex; align-items:center; justify-content:center;
        flex:0 0 48px; min-width:48px !important; width:48px !important;
        min-height:48px !important; height:48px !important; margin:0 !important;
    }
    html body .bkg-modal-card > .close-btn { position:absolute; top:6px; right:6px; z-index:2; }
    html body .bkg-modal-card > .close-btn ~ .bkg-modal-header { padding-right:58px !important; }
    html body .bkg-modal-body {
        font-size:14px; line-height:1.5;
        flex:1 1 auto !important; min-width:0 !important; min-height:0 !important;
        max-width:100% !important; overflow-y:auto !important; overflow-x:hidden !important;
        overscroll-behavior:contain; -webkit-overflow-scrolling:touch;
        padding:12px !important; scroll-padding-block:12px;
    }
    html body :is(.bkg-modal-card,dialog.bkg-mobile-native) :is(input,select,textarea,[contenteditable="true"]) {
        scroll-margin-block:12px;
        font-size:16px !important;
    }
    html body .bkg-modal-body :is(p,small,label,.text-nowrap,pre,.modal-value) {
        white-space:normal !important; overflow-wrap:anywhere; max-width:100%;
        line-height:1.5 !important;
    }
    html body .bkg-modal-body :is(.row,.d-flex,.input-group) { min-width:0; }
    html body .bkg-modal-body > .row { margin-inline:0 !important; width:100% !important; }
    html body .bkg-modal-body :is(.table-responsive,.table-scroll,.table-wrap,.scroller) { max-width:100%; min-width:0; overflow-x:auto !important; }
    html body .bkg-modal-body :is(img,video,iframe) { max-width:100%; }
    html body .bkg-modal-footer {
        box-sizing:border-box; flex-wrap:wrap !important;
        flex:0 0 auto !important; align-items:center; gap:8px !important;
        width:100% !important; max-width:100% !important; margin:0 !important;
        max-height:calc(var(--bkg-modal-height,100dvh) * .45); overflow-y:auto; overflow-x:hidden;
        padding:10px 12px !important;
    }
    html body .bkg-modal-footer:not([hidden]) { display:flex; }
    html body .bkg-modal-footer:empty { display:none !important; }
    html body .bkg-modal-footer > :is(button,a.btn,input[type="submit"],input[type="button"]) {
        flex:1 1 120px !important; width:auto !important; max-width:100% !important; margin:0 !important;
    }
    html body .bkg-modal-footer :is(button,a.btn,input[type="submit"],input[type="button"]) {
        min-height:48px !important; height:auto !important; min-width:48px !important;
        white-space:normal !important; overflow-wrap:anywhere; line-height:1.4 !important;
        padding:9px 12px !important; border-radius:6px !important;
    }
    html body .bkg-modal-footer > :is(.row,form,.btn-group,.d-flex):not(.d-none):not([hidden]) {
        display:flex !important; flex-wrap:wrap !important; gap:8px !important;
        flex:1 1 100%; width:100% !important; min-width:0; max-width:100%; margin:0 !important;
    }
    html body .bkg-modal-footer > .row > [class*="col-"] { flex:1 1 120px; width:auto; padding:0 !important; }
    html body .bkg-modal-footer > .row > [class*="col-"] > :is(button,a.btn) { width:100% !important; }
    html body .bkg-modal-footer .btn-group > .btn { flex:1 1 120px; margin-left:0 !important; }
    html body .bkg-modal-footer.bkg-modal-sticky-actions {
        position:sticky; bottom:0; z-index:2;
        background:var(--bkg-ui-elevated,var(--bs-body-bg,#fff));
        border-top:1px solid var(--bkg-ui-border,#cbd5e1);
    }
    html body .bkg-modal-scroll-card { overflow-y:auto !important; }
    html body .swal2-container { padding:8px !important; max-width:100vw; top:var(--bkg-modal-top,0px) !important; bottom:auto !important; height:var(--bkg-modal-height,100dvh) !important; }
    html body .swal2-popup {
        box-sizing:border-box; width:100% !important; min-width:0 !important;
        max-width:calc(100vw - 16px) !important; max-height:calc(var(--bkg-modal-height,100dvh) - 16px) !important;
        overflow-y:auto; border-radius:8px !important; padding:12px !important;
    }
    html body .swal2-popup :is(.swal2-title,.swal2-html-container) { overflow-wrap:anywhere; min-width:0; max-width:100%; }
    html body .swal2-popup :is(.swal2-input,.swal2-select,.swal2-textarea) { box-sizing:border-box; min-width:0; max-width:100%; width:calc(100% - 24px); margin-inline:12px; }
    html body .swal2-actions { display:flex; flex-wrap:wrap; gap:8px; width:100%; margin:12px 0 0; position:sticky; bottom:0; background:inherit; z-index:1; }
    html body .swal2-actions button { flex:1 1 120px; min-height:48px; margin:0 !important; white-space:normal; overflow-wrap:anywhere; }
}

@media screen and (max-width:1199.98px) {
    :is(html,html body):has(.bkg-mobile-modal:is(.show,[style*="display: flex"],[style*="display:flex"],[style*="display: block"],[style*="display:block"])),
    :is(html,html body):has(dialog.bkg-mobile-native[open]) { zoom:1 !important; }
    html body .bkg-mobile-modal { padding:0 !important; }
    html body .bkg-mobile-modal .bkg-modal-card,
    html body .bkg-mobile-modal .bkg-modal-card.bkg-modal-content-fit {
        height:100% !important;
        min-height:100% !important;
        max-height:100% !important;
        border-radius:0 !important;
    }
    html body dialog.bkg-mobile-native[open] {
        top:var(--bkg-modal-top,0px) !important;
        left:0 !important; right:0 !important;
        width:100% !important; max-width:100% !important;
        height:var(--bkg-modal-height,100dvh) !important;
        max-height:var(--bkg-modal-height,100dvh) !important;
        border-radius:0 !important;
    }
    html body .bkg-modal-card > .bkg-modal-body,
    html body .bkg-modal-card > form > .bkg-modal-body,
    html body #portalMobileNotificationModal .modal-body,
    html body #portalMobileNotificationModal .vo-notification-feed-panel,
    html body #portalMobileNotificationModal .vo-notification-feed-list {
        flex:1 1 auto !important;
        min-height:0 !important;
        max-height:none !important;
    }
    html body #portalMobileNotificationModal .vo-notification-feed-panel { height:100% !important; }
    html body .bkg-modal-header {
        padding-left:max(12px,env(safe-area-inset-left)) !important;
        padding-right:max(12px,env(safe-area-inset-right)) !important;
    }
    html body .bkg-modal-body,
    html body .bkg-modal-footer { padding-bottom:max(12px,env(safe-area-inset-bottom)) !important; }
    html body #editStructureModal.bkg-mobile-modal { padding:0 !important; overflow:hidden !important; }
    html body #editStructureModal .bkg-modal-shell {
        display:flex !important; width:100% !important; max-width:100% !important;
        height:100% !important; margin:0 !important;
    }
    html body #editStructureModal .bkg-modal-card {
        height:100% !important; min-height:100% !important; max-height:100% !important;
        border-radius:0 !important;
    }
    html body #editStructureModal .bkg-modal-body { flex:1 1 auto !important; overflow-y:auto !important; }
}
