/* ============================================================
   GTBNPS FINANCE — LAYOUT
   App shell: sidebar, topbar, content area, mobile bottom nav.
   ============================================================ */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh; height: 100dvh;
  transition: grid-template-columns var(--base);
}
.shell.collapsed { grid-template-columns: var(--sidebar-w-col) 1fr; }

/* ══════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════ */
.sidebar {
  background: linear-gradient(178deg, var(--navy) 0%, var(--navy-deep) 100%);
  display: flex; flex-direction: column;
  overflow: hidden;
  padding-top: env(safe-area-inset-top);
  position: relative;
  z-index: 40;
}

.sidebar__head {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4) var(--s4) var(--s3);
  min-height: 66px;
}
.sidebar__mark {
  width: 38px; height: 38px; flex: none; border-radius: 11px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  display: grid; place-items: center; overflow: hidden;
  color: var(--gold-light); font-weight: var(--w-black); font-size: 14px; letter-spacing: -.5px;
}
.sidebar__mark img { width: 100%; height: 100%; object-fit: cover; }
.sidebar__titles { min-width: 0; transition: opacity var(--fast); }
.sidebar__title { color: #fff; font-size: var(--t-base); font-weight: var(--w-bold); letter-spacing: -.01em; }
.sidebar__sub { color: rgba(255,255,255,.5); font-size: var(--t-xs); }
.shell.collapsed .sidebar__titles { opacity: 0; pointer-events: none; }

.sidebar__nav {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: var(--s2) var(--s3) var(--s4);
  /* The scrollbar is hidden here on purpose: a pale track against the
     navy reads as a rendering fault rather than an affordance. */
  scrollbar-width: none;
}
.sidebar__nav::-webkit-scrollbar { width: 0; }

.nav__group {
  color: rgba(255,255,255,.34);
  font-size: 10px; font-weight: var(--w-bold);
  letter-spacing: .09em; text-transform: uppercase;
  padding: var(--s4) var(--s3) var(--s2);
  white-space: nowrap;
}
.shell.collapsed .nav__group { opacity: 0; height: 20px; padding: 6px 0 0; }

.nav__item {
  display: flex; align-items: center; gap: var(--s3);
  width: 100%; padding: 10px var(--s3);
  border-radius: var(--r-sm);
  color: rgba(255,255,255,.72);
  font-size: var(--t-base); font-weight: var(--w-medium);
  transition: background var(--fast), color var(--fast);
  position: relative; white-space: nowrap;
  margin-bottom: 2px;
}
.nav__item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav__item.active { background: rgba(255,255,255,.13); color: #fff; font-weight: var(--w-semi); }
.nav__item.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--gold-light);
}
.nav__icon { width: 20px; height: 20px; flex: none; display: grid; place-items: center; }
.nav__icon svg { width: 18px; height: 18px; stroke-width: 1.9; }
.nav__label { flex: 1; text-align: left; transition: opacity var(--fast); }
.shell.collapsed .nav__label { opacity: 0; pointer-events: none; }
.nav__badge {
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: var(--r-full);
  background: var(--gold); color: var(--navy-deep);
  font-size: 10.5px; font-weight: var(--w-bold);
  display: grid; place-items: center;
}
.shell.collapsed .nav__badge {
  position: absolute; top: 5px; right: 5px; min-width: 8px; height: 8px; padding: 0; font-size: 0;
}
/* A nav item that is only visible to some roles reads as ordinary;
   the private one gets a quiet gold edge so the bursar can see at a
   glance that she is looking at something not everyone sees. */
.nav__item.private { color: var(--gold-light); }
.nav__item.private.active { background: rgba(212,160,23,.17); }
.nav__item.private.active::before { background: var(--gold); }

