/* REZI.ELITE portal layout hardening: prevent page-level horizontal overflow. */
html,body.portal-body{max-width:100%;overflow-x:hidden}
.portal-shell{width:100%;max-width:100vw;min-width:0}
.portal-main,.portal-content,.portal-content>.container,.container{min-width:0;max-width:100%}
.portal-content{overflow-x:clip}
.dashboard-page{overflow-x:clip}

/* Desktop: the navigation never scrolls with the workspace and has no independent scrollbar. */
@media(min-width:901px){
  .portal-shell{display:block!important;min-height:100vh!important}
  .sidebar{
    position:fixed!important;
    inset:0 auto 0 0!important;
    width:248px!important;
    height:100vh!important;
    height:100dvh!important;
    max-height:none!important;
    overflow:hidden!important;
    z-index:50!important;
  }
  .portal-main{
    margin-left:248px!important;
    width:calc(100% - 248px)!important;
    min-height:100vh!important;
  }
  /* Desktop already has the clickable REZI.ELITE brand in the fixed sidebar. */
  .portal-topbar{display:none!important}
}

/* Short laptop screens: tighten the fixed sidebar instead of introducing sidebar scrolling. */
@media(min-width:901px) and (max-height:760px){
  .sidebar{padding:13px 12px!important}
  .sidebar-brand{padding-bottom:12px!important}
  .sidebar-label{padding:7px 10px 4px!important}
  .sidebar-nav{gap:2px!important}
  .sidebar-nav a{padding:7px 9px!important}
  .sidebar-user{padding:9px 7px 6px!important;margin-top:6px!important}
  .sidebar-logout{padding:0 7px!important}
  .ghost-button{padding:7px!important}
}

/* Every grid/flex child must be allowed to shrink inside the portal content column. */
.dashboard-page *,
.page-head>*,.section-head>*,.split>*,
.grid>*,.grid-2>*,.finance-grid>*,.business-strip>*,
.candidate-row>*,.candidate-mini-grid>*,.access-layout>*{min-width:0}

/* Keep tables responsible for their own overflow, never the entire page. */
.table-wrap,.application-table-wrap,.finance-table-wrap{max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}

/* Candidate workload row: four columns only when there is genuinely enough room. */
.candidate-row{width:100%;max-width:100%;box-sizing:border-box}
.candidate-actions{min-width:0!important;max-width:100%;flex-wrap:wrap}
.candidate-actions .btn{min-width:0;white-space:nowrap}

/* The fixed sidebar reduces usable workspace width, so reflow earlier. */
@media(max-width:1580px){
  .candidate-row{grid-template-columns:minmax(0,1fr) minmax(0,1fr)!important;gap:18px 24px!important}
  .candidate-actions{justify-content:flex-start!important;align-self:end}
  .candidate-latest{grid-column:1/-1!important;margin-top:0!important}
  .candidate-mini-grid{width:100%}
}

@media(max-width:1180px){
  .container{padding-left:24px!important;padding-right:24px!important}
  .finance-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  .ops-board{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}

@media(max-width:900px){
  .portal-shell{display:block!important;max-width:100%!important}
  .sidebar{position:static!important;width:auto!important;height:auto!important;max-height:none!important;overflow:visible!important}
  .portal-main{margin-left:0!important;width:100%!important}
  .portal-topbar{
    display:flex!important;
    height:58px!important;
    padding:0 18px!important;
    background:rgba(243,242,239,.94)!important;
    border-bottom:1px solid #deddd8!important;
    position:sticky!important;
    top:0!important;
    z-index:40!important;
  }
  .container{padding-left:20px!important;padding-right:20px!important}
  .candidate-row{grid-template-columns:1fr!important}
  .candidate-actions{width:100%}
  .candidate-actions .btn{flex:1 1 auto}
  .candidate-latest{grid-column:1!important}
}

@media(max-width:640px){
  .finance-grid,.grid-2,.profile-grid,.subscription-grid{grid-template-columns:1fr!important}
  .candidate-mini-grid{grid-template-columns:repeat(2,minmax(0,1fr))!important}
}
