/* ── App shell: top banner + sidebar + content ───────────────────────────── */
#app { min-height: var(--vh-full); }

/* ── Top banner (always visible) ─────────────────────────────────────────── */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--bg-2);
  color: var(--text);
  display: flex; align-items: center; gap: 14px;
  padding: 0 20px; z-index: 60;
  border-bottom: 1px solid var(--line);
}
#topbar .brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
#topbar .brand img { height: 34px; width: auto; filter: invert(1); } /* white Luminos logo → dark on light bg */
#topbar .brand .divider { width: 1px; height: 28px; background: var(--line); }
#topbar .brand .co-name {
  font-weight: 700; font-size: 1.02rem;
  letter-spacing: -.01em; white-space: nowrap; color: var(--text);
}
#topbar .spacer { flex: 1; }
#topbar .topbar-user { display: flex; align-items: center; gap: 12px; }
#topbar .topbar-user .u-meta { text-align: right; line-height: 1.2; display: block; }
#topbar .topbar-user .u-name { font-weight: 600; font-size: .9rem; display: block; }
#topbar .topbar-user .u-role { font-size: .72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; display: block; }
/* Your name and face, as a control. */
#topbar .topbar-me {
  display: flex; align-items: center; gap: 12px; background: none; border: 1px solid transparent;
  border-radius: 999px; padding: 4px 6px 4px 12px; cursor: pointer; color: inherit; font: inherit;
  transition: all var(--transition);
}
#topbar .topbar-me:hover { background: var(--surface-2); border-color: var(--line); }
#topbar .topbar-me.active { background: var(--surface-3); border-color: var(--line); }
#topbar .avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--surface-3); color: var(--text);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
}
#topbar .logout-btn {
  display: flex; align-items: center; gap: 7px;
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 14px; font-size: .85rem; font-weight: 500;
  transition: all var(--transition);
}
#topbar .logout-btn:hover { background: var(--surface-3); color: var(--text); }
#menu-toggle {
  display: none; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  width: 42px; height: 42px; font-size: 1.2rem; line-height: 1;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; width: var(--sidebar-w);
  background: var(--bg-2); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 50;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-section { padding: 14px 12px 6px; }
.sidebar-section + .sidebar-section { border-top: 1px solid var(--line-2); }
.sidebar-section-label {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .09em; color: var(--text-3); padding: 4px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: .93rem;
  cursor: pointer; transition: all var(--transition); margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--surface-3); color: var(--text); font-weight: 600; }
.nav-item.active .nav-icon { color: var(--text); }
.nav-icon { display: flex; color: var(--text-3); flex-shrink: 0; }
.sidebar-foot { margin-top: auto; padding: 18px 16px; border-top: 1px solid var(--line-2); }
.sidebar-foot .powered {
  font-size: .66rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-3); text-align: center;
}
.sidebar-foot .powered img { height: 26px; margin: 10px auto 0; opacity: .9; }

/* ── Main content ────────────────────────────────────────────────────────── */
#main-wrap { margin-left: var(--sidebar-w); padding-top: var(--topbar-h); min-height: var(--vh-full); }
#content { padding: 26px 30px 70px; max-width: 1360px; }
.page-head { margin-bottom: 22px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .titles h1 { margin-bottom: 3px; }
.page-head .titles p { color: var(--text-3); font-size: .92rem; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Sidebar drawer overlay (mobile/tablet) */
#sidebar-overlay {
  display: none; position: fixed; inset: 0; top: var(--topbar-h);
  background: rgba(0,0,0,.55); z-index: 45;
}
#sidebar-overlay.open { display: block; }

/* ── Sandbox environment bar ─────────────────────────────────────────────────
   Only sandbox.tbs.vbacorp.co.za: the server adds body.sandbox and the bar
   to index.html (server/lib/sandbox.js). A slim dark row across the top of
   the header bar, the way ERPs mark a test system, with VBA's cyan as the one
   accent. The header grows by the bar's height through --topbar-h, so the
   sidebar, page, toasts and sticky panels all sit below it unchanged. */
.sandbox-env, .se-tag { display: none; }
body.sandbox { --env-h: 34px; --topbar-h: calc(64px + var(--env-h)); --env-accent: #33c3dd; }
body.sandbox #topbar { padding-top: var(--env-h); }
body.sandbox .sandbox-env {
  display: flex; align-items: center; gap: 12px;
  height: var(--env-h); padding: 0 20px;
  background: #262526; color: #fff;
  border-bottom: 2px solid var(--env-accent);
  font-size: .8rem; line-height: 1; white-space: nowrap; overflow: hidden;
}
body.sandbox #topbar .sandbox-env { position: absolute; top: 0; left: 0; right: 0; }
body.sandbox .se-name {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; letter-spacing: .14em;
}
body.sandbox .se-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--env-accent); }
body.sandbox .se-sep { width: 1px; height: 12px; background: rgba(255, 255, 255, .28); }
body.sandbox .se-note { color: rgba(255, 255, 255, .72); letter-spacing: .02em; text-overflow: ellipsis; overflow: hidden; }
body.sandbox #topbar .brand .se-tag {
  display: inline-block; margin-left: -4px;
  padding: 4px 8px; border-radius: 4px;
  background: #262526; color: #fff;
  font-size: .68rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; line-height: 1;
}
/* On the sign-in page the bar is its own row above the two panels. */
body.sandbox #login-screen:not(.hidden) { display: flex; flex-direction: column; overflow-y: auto; }
body.sandbox #login-screen .sandbox-env { flex-shrink: 0; }
body.sandbox #login-screen .auth-grid { flex: 1; min-height: 0; }

/* Home. One control, two homes: the topbar on desktop, the drawer once the
   sidebar is a drawer - so it is always reachable and never duplicated. */
#topbar .topbar-home { width: 34px; height: 34px; }
#topbar .topbar-home.active { background: var(--surface-3); color: var(--text); border-color: var(--line-2); }
#nav-home-section { display: none; }

/* ── Responsive (tablet + mobile) ────────────────────────────────────────── */
@media (max-width: 960px) {
  #topbar .topbar-home { display: none; }
  #nav-home-section { display: block; }
  #menu-toggle { display: flex; align-items: center; justify-content: center; }
  #sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  #sidebar.open { transform: translateX(0); }
  #main-wrap { margin-left: 0; }
  #content { padding: 18px 16px 80px; }
  #topbar .brand .co-name { font-size: .92rem; }
  #topbar .topbar-user .u-meta { display: none; }
  #topbar .topbar-me { padding: 4px; }
  #topbar .logout-btn span { display: none; }
  #topbar .logout-btn { padding: 9px; }
}
/* Phones: the long company name overflows into the avatar - keep just the logo. */
@media (max-width: 620px) {
  body.sandbox .sandbox-env { padding: 0 12px; gap: 10px; }
  body.sandbox .se-more { display: none; }
  body.sandbox #topbar .brand .se-tag { display: none; }
}
@media (max-width: 620px) {
  #topbar { padding: 0 12px; gap: 10px; }
  #topbar .brand .co-name,
  #topbar .brand .divider { display: none; }
  #topbar .brand img { height: 30px; }
  #topbar .topbar-user { gap: 8px; }
}
