/* GCNM v13.8 — mobile scroll recovery, operations admin surfaces and resilient dashboard flow */
:root{--g138-safe-bottom:calc(24px + env(safe-area-inset-bottom,0px));--g138-card:#fff;--g138-line:#dbe6e0;--g138-forest:#0f4537;--g138-muted:#65776e}
html{height:auto!important;min-height:100%!important;overflow-x:hidden!important;overflow-y:auto!important;scroll-behavior:smooth}
body.v2-shell{height:auto!important;min-height:100dvh!important;max-height:none!important;overflow-x:hidden!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch;overscroll-behavior-y:auto;background:#f4f7f5!important}
body.v2-shell .layout-wrapper,body.v2-shell .layout-container,body.v2-shell .layout-page,body.v2-shell .content-wrapper{height:auto!important;min-height:100dvh!important;max-height:none!important;overflow-y:visible!important}
body.v2-shell .layout-page{align-self:stretch!important;display:flex!important;flex-direction:column!important}
body.v2-shell .content-wrapper{flex:1 0 auto!important;padding-bottom:var(--g138-safe-bottom)!important}
body.v2-shell footer,body.v2-shell .content-footer{flex:0 0 auto!important}

/* Never allow stale UI masks to sit over the working surface after a drawer closes. */
body.v2-shell:not(.modal-open):not(.offcanvas-open) .layout-overlay:not(.layout-menu-toggle-active){pointer-events:none}
body.v2-shell .content-wrapper{isolation:isolate}

/* Full-width operational records with readable controls and touch targets. */
.gcnm-v138-admin-page{padding-bottom:var(--g138-safe-bottom)!important}
.gcnm-v138-admin-page .gcnm-card{border:1px solid var(--g138-line);border-radius:18px;background:var(--g138-card);box-shadow:0 8px 34px rgba(14,63,49,.045)}
.gcnm-v138-admin-page .gcnm-card-head{gap:12px;flex-wrap:wrap}
.gcnm-v138-admin-page .form-control,.gcnm-v138-admin-page .form-select{min-height:44px;line-height:1.3}
.gcnm-v138-admin-page textarea.form-control{min-height:92px}
.gcnm-v138-admin-page .btn{min-height:40px}
.gcnm-v138-admin-page .table-responsive{overscroll-behavior-x:contain;scrollbar-gutter:stable both-edges}
.gcnm-v138-admin-page .table{min-width:760px}
.gcnm-v138-admin-page .modal-body{padding-bottom:max(1.25rem,env(safe-area-inset-bottom))}

/* Registry and list pages should not force the whole dashboard wider than the viewport. */
body.v2-shell .gcnm-page,body.v2-shell .gcnm-card,body.v2-shell .gcnm-card-body,body.v2-shell .row,body.v2-shell [class*="col-"]{min-width:0!important}
body.v2-shell img,body.v2-shell svg,body.v2-shell canvas{max-width:100%}
body.v2-shell .dropdown-menu{max-width:min(92vw,420px)}

@media(max-width:991.98px){
  body.v2-shell .layout-container{display:block!important;min-height:100dvh!important}
  body.v2-shell .layout-page{width:100%!important;max-width:100%!important;min-height:100dvh!important;margin:0!important;padding:0!important}
  body.v2-shell #mobileMenu{height:100dvh!important;max-height:100dvh!important;overflow:hidden!important;-webkit-overflow-scrolling:touch}
  body.v2-shell #mobileMenu .tk-panel,body.v2-shell #mobileMenu .tk-rail{height:100dvh!important;max-height:100dvh!important}
  body.v2-shell #mobileMenu .tk-panel-body{height:auto!important;max-height:calc(100dvh - 116px)!important;overflow-y:auto!important;-webkit-overflow-scrolling:touch;overscroll-behavior:contain}
  body.v2-shell .content-wrapper{overflow:visible!important;min-height:calc(100dvh - 64px)!important;padding-bottom:calc(96px + env(safe-area-inset-bottom,0px))!important}
  body.v2-shell .content-wrapper>.container-fluid,body.v2-shell .content-wrapper>.container-xxl,body.v2-shell .content-wrapper>.container-xl,body.v2-shell .gcnm-page{padding-left:12px!important;padding-right:12px!important}
  .gcnm-v138-admin-page .position-sticky{position:static!important;top:auto!important}
  .gcnm-v138-admin-page .gcnm-hero{padding:22px 18px!important;border-radius:16px!important}
  .gcnm-v138-admin-page .gcnm-title{font-size:clamp(1.55rem,7vw,2.1rem)!important;line-height:1.08!important}
  .gcnm-v138-admin-page .table{min-width:690px}
  .gcnm-v138-admin-page .modal-dialog{margin:8px!important;max-width:calc(100vw - 16px)!important}
  .gcnm-v138-admin-page .modal-content{max-height:calc(100dvh - 16px)!important}
  .gcnm-float-action{z-index:1030!important}
}
@media(max-width:575.98px){
  body.v2-shell .navbar-nav-right,body.v2-shell .layout-navbar{min-width:0!important}
  .gcnm-v138-admin-page .gcnm-card-head,.gcnm-v138-admin-page .gcnm-card-body{padding-left:14px!important;padding-right:14px!important}
  .gcnm-v138-admin-page .btn{white-space:normal}
  .gcnm-v138-admin-page .d-flex.text-nowrap{white-space:normal!important;flex-wrap:wrap!important}
  .gcnm-v138-admin-page .table{min-width:640px}
}

/* v13.8.1 mobile/off-canvas guard: keep the page and menu independently scrollable. */
@media(max-width:991.98px){
  html,body.v2-shell{position:relative!important;width:100%!important;max-width:100%!important;touch-action:pan-y pinch-zoom!important}
  body.v2-shell:not(.modal-open){overflow-y:auto!important;height:auto!important;min-height:100dvh!important}
  body.v2-shell #mobileMenu{position:fixed!important;inset:0 auto 0 0!important;width:min(94vw,390px)!important;max-width:94vw!important;overflow:visible!important;overscroll-behavior:contain!important}
  body.v2-shell #mobileMenu .tk-rail{flex:0 0 var(--tk-rail-w,64px)!important;overflow-y:auto!important;overflow-x:hidden!important}
  body.v2-shell #mobileMenu .tk-panel{min-width:0!important;max-width:calc(min(94vw,390px) - var(--tk-rail-w,64px))!important;display:flex!important;flex-direction:column!important;overflow:hidden!important}
  body.v2-shell #mobileMenu .tk-panel-head{flex:0 0 auto!important}
  body.v2-shell #mobileMenu .tk-panel-body{flex:1 1 auto!important;min-height:0!important;max-height:none!important;overflow-y:auto!important;overflow-x:hidden!important;padding-bottom:calc(28px + env(safe-area-inset-bottom,0px))!important;touch-action:pan-y!important}
  body.v2-shell .layout-navbar{position:sticky!important;top:0!important;z-index:1025!important}
  body.v2-shell .content-wrapper,body.v2-shell main,body.v2-shell .container-fluid,body.v2-shell .container-xxl{max-width:100vw!important;overflow-x:hidden!important}
  body.v2-shell .table-responsive{width:100%!important;max-width:100%!important;overflow-x:auto!important;-webkit-overflow-scrolling:touch!important}
}
@media(max-width:575.98px){
  body.v2-shell #mobileMenu{width:96vw!important;max-width:96vw!important}
  body.v2-shell #mobileMenu .tk-panel{max-width:calc(96vw - var(--tk-rail-w,64px))!important}
  .gcnm-v138-admin-page .row>*{width:100%;max-width:100%}
  .gcnm-v138-admin-page .form-control,.gcnm-v138-admin-page .form-select,.gcnm-v138-admin-page .select2-container{width:100%!important;max-width:100%!important}
}
