/* App shell: fixed sidebar + scrolling body. */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: var(--topbar-h);
  padding: 0 var(--s-5);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.brandmark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  background: var(--brand);
  color: var(--brand-fg);
  flex: none;
}
.brandmark__word {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sidebar__close { display: none; margin-left: auto; }

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5) var(--s-3);
}

.nav-group__label {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 var(--s-3);
  margin-bottom: var(--s-2);
}
.nav-group { margin-bottom: var(--s-6); }
.nav-group:last-child { margin-bottom: 0; }

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: var(--fs-body);
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-link svg { flex: none; color: var(--text-3); transition: color var(--dur-fast) var(--ease); }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover svg { color: var(--text-2); }

.nav-link[aria-current="page"] {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 550;
}
.nav-link[aria-current="page"] svg { color: var(--brand); }
.nav-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset-inline-start: calc(var(--s-3) * -1);
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 20px;
  border-radius: var(--r-full);
  background: var(--brand-line);
}

.sidebar__foot {
  flex: none;
  padding: var(--s-3);
  border-top: 1px solid var(--border);
  display: grid;
  gap: var(--s-3);
}

.profile {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2);
}
.profile__avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 600;
  font-size: var(--fs-sm);
}
.profile__meta { display: grid; min-width: 0; }
.profile__name {
  font-size: var(--fs-sm);
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile__note { font-size: var(--fs-xs); color: var(--text-3); }

/* ---------- Body column ---------- */
.shell__body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  gap: var(--s-3);
  height: var(--topbar-h);
  padding: 0 var(--s-6);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.topbar__menu { display: none; }
.topbar__title { display: none; font-weight: 600; }

.topbar__search {
  position: relative;
  flex: 1;
  max-width: 420px;
  margin-inline-end: auto;
}
.topbar__search-icon {
  position: absolute;
  left: var(--s-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}
.topbar__search input {
  width: 100%;
  height: 36px;
  padding: 0 var(--s-3) 0 var(--s-8);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
}
.topbar__search input::placeholder { color: var(--text-3); }
.topbar__search input:focus-visible { outline-offset: 0; border-color: var(--brand); }
.topbar__search input::-webkit-search-cancel-button { -webkit-appearance: none; }

.view {
  flex: 1;
  padding: var(--s-8) var(--s-6) var(--s-12);
  max-width: calc(var(--content-max) + var(--s-6) * 2);
  width: 100%;
}
.view:focus { outline: none; }

.tabbar { display: none; }

/* ---------- Page header ---------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  margin-bottom: var(--s-6);
}
.page-head__text { min-width: 0; }
.page-head__eyebrow {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: var(--s-1);
}
.page-head__title { font-size: var(--fs-display); }
.page-head__sub {
  color: var(--text-2);
  font-size: var(--fs-sm);
  margin-top: var(--s-1);
  max-width: 60ch;
}
.page-head__actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
}
/* `flex: 1 1 auto`, not `flex: 1`. A zero flex-basis stops the row from ever
   wrapping, and nowrap button labels then overflow instead of moving down. */
.page-head__actions > .btn { flex: 1 1 auto; }

/* ---------- Generic grids ---------- */
.grid { display: grid; gap: var(--s-4); }
.grid--kpi   { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--split { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); align-items: start; }
.grid--halves{ grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.grid--cards { grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); }
/* `minmax(0, 1fr)` rather than the default `auto`: an auto track grows to the
   widest child's min-content, so one wide table or a nowrap button row would
   stretch the whole page and produce horizontal overflow on narrow screens. */
.stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-4);
}
