:root {
  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --accent: #0369a1;
  --accent-bg: #f0f9ff;
  --accent-border: #bae6fd;
  --warn-bg: #fffbeb;
  --warn-border: #fde68a;
  --warn-text: #92400e;
  --del-bg: #fef2f2;
  --del-border: #fecaca;
  --del-text: #991b1b;
  --keep-bg: #f0fdf4;
  --keep-border: #bbf7d0;
  --keep-text: #166534;
  --ext-bg: #f8fafc;
  --ext-border: #cbd5e1;
  --ext-text: #475569;
  --radius: 8px;
  --max-w: 780px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-hover: #1e293b;
    --border: #1e293b;
    --border-strong: #334155;
    --text: #f8fafc;
    --text-body: #cbd5e1;
    --text-muted: #94a3b8;
    --accent: #38bdf8;
    --accent-bg: rgba(56, 189, 248, 0.08);
    --accent-border: rgba(56, 189, 248, 0.25);
    --warn-bg: rgba(245, 158, 11, 0.1);
    --warn-border: rgba(245, 158, 11, 0.3);
    --warn-text: #fcd34d;
    --del-bg: rgba(239, 68, 68, 0.12);
    --del-border: rgba(239, 68, 68, 0.35);
    --del-text: #fca5a5;
    --keep-bg: rgba(34, 197, 94, 0.12);
    --keep-border: rgba(34, 197, 94, 0.3);
    --keep-text: #86efac;
    --ext-bg: #1e293b;
    --ext-border: #334155;
    --ext-text: #cbd5e1;
  }
}

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

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

body {
  background: var(--bg);
  color: var(--text-body);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Top Navigation */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-tag {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav a:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.nav a[aria-current="page"] {
  background: var(--accent-bg);
  color: var(--accent);
  font-weight: 600;
}

/* Main Content */
main {
  flex: 1;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.doc-header {
  padding-bottom: 1.75rem;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

h1 {
  font-size: clamp(1.65rem, 4vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
  margin-bottom: 0.65rem;
}

.meta {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.lead {
  font-size: 1.02rem;
  color: var(--text-body);
  margin-top: 0.85rem;
}

/* Table of Contents */
.toc {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}

.toc-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.toc ol {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.3rem 1.25rem;
  padding: 0;
  margin: 0;
}

.toc a {
  font-size: 0.88rem;
  color: var(--text-body);
  text-decoration: none;
}

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

/* Sections & Typography */
section {
  margin-bottom: 2.25rem;
  scroll-margin-top: 4.5rem;
}

h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

h3 {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.1rem 0 0.4rem;
}

p {
  margin-bottom: 0.75rem;
}

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

ul, ol {
  padding-left: 1.35rem;
  margin: 0.5rem 0 0.9rem;
}

li {
  margin-bottom: 0.4rem;
}

li:last-child {
  margin-bottom: 0;
}

strong {
  color: var(--text);
  font-weight: 600;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

a:hover {
  opacity: 0.85;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.86em;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.1rem 0.38rem;
  border-radius: 4px;
  color: var(--text);
}

/* Callouts */
.callout {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius);
  padding: 0.95rem 1.15rem;
  margin: 1rem 0;
  font-size: 0.94rem;
}

.callout-warn {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  border-radius: var(--radius);
  padding: 0.95rem 1.15rem;
  margin: 1rem 0;
  font-size: 0.94rem;
}

.callout-warn strong {
  color: inherit;
}

/* Hub Cards */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
  margin: 1.5rem 0 2rem;
}

.doc-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.3rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.doc-card:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
  opacity: 1;
}

.doc-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.doc-card-arrow {
  color: var(--accent);
  font-weight: 600;
}

.doc-card-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 0.9rem 0 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

th {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td {
  border-bottom: none;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-del {
  background: var(--del-bg);
  color: var(--del-text);
  border: 1px solid var(--del-border);
}

.badge-keep {
  background: var(--keep-bg);
  color: var(--keep-text);
  border: 1px solid var(--keep-border);
}

.badge-ext {
  background: var(--ext-bg);
  color: var(--ext-text);
  border: 1px solid var(--ext-border);
}

/* Steps */
.steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 0.9rem 0 1.25rem;
}

.step {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1.1rem;
}

.step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.1rem;
}

.step-body h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
}

.step-body p {
  font-size: 0.93rem;
  margin-bottom: 0.3rem;
}

/* Contact & CTA */
.contact-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem 1.3rem;
  margin-top: 0.75rem;
}

.contact-box p {
  margin-bottom: 0.35rem;
  font-size: 0.94rem;
}

.btn {
  display: inline-block;
  margin-top: 0.65rem;
  padding: 0.55rem 1.1rem;
  background: var(--text);
  color: var(--bg);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  transition: opacity 0.15s ease;
}

.btn:hover {
  opacity: 0.88;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.5rem 1.25rem;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.footer-links {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

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

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

@media (max-width: 600px) {
  main {
    padding: 1.75rem 1rem 3rem;
  }
  .toc ol {
    grid-template-columns: 1fr;
  }
  .step {
    gap: 0.7rem;
    padding: 0.85rem 0.95rem;
  }
}

@media print {
  .topbar, .toc, .btn {
    display: none;
  }
  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }
  main {
    padding: 0;
    max-width: 100%;
  }
}
