/* Shell (§16.3): sidebar + workspace, CSS Grid, no floats, no absolute grids. */

html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

/*
 * The signed-out pages (login, change-password) render no sidebar — there is
 * nothing to navigate to yet — so they centre a single panel instead of using
 * .shell. .stack is the vertical rhythm inside their forms.
 */
.page--centered {
  display: grid;
  place-items: center;
  padding: var(--space-6);
}

.page--centered > .panel {
  width: 100%;
  max-width: 26rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Per-row controls in a DataTable cell: side by side, never wrapping the row. */
.row-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
}

/* Label/value pairs that read as a record, not a form: the Account screen. */
.detail-list {
  display: grid;
  grid-template-columns: minmax(0, 10rem) minmax(0, 1fr);
  gap: var(--space-2) var(--space-4);
  margin: 0 0 var(--space-4);
}

.detail-list dt { color: var(--text-secondary); font-size: var(--text-sm); }
.detail-list dd { margin: 0; color: var(--text); }

/* A generated password, shown exactly once. Large enough to read off a screen
 * and down a phone line, which is the only way it is ever delivered. */
.one-shot {
  margin: var(--space-3) 0 0;
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  letter-spacing: 0.08em;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  padding: var(--space-6) var(--space-4);
  border-right: 1px solid var(--border);
  background: var(--bg-sidebar);
}

.sidebar__identity { display: grid; grid-template-columns: auto 1fr; gap: 0 var(--space-2); align-items: center; }
/* .sidebar prefix beats components.css's single-class .icon rule, which
   loads after this file and would otherwise win the width/height tie. */
.sidebar .sidebar__mark { color: var(--accent-violet-text); width: 1.25rem; height: 1.25rem; }
.sidebar__brand { color: var(--text); font-weight: 600; }
.sidebar__product { grid-column: 2; color: var(--text-muted); font-size: var(--text-xs); }

.sidebar__nav { display: flex; flex-direction: column; gap: var(--space-1); }

.nav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-decoration: none;
  transition: all var(--duration) var(--ease);
}

.nav__item:hover { background: var(--surface); color: var(--text); }

.nav__item.is-active {
  border-color: var(--border-violet);
  background: var(--tint-violet);
  color: var(--accent-violet-text);
}

.nav__item:focus-visible { outline: 2px solid var(--accent-violet-text); outline-offset: 2px; }

.nav__item.is-unbuilt { color: var(--text-muted); cursor: default; }
.nav__item.is-unbuilt:hover { background: transparent; color: var(--text-muted); }
.nav__label { flex: 1; }
.nav__pending {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 0 var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.sidebar__footer { margin-top: auto; display: flex; flex-direction: column; gap: var(--space-3); }
.sidebar__user {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0 var(--space-2);
  align-items: center;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}
.sidebar__user-role { grid-column: 2; color: var(--text-muted); font-size: var(--text-xs); }
.sidebar__sign-out { grid-column: 1 / -1; margin-top: var(--space-2); }
.sidebar__sign-out .btn { width: 100%; justify-content: center; }

.workspace { padding: var(--workspace-padding); display: flex; flex-direction: column; gap: var(--space-6); }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
}

.page-header__title { margin: 0; font-size: var(--text-2xl); font-weight: 600; line-height: var(--leading-tight); }
.page-header__description { margin: var(--space-1) 0 0; color: var(--text-secondary); font-size: var(--text-sm); }
.page-header__actions { display: flex; gap: var(--space-2); flex: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--border); }
  .workspace { padding: var(--space-4); }
  /* A long title beside two header actions overflowed a phone viewport by
     ~30px (fuel.php at 390px) and squeezed the description into a column a
     few words wide (history, export). Let the actions drop under the title. */
  .page-header { flex-wrap: wrap; }
  .page-header__actions { flex-wrap: wrap; }
}
