/* Phase 4: Shell / Layout */
/* App shell (Sidebar + Content) */
.shell{
  display:flex;
  align-items: flex-start;
  flex: 1 1 auto;
  gap: 20px;
  max-width: calc(var(--max) + 260px);
  margin: 0 auto;
  width: 100%;
}
.shell__main{ flex: 1 1 auto; min-width: 0; min-height: 0; }

.sidebar{
  width: 240px;
  padding: 8px 0 16px;
  position: sticky;
  top: 74px;
  max-height: calc(100vh - 92px);
  overflow: auto;
  overscroll-behavior: contain;
  align-self: flex-start;
}
.sidebar__inner{
  padding: 0 12px;
  display:flex;
  flex-direction: column;
  gap: 14px;
}
.sidebar__section{
  background: rgba(255,255,255,.70);
  backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 12px;
  box-shadow: var(--shadow2);
}
.sidebar__label{
  font-size: 12px;
  color: var(--muted);
  padding: 6px 8px 10px;
  font-weight: 700;
  letter-spacing: .2px;
}
.sidebar__footer{ padding: 0 10px; }

.snav{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  border: 1px solid transparent;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
}
.snav svg{ opacity: .86; }
.snav:hover{ background: rgba(11,91,211,.08); text-decoration:none; }
.snav.active{
  background: rgba(11,91,211,.12);
  border-color: rgba(11,91,211,.25);
  color: var(--blue2);
}

/* Mobile: hide sidebar */
@media (max-width: 900px), (hover: none) and (pointer: coarse){
  .shell{ display:block; }
  .sidebar{ display:none; }
}

.topbar{
  position: sticky;
  top:0;
  z-index:60;
  display:flex;
  align-items:center;
  justify-content: space-between;
  min-height: 66px;
  padding: 12px 16px;
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbarActions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 12px;
}
.pagetitle{
  font-weight: 850;
  letter-spacing: .2px;
  padding: 0 8px;
  max-width: 40vw;
  white-space: nowrap;
  overflow:hidden;
  text-overflow: ellipsis;
}
.topbar__menuBtn{ display:none; }

@media (max-width: 900px), (hover: none) and (pointer: coarse){
  .pagetitle{ display:none; }
  .topbar__menuBtn{ display:inline-flex; }
}

.userbtn{
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(10px);
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 6px 10px 6px 6px;
}
.userbtn:active{ transform: scale(.99); }
.userbtn__avatar{
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 900;
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(11,91,211,.22);
}
.userbtn__name{ font-weight: 750; max-width: 180px; white-space: nowrap; overflow:hidden; text-overflow: ellipsis; }

@media (max-width: 767px){
  .userbtn{
    padding: 6px;
  }
  .userbtn__name{
    display:none;
  }
}

.usermenu{
  position: fixed;
  top: 66px;
  right: 16px;
  width: min(86vw, 360px);
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 60px rgba(0,0,0,.18);
  z-index: 60;
}
.usermenu.hidden{ display:none; }
.usermenu__hdr{ display:flex; align-items:flex-start; justify-content:space-between; gap: 10px; }
.usermenu__title{ font-weight: 900; letter-spacing:.2px; padding: 4px 6px 2px; }
.usermenu__link{
  display:block;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  color: var(--text);
  text-decoration:none;
  margin-top: 10px;
}
.usermenu__link:hover{ background: rgba(11,91,211,.08); text-decoration:none; }
/* Mobile Burger Menu */
.topnav--mobile{ display:none; }
.iconbtn{
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(10px);
  display:inline-flex; align-items:center; justify-content:center;
}
.iconbtn:active{ transform: scale(.98); }
.iconbtn__lines{
  width: 18px; height: 12px; position: relative; display:block;
}
.iconbtn__lines::before,
.iconbtn__lines::after,
.iconbtn__lines{
  background: transparent;
}
.iconbtn__lines::before,
.iconbtn__lines::after{
  content:"";
  position:absolute; left:0; right:0;
  height:2px; border-radius:2px;
  background: var(--text);
}
.iconbtn__lines::before{ top:1px; }
.iconbtn__lines::after{ bottom:1px; }
.iconbtn__lines{
  border-top: 2px solid var(--text);
  border-radius: 2px;
}

.topmenu{
  position: fixed;
  inset: 0;
  z-index: 50;
}
.topmenu.hidden{ display:none; }
.topmenu__backdrop{
  position:absolute; inset:0;
  background: rgba(0,0,0,.25);
}
.topmenu__panel{
  position:absolute;
  top: 12px; right: 12px;
  width: min(86vw, 360px);
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 60px rgba(0,0,0,.18);
  display:flex;
  flex-direction: column;
  gap: 10px;
}
.topmenu__hdr{ display:flex; align-items:flex-start; justify-content:space-between; gap: 10px; }
.topmenu__sub{ font-size: 12px; padding-left: 6px; margin-top: 2px; }
.topmenu__title{ font-weight: 800; letter-spacing:.2px; padding: 4px 6px 6px; }

