/* =================================================================
   Lao Hydropower Forum 2026 — interactive systems map
   White background · thin colored borders · dense small text
   Collapsible cards via <details>
================================================================= */

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

:root {
  /* Surfaces */
  --paper:        #ffffff;
  --paper-2:      #fafbfc;
  --paper-3:      #f3f5f8;
  --rule:         #e4e7ec;
  --rule-strong:  #c9d0d9;

  /* Ink */
  --ink:          #1a2540;
  --ink-2:        #3a4357;
  --ink-3:        #5e6678;
  --muted:        #8590a3;

  /* Category colors — slightly desaturated, UN-report palette */
  --c-trigger:    #9b2522;  /* deep red */
  --c-ops:        #2c5d8f;  /* deep blue */
  --c-lev:        #2d6a3f;  /* deep green */
  --c-impact:     #c87124;  /* burnt orange */
  --c-sol:        #1f7a7a;  /* deep teal */

  /* Soft tints for card insides */
  --tint-trigger: #fdf3f2;
  --tint-ops:     #f1f6fc;
  --tint-lev:     #f1f7f3;
  --tint-impact:  #fcf5ed;
  --tint-sol:     #eef7f7;

  /* Accent */
  --hi:           #3a6890;

  /* Stage */
  --stage-bg:     #eef0f4;
}

html, body {
  background: var(--stage-bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }

a { color: var(--c-ops); text-decoration: none; }
a:hover { text-decoration: underline; }

/* =================================================================
   CONTROL BAR (sticky top)
================================================================= */
.control-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  background: rgba(255,255,255,0.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
}

.control-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-mark {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: white;
  border-radius: 6px;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.brand-meta { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text { font-size: 13px; font-weight: 700; color: var(--ink); }
.brand-sub { font-size: 10.5px; color: var(--muted); font-family: 'JetBrains Mono', monospace; letter-spacing: 0.02em; }

.band-jump {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}
.band-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--paper-3);
  border: 1px solid var(--rule);
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
}
.band-chip:hover { background: white; border-color: var(--chip, var(--rule-strong)); color: var(--chip, var(--ink)); }
.band-chip.active {
  background: var(--chip, var(--ink));
  color: white;
  border-color: var(--chip, var(--ink));
}
.band-chip.active .dot { background: white; }
.band-chip .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--chip, var(--muted));
}

.control-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ctrl-btn {
  height: 30px;
  min-width: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--rule);
  background: white;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all .15s ease;
  font-family: inherit;
}
.ctrl-btn:hover { background: var(--paper-3); border-color: var(--rule-strong); color: var(--ink); }
.ctrl-btn-zoom { min-width: 54px; font-family: 'JetBrains Mono', monospace; font-size: 11.5px; }
.ctrl-btn-lock { padding: 0 12px; font-size: 12px; }
.ctrl-btn-lock .ic-lock { display: none; }
.ctrl-btn-lock[aria-pressed="true"] {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.ctrl-btn-lock[aria-pressed="true"] .ic-unlock { display: none; }
.ctrl-btn-lock[aria-pressed="true"] .ic-lock { display: inline; }
.lock-label { font-weight: 600; }

/* =================================================================
   STAGE + PAN/ZOOM
================================================================= */
.stage {
  position: relative;
  background: var(--stage-bg);
  padding: 28px 0 48px;
  min-height: calc(100vh - 56px);
}
.stage-viewport {
  width: 100%;
  display: flex;
  justify-content: center;
}

body.poster-locked {
  overflow: hidden;
}
body.poster-locked .stage {
  height: calc(100vh - 56px);
  overflow: hidden;
  padding: 0;
  cursor: grab;
}
body.poster-locked .stage.is-panning { cursor: grabbing; }
body.poster-locked .stage-viewport {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1180px;
  transform-origin: 0 0;
  will-change: transform;
}
body.poster-locked .control-bar {
  position: sticky; /* still visible */
}

.pan-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(26,37,64,0.94);
  color: white;
  font-size: 12px;
  padding: 8px 14px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease;
  z-index: 50;
  font-weight: 500;
}
body.poster-locked .pan-hint { opacity: 1; }
.pan-hint .kbd {
  display: inline-block;
  background: rgba(255,255,255,0.18);
  border-radius: 3px;
  padding: 1px 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

/* =================================================================
   POSTER
================================================================= */
.poster {
  width: 1180px;
  max-width: calc(100vw - 32px);
  background: var(--paper);
  border: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(0,0,0,0.02), 0 24px 60px -28px rgba(20,28,52,0.18);
  padding: 32px 36px 28px;
}

/* ---------- HEADER ---------- */
.p-head {
  display: grid;
  grid-template-columns: 1fr 280px 180px;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--rule);
}
.p-head-main { padding-top: 4px; }
.p-head-eyebrow {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.p-head-tag { display: inline-flex; align-items: center; gap: 6px; }
.p-head-tag::before {
  content: '';
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--c-ops);
  display: inline-block;
  opacity: 0.65;
}
.p-head-tag-dot::before { background: var(--c-sol); }
.p-head-tag:nth-child(3)::before { background: var(--c-impact); }

