/* JMD Staff Portal - responsive layer (phones / tablets). Loaded after app.css.
   Desktop (> 1100px) is unchanged. Breakpoints:
     <= 1100px  narrower sidebar, multi-column grids stack (as before)
     <=  900px  sidebar becomes an off-canvas drawer (hamburger), header wraps, wide tables scroll
     <=  600px  phone: compact header, single-column forms, full-width buttons, touch sizes
   CSP: same-origin stylesheet, no inline styles added. */

/* elements that only exist for small screens */
.nav-toggle,.nav-close,.nav-backdrop{display:none}

/* ---------- 901px - 1100px: keep the sidebar as a column (was: stacked above the page) ---------- */
@media (min-width:901px) and (max-width:1100px){
  .shell{grid-template-columns:220px 1fr}
  nav.side{position:sticky;top:58px;height:calc(100vh - 58px)}
  nav.side a{padding-left:20px}
  nav.side a.active{padding-left:17px}
  .top .search{max-width:none;min-width:120px}
  .user-chip>div:last-child{display:none}
  .user-chip{padding:3px}
  .login-wrap{grid-template-columns:1fr 1fr}
}
@media (max-width:1100px){
  /* inline two-column page layouts (dashboard, bank confirmations) stack like .g2 */
  .grid[style*="grid-template-columns"]{grid-template-columns:1fr!important}
  .eng-head{grid-template-columns:1fr 1fr}
  .eng-head>:first-child{grid-column:1/-1}
}

