/* ========================================================================
   GaliVue V5.1.125 — FINAL COMPACT WORKSPACE GEOMETRY

   Scope: compact authenticated workspace presentation only.

   Root causes closed here:
   1) mobile-shell-fix-v5181.css carried a high-specificity authenticated-public
      entry rule that forced .gv39-dashboard-main padding-top to 0. Once the
      shared header was relocated to the non-scrolling top rail, that legacy
      rule made the first Dashboard content render underneath the rail even at
      scrollTop=0.
   2) historical title-only optical offsets (including the Dashboard baseline
      transform) made the four visible header regions use different vertical
      centres.

   Final phone contract:
     GaliVue | page title | EN | profile
   - one 62px top rail (plus safe-area inset)
   - one shared vertical centre for all four visible regions
   - middle scroller reserves the full rail before its first content
   - no route/auth/workflow/backend behaviour changes
   ======================================================================== */

@media (max-width:767px) {
  /* Authoritative rail height. Keep this synchronized with V5.1.112, but give
     the last presentation layer its own variable so legacy rules cannot erase
     the content reserve on the public -> authenticated entry path. */
  html body #dashboardDialog #dashboardPanel {
    --gv51125-head-h:calc(62px + env(safe-area-inset-top));
  }

  /* FINAL SCROLL RESERVE.
     This intentionally outranks the V5.1.108 public-entry rule:
       html[data-galivue-auth-state="authenticated"] body.gvf-homepage-v5171
       #dashboardDialog:not(.hidden) #dashboardPanel .gv39-dashboard-main
       { padding-top:0!important; }
     Only top padding is reclaimed; approved side/bottom geometry remains owned
     by the existing mobile/tablet shell. */
  html[data-galivue-auth-state="authenticated"] body.gvf-homepage-v5171
    #dashboardDialog:not(.hidden) #dashboardPanel .gv39-dashboard-main,
  html body #dashboardDialog #dashboardPanel.gv51112-rails-ready .gv39-dashboard-main {
    padding-top:calc(var(--gv51125-head-h) + 8px)!important;
    scroll-padding-top:calc(var(--gv51125-head-h) + 8px)!important;
  }

  /* One physical row and one vertical centre. */
  html body #dashboardDialog #dashboardPanel .workspace-head,
  html body #dashboardDialog #dashboardPanel.gv51112-rails-ready > .workspace-head,
  html body #dashboardDialog #dashboardPanel .workspace-head.gv5158-has-app-slot,
  html body #dashboardDialog #dashboardPanel.gv51112-rails-ready > .workspace-head.gv5158-has-app-slot {
    height:var(--gv51125-head-h)!important;
    min-height:var(--gv51125-head-h)!important;
    padding:max(0px,env(safe-area-inset-top)) 14px 0!important;
    box-sizing:border-box!important;
    display:grid!important;
    grid-template-columns:auto minmax(0,1fr) auto!important;
    grid-template-rows:1fr!important;
    align-items:center!important;
    column-gap:8px!important;
    row-gap:0!important;
  }

  html body #dashboardDialog #dashboardPanel .workspace-head > .workspace-brand,
  html body #dashboardDialog #dashboardPanel .workspace-head.gv5158-has-app-slot > .workspace-brand {
    display:contents!important;
  }

  /* Left / centre / right tracks all use the same 40px alignment box. */
  html body #dashboardDialog #dashboardPanel .workspace-head .workspace-brand-mark {
    grid-column:1!important;
    grid-row:1!important;
    align-self:center!important;
    justify-self:start!important;
    display:flex!important;
    align-items:center!important;
    justify-content:flex-start!important;
    height:40px!important;
    min-height:40px!important;
    margin:0!important;
    padding:0!important;
    position:static!important;
    top:auto!important;
    transform:none!important;
  }
  html body #dashboardDialog #dashboardPanel .workspace-head .workspace-brand-mark img {
    display:block!important;
    width:auto!important;
    height:25px!important;
    max-width:82px!important;
    margin:0!important;
    transform:none!important;
  }

  html body #dashboardDialog #dashboardPanel .workspace-head .workspace-brand-copy {
    grid-column:2!important;
    grid-row:1!important;
    align-self:center!important;
    justify-self:stretch!important;
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    height:40px!important;
    min-height:40px!important;
    width:100%!important;
    min-width:0!important;
    max-width:100%!important;
    margin:0!important;
    padding:0!important;
    position:static!important;
    inset:auto!important;
    top:auto!important;
    transform:none!important;
    text-align:center!important;
    overflow:hidden!important;
  }
  html body #dashboardDialog #dashboardPanel .workspace-head .workspace-title-nav {
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    width:100%!important;
    height:40px!important;
    min-height:40px!important;
    min-width:0!important;
    max-width:100%!important;
    margin:0!important;
    padding:0!important;
    position:static!important;
    top:auto!important;
    transform:none!important;
    overflow:hidden!important;
  }
  html body #dashboardDialog #dashboardPanel .workspace-head .workspace-brand h2,
  html body #dashboardDialog #dashboardPanel .workspace-head #dashboardTitle,
  html body #dashboardDialog #dashboardPanel .workspace-head #dashboardTitle.dashboard-title-refreshable,
  html body #dashboardDialog #dashboardPanel.gv3936-account-shell .workspace-head #dashboardTitle {
    display:flex!important;
    align-items:center!important;
    justify-content:center!important;
    width:100%!important;
    height:40px!important;
    min-height:40px!important;
    min-width:0!important;
    max-width:100%!important;
    margin:0!important;
    padding:0!important;
    position:static!important;
    inset:auto!important;
    top:auto!important;
    left:auto!important;
    right:auto!important;
    transform:none!important;
    font-size:1rem!important;
    line-height:1!important;
    text-align:center!important;
    overflow:hidden!important;
    text-overflow:ellipsis!important;
    white-space:nowrap!important;
  }

  html body #dashboardDialog #dashboardPanel .workspace-head > .workspace-head-actions,
  html body #dashboardDialog #dashboardPanel .workspace-head.gv5158-has-app-slot > .workspace-head-actions {
    grid-column:3!important;
    grid-row:1!important;
    align-self:center!important;
    justify-self:end!important;
    display:flex!important;
    align-items:center!important;
    justify-content:flex-end!important;
    height:40px!important;
    min-height:40px!important;
    gap:6px!important;
    width:auto!important;
    min-width:0!important;
    margin:0!important;
    padding:0!important;
    position:static!important;
    top:auto!important;
    transform:none!important;
  }
  html body #dashboardDialog #dashboardPanel .workspace-head .workspace-language-switcher,
  html body #dashboardDialog #dashboardPanel .workspace-head .profile-menu-wrap,
  html body #dashboardDialog #dashboardPanel .workspace-head .profile-avatar-button {
    align-self:center!important;
    margin-top:0!important;
    margin-bottom:0!important;
    top:auto!important;
    transform:none!important;
  }
  html body #dashboardDialog #dashboardPanel .workspace-head .workspace-language-switcher,
  html body #dashboardDialog #dashboardPanel .workspace-head .profile-avatar-button {
    height:40px!important;
    min-height:40px!important;
  }
}

@media (max-width:360px) {
  html body #dashboardDialog #dashboardPanel .workspace-head,
  html body #dashboardDialog #dashboardPanel.gv51112-rails-ready > .workspace-head {
    column-gap:6px!important;
  }
  html body #dashboardDialog #dashboardPanel .workspace-head > .workspace-head-actions,
  html body #dashboardDialog #dashboardPanel .workspace-head.gv5158-has-app-slot > .workspace-head-actions {
    gap:4px!important;
  }
}