.p-head-title {
  font-family: 'Inter', sans-serif;
  font-size: 38px;
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-transform: none;
  margin-bottom: 10px;
}
.p-head-deck {
  font-size: 15px;
  font-weight: 600;
  color: var(--c-ops);
  line-height: 1.35;
  max-width: 520px;
}

.p-head-insight {
  background: #eef3f9;
  border: 1px solid #d2dfee;
  border-radius: 6px;
  padding: 0;
  align-self: start;
  margin-top: 4px;
  overflow: hidden;
}
.p-head-insight-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 40px 12px 14px;
  position: relative;
  display: block;
}
.p-head-insight-summary::-webkit-details-marker { display: none; }
.p-head-insight-eyebrow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--c-ops);
  margin-bottom: 8px;
}
.p-head-insight-headline {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink);
  font-weight: 600;
  margin: 0;
}
.p-head-insight-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 20px;
  height: 20px;
  border: 1px solid #b8cce0;
  border-radius: 3px;
  background: #fff;
  display: grid;
  place-items: center;
  color: var(--c-ops);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  line-height: 1;
  transition: background .12s ease, border-color .12s ease;
}
.p-head-insight-toggle::before { content: '+'; }
.p-head-insight[open] .p-head-insight-toggle { background: var(--c-ops); border-color: var(--c-ops); color: #fff; }
.p-head-insight[open] .p-head-insight-toggle::before { content: '−'; }
.p-head-insight-summary:hover .p-head-insight-toggle { border-color: var(--c-ops); }
.p-head-insight-body-wrap {
  padding: 0 14px 14px 14px;
  border-top: 1px solid #d2dfee;
  margin-top: 0;
  padding-top: 12px;
  background: #f5f8fc;
}
.p-head-insight-body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 0 0 8px 0;
}
.p-head-insight-body:last-child { margin-bottom: 0; }
.p-head-insight-body strong { color: var(--c-ops); }
.p-head-insight-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 10px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  counter-reset: insight-finding;
}
.p-head-insight-list li {
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-2);
  padding: 8px 10px 8px 32px;
  background: #fff;
  border: 1px solid #dde7f1;
  border-left: 3px solid var(--c-ops);
  border-radius: 3px;
  position: relative;
  counter-increment: insight-finding;
}
.p-head-insight-list li::before {
  content: counter(insight-finding);
  position: absolute;
  left: 8px;
  top: 8px;
  width: 18px;
  height: 18px;
  background: var(--c-ops);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  border-radius: 50%;
  display: grid;
  place-items: center;
  line-height: 1;
}
.p-head-insight-list li strong {
  display: block;
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 2px;
  font-size: 12px;
}
.p-head-insight-list li span { display: block; color: var(--ink-2); }

.p-head-illus {
  align-self: center;
  justify-self: end;
  width: 180px;
  height: 130px;
  display: grid;
  place-items: center;
}

/* ---------- KEY NUMBERS STRIP ---------- */
.p-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 18px;
}
.p-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-right: 1px solid var(--rule);
}
.p-stat:last-child { border-right: none; }
.p-stat-glyph { flex-shrink: 0; opacity: 0.85; }
.p-stat .num {
  font-family: 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.p-stat .num-suffix {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}
.p-stat .lbl {
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.3;
  margin-top: 2px;
}

/* =================================================================
   BAND LAYOUT — colored strip label on left, content on right
================================================================= */
.band {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  margin-bottom: 6px;
}

.band-rail {
  background: var(--rail-color, var(--ink));
  color: white;
  border-radius: 4px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  min-height: 160px;
  gap: 6px;
}
/* Rotate rail text 90 deg CCW so it reads bottom-to-top along the rail */
.rail-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.85;
  letter-spacing: 0.12em;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  flex: 0 0 auto;
}
.rail-name {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.15;
  text-transform: uppercase;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.rail-name br { display: none; }
.rail-glyph {
  opacity: 0.9;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.rail-glyph svg { width: 18px; height: 18px; }

.band-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* =================================================================
   COLLAPSIBLE CARDS (<details class="card-fold">)
================================================================= */
.card-fold {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
}
.card-fold-summary {
  list-style: none;
  cursor: pointer;
  padding: 11px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: inherit;
  transition: background .15s ease;
  user-select: none;
}
.card-fold-summary::-webkit-details-marker { display: none; }
.card-fold-summary:hover { background: var(--paper-2); }

.card-fold-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  flex-shrink: 0;
  padding-right: 12px;
  border-right: 1px solid var(--rule);
  margin-right: 4px;
}
.card-fold-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  flex: 1;
  line-height: 1.3;
}
.card-fold-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--ink-3);
}
.card-fold-toggle {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  background: var(--paper-3);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  position: relative;
  transition: all .2s ease;
}
.card-fold-toggle::before,
.card-fold-toggle::after {
  content: '';
  position: absolute;
  background: var(--ink-2);
  border-radius: 1px;
}
.card-fold-toggle::before { width: 10px; height: 2px; }
.card-fold-toggle::after  { width: 2px; height: 10px; transition: transform .2s ease; }
.card-fold[open] > .card-fold-summary .card-fold-toggle::after { transform: rotate(90deg); }
.card-fold[open] > .card-fold-summary .card-fold-toggle { background: var(--ink); }
.card-fold[open] > .card-fold-summary .card-fold-toggle::before,
.card-fold[open] > .card-fold-summary .card-fold-toggle::after { background: white; }

