:root {
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --bg: #f8fafc;
  --panel: #ffffff;
  --accent: #1d4ed8;
  --accent-soft: #dbeafe;
  --todo: #b45309;
  --todo-bg: #fef3c7;
  --header-h: 60px;
  --sidebar-w: 288px;
  --maxw: 1180px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

/* Masthead */
.masthead {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  background: #0f172a;
  color: #f8fafc;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

#top {
  scroll-margin-top: calc((var(--header-h) + 16px) * -1);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #f8fafc;
  color: var(--accent);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.3px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}

.brand-title {
  font-weight: 700;
  font-size: 17px;
}

.brand-subtitle {
  font-size: 12.5px;
  color: #cbd5e1;
  letter-spacing: 0.3px;
}

.masthead-badge {
  flex-shrink: 0;
  margin-left: auto;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fbbf24;
  color: #7c2d12;
}

.nav-toggle {
  display: none;
  flex-shrink: 0;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 44px;
  height: 44px;
  padding: 0 8px;
  background: transparent;
  border: 1px solid rgba(248, 250, 252, 0.25);
  border-radius: 8px;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  height: 2px;
  background: #f8fafc;
  border-radius: 2px;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 40px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px;
  align-items: start;
}

/* Sidebar / TOC */
.sidebar {
  position: sticky;
  top: var(--header-h);
  align-self: start;
  max-height: calc(100vh - var(--header-h));
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px 8px 28px 0;
}

.toc-heading {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  padding-left: 12px;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: none;
}

.toc-list li {
  margin: 0;
}

.toc-list a {
  display: block;
  padding: 7px 12px;
  border-left: 2px solid transparent;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
  border-radius: 0 6px 6px 0;
}

.toc-list a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.toc-list a.is-active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.toc-list ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-list ol a {
  padding-left: 28px;
  font-size: 13px;
}

/* Content */
.content {
  padding: 28px 0 64px;
  max-width: 780px;
  min-width: 0;
}

.doc-intro {
  border-bottom: 1px solid var(--line);
  padding-bottom: 22px;
  margin-bottom: 8px;
}

.doc-intro h1 {
  font-size: clamp(1.5rem, 1.15rem + 1.4vw, 1.875rem);
  line-height: 1.2;
  margin: 0 0 12px;
  overflow-wrap: anywhere;
}

.lede {
  font-size: 17px;
  color: var(--ink-soft);
  margin: 0 0 14px;
}

.doc-meta {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0;
}

.doc-section {
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}

.doc-section:last-child {
  border-bottom: none;
  min-height: calc(100vh - var(--header-h) - 16px);
  min-height: calc(100dvh - var(--header-h) - 16px);
}

/* The last contents target has to reach the reading line under the masthead.
   Without this room, the page ends first and that item never becomes active. */
.doc-section:last-child > .doc-subsection:last-child {
  min-height: calc(100vh - var(--header-h) - 16px);
  min-height: calc(100dvh - var(--header-h) - 16px);
}

.doc-section h2 {
  font-size: clamp(1.2rem, 1.05rem + 0.5vw, 1.3125rem);
  margin: 0 0 10px;
  overflow-wrap: anywhere;
  scroll-margin-top: calc(var(--header-h) + 16px);
}

.doc-section > p {
  color: var(--ink-soft);
  margin: 0 0 14px;
}

/* Field lists */
.fields {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.fields li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}

.fields li:last-child {
  border-bottom: none;
}

.field-label {
  flex: 0 0 190px;
  font-weight: 600;
  color: var(--ink);
  font-size: 14px;
}

.field-value {
  flex: 1;
  min-width: 180px;
  color: var(--ink-soft);
  font-size: 14px;
}

.field-value.todo,
.todo {
  color: var(--todo);
}

/* Checklists */
.checklist {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.checklist li {
  position: relative;
  padding: 8px 12px 8px 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14.5px;
  color: var(--ink-soft);
}

.checklist li::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 12px;
  height: 12px;
  border: 2px solid var(--line-strong);
  border-radius: 4px;
}

p.note {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--todo);
  background: var(--todo-bg);
  padding: 3px 10px;
  border-radius: 999px;
  margin: 4px 0 0;
}

/* Footer */
.site-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.site-footer p {
  margin: 0 0 4px;
}

.disclaimer {
  font-size: 12px;
}

/* Back to top */
.back-to-top {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 30;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(29, 78, 216, 0.35);
  text-decoration: none;
}

.back-to-top:link,
.back-to-top:visited,
.back-to-top:hover,
.back-to-top:active {
  color: #fff;
  text-decoration: none;
}

.back-to-top[hidden] {
  display: none;
}

/* Callouts */
.callout {
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 14px 16px;
  margin: 14px 0;
  background: var(--panel);
}

.callout .callout-label {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}

.callout p {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--ink-soft);
}

.callout p:last-child {
  margin-bottom: 0;
}

