:root {
  --red: #c8392f;
  --red-dark: #a62b22;
  --red-light: #e08574;
  --blue: #2c7da0;
  --blue-light: #d8eaf2;
  --bg: #fefcfb;
  --bg-soft: #faf3f1;
  --paper: #ffffff;
  --ink: #1a1414;
  --muted: #6b5e5b;
  --line: rgba(200, 57, 47, 0.12);
  --line-soft: rgba(0, 0, 0, 0.08);
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 20px 40px rgba(200, 57, 47, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; }

/* === TOPBAR === */
/* === FLOATING ACTION BUTTONS === */
.fab {
  position: fixed;
  z-index: 50;
  left: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(26, 20, 20, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(26, 20, 20, 0.22);
  transition: transform 0.2s, background 0.2s, border-color 0.2s;
}
.fab:hover { background: var(--red); border-color: var(--red); transform: translateY(-1px); }
.fab:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

.fab-back  { top: 18px; }
.fab-toc   { top: 74px; }

/* === TOC DRAWER === */
.toc-drawer {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
}
.toc-drawer.is-open { pointer-events: auto; }
.toc-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 20, 20, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.toc-drawer.is-open .toc-backdrop { opacity: 1; }
.toc-panel {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(380px, 86vw);
  background: #fff;
  box-shadow: -16px 0 40px rgba(26, 20, 20, 0.18);
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.toc-drawer.is-open .toc-panel { transform: translateX(0); }
.toc-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: #fff;
}
.toc-panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--red);
}
.toc-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.toc-close:hover { background: var(--bg-soft); color: var(--red); }
.toc-drawer-list {
  list-style: none;
  margin: 0;
  padding: 12px 0;
  counter-reset: none;
}
.toc-drawer-list ol {
  list-style: none;
  margin: 4px 0 8px;
  padding: 0 0 0 18px;
}
.toc-drawer-list li { margin: 0; }
.toc-drawer-list a {
  display: flex;
  gap: 12px;
  padding: 10px 24px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}
.toc-drawer-list a:hover {
  background: var(--bg-soft);
  color: var(--red);
  border-left-color: var(--red);
}
.toc-drawer-list .toc-num {
  flex: 0 0 36px;
  color: var(--red);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.toc-drawer-list ol .toc-num { color: var(--muted); font-weight: 700; }

@media print {
  .fab, .toc-drawer { display: none !important; }
}

/* === DOCUMENT === */
.doc {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 32px 60px;
}

/* === COVER === */
.cover {
  padding: 80px 0 64px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.cover-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--red);
  background: rgba(200, 57, 47, 0.08);
  padding: 6px 14px;
  border-radius: 99px;
  margin-bottom: 28px;
}
.cover-title {
  font-size: clamp(30px, 4.2vw, 44px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 24px;
  color: var(--ink);
}
.cover-lede {
  max-width: 640px;
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.55;
  color: var(--muted);
}
.cover-version {
  font-size: 16px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 36px;
}
.cover-meta {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 36px;
  background: var(--bg-soft);
  padding: 18px 28px;
  border-radius: 12px;
}
.meta-row {
  display: flex;
  gap: 14px;
  font-size: 13px;
  align-items: baseline;
  justify-content: space-between;
}
.meta-label {
  color: var(--muted);
  font-weight: 500;
}
.meta-value {
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}
.cover-client {
  margin-bottom: 28px;
}
.client-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.client-org {
  font-size: 14px;
  color: var(--muted);
  font-weight: 500;
}
.cover-date {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

/* === SUMÁRIO === */
.toc {
  padding: 52px 0;
  border-bottom: 1px solid var(--line);
}
.section-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 20px;
}
.toc h2 { font-size: 12px; }
.toc-list {
  list-style: none;
  padding: 0;
}
.toc-list ol {
  list-style: none;
  padding-left: 22px;
  margin: 4px 0;
}
.toc-list li {
  margin-bottom: 6px;
}
.toc-list a {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 6px 0;
  font-size: 14px;
  color: var(--ink);
  border-bottom: 1px dotted transparent;
  transition: all 0.15s;
}
.toc-list a:hover {
  color: var(--red);
  border-bottom-color: var(--red);
}
.toc-num {
  font-weight: 800;
  color: var(--red);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
}
.toc-list ol .toc-num { color: var(--muted); font-weight: 700; }
.toc-list ol ol .toc-num { color: var(--muted); font-weight: 600; }

/* === CHAPTERS === */
.chapter {
  padding: 52px 0;
  border-bottom: 1px solid var(--line);
}
.chapter > h2 {
  font-size: clamp(24px, 3.2vw, 32px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin-bottom: 20px;
  scroll-margin-top: 80px;
}
.chapter > h2 .ch-num {
  color: var(--red);
  font-variant-numeric: tabular-nums;
  margin-right: 8px;
}

.chapter p,
.sub p,
.sub-sub p {
  font-size: 15.5px;
  margin-bottom: 14px;
  color: var(--ink);
  text-align: justify;
}

.bullet {
  list-style: none;
  margin: 14px 0 18px;
  padding: 0;
}
.bullet li {
  position: relative;
  padding: 4px 0 4px 24px;
  font-size: 15px;
  color: var(--ink);
}
.bullet li::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 14px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red);
}