.card-fold-body {
  padding: 14px 16px 16px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
  animation: fold-in 0.22s ease-out;
}
@keyframes fold-in {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Colored band cards */
.band-card-trigger {
  border-color: rgba(155,37,34,0.32);
  border-top: 3px solid var(--c-trigger);
}
.band-card-trigger > .card-fold-summary { background: var(--tint-trigger); }
.band-card-trigger > .card-fold-summary .card-fold-eyebrow,
.band-card-trigger > .card-fold-summary .card-fold-title { color: #6e1b19; }

.band-card-lev {
  border-color: rgba(45,106,63,0.32);
  border-top: 3px solid var(--c-lev);
}
.band-card-lev > .card-fold-summary { background: var(--tint-lev); }
.band-card-lev > .card-fold-summary .card-fold-eyebrow,
.band-card-lev > .card-fold-summary .card-fold-title { color: #1f4e2d; }

.band-card-sol {
  border-color: rgba(31,122,122,0.32);
  border-top: 3px solid var(--c-sol);
}
.band-card-sol > .card-fold-summary { background: var(--tint-sol); }
.band-card-sol > .card-fold-summary .card-fold-eyebrow,
.band-card-sol > .card-fold-summary .card-fold-title { color: #155656; }

/* Sub-cards inside Downstream Impacts band */
.sub-card { margin-top: 4px; }
.sub-card > .card-fold-summary { background: var(--tint-impact); }
.sub-card {
  border-color: rgba(200,113,36,0.32);
  border-top: 2px solid var(--c-impact);
}
.sub-card > .card-fold-summary .card-fold-eyebrow,
.sub-card > .card-fold-summary .card-fold-title { color: #813f0d; }

/* =================================================================
   FLOW CARDS (operational gaps + downstream impact cards)
================================================================= */
.flow-3col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.band-impact .flow-3col {
  grid-template-columns: repeat(4, 1fr);
}

.flow-card {
  background: white;
  border: 1px solid var(--rule);
  border-top: 3px solid var(--c-ops);
  border-radius: 5px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 110px;
  transition: all .15s ease;
}
.flow-card[data-cluster-id] { cursor: pointer; border-top-color: var(--c-impact); }
.flow-card[data-cluster-id]:hover { transform: translateY(-1px); box-shadow: 0 4px 12px -4px rgba(20,30,55,0.15); }
.flow-card-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.flow-card-body {
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.45;
  flex: 1;
}
.flow-card-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--c-ops);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-top: 1px solid var(--rule);
  padding-top: 6px;
  margin-top: 2px;
}

/* =================================================================
   FLOW-TRIGGER (Band 01) and FLOW-LEVERAGE (Band 03) bodies
   (rendered by app.js into a single block)
================================================================= */
#flow-trigger, #flow-leverage {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.flow-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
}
.flow-subtitle {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.55;
  max-width: 780px;
}
.flow-bullets {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 14px;
  margin-top: 4px;
}
.flow-bullets li {
  font-size: 11.5px;
  color: var(--ink-2);
  padding-left: 14px;
  position: relative;
  line-height: 1.45;
}
.flow-bullets li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--c-ops);
}
.band-card-trigger .flow-bullets li::before { background: var(--c-trigger); }
.band-card-lev     .flow-bullets li::before { background: var(--c-lev); }

.flow-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 8px;
  border-top: 1px dashed var(--rule);
  margin-top: 4px;
}
.band-card-lev .flow-meta { color: var(--c-lev); font-weight: 700; }

/* leverage icon-row mini blocks (DOE/EAP/etc) — repurpose existing flow-bullets */

/* =================================================================
   ARROW BANDS
================================================================= */
.arrow-band {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 0 6px;
  color: var(--muted);
}
.arrow-band .arrow-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.arrow-svg {
  width: 28px;
  height: 22px;
  color: var(--rule-strong);
}
.arrow-band-solution .arrow-svg { color: var(--c-sol); }
.arrow-band-solution .arrow-label { color: var(--c-sol); font-weight: 700; }

