/* App layout v4: one white sidebar + topbar + content */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

/* Sidebar (contents styled in shell.css) */
.sidebar {
  background: var(--c-side-bg);
  color: var(--c-side-text);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
  scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; color: var(--c-text); }
.brand:hover { text-decoration: none; }
.brand__logo { width: 38px; height: 38px; flex: none; border-radius: 11px; background: var(--brand-mark); display: grid; place-items: center; color: #fff; }
.brand__logo svg { width: 22px; height: 22px; fill: currentColor; stroke: none; }
.brand__name { display: block; font-weight: 700; font-size: 18px; line-height: 1.2; color: var(--c-text); }
.brand__sub { display: block; font-size: 13px; color: var(--c-text-3); line-height: 1.3; }

/* Main column */
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h);
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-6);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.branch-switch { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; border: 1px solid var(--c-border-strong); border-radius: var(--r-full); font-weight: 650; font-size: 14px; background: var(--c-surface); color: var(--c-text); white-space: nowrap; }
.branch-switch:hover { border-color: var(--c-primary); text-decoration: none; }
.branch-switch .icon { color: var(--c-text-3); }
.branch-switch--static { border-color: transparent; color: var(--c-text-2); padding: 0 6px; }
.branch-switch--static:hover { border-color: transparent; }
.icon-btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: var(--r-full); color: var(--c-text-2); border: 1px solid transparent; background: none; cursor: pointer; }
.icon-btn:hover { background: var(--c-surface-3); color: var(--c-text); text-decoration: none; }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 9px; height: 9px; background: var(--c-danger); border-radius: 50%; border: 2px solid var(--c-surface); }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 6px; }
.user-chip__name { font-weight: 650; font-size: 14px; line-height: 1.25; color: var(--c-text); }
.user-chip__role { font-size: 13px; color: var(--c-text-3); line-height: 1.25; }

.content { padding: var(--sp-6) var(--sp-8) var(--sp-8); display: flex; flex-direction: column; gap: var(--sp-5); max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; }
.page-head__title { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.page-head__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.crumbs { font-size: 14px; color: var(--c-text-3); display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--c-link); }

/* Common page layouts */
.layout-aside { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--sp-5); align-items: start; }
.layout-aside--left { grid-template-columns: 320px minmax(0, 1fr); }
.layout-3col { display: grid; grid-template-columns: 280px minmax(0, 1fr) 300px; gap: var(--sp-4); align-items: start; }

/* Mobile nav toggle (checkbox hack) */
.nav-toggle { display: none; }
.nav-burger { display: none; }
.nav-scrim { display: none; }

@media (max-width: 1320px) {
  .layout-3col { grid-template-columns: 260px minmax(0, 1fr); }
  .layout-3col > :last-child { grid-column: 1 / -1; }
}
@media (max-width: 1180px) {
  .layout-aside, .layout-aside--left { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 60; transform: translateX(-105%); transition: transform .2s ease; }
  .nav-toggle:checked ~ .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .nav-toggle:checked ~ .nav-scrim { display: block; }
  .nav-scrim { display: none; position: fixed; inset: 0; background: rgba(15, 29, 36, .4); z-index: 55; }
  .nav-burger { display: inline-flex; }
  .topbar { padding: 0 var(--sp-4); }
  .user-chip__text { display: none; }
  .content { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
  .layout-3col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 600px) {
  .branch-switch { display: none; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn--primary { flex: 1; }
}
