:root {
  --bg: #0a0e14;
  --bg-elev: #0f141b;
  --bg-card: #131a23;
  --border: #1f2832;
  --border-strong: #2a3744;
  --text: #d6dde6;
  --text-dim: #8b97a8;
  --text-muted: #5e6877;
  --accent: #50fa7b;
  --accent-2: #8be9fd;
  --accent-3: #ffb86c;
  --warn: #ff5555;
  --mid: #f1fa8c;
  --code-bg: #0d1219;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: 2rem;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ────────────────────────────── */
.sidebar {
  width: 260px;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}
.brand-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  color: var(--bg);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 6px;
}
.brand-name {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.sidebar nav {
  flex: 1;
  padding: 0 0.75rem;
}
.sidebar nav a {
  display: block;
  padding: 0.42rem 0.75rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.86rem;
  border-radius: 5px;
  margin: 1px 0;
  transition: all 0.15s;
  border-left: 2px solid transparent;
}
.sidebar nav a:hover {
  color: var(--text);
  background: var(--bg-card);
}
.sidebar nav a.active {
  color: var(--accent);
  background: var(--bg-card);
  border-left-color: var(--accent);
}
.sidebar nav a.primary {
  background: var(--accent);
  color: var(--bg);
  font-weight: 600;
  margin: 0.5rem 0;
  text-align: center;
}
.sidebar nav a.primary:hover {
  background: var(--accent-2);
  color: var(--bg);
}
.nav-section {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 1rem 0.75rem 0.4rem;
  font-weight: 600;
}

.footer-meta {
  padding: 1rem 1.5rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  line-height: 1.5;
}

/* ── Main ──────────────────────────────── */
main {
  margin-left: 260px;
  flex: 1;
  padding: 3rem 4rem;
  max-width: calc(100vw - 260px);
}

section {
  max-width: 920px;
  margin: 0 auto 5rem;
  scroll-margin-top: 2rem;
}

.hero {
  margin-top: 1rem;
  padding-bottom: 3rem;
  border-bottom: 1px solid var(--border);
}
.hero .tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  font-size: 0.72rem;
  color: var(--accent-2);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 1rem;
}
.hero h1 {
  font-size: 2.6rem;
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}
.hero h1 .muted {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.65em;
  display: block;
  margin-top: 0.4rem;
}
.hero .lead {
  font-size: 1.05rem;
  color: var(--text-dim);
  max-width: 780px;
  margin-bottom: 2rem;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 2rem 0;
}
.hero-stats > div {
  padding: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
}
.stat-num {
  font-family: var(--mono);
  font-size: 1.6rem;
  color: var(--accent);
  font-weight: 600;
}
.stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  margin: 1.5rem 0;
}

.btn {
  display: inline-block;
  padding: 0.7rem 1.4rem;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.92rem;
  transition: all 0.15s;
  font-family: var(--mono);
}
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: 1px solid var(--accent);
}
.btn-primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}
.btn-ghost {
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.callout {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-3);
  padding: 1rem 1.25rem;
  margin-top: 1.5rem;
  font-size: 0.92rem;
  color: var(--text-dim);
  border-radius: 0 4px 4px 0;
}
.callout strong { color: var(--accent-3); }
.callout a { color: var(--accent-2); }

/* ── Headings ─────────────────────────── */
h2 {
  font-size: 1.7rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
h2 .num {
  font-family: var(--mono);
  font-size: 0.78em;
  color: var(--accent);
  background: var(--bg-card);
  padding: 0.2em 0.5em;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
}
h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  margin: 1.75rem 0 0.75rem;
}
h4 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent-2);
  margin-bottom: 0.4rem;
}

p { margin: 0.75rem 0; }

/* ── Code ───────────────────────────────── */
code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--code-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--accent-2);
}
pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.1rem 1.25rem;
  margin: 1rem 0;
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.55;
}
pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: inherit;
}
.diagram {
  font-family: var(--mono);
  color: var(--text-dim);
  white-space: pre;
  font-size: 0.78rem;
  line-height: 1.4;
}

.note {
  font-size: 0.88rem;
  color: var(--text-dim);
  background: var(--bg-card);
  border-left: 3px solid var(--accent-2);
  padding: 0.75rem 1rem;
  margin: 1rem 0;
  border-radius: 0 4px 4px 0;
}
.note strong { color: var(--accent-2); }

.ref {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  margin-left: 0.4rem;
}

ul, ol { padding-left: 1.5rem; margin: 0.75rem 0; }
li { margin: 0.35rem 0; }
.findings li { margin: 0.55rem 0; }

/* ── Tables ─────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
th, td {
  padding: 0.6rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  background: var(--bg-card);
  color: var(--accent-2);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tr:last-child td { border-bottom: none; }

.risk-high { color: var(--warn); font-weight: 600; }
.risk-mid { color: var(--mid); font-weight: 600; }
.risk-low { color: var(--accent); font-weight: 600; }

.muted { color: var(--text-muted); font-size: 0.84em; }

.step-table { font-size: 0.83rem; }
.step-table code { font-size: 0.85em; }

.creds td:first-child {
  color: var(--text-muted);
  font-weight: 600;
  width: 32%;
}
.creds td:nth-child(2) {
  font-family: var(--mono);
  font-size: 0.85em;
}
.creds a { color: var(--accent); }

.refs td:first-child { width: 38%; }
.refs code { font-size: 0.8rem; }

/* ── Cards ──────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.25rem 0;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin: 1rem 0;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1rem 1.1rem;
}
.card.sm {
  font-size: 0.8rem;
  padding: 0.7rem 0.85rem;
  line-height: 1.45;
}
.card.sm strong {
  color: var(--accent-2);
  font-family: var(--mono);
  font-size: 0.95em;
}

/* ── Compare ────────────────────────────── */
.compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1.25rem 0;
}
.compare > div {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
}
.compare h3 {
  margin-top: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-family: var(--mono);
  font-weight: 600;
  text-transform: uppercase;
}
.badge-default {
  background: var(--accent);
  color: var(--bg);
}
.badge-alt {
  background: var(--bg);
  color: var(--accent-2);
  border: 1px solid var(--accent-2);
}
.compare ul { font-size: 0.86rem; }

/* ── Footer ─────────────────────────────── */
footer {
  margin-top: 4rem;
  padding: 2rem 0 4rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-dim);
}
footer .muted { display: block; margin-top: 0.5rem; }
footer code { font-size: 0.78rem; }

/* ── Mobile ─────────────────────────────── */
@media (max-width: 980px) {
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  body { flex-direction: column; }
  main {
    margin-left: 0;
    padding: 2rem 1.25rem;
    max-width: 100vw;
  }
  .hero h1 { font-size: 1.9rem; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .compare { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .diagram { font-size: 0.62rem; }
}
