/* Reset, typography and the app shell (sidebar + top bar + content). */
@font-face {
  font-family: "Inter";
  src: url("../fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/InterVariable-Italic.woff2") format("woff2");
  font-weight: 100 900; font-style: italic; font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: var(--fs-md); line-height: var(--lh);
  font-feature-settings: "cv05", "cv11";
}
h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 var(--sp-2); font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }
strong { font-weight: 600; }
small, .small { font-size: var(--fs-sm); color: var(--muted); }
.muted { color: var(--muted); }
.lead { font-size: var(--fs-lg); color: var(--text); }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-5) 0; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .92em; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 1px 5px; }
:focus-visible { outline: var(--focus-ring); outline-offset: 2px; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: var(--sp-3); top: -60px; background: var(--surface); color: var(--brand-700); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); z-index: 100; box-shadow: var(--shadow-md); }
.skip-link:focus { top: var(--sp-3); }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; height: 100dvh; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-5) var(--sp-5) var(--sp-4); text-decoration: none; color: inherit; }
.sidebar-brand:hover { text-decoration: none; }
.sidebar-brand img { width: 176px; height: auto; display: block; }
.sidebar-brand .suite { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--side-muted); margin-top: var(--sp-2); font-weight: 600; }
.sidebar nav { padding: 0 var(--sp-3) var(--sp-4); flex: 1; }
.nav-section { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--side-muted); font-weight: 650; padding: var(--sp-4) var(--sp-3) var(--sp-1); }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3); padding: 9px var(--sp-3); margin: 1px 0;
  color: var(--side-text); text-decoration: none; border-radius: var(--r-sm); font-weight: 500; font-size: var(--fs-md);
  position: relative; border-left: 3px solid transparent;
}
.nav-item .icon { width: 18px; height: 18px; flex: 0 0 18px; opacity: .8; }
.nav-item:hover { background: var(--side-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--side-active); color: #fff; border-left-color: var(--side-accent); }
.nav-item.active .icon { opacity: 1; color: var(--side-accent); }
.sidebar-foot { padding: var(--sp-4) var(--sp-5); font-size: var(--fs-xs); color: var(--side-muted); border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-scrim { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-6); position: sticky; top: 0; z-index: 20;
}
.topbar .crumbs { display: flex; align-items: center; gap: var(--sp-2); min-width: 0; font-size: var(--fs-sm); color: var(--muted); }
.topbar .crumbs a { color: var(--muted); }
.topbar .crumbs .sep { color: var(--faint); }
.topbar .crumbs .current { color: var(--ink); font-weight: 600; font-size: var(--fs-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .grow { flex: 1; }
.topbar .ver { font-size: var(--fs-xs); color: var(--faint); white-space: nowrap; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--r-sm);
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn .icon { width: 20px; height: 20px; }
.sidebar-toggle { display: none; }

/* User menu */
.menu { position: relative; }
.menu-button {
  display: inline-flex; align-items: center; gap: var(--sp-2); padding: 6px 10px 6px 6px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font: inherit; color: var(--text); max-width: 260px;
}
.menu-button:hover { background: var(--surface-2); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--brand-700); color: #fff; font-weight: 650; font-size: 12px;
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 28px;
}
.menu-button .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-button .icon { width: 16px; height: 16px; color: var(--muted); }
.menu-panel {
  display: none; position: absolute; right: 0; top: calc(100% + 6px); min-width: 240px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-md); padding: var(--sp-2); z-index: 30;
}
.menu.open .menu-panel { display: block; }
.menu-panel .who { padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-2); }
.menu-panel .who strong { display: block; }
.menu-panel .who span { font-size: var(--fs-sm); color: var(--muted); }
.menu-panel a, .menu-panel button {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%; text-align: left; padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm); color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--surface-2); text-decoration: none; }
.menu-panel .icon { width: 16px; height: 16px; color: var(--muted); }

.content { flex: 1; padding: var(--sp-6); width: 100%; max-width: var(--content-max); margin: 0 auto; }
.content.narrow { max-width: var(--narrow-max); }
.content.reading { max-width: var(--reading-max); }
.foot { padding: var(--sp-4) var(--sp-6); font-size: var(--fs-xs); color: var(--faint); text-align: center; }

/* Page header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: var(--fs-2xl); }
.page-head .sub { color: var(--muted); margin: var(--sp-1) 0 0; max-width: 72ch; }
.page-head .actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }

/* ---------- Auth layout (signed out) ---------- */
.auth-body { min-height: 100vh; display: flex; flex-direction: column; background: linear-gradient(160deg, var(--brand-900), var(--brand-700) 70%, var(--brand-600)); }
.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: var(--sp-8) var(--sp-4); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: var(--sp-8); }
.auth-card .logo { display: block; width: 220px; margin: 0 auto var(--sp-6); }
.auth-card h1 { font-size: var(--fs-xl); text-align: center; }
.auth-card .lead { font-size: var(--fs-md); color: var(--muted); text-align: center; margin-bottom: var(--sp-5); }
.auth-card .btn.block { width: 100%; justify-content: center; margin-top: var(--sp-2); }
.auth-links { text-align: center; margin-top: var(--sp-5); font-size: var(--fs-sm); color: var(--muted); }
.auth-foot { text-align: center; padding: var(--sp-4); font-size: var(--fs-xs); color: rgba(255,255,255,.7); }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  :root { --sidebar-w: 232px; }
  .content { padding: var(--sp-5); }
}
@media (max-width: 860px) {
  /* Off canvas AND hidden, so the drawer's links leave the tab order until it opens. */
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility 0s .2s; box-shadow: none; }
  .shell.sidebar-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(0,34,17,.45); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .shell.sidebar-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
  .sidebar-toggle { display: inline-flex; }
  .topbar { padding: 0 var(--sp-4); }
  .topbar .ver { display: none; }
  .menu-button .name { display: none; }
  .content { padding: var(--sp-4); }
  .page-head h1 { font-size: var(--fs-xl); }
  .auth-card { padding: var(--sp-6); }
}
