/* Topic pages — designer v2 styling */

.page-topic {
  --topic-accent: var(--green-600);
  background: var(--bg);
  padding-top: 0;
}

.page-topic[data-accent="green"] { --topic-accent: #0e774b; }
.page-topic[data-accent="gold"] { --topic-accent: #b8860b; }
.page-topic[data-accent="amber"] { --topic-accent: #c8a036; }
.page-topic[data-accent="brown"] { --topic-accent: #8a5a2b; }
.page-topic[data-accent="lime"] { --topic-accent: #65a30d; }
.page-topic[data-accent="teal"] { --topic-accent: #0d9488; }
.page-topic[data-accent="violet"] { --topic-accent: #6d4c9a; }
.page-topic[data-accent="sky"] { --topic-accent: #0284c7; }
.page-topic[data-accent="slate"] { --topic-accent: #475569; }
.page-topic[data-accent="orange"] { --topic-accent: #c76a1a; }
.page-topic[data-accent="blue"] { --topic-accent: #2563eb; }
.page-topic[data-accent="soil"] { --topic-accent: #8a5a2b; }

.page-topic .main.stack,
.page-topic .shell.stack { gap: 12px; padding-top: 6px; padding-bottom: 32px; }

.page-kpi-band { margin-top: 6px; }

.page-kpi-grid--5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .page-kpi-grid--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
  .page-kpi-grid--5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Topic pages: full executive headline with compact live metadata */
.hero--page {
  border-bottom: 0;
  background: linear-gradient(180deg, #edf5f2 0%, var(--bg) 100%);
}

.hero--page .shell {
  padding-top: 24px;
  padding-bottom: 14px;
}

.hero--page .hero__bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 0;
  padding-bottom: 16px;
  border-bottom: 2px solid rgba(24, 76, 90, 0.15);
}

.hero__titles {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 820px;
}

.hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: #1e6350;
}

.hero__brand-badge {
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(24, 76, 90, .1);
  color: #184c5a;
  font-size: 9.5px;
  font-weight: 750;
  letter-spacing: .06em;
}

.hero--page .hero__page-title {
  margin: 0;
  font-size: clamp(28px, 2.9vw, 42px);
  font-weight: 850;
  line-height: 1.06;
  letter-spacing: -.035em;
  color: #0f3339;
  text-wrap: balance;
}

.hero--page .hero__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 2px;
}

.hero--page .chip--meta {
  min-height: 32px;
  padding: 0 14px;
  background: #ffffff;
  border: 1px solid #d4dfda;
  border-radius: 999px;
  box-shadow: 0 2px 6px rgba(15, 51, 57, .04);
  font-size: 11.5px;
  font-weight: 700;
  color: #274b52;
}

.hero--page .chip--meta svg {
  width: 13px;
  height: 13px;
  color: #10b981;
}

@media (max-width: 720px) {
  .hero--page .hero__headline {
    white-space: normal;
    flex-wrap: wrap;
  }

  .hero--page .shell { padding-top: 15px; }
  .hero--page .hero__bar { align-items: flex-start; flex-direction: column; gap: 14px; }
  .hero--page .hero__page-title { width: 100%; font-size: 30px; }
  .hero--page .hero__meta { width: 100%; justify-content: flex-start; margin-left: 0; }

  .page-topic .shell.stack { padding-top: 6px; }
}

/* --- Legacy topic hero (unused) --------------------------------------- */
.hero--topic {
  border-bottom: 2px solid var(--green-600);
  background: var(--bg);
}

.hero--topic::after { opacity: .1; }

.hero--topic .shell {
  padding-top: 22px;
  padding-bottom: 18px;
}

.hero-topic__main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 28px;
  flex-wrap: wrap;
}

.hero-topic__eyebrow {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--green-600);
}

.hero-topic__title {
  margin: 0;
  font-size: clamp(2rem, 3.8vw, 2.65rem);
  font-weight: 800;
  letter-spacing: -.035em;
  color: var(--green-900);
  line-height: 1.02;
}

.hero-topic__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 6px;
}

.hero-topic__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.topic-sources--inline { display: none; }

@media (max-width: 720px) {
  .hero--topic .shell { padding-top: 18px; padding-bottom: 14px; }
  .hero-topic__title { font-size: clamp(1.65rem, 7vw, 2rem); }
  .hero-topic__actions { width: 100%; padding-bottom: 0; }
  .hero-topic__meta { margin-top: 12px; padding-top: 12px; }
}

/* --- Legacy topic hero ------------------------------------------------ */
.topic-hero {
  background: var(--bg);
  border-bottom: none;
  padding: 24px 0 0;
}

.topic-hero__row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.topic-hero__eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--green-600);
}

.topic-hero__title {
  margin: 0;
  font-size: clamp(1.75rem, 3.2vw, 2.35rem);
  font-weight: 800;
  letter-spacing: -.03em;
  color: var(--green-900);
  line-height: 1.05;
}

.topic-hero__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}

.topic-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--green-100);
  color: var(--green-800);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.topic-hero__cta {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--green-800);
  color: var(--green-800);
  font-size: 12px;
  font-weight: 650;
  background: #fff;
  transition: background .15s ease, border-color .15s ease;
}

.topic-hero__cta:hover {
  background: #fff;
  border-color: var(--green-600);
}

.topic-hero__kadic {
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.topic-hero__kadic summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--green-800);
}

.topic-hero__kadic summary::-webkit-details-marker { display: none; }

.topic-hero__kadic-chev {
  width: 14px;
  height: 14px;
  opacity: .55;
  transition: transform .18s ease;
  flex: none;
}

.topic-hero__kadic[open] .topic-hero__kadic-chev { transform: rotate(180deg); }

.topic-hero__kadic-body {
  margin: 0;
  padding: 0 18px 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.topic-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 18px 14px;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(14, 119, 75, 0.08);
  color: var(--green-800);
  border: 1px solid rgba(14, 119, 75, 0.14);
}

.source-chip--gap {
  background: rgba(200, 160, 54, 0.12);
  color: #7a5b12;
  border-color: rgba(200, 160, 54, 0.22);
}

/* --- KPI strip -------------------------------------------------------- */
.page-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.page-kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 1px 0 rgba(26, 51, 56, .03);
}