/* =================================================================
   CHALLENGES (7 ranked cards inside downstream sub-card)
================================================================= */
.challenges {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.cluster {
  display: grid;
  grid-template-columns: 64px 1fr 150px;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-left: 4px solid var(--cluster-color, var(--c-ops));
  border-radius: 4px;
  background: white;
  cursor: pointer;
  align-items: start;
  transition: all .15s ease;
}
.cluster:hover { background: var(--paper-2); transform: translateX(2px); }
.cluster-rank {
  font-family: 'JetBrains Mono', monospace;
  font-size: 18px;
  font-weight: 800;
  color: var(--cluster-color, var(--ink));
  line-height: 1;
}
.cluster-rank-sub {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.cluster-body { min-width: 0; }
.cluster-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.2;
  margin-bottom: 1px;
}
.cluster-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 6px;
}
.cluster-evidence {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.cluster-evidence span {
  display: inline-block;
  padding: 2px 7px;
  background: var(--paper-3);
  border-radius: 3px;
  font-size: 10.5px;
  color: var(--ink-2);
  line-height: 1.4;
}
.cluster-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--ink-3);
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.02em;
}
.cluster-letter {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cluster-color, var(--ink));
  color: white;
  font-size: 9px;
  font-weight: 800;
  font-family: 'Inter', sans-serif;
}
.cluster-score {
  text-align: right;
  border-left: 1px solid var(--rule);
  padding-left: 14px;
}
.cluster-tier {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  font-weight: 700;
  color: var(--cluster-color);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.cluster-score-num {
  font-size: 26px;
  font-weight: 900;
  color: var(--cluster-color);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  margin-top: 2px;
}
.cluster-score-out {
  font-size: 9.5px;
  color: var(--muted);
  font-family: 'JetBrains Mono', monospace;
}
.cluster-bar {
  height: 4px;
  background: var(--paper-3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
  margin-top: 6px;
}
.cluster-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  width: var(--bar-pct, 0%);
  background: var(--cluster-color);
  transition: width .9s cubic-bezier(.22,.61,.36,1);
}
.cluster-axis {
  display: flex;
  justify-content: space-between;
  font-family: 'JetBrains Mono', monospace;
  font-size: 8.5px;
  color: var(--muted);
  margin-top: 3px;
}

/* Tier legend below challenges */
.tiers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  background: var(--paper-2);
  border: 1px dashed var(--rule);
  border-radius: 4px;
}
.tier { display: flex; align-items: flex-start; gap: 8px; }
.tier-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.tier-name { font-size: 12px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.tier-rule { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--muted); margin-top: 1px; }
.tier-action { font-size: 11px; color: var(--ink-2); margin-top: 1px; }

/* =================================================================
   DAMS GRID
================================================================= */
.mrc-banner {
  display: flex;
  gap: 12px;
  background: #eef3f9;
  border: 1px solid #d2dfee;
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.mrc-banner-mark {
  display: grid;
  place-items: center;
  background: var(--c-ops);
  color: white;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  width: 38px;
  height: 38px;
  border-radius: 4px;
  flex-shrink: 0;
}
.mrc-banner-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--c-ops);
  margin-bottom: 2px;
}
.mrc-banner-text {
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.45;
}
.mrc-banner-stats {
  display: flex;
  gap: 14px;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: 'JetBrains Mono', monospace;
  flex-wrap: wrap;
}
.mrc-banner-stats strong { color: var(--ink); font-weight: 800; }

.dam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
  gap: 8px;
}
.dam {
  background: white;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all .15s ease;
}
.dam:hover {
  border-color: var(--c-ops);
  background: var(--tint-ops);
  transform: translateY(-1px);
}
.dam-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  margin-bottom: 4px;
}
.dam-cap {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-ops);
}
.dam-river {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* =================================================================
   TIMELINE
================================================================= */
.timeline {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}
.tl-event {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 12px;
  align-items: start;
  padding: 8px 12px;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--c-impact);
  background: white;
  border-radius: 4px;
}
.tl-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-impact);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tl-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.tl-detail {
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.45;
  grid-column: 2;
  margin-top: 3px;
}

