@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=DM+Sans:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg-deep: #060B14;
  --bg-primary: #0A1628;
  --bg-secondary: #0F1E36;
  --bg-card: #132644;
  --bg-card-hover: #1A3358;
  --accent-gold: #C8A55C;
  --accent-gold-light: #E8CC7A;
  --accent-gold-dim: #8B7340;
  --text-primary: #E8E8E8;
  --text-secondary: #9BA8BE;
  --text-muted: #5C6B82;
  --border: rgba(200,165,92,0.15);
  --border-strong: rgba(200,165,92,0.3);
  --glow: rgba(200,165,92,0.08);
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'DM Sans', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --success: #4ADE80;
  --warning: #FBBF24;
  --danger: #F87171;
  --info: #60A5FA;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.7;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
}

/* ═══════ SIDEBAR ═══════ */
.sidebar {
  position: fixed;
  left: 0; top: 0;
  width: 300px;
  height: 100vh;
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.4s cubic-bezier(0.16,1,0.3,1);
}

.sidebar-header {
  padding: 32px 28px 24px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.logo-mark {
  width: 40px; height: 40px;
  border: 2px solid var(--accent-gold);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: var(--accent-gold);
  background: rgba(200,165,92,0.06);
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.logo-sub {
  font-family: var(--font-body);
  font-size: 10px;
  font-weight: 500;
  color: var(--accent-gold-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-gold-dim);
  padding: 16px 28px 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 28px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: all 0.25s ease;
  border-left: 2px solid transparent;
}

.nav-link:hover {
  color: var(--text-primary);
  background: var(--glow);
  border-left-color: var(--accent-gold-dim);
}

.nav-link.active {
  color: var(--accent-gold);
  background: rgba(200,165,92,0.06);
  border-left-color: var(--accent-gold);
  font-weight: 500;
}

.nav-num {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  min-width: 22px;
}

.sidebar-footer {
  padding: 20px 28px;
  border-top: 1px solid var(--border);
}

.sidebar-footer span {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

/* ═══════ MAIN ═══════ */
.main {
  margin-left: 300px;
  min-height: 100vh;
}

/* ═══════ PAGE HEADER ═══════ */
.page-header {
  padding: 80px 60px 48px;
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.page-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 30% 0%, rgba(200,165,92,0.04) 0%, transparent 60%),
    linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-deep) 100%);
}

.page-header > * { position: relative; z-index: 1; }

.page-header .breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.page-header .breadcrumb a {
  color: var(--accent-gold-dim);
  text-decoration: none;
}

.page-header .breadcrumb a:hover {
  color: var(--accent-gold);
}

.page-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent-gold-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.page-title {
  font-family: var(--font-display);
  font-size: clamp(32px, 4vw, 48px);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  line-height: 1.15;
}

.page-subtitle {
  font-size: 17px;
  color: var(--text-secondary);
  max-width: 700px;
  line-height: 1.7;
}

/* ═══════ CONTENT ═══════ */
.content {
  padding: 48px 60px 120px;
  max-width: 960px;
}

.content h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 56px 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.content h2:first-child { margin-top: 0; }

.content h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--accent-gold-light);
  margin: 36px 0 14px;
}

.content h4 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 24px 0 10px;
  letter-spacing: 0.02em;
}

.content p {
  margin-bottom: 16px;
  color: var(--text-secondary);
  font-size: 15px;
}

.content strong { color: var(--text-primary); }

.content ul, .content ol {
  margin: 0 0 20px 20px;
  color: var(--text-secondary);
  font-size: 15px;
}

.content li { margin-bottom: 6px; }

.content blockquote {
  border-left: 3px solid var(--accent-gold);
  padding: 16px 24px;
  margin: 24px 0;
  background: rgba(200,165,92,0.04);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--accent-gold-light);
  font-family: var(--font-display);
  font-size: 17px;
}

/* ═══════ TABLES ═══════ */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0 28px;
  font-size: 13.5px;
}

.content thead th {
  background: var(--bg-card);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-gold);
  border-bottom: 2px solid var(--accent-gold-dim);
}

.content tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}

.content tbody tr:hover td {
  background: rgba(200,165,92,0.03);
}

.content tbody td strong {
  color: var(--text-primary);
}

/* ═══════ DIAGRAM BOXES ═══════ */
.diagram {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin: 24px 0;
  overflow-x: auto;
}

.diagram pre {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre;
  margin: 0;
}

.diagram-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-gold-dim);
  margin-bottom: 16px;
}

/* ═══════ FLOW CARDS ═══════ */
.flow {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 24px 0;
}

.flow-step {
  display: flex;
  align-items: stretch;
  gap: 20px;
}

.flow-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 32px;
  flex-shrink: 0;
}