.page-kpi[data-tint="green"] { border-top: 3px solid #0e774b; }
.page-kpi[data-tint="gold"] { border-top: 3px solid #c8a036; }
.page-kpi[data-tint="amber"] { border-top: 3px solid #c8a036; }
.page-kpi[data-tint="violet"] { border-top: 3px solid #6d4c9a; }
.page-kpi[data-tint="teal"] { border-top: 3px solid #0d9488; }
.page-kpi[data-tint="blue"] { border-top: 3px solid #2563eb; }
.page-kpi[data-tint="brown"] { border-top: 3px solid #8a5a2b; }

.page-kpi__label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.page-kpi__value {
  display: block;
  font-size: clamp(1.45rem, 2.4vw, 1.85rem);
  font-weight: 800;
  line-height: 1.05;
  color: var(--ink);
}

.page-kpi__unit,
.page-kpi__note {
  display: block;
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}

.page-kpi__delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--green-600);
}

.page-kpi__delta.is-down { color: #c2410c; }

/* --- Sections & tiles ------------------------------------------------- */
.page-topic .topic-section { margin-top: 0; }

.page-topic .section {
  border-radius: 16px;
  border-color: var(--line);
  box-shadow: 0 1px 0 rgba(26, 51, 56, .03);
}

.page-topic .section__head {
  background: #fff;
  padding: 14px 18px;
  border-bottom-color: var(--line-2);
}

.page-topic .section__title h3 {
  font-size: 15px;
  font-weight: 750;
  color: var(--green-900);
}

.page-topic .section__title .tick {
  background: var(--topic-accent);
  height: 18px;
}

.page-topic .section__sub {
  font-size: 11.5px;
  color: var(--muted);
}

.page-topic .tile {
  border-radius: 14px;
  border-color: var(--line);
}

.page-topic .tile__head {
  background: #fafcfb;
  border-bottom: 1px solid var(--line-2);
}

.page-topic .tile__head h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-2);
}

.topic-grid { display: grid; gap: 16px; }
.topic-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.topic-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.topic-grid--hero { grid-template-columns: 1.2fr 0.8fr; }
.topic-grid--split { grid-template-columns: 1fr 1fr; gap: 20px; }

/* --- Insights & narrative cards -------------------------------------- */
.insights-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.insights-section__head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
  color: var(--green-900);
}

.insight-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.insight-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  border-left: 4px solid var(--topic-accent);
}

.insight-card[data-severity="warning"] { border-left-color: #c8a036; }
.insight-card[data-severity="critical"] { border-left-color: #dc2626; }

.insight-card__title {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 6px;
  color: var(--green-900);
}

.insight-card__body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  margin: 0;
}

.narrative-card {
  background: linear-gradient(135deg, var(--green-800), var(--green-900));
  color: #fff;
  border-radius: 16px;
  padding: 22px 24px;
  margin-top: 8px;
}

.narrative-card__eyebrow {
  margin: 0 0 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .55);
}

.narrative-card__title {
  margin: 0 0 10px;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.25;
}

.narrative-card__body {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: rgba(255, 255, 255, .78);
}

.narrative-card__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.narrative-stat {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  padding: 12px 14px;
}

.narrative-stat__value {
  display: block;
  font-size: 1.25rem;
  font-weight: 800;
  line-height: 1.1;
}

.narrative-stat__label {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: rgba(255, 255, 255, .62);
}

/* --- Locked band ------------------------------------------------------ */
.locked-band {
  margin-top: 8px;
  border: 1px dashed rgba(24, 76, 90, .28);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(14, 119, 75, .04), rgba(200, 160, 54, .07));
}

.locked-band__inner {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 16px;
  align-items: center;
  padding: 20px 22px;
}

.locked-band__icon svg { width: 28px; height: 28px; color: var(--green-800); }
.locked-band__copy strong { display: block; font-size: 14px; margin-bottom: 4px; color: var(--green-900); }
.locked-band__copy p { margin: 0; font-size: 13px; color: var(--muted); }
.locked-band__modules { display: flex; flex-wrap: wrap; gap: 6px; }
.locked-band__item {
  font-size: 11px;
  font-weight: 600;
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .88);
  border: 1px solid var(--line);
}