/* =================================================================
   SOLUTION — 7-step plan
================================================================= */
.steps-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--tint-sol);
  border: 1px solid rgba(31,122,122,0.22);
  border-radius: 4px;
  padding: 10px 12px;
  margin-bottom: 14px;
}
.steps-banner-mark {
  display: grid;
  place-items: center;
  background: var(--c-sol);
  color: white;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  width: 38px;
  height: 38px;
  border-radius: 4px;
  flex-shrink: 0;
}
.steps-banner-title {
  font-size: 13.5px;
  font-weight: 700;
  color: #155656;
  line-height: 1.2;
}
.steps-banner-presenter {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
}
.solutions-lead {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
  margin-bottom: 12px;
}
.phases { display: flex; flex-direction: column; gap: 14px; }
.phase {
  padding: 10px 0 0;
  border-top: 1px dashed var(--rule);
}
.phase:first-child { border-top: none; padding-top: 0; }
.phase-label {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}
.phase-label-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--c-sol);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: var(--tint-sol);
  padding: 2px 7px;
  border-radius: 3px;
}
.phase-label-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.steps-list { display: grid; grid-template-columns: 1fr; gap: 6px; }
.step-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: stretch;
}
.step-oval {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: var(--step-color, var(--c-sol));
  color: white;
  border-radius: 999px;
  padding: 0 12px;
  height: 38px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
  flex-shrink: 0;
  transition: transform .15s ease;
}
.step-oval:hover { transform: scale(1.03); }
.step-oval-icon {
  width: 18px;
  height: 18px;
  background: rgba(255,255,255,0.22);
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.step-oval-icon svg { width: 11px; height: 11px; }
.step-card {
  background: white;
  border: 1px solid var(--rule);
  border-left: 3px solid var(--step-color, var(--c-sol));
  border-radius: 4px;
  padding: 9px 12px;
  cursor: pointer;
  transition: all .15s ease;
}
.step-card:hover { background: var(--paper-2); transform: translateX(2px); }
.step-card-name {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.step-card-short {
  font-size: 11px;
  color: var(--ink-2);
  margin-top: 3px;
  line-height: 1.4;
}
.step-card-agencies {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.agency-tag {
  display: inline-block;
  padding: 1px 6px;
  background: var(--paper-3);
  border: 1px solid var(--rule);
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  color: var(--ink-2);
  letter-spacing: 0.02em;
}
.step-card-link {
  display: inline-block;
  margin-top: 5px;
  font-size: 10.5px;
  color: var(--step-color, var(--c-sol));
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
}

.agencies {
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
}
.agencies-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}
.agencies-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 4px 16px;
}
.agencies-list .item { display: flex; gap: 6px; font-size: 11px; }
.agencies-list dt { font-weight: 700; color: var(--c-sol); font-family: 'JetBrains Mono', monospace; }
.agencies-list dd { color: var(--ink-2); }

.tagline {
  margin-top: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-sol);
  text-align: center;
  padding: 8px 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.outcome {
  font-size: 11.5px;
  color: var(--ink-2);
  text-align: center;
  line-height: 1.5;
}

/* =================================================================
   WHY THIS MATTERS + WHAT MUST CHANGE
================================================================= */
.why-change {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0 12px;
}
.why-fold { border-top: 3px solid var(--c-impact); }
.why-fold > .card-fold-summary { background: var(--tint-impact); color: #813f0d; }
.why-fold > .card-fold-summary .card-fold-title { color: #813f0d; }
.change-fold { border-top: 3px solid var(--c-lev); }
.change-fold > .card-fold-summary { background: var(--tint-lev); color: #1f4e2d; }
.change-fold > .card-fold-summary .card-fold-title { color: #1f4e2d; }
.card-fold-icon { color: inherit; }

.why-list, .change-list {
  list-style: none;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.why-list li, .change-list li {
  padding: 8px 10px 8px 28px;
  background: white;
  border: 1px solid var(--rule);
  border-radius: 4px;
  position: relative;
}
.why-list li::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--c-impact);
}
.change-list li::before {
  content: '✓';
  position: absolute;
  left: 8px;
  top: 6px;
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  background: var(--c-lev);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 3px;
}
.why-list .t, .change-list .t {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.why-list .b, .change-list .b {
  font-size: 11px;
  color: var(--ink-2);
  margin-top: 2px;
  line-height: 1.45;
}

/* =================================================================
   BOTTOM STRIP — scoring + call to action + legend
================================================================= */
.bottom-strip {
  display: grid;
  grid-template-columns: 1.7fr 1fr 0.9fr;
  gap: 12px;
  margin-bottom: 16px;
}
.strip-fold { border-top: 2px solid var(--ink); }
.strip-fold > .card-fold-summary { background: var(--paper-2); }

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}
.score-table th, .score-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
}
.score-table thead th {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--rule);
}
.score-table .num-col { text-align: right; font-variant-numeric: tabular-nums; }
.score-table .dotbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  color: var(--ink);
}
.score-table .dotbox .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.score-table tbody tr:hover { background: var(--paper-2); }
.score-note {
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 6px;
  font-style: italic;
}

.cta-headline {
  display: inline-block;
  background: var(--ink);
  color: white;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin-bottom: 10px;
}
.cta-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.cta-list li {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 11.5px;
  color: var(--ink-2);
  line-height: 1.4;
}
.cta-tick {
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--c-lev);
  color: white;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 1px;
}

.legend-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.legend-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--ink-2);
}
.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* =================================================================
   FOOTER
