.app-shell {
  display: grid;
  grid-template-columns: var(--layout-sidebar) 1fr;
  grid-template-rows: var(--layout-topbar) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
  background: var(--c-bg-subtle);
}
.app-shell[data-collapsed="true"] { grid-template-columns: var(--layout-sidebar-collapsed) 1fr; }
.sidebar { grid-area: sidebar; background: var(--c-surface); border-right: 1px solid var(--c-border); display: flex; flex-direction: column; min-height: 0; }
.topbar  { grid-area: topbar;  background: var(--c-surface); border-bottom: 1px solid var(--c-border); display: flex; align-items: center; gap: var(--s-3); padding: 0 var(--s-4); z-index: var(--z-sticky); }
.main    { grid-area: main; overflow: auto; padding: var(--s-6); }
.main-inner { max-width: var(--layout-max-content); margin: 0 auto; }

.sidebar__logo { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-4); border-bottom: 1px solid var(--c-border); color: var(--c-fg); }
.sidebar__nav  { flex: 1; padding: var(--s-3); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sidebar__foot { padding: var(--s-3); border-top: 1px solid var(--c-border); }

.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md);
  color: var(--c-fg-muted); font-weight: var(--fw-medium);
  cursor: pointer; transition: background var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out);
  user-select: none;
}
.nav-item:hover { background: var(--c-bg-muted); color: var(--c-fg); }
.nav-item[aria-current="page"] { background: var(--c-bg-muted); color: var(--c-brand); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-section-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.05em; color: var(--c-fg-subtle); padding: var(--s-3) var(--s-3) var(--s-1); }

.topbar__spacer { flex: 1; }
.workspace-switcher {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-1) var(--s-3); border-radius: var(--r-md);
  background: var(--c-bg-muted); cursor: pointer; max-width: 280px; min-width: 0;
}
.workspace-switcher:hover { background: var(--c-border); }
.workspace-switcher__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--fw-medium); }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-6); }
.page-title { margin: 0 0 var(--s-1); }
.page-subtitle { color: var(--c-fg-muted); font-size: var(--fs-base); }

.grid { display: grid; gap: var(--s-4); }
.grid--kpi { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.row { display: flex; gap: var(--s-3); align-items: center; }
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: var(--s-3); }
.gap-1 { gap: var(--s-1) !important; }
.gap-2 { gap: var(--s-2) !important; }
.gap-3 { gap: var(--s-3) !important; }
.gap-4 { gap: var(--s-4) !important; }
.mt-2 { margin-top: var(--s-2) !important; }
.mt-4 { margin-top: var(--s-4) !important; }
.mt-6 { margin-top: var(--s-6) !important; }

@media (max-width: 768px) {
  .app-shell { grid-template-columns: 0 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform var(--dur-3) var(--ease-out); z-index: var(--z-drawer); width: var(--layout-sidebar); }
  .app-shell[data-mobile-open="true"] .sidebar { transform: translateX(0); box-shadow: var(--sh-lg); }
}