/* --- Data viz helpers ------------------------------------------------- */
.compare-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.compare-col {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--card);
}
.compare-col--left { border-top: 4px solid #0e774b; }
.compare-col--right { border-top: 4px solid #c8a036; }
.compare-col__head { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.compare-col__head h4 { margin: 0 0 4px; font-size: 15px; }
.compare-col__total { font-size: 28px; font-weight: 800; color: var(--ink); }
.compare-col__head p { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.compare-col__body { padding: 14px 18px 18px; display: grid; gap: 10px; }
.compare-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line-2);
  margin-bottom: 16px;
}
.compare-bar__cig, .compare-bar__vmg { display: block; height: 100%; transition: width .6s ease; }
.compare-bar__cig { background: #0e774b; }
.compare-bar__vmg { background: #c8a036; }

.funnel-step {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 14px;
  margin-bottom: 8px;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(200, 160, 54, .12) var(--w), transparent var(--w));
  border: 1px solid rgba(200, 160, 54, .18);
}
.funnel-step__label { font-size: 13px; font-weight: 600; }
.funnel-step__value { font-weight: 800; }
.funnel-step__rate { font-size: 12px; color: var(--muted); }

.gauge { text-align: center; padding: 8px 0; }
.gauge svg { width: 140px; height: auto; display: block; margin: 0 auto; }
.gauge__track { fill: none; stroke: var(--line-2); stroke-width: 10; stroke-linecap: round; }
.gauge__fill { fill: none; stroke: var(--topic-accent); stroke-width: 10; stroke-linecap: round; }
.gauge__value { display: block; font-size: 24px; font-weight: 800; margin-top: -8px; }
.gauge__label { font-size: 12px; color: var(--muted); }

.heatmap { width: 100%; border-collapse: collapse; font-size: 11px; }
.heatmap th, .heatmap td { padding: 8px 6px; border: 1px solid var(--line); text-align: center; }
.heatmap th { background: #f8faf9; font-weight: 600; }
.heatmap td { background: rgba(14, 119, 75, calc(0.08 + var(--heat) * 0.72)); }

.age-pyramid { display: grid; gap: 8px; }
.age-row {
  display: grid;
  grid-template-columns: 80px 1fr 48px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.age-row__bar { height: 8px; border-radius: 999px; background: var(--line-2); overflow: hidden; }
.age-row__bar i { display: block; height: 100%; background: var(--topic-accent); border-radius: inherit; }

.vc-mosaic {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}
.vc-mosaic__item {
  border-radius: 12px;
  padding: 14px;
  color: #fff;
  min-height: 88px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.vc-mosaic__label { font-size: 12px; opacity: .92; }
.vc-mosaic__value { font-size: 20px; font-weight: 800; }

.network-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.network-stat {
  text-align: center;
  padding: 16px;
  border-radius: 12px;
  background: #f7faf9;
  border: 1px solid rgba(24, 76, 90, .12);
}
.network-stat__value { font-size: 24px; font-weight: 800; color: var(--green-800); }
.network-stat__label { font-size: 12px; color: var(--muted); }

.ledger-metric {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.ledger-metric:last-child { border-bottom: 0; }
.ledger-metric__label { font-size: 13px; color: var(--muted); }
.ledger-metric__value { font-size: 18px; font-weight: 800; }

.page-topic .ltable thead th {
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  background: #f8faf9;
}

.page-topic .ltable tbody tr:hover {
  background: rgba(14, 119, 75, .04);
}

.page-topic .dist__inner { grid-template-columns: 1.1fr 0.9fr; }

.page-error {
  margin-bottom: 20px;
  padding: 16px 18px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  border-radius: 12px;
  font-size: 13px;
}

@media (max-width: 960px) {
  .topic-grid--2,
  .topic-grid--3,
  .topic-grid--hero,
  .topic-grid--split,
  .compare-split { grid-template-columns: 1fr; }
  .locked-band__inner { grid-template-columns: 1fr; }
  .network-stats { grid-template-columns: 1fr; }
  .page-topic .dist__inner { grid-template-columns: 1fr; }
}

/* --- Topic Pages Situation Room Dark Mode --- */
body.is-war-room-mode .page-topic {
  background: #07191d !important;
  color: #e2e8f0;
}

body.is-war-room-mode .hero--page {
  background: linear-gradient(180deg, #0b2227 0%, #07191d 100%) !important;
}

body.is-war-room-mode .hero--page .hero__page-title {
  color: #38bdf8 !important;
  text-shadow: 0 0 20px rgba(56, 189, 248, .3);
}

body.is-war-room-mode .hero--page .chip--meta {
  background: #0b2227 !important;
  border-color: rgba(255, 255, 255, .15) !important;
  color: #cbd5e1 !important;
}

body.is-war-room-mode .design-kpi,
body.is-war-room-mode .page-kpi,
body.is-war-room-mode .design-panel,
body.is-war-room-mode .design-split-banner__seg {
  background: #0b2227 !important;
  border-color: rgba(255, 255, 255, .12) !important;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4) !important;
  color: #e2e8f0 !important;
}

body.is-war-room-mode .design-kpi__value,
body.is-war-room-mode .page-kpi__value,
body.is-war-room-mode .design-split-banner__seg strong {
  color: #38bdf8 !important;
}

body.is-war-room-mode .design-kpi__label,
body.is-war-room-mode .page-kpi__label,
body.is-war-room-mode .design-panel__sub {
  color: #94a3b8 !important;
}

body.is-war-room-mode .design-panel__head {
  background: #0d282f !important;
  border-bottom-color: rgba(255, 255, 255, .1) !important;
}

body.is-war-room-mode .design-panel__head h3 {
  color: #f1f5f9 !important;
}

body.is-war-room-mode .design-panel__foot {
  background: #091c20 !important;
  border-top-color: rgba(255, 255, 255, .1) !important;
}

body.is-war-room-mode .design-table th,
body.is-war-room-mode .ltable th {
  color: #94a3b8 !important;
  border-bottom-color: rgba(255, 255, 255, .1) !important;
  background: #0d282f !important;
}

body.is-war-room-mode .design-table td,
body.is-war-room-mode .ltable td {
  color: #e2e8f0 !important;
  border-bottom-color: rgba(255, 255, 255, .06) !important;
}
