/* =====================================================================
   App shell (header + sidebar + main) rendered by components/app-shell.js,
   plus generic layout helpers.
   ===================================================================== */
.app-header {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-4);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
}
.app-header .brand {
  display: flex; align-items: center; gap: var(--sp-2);
  font-weight: 700; color: var(--c-text);
}
.app-header .brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  background: var(--c-primary); color: var(--c-on-primary);
  font-size: var(--fs-sm); font-weight: 800;
}
.app-header .spacer { flex: 1; }
.app-header .user-chip { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }
.app-header .user-chip .role { color: var(--c-text-muted); }
.menu-toggle { display: none; }

.app-body { display: flex; min-height: calc(100vh - var(--header-h)); }

.app-sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  padding: var(--sp-4) var(--sp-3);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
}
.app-sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.app-sidebar .nav-section {
  margin: var(--sp-4) var(--sp-2) var(--sp-1);
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--c-text-muted);
}
.app-sidebar a {
  display: block; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--c-text); font-size: var(--fs-sm);
}
.app-sidebar a:hover { background: var(--c-surface-2); text-decoration: none; }
.app-sidebar a[aria-current="page"] { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; }

.app-main { flex: 1; min-width: 0; padding: var(--sp-5); }
.public-main { max-width: 1120px; margin: 0 auto; }

.page-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--sp-3); margin-bottom: var(--sp-5);
}
.page-header h1 { margin: 0; }
.breadcrumb { font-size: var(--fs-sm); color: var(--c-text-muted); margin-bottom: var(--sp-1); }

.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-2 { display: grid; gap: var(--sp-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Centered single-card pages (login, register, ...) */
.auth-layout {
  min-height: 100vh; display: grid; place-items: center;
  padding: var(--sp-5) var(--sp-4);
}
.auth-layout .card { width: 100%; max-width: 420px; }

@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .app-sidebar {
    position: fixed; z-index: 30; top: var(--header-h); bottom: 0; left: 0;
    transform: translateX(-100%); transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }
  body.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-main { padding: var(--sp-4); }
  .grid-2 { grid-template-columns: 1fr; }
  .app-header .user-chip .name { display: none; }
}

/* Phones (down to 360px): stack headers, let filters and dialogs use the full width. */
@media (max-width: 480px) {
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header > .row, .page-header > .btn { justify-content: flex-start; }
  .toolbar .input, .toolbar .select { min-width: 0; max-width: none; flex-basis: 100%; }
  .label-row { flex-wrap: wrap; }
  .table th, .table td { padding: var(--sp-2); }
  dialog.modal { width: calc(100vw - 2 * var(--sp-3)); max-width: none; }
  .form-actions .btn { flex: 1 1 auto; }
}