================================================================= */
.p-foot {
  background: #2c4866;
  color: white;
  border-radius: 4px;
  padding: 12px 20px;
  text-align: center;
  margin-top: 6px;
}
.p-foot-line {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.p-foot-link { color: white; }
.p-foot-sep { color: rgba(255,255,255,0.4); }
.p-foot-source {
  font-size: 10.5px;
  color: rgba(255,255,255,0.7);
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.4;
}

/* =================================================================
   MODAL (unchanged structure, restyled to fit poster)
================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,28,52,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 28px;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: white;
  border-radius: 6px;
  max-width: 760px;
  width: 100%;
  max-height: calc(100vh - 56px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  background: var(--cluster-color, var(--ink));
  color: white;
}
.modal-rank {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.modal-title {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
}
.modal-close {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.4);
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
}
.modal-close:hover { background: rgba(255,255,255,0.15); }
.modal-body {
  padding: 18px 22px 22px;
  overflow-y: auto;
}
.modal-detail {
  font-size: 13.5px;
  color: var(--ink-2);
  line-height: 1.55;
  margin-bottom: 14px;
}
.modal-evidence-title, .modal-effects-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 12px 0 6px;
}
.modal-evidence-list {
  list-style: disc inside;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.55;
  padding-left: 4px;
}
.modal-evidence-list li { margin-bottom: 3px; }
.modal-effect {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px solid var(--rule);
}
.modal-effect:last-child { border-bottom: none; }
.modal-effect-name { font-size: 12.5px; font-weight: 700; color: var(--ink); }
.modal-effect-note { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.45; }
.modal-effect-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 800;
  color: var(--cluster-color, var(--c-ops));
  flex-shrink: 0;
}

/* MRC verify card inside dam modal */
.mrc-verify {
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--paper-2);
  border: 1px solid var(--rule);
  border-radius: 5px;
}
.mrc-verify-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.mrc-verify-mark {
  display: grid;
  place-items: center;
  background: var(--c-ops);
  color: white;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  font-weight: 700;
  width: 30px;
  height: 30px;
  border-radius: 4px;
}
.mrc-verify-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--c-ops);
  flex: 1;
}
.mrc-verify-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.mrc-verify-badge.match     { background: #d4edd9; color: #1d6a32; }
.mrc-verify-badge.cap-diff  { background: #fff4cc; color: #8a6a13; }
.mrc-verify-badge.status-diff { background: #ffe1c4; color: #8c4a18; }
.mrc-verify-grid {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 5px 12px;
  font-size: 11.5px;
}
.mrc-verify-grid dt { color: var(--muted); font-family: 'JetBrains Mono', monospace; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; }
.mrc-verify-grid dd { color: var(--ink-2); }
.mrc-verify-note {
  margin-top: 8px;
  padding: 6px 8px;
  background: #fff8dc;
  border-left: 2px solid #d6a814;
  font-size: 11px;
  color: var(--ink-2);
  line-height: 1.45;
}
.mrc-verify-source {
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--muted);
}

/* =================================================================
   RESPONSIVE
================================================================= */
@media (max-width: 980px) {
  /* On medium screens, brand sub-line is the first to go */
  .brand-sub { display: none; }
  .brand-text { font-size: 12px; }
  .band-chip { padding: 4px 8px; font-size: 10.5px; }
  .ctrl-btn-lock .lock-label { display: none; }
  .poster { padding: 22px 18px 20px; }
  .p-head { grid-template-columns: 1fr 240px; }
  .p-head-illus { display: none; }
  .p-head-title { font-size: 30px; }
  .p-stats { grid-template-columns: repeat(2, 1fr); }
  .p-stat { border-bottom: 1px solid var(--rule); }
  .p-stat:nth-child(3), .p-stat:nth-child(4) { border-right: none; }
  .p-stat:nth-child(2) { border-right: none; }
  .p-stat:nth-child(3), .p-stat:nth-child(4) { border-bottom: none; }
  .flow-3col, .band-impact .flow-3col { grid-template-columns: 1fr 1fr; }
  .tiers { grid-template-columns: 1fr; }
  .bottom-strip { grid-template-columns: 1fr; }
  .why-change { grid-template-columns: 1fr; }
  .step-row { grid-template-columns: 90px 1fr; }
}

@media (max-width: 640px) {
  /* COMPACT NAV: single 48px row -- brand mark | numbered colored dots | icon-only actions */
  .control-bar {
    height: 48px;
    padding: 0 10px;
    gap: 8px;
    flex-wrap: nowrap;
    overflow: hidden;
  }
  .control-brand { gap: 0; flex: 0 0 auto; }
  .brand-meta { display: none; }
  .brand-mark { width: 28px; height: 28px; font-size: 13px; }

  /* Chips become small numbered colored dots in a tight row */
  .band-jump {
    flex: 1 1 auto;
    width: auto;
    gap: 5px;
    justify-content: center;
    flex-wrap: nowrap;
    order: 0;
  }
  .band-chip {
    padding: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--chip, var(--paper-3));
    border: 1px solid var(--chip, var(--rule));
    color: white;
    font-size: 11px;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
  }
  .band-chip:hover { background: var(--chip); color: white; }
  .band-chip .dot { display: none; }
  .band-chip .chip-label { display: none; }
  .band-chip::before {
    content: attr(data-num);
    color: white;
    line-height: 1;
  }
  .band-chip.active {
    transform: scale(1.18);
    opacity: 1;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.06);
  }

  /* Action buttons: condense */
  .control-actions { gap: 4px; flex: 0 0 auto; }
  .ctrl-btn { height: 28px; min-width: 28px; padding: 0 8px; font-size: 12px; }
  .ctrl-btn-zoom { min-width: 42px; font-size: 10.5px; padding: 0 6px; }
  .ctrl-btn-lock { padding: 0 8px; }
  .ctrl-btn-lock .lock-label { display: none; }
  .poster { padding: 16px 12px 14px; max-width: 100%; }
  .p-head { grid-template-columns: 1fr; gap: 12px; }
  .p-head-title { font-size: 24px; }
  .p-head-deck { font-size: 13px; }
  .p-stats { grid-template-columns: 1fr; }
  .p-stat { border-right: none; border-bottom: 1px solid var(--rule); }
  .p-stat:last-child { border-bottom: none; }
  .band { grid-template-columns: 48px 1fr; gap: 8px; }
  .rail-name { font-size: 11px; letter-spacing: 0.04em; }
  .flow-3col, .band-impact .flow-3col { grid-template-columns: 1fr; }
  .cluster { grid-template-columns: 50px 1fr; }
  .cluster-score { grid-column: 1 / -1; border-left: none; border-top: 1px solid var(--rule); padding: 8px 0 0; text-align: left; display: flex; align-items: center; gap: 12px; }
  .cluster-score-num { font-size: 22px; }
  .cluster-bar, .cluster-axis { width: 120px; }
  .tl-event { grid-template-columns: 1fr; }
  .tl-detail { grid-column: 1; }
  .step-row { grid-template-columns: 1fr; }
  .step-oval { width: max-content; }

  /* Card-fold headers: eyebrow on its own row above icon+title+toggle */
  .card-fold-summary {
    flex-wrap: wrap;
    gap: 6px 10px;
    padding: 10px 12px;
    align-items: center;
  }
  .card-fold-eyebrow {
    flex-basis: 100%;
    order: 0;
    padding-right: 0;
    border-right: 0;
    margin-right: 0;
    font-size: 9.5px;
    letter-spacing: 0.06em;
    white-space: normal;
    word-break: break-word;
    line-height: 1.35;
  }
  .card-fold-icon { order: 1; flex-shrink: 0; }
  .card-fold-title {
    order: 2;
    flex: 1 1 0;
    min-width: 0;
    font-size: 13px;
    line-height: 1.3;
    word-break: break-word;
  }
  .card-fold-toggle { order: 3; flex-shrink: 0; }
}