/* === SUB-SECTIONS === */
.sub {
  margin-top: 36px;
}
.sub > h3 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 8px 0 16px;
  color: var(--ink);
  scroll-margin-top: 80px;
}
.sub > h3 .sub-num {
  color: var(--red);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

.sub-sub {
  margin-top: 30px;
  padding-left: 18px;
  border-left: 2px solid var(--line);
}
.sub-sub > h4 {
  font-size: 17px;
  font-weight: 800;
  margin: 4px 0 14px;
  color: var(--ink);
  scroll-margin-top: 80px;
}
.sub-sub > h4 .sub-num {
  color: var(--red);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}

/* === FORMULA CARD === */
.formula-card {
  background: linear-gradient(135deg, #1a1414, #2a201d);
  color: #fff;
  padding: 26px 30px;
  border-radius: 14px;
  margin: 22px 0;
  box-shadow: var(--shadow-lg);
}
.formula-eq {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-align: center;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 16px;
  color: #fff;
}
.formula-eq sub {
  font-size: 0.65em;
  vertical-align: sub;
  color: var(--red-light);
}
.formula-vars {
  list-style: none;
  display: grid;
  gap: 6px;
  font-size: 13.5px;
}
.formula-vars li {
  color: rgba(255, 255, 255, 0.85);
  padding-left: 16px;
  position: relative;
}
.formula-vars li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--red-light);
}
.formula-vars strong {
  color: #fff;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.formula-vars sub {
  color: var(--red-light);
  vertical-align: sub;
  font-size: 0.85em;
}

/* === RIVER DIAGRAM (SVG) === */
.river-diagram {
  margin: 28px 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}
.river-diagram svg {
  display: block;
  width: 100%;
  height: auto;
}
.diagram-divider {
  background: var(--bg-soft);
  padding: 10px 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--red);
  text-align: center;
}
.diagram-summary {
  background: var(--bg-soft);
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 6px;
}
.ds-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px;
  align-items: baseline;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.ds-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--red);
  white-space: nowrap;
}
.ds-value {
  color: var(--ink);
}
.ds-value strong {
  color: var(--red-dark);
  font-weight: 800;
}
.river-diagram figcaption {
  padding: 12px 22px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  text-align: center;
  background: #fff;
}
.river-diagram figcaption strong {
  color: var(--ink);
  font-weight: 700;
}

@media (max-width: 600px) {
  .ds-row { grid-template-columns: 1fr; gap: 2px; }
  .diagram-summary { padding: 14px 16px; }
}

