:root {
  --bg: #f6f5f1;
  --paper: #ffffff;
  --ink: #17202a;
  --muted: #65717e;
  --line: #d8d6ce;
  --nav: #101820;
  --accent: #2f6f73;
  --accent-2: #b45f3b;
  --good: #2f7d57;
  --watch: #a76c1f;
  --bad: #a33b35;
  --shadow: 0 12px 28px rgba(17, 24, 32, 0.08);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.book-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 22px;
  background: var(--nav);
  color: #f4f1ea;
  overflow-y: auto;
}

.brand {
  display: grid;
  gap: 6px;
  margin-bottom: 26px;
}

.brand .ticker {
  width: fit-content;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 4px;
  color: #dce8e4;
  font-size: 12px;
  letter-spacing: 0;
}

.brand h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.1;
}

.brand p {
  margin: 0;
  color: #b9c0c5;
  font-size: 13px;
}

.nav-block {
  display: grid;
  gap: 8px;
  margin: 20px 0;
}

.side-nav a.nav-sub {
  position: relative;
  padding-left: 20px;
  font-size: 13px;
  color: #d3d9da;
}

.side-nav a.nav-sub::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 16px;
  width: 7px;
  height: 1px;
  background: rgba(244, 241, 234, 0.4);
}

.nav-block h2 {
  margin: 0 0 4px;
  color: #98b6b7;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.side-nav a,
.print-button {
  display: block;
  width: 100%;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: #f4f1ea;
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.side-nav a:hover,
.side-nav a.active,
.print-button:hover {
  color: #91d0c9;
}
.side-nav a.active {
  font-weight: 700;
}

.nav-block.compact {
  gap: 4px;
  margin: 16px 0;
}

.nav-block.compact a {
  position: relative;
  padding: 5px 0 5px 14px;
  color: #d9dedf;
  font-size: 13px;
}

.nav-block.compact a::before {
  content: "";
  position: absolute;
  left: 0;
  top: 15px;
  width: 6px;
  height: 1px;
  background: rgba(244, 241, 234, 0.35);
}

.nav-block.compact a:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 18px;
  bottom: -7px;
  width: 1px;
  background: rgba(244, 241, 234, 0.18);
}

.nav-block.compact a.active,
.nav-block.compact a:hover,
.side-nav .section-link:hover {
  color: #91d0c9;
}

.side-nav .section-link {
  color: #c7cdcf;
  font-size: 13px;
}

.side-nav a.disabled,
.side-nav a.disabled:hover {
  color: rgba(244, 241, 234, 0.42);
  cursor: default;
}

.side-nav a.disabled {
  color: #6b7681;
  pointer-events: none;
  cursor: default;
}

.content {
  min-width: 0;
}

.topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(246, 245, 241, 0.96);
  backdrop-filter: blur(10px);
}

.topbar button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

main {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 34px 34px 70px;
}

.page-head {
  padding: 24px 0 26px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  letter-spacing: 0;
}

.page-head h1 {
  max-width: 920px;
  margin: 0;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.02;
}

.lead {
  max-width: 860px;
  margin: 18px 0 0;
  color: #33414d;
  font-size: 19px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfaf7;
  color: #2a3742;
  font-size: 13px;
}

.section {
  padding: 34px 0;
  border-bottom: 1px solid var(--line);
}

.section h2 {
  margin: 0 0 14px;
  font-size: 25px;
}

.section h3 {
  margin: 24px 0 10px;
  font-size: 18px;
}

.grid {
  display: grid;
  gap: 18px;
}

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

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.card h3 {
  margin-top: 0;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.metric {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  background: var(--paper);
  font-size: 14px;
}

.data-table th,
.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  background: #ece9e0;
  color: #28343f;
  font-size: 12px;
  text-transform: uppercase;
}

.bar-chart {
  display: grid;
  gap: 12px;
  margin: 18px 0;
}

.bar-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 96px;
  gap: 12px;
  align-items: center;
  font-size: 14px;
}

.bar-track {
  height: 22px;
  border-radius: 4px;
  background: #e7e3d9;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
}

.bar-fill.alt {
  background: var(--accent-2);
}

.bar-fill.minor {
  background: #7d8792;
}

.scenario {
  border-top: 4px solid var(--accent);
}

.scenario.base {
  border-color: var(--watch);
}

.scenario.bear {
  border-color: var(--bad);
}

