/* Reset, typography and the workbench shell (redesign D-81: Mission Control + Context
   Workbench). No external resources; no inline styles are needed. The shell is a fixed
   sidebar with the brand and the nine entries, a sticky top bar with the breadcrumb and
   the Network Guard status, and the workspace. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: 5rem; /* WCAG 2.4.11: the sticky header must not cover focused items */
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-text);
  font-size: 1rem;
  line-height: 1.5;
  font-feature-settings: "tnum" 1, "cv11" 1;
  overflow-wrap: break-word;
}

h1,
h2,
h3 {
  line-height: 1.2;
  margin: 0 0 var(--space-3);
}

h1 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 1.15rem;
  font-weight: 600;
}

h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

p {
  margin: 0 0 var(--space-3);
  max-width: var(--measure);
}

a {
  color: var(--accent);
  text-underline-offset: 0.2em;
}

a:hover {
  text-decoration-thickness: 2px;
}

code,
kbd,
samp,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  font-feature-settings: "liga" 0, "calt" 0; /* verbatim -> != == in evidence */
}

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

.skip {
  position: absolute;
  left: var(--space-4);
  top: -4rem;
  z-index: 10;
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--on-accent);
  border-radius: var(--radius);
  font-weight: 600;
}

.skip:focus {
  top: var(--space-2);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* The brand: in the sidebar when signed in, in the top bar on the sign-in page. */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--text);
  text-decoration: none;
}

.brand .icon {
  color: var(--accent);
  width: 1.5rem;
  height: 1.5rem;
}

/* Page shell: sidebar first, then the work column (top bar + main). */
.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

.work {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Top bar: breadcrumb on the left, Network Guard status and tools on the right. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-4);
  min-height: 3.5rem;
  padding: var(--space-2) var(--space-4);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.crumbs {
  min-width: 0;
}

.crumbs ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.9rem;
}

.crumbs li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.crumbs .crumb-sep {
  color: var(--text-muted);
}

.crumbs a {
  color: var(--text-muted);
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--text);
  text-decoration: underline;
}

.crumbs .crumb-here {
  color: var(--text);
  font-weight: 600;
}

.topbar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-inline-start: auto;
}

.topbar form {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
}

/* The top bar's own controls stay quiet: small, borderless until hovered. */
.topbar-tools button,
.topbar-tools select {
  min-height: 2.25rem;
  font-size: 0.9rem;
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.topbar-tools select {
  width: auto;
  border: 1px solid var(--border);
}

.topbar-tools button:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* The Lockdown entry in the top bar is a link to the Traffic page, where the real,
   plain-form Lockdown lives: pressing this never locks anything by itself. */
.lockdown-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-weight: 600;
  text-decoration: none;
}

.lockdown-link:hover {
  background: var(--surface);
}

/* Sidebar: brand, the nine entries, and the instance footer. */
.sidenav {
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--border);
  background: var(--nav);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sidenav .brand {
  padding: var(--space-2) var(--space-3);
}

.sidenav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidenav a,
.sidenav summary {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--control-height);
  font-size: 0.95rem;
  padding: 0 var(--space-3);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
  border-inline-start: 3px solid transparent;
  cursor: pointer;
}

.sidenav a:hover,
.sidenav summary:hover {
  background: var(--surface-2);
}

.sidenav a[aria-current="page"] {
  background: var(--surface-2);
  border-inline-start-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* Grouped navigation (README 2.2): nine entries, submenus collapsed unless active. */
.navgroup summary {
  list-style: none;
  font-weight: 500;
  color: var(--text);
}

.navgroup summary::-webkit-details-marker {
  display: none;
}

.navgroup[open] > summary {
  color: var(--text);
  font-weight: 600;
}

.navcaret {
  margin-inline-start: auto;
  display: inline-flex;
  color: var(--text-muted);
}

.navgroup[open] > summary .navcaret {
  transform: rotate(90deg);
}

.navsub {
  margin: var(--space-1) 0 var(--space-2);
  padding-inline-start: var(--space-4);
  border-inline-start: 1px solid var(--border);
}

.navsub a {
  min-height: 2.25rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.navsub a[aria-current="page"] {
  color: var(--accent);
}

/* The count of pending authorizations beside Traffic: the same number as the header chip. */
.navbadge {
  margin-inline-start: auto;
  min-width: 1.5rem;
  padding: 0 var(--space-2);
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
}

.sidenav a[aria-current="page"] .navbadge {
  margin-inline-start: var(--space-2);
}

.sidenav-foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: auto 0 0;
  padding: var(--space-3) var(--space-3) var(--space-1);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.85rem;
}

main {
  padding: var(--space-6) var(--space-4) var(--space-12);
  width: 100%;
  max-width: 90rem;
}

main:focus {
  outline: none;
}

@media (min-width: 52rem) {
  .shell:has(> .sidenav) {
    grid-template-columns: var(--sidenav-width) minmax(0, 1fr);
    align-items: start;
  }

  .sidenav {
    position: sticky;
    top: 0;
    min-height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    border-bottom: 0;
    border-inline-end: 1px solid var(--border);
  }

  main {
    padding: var(--space-6) var(--space-8) var(--space-12);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .sidenav a,
  .btn,
  button {
    transition: background-color 0.15s ease, border-color 0.15s ease;
  }
}