/* === FIGURE === */
.fig {
  margin: 24px 0 12px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg-soft);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.05);
}
.fig img {
  width: 100%;
  display: block;
}
.fig figcaption {
  padding: 12px 18px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
  border-top: 1px solid var(--line);
  background: #fff;
}

/* === CALLOUT === */
.callout {
  background: var(--bg-soft);
  border-left: 4px solid var(--red);
  border-radius: 10px;
  padding: 22px 26px;
  margin: 24px 0;
}
.callout.warn {
  background: #fef7f4;
  border-color: #d97706;
}
.callout h5 {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #d97706;
  margin-bottom: 12px;
}
.callout p {
  font-size: 14.5px;
  margin-bottom: 10px;
  color: var(--ink);
}
.callout p:last-child { margin-bottom: 0; }

/* === REGIONS GRID === */
.regions-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 22px 0;
}
.region {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.region h5 {
  font-size: 16px;
  font-weight: 800;
  color: var(--red);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}
.region p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.55;
  text-align: left;
  margin-bottom: 0;
}

/* === DATA CARDS === */
.data-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 22px 0;
}
.data-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.data-card h5 {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--red);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.data-card .bullet {
  margin: 0;
}
.data-card .bullet li { font-size: 13.5px; }

/* === SIGNATURES === */
.signatures {
  padding: 60px 0;
  border-top: 1px solid var(--line);
}
.sig-place {
  font-size: 14px;
  text-align: center;
  margin-bottom: 56px;
  color: var(--ink);
  font-weight: 500;
}
.sig-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}
.sig {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sig-line {
  display: block;
  border-top: 1px solid var(--ink);
  margin: 0 auto 12px;
  width: 80%;
  max-width: 280px;
}
.sig strong {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}
.sig-role {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}

/* === ANNEX === */
.annex {
  padding: 52px 0 32px;
  border-top: 1px solid var(--line);
}
.annex h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
  letter-spacing: -0.01em;
}
.annex-note {
  font-size: 14px;
  color: var(--muted);
  font-style: italic;
}

/* === FOOTER === */
.site-footer {
  text-align: center;
  padding: 32px 24px 40px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
}
.site-footer a { color: var(--ink); transition: color 0.2s; }
.site-footer a:hover { color: var(--red); }

/* === RESPONSIVE === */
@media (max-width: 800px) {
  .topbar { padding: 12px 16px; grid-template-columns: auto 1fr auto; }
  .brand { height: 24px; justify-self: center; }
  .print-btn span, .back span { display: none; }
  .doc { padding: 0 20px 40px; }
  .cover { padding: 50px 0 40px; }
  .toc, .chapter, .signatures, .annex { padding: 36px 0; }
  .chapter p, .sub p, .sub-sub p { text-align: left; font-size: 15px; }
  .formula-eq { font-size: 18px; padding: 10px 0; }
  .regions-grid, .data-cards { grid-template-columns: 1fr; }
  .sig-grid { grid-template-columns: 1fr; gap: 36px; }
  .sub-sub { padding-left: 12px; }
}

/* === PRINT === */
@media print {
  body { background: #fff; color: #000; }
  .topbar, .site-footer { display: none; }
  .doc { max-width: none; padding: 0 12mm; }
  .cover { padding: 30mm 0; page-break-after: always; }
  .toc { page-break-after: always; }
  .chapter { page-break-inside: avoid; }
  .sub-sub, .formula-card, .fig, .callout { page-break-inside: avoid; }
  .formula-card { background: #fafafa; color: #000; box-shadow: none; border: 1px solid #ddd; }
  .formula-card .formula-eq { color: #000; border-color: #ccc; }
  .formula-card .formula-vars li { color: #333; }
  .formula-card .formula-vars strong { color: #000; }
  .signatures { page-break-before: always; }
  a { color: inherit; text-decoration: none; }
}