.callout ol {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-soft);
}

.callout.ok ol li::marker {
  font-weight: 600;
  color: var(--ink-soft);
}

.callout.ok {
  border-color: #bbf7d0;
  border-left-color: #15803d;
  background: #f0fdf4;
}
.callout.ok .callout-label {
  color: #15803d;
}

.callout.warn {
  border-color: #fde68a;
  border-left-color: #b45309;
  background: #fffbeb;
}
.callout.warn .callout-label {
  color: #b45309;
}

.callout.info {
  border-color: #bfdbfe;
  border-left-color: var(--accent);
  background: #eff6ff;
}
.callout.info .callout-label {
  color: var(--accent);
}

.doc-section .callout a:link,
.doc-section .callout a:visited,
.doc-section .callout a:hover,
.doc-section .callout a:active,
.callout a:link,
.callout a:visited,
.callout a:hover,
.callout a:active {
  color: var(--ink-soft);
  text-decoration-color: var(--ink-soft);
}

/* Data tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  font-size: 13.5px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  vertical-align: top;
}

.data-table th {
  background: #f1f5f9;
  font-weight: 600;
}

/* A wide table scrolls inside the page at every window size. */
.table-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.shares-table {
  width: max-content;
  min-width: 100%;
}

.roles-table th,
.shares-table th,
.roles-table td:nth-child(-n+2),
.shares-table td:nth-child(1),
.shares-table td:nth-child(3) {
  white-space: nowrap;
}

.roles-table th:nth-child(-n+2),
.roles-table td:nth-child(-n+2),
.shares-table th:nth-child(1),
.shares-table th:nth-child(3),
.shares-table td:nth-child(1),
.shares-table td:nth-child(3) {
  width: 1%;
}

.shares-table .rights {
  margin: 0;
  padding-left: 1.15rem;
}

.shares-table .rights li {
  white-space: nowrap;
}

.shares-table .rights li + li {
  margin-top: 0.2rem;
}

.status-ok {
  color: #15803d;
  font-weight: 700;
}

.status-warn {
  color: #b45309;
  font-weight: 700;
}

/* Contract template */
.template {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #0f172a;
  color: #e2e8f0;
  padding: 16px 18px;
  overflow-x: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  white-space: pre-wrap;
}

/* Sub-headings and refs */
.doc-section h3 {
  font-size: 16px;
  margin: 18px 0 8px;
}

.subtle-ref {
  font-size: 12.5px;
  color: var(--muted);
}

.doc-section a {
  color: var(--accent);
}

/* Responsive */
@media (max-width: 860px) {
  .nav-toggle {
    display: flex;
  }

  .nav-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 44;
    margin: 0;
    padding: 0;
    border: 0;
    appearance: none;
    background: rgba(15, 23, 42, 0.45);
    cursor: pointer;
    touch-action: none;
  }

  body.nav-open {
    overflow: hidden;
  }

  .layout,
  .content,
  .doc-section,
  .doc-subsection {
    min-width: 0;
  }

  .table-scroll {
    overflow-x: auto;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
  }

  /* Keep each table wide enough to read, and scroll it inside the page
     so the phone does not zoom out to fit the table. */
  .table-scroll > .data-table {
    width: max-content;
    min-width: 100%;
  }

  .roles-table th:nth-child(3),
  .roles-table td:nth-child(3),
  #compliance-review .data-table th,
  #compliance-review .data-table td {
    max-width: 18rem;
  }

  #compliance-review .data-table th:nth-child(3),
  #compliance-review .data-table td:nth-child(3) {
    max-width: none;
    white-space: nowrap;
  }

  .layout {
    display: block;
    padding: 0;
  }

  .sidebar {
    position: fixed;
    top: var(--header-h);
    left: calc(min(84vw, var(--sidebar-w)) * -1);
    bottom: auto;
    width: min(84vw, var(--sidebar-w));
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 12px 12px 28px;
    transform: none;
    transition: left 0.22s ease;
    z-index: 45;
    box-shadow: 6px 0 24px rgba(15, 23, 42, 0.12);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.is-open {
    left: 0;
    transform: none;
  }

  .content {
    max-width: none;
    padding: 20px max(20px, env(safe-area-inset-right)) 32px max(20px, env(safe-area-inset-left));
  }

  .nav-toggle {
    width: 44px;
    height: 44px;
  }

  .toc-list a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .sidebar {
    padding-bottom: max(28px, env(safe-area-inset-bottom));
  }
}

/* A laptop-width window still shows the contents beside the article,
   with a narrower list so the article keeps a readable measure. */
@media (min-width: 861px) and (max-width: 1100px) {
  :root {
    --sidebar-w: 248px;
  }

  .layout {
    gap: 24px;
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .sidebar {
    transition: none;
  }
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.masthead :focus-visible {
  outline-color: #f8fafc;
}