/* =================================================================
   ENTITY FOLD - inline +/- collapsible for each entity card
   replaces the old modal popup pattern
================================================================= */
details.entity-fold {
  display: block;
  margin: 0;
  list-style: none;
}
details.entity-fold > summary.entity-fold-summary {
  list-style: none;
  cursor: pointer;
  position: relative;
  /* Preserve the existing card layout exactly: use the SAME grid as before */
}
details.entity-fold > summary.entity-fold-summary::-webkit-details-marker { display: none; }
details.entity-fold > summary.entity-fold-summary::marker { content: ''; }

/* Toggle button - a small + that becomes x when open */
.entity-fold-toggle {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid var(--rule);
  background: var(--paper);
  display: inline-grid;
  place-items: center;
  z-index: 2;
}
.entity-fold-toggle::before,
.entity-fold-toggle::after {
  content: '';
  position: absolute;
  background: var(--ink);
  transition: transform .2s ease;
}
.entity-fold-toggle::before { width: 10px; height: 2px; }
.entity-fold-toggle::after  { width: 2px; height: 10px; }
details.entity-fold[open] > summary > .entity-fold-toggle { background: var(--ink); border-color: var(--ink); }
details.entity-fold[open] > summary > .entity-fold-toggle::before,
details.entity-fold[open] > summary > .entity-fold-toggle::after { background: white; }
details.entity-fold[open] > summary > .entity-fold-toggle::after { transform: rotate(90deg); }

