/* =============================================================================
   NutraTech — Base & App Shell
   Reset, typography defaults, and the persistent shell (sidebar + topbar).
   Depends on design-tokens.css.
   ============================================================================= */

/* ---- Fonts ---------------------------------------------------------------- */
@import url("https://fonts.googleapis.com/css2?family=Public+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,500;0,8..60,600;1,8..60,400&family=IBM+Plex+Mono:wght@400;500;600&display=swap");

/* ---- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  line-height: var(--lh-normal);
  color: var(--text-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv05" 1, "ss01" 1;
}
h1, h2, h3, h4, h5, p, figure { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }
svg { display: block; }
:focus-visible { outline: none; box-shadow: var(--ring-focus); border-radius: var(--radius-sm); }
::selection { background: var(--teal-200); }

/* ---- Type helpers --------------------------------------------------------- */
.t-label {
  font-size: var(--text-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-muted);
}
.t-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.ic { width: 18px; height: 18px; flex: none; }
.t-num  { font-variant-numeric: tabular-nums; }
.t-muted { color: var(--text-muted); }
.t-secondary { color: var(--text-secondary); }
.t-sm { font-size: var(--text-sm); }
.t-xs { font-size: var(--text-xs); }
.t-lg { font-size: var(--text-lg); }
.section-title {
  font-size: var(--text-md);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
}

/* =============================================================================
   APP SHELL
   ============================================================================= */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar -------------------------------------------------------------- */
.sidebar {
  background: var(--bg-sidebar);
  color: var(--text-on-teal);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}
.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
}
.brandmark {
  width: 34px; height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(150deg, var(--teal-400), var(--teal-600));
  display: grid; place-items: center;
  color: #fff; flex: none;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.brandmark svg { width: 20px; height: 20px; }
.brand__name { font-size: var(--text-md); font-weight: var(--fw-bold); letter-spacing: -0.02em; color: #fff; }
.brand__sub  { font-size: var(--text-2xs); color: var(--text-on-teal-mut); letter-spacing: 0.02em; }

.nav { padding: var(--space-2) var(--space-3); display: flex; flex-direction: column; gap: 2px; }
.nav__group-label {
  font-size: var(--text-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--text-on-teal-mut);
  padding: var(--space-4) var(--space-3) var(--space-2);
}
.nav__item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-on-teal);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  transition: background var(--dur-fast) var(--ease);
  position: relative; white-space: nowrap;
}
.nav__item:hover { background: rgba(255,255,255,0.07); text-decoration: none; }
.nav__item.is-active { background: var(--teal-700); color: #fff; }
.nav__item.is-active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: var(--radius-pill); background: var(--teal-300);
}
.nav__item svg { width: 18px; height: 18px; flex: none; opacity: 0.92; }
.nav__item .nav__count {
  margin-left: auto;
  font-size: var(--text-2xs); font-weight: var(--fw-bold);
  background: rgba(255,255,255,0.14); color: #fff;
  padding: 1px 7px; border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
}
.nav__item .nav__count.is-alert { background: var(--sev-high-500); }

.sidebar__foot { margin-top: auto; padding: var(--space-4); }
.userchip {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2); border-radius: var(--radius-md);
  background: rgba(255,255,255,0.05);
}
.userchip:hover { background: rgba(255,255,255,0.09); }
.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-pill);
  background: var(--teal-500); color: #fff;
  display: grid; place-items: center;
  font-size: var(--text-xs); font-weight: var(--fw-bold);
  flex: none;
}
.userchip__name { font-size: var(--text-xs); font-weight: var(--fw-semibold); color: #fff; }
.userchip__role { font-size: var(--text-2xs); color: var(--text-on-teal-mut); }

/* ---- Main column ---------------------------------------------------------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-6);
  position: sticky; top: 0; z-index: 20;
}
.breadcrumb { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); color: var(--text-muted); white-space: nowrap; }
.breadcrumb b { color: var(--text-primary); font-weight: var(--fw-semibold); }
.breadcrumb .sep { color: var(--border-strong); }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: var(--space-2); }

.searchbox {
  display: flex; align-items: center; gap: var(--space-2);
  background: var(--bg-inset); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-2) var(--space-3);
  width: 280px; color: var(--text-muted);
}
.searchbox input { border: none; background: none; outline: none; width: 100%; font-size: var(--text-sm); }
.searchbox svg { width: 16px; height: 16px; flex: none; }
.searchbox kbd {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1px 5px; color: var(--text-muted);
}

.iconbtn {
  width: 36px; height: 36px; border-radius: var(--radius-md);
  background: transparent; border: 1px solid transparent;
  display: grid; place-items: center; color: var(--text-secondary);
  position: relative;
}
.iconbtn:hover { background: var(--bg-inset); border-color: var(--border); }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn__dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border-radius: 50%; background: var(--sev-high-500); border: 2px solid var(--bg-surface); }

/* ---- Content region ------------------------------------------------------- */
.content { padding: var(--space-6) var(--space-8) var(--space-12); flex: 1; }
.content--wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; gap: var(--space-4); margin-bottom: var(--space-5); }
.page-head__titles { min-width: 0; }
.page-title { font-size: var(--text-2xl); font-weight: var(--fw-bold); letter-spacing: -0.02em; line-height: var(--lh-tight); }
.page-sub { color: var(--text-secondary); font-size: var(--text-md); margin-top: 2px; }
.page-head__actions { margin-left: auto; display: flex; gap: var(--space-2); align-items: center; }

/* ---- Generic layout utilities -------------------------------------------- */
.stack { display: flex; flex-direction: column; }
.stack-2 > * + * { margin-top: var(--space-2); }
.stack-3 > * + * { margin-top: var(--space-3); }
.stack-4 > * + * { margin-top: var(--space-4); }
.stack-6 > * + * { margin-top: var(--space-6); }
.row { display: flex; align-items: center; }
.row-gap-2 { gap: var(--space-2); }
.row-gap-3 { gap: var(--space-3); }
.row-gap-4 { gap: var(--space-4); }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid { display: grid; }

@media (max-width: 1100px) {
  .app { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .sidebar__brand .brand__text, .nav__item span:not(.nav__count), .nav__group-label, .userchip__meta { display: none; }
  .nav__item { justify-content: center; }
  .content { padding: var(--space-5) var(--space-5) var(--space-10); }
}