.sidebar__foot { padding: var(--s3); border-top: 1px solid rgba(255,255,255,.08); }
.sidebar__user {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2); border-radius: var(--r-sm); width: 100%;
  transition: background var(--fast);
}
.sidebar__user:hover { background: rgba(255,255,255,.07); }
.avatar {
  width: 32px; height: 32px; flex: none; border-radius: var(--r-full);
  background: var(--navy-soft); color: #fff;
  display: grid; place-items: center; overflow: hidden;
  font-size: var(--t-sm); font-weight: var(--w-bold);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.sidebar__user-txt { min-width: 0; text-align: left; transition: opacity var(--fast); }
.sidebar__user-name { color: #fff; font-size: var(--t-sm); font-weight: var(--w-semi); }
.sidebar__user-role { color: rgba(255,255,255,.45); font-size: var(--t-xs); }
.shell.collapsed .sidebar__user-txt { opacity: 0; pointer-events: none; }

.sidebar__toggle {
  position: absolute; top: 74px; right: -11px; z-index: 50;
  width: 22px; height: 22px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
  display: grid; place-items: center; color: var(--text-2);
  transition: transform var(--base);
}
.sidebar__toggle svg { width: 13px; height: 13px; }
.shell.collapsed .sidebar__toggle { transform: rotate(180deg); }

/* ══════════════════════════════════════════════════════════
   MAIN
   ══════════════════════════════════════════════════════════ */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  height: var(--topbar-h);
  flex: none;
  display: flex; align-items: flex-end; gap: var(--s3);
  padding: 0 var(--s5) 0;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.topbar__inner {
  height: 58px; width: 100%;
  display: flex; align-items: center; gap: var(--s3);
}
.topbar__title { font-size: var(--t-lg); font-weight: var(--w-bold); letter-spacing: -.02em; }
.topbar__sub { font-size: var(--t-xs); color: var(--text-3); margin-top: -2px; }

.iconbtn {
  width: 36px; height: 36px; border-radius: var(--r-sm);
  display: grid; place-items: center; color: var(--text-2);
  transition: background var(--fast), color var(--fast);
  position: relative; flex: none;
}
.iconbtn:hover { background: var(--bg-sunken); color: var(--text); }
.iconbtn svg { width: 19px; height: 19px; stroke-width: 1.8; }
.iconbtn__dot {
  position: absolute; top: 6px; right: 6px;
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-full);
  background: var(--red-mid); color: #fff;
  font-size: 9.5px; font-weight: var(--w-bold);
  display: grid; place-items: center;
  border: 2px solid var(--surface);
}

.content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: var(--s5);
  scroll-behavior: smooth;
}
.content.flush { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

.page { max-width: 1420px; margin: 0 auto; }
.page-head { margin-bottom: var(--s5); }
.page-head h2 { font-size: var(--t-xl); }
.page-head p { color: var(--text-2); font-size: var(--t-base); margin-top: var(--s1); }

/* ══════════════════════════════════════════════════════════
   MOBILE
   ══════════════════════════════════════════════════════════ */
.scrim {
  position: fixed; inset: 0; z-index: 45;
  background: rgba(15,30,66,.45);
  backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden; transition: opacity var(--base), visibility var(--base);
}
.scrim.on { opacity: 1; visibility: visible; }

.bottomnav { display: none; }

@media (max-width: 900px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0;
    width: min(300px, 86vw);
    transform: translateX(-102%);
    transition: transform var(--spring);
    box-shadow: var(--sh-xl);
    /* ABOVE the scrim. At the shell's default z-index of 40 the
       drawer slid out behind the dark blurred overlay — it looked
       dimmed and unreadable, and every tap landed on the scrim and
       closed it again instead of hitting a nav item. */
    z-index: 50;
  }
  .sidebar.open { transform: none; }
  .sidebar__toggle { display: none; }
  /* The collapsed-rail rules must not leak into the mobile drawer —
     a drawer with invisible labels would be unusable. */
  .shell.collapsed .sidebar__titles,
  .shell.collapsed .nav__label,
  .shell.collapsed .sidebar__user-txt { opacity: 1; pointer-events: auto; }
  .shell.collapsed .nav__group { opacity: 1; height: auto; padding: var(--s4) var(--s3) var(--s2); }
  .shell.collapsed .nav__badge {
    position: static; min-width: 19px; height: 19px; padding: 0 5px; font-size: 10.5px;
  }

  .topbar { padding: 0 var(--s4); }
  .content { padding: var(--s4) var(--s4) calc(var(--bottomnav-h) + var(--s6) + env(safe-area-inset-bottom)); }
  .content.flush { padding: 0; }

  .bottomnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 44;
    display: flex; align-items: stretch;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: rgba(255,255,255,.94);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-top: 1px solid var(--border);
  }
  .bottomnav__item {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; color: var(--text-3); font-size: 10.5px; font-weight: var(--w-medium);
    position: relative; transition: color var(--fast);
  }
  .bottomnav__item svg { width: 21px; height: 21px; stroke-width: 1.85; }
  .bottomnav__item.active { color: var(--navy); font-weight: var(--w-semi); }
  .bottomnav__item.active::before {
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--navy);
  }
  .bottomnav__badge {
    position: absolute; top: 6px; left: 50%; margin-left: 4px;
    min-width: 15px; height: 15px; padding: 0 4px; border-radius: var(--r-full);
    background: var(--red-mid); color: #fff; font-size: 9px; font-weight: var(--w-bold);
    display: grid; place-items: center; border: 2px solid #fff;
  }

  .page-head h2 { font-size: var(--t-lg); }
}

@media (max-width: 480px) {
  /* On a narrow phone the title was competing with the action
     buttons and losing — "Dashboa…". The subtitle is a nicety; the
     page name is not. */
  .topbar__title { font-size: var(--t-base); }
  .topbar__sub { display: none; }
  .topbar { padding: 0 var(--s3); }
  .topbar__inner { gap: var(--s2); }
}
