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

:root {
  --bg: #0d0d0f;
  --bg2: #13131a;
  --bg3: #1a1a24;
  --border: rgba(255, 152, 0, 0.12);
  --border-light: rgba(255, 255, 255, 0.07);
  --amber: #ff9800;
  --amber-dim: #e65100;
  --amber-glow: rgba(255, 152, 0, 0.15);
  --cyan: #00e5ff;
  --cyan-dim: rgba(0, 229, 255, 0.12);
  --text: #e8e8ec;
  --text-mid: #9898ab;
  --text-dim: #5a5a72;
  --sidebar-w: 280px;
  --topbar-h: 56px;
  --radius: 10px;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Manrope', sans-serif;
  font-size: 15px;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.sidebar-open {
  overflow: hidden;
}

/* ── TOPBAR ── */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-h);
  background: rgba(13, 13, 15, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 200;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.topbar-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--amber);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  opacity: 0.85;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.topbar-back:hover {
  opacity: 1;
}

.topbar-sep {
  color: var(--text-dim);
  font-size: 13px;
}

.topbar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-mid);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-badge {
  background: var(--amber-glow);
  border: 1px solid rgba(255, 152, 0, 0.28);
  color: var(--amber);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border-light);
  color: var(--text-mid);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

/* ── LAYOUT ── */
.layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: var(--topbar-h) 0 0 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 140;
}

.sidebar-backdrop.open {
  display: block;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: calc(100vh - var(--topbar-h));
  background: var(--bg2);
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  flex-shrink: 0;
  padding: 28px 0 40px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-section {
  padding: 0 20px;
  margin-bottom: 6px;
}

.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  padding: 10px 4px 6px;
  display: block;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-radius: 7px;
  color: var(--text-mid);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  line-height: 1.35;
}

.sidebar nav a:hover {
  background: var(--amber-glow);
  color: var(--text);
}

.sidebar nav a.active {
  background: var(--amber-glow);
  color: var(--amber);
  font-weight: 600;
}

.sidebar nav a .nav-icon {
  font-size: 15px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.sidebar-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 12px 20px;
}

/* ── MAIN ── */
.main {
  flex: 1;
  min-width: 0;
  padding: 48px 56px 80px;
  max-width: 900px;
}

/* ── CHAPTERS ── */
.chapter {
  margin-bottom: 80px;
  scroll-margin-top: calc(var(--topbar-h) + 24px);
}

.chapter-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 10px;
  display: block;
}

.chapter h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 18px;
}

.chapter-lead {
  font-size: 16px;
  color: var(--text-mid);
  margin-bottom: 32px;
  max-width: 680px;
  line-height: 1.75;
}

/* ── SECTION WITHIN CHAPTER ── */
.section {
  margin-bottom: 40px;
}

.section h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #dde0ff;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section h3 .h3-tag {
  font-size: 11px;
  font-weight: 600;
  background: var(--cyan-dim);
  color: var(--cyan);
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.section h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--amber);
  margin: 20px 0 8px;
  letter-spacing: 0.01em;
}

p {
  color: var(--text);
  margin-bottom: 14px;
}

/* ── CARDS ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: rgba(255, 152, 0, 0.32);
}

.card-icon {
  font-size: 22px;
  margin-bottom: 10px;
  display: block;
}

.card h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #fff;
}

.card p {
  font-size: 13px;
  color: var(--text-mid);
  margin: 0;
}

/* ── MODULE CARDS ── */
.module-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

.module-card:hover {
  border-color: rgba(255, 152, 0, 0.32);
}

.module-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--cyan);
  background: var(--cyan-dim);
  display: inline-block;
  padding: 3px 10px;
  border-radius: 5px;
  margin-bottom: 10px;
}

.module-card h4 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #fff;
}

.module-card p {
  font-size: 13px;
  color: var(--text-mid);
  margin: 0 0 12px;
}

.module-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-mid);
}

.tag-amber {
  background: var(--amber-glow);
  color: var(--amber);
}

.tag-cyan {
  background: var(--cyan-dim);
  color: var(--cyan);
}

.tag-green {
  background: rgba(0, 230, 118, 0.1);
  color: #00e676;
}

/* ── PIPELINE ── */
.pipeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 20px 0;
}

.pipeline-step {
  display: flex;
  gap: 20px;
  position: relative;
}

.pipeline-step::before {
  content: '';
  position: absolute;
  left: 19px;
  top: 44px;
  bottom: -1px;
  width: 2px;
  background: linear-gradient(to bottom, var(--amber), transparent);
  opacity: 0.3;
}

.pipeline-step:last-child::before {
  display: none;
}

.step-num {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--amber-glow);
  border: 2px solid rgba(255, 152, 0, 0.4);
  color: var(--amber);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-body {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  flex: 1;
  margin-bottom: 12px;
}

.step-body h4 {
  margin: 0 0 4px;
  font-size: 14px;
  color: #fff;
}

.step-body p {
  margin: 0;
  font-size: 13px;
  color: var(--text-mid);
}

/* ── TABLE ── */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 16px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: rgba(255, 152, 0, 0.08);
  color: var(--amber);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-mid);
  vertical-align: top;
}

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

tbody tr:hover td {
  background: rgba(255, 152, 0, 0.04);
}

