/* POSH Invoice targeted layout fix — 2026-08-24
   Scope: desktop sidebar/menu width + Invoice/Estimate register height/scroll only. */

/* Wider, more balanced navigation rail on desktop */
@media (min-width: 821px){
  :root{ --posh-shell-sidebar: 216px; }
  .sidebar,.app-shell>.sidebar{
    width:var(--posh-shell-sidebar)!important;
    min-width:var(--posh-shell-sidebar)!important;
  }
  .main,.app-shell>.main,.main-content{
    margin-left:var(--posh-shell-sidebar)!important;
    width:calc(100% - var(--posh-shell-sidebar))!important;
  }
  .sidebar-logo,.brand-block{
    margin-left:12px!important;
    margin-right:12px!important;
  }
  .sidebar-logo::before,.brand-block::before{
    width:172px!important;
    max-width:100%!important;
  }
  .sidebar nav{padding-inline:10px!important}
  .sidebar nav button{
    min-height:38px!important;
    padding:0 12px!important;
    gap:11px!important;
    font-size:11.5px!important;
  }
  .posh-nav-group{
    margin-left:13px!important;
    margin-right:13px!important;
    font-size:7.5px!important;
  }
}

/* Invoice/Estimate register: fixed visual height equal to the Live Preview.
   Only the records area scrolls; filters/header remain visible. */
@media (min-width: 1025px){
  .documents-layout{
    grid-template-columns:minmax(360px, 38%) minmax(0, 1fr)!important;
    align-items:start!important;
  }
  .documents-layout > .panel:first-child{
    min-height:0!important;
    overflow:hidden!important;
    display:flex!important;
    flex-direction:column!important;
  }
  .documents-layout > .panel:first-child > .panel-head{
    flex:0 0 auto!important;
  }
  .documents-layout > .panel:first-child > .panel-body{
    min-height:0!important;
    flex:1 1 auto!important;
    display:flex!important;
    flex-direction:column!important;
    overflow:hidden!important;
  }
  .documents-layout > .panel:first-child .filter-row{
    flex:0 0 auto!important;
  }
  .documents-layout > .panel:first-child .document-list{
    min-height:0!important;
    flex:1 1 auto!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    scrollbar-gutter:stable!important;
    padding-right:4px!important;
    -webkit-overflow-scrolling:touch;
  }
  .documents-layout > .panel:first-child .document-list::-webkit-scrollbar{width:8px}
  .documents-layout > .panel:first-child .document-list::-webkit-scrollbar-thumb{
    background:#c5d5e2;border-radius:999px;border:2px solid transparent;background-clip:padding-box;
  }
  .documents-layout > .panel:first-child .document-list::-webkit-scrollbar-track{background:transparent}
}

/* Keep tablet/mobile behavior adaptive rather than forcing a fixed rail/register. */
@media (max-width: 1024px){
  .documents-layout > .panel:first-child{height:auto!important;max-height:none!important}
  .documents-layout > .panel:first-child .document-list{max-height:none!important;overflow:visible!important}
}


/* V30 document workspace: Builder above Register, Preview on right */
@media (min-width:1025px){
  .documents-layout.documents-layout-builder-first{
    grid-template-columns:minmax(420px,44%) minmax(0,1fr)!important;
    gap:14px!important;
    align-items:start!important;
  }
  .documents-layout-builder-first>.documents-left-stack{
    min-width:0!important;
    display:flex!important;
    flex-direction:column!important;
    gap:12px!important;
    min-height:0!important;
    overflow:hidden!important;
  }
  .documents-layout-builder-first>.documents-preview-column{min-width:0!important}
  .documents-layout-builder-first>.documents-preview-column>.preview-panel{margin:0!important}

  /* Builder is compact and independently scrollable; register remains visible below it. */
  .documents-left-stack>.panel:first-child{
    flex:0 0 auto!important;
    min-height:280px!important;
    overflow:hidden!important;
    display:flex!important;
    flex-direction:column!important;
  }
  .documents-left-stack>.panel:first-child>.panel-head{flex:0 0 auto!important}
  .documents-left-stack>.panel:first-child>.panel-body{
    min-height:0!important;
    flex:1 1 auto!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    padding:12px!important;
    scrollbar-gutter:stable!important;
  }
  .documents-left-stack>.panel:last-child{
    flex:1 1 0!important;
    min-height:190px!important;
    overflow:hidden!important;
    display:flex!important;
    flex-direction:column!important;
  }
  .documents-left-stack>.panel:last-child>.panel-head{flex:0 0 auto!important}
  .documents-left-stack>.panel:last-child>.panel-body{
    min-height:0!important;
    flex:1 1 auto!important;
    display:flex!important;
    flex-direction:column!important;
    overflow:hidden!important;
  }
  .documents-left-stack>.panel:last-child .filter-row{flex:0 0 auto!important}
  .documents-left-stack>.panel:last-child .document-list{
    min-height:0!important;
    flex:1 1 auto!important;
    overflow-y:auto!important;
    overflow-x:hidden!important;
    overscroll-behavior:contain!important;
    scrollbar-gutter:stable!important;
  }
  .documents-left-stack>.panel:first-child .form-grid{
    grid-template-columns:repeat(2,minmax(0,1fr))!important;
    gap:9px 10px!important;
  }
  .documents-left-stack>.panel:first-child .field label,
  .documents-left-stack>.panel:first-child .field>span{font-size:10px!important}
  .documents-left-stack>.panel:first-child input,
  .documents-left-stack>.panel:first-child select,
  .documents-left-stack>.panel:first-child textarea{min-height:34px!important}
  .documents-left-stack>.panel:first-child textarea{min-height:64px!important}
  .documents-left-stack>.panel:first-child .document-steps{margin-bottom:9px!important}
  .documents-left-stack>.panel:first-child .builder-section{margin-top:8px!important}
  .documents-left-stack>.panel:first-child .line-toolbar{margin-block:8px!important}
}

@media (max-width:1024px){
  .documents-layout.documents-layout-builder-first{display:block!important}
  .documents-left-stack{height:auto!important;max-height:none!important;overflow:visible!important}
  .documents-left-stack>.panel:first-child,
  .documents-left-stack>.panel:last-child{height:auto!important;max-height:none!important}
  .documents-left-stack>.panel:first-child>.panel-body,
  .documents-left-stack>.panel:last-child>.panel-body{overflow:visible!important}
  .documents-left-stack>.panel:last-child .document-list{max-height:360px!important;overflow-y:auto!important}
  .documents-preview-column{margin-top:12px!important}
}
