/* RICHHOME admin touch scroll v1. Document owns vertical scrolling on phones
   and touch tablets; PC layout, dialogs, drawers and horizontal tables remain independent. */
@media (max-width: 900px), (max-width: 1366px) and (any-pointer: coarse) {
  html:root:has(#app > .layout),
  html:root body:has(#app > .layout) {
    height: auto !important; max-height: none !important;
    min-height: 100vh !important; min-height: 100dvh !important;
    overflow-x: clip !important; overflow-y: visible !important;
    overscroll-behavior-y: auto !important;
  }
  html:root:has(#app > .layout) { overflow-y: auto !important; }
  html:root body:has(#app > .layout) #app,
  html:root body:has(#app > .layout) #app > .layout {
    height: auto !important; max-height: none !important;
    min-height: 100vh !important; min-height: 100dvh !important;
    overflow: visible !important;
  }
  html:root body:has(#app > .layout) #app > .layout {
    align-content: start !important; grid-template-rows: auto !important;
  }
  html:root body:has(#app > .layout) #app > .layout > .content {
    display: block !important; flex: none !important;
    grid-row: auto !important; height: auto !important;
    min-height: 0 !important; max-height: none !important; min-width: 0 !important;
    overflow: visible !important; overscroll-behavior: auto !important;
    touch-action: auto !important;
    padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)) !important;
  }
  html:root body:has(#app > .layout) #app > .layout > .content > .top {
    position: relative !important; top: auto !important;
  }
  html:root body:has(#app > .layout) #app > .layout > .content > .quotation-editor,
  html:root body:has(#app > .layout) #order-management-page,
  html:root body:has(#app > .layout) #work-type-management-page,
  html:root body:has(#app > .layout) #work-type-management-page :is(.work-type-pane,.work-type-grid,.work-type-editor) {
    flex: none !important; height: auto !important; min-height: 0 !important;
    max-height: none !important; overflow: visible !important;
    overscroll-behavior: auto !important; touch-action: auto !important;
  }
  html:root body:has(#app > .layout) #app > .layout > .content .dashboard-table-panel,
  html:root body:has(#app > .layout) #order-management-page > .table-panel,
  html:root body:has(#app > .layout) .completion-review-page > .table-panel,
  html:root body:has(#app > .layout) #technician-login-status-page .member-table-panel {
    flex: none !important; height: auto !important; min-height: 0 !important;
    max-height: none !important; max-width: 100%;
    overflow-x: auto !important; overflow-y: hidden !important;
    overscroll-behavior-y: auto !important; touch-action: pan-x pan-y !important;
  }
  /* The ledger installs its stylesheet dynamically after the shell renders.
     Use explicit shell selectors so these rules win regardless of insertion order. */
  html:root body:has(#rh-unified) #app > .layout > .content > #rh-unified,
  html:root body:has(#rh-unified) #app > .layout > .content > #rh-unified > .rh-active-pane {
    display: block !important; flex: none !important;
    height: auto !important; min-height: 0 !important; max-height: none !important;
    overflow: visible !important; overscroll-behavior: auto !important;
  }
  html:root body:has(#rh-unified) #app > .layout > .content > #rh-unified > .rh-active-pane > .rh-viewport {
    flex: none !important; height: auto !important; min-height: 0 !important; max-height: none !important;
    max-width: 100%; overflow-x: auto !important; overflow-y: hidden !important;
    overscroll-behavior-y: auto !important; touch-action: pan-x pan-y !important;
  }
  /* Horizontal lists must not capture vertical gestures. */
  #rh-unified .rh-f-details > div, #rh-unified .rh-space-scroll {
    max-width: 100%; overscroll-behavior-y: auto; touch-action: pan-x pan-y;
  }
  /* Preserve intentional locks while a drawer/modal is open. */
  html:root:has(#app > .layout):has(body.mobile-menu-open, body[style*="overflow: hidden"], body[style*="overflow:hidden"], dialog[open], #rh-modal-backdrop),
  html:root body:has(#app > .layout):is(.mobile-menu-open,[style*="overflow: hidden"],[style*="overflow:hidden"],:has(dialog[open],#rh-modal-backdrop)) {
    overflow: hidden !important;
  }
}
@media (max-width: 900px) {
  html:root body:has(#app > .layout) #app > .layout { display: block !important; }
  html:root body:has(#app > .layout) #app > .layout > aside { display: none !important; }
}
@media (min-width: 901px) and (max-width: 1366px) and (any-pointer: coarse) {
  html:root body:has(#app > .layout) #app > .layout { display: grid !important; }
  html:root body:has(#app > .layout) #app > .layout > aside {
    position: sticky; top: 0; align-self: start; height: 100dvh !important;
    max-height: 100dvh !important; overflow-y: auto !important;
  }
}