/* Tabelas de requisitos: manter IDs íntegros e preservar largura da coluna Nome */
#requisitos table th:first-child,
#requisitos table td:first-child,
#rnf table th:first-child,
#rnf table td:first-child {
  width: 86px;
  min-width: 86px;
  white-space: nowrap;
}

#requisitos table th:nth-child(2),
#requisitos table td:nth-child(2),
#rnf table th:nth-child(2),
#rnf table td:nth-child(2) {
  min-width: 240px;
}

td code,
th code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  background: rgba(0, 229, 255, 0.08);
  color: var(--cyan);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── STATUS BADGES ── */
.badge-impl {
  background: rgba(0, 230, 118, 0.1);
  color: #00e676;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-partial {
  background: rgba(255, 193, 7, 0.12);
  color: #ffc107;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-pending {
  background: rgba(255, 82, 82, 0.1);
  color: #ff5252;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* ── CODE ── */
pre {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 16px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  line-height: 1.65;
  color: #c9d1d9;
  scrollbar-width: thin;
}

pre .kw {
  color: #ff9800;
}

pre .fn {
  color: #00e5ff;
}

pre .str {
  color: #a5d6a7;
}

pre .cm {
  color: #5a5a72;
  font-style: italic;
}

pre .num {
  color: #ce93d8;
}

pre .type {
  color: #80cbc4;
}

code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--cyan);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── CALLOUT ── */
.callout {
  border-left: 3px solid var(--amber);
  background: var(--amber-glow);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 14px 18px;
  margin: 18px 0;
  font-size: 13.5px;
  color: var(--text);
}

.callout.callout-cyan {
  border-left-color: var(--cyan);
  background: var(--cyan-dim);
}

.callout.callout-warn {
  border-left-color: #ffc107;
  background: rgba(255, 193, 7, 0.08);
}

.callout strong {
  color: var(--amber);
}

.callout.callout-cyan strong {
  color: var(--cyan);
}

/* ── STAT GRID ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin: 20px 0;
}

.stat-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
}

.stat-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--amber);
  display: block;
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── COVER ── */
.cover {
  background: linear-gradient(135deg, var(--bg2) 0%, var(--bg3) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 48px 48px 40px;
  margin-bottom: 56px;
  position: relative;
  overflow: hidden;
}

.cover::before {
  content: '';
  position: absolute;
  top: -60px;
  right: -60px;
  width: 240px;
  height: 240px;
  background: radial-gradient(circle, rgba(255, 152, 0, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.cover-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 16px;
  display: block;
}

.cover h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  color: #fff;
  line-height: 1.15;
  margin-bottom: 16px;
}

.cover h1 span {
  background: linear-gradient(90deg, #ff9800, #ffcc80);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.cover-desc {
  font-size: 15px;
  color: var(--text-mid);
  max-width: 560px;
  line-height: 1.75;
  margin-bottom: 28px;
}

.cover-meta {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.cover-meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.cover-meta-item span:first-child {
  color: var(--amber);
}

/* ── TOC ── */
.toc {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 56px;
}

.toc h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: var(--amber);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: none;
  padding: 0;
}

.toc-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 4px 24px;
}

.toc-list li a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--text-mid);
  text-decoration: none;
  font-size: 13px;
  padding: 5px 0;
  transition: color 0.15s;
}

.toc-list li a:hover {
  color: var(--amber);
}

.toc-num {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  flex-shrink: 0;
  width: 24px;
}

/* ── BOUNDARY CARD ── */
.boundary-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 14px;
}

.boundary-card h4 {
  color: var(--amber);
  font-size: 14px;
  margin-bottom: 6px;
}

.boundary-card p {
  font-size: 13px;
  color: var(--text-mid);
  margin: 0;
}

/* ── FOOTER ── */
.mag-footer {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 32px 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.mag-footer p {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0;
}

.mag-footer a {
  color: var(--amber);
  text-decoration: none;
}

.mag-footer a:hover {
  text-decoration: underline;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .main {
    padding: 32px 28px 60px;
  }

  .cover {
    padding: 32px 28px 28px;
  }

  .mag-footer {
    padding: 24px 28px;
  }
}

@media (max-width: 720px) {
  :root {
    --sidebar-w: 0px;
  }

  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: 280px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.28s ease;
    height: calc(100vh - var(--topbar-h));
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    padding: 24px 18px 60px;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cover {
    padding: 24px 20px 20px;
  }

  .toc-list {
    grid-template-columns: 1fr;
  }

  .cover-meta {
    flex-direction: column;
    gap: 10px;
  }

  .chapter {
    margin-bottom: 56px;
  }

  .chapter-lead {
    font-size: 15px;
  }

  pre {
    font-size: 11.5px;
    padding: 14px 14px;
  }

  .topbar {
    padding: 0 12px;
    gap: 8px;
  }

  .topbar-title {
    display: none;
  }

  .topbar-sep {
    display: none;
  }
}

@media (max-width: 520px) {
  .topbar-badge {
    font-size: 10px;
    padding: 2px 8px;
  }

  .topbar-back {
    font-size: 12px;
  }

  .main {
    padding: 20px 14px 52px;
  }

  .cover {
    padding: 20px 14px 16px;
  }

  .section h3 {
    font-size: 16px;
  }

  .topbar-right {
    display: none;
  }
}

/* ── PROGRESS BAR ── */
#progress-bar {
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--amber), var(--cyan));
  z-index: 300;
  width: 0%;
  transition: width 0.1s linear;
}