/* ECG Lab — app shell v5 stabilized.
   Desktop/tablet uses one browser-owned document scrollbar at the far-right edge.
   The navigation rail is fixed to the viewport (not sticky), which prevents it
   from drifting or ending partway down long pages. Mobile keeps natural scrolling. */

@media (min-width:721px){
  html{
    width:100%;
    min-height:100%;
    height:auto!important;
    overflow-x:hidden!important;
    overflow-y:auto!important;
    scrollbar-width:none;
    scrollbar-color:auto;
  }

  body{
    width:100%;
    min-height:100dvh;
    height:auto!important;
    overflow:visible!important;
  }

  html::-webkit-scrollbar{width:0!important;height:0!important;display:none!important}
  html::-webkit-scrollbar-track,
  html::-webkit-scrollbar-thumb,
  html::-webkit-scrollbar-button,
  html::-webkit-scrollbar-corner{display:none!important;width:0!important;height:0!important;background:transparent!important}

  #app{
    width:100%;
    min-height:100dvh;
    height:auto!important;
    overflow:visible!important;
  }

  .shell{
    display:block!important;
    width:100%;
    min-height:100dvh!important;
    height:auto!important;
    overflow:visible!important;
  }

  .sidebar{
    display:flex!important;
    position:fixed!important;
    left:0!important;
    right:auto!important;
    top:0!important;
    bottom:0!important;
    width:250px!important;
    height:100dvh!important;
    min-height:0!important;
    margin:0!important;
    align-self:auto!important;
    overflow:hidden!important;
    z-index:40!important;
  }

  .sidebar .brand{flex:0 0 auto}
  .sidebar .nav{
    flex:1 1 auto;
    min-height:0;
    overflow-y:auto;
    overflow-x:hidden;
    overscroll-behavior:contain;
    scrollbar-width:none;
  }
  .sidebar .nav::-webkit-scrollbar{display:none}
  .sidebar-footer{flex:0 0 auto;width:100%;min-width:0}

  body.ui-foundation-v3 .main,
  .main{
    position:relative;
    box-sizing:border-box!important;
    width:calc(100% - 250px)!important;
    max-width:none!important;
    margin:0 0 0 250px!important;
    height:auto!important;
    min-height:100dvh!important;
    min-width:0!important;
    overflow:visible!important;
  }

  /* Keep page content centered, but let the header span the full usable desktop
     width so PT / Treino rápido / Entrar-Sair can sit at the far-right edge. */
  .main>.topbar{
    box-sizing:border-box;
    width:100%;
    max-width:none!important;
    min-width:0;
    margin-left:0!important;
    margin-right:0!important;
  }

  .main>.topbar>.actions{
    margin-left:auto!important;
    justify-content:flex-end!important;
  }

  .main>.page{
    box-sizing:border-box;
    width:100%;
    max-width:1500px;
    min-width:0;
    margin-left:auto;
    margin-right:auto;
  }

  .page,.page>*{min-width:0}
  .cat-home,.cat-section,.cat-history-list,.cat-history-item,
  .sim-home,.sim-section,.sim-history-list,.sim-history-item,
  .perf-page,.study-detail-grid,.case-layout{max-width:100%;min-width:0}

  .ft2-fab{right:24px!important}

  .sidebar-footer .beta-feedback-launcher{
    position:static!important;
    inset:auto!important;
    z-index:auto!important;
    display:flex;
    align-items:center;
    justify-content:center;
    width:100%;
    max-width:none;
    min-height:34px;
    margin:8px 0 0;
    padding:7px 10px;
    border-color:rgba(145,167,196,.16);
    border-radius:11px;
    background:rgba(255,255,255,.025);
    color:var(--muted,#91a7c4);
    box-shadow:none;
    backdrop-filter:none;
    -webkit-backdrop-filter:none;
    font-size:10.5px;
    font-weight:600;
    letter-spacing:0;
  }

  .sidebar-footer .beta-feedback-launcher:hover{
    transform:none;
    background:rgba(255,255,255,.05);
    border-color:rgba(76,224,179,.22);
    color:#cbeee4;
  }

  .sidebar-footer .beta-version{margin-top:7px;text-align:left}
}

