/* Shared layout bounds for staff and client mini apps. */
*,*::before,*::after{box-sizing:border-box}
html,body{max-width:100%;overflow-x:clip}
:where(main,section,article,form,fieldset,label,.block,.row,.two,.identity-row,.cart-tools,.mini-header nav){min-width:0}
:where(form,fieldset,label,input,textarea,select){max-width:100%;min-width:0}
fieldset{margin-inline:0}
input:not([type=checkbox]):not([type=radio]):not([type=hidden]),textarea,select{box-sizing:border-box;max-inline-size:100%;min-inline-size:0}
textarea{resize:vertical}
:where(p,label,h1,h2,h3,.line-name,.description,.customer-title){overflow-wrap:anywhere}
:where(img,video,canvas,iframe){max-width:100%}
:where(.two,.filter-grid,.delivery-slot,.catalog-tools)>*{min-width:0;max-width:100%}
:where(.cart-tools,.inline-actions,.sheet-actions,.mini-header nav){flex-wrap:wrap}
button{max-width:100%}
button:not(.icon){overflow-wrap:anywhere}
/* One centered, keyboard-bounded surface for every compact app dialog. */
body dialog:not(#viewer):not(#jd-connection){
 position:fixed!important;
 top:calc(var(--visible-top,0px) + 12px + env(safe-area-inset-top,0px))!important;
 bottom:max(12px,calc(100dvh - var(--visible-top,0px) - var(--visible-height,100dvh) + 12px + env(safe-area-inset-bottom,0px)))!important;
 left:12px!important;right:12px!important;margin:auto!important;transform:none!important;
 width:min(var(--jd-dialog-width,480px),calc(100% - 24px))!important;max-width:calc(100% - 24px)!important;
 height:fit-content!important;max-height:calc(var(--visible-height,100dvh) - 24px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px))!important;
 min-width:0!important;min-height:0!important;overflow:auto!important;overscroll-behavior:contain;
 overflow-wrap:anywhere;border-radius:18px!important;box-sizing:border-box;scroll-padding:12px;
}
body dialog#modal{--jd-dialog-width:560px}
body dialog#order-info-popup,body dialog#msk-delivery-choice{--jd-dialog-width:380px}
body dialog.receiving-calendar{--jd-dialog-width:320px}
body dialog.jd-product-card-dialog,body dialog#modal.jd-product-card-dialog{--jd-dialog-width:480px}
body dialog#sheet:has(#simple-pay){--jd-dialog-width:380px}
/* File viewing keeps the entire visible viewport available for zoom/scroll. */
body dialog#viewer{
 position:fixed!important;top:var(--visible-top,0px)!important;bottom:auto!important;left:0!important;right:0!important;
 margin:0!important;transform:none!important;width:100%!important;max-width:100%!important;
 height:var(--visible-height,100dvh)!important;max-height:var(--visible-height,100dvh)!important;
 padding:0!important;border-radius:0!important;overflow:hidden!important;box-sizing:border-box;
}
dialog :where(form,section,div,label,fieldset){min-width:0;max-width:100%}
dialog :where(img,video){object-fit:contain;max-height:calc(var(--visible-height,100dvh) - 120px);height:auto}
dialog :where(pre,table){max-width:100%;overflow:auto}
@media(max-width:380px){.delivery-slot{grid-template-columns:minmax(0,1.2fr) minmax(0,1fr) minmax(0,1fr)}.cart-tools{gap:5px}.customer-mini .mini-header{gap:4px;padding-inline:8px}.mini-header button{padding-inline:8px}}

/* Keyboard: settle once above the keyboard instead of recentering each frame. */
@media(max-width:600px) and (pointer:coarse){
 html.jd-keyboard-open body dialog:not(#viewer):not(#jd-connection),
 body dialog:not(#viewer):not(#jd-connection):has(textarea:focus,[contenteditable="true"]:focus,input:not([type=file]):not([type=checkbox]):not([type=radio]):focus){
  top:calc(var(--visible-top,0px) + 12px + env(safe-area-inset-top,0px))!important;
  bottom:auto!important;margin-block:0!important;transition:none!important;
  max-height:calc(var(--visible-height,100dvh) - 24px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px))!important;
  scroll-padding-block:16px;overflow-anchor:none;
 }
 body dialog input:not([type=checkbox]):not([type=radio]),body dialog textarea,body dialog select{font-size:16px!important}
 html.jd-keyboard-open dialog :is(.filter-footer,.pay-file-actions,.inline-actions){flex-shrink:0}
}