/* Close icon for mobile menu */
.iconbtn__x{
  width: 18px; height: 18px; position: relative; display:block;
}
.iconbtn__x::before,
.iconbtn__x::after{
  content:"";
  position:absolute;
  left: 2px; right: 2px; top: 8px;
  height:2px; border-radius:2px;
  background: var(--text);
}
.iconbtn__x::before{ transform: rotate(45deg); }
.iconbtn__x::after{ transform: rotate(-45deg); }
.topmenu__link{
  display:block;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.7);
  color: var(--text);
  text-decoration:none;
}
.topmenu__link:active{ transform: scale(.99); }
.topmenu__link.active{
  background: rgba(11,91,211,.12);
  border-color: rgba(11,91,211,.25);
  color: var(--blue2);
  font-weight: 800;
}
.topmenu__sep{ height:1px; background: var(--line); margin: 4px 0; }

/*
  Navigation behavior
  - Desktop: always show full nav (even if the window is narrow)
  - Mobile / touch devices: show burger menu and hide the full nav

  We use an OR-combination:
  - Small viewports (classic responsive)
  - Coarse pointer / no hover (phones & most tablets)
*/
@media (max-width: 720px), (hover: none) and (pointer: coarse){
  .topnav--desktop{ display:none !important; }
  .topnav--mobile{ display:flex !important; }
}

/* Bottom navigation (mobile quick tabs) */
.bottomnav{ display:none; }
@media (max-width: 900px), (hover: none) and (pointer: coarse){
  body{ padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .bottomnav{
    display:flex;
    gap: 6px;
    position: fixed;
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    bottom: max(8px, env(safe-area-inset-bottom, 0px));
    z-index: 70;
    background: rgba(255,255,255,.92);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 7px;
    backdrop-filter: blur(14px);
    box-shadow: 0 18px 60px rgba(0,0,0,.12);
  }
  .bnav{
    flex: 1 1 0;
    min-height: 52px;
    height: 52px;
    border-radius: 16px;
    border: 1px solid transparent;
    background: transparent;
    display:flex;
    flex-direction: column;
    align-items:center;
    justify-content:center;
    gap: 4px;
    color: var(--gray);
    text-decoration:none;
    font-size: 11px;
    font-weight: 750;
    padding: 5px 4px;
  }
  .bnav svg{ opacity: .92; }
  .bnav.active{
    background: rgba(11,91,211,.12);
    border-color: rgba(11,91,211,.25);
    color: var(--blue2);
  }
  .bnav:active{ transform: scale(.99); }
}

@media (max-width: 430px){
  .bottomnav{
    gap: 4px;
    padding: 5px;
    border-radius: 18px;
  }
  .bnav{
    min-height: 48px;
    height: 48px;
    gap: 3px;
    font-size: 10px;
    padding: 4px 3px;
  }
  .bnav svg{
    width: 18px;
    height: 18px;
  }
}


.brand{ display:flex; align-items:center; gap:12px; }
.brand__dot{
  width: 12px; height: 12px; border-radius: 999px;
  background: var(--blue);
  box-shadow: 0 0 0 6px rgba(11,91,211,.12);
}
.brand__title{ font-weight: 800; letter-spacing: .2px; }
.brand__sub{ font-size: 12px; color: var(--muted); margin-top: 2px; }

.footer{
  display:flex;
  justify-content:center;
  gap: 10px;
  margin-top: auto;
  padding: 8px 16px 24px;
  color: var(--muted);
  flex-wrap: wrap;
}

.view.hidden{ display:none; }

.grid{ display:grid; gap: 14px; width:100%; max-width: var(--content-max); margin: 0 auto; }

body.app-view-login .shell{
  display:block;
  max-width:100%;
}

body.app-view-login .topbar,
body.app-view-login .sidebar{
  display:none;
}

body.app-view-login .container{
  max-width: 620px;
  min-height: clamp(0px, calc(100dvh - 112px), 720px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding-top: 20px;
  padding-bottom: 20px;
}

body.app-view-login #app,
body.app-view-login #view-login{
  width:100%;
}

body.app-view-login .footer{
  padding-top: 0;
  padding-bottom: 16px;
}

.login-card{
  width:100%;
  max-width: 580px;
  margin: 0 auto;
  padding: clamp(20px, 3vw, 28px);
  border-radius: var(--r-lg);
}

.login-card__intro{
  display:flex;
  flex-direction:column;
  gap: 8px;
  margin-bottom: 18px;
}

.login-card__eyebrow{
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--blue2);
}

.login-form{
  gap: 12px;
}

@supports (height: 100dvh){
  .sidebar{ max-height: calc(100dvh - 92px); }
}


