/* Final mobile overrides: keep content inside the usable viewport, not clipped. */
@media (max-width:1000px) {
  html { -webkit-text-size-adjust:100%; text-size-adjust:100%; }
  html:root body :is(#publicLanding,#authView,#appView,#communityView,#communityRoot,#portal,#admin) { min-width:0; max-width:100%; }
  html:root body :is(#publicLanding,#authView,#appView,#communityView) { overflow-x:visible; }
  html:root body :is(#scCustomerEntry,.sc-auth-layout,.sc-auth-card,.sc-personal,.sc12-admin,.t31-page) :is(h1,h2,h3,p,label,button,a) { overflow-wrap:anywhere; }
  html:root body :is(.sc-auth-layout,.sc-auth-card,.sc-personal-grid,.sce-preview-panel,.sce-preview-heading,.sce-preview-tabs,.sce-module-rows)>* { min-width:0; }
  html:root body #scCustomerEntry .sce-width { box-sizing:border-box; width:auto; max-width:1240px; margin-left:max(16px,var(--sc-safe-left,0px)); margin-right:max(16px,var(--sc-safe-right,0px)); }
  html:root body #scCustomerEntry .sce-nav { flex-wrap:wrap; gap:4px 18px; overflow:visible; white-space:normal; }
  html:root body #scCustomerEntry .sce-nav a { min-width:0; max-width:100%; }
  html:root body #scCustomerEntry .sce-button { max-width:100%; white-space:normal; text-align:left; }
  html:root body #scCustomerEntry .sce-module p { max-width:100%; }
  html:root body #scCustomerEntry .sce-preview-row { min-width:0; overflow-wrap:anywhere; }
  html:root body #scCustomerEntry .sce-preview-row>* { min-width:0; }
  html:root body #publicLanding .sc-v126-header { flex-wrap:wrap; height:auto!important; gap:10px; }
  html:root body #publicLanding .sc-v126-actions { min-width:0; max-width:100%; flex-wrap:wrap; }
  html:root body #publicLanding .sc-v126-actions :is(button,select) { max-width:100%; white-space:normal; min-height:44px; }
  html:root body :is(.sc-auth-layout,.sc-auth-card) { min-width:0; max-width:100%; height:auto; }
  html:root body :is(#portal .main,.c74-page,#admin .sc12-admin) { padding-left:max(12px,var(--sc-safe-left,0px))!important; padding-right:max(12px,var(--sc-safe-right,0px))!important; }
  /* Wide data stays scrollable in its own labelled region. */
  .sc-mobile-table-scroll { max-width:100%; min-width:0; overflow:auto; overscroll-behavior-x:contain; -webkit-overflow-scrolling:touch; }
  .sc-mobile-table-scroll:focus-visible { outline:2px solid #e8ad73; outline-offset:2px; }
  /* The visual viewport also follows the on-screen keyboard. */
  html:root body :is(.sc12-modal,.t32-modal,.c50-modal) {
    box-sizing:border-box; top:var(--sc-visual-top,0px)!important; bottom:auto!important;
    height:var(--sc-visual-height,100dvh)!important; max-height:var(--sc-visual-height,100dvh)!important;
    padding:var(--sc-safe-top,0px) var(--sc-safe-right,0px) var(--sc-safe-bottom,0px) var(--sc-safe-left,0px)!important;
  }
  html:root body :is(.sc12-modal-card,.t32-modal-card) { box-sizing:border-box; min-width:0; max-width:100%!important; max-height:100%!important; overflow:auto!important; overscroll-behavior:contain; }
  html:root body .c50-modal>div { box-sizing:border-box; min-width:0; max-width:100%!important; max-height:100%!important; overflow:auto!important; }
  html:root body dialog:modal { max-height:calc(var(--sc-visual-height,100dvh) - var(--sc-safe-top,0px) - var(--sc-safe-bottom,0px) - 24px)!important; overflow:auto; }
}
@media (max-width:820px) {
  html:root body .c59-bottom.sc-app-nav { left:0!important; right:0!important; bottom:0!important; transform:none!important; width:100%!important; max-width:100%!important; height:auto!important; min-height:var(--sc-mobile-bottom,80px); border-radius:16px 16px 0 0!important; }
  html:root body .c59-bottom.sc-app-nav>button { min-width:0!important; min-height:56px; white-space:normal!important; }
  html:root body .c59-bottom.sc-app-nav>button span { white-space:normal!important; overflow-wrap:anywhere; }
  html:root body #c50Sheet.sc-app-menu { right:max(8px,var(--sc-safe-right,0px))!important; width:min(320px,calc(100% - var(--sc-safe-left,0px) - var(--sc-safe-right,0px) - 16px))!important; bottom:calc(var(--sc-mobile-bottom,80px) + 8px)!important; max-height:calc(var(--sc-visual-height,100dvh) - var(--sc-mobile-bottom,80px) - var(--sc-safe-top,0px) - 24px)!important; overflow:auto!important; }
  html:root body :is(.c59-main,.c50-main) { padding-bottom:calc(var(--sc-mobile-bottom,80px) + 24px)!important; }
  html:root body #portal .mnav.partner-nav { height:auto!important; min-height:var(--sc-mobile-bottom,80px); }
  html:root body.role-admin.sc-admin-archive #bottomNav { height:auto!important; min-height:var(--sc-mobile-bottom,126px); }
  html:root body .sc12-modal.sc-admin-chat-window .sc-chat-history { min-height:140px!important; height:clamp(140px,40dvh,400px)!important; }
  html:root body .sc12-modal.sc-admin-chat-window .sc-chat-compose { position:static!important; }
}
@media (max-width:480px) {
  html:root body #scCustomerEntry .sce-preview-heading { flex-wrap:wrap; }
  html:root body #scCustomerEntry :is(.sce-preview,.sce-module) { padding:18px 14px; }
  html:root body #scCustomerEntry .sce-preview-tabs button { flex-wrap:wrap; min-width:0; white-space:normal; }
  html:root body #scCustomerEntry .sce-module h2 { margin-right:0; padding-right:48px; font-size:24px; }
  html:root body #scCustomerEntry .sce-module>.sce-line-icon { right:14px; width:34px; height:34px; }
  html:root body #scCustomerEntry .sce-preview-row { gap:10px; padding:14px 12px; }
  html:root body #scCustomerEntry .sce-section-heading h2 { font-size:27px; }
  html:root body .sc-auth-layout { grid-template-columns:minmax(0,1fr)!important; }
}