.flow-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent-gold);
  border: 3px solid var(--bg-deep);
  box-shadow: 0 0 0 2px var(--accent-gold-dim);
  flex-shrink: 0;
  margin-top: 16px;
}

.flow-line {
  width: 2px;
  flex: 1;
  background: var(--border-strong);
}

.flow-content {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 4px 0;
}

.flow-content h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.flow-content p {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0;
}

/* ═══════ INFO BOXES ═══════ */
.info-box {
  border-radius: 10px;
  padding: 20px 24px;
  margin: 20px 0;
  border: 1px solid;
}

.info-box.gold {
  background: rgba(200,165,92,0.06);
  border-color: rgba(200,165,92,0.2);
}

.info-box.blue {
  background: rgba(96,165,250,0.06);
  border-color: rgba(96,165,250,0.2);
}

.info-box.red {
  background: rgba(248,113,113,0.06);
  border-color: rgba(248,113,113,0.2);
}

.info-box.green {
  background: rgba(74,222,128,0.06);
  border-color: rgba(74,222,128,0.2);
}

.info-box-title {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.info-box.gold .info-box-title { color: var(--accent-gold); }
.info-box.blue .info-box-title { color: var(--info); }
.info-box.red .info-box-title { color: var(--danger); }
.info-box.green .info-box-title { color: var(--success); }

/* ═══════ METRIC CARDS ═══════ */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  text-align: center;
}

.metric-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-gold);
  line-height: 1;
  margin-bottom: 6px;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 500;
}

/* ═══════ CODE / JSON ═══════ */
.code-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px 24px;
  margin: 20px 0;
  overflow-x: auto;
}

.code-block code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-secondary);
}

.code-block .key { color: var(--accent-gold-light); }
.code-block .string { color: var(--success); }
.code-block .number { color: var(--info); }

/* ═══════ NAV FOOTER ═══════ */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 48px 60px;
  border-top: 1px solid var(--border);
}

.page-nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 24px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.3s ease;
  min-width: 200px;
}

.page-nav a:hover {
  border-color: var(--border-strong);
  background: var(--bg-card);
  transform: translateY(-2px);
}

.page-nav .nav-dir {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent-gold-dim);
}

.page-nav .nav-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.page-nav a.next { text-align: right; margin-left: auto; }

/* ═══════ PDF BAR ═══════ */
.pdf-bar {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
}

.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent-gold-dim));
  color: var(--bg-deep);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.pdf-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(200,165,92,0.3);
}

/* ═══════ FOOTER ═══════ */
.page-footer {
  padding: 32px 60px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ═══════ MOBILE TOGGLE ═══════ */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px; left: 16px;
  z-index: 200;
  width: 44px; height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--accent-gold);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ═══════ TOC ═══════ */
.toc {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px 28px;
  margin: 0 0 40px;
}

.toc-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent-gold-dim);
  margin-bottom: 14px;
}

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

.toc li {
  counter-increment: toc-counter;
  margin-bottom: 4px;
}

.toc li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: color 0.2s;
}

.toc li a:hover { color: var(--accent-gold); }

.toc li a::before {
  content: counter(toc-counter, decimal-leading-zero);
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  min-width: 20px;
}

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 900px) {
  .mobile-toggle { display: flex; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .page-header { padding: 60px 24px 36px; }
  .content { padding: 36px 24px 80px; }
  .page-nav { padding: 36px 24px; flex-direction: column; }
  .page-nav a.next { text-align: left; }
  .page-footer { flex-direction: column; gap: 8px; padding: 24px; }
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ═══════ PRINT ═══════ */
@media print {
  .sidebar, .mobile-toggle, .pdf-bar { display: none !important; }
  .main { margin-left: 0 !important; }
  body { background: white; color: #1a1a1a; }
  body::before { display: none; }
  .page-header { padding: 40px 30px 24px; }
  .page-header::before { display: none; }
  .content { padding: 24px 30px 40px; max-width: none; }
  .page-title, .content h2, .content h3 { color: #0A1628; }
  .page-subtitle, .content p, .content td { color: #333; }
  .content h2 { border-color: #ddd; }
  .content thead th { background: #f0f0f0; color: #0A1628; border-color: #8B7340; }
  .content tbody td { border-color: #ddd; }
  .diagram { background: #f8f8f8; border-color: #ddd; }
  .diagram pre { color: #333; }
  .toc { background: #f8f8f8; border-color: #ddd; }
  .info-box { break-inside: avoid; }
  .page-nav { display: none; }
  .metric-card { background: #f5f5f5; border-color: #ddd; }
  .metric-value { color: #8B7340; }
  blockquote { color: #8B7340; }
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--bg-card); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-card-hover); }
