.portal-mobile-sort { display:none; }
@media (max-width:700px) {
  .flexigrid { width:100%!important; max-width:100%; min-width:0; }
  .flexigrid .hDiv, .flexigrid .cDrag, .flexigrid .vGrip, .flexigrid .nBtn { display:none!important; }
  .flexigrid .portal-mobile-sort { display:flex; align-items:center; gap:8px; padding:8px 12px; background:#f7fafb; }
  .portal-mobile-sort select { flex:1; min-width:0; height:40px; border:1px solid #dce5eb; border-radius:8px; background:white; color:#365f64; font:inherit; }
  .portal-mobile-sort button { min-width:44px; min-height:40px; border:1px solid #dce5eb; border-radius:8px; background:white; color:#146b70; font-size:20px; }
  .flexigrid div.bDiv { overflow-x:hidden; background:#f3f7f9; }
  .flexigrid div.bDiv > table { display:block; width:100%!important; margin:0!important; table-layout:auto!important; }
  .flexigrid div.bDiv > table > tbody { display:block; padding:10px; }
  .flexigrid div.bDiv > table > tbody > tr { display:block; margin:0 0 12px; padding:6px 10px; border:1px solid #dbe5eb; border-radius:12px; background:#fff; box-shadow:0 2px 6px #172c4308; }
  .flexigrid div.bDiv > table > tbody > tr.trSelected { border-color:#b77912; background:#ffe3a3; }
  .flexigrid div.bDiv > table > tbody > tr > td { display:grid; grid-template-columns:minmax(90px,35%) minmax(0,1fr); gap:10px; width:auto!important; padding:7px 0!important; border:0!important; border-bottom:1px solid #edf1f4!important; background:transparent!important; box-shadow:none!important; text-align:start; align-items:start; }
  .flexigrid div.bDiv > table > tbody > tr > td:last-child { border-bottom:0!important; }
  .flexigrid div.bDiv > table > tbody > tr > td::before { content:attr(data-label); color:#758593; font-size:12px; line-height:1.8; overflow-wrap:anywhere; }
  .flexigrid div.bDiv > table > tbody > tr > td[data-label=""] { grid-template-columns:minmax(0,1fr); }
  .flexigrid div.bDiv > table > tbody > tr > td[data-label=""]::before { display:none; }
  .flexigrid div.bDiv > table > tbody > tr > td > div { width:auto!important; min-width:0; max-width:100%; height:auto!important; padding:0!important; white-space:normal!important; overflow-wrap:anywhere; text-align:start!important; line-height:1.8; }
  .flexigrid div.sDiv { white-space:normal; padding:8px; }
  .flexigrid div.sDiv input:not([type=button]), .flexigrid div.sDiv select { max-width:100%; min-height:40px; }
  .flexigrid div.pDiv .pDiv2 { justify-content:center; }
  .flexigrid div.pDiv .pPageStat { width:100%; text-align:center; }
}

/* Mobile pages scroll as a document: navigation must not squeeze rows to zero. */
@media (max-width:700px) {
  html:has(.ContentMain .portal-grid-shell),
  body:has(.ContentMain .portal-grid-shell) { height:auto; overflow:auto; }
  .Whole:has(.ContentMain .portal-grid-shell) { position:relative; inset:auto; display:block; height:auto; min-height:100dvh; overflow:visible; box-sizing:border-box; padding-bottom:calc(48px + env(safe-area-inset-bottom, 0px)); }
  .Whole:has(.portal-grid-shell) > .TopMenu { position:relative; padding:6px 10px; }
  #TopMenuContent { gap:4px 8px; }
  #TopMenuItem { flex:0 0 100%; flex-wrap:nowrap; justify-content:flex-start; overflow-x:auto; padding-top:4px; scrollbar-width:thin; }
  #TopMenuItem > div { flex:0 0 auto; }
  #TopMenuItem a { min-height:36px; padding:6px 9px; }
  .portal-section-tabs { flex-wrap:nowrap; overflow-x:auto; gap:0 6px; scrollbar-width:thin; }
  .portal-section-tabs .portal-section-tab { min-height:40px; padding:7px 8px; }
  .Whole:has(.portal-grid-shell) > .ContentMainContainer,
  .ContentMainContainer:has(.portal-grid-shell) > center,
  .ContentMain:has(.portal-grid-shell),
  .ContentMain .portal-grid-shell,
  .ContentMain .portal-grid-shell #Grid,
  .ContentMain .portal-grid-shell #Grid > div:has(>.flexigrid),
  .ContentMain .portal-grid-shell #ListContainer,
  .ContentMain .portal-grid-shell .flexigrid { display:block; flex:none; height:auto!important; min-height:0; }
  .ContentMain .portal-grid-shell .flexigrid div.bDiv { height:auto!important; max-height:none!important; min-height:0; overflow:visible; }
  .ContentMain .portal-grid-shell .flexigrid div.tDiv { max-height:120px; padding:6px; }
  /* Keep the footer visible while cards scroll, including the iPhone safe area. */
  .Whole:has(.portal-grid-shell) > .Footer { position:fixed!important; inset:auto 0 0; z-index:100; width:100%; height:calc(48px + env(safe-area-inset-bottom, 0px))!important; margin:0; padding:0 0 env(safe-area-inset-bottom, 0px); }
  .Whole:has(.portal-grid-shell) > .Footer .FooterMenu { height:47px; }
  .Footer .FooterMenu { flex-wrap:nowrap; justify-content:flex-start; overflow-x:auto; gap:14px; padding:6px 10px; }
  .Footer .FooterMenu > div { flex:0 0 auto; white-space:nowrap; }
  #calculator { display:none!important; }
}