.callout {
  margin: 20px 0;
  padding: 16px 18px;
  border-left: 4px solid var(--accent);
  background: #e9f1ef;
}

.warning {
  border-left-color: var(--bad);
  background: #f3e8e5;
}

.callout.invest {
  border-left-color: var(--good);
  background: #e9f1ec;
}

.source-note {
  color: var(--muted);
  font-size: 13px;
}

.chapter-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.chapter-link {
  display: block;
  min-height: 132px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
}

.chapter-link strong {
  display: block;
  margin-bottom: 8px;
  color: var(--accent);
}

.chapter-link span {
  color: var(--muted);
}

.status-list {
  display: grid;
  gap: 10px;
  padding-left: 20px;
}

.status-list li::marker {
  color: var(--accent);
}

.footer {
  padding: 30px 0 0;
  color: var(--muted);
  font-size: 13px;
}

/* --- Tier-Karte & Badges (aus dem Lieferkette-Dossier übernommen) --- */
.tier-stack {
  display: grid;
  gap: 14px;
  margin: 18px 0;
}

.tier-band {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.tier-band .tier-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.tier-band .tier-no {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.tier-band h3 {
  margin: 0;
  font-size: 18px;
}

.tier-band > p {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.tier-band .tier-firms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill.hoch { border-color: var(--bad); color: var(--bad); background: #f7ece9; }
.pill.mittel { border-color: var(--watch); color: var(--watch); background: #f6efe2; }
.pill.niedrig { border-color: var(--good); color: var(--good); background: #e9f1ec; }

/* IP-Intensität-Bubbles: "hoch" ist hier eine STÄRKE (Burggraben), kein Risiko →
   eigene Stufenklassen, hoch = grün/positiv, niedrig = neutral. Bewusst NICHT die
   roten Engpass-Stufen wiederverwenden (siehe AGENTS.md "Status-Bubbles"). */
.pill.ip-hoch { border-color: var(--good); color: var(--good); background: #e9f1ec; }
.pill.ip-mittel { border-color: var(--watch); color: var(--watch); background: #f6efe2; }
.pill.ip-niedrig { border-color: var(--muted); color: var(--muted); background: #f0efe9; }

/* Querverweis-Lücke: Firma genannt, aber (noch) kein eigenes Dossier im Repo. */
.kein-dossier { color: var(--muted); border-bottom: 1px dotted var(--muted); cursor: help; }

/* Energie/Strom: Zwei-Layer-Modell (vor/hinter dem Zähler) auf Basis der tier-band. */
.tier-band.layer1 { border-left-color: #5b6b76; }
.tier-band.layer1 .tier-no { color: #5b6b76; }
.tier-band.layer2 { border-left-color: var(--good); }
.tier-band.layer2 .tier-no { color: var(--good); }

/* === Beispiel-Dossier: Phasen-Fluss-Überblick (Phase 0 → 6) === */
.phase-flow {
  display: grid;
  justify-items: stretch;
  gap: 0;
  margin: 22px 0;
}

.phase-band {
  position: relative;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--accent);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.phase-band .phase-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

.phase-band .phase-no {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

.phase-band h3 {
  margin: 0;
  font-size: 18px;
}

.phase-band > p {
  margin: 4px 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.phase-firms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Verbinder zwischen den Bändern: vertikale Linie + CSS-Dreieck (kein Emoji) */
.phase-arrow {
  position: relative;
  justify-self: center;
  width: 2px;
  height: 30px;
  margin: 2px 0;
  background: var(--accent);
}

.phase-arrow::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -1px;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid var(--accent);
}

/* Phasen-Farbcodierung (Senke dunkel → Rohstoffe grau) */
.phase-band.p0 { border-left-color: #101820; }
.phase-band.p1 { border-left-color: var(--accent); }
.phase-band.p2 { border-left-color: #3a7d6e; }
.phase-band.p3 { border-left-color: var(--accent-2); }
.phase-band.p4 { border-left-color: var(--watch); }
.phase-band.p5 { border-left-color: #8a5a2b; }
.phase-band.p6 { border-left-color: #5b6b76; }

.phase-band.p0 .phase-no { color: #101820; }
.phase-band.p2 .phase-no { color: #3a7d6e; }
.phase-band.p3 .phase-no { color: var(--accent-2); }
.phase-band.p4 .phase-no { color: var(--watch); }
.phase-band.p5 .phase-no { color: #8a5a2b; }
.phase-band.p6 .phase-no { color: #5b6b76; }

/* === Beispiel-Dossier: ausklappbarer Verzweigungs-Baum (Decomposition) === */
.supply-tree {
  margin: 18px 0;
  font-size: 14px;
}

.supply-tree details {
  margin: 0;
}

.supply-tree summary,
.supply-tree .tree-leaf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 5px 0;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
}

.supply-tree summary {
  cursor: pointer;
  list-style: none;
}

.supply-tree summary::-webkit-details-marker {
  display: none;
}

/* Disclosure-Caret rein per CSS-Dreieck (kein ▾/▸-Emoji) */
.supply-tree summary::before {
  content: "";
  flex: 0 0 auto;
  width: 0;
  height: 0;
  border-left: 7px solid var(--accent);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transition: transform 0.15s ease;
}

.supply-tree details[open] > summary::before {
  transform: rotate(90deg);
}

.supply-tree summary:hover {
  border-color: var(--accent);
}

/* Leaf-Knoten: kurzer Strich statt Caret */
.supply-tree .tree-leaf::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 2px;
  background: var(--muted);
}

.supply-tree .children {
  margin: 0 0 6px 16px;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.node-name {
  font-weight: 700;
}

.node-role {
  color: var(--muted);
}

.pill.phase {
  border-color: var(--accent);
  color: var(--accent);
  background: #e9f1ef;
  font-weight: 700;
}

.pill.self {
  border-color: #101820;
  color: #101820;
  background: #e7eaec;
}

.tree-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 6px 0 0;
}

/* === Beispiel-Dossier: Donut (conic-gradient) === */
.donut-chart {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 28px;
  margin: 18px 0;
}

.donut {
  --size: 210px;
  position: relative;
  flex: 0 0 auto;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
}

.donut::after {
  content: "";
  position: absolute;
  inset: 26%;
  background: var(--paper);
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px var(--line);
}

.donut-legend {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
}

.donut-legend li {
  display: flex;
  align-items: center;
  gap: 9px;
}

.legend-swatch {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  border-radius: 3px;
}

.donut-legend .value {
  color: var(--muted);
}

/* === Beispiel-Dossier: vertikales Säulendiagramm (Zeitreihe) === */
.col-chart {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  height: 240px;
  margin: 18px 0 6px;
  padding: 10px 6px 0;
  border-bottom: 2px solid var(--line);
}

.col-item {
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}

.col-bar {
  width: 64%;
  max-width: 58px;
  min-height: 4px;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
}

.col-bar.guidance {
  background: repeating-linear-gradient(45deg, var(--watch), var(--watch) 7px, #c89042 7px, #c89042 14px);
}

.col-value {
  font-size: 13px;
  font-weight: 700;
}

.col-label {
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .book-shell {
    display: block;
  }

  .side-nav {
    display: none;
    position: fixed;
    inset: 58px 0 0;
    z-index: 20;
    height: auto;
  }

  .side-nav.open {
    display: block;
  }

  .topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  main {
    padding: 20px 16px 54px;
  }

  .grid.two,
  .grid.three,
  .metric-grid,
  .chapter-list {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .bar-row .value {
    grid-column: 2;
    color: var(--muted);
  }

  .supply-tree .children {
    margin-left: 9px;
    padding-left: 9px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .book-shell {
    display: block;
  }

  .side-nav,
  .topbar {
    display: none;
  }

  main {
    width: 100%;
    padding: 0;
  }

  .card,
  .metric,
  .chapter-link,
  .tier-band,
  .phase-band {
    box-shadow: none;
  }

  /* Im Druck den ganzen Baum aufklappen */
  .supply-tree details > *:not(summary) {
    display: block !important;
  }

  .supply-tree details[open] > summary::before,
  .supply-tree summary::before {
    transform: rotate(90deg);
  }
}

/* gloss-link: Akronyme/Begriffe -> glossar.html (Link + Tooltip). Dezent, kein Konkurrent zu Querverweis-Links. */
.gloss-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted var(--muted, #65717e);
  cursor: help;
}
.gloss-link:hover {
  border-bottom-color: var(--accent, #2f6f73);
}
.gloss-link abbr {
  border: 0;
  text-decoration: none;
  cursor: help;
}
@media print {
  .gloss-link {
    border-bottom: 0;
  }
}