/* Reset, layout shell, and typography. Shared by the staff shell and the portal. */

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

/* The `hidden` attribute must always win. The browser's own [hidden] rule is weaker than
   any class that sets display (.field is flex, .lo-two is grid), so without this a
   script's `el.hidden = true` silently shows the element anyway: the field dialog showed
   lookup settings on a Text field, Add user showed Access on an Administrator. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv11", "ss03";   /* Inter: single-storey a off, rounder digits */
}

h1, h2, h3 { font-weight: 600; margin: 0; line-height: 1.3; letter-spacing: -.015em; }
h1 { font-weight: 700; letter-spacing: -.02em; }
/* Thin, quiet scrollbars. */
* { scrollbar-width: thin; scrollbar-color: color-mix(in oklab, var(--color-fg) 18%, transparent) transparent; }
h1 { font-size: var(--text-xl); }
h2 { font-size: var(--text-lg); }
h3 { font-size: var(--text-base); }
p { margin: 0; }

a { color: var(--color-accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Every date, count, size and duration aligns in a column. */
.num, time, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

button, [role="button"], summary, label { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

.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;
}

.icon { width: 18px; height: 18px; flex: none; fill: none;
        stroke: currentColor; stroke-width: 2;
        stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }

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

#app { min-height: 100%; }

/* DevNOS (the local test copy) keeps a banner at the top of every page; --banner-h is its height
   and 0 on live, so the full-height parts below stay exactly one window tall. */
:root { --banner-h: 0px; }
body.has-instance-banner { --banner-h: 28px; padding-top: var(--banner-h); }
.instance-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 50; height: var(--banner-h);
                   display: flex; align-items: center; justify-content: center; padding: 0 var(--space-3);
                   background: var(--color-warning); color: var(--color-bg); font-size: var(--text-xs);
                   font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* On a narrow window the banner starts at the left, so its first words (the name) are never cut. */
@media (max-width: 700px) { .instance-banner { justify-content: flex-start; } }

.shell { display: grid; grid-template-columns: var(--sidebar-width) 1fr; min-height: calc(100vh - var(--banner-h)); }

.sidebar {
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column;
  padding: var(--space-4) var(--space-3);
  gap: var(--space-5);
  /* Pinned to the viewport: without this the sidebar stretches with the page
     (the grid row is as tall as the content column), so on a long page the
     account block / Sign out / mark sits at the DOCUMENT bottom -- invisible
     until you scroll everything (sibling app, found at go-live 2026-08-23).
     Sticky keeps it in view while only the content scrolls; overflow-y lets
     the sidebar itself scroll on very short windows so nothing is cut off. */
  position: sticky; top: var(--banner-h);
  height: calc(100vh - var(--banner-h));
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-2); }

/* The NOS logo (ui.js logo()): both images are emitted, one per theme -- dark is the default
   (bare :root), an explicit data-theme wins, and the OS preference covers the unstamped state. */
.logo { flex: none; }
.logo-on-light { display: none; }
.logo-on-dark { display: block; }
:root[data-theme="light"] .logo-on-light { display: block; }
:root[data-theme="light"] .logo-on-dark { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .logo-on-light { display: block; }
  :root:not([data-theme]) .logo-on-dark { display: none; }
}

/* Text selection carries the second color; blue keeps links and actions. */
::selection { background: var(--color-accent-2); color: var(--color-on-accent-2); }
.brand-text { font-weight: 600; font-size: var(--text-sm); line-height: 1.2; }
.brand-text span { display: block; color: var(--color-fg-muted); font-weight: 400;
                   font-size: var(--text-xs); }

.nav { display: flex; flex-direction: column; gap: var(--space-1); }
.nav a {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--color-fg-muted);
  font-size: var(--text-sm); font-weight: 500;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}
.nav a:hover { background: var(--color-muted); color: var(--color-fg); text-decoration: none; }
.nav a:active { transform: scale(.98); }
/* The current page: a raised neutral pill with bright text (the Mauve dashboard's sidebar). */
.nav a[aria-current="page"] { background: var(--color-muted); color: var(--color-fg); font-weight: 600; }
.nav a[aria-current="page"] .icon { color: var(--color-accent-text); }
/* Group headings in the side menu (Work, Setup, Administration, Help). */
.nav-group { margin: var(--space-4) var(--space-3) var(--space-1); font-size: var(--text-xs); font-weight: 500;
             color: var(--color-fg-muted); letter-spacing: .01em; }
.nav-group:first-child { margin-top: 0; }

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column;
                  gap: var(--space-3); padding: 0 var(--space-2); }
/* The corporate mark, at a size you can actually read it at. The lockup is wide
   (1200x529), so width is what controls its weight -- capped against the sidebar so
   it cannot push the nav around. */
.sidebar-footer img { width: min(160px, 100%); height: auto; opacity: .9; }

.user-chip { font-size: var(--text-xs); color: var(--color-fg-muted); }
.user-chip strong { color: var(--color-fg); display: block; font-size: var(--text-sm); }

/* The content uses the whole window (no max-width): on a wide screen a capped main
   left a dead empty band on the right of every page (user, 2026-09-30). min-width: 0
   lets wide tables scroll inside their own box instead of stretching the page. */
.main { padding: var(--space-5) var(--space-6); min-width: 0; }
/* Wrapping matters: heads that carry actions alongside the title squash the title
   into two or three characters per line on a narrow window instead of stacking. */
.page-head { display: flex; align-items: baseline; justify-content: space-between;
             flex-wrap: wrap; gap: var(--space-4); margin-bottom: var(--space-5); }
.page-head > div { min-width: min(32ch, 100%); }
.page-head p { color: var(--color-fg-muted); font-size: var(--text-sm); }

/* Narrow windows: the sidebar becomes a top bar of two rows -- brand and account
   controls on the first, the nav as a full-width row of pills on the second.
   (Lessons carried from the sibling shell: the nav must wrap, labels must not,
   and the desktop gaps must not survive the rewrap.) */
@media (max-width: 1023px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row; align-items: center; flex-wrap: wrap;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-2) var(--space-4);
    border-right: 0; border-bottom: 1px solid var(--color-border);
    /* The top-bar variant flows with the page: undo the desktop pinning. */
    position: static; height: auto; overflow: visible;
  }
  .sidebar-footer { margin-top: 0; margin-left: auto; flex-direction: row;
                    align-items: center; order: 2; gap: var(--space-2); }
  .sidebar-footer img { display: none; }
  /* Identity is already in the brand block; the two-line chip only adds height. */
  .user-chip { display: none; }
  .nav {
    order: 3; flex: 1 1 100%;
    flex-direction: row; flex-wrap: wrap;
    gap: var(--space-1);
  }
  .nav a { white-space: nowrap; padding: var(--space-1) var(--space-3); }
  .nav-group { display: none; }
  .main { padding: var(--space-4); }
  /* The top bar keeps its own height: without this the grid stretched it to fill the
     screen and the wrapped rows drifted apart (empty bands above and below the menu). */
  .shell { grid-template-rows: auto 1fr; }
  .sidebar { align-content: flex-start; }
}
/* Menu button: only on a phone, where the full menu would fill the first screen. Scoped to
   .sidebar: components.css loads after this file and its .btn { display: inline-flex } beat a
   bare .nav-toggle rule, so the button showed on every screen (2026-11-19). */
.sidebar .nav-toggle { display: none; }
@media (max-width: 760px) {
  .sidebar .nav-toggle { display: inline-flex; }
  .sidebar:has(.nav-toggle) .nav { display: none; }
  .sidebar.nav-open .nav { display: flex; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}