/* ---------- <= 900px: tablet & phone ---------- */
@media (max-width:900px){
  html,body{overflow-x:hidden}
  /* header: [menu] [brand] ............ [lang] [bell] [avatar] [logout]
             [search ...........................................] */
  .top{height:auto;min-height:56px;flex-wrap:wrap;padding:8px 12px;gap:8px 10px;row-gap:8px}
  .nav-toggle{display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;padding:0;font-size:20px;line-height:1;
    background:#163a5c;border:1px solid #1f4a73;color:#fff;border-radius:8px;flex:none}
  .nav-toggle:hover:not(:disabled){background:#1f4a73}
  .top .brand{flex:1 1 0;min-width:0}
  .top .brand>div:last-child{min-width:0}
  .top .brand .logo-mark{flex:none}
  .top .brand small{display:none}
  .top .brand .pname{font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .top .right{flex:none;gap:8px}
  .top .search{order:10;flex:1 1 100%;max-width:none}
  .top .search input{padding-top:9px;padding-bottom:9px}
  .top .search .results{max-height:60vh}
  .user-chip>div:last-child{display:none}
  .user-chip{padding:3px}
  .bell{padding:6px 10px!important}

  /* off-canvas drawer */
  .shell{grid-template-columns:1fr;min-height:0}
  nav.side{position:fixed;top:0;left:0;bottom:0;z-index:45;width:min(86vw,320px);height:100%;max-height:none;
    transform:translateX(-105%);visibility:hidden;transition:transform .22s ease,visibility 0s linear .22s;
    box-shadow:6px 0 24px rgba(0,0,0,.28);overscroll-behavior:contain;padding-top:6px}
  body.nav-open nav.side{transform:none;visibility:visible;transition:transform .22s ease,visibility 0s}
  body.nav-open{overflow:hidden}
  .nav-close{display:block;align-self:flex-end;margin:2px 10px 0 0;width:40px;height:40px;padding:0;font-size:18px;
    background:transparent;border:1px solid #2b5680;color:#cfe0f0;border-radius:8px;flex:none}
  .nav-close:hover:not(:disabled){background:#1a3d60}
  nav.side a{padding-top:10px;padding-bottom:10px}
  .subnav{padding-top:8px!important;padding-bottom:8px!important}
  .nav-backdrop{position:fixed;inset:0;background:rgba(15,23,38,.5);z-index:44}
  body.nav-open .nav-backdrop{display:block}

  /* content */
  main{padding:14px 14px 40px}
  .page-h{flex-wrap:wrap}
  .page-h>div:first-child{flex:1 1 260px;min-width:0}
  .page-h input[style*="width"],.page-h select[style*="width"]{width:100%!important;flex:1 1 100%}
  .card{padding:12px}
  .card>h3{flex-wrap:wrap}
  .flex>*{min-width:0}
  .arch{grid-template-columns:1fr}
  .formgrid{grid-template-columns:1fr 1fr}
  .formgrid>[style*="grid-column"]{grid-column:1/-1!important}
  .eng-head{grid-template-columns:1fr}
  .gatebox{flex-wrap:wrap}
  .task{flex-wrap:wrap}
  .modal{width:96%;max-height:92vh}
  .modal .mf{flex-wrap:wrap}
  /* wide tables: keep readable column widths and scroll inside the card instead of crushing */
  .card table:has(tr>:nth-child(5)){min-width:640px}
  .card table:has(tr>:nth-child(7)){min-width:820px}
  .card table.k21{min-width:520px}
  .cal{min-width:620px}
  .tabs{-webkit-overflow-scrolling:touch}
  .console{height:200px}

  /* login: two panels stack, sign-in card first */
  .login-wrap{grid-template-columns:1fr;min-height:100vh;min-height:100dvh}
  .login-panel{order:-1;padding:24px 16px 20px}
  .login-brand{padding:24px 22px}
  .login-brand h1{font-size:22px;margin-top:16px}
}

/* ---------- <= 600px: phone ---------- */
@media (max-width:600px){
  html,body{font-size:14px}
  /* header items become one flex row (display:contents) so the demo pill can sit beside the search */
  .top{padding:8px 10px;gap:8px}
  .top .right{display:contents}
  .top .brand{order:1}
  .nav-toggle{order:0}
  .top .lang{order:3;margin-left:auto}
  .top .bell{order:4}
  .top .user-chip{order:5}
  .top #btn-logout{order:6}
  .top .search{order:10;flex:1 1 200px}
  .top .pill.ex{order:11;align-self:center}
  .top .brand .logo-mark{width:30px;height:30px}
  .lang button{padding:6px 9px}
  .bell .bell-lbl{display:none}
  .bell .cnt{margin-left:2px}
  .top button.ghost.sm{padding:7px 9px}

  main{padding:12px 10px 36px}
  .page-h h1{font-size:18px}
  .crumb{overflow-wrap:anywhere}
  .card{padding:12px 10px;border-radius:8px}
  .g6{grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}
  .launch{grid-template-columns:1fr 1fr;gap:8px}
  .tile{min-height:64px;padding:10px}
  .formgrid{grid-template-columns:1fr}
  .sigs{flex-direction:column}
  .gatebox>*{flex:1 1 100%}
  .gatebox button{width:100%}
  .stat .n{font-size:21px}
  .eng-head h1{font-size:17px}
  .steps{max-width:none}

  /* touch-friendly controls; 16px inputs stop iOS from zooming on focus */
  input,select,textarea{font-size:16px}
  select.sm{font-size:14px}
  button,.btn{min-height:38px}
  button.sm{min-height:32px;padding:5px 9px}
  button.link{min-height:0}
  .chk{width:20px;height:20px}
  .page-h>button,.page-h>.flex,.page-h>.btn{flex:1 1 100%}
  .modal-bg{align-items:flex-end}
  .modal{width:100%;max-height:94vh;border-radius:12px 12px 0 0}
  .modal .mf button{flex:1 1 auto}
  .toast{left:10px;right:10px;bottom:10px;max-width:none;text-align:center}
  .docview{padding:12px}

  /* login */
  .login-panel{padding:16px 12px 14px}
  .login-card{padding:20px 16px;border-radius:10px}
  .login-card input{min-height:44px}
  .login-card .row{flex-wrap:wrap}
  .login-card .row button.pri{flex:1 1 140px;min-height:44px}
  .login-card .row button:not(.pri){min-height:44px}
  .otp{font-size:22px;letter-spacing:6px}
  .demo-grid{grid-template-columns:1fr}
  .login-brand{padding:20px 18px}
  .login-brand h1{font-size:19px;margin:14px 0 6px}
  .login-brand ul{margin:8px 0}
  .qr{width:180px;height:180px}
}
@media (max-width:480px){
  .top .brand .pname{display:none}
  .top .brand .logo-mark{width:34px;height:34px;font-size:11px}
}
@media (max-width:360px){
  .launch{grid-template-columns:1fr}
  .lang button{padding:6px 7px}
}
/* coarse pointers (touch tablets) get slightly larger hit areas without changing desktop */
@media (pointer:coarse) and (min-width:601px){
  button,.btn{min-height:36px}
  button.sm{min-height:30px}
}