/* Inline body shown when entity-fold is open */
.entity-fold-body {
  padding: 14px 16px 18px;
  border-top: 1px solid var(--rule);
  background: var(--paper);
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink);
  animation: foldIn .18s ease-out;
}
@keyframes foldIn {
  from { opacity: 0; transform: translateY(-2px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Inline body content styles */
.inline-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 24px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}
.inline-detail-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 3px;
}
.inline-detail-big {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}
.inline-detail-of {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.inline-detail-mid {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
}
.inline-detail-para {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink-2);
}
.inline-detail-h {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 14px 0 6px;
}
.inline-detail-list {
  margin: 0 0 12px;
  padding-left: 18px;
}
.inline-detail-list li {
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.55;
}
.inline-leverage {
  background: var(--tint-lev);
  border-left: 3px solid var(--c-lev);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  margin: 8px 0 12px;
  border-radius: 0 4px 4px 0;
}
.inline-effect {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  margin-bottom: 6px;
}
.inline-effect-name { font-weight: 700; font-size: 13px; }
.inline-effect-note { font-size: 12px; color: var(--muted); }
.inline-effect-score {
  font-weight: 800;
  font-size: 18px;
  color: var(--ink);
  font-family: 'JetBrains Mono', monospace;
}
.inline-fact-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--rule);
}
.inline-fact-k {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.inline-fact-v {
  font-weight: 600;
  font-size: 13px;
}
.step-body-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

/* Make sure the legacy cluster grid still works inside summary */
.entity-fold-summary.cluster {
  display: grid;
  grid-template-columns: 80px 1fr 160px;
  gap: 16px;
  padding: 16px 44px 16px 18px; /* extra right padding for +/- */
  background: var(--paper);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--cluster-color, var(--ink));
  border-radius: 6px;
  margin-bottom: 8px;
  position: relative;
  align-items: center;
}
.entity-fold-summary.cluster:hover { background: var(--paper-2); }
details.cluster-fold { margin-bottom: 8px; }
details.cluster-fold[open] > summary.entity-fold-summary.cluster {
  border-radius: 6px 6px 0 0;
  margin-bottom: 0;
  border-bottom: none;
}
details.cluster-fold[open] > .entity-fold-body {
  border: 1px solid var(--rule);
  border-top: none;
  border-left: 3px solid var(--cluster-color, var(--ink));
  border-radius: 0 0 6px 6px;
  margin-bottom: 8px;
}

/* Flow-fold (impact cards) */
.entity-fold-summary.flow-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 36px 12px 14px;
  position: relative;
}
details.flow-fold {
  border: 1px solid var(--rule);
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
}
details.flow-fold[open] {
  border-color: var(--cluster-color, var(--rule));
}

/* Step-fold */
.entity-fold-summary.step-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 18px;
  padding: 14px 40px 14px 0;
  align-items: flex-start;
  position: relative;
}
details.step-fold {
  margin-bottom: 4px;
}
details.step-fold > .entity-fold-body.step-body {
  margin-left: 130px; /* align with step content, not the oval */
  border-left: 3px solid var(--step-color, var(--ink));
  border-radius: 4px;
  margin-bottom: 12px;
}
/* The toggle on step-fold sits to the right of the step card */
.entity-fold-summary.step-row > .entity-fold-toggle {
  top: 18px;
  right: 6px;
}

/* Dam-fold */
.entity-fold-summary.dam {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 36px 12px 14px;
  position: relative;
}
.dam-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
details.dam-fold {
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--paper);
}
details.dam-fold[open] {
  border-color: var(--ink-3);
  grid-column: 1 / -1;
  background: var(--paper);
}
details.dam-fold[open] > summary.dam {
  border-bottom: 1px solid var(--rule);
}
details.dam-fold[open] .dam-main {
  flex-direction: row;
  gap: 14px;
  align-items: baseline;
  flex-wrap: wrap;
}

/* On mobile, fact rows stack */
@media (max-width: 640px) {
  .inline-detail-grid { grid-template-columns: 1fr 1fr; }
  .inline-fact-row { grid-template-columns: 1fr; gap: 2px; }
  .entity-fold-summary.cluster { grid-template-columns: 56px 1fr; padding: 12px 40px 12px 12px; }
  .entity-fold-summary.cluster .cluster-score {
    grid-column: 1 / -1;
    border-left: none;
    border-top: 1px solid var(--rule);
    padding-top: 8px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 12px;
  }
  details.step-fold > .entity-fold-body.step-body { margin-left: 0; }
  .entity-fold-summary.step-row { grid-template-columns: 1fr; }
}

/* ============ Document upload — control bar button + modal ============ */
.ctrl-btn-upload {
  background: linear-gradient(180deg, rgba(78,195,255,0.12), rgba(78,195,255,0.06));
  border-color: rgba(78,195,255,0.55);
  color: #4ec3ff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.ctrl-btn-upload:hover {
  background: rgba(78,195,255,0.22);
  border-color: rgba(78,195,255,0.85);
}
.ctrl-btn-upload svg { stroke: currentColor; }
.upload-label { font-size: 12px; }
@media (max-width: 720px) { .upload-label { display: none; } }

.upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 9, 16, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 6vh 16px 24px;
  overflow-y: auto;
  animation: upload-fade-in 160ms ease-out;
}
.upload-overlay[hidden] { display: none; }
@keyframes upload-fade-in { from { opacity: 0; } to { opacity: 1; } }

.upload-modal {
  width: 100%;
  max-width: 640px;
  background: #0d1117;
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 14px;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
.upload-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}
.upload-modal-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.upload-modal-sub {
  margin: 0;
  font-size: 13px;
  color: #8b949e;
  line-height: 1.5;
}
.upload-modal-close {
  background: transparent;
  border: 1px solid #30363d;
  color: #8b949e;
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms, color 120ms;
  flex-shrink: 0;
}
.upload-modal-close:hover {
  background: rgba(248, 81, 73, 0.12);
  color: #f85149;
  border-color: rgba(248, 81, 73, 0.5);
}
.upload-modal-foot {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: #8b949e;
  min-height: 18px;
}
