/* MSP base: reset, type and the app shell (sidebar + main). Colours only from tokens.css. */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--c-secondary);
  color: var(--c-text);
  font: 15px/1.5 var(--font-sans);
}

h1, h2, h3 { margin: 0; line-height: 1.25; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
p { margin: 0; }
a { color: inherit; }
a:hover { color: var(--c-highlight); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--c-highlight); outline-offset: 2px; }
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: -999px; top: 8px; z-index: 10; padding: 8px 12px; background: var(--c-highlight); color: var(--c-on-highlight); }
.skip:focus { left: 8px; }
.muted { color: var(--c-muted); }
.mono { font-family: var(--font-mono); font-size: .9em; }

/* ---- shell ---- */

:root { --topbar-h: 56px; } /* the search bar above #main; full-height pages subtract it */

.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.workspace { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex; align-items: center; height: var(--topbar-h); padding: 0 32px;
  background: var(--c-primary); border-bottom: 1px solid var(--c-line);
}
.topbar-search { position: relative; display: flex; align-items: center; width: 100%; max-width: 560px; }
.topbar-search .icon { position: absolute; left: 10px; color: var(--c-muted); pointer-events: none; }
.topbar-search input {
  width: 100%; padding: 8px 12px 8px 38px; border-radius: 8px;
  background: var(--c-secondary); border: 1px solid var(--c-line); color: var(--c-text);
}
.topbar-search input:focus { border-color: var(--c-highlight); outline: none; box-shadow: 0 0 0 2px var(--c-highlight-tint); }
.topbar-search input { padding-right: 96px; } /* room for the Search button inside the field */
.topbar-go { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 30px; padding: 0 14px; }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 24px;
  padding: 20px 12px 16px;
  background: var(--c-primary);
  border-right: 1px solid var(--c-line);
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  background: var(--c-highlight); color: var(--c-on-highlight); font-weight: 700;
}
.brand-name { display: flex; flex-direction: column; font-weight: 700; letter-spacing: .04em; line-height: 1.15; }
.brand-name small { font-weight: 400; letter-spacing: 0; font-size: .72rem; color: var(--c-muted); }

.nav-menu select {
  width: 100%; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  background: var(--c-secondary); border: 1px solid var(--c-line); color: var(--c-text); font-weight: 600;
}
.nav-menu select:focus-visible { outline: 2px solid var(--c-highlight); outline-offset: 1px; }
.nav, .nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group[hidden] { display: none; }
.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 8px;
  text-decoration: none; color: var(--c-muted);
}
.nav a:hover { background: var(--c-hover-tint); color: var(--c-text); }
.nav a[aria-current="page"] { background: var(--c-highlight-tint); color: var(--c-text); box-shadow: inset 3px 0 0 var(--c-highlight); }
.icon { flex: none; }

.sidebar-user { margin-top: auto; display: flex; flex-direction: column; min-height: 2.4em; padding: 0 8px; font-size: .82rem; line-height: 1.2; }
.sidebar-user-code { color: var(--c-text); font-weight: 600; }
.sidebar-user-name { color: var(--c-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot { display: flex; align-items: center; gap: 4px; padding: 0 4px 0 8px; }
.version { margin-right: auto; font-size: .78rem; color: var(--c-muted); }

main { display: flex; flex-direction: column; min-width: 0; min-height: calc(100vh - var(--topbar-h)); padding: 28px 32px 48px; outline: none; }

/* ---- mobile: the sidebar becomes a bar on top ---- */

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar {
    position: static; height: auto; gap: 10px; padding: 10px 16px;
    border-right: 0; border-bottom: 1px solid var(--c-line);
  }
  .brand-name small { display: none; }
  .nav, .nav-group { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav a { flex: none; padding: 8px 10px; }
  .nav a span { display: none; }
  .nav a[aria-current="page"] span { display: inline; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--c-highlight); }
  .sidebar-foot { margin-top: 0; padding: 0; }
  .sidebar-user { display: none; }
  .topbar { height: auto; padding: 10px 16px; }
  main { padding: 20px 16px 40px; min-height: 0; } /* fills the rest of the screen below the top bar */
}
