/* Presentation-only containment for verified page modal families, 2026-11-11.
   Each shell below has a verified scroll owner. Embedded workbench drawers,
   media previews, report iframes, map canvases and suggestion menus are excluded. */

/* Order workbench: existing head/body shell, including synchronous templates. */
:is(#opportunityModal,#opportunityDetailModal,#statusTimelineModal,#voidOrderModal,#changeEventModal,#pairingSuggestModal,#formModal,#sortSettingsModal,#businessSettingsModal,#fulfillmentScopeModal,#storeDetailModal,#directMakerConfirmModal){box-sizing:border-box;--msc-page-gap:40px}
:is(#opportunityModal,#opportunityDetailModal,#statusTimelineModal,#voidOrderModal,#changeEventModal,#pairingSuggestModal,#formModal,#sortSettingsModal,#businessSettingsModal,#fulfillmentScopeModal,#storeDetailModal)>.panel{box-sizing:border-box;min-height:0;max-width:100%;max-height:calc(100vh - var(--msc-page-gap));max-height:calc(100dvh - var(--msc-page-gap))}
:is(#opportunityModal,#opportunityDetailModal,#statusTimelineModal,#voidOrderModal,#changeEventModal,#pairingSuggestModal,#formModal,#sortSettingsModal,#fulfillmentScopeModal,#storeDetailModal)>.panel>.bd{min-height:0;min-width:0;overscroll-behavior:contain}
#businessSettingsModal>.panel>.account-settings-layout{min-height:0}
#directMakerConfirmModal>.direct-maker-confirm-panel{box-sizing:border-box;min-height:0;max-width:100%;max-height:calc(100vh - 40px);max-height:calc(100dvh - 40px);overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
#businessApprovalDialog{box-sizing:border-box;--msc-page-gap:40px}
#businessApprovalDialog>.business-approval-dialog{box-sizing:border-box;min-height:0;max-height:calc(100vh - var(--msc-page-gap));max-height:calc(100dvh - var(--msc-page-gap))}
#businessApprovalDialog .business-approval-dialog-head{flex:0 0 auto}
#businessApprovalDialog .business-approval-dialog-scroll{flex:1 1 auto;min-height:0;min-width:0;overscroll-behavior:contain;scrollbar-gutter:stable}
/* Named dynamic shells keep their existing children and grid/form rules. */
.ai-review-modal{box-sizing:border-box}
.ai-review-modal>.ai-review-dialog{box-sizing:border-box;min-height:0;max-width:100%;max-height:calc(100vh - 44px);max-height:calc(100dvh - 44px)}
.ai-review-dialog>.ai-review-head{flex:0 0 auto}
.ai-review-dialog>.ai-review-body{flex:1 1 auto;min-height:0;overscroll-behavior:contain}
.device-replacement-modal{box-sizing:border-box}
.device-replacement-modal>.device-replacement-dialog{box-sizing:border-box;min-height:0;max-width:100%;max-height:calc(100vh - 40px);max-height:calc(100dvh - 40px);overscroll-behavior:contain}
:is(.nm-acceptance-dialog,.nm-result-dialog,.map-profile-modal)>.panel{box-sizing:border-box;min-height:0;max-width:100%;max-height:calc(100vh - 40px);max-height:calc(100dvh - 40px)}
:is(.nm-acceptance-dialog,.nm-result-dialog)>.panel{overflow:hidden}
:is(.nm-acceptance-dialog,.nm-result-dialog)>.panel>.hd{flex:0 0 auto}
:is(.nm-acceptance-dialog,.nm-result-dialog)>.panel>.bd{flex:1 1 auto;min-height:0;overscroll-behavior:contain;scrollbar-gutter:stable}
.map-profile-modal>.panel>.bd{min-height:0;max-height:none;overscroll-behavior:contain}

/* Current maker cards are direct-content roots; keep textarea resize and the
   scrollbar visible, with its painted track inset from the rounded corners. */
:is(#makerMatchModal,#makerVoidModal){box-sizing:border-box;--msc-page-gap:44px}
:is(#makerMatchModal,#makerVoidModal)>.maker-void-panel{box-sizing:border-box;min-height:0;max-height:calc(100vh - var(--msc-page-gap));max-height:calc(100dvh - var(--msc-page-gap));overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}

/* Dispatch search, lists and embedded personnel keep their existing grid rows.
   Desktop minimums must not exceed short desktop or zoomed viewports. */
:is(#dispatchOrderSearchModal,#dispatchCrossApprovalModal,#afterSaleWhitelistModal){box-sizing:border-box;--msc-page-gap:40px}
#dispatchPersonnelModal{box-sizing:border-box;--msc-page-gap:36px}
:is(#dispatchOrderSearchModal,#dispatchCrossApprovalModal,#afterSaleWhitelistModal,#dispatchPersonnelModal)>:is(.order-search-modal,.cross-approval-modal,.after-sale-whitelist-modal,.personnel-embed-modal){box-sizing:border-box;min-height:0;max-width:100%;max-height:calc(100vh - var(--msc-page-gap));max-height:calc(100dvh - var(--msc-page-gap))}
:is(#dispatchOrderSearchModal,#afterSaleWhitelistModal,#dispatchPersonnelModal)>:is(.order-search-modal,.after-sale-whitelist-modal,.personnel-embed-modal){height:calc(100vh - var(--msc-page-gap));height:calc(100dvh - var(--msc-page-gap))}
:is(.order-search-layout,.after-sale-whitelist-layout,.personnel-embed-body){min-height:0;min-width:0}
:is(#manualRecordModal,#orderDetailModal){box-sizing:border-box;--msc-page-gap:44px}
:is(#manualRecordModal,#orderDetailModal)>.flow-modal{box-sizing:border-box;display:flex;flex-direction:column;min-height:0;max-width:100%;max-height:calc(100vh - var(--msc-page-gap));max-height:calc(100dvh - var(--msc-page-gap));overflow:hidden}
:is(#manualRecordModal,#orderDetailModal)>.flow-modal>.modal-head{flex:0 0 auto}
:is(#manualRecordModal,#orderDetailModal)>.flow-modal>.modal-body{flex:1 1 auto;min-height:0;min-width:0;max-height:none;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
#assignConfirmModal{box-sizing:border-box}
#assignConfirmModal>.assign-confirm-modal{box-sizing:border-box;min-height:0;max-width:100%;max-height:calc(100vh - 44px);max-height:calc(100dvh - 44px)}
#whitelistGroupChangeModal>.awgc-dialog{box-sizing:border-box;overscroll-behavior:contain;scrollbar-gutter:stable}

/* Dispatch management has a verified direct head/body pair. */
:is(#peopleSettingsModal,#techManagerModal,#backendModal){box-sizing:border-box;--msc-page-gap:48px}
:is(#peopleSettingsModal,#techManagerModal,#backendModal)>.modal-card{box-sizing:border-box;display:flex;flex-direction:column;min-height:0;max-width:100%;max-height:calc(100vh - var(--msc-page-gap));max-height:calc(100dvh - var(--msc-page-gap));overflow:hidden}
:is(#peopleSettingsModal,#techManagerModal,#backendModal)>.modal-card>.modal-head{position:relative;top:auto;flex:0 0 auto}
:is(#peopleSettingsModal,#techManagerModal,#backendModal)>.modal-card>.modal-body{flex:1 1 auto;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}

/* Flat static admin cards receive only an inset scroll wrapper in HTML. Existing
   card padding surrounds the scroll rail, so its rail never crosses the radius. */
:is(#addM,#editM,#listM,#disM,#rptCfgM,#tagMgmtM,#statsM,#techDetailM,#serviceDispatchDetailM){box-sizing:border-box;padding:20px 16px;align-items:center;overflow:hidden;--msc-page-gap:40px}
:is(#addM,#editM,#listM,#disM,#rptCfgM,#tagMgmtM,#statsM)>.modal{box-sizing:border-box;min-height:0;max-height:calc(100vh - 40px);max-height:calc(100dvh - 40px);margin-bottom:0;overflow:auto;overscroll-behavior:contain}
:is(#addM,#editM,#listM,#disM,#rptCfgM,#tagMgmtM,#statsM)>.modal:has(>.msc-page-flat-scroll){display:flex;flex-direction:column;overflow:hidden}
.msc-page-flat-scroll{flex:1 1 auto;min-width:0;min-height:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;padding-right:4px}
#techDetailM>.modal{box-sizing:border-box;min-height:0;max-height:calc(100vh - 40px)!important;max-height:calc(100dvh - 40px)!important;margin-bottom:0;overflow:hidden}
#techDetailM>.modal>:is(.modal-head,#tdStats){flex:0 0 auto}
#techDetailM #tdBody{height:auto!important;flex:1 1 auto;min-height:0}
#techDetailM :is(#tdBig,#tdSmall){min-height:0;overscroll-behavior:contain}
#serviceDispatchDetailM>#serviceDispatchDetailBox{box-sizing:border-box;min-height:0;max-height:calc(100vh - 40px);max-height:calc(100dvh - 40px);margin-bottom:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}

/* Other direct-content cards retain one root scroller. */
:is(#editModal,#settingsModal).modal-overlay{box-sizing:border-box;padding:20px;--msc-page-gap:40px}
:is(#editModal,#settingsModal).modal-overlay>.modal{box-sizing:border-box;min-height:0;max-width:100%;max-height:calc(100vh - 40px);max-height:calc(100dvh - 40px);overscroll-behavior:contain;scrollbar-gutter:stable}
#assignModal.modal-mask{box-sizing:border-box}
#assignModal>.modal{box-sizing:border-box;min-height:0;max-height:calc(100vh - 36px);max-height:calc(100dvh - 36px);overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
#modal.modal:has(>#dialog.dialog){box-sizing:border-box}
#modal>#dialog.dialog{box-sizing:border-box;min-height:0;max-width:100%;max-height:calc(100vh - 40px);max-height:calc(100dvh - 40px);overscroll-behavior:contain;scrollbar-gutter:stable}
#modal.modal>.dialog:has(>.dialog-body){box-sizing:border-box;display:flex;flex-direction:column;min-height:0;max-width:100%;max-height:calc(100vh - 40px);max-height:calc(100dvh - 40px);overflow:hidden}
#modal.modal>.dialog>.dialog-head{position:relative;top:auto;flex:0 0 auto}
#modal.modal>.dialog>.dialog-body{flex:1 1 auto;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
#confirmOverlay{box-sizing:border-box;padding:20px}
#confirmOverlay>.confirm-box{box-sizing:border-box;min-height:0;max-height:calc(100vh - 40px);max-height:calc(100dvh - 40px);overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}

/* Expenses and safe-place editors: existing body owns scroll, chrome stays put. */
#approveModal{box-sizing:border-box}
#approveModal>.modal-box{box-sizing:border-box;display:flex;flex-direction:column;min-height:0;max-height:calc(100vh - 40px);max-height:calc(100dvh - 40px);overflow:hidden}
#approveModal .modal-hd{position:relative;top:auto;flex:0 0 auto}
#approveModal .modal-bd{flex:1 1 auto;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
:is(#editOverlay,#akOverlay){box-sizing:border-box}
:is(#editOverlay,#akOverlay)>.modal{box-sizing:border-box;display:flex;flex-direction:column;min-height:0;max-height:calc(100vh - 32px);max-height:calc(100dvh - 32px);overflow:hidden}
:is(#editOverlay,#akOverlay)>.modal>:is(.modal-head,.modal-foot){flex:0 0 auto}
:is(#editOverlay,#akOverlay)>.modal>.modal-body{flex:1 1 auto;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}

/* General management: preserve the wide personnel console's intentional columns. */
:is(#profileOverlay,#peopleOverlay,#devClearOverlay){box-sizing:border-box;--msc-page-gap:44px}
:is(#profileOverlay,#devClearOverlay)>:is(.profile-modal,.dev-clear-modal){box-sizing:border-box;display:flex;flex-direction:column;min-height:0;max-width:100%;max-height:calc(100vh - 44px);max-height:calc(100dvh - 44px);overflow:hidden}
:is(.profile-modal,.dev-clear-modal)>:is(.profile-head,.dev-clear-head){flex:0 0 auto}
:is(.profile-modal,.dev-clear-modal)>:is(.profile-body,.dev-clear-body){flex:1 1 auto;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
#peopleOverlay>.people-modal{box-sizing:border-box;min-height:0;max-width:100%;max-height:calc(100vh - 44px);max-height:calc(100dvh - 44px)}
.field-detail-drawer>.field-detail-panel,.hub-order-drawer>.hub-order-panel{box-sizing:border-box;max-height:100vh;max-height:100dvh;overscroll-behavior:contain}
@media(max-width:1320px){#peopleOverlay>.people-modal{overflow:hidden}#peopleOverlay .people-body{min-height:0;overflow:auto;overscroll-behavior:contain}}

/* Portal cards use independent masks; only visible card state locks the root. */
:is(#loginModal,#changelogModal){box-sizing:border-box;display:flex;flex-direction:column;min-height:0;max-height:calc(100vh - 32px);max-height:calc(100dvh - 32px)}
:is(#loginModal,#changelogModal)>.modal-head{flex:0 0 auto}
#loginModal>.modal-body,#changelogModal>.changelog-body{flex:1 1 auto;min-height:0;min-width:0;overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable}

/* Inset scrollbar paint on verified direct-content roots only. No scrollbar is
   hidden, and no clip/overflow rule is applied to nested menus or media. */
:is(#makerMatchModal,#makerVoidModal)>.maker-void-panel::-webkit-scrollbar,
#directMakerConfirmModal>.direct-maker-confirm-panel::-webkit-scrollbar,
.device-replacement-modal>.device-replacement-dialog::-webkit-scrollbar,
#serviceDispatchDetailM>#serviceDispatchDetailBox::-webkit-scrollbar,
:is(#editModal,#settingsModal).modal-overlay>.modal::-webkit-scrollbar,
#assignModal>.modal::-webkit-scrollbar,#modal>#dialog.dialog::-webkit-scrollbar,
#confirmOverlay>.confirm-box::-webkit-scrollbar{width:10px;height:10px}
:is(#makerMatchModal,#makerVoidModal)>.maker-void-panel::-webkit-scrollbar-track,
#directMakerConfirmModal>.direct-maker-confirm-panel::-webkit-scrollbar-track,
.device-replacement-modal>.device-replacement-dialog::-webkit-scrollbar-track,
#serviceDispatchDetailM>#serviceDispatchDetailBox::-webkit-scrollbar-track,
:is(#editModal,#settingsModal).modal-overlay>.modal::-webkit-scrollbar-track,
#assignModal>.modal::-webkit-scrollbar-track,#modal>#dialog.dialog::-webkit-scrollbar-track,
#confirmOverlay>.confirm-box::-webkit-scrollbar-track{margin:16px 0;background:transparent}
:is(#makerMatchModal,#makerVoidModal)>.maker-void-panel::-webkit-scrollbar-thumb,
#directMakerConfirmModal>.direct-maker-confirm-panel::-webkit-scrollbar-thumb,
.device-replacement-modal>.device-replacement-dialog::-webkit-scrollbar-thumb,
#serviceDispatchDetailM>#serviceDispatchDetailBox::-webkit-scrollbar-thumb,
:is(#editModal,#settingsModal).modal-overlay>.modal::-webkit-scrollbar-thumb,
#assignModal>.modal::-webkit-scrollbar-thumb,#modal>#dialog.dialog::-webkit-scrollbar-thumb,
#confirmOverlay>.confirm-box::-webkit-scrollbar-thumb{border:3px solid transparent;border-radius:999px;background:rgba(89,107,97,.55);background-clip:padding-box}

@media(max-width:760px){
 :is(#dispatchOrderSearchModal,#dispatchCrossApprovalModal,#afterSaleWhitelistModal,#dispatchPersonnelModal){--msc-page-gap:16px}
}
@media(max-width:640px){
 :is(#makerMatchModal,#makerVoidModal){--msc-page-gap:24px}
 #businessApprovalDialog{--msc-page-gap:16px}
}

/* True open states only. Hidden mounted elements and in-page drawers do not lock
   the background. Native top-layer dialogs are handled by their named families. */
:is(html,body):has(:is(#opportunityModal,#opportunityDetailModal,#statusTimelineModal,#voidOrderModal,#changeEventModal,#pairingSuggestModal,#formModal,#sortSettingsModal,#businessSettingsModal,#fulfillmentScopeModal,#storeDetailModal,#directMakerConfirmModal).show:not([hidden])),
:is(html,body):has(#businessApprovalDialog:not([hidden])),
:is(html,body):has(:is(.ai-review-modal,.device-replacement-modal).show),
:is(html,body):has(:is(.nm-acceptance-dialog,.nm-result-dialog,.map-profile-modal).show:not([hidden])),
:is(html,body):has(:is(#makerMatchModal,#makerVoidModal):not([hidden])),
:is(html,body):has(:is(#dispatchOrderSearchModal,#dispatchCrossApprovalModal,#afterSaleWhitelistModal,#dispatchPersonnelModal,#manualRecordModal,#orderDetailModal,#assignConfirmModal).show:not([hidden])),
:is(html,body):has(#whitelistGroupChangeModal:not([hidden])),
:is(html,body):has(:is(#peopleSettingsModal,#techManagerModal,#backendModal).show),
:is(html,body):has(:is(#addM,#editM,#listM,#disM,#rptCfgM,#tagMgmtM,#statsM,#techDetailM,#serviceDispatchDetailM).show),
:is(html,body):has(:is(#editModal,#settingsModal).modal-overlay.show),
:is(html,body):has(#assignModal:not(.hidden):not([hidden])),
:is(html,body):has(#modal.modal.show>#dialog.dialog),
:is(html,body):has(#modal.modal.show>.dialog>.dialog-body),
:is(html,body):has(:is(.field-detail-drawer,.hub-order-drawer,.rrzu-dossier-drawer):not([hidden])),
:is(html,body):has(:is(#approveModal,#confirmOverlay).open),
:is(html,body):has(:is(#editOverlay,#akOverlay,#profileOverlay,#peopleOverlay,#devClearOverlay).show),
:is(html,body):has(:is(#loginModal,#changelogModal):not(.hidden)){
 overflow:hidden!important;
}

/* risk-service-families: verified by the focused current-DOM matrix. */
/* Local presentation candidate: verified modal families only; no workflow rules. */

/* Match actual open state, so mounted closed panels never lock the document. */
html:has(:is(#managementTreeModal,#peopleManagerModal,#workspaceSettingsOverlay,#vipEditMask,#vipVisitMask,#contentEditorMask,#notifyModal).show:not([hidden])),
body:has(:is(#managementTreeModal,#peopleManagerModal,#workspaceSettingsOverlay,#vipEditMask,#vipVisitMask,#contentEditorMask,#notifyModal).show:not([hidden])),
html:has(#compApprovalModal:not(.hidden):not([hidden]):not([aria-hidden="true"])),
body:has(#compApprovalModal:not(.hidden):not([hidden]):not([aria-hidden="true"])),
html:has(:is(#rkaDrawerMask,.rka-drawer-mask).open:not([hidden])),
body:has(:is(#rkaDrawerMask,.rka-drawer-mask).open:not([hidden])),
html:has(.rrzu-risk-drawer:not([hidden])),
body:has(.rrzu-risk-drawer:not([hidden])),
html:has(.rrzu-account-shell:not([hidden])),
body:has(.rrzu-account-shell:not([hidden])),
html:has(dialog:is(#manualRiskDialog,#historySourceDialog,#yujianReportDialog,#receiptDialog,#costDialog,#ruleDialog,#editor,#reportOrderDialog,#rrzuLoginRequired)[open]),
body:has(dialog:is(#manualRiskDialog,#historySourceDialog,#yujianReportDialog,#receiptDialog,#costDialog,#ruleDialog,#editor,#reportOrderDialog,#rrzuLoginRequired)[open]) {
  overflow: hidden;
}

/* Verified structured shells: chrome stays inside the available viewport. */
:is(#managementTreeModal,#peopleManagerModal) {
  box-sizing: border-box;
}
:is(#managementTreeModal,#peopleManagerModal) > .modal-card {
  box-sizing: border-box;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
:is(#managementTreeModal,#peopleManagerModal) > .modal-card > .modal-head {
  flex: 0 0 auto;
}
:is(#managementTreeModal,#peopleManagerModal) > .modal-card > .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#workspaceSettingsOverlay {
  box-sizing: border-box;
}
#workspaceSettingsOverlay > .ws-modal {
  box-sizing: border-box;
  max-width: 100%;
  max-height: calc(100vh - 52px);
  max-height: calc(100dvh - 52px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#workspaceSettingsOverlay > .ws-modal > :is(.ws-head,.ws-tabs) {
  flex: 0 0 auto;
}
#workspaceSettingsOverlay > .ws-modal > .ws-body {
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#historySourceDialog.hist-source-dialog {
  box-sizing: border-box;
  min-height: 0;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: hidden;
}
#historySourceDialog.hist-source-dialog > .hist-source-body {
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#compApprovalModal {
  box-sizing: border-box;
}
#compApprovalModal > .comp-approval-dialog {
  box-sizing: border-box;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#compApprovalModal > .comp-approval-dialog > :is(.comp-approval-head,.comp-approval-actions) {
  flex: 0 0 auto;
}
#compApprovalModal > .comp-approval-dialog > .comp-approval-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

#notifyModal {
  box-sizing: border-box;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  min-height: 0;
}
#notifyModal.show {
  display: flex;
  flex-direction: column;
}
#notifyModal > :is(.m-hd,.m-ft) {
  flex: 0 0 auto;
}
#notifyModal > .m-bd {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

/* Direct form dialogs keep native top-layer behavior and one scroll owner. */
dialog:is(#manualRiskDialog,#receiptDialog,#costDialog,#ruleDialog,#editor,#reportOrderDialog,#rrzuLoginRequired) {
  box-sizing: border-box;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
}
dialog:is(#manualRiskDialog,#receiptDialog,#costDialog,#ruleDialog,#editor,#reportOrderDialog,#rrzuLoginRequired)::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
dialog:is(#manualRiskDialog,#receiptDialog,#costDialog,#ruleDialog,#editor,#reportOrderDialog,#rrzuLoginRequired)::-webkit-scrollbar-track {
  margin-block: 18px;
  background: transparent;
}
dialog:is(#manualRiskDialog,#receiptDialog,#costDialog,#ruleDialog,#editor,#reportOrderDialog,#rrzuLoginRequired)::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: #a6b4ab;
  background-clip: padding-box;
}

/* Customer cards have no body wrapper; retain their existing card scrolling. */
:is(#vipEditMask,#vipVisitMask,#contentEditorMask) {
  box-sizing: border-box;
}
:is(#vipEditMask,#vipVisitMask,#contentEditorMask) > .modal {
  box-sizing: border-box;
  max-width: 100%;
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scrollbar-width: auto;
}
:is(#vipEditMask,#vipVisitMask,#contentEditorMask) > .modal::-webkit-scrollbar-track {
  margin-block: 20px;
}

/* Non-WebKit engines keep their native thin scrollbar; WebKit track insets
   require scrollbar-width:auto so the standard property does not override them. */
@supports not selector(::-webkit-scrollbar) {
  dialog:is(#manualRiskDialog,#receiptDialog,#costDialog,#ruleDialog,#editor,#reportOrderDialog,#rrzuLoginRequired),
  :is(#vipEditMask,#vipVisitMask,#contentEditorMask) > .modal {
    scrollbar-width: thin;
  }
}

/* Square full-height drawers retain their own scroll/sticky-header model. */
.rrzu-risk-drawer > .rrzu-risk-panel {
  box-sizing: border-box;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overscroll-behavior: contain;
}
.rka-drawer-mask > .rka-drawer,
.rrzu-account-shell > .rrzu-account-drawer {
  box-sizing: border-box;
  max-height: 100vh;
  max-height: 100dvh;
  overscroll-behavior: contain;
}

@media (max-width: 820px) {
  #workspaceSettingsOverlay > .ws-modal {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }
}
@media (max-width: 700px) {
  #compApprovalModal > .comp-approval-dialog {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }
}
@media (max-width: 560px) {
  #historySourceDialog.hist-source-dialog {
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
  }
}

/* Technical pages only: rounded shells contain bounded, separate scroll bodies. */
html.tech-modal-scroll-page :is(.modal-overlay,.transfer-overlay) > .modal-box {
  display:flex;
  flex-direction:column;
  min-height:0;
  max-height:min(92vh,calc(100vh - 40px));
  max-height:min(92dvh,calc(100dvh - 40px));
  overflow:hidden;
  scrollbar-gutter:auto;
}
html.tech-modal-scroll-page :is(.customer-detail-modal,.done-info-modal,.team-readonly-modal,.personal-performance-modal,.stats-points-modal) > .modal-box {
  max-height:min(88vh,calc(100vh - 40px));
  max-height:min(88dvh,calc(100dvh - 40px));
}
html.tech-modal-scroll-page :is(.after-pool-detail-modal,.reminder-detail-modal) > .modal-box {
  max-height:min(86vh,calc(100vh - 40px));
  max-height:min(86dvh,calc(100dvh - 40px));
}
html.tech-modal-scroll-page :is(
  #customerDetailBody,#teamTaskReadBody,#doneInfoModalBody,#afterPoolDetailBody,
  #insightModalBody,#reminderDetailBody,#addressChangeDetailBody,.tech-modal-scroll-body
) {
  flex:1 1 auto;
  min-width:0;
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
  padding:2px 6px 2px 2px;
}
html.tech-modal-scroll-page .modal-box > :is(
  h3,.modal-btns,.address-change-modal-head,.fail-console-head,
  .transfer-head,.transfer-mode-strip,.personal-performance-head,.stats-points-head
) {flex:0 0 auto}
html.tech-modal-scroll-page :is(.fail-console-grid,.transfer-layout) {
  flex:1 1 auto;
  min-height:0;
  max-height:none;
  overflow:auto;
  overscroll-behavior:contain;
}
html.tech-modal-scroll-page :is(.personal-performance-body,.stats-points-body) {
  flex:1 1 auto;
  min-height:0;
  max-height:none;
  margin:0 12px 12px;
  padding:16px 6px 10px;
  overflow:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}
html.tech-modal-scroll-page :is(.modal-overlay,.transfer-overlay,.field-expense-overlay,.add-after-modal,.add-after-submit-block,#tobModal) {
  overscroll-behavior:contain;
}
html.tech-modal-scroll-page :is(.field-expense-modal,.add-after-card,.add-after-submit-block-card,.tech-whitelist-card),
html.tech-modal-scroll-page #tobModal > .c {
  min-height:0;
  max-height:calc(100vh - 40px);
  max-height:calc(100dvh - 40px);
}
html.tech-modal-scroll-page .add-after-submit-block-card {
  display:flex;
  flex-direction:column;
}
html.tech-modal-scroll-page :is(.field-expense-head,.field-expense-footer,.add-after-head,.add-after-foot,.add-after-submit-block-head,.add-after-submit-block-foot),
html.tech-modal-scroll-page #tobModal > .c > :is(.h,.bar,.ft) {flex:0 0 auto}
html.tech-modal-scroll-page :is(.field-expense-body,.add-after-body,.add-after-submit-block-body),
html.tech-modal-scroll-page #tobModal > .c > .body {
  flex:1 1 auto;
  min-width:0;
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}
html.tech-modal-scroll-page .tech-whitelist-list {
  margin:0 10px 12px;
  padding:12px 6px 4px;
  overscroll-behavior:contain;
}
html.tech-modal-scroll-page #compModal {
  flex-direction:column;
  min-height:0;
  max-height:calc(100vh - 40px);
  max-height:calc(100dvh - 40px);
  overflow:hidden;
}
html.tech-modal-scroll-page #compModal:is([style*="display: block"],[style*="display:block"]) {display:flex!important}
html.tech-modal-scroll-page #compModal > :is(.h,.f) {flex:0 0 auto}
html.tech-modal-scroll-page #compModal > .b {
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}
html.tech-modal-scroll-page .tech-mobile-download-dialog {
  min-height:0;
  max-height:calc(100vh - 32px);
  max-height:calc(100dvh - 32px);
  padding:14px;
  overflow:hidden;
}
html.tech-modal-scroll-page .tech-mobile-download-dialog[open] {display:flex;flex-direction:column}
html.tech-modal-scroll-page .tech-mobile-download-dialog > .tech-mobile-download-panel {
  flex:1 1 auto;
  min-height:0;
  padding:16px;
  overflow:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}
html.tech-modal-scroll-page .tech-mobile-download-dialog .tech-mobile-download-close {
  position:sticky;
  top:0;
  float:right;
  margin:-4px -4px -30px 0;
  z-index:2;
}
html:is(.tech-modal-scroll-page,.tech-sheet-scroll-page) .tech-confirm-overlay {padding:20px;overscroll-behavior:contain}
html:is(.tech-modal-scroll-page,.tech-sheet-scroll-page) .tech-confirm-box {
  display:flex;
  flex-direction:column;
  min-height:0;
  max-height:calc(100vh - 40px);
  max-height:calc(100dvh - 40px);
  overflow:hidden;
}
html:is(.tech-modal-scroll-page,.tech-sheet-scroll-page) .tech-confirm-body {
  flex:1 1 auto;
  min-height:0;
  overflow:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}
html:is(.tech-modal-scroll-page,.tech-sheet-scroll-page) .tech-confirm-actions {flex:0 0 auto}
html.tech-modal-scroll-page :is(.modal-overlay,.transfer-overlay,.field-expense-overlay,.add-after-modal,.add-after-submit-block,#tobModal,#compModal,.tech-mobile-download-dialog)[hidden] {display:none!important}
/* The existing password form has flat siblings and is created as inline markup.
   Keep the full form reachable; inset its scrollbar track within the curved shell. */
html.tech-modal-scroll-page #changePwOverlay {padding:20px;overscroll-behavior:contain}
html.tech-modal-scroll-page #changePwOverlay > div {
  max-height:calc(100vh - 40px);
  max-height:calc(100dvh - 40px);
  overflow:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}
html.tech-modal-scroll-page #changePwOverlay > div::-webkit-scrollbar-track {margin-block:18px}

/* Public technical-task bottom sheets preserve their existing controls and IDs. */
html.tech-sheet-scroll-page :is(.fail-overlay,#debugModal) {overscroll-behavior:contain}
html.tech-sheet-scroll-page :is(#failModal,#debugModal,.tech-confirm-overlay)[hidden] {display:none!important}
html.tech-sheet-scroll-page #debugModal {align-items:flex-end;justify-content:center}
html.tech-sheet-scroll-page :is(.fail-modal,.tech-debug-sheet) {
  display:flex;
  flex-direction:column;
  min-height:0;
  max-height:calc(100vh - 16px)!important;
  max-height:calc(100dvh - 16px)!important;
  overflow:hidden!important;
}
html.tech-sheet-scroll-page :is(.fail-modal,.tech-debug-sheet) > :not(.tech-sheet-scroll-body) {flex:0 0 auto}
html.tech-sheet-scroll-page .tech-sheet-scroll-body {
  flex:1 1 auto;
  min-height:0;
  padding:2px 8px 2px 2px;
  overflow:auto;
  overscroll-behavior:contain;
  scrollbar-gutter:stable;
}

/* Lock only actual open technical overlays. Hidden siblings do not lock pages. */
@supports selector(html:has(body)) {
  html.tech-modal-scroll-page:has(body > :is(.modal-overlay,.transfer-overlay,.field-expense-overlay).show:not([hidden]):not([style*="display: none"]):not([style*="display:none"])),
  html.tech-modal-scroll-page:has(body > .modal-overlay:is([style*="display: flex"],[style*="display:flex"]):not([hidden])),
  html.tech-modal-scroll-page:has(#appPage:not([hidden]):not([style*="display: none"]):not([style*="display:none"]) #pitView:not([hidden]):not([style*="display: none"]):not([style*="display:none"]) :is(#pitModal,#pitAppendModal):is([style*="display: flex"],[style*="display:flex"]):not([hidden])),
  html.tech-modal-scroll-page:has(body > :is(.add-after-modal,.add-after-submit-block,.tech-confirm-overlay,#changePwOverlay):not([hidden]):not([style*="display: none"]):not([style*="display:none"])),
  html.tech-modal-scroll-page:has(#compModal:is([style*="display: block"],[style*="display:block"]):not([hidden])),
  html.tech-modal-scroll-page:has(#tobModal.show:not([hidden]):not([style*="display: none"]):not([style*="display:none"])),
  html.tech-modal-scroll-page:has(.tech-mobile-download-dialog[open]:not([hidden]):not([style*="display: none"]):not([style*="display:none"])),
  html.tech-sheet-scroll-page:has(body > .tech-confirm-overlay:not([hidden]):not([style*="display: none"]):not([style*="display:none"])),
  html.tech-sheet-scroll-page:has(body > #failModal:not([hidden]):not([style*="display: none"]):not([style*="display:none"]) > .fail-overlay),
  html.tech-sheet-scroll-page:has(#app:not([hidden]):not([style*="display: none"]):not([style*="display:none"]) #failModal:not([hidden]):not([style*="display: none"]):not([style*="display:none"]) > .fail-overlay),
  html.tech-sheet-scroll-page:has(body > #debugModal:is([style*="display: flex"],[style*="display:flex"]):not([hidden])),
  html.tech-sheet-scroll-page:has(#app:not([hidden]):not([style*="display: none"]):not([style*="display:none"]) #debugModal:is([style*="display: flex"],[style*="display:flex"]):not([hidden])) {
    overflow:hidden;
  }
}
@media (max-width:620px) {
  html.tech-modal-scroll-page .modal-box :is(.customer-detail-grid,.customer-device-list) {grid-template-columns:minmax(0,1fr)}
  html.tech-modal-scroll-page .modal-box .customer-detail-head {flex-wrap:wrap}
  html.tech-modal-scroll-page .modal-box .customer-detail-kv {grid-template-columns:72px minmax(0,1fr)}
}
@media (max-height:480px) {
  html.tech-modal-scroll-page :is(.personal-performance-head,.stats-points-head,.fail-console-head,.transfer-head) {padding-top:10px;padding-bottom:10px}
  html.tech-modal-scroll-page .tech-whitelist-head {padding:10px 16px}
  html.tech-modal-scroll-page .tech-whitelist-summary {padding:8px 16px}
  html.tech-modal-scroll-page .tech-whitelist-help {margin-top:6px;padding:6px 10px}
}


/* The live-room dialog sets body overflow itself; also contain the viewport
   where the application uses html as its scroll owner. */
@supports selector(html:has(body)) {
  html:has(>body>#tx-livestream-modal.ol-overlay:not([hidden]):not([style*="display: none"]):not([style*="display:none"])) {overflow:hidden}
}

/* The status belongs to the pending summary, not the full height of the card. */
#appPage .pending-bar.pb-collapsible{padding-inline:16px;cursor:default}
#appPage .pending-bar.pb-collapsible::before{content:none}
#appPage .pb-collapsible .pb-toggle{
  display:block;width:100%;min-width:0;padding:0;border:0;border-radius:12px;
  background:none;color:inherit;font:inherit;text-align:left;cursor:pointer;
}
#appPage .pb-collapsible .pb-toggle:focus-visible{outline:2px solid var(--wz-action);outline-offset:4px}
#appPage .pb-collapsible .pb-toggle-head{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:10px;align-items:start}
#appPage .pb-collapsible .pb-row2,#appPage .pb-collapsible .pb-preview{display:block}
#appPage .pb-collapsible .pb-task-name{font-size:14px;font-weight:700;margin-left:auto}
#appPage .pb-collapsible .pb-status{display:inline-flex;align-items:center;gap:5px;flex:none;white-space:nowrap}
#appPage .pb-collapsible .pb-status::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor;flex:none}
#appPage .pb-collapsible:is(.urgent-5,.overdue) .pb-status{color:var(--wz-danger);background:var(--wz-danger-bg)}
#appPage .pb-collapsible .pb-toggle-indicator{
  display:inline-flex;align-items:center;gap:5px;min-height:28px;padding:4px 8px;
  border:1px solid var(--wz-border);border-radius:9px;background:var(--wz-surface);
  color:var(--wz-action);font-size:12px;font-weight:750;line-height:1.4;white-space:nowrap;
}
#appPage .pb-collapsible .pb-toggle:hover .pb-toggle-indicator{background:var(--wz-surface-2);border-color:var(--wz-border-strong)}
#appPage .pb-collapsible .pb-toggle-arrow{display:inline-block;font-size:15px;line-height:1;transform:translateY(-2px)}
#appPage .pb-collapsible .pb-toggle[aria-expanded="true"] .pb-toggle-arrow{transform:translateY(2px) rotate(180deg)}
#appPage .pb-collapsible .pb-detail[hidden]{display:none}
@media(max-width:620px){
  #appPage .pending-bar.pb-collapsible{padding-inline:12px}
  #appPage .pb-collapsible .pb-toggle-head{gap:6px}
  #appPage .pb-collapsible .pb-task-name{margin-left:0}
}