@media (min-width:721px) and (max-width:1100px){
  .sidebar{width:84px!important}
  body.ui-foundation-v3 .main,
  .main{width:calc(100% - 84px)!important;margin-left:84px!important}
  .sidebar-footer{display:flex;flex-direction:column;align-items:center}
  .sidebar-footer .beta-feedback-launcher{
    width:42px;min-width:42px;height:36px;min-height:36px;padding:0;font-size:0!important
  }
  .sidebar-footer .beta-feedback-launcher::before{content:"⚑";font-size:14px;line-height:1}
  .sidebar-footer .beta-version{
    max-width:58px;text-align:center;overflow-wrap:anywhere;font-size:8px;line-height:1.3
  }
}

@media (min-width:1101px) and (max-width:1450px){
  .cat-history-item{grid-template-columns:minmax(0,1fr) auto!important}
  .cat-history-item>.badge{justify-self:start}
  .cat-history-item>.btn{justify-self:end}
  .perf-kpis{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .perf-plan-list{grid-template-columns:1fr!important}
  .perf-two{grid-template-columns:1fr!important}
  .perf-area-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .clinical-cases-grid{grid-template-columns:repeat(3,minmax(0,1fr))!important}
  .study-detail-grid,.case-layout{grid-template-columns:1fr!important}
  .case-question{position:static!important}
}

@media (max-width:720px){
  html,
  body{
    width:100%;
    min-height:100%;
    height:auto;
    overflow-x:hidden!important;
    overflow-y:auto!important;
  }

  #app{height:auto;min-height:100dvh;overflow:visible}
  .shell{display:block!important;height:auto!important;min-height:100dvh!important;overflow:visible!important}
  .sidebar{display:none!important}

  body.ui-foundation-v3 .main,
  .main{
    width:100%!important;
    max-width:none!important;
    margin:0!important;
    height:auto!important;
    min-height:0!important;
    overflow:visible!important;
  }

  /* Force the complete mobile action group to the physical right edge. Using
     absolute positioning avoids older flex rules and injected controls changing
     the horizontal placement. */
  body.ui-foundation-v3 .main>.topbar,
  .main>.topbar{
    position:relative!important;
    display:block!important;
    width:100%!important;
    max-width:none!important;
    min-height:58px!important;
    box-sizing:border-box!important;
    padding:0!important;
    margin-left:0!important;
    margin-right:0!important;
  }

  body.ui-foundation-v3 .main>.topbar>.actions,
  .main>.topbar>.actions{
    position:absolute!important;
    top:0!important;
    right:max(8px,env(safe-area-inset-right))!important;
    left:auto!important;
    display:flex!important;
    flex-wrap:nowrap!important;
    align-items:center!important;
    justify-content:flex-end!important;
    width:max-content!important;
    max-width:calc(100vw - 16px)!important;
    margin:0!important;
    padding:0!important;
    transform:none!important;
  }

  .topbar .beta-feedback-launcher{
    position:static!important;
    inset:auto!important;
    z-index:auto!important;
    width:38px;
    min-width:38px;
    height:38px;
    max-width:none;
    padding:0;
    margin:0;
    border-radius:11px;
    background:rgba(255,255,255,.035);
    border-color:rgba(255,255,255,.08);
    color:var(--muted,#91a7c4);
    box-shadow:none;
    backdrop-filter:none;
    -webkit-backdrop-filter:none;
    font-size:0!important;
  }

  .topbar .beta-feedback-launcher::before{content:"⚑";font-size:14px;line-height:1}
  .topbar .beta-feedback-launcher:hover{
    transform:none;
    background:rgba(255,255,255,.06);
    border-color:rgba(76,224,179,.2);
  }
}

@media (prefers-reduced-motion:reduce){html{scroll-behavior:auto}}
