/* Keep dialogs above mobile navigation and wide content inside its own viewport. */
@media screen and (max-width:800px){
  body{padding-bottom:0}
  #menuButton{display:inline-flex;align-items:center;justify-content:center;width:44px;height:44px;color:#fff;font-size:27px}
  #sidebar,#sidebar.open{top:64px;bottom:0;left:0;right:auto;width:min(300px,88vw);height:auto;box-sizing:border-box;padding:12px;overflow-y:auto;overflow-x:hidden;display:block;z-index:40;transform:translateX(-105%);visibility:hidden;transition:transform .2s ease,visibility .2s;box-shadow:8px 0 24px #06111c44}
  #sidebar.open{transform:translateX(0);visibility:visible}
  #sidebar .nav{width:100%;height:auto;min-height:46px;min-width:0;flex-direction:row;justify-content:flex-start;gap:12px;padding:12px;margin:3px 0;font-size:20px;white-space:normal;text-align:left}
  #sidebar .nav span{font-size:16px;line-height:1.35}
  #sidebar .sidebar-business-name{display:block}
  #sidebar .sidebar-footer{display:block;position:static;margin:18px 12px;padding-bottom:env(safe-area-inset-bottom)}
}
@media screen {
  .modal-backdrop{z-index:100;overflow:hidden;isolation:isolate}
  .modal{box-sizing:border-box;min-width:0;max-height:92dvh;overscroll-behavior:contain}
  .modal label,.modal section,.form-grid>*{min-width:0}
  .modal input,.modal select,.modal textarea{box-sizing:border-box;max-width:100%;min-width:0}
  main{min-width:0;box-sizing:border-box}
  main>.paper,main .print-sheet{box-sizing:border-box;max-width:100%!important;overflow-x:auto!important;overscroll-behavior-x:contain}
  .page-heading>div{min-width:0}
}
@media screen and (max-width:800px){
  .modal-backdrop{padding:8px;align-items:center}
  .modal{width:100%;max-width:100%;max-height:calc(100dvh - 16px);border-radius:12px;padding:16px;padding-bottom:max(16px,env(safe-area-inset-bottom))}
  .sale-primary-choices,.matrix-top,.form-grid,.form-grid.four{grid-template-columns:minmax(0,1fr)!important}
  .sale-checkout .checkout-line{min-width:0;overflow-wrap:anywhere}
  .checkout-line>div,.checkout-lens-fields{min-width:0;max-width:100%}
  .checkout-lens-fields{flex-wrap:wrap}.checkout-lens-fields select{width:100%}
  main>.paper,main .print-sheet{width:100%!important;min-height:0!important;max-height:none!important;margin:12px 0!important;padding:12px!important}
  .paper table{min-width:560px!important}
  .paper .info,.paper .sign{min-width:0;gap:8px;overflow-wrap:anywhere}
  .page-heading>div:last-child{display:flex;flex-wrap:wrap;gap:8px;max-width:100%}
  .page-heading .button{white-space:normal;min-height:44px}
  .modal .notice{overflow-wrap:anywhere}
  .modal-actions{padding-bottom:env(safe-area-inset-bottom)}
}
