:root {
  --ink: #12201d;
  --muted: #5d6e69;
  --paper: #f6f8f5;
  --surface: #ffffff;
  --line: #dce4df;
  --green: #15745b;
  --green-dark: #0d5845;
  --green-soft: #e5f4ee;
  --blue-soft: #eaf1fc;
  --amber: #a65c08;
  --amber-soft: #fff3dc;
  --red: #a63b3b;
  --red-soft: #ffebeb;
  --navy: #10231f;
  --shadow: 0 16px 44px rgba(16, 35, 31, .08);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
a { color: var(--green-dark); }
.skip-link { position: fixed; top: -50px; left: 16px; z-index: 100; padding: 10px 16px; background: white; }
.skip-link:focus { top: 10px; }

.topbar {
  position: sticky; top: 0; z-index: 20; height: 72px; padding: 0 28px;
  display: flex; align-items: center; gap: 28px; color: white; background: var(--navy);
  box-shadow: 0 4px 24px rgba(0,0,0,.13);
}
.brand { display: flex; align-items: center; gap: 11px; color: white; text-decoration: none; min-width: 210px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border: 1px solid #83bdaa; border-radius: 11px; color: #b8ead9; font-weight: 800; }
.brand strong, .brand small { display: block; line-height: 1.15; }
.brand small { color: #b8c9c3; font-size: 12px; margin-top: 3px; }
.topnav { display: flex; gap: 5px; flex: 1; }
.topnav a { padding: 8px 11px; border-radius: 9px; color: #cad7d3; text-decoration: none; font-size: 14px; }
.topnav a:hover, .topnav a.active { color: white; background: rgba(255,255,255,.09); }
.header-progress { width: 145px; font-size: 12px; color: #d7e4df; }
.header-progress > span { float: right; margin-bottom: 4px; }
.progress-track { clear: both; height: 7px; overflow: hidden; border-radius: 10px; background: rgba(255,255,255,.15); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: #53d4a7; transition: width .35s ease; }
.menu-toggle { display: none; color: white; background: transparent; border: 0; font-size: 24px; }

.app-shell { display: grid; grid-template-columns: 268px minmax(0, 1fr); min-height: calc(100vh - 72px); }
.sidebar { position: sticky; top: 72px; align-self: start; height: calc(100vh - 72px); overflow: auto; padding: 22px 16px; border-right: 1px solid var(--line); background: #fbfcfa; }
.sidebar-heading { display: flex; justify-content: space-between; padding: 0 8px 14px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .07em; }
.sidebar-heading strong { color: var(--green); }
.module-link { display: grid; grid-template-columns: 28px 1fr 8px; align-items: center; gap: 9px; margin: 3px 0; padding: 10px 9px; color: #3e504b; text-decoration: none; border-radius: 11px; font-size: 13px; line-height: 1.35; }
.module-link:hover, .module-link.active { background: var(--green-soft); color: var(--green-dark); }
.module-number { display: grid; place-items: center; width: 27px; height: 27px; border-radius: 8px; background: #edf1ee; font-size: 12px; font-weight: 700; }
.module-link.done .module-number { color: white; background: var(--green); }
.state-dot { width: 7px; height: 7px; border-radius: 50%; background: #c7cfcb; }
.module-link.started .state-dot { background: #e89c3a; }
.module-link.done .state-dot { background: #28a47b; }
.module-link.locked { color: #87928e; cursor: not-allowed; }
.module-link.locked:hover { color: #87928e; background: #f0f2f1; }
.module-link.locked .module-number { font-size: 11px; background: #e4e8e6; }
.module-link.locked .state-dot { background: #aeb7b3; }
.sidebar .btn { width: 100%; margin-top: 18px; }

main { width: 100%; min-width: 0; }
.page { max-width: 1180px; margin: 0 auto; padding: 52px 48px 90px; }
.page.narrow { max-width: 920px; }
.eyebrow { display: inline-block; color: var(--green); font-size: 13px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, h3, h4 { margin: 0 0 .55em; line-height: 1.18; letter-spacing: -.025em; }
h1 { font-size: clamp(38px, 6vw, 68px); max-width: 850px; }
h2 { margin-top: 1.8em; font-size: clamp(27px, 3vw, 38px); }
h3 { margin-top: 1.6em; font-size: 22px; }
h4 { margin-top: 1.35em; font-size: 17px; }
p { margin: 0 0 1em; }
.lead { max-width: 820px; color: #4d615b; font-size: clamp(18px, 2vw, 22px); }
.hero { position: relative; overflow: hidden; min-height: 470px; padding: 68px; color: white; background: linear-gradient(125deg, #10231f 0%, #153e33 68%, #1b654f 100%); border-radius: 28px; box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; right: -80px; bottom: -130px; width: 430px; height: 430px; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; box-shadow: 0 0 0 50px rgba(255,255,255,.03), 0 0 0 100px rgba(255,255,255,.025); }
.hero .eyebrow { color: #73dbb7; }
.hero h1 { position: relative; z-index: 1; }
.hero .lead { position: relative; z-index: 1; color: #d5e5df; }
.hero-actions, .action-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.meta-row { display: flex; flex-wrap: wrap; gap: 20px; margin-top: 34px; color: #c8d7d2; font-size: 14px; }
.meta-row span { padding-right: 20px; border-right: 1px solid rgba(255,255,255,.2); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border: 1px solid transparent; border-radius: 11px; cursor: pointer; text-decoration: none; font-weight: 750; transition: transform .15s, background .15s; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { color: white; background: var(--green); }
.btn-primary:hover { background: var(--green-dark); }
.hero .btn-primary { color: var(--navy); background: #75dfba; }
.btn-secondary { color: var(--green-dark); border-color: #b7cec5; background: white; }
.btn-ghost { color: var(--muted); border-color: var(--line); background: transparent; }
.btn-danger { color: var(--red); border-color: #efb7b7; background: white; }
.btn-small { padding: 8px 11px; font-size: 13px; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { padding: 27px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: 0 5px 24px rgba(16,35,31,.035); }
.card h3 { margin-top: 0; }
.stat { font-size: 35px; font-weight: 850; color: var(--green); }
.muted { color: var(--muted); }
.section-intro { max-width: 760px; color: var(--muted); }

.global-progress-card { margin: 28px 0 4px; padding: 25px; border-radius: var(--radius); background: white; border: 1px solid var(--line); }
.global-progress-card .progress-track { height: 12px; background: #e5ebe7; }
.global-progress-card .progress-track span { background: linear-gradient(90deg, var(--green), #4dc99f); }
.progress-labels { display: flex; justify-content: space-between; margin-bottom: 9px; font-weight: 700; }

.route-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 25px; }
.module-card { position: relative; display: flex; flex-direction: column; min-height: 330px; }
.module-card.locked { background: #f3f5f4; }
.module-card.locked .number, .module-card.locked h3, .module-card.locked .objectives { opacity: .62; }
.module-card.locked .btn { cursor: not-allowed; }
.module-card .number { color: #c4d1cc; font-size: 44px; font-weight: 900; line-height: 1; }
.module-card h3 { min-height: 54px; margin-top: 12px; }
.module-card .objectives { flex: 1; color: var(--muted); font-size: 14px; }
.module-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.badges { display: flex; flex-wrap: wrap; gap: 7px; }
.badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 100px; color: #53645f; background: #edf1ef; font-size: 12px; font-weight: 700; }
.badge.green { color: var(--green-dark); background: var(--green-soft); }
.badge.amber { color: #81500e; background: var(--amber-soft); }

.module-header { padding-bottom: 34px; border-bottom: 1px solid var(--line); }
.module-header h1 { max-width: 900px; font-size: clamp(35px, 5vw, 56px); }
.module-layout { display: grid; grid-template-columns: minmax(0, 1fr) 235px; gap: 46px; align-items: start; margin-top: 38px; }
.module-content { min-width: 0; }
.toc { position: sticky; top: 100px; padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: white; font-size: 13px; }
.toc strong { display: block; margin-bottom: 10px; }
.toc a { display: block; padding: 5px 0; color: var(--muted); text-decoration: none; }
.toc a:hover { color: var(--green); }
.lesson-section { scroll-margin-top: 95px; padding-bottom: 14px; }
.lesson-section ul, .lesson-section ol { padding-left: 22px; }
.lesson-section li { margin-bottom: 7px; }
.callout { margin: 22px 0; padding: 18px 20px; border-left: 4px solid var(--green); border-radius: 0 12px 12px 0; background: var(--green-soft); }
.callout.warning { border-color: #e79a2d; background: var(--amber-soft); }
.callout.danger { border-color: #d25b5b; background: var(--red-soft); }
.callout strong { display: block; margin-bottom: 4px; }
.table-wrap { overflow-x: auto; margin: 20px 0; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; background: white; font-size: 14px; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: #3f514c; background: #eff3f0; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
tr:last-child td { border-bottom: 0; }
pre { position: relative; overflow: auto; margin: 20px 0; padding: 22px; color: #dcebe6; background: #132622; border-radius: 14px; font: 13px/1.65 "SFMono-Regular", Consolas, monospace; white-space: pre; }
code { padding: 2px 5px; border-radius: 5px; color: #135e4b; background: #e8efec; font-family: "SFMono-Regular", Consolas, monospace; font-size: .9em; }
pre code { padding: 0; color: inherit; background: none; font-size: inherit; }
.copy-btn { position: absolute; top: 10px; right: 10px; padding: 5px 9px; color: #c9d9d4; background: #263c36; border: 0; border-radius: 7px; cursor: pointer; font-size: 11px; }
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 22px 0; padding: 22px; border-radius: 15px; background: white; border: 1px solid var(--line); }
.flow span { padding: 10px 13px; border-radius: 9px; background: var(--green-soft); font-size: 13px; font-weight: 700; }
.flow i { color: var(--green); font-style: normal; font-weight: 900; }
.exercise { margin: 30px 0; padding: 26px; border: 1px solid #bed3cb; border-radius: var(--radius); background: #f9fcfa; }
.exercise h3 { margin-top: 0; }
.practice-area { width: 100%; min-height: 130px; margin-top: 12px; padding: 14px; resize: vertical; border: 1px solid #cbd6d1; border-radius: 10px; background: white; }
.check-list { list-style: none; padding: 0 !important; }
.check-list li { position: relative; padding-left: 27px; }
.check-list li::before { content: "✓"; position: absolute; left: 0; color: var(--green); font-weight: 900; }
.module-completion { margin-top: 42px; padding: 28px; border-radius: var(--radius); color: white; background: var(--navy); }

.quiz { margin-top: 28px; }
.quiz-question { margin: 18px 0; padding: 24px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.quiz-question.correct { border-color: #56ad8e; background: #f4fbf8; }
.quiz-question.incorrect { border-color: #dc7e7e; background: #fff8f8; }
.question-number { color: var(--green); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.question-text { margin: 6px 0 14px; font-weight: 750; }
.option { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; padding: 10px 12px; border: 1px solid #e1e7e3; border-radius: 9px; cursor: pointer; }
.option:hover { background: #f5f8f6; }
.option input { margin-top: 5px; accent-color: var(--green); }
.feedback { display: none; margin-top: 13px; padding: 12px; border-radius: 9px; font-size: 14px; }
.correct .feedback, .incorrect .feedback { display: block; }
.correct .feedback { color: #145e49; background: #ddf3eb; }
.incorrect .feedback { color: #853b3b; background: #fee6e6; }
.quiz-result { margin: 25px 0; padding: 26px; border-radius: var(--radius); background: var(--navy); color: white; }
.score-big { font-size: 48px; font-weight: 900; }

.calculator { padding: 25px; border-radius: var(--radius); background: #eef5f2; }
.calc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.calc-grid label { color: var(--muted); font-size: 13px; font-weight: 700; }
.calc-grid input { width: 100%; margin-top: 5px; padding: 10px; border: 1px solid #c8d6d0; border-radius: 8px; }
.calc-result { margin-top: 18px; font-size: 22px; font-weight: 800; color: var(--green-dark); }

.search-box { width: 100%; padding: 14px 17px; border: 1px solid #cbd6d1; border-radius: 12px; background: white; }
.glossary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 25px; }
.term { scroll-margin-top: 95px; }
.term h3 { color: var(--green-dark); margin: 0 0 7px; }
.resource-card a { word-break: break-word; }
.mastery-list label { display: flex; gap: 12px; align-items: flex-start; padding: 13px 0; border-bottom: 1px solid var(--line); }
.mastery-list input { margin-top: 6px; accent-color: var(--green); }
.certificate { position: relative; overflow: hidden; margin-top: 30px; padding: 55px; border: 8px double #b89b53; text-align: center; background: #fffdf5; }
.certificate h2 { margin: 10px 0; font-family: Georgia, serif; font-size: 38px; }
.certificate::after { content: "NO OFICIAL"; position: absolute; right: -35px; top: 25px; padding: 7px 42px; transform: rotate(35deg); color: white; background: #9b443f; font-size: 11px; font-weight: 900; letter-spacing: .12em; }
.final-analysis { grid-template-columns: repeat(2, 1fr); }
.category-bar { margin: 12px 0; }
.category-bar > div:first-child { display: flex; justify-content: space-between; font-size: 13px; }
.category-bar .progress-track { margin-top: 5px; background: #e3e9e5; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 350px; padding: 13px 17px; color: white; background: var(--navy); border-radius: 10px; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .25s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translateY(0); }
.site-footer { padding: 9px 16px; text-align: center; color: #84908c; font-size: 11px; background: var(--paper); }
.site-footer a { color: inherit; text-decoration: none; }
.site-footer a:hover, .site-footer a:focus { color: var(--green-dark); text-decoration: underline; }
.counter-page h1 { font-size: clamp(38px, 6vw, 60px); }
.counter-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin: 32px 0; }
.counter-summary .card { display: flex; flex-direction: column; }
.counter-summary .stat { line-height: 1.2; }
.counter-page .table-wrap { margin-top: 24px; }
.counter-page th:nth-child(2), .counter-page td:nth-child(2) { width: 120px; text-align: right; }
.counter-page th:last-child, .counter-page td:last-child { width: 210px; }

@media (max-width: 1000px) {
  .topnav { display: none; position: fixed; top: 72px; left: 0; right: 0; padding: 14px; flex-direction: column; background: var(--navy); }
  .topnav.open { display: flex; }
  .menu-toggle { display: block; order: 3; }
  .header-progress { margin-left: auto; }
  .module-layout { grid-template-columns: 1fr; }
  .toc { position: static; order: -1; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .topbar { height: 64px; padding: 0 15px; gap: 12px; }
  .brand { min-width: 0; flex: 1; }
  .brand small { display: none; }
  .header-progress { width: 90px; }
  .app-shell { display: block; }
  .sidebar { display: none; }
  .page { padding: 30px 18px 70px; }
  .hero { min-height: auto; padding: 38px 25px; border-radius: 20px; }
  h1 { font-size: 40px; }
  .grid-2, .grid-3, .route-grid, .glossary-grid, .final-analysis { grid-template-columns: 1fr; }
  .calc-grid { grid-template-columns: 1fr; }
  .meta-row { gap: 10px; }
  .meta-row span { border: 0; }
  .module-card h3 { min-height: auto; }
  .certificate { padding: 38px 18px; }
  .certificate h2 { font-size: 29px; }
  .counter-summary { grid-template-columns: 1fr; }
  .counter-page th:last-child, .counter-page td:last-child { display: none; }
}

@media print {
  .topbar, .sidebar, .btn, .toc { display: none !important; }
  .app-shell { display: block; }
  .page { padding: 0; }
  .certificate { break-inside: avoid; }
}
