:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #eef3f6;
  --text: #17202a;
  --muted: #66717f;
  --line: #dce3ea;
  --blue: #345995;
  --teal: #1f7a6b;
  --amber: #b56b1d;
  --red: #b94141;
  --green: #3f7d42;
  --shadow: 0 12px 32px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 248, 0.94);
  backdrop-filter: blur(14px);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.05;
  letter-spacing: 0;
}

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

h2 {
  margin-bottom: 4px;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 48px);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
}

.range-button,
.secondary-button {
  min-height: 36px;
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.range-button {
  border-right: 1px solid var(--line);
}

.range-button:last-child {
  border-right: 0;
}

.range-button.active {
  color: #fff;
  background: var(--blue);
}

.secondary-button {
  min-width: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  color: var(--text);
  text-decoration: none;
}

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 42px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 118px;
  padding: 18px;
}

.metric-card.factor-flagged {
  border-color: rgba(185, 65, 65, 0.55);
  background: #fff9f9;
}

.metric-label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1;
  letter-spacing: 0;
}

.metric-card small {
  color: var(--muted);
  font-size: 13px;
}

.forecast-panel {
  margin-bottom: 14px;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.forecast-card {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.forecast-card span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.forecast-card strong {
  display: block;
  margin-bottom: 7px;
  font-size: 28px;
  line-height: 1;
}

.forecast-card small {
  color: var(--muted);
  font-size: 12px;
}

.forecast-table-wrap {
  margin-bottom: 0;
}

.overlap-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.headline-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 20px;
  margin-bottom: 14px;
  padding: 18px;
}

.model-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 14px;
  padding: 22px;
}

.hero-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.hero-main h2 {
  margin: 10px 0 8px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.05;
}

.hero-side {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-stat {
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.mini-stat span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.mini-stat strong {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.regime-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  min-height: 34px;
  padding: 7px 11px;
  border-radius: 999px;
  color: #fff;
  background: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.regime-normal {
  background: var(--teal);
}

.regime-watch {
  background: var(--amber);
}

.regime-elevated {
  background: #9b5c18;
}

.regime-high-risk {
  background: var(--red);
}

.regime-extreme {
  background: #4b1b1b;
}

.regime-unknown {
  background: var(--muted);
}

.evidence-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 18px;
  margin-bottom: 14px;
  padding: 18px;
}

.evidence-rows {
  display: grid;
  gap: 8px;
}

.evidence-row {
  display: grid;
  grid-template-columns: 150px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.evidence-row strong {
  font-size: 13px;
}

.evidence-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.signal-pill {
  min-width: 86px;
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.signal-supportive {
  background: var(--teal);
}

.signal-adverse {
  background: var(--red);
}

.signal-mixed {
  color: #344252;
  background: #ddd8ca;
}

.signal-missing,
.signal-stale {
  color: #344252;
  background: #d6d0c1;
}

.bar-label .signal-supportive,
.bar-label .signal-adverse,
.bar-label .signal-mixed,
.bar-label .signal-missing {
  background: transparent;
}

.bar-label .signal-supportive {
  color: var(--teal);
}

.bar-label .signal-adverse {
  color: var(--red);
}

.bar-label .signal-mixed,
.bar-label .signal-missing {
  color: var(--muted);
}

.current-read {
  max-width: 980px;
  margin-bottom: 0;
  color: #344252;
  line-height: 1.5;
}

.flag-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: 460px;
}

.flag {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: #344252;
  background: var(--panel-soft);
  font-size: 12px;
  font-weight: 700;
}

.flag.on {
  color: #fff;
  border-color: transparent;
  background: var(--teal);
}

.flag.warn {
  color: #fff;
  border-color: transparent;
  background: var(--amber);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 14px;
}

.primary-grid {
  margin-top: 14px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.wide {
  grid-column: 1 / -1;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.panel-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.chart {
  width: 100%;
  min-height: 360px;
}

.chart.compact {
  min-height: 300px;
}

.chart svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.recession-swatch {
  border: 1px solid rgba(102, 113, 127, 0.35);
  background: rgba(102, 113, 127, 0.18);
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.x-axis-label {
  font-size: 10px;
}

.axis-tick {
  stroke: #9aa7b4;
  stroke-width: 1;
}

.recession-band {
  fill: rgba(102, 113, 127, 0.14);
}

.grid-line {
  stroke: #e4e1d7;
  stroke-width: 1;
}

.zero-line {
  stroke: #a9a397;
  stroke-width: 1.2;
  stroke-dasharray: 4 4;
}

.line-path {
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bar-stack {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.layer-section {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.layer-section h3 {
  margin: 0 0 10px;
  font-size: 13px;
}

.layer-section .bar-row {
  margin-bottom: 8px;
}

.layer-section .bar-row:last-child {
  margin-bottom: 0;
}

.bar-row {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #344252;
  font-size: 13px;
  font-weight: 700;
}

.bar-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #e7e3d7;
  overflow: hidden;
}

.bar-zero {
  position: absolute;
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
  background: rgba(23, 32, 42, 0.35);
}

.bar-fill {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 999px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.policy-panel,
.source-list,
.method-grid {
  display: grid;
  gap: 10px;
}

.policy-item,
.source-item,
.method-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.policy-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.policy-item strong,
.source-item strong,
.method-card strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.policy-pill {
  min-width: 54px;
  padding: 5px 8px;
  border-radius: 999px;
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.policy-pill.yes {
  background: var(--teal);
}

.policy-pill.no {
  background: var(--red);
}

.source-item a {
  color: var(--blue);
  text-decoration: none;
  word-break: break-word;
}

.freshness-table td,
.freshness-table th,
.validation-table td,
.validation-table th {
  white-space: normal;
}

.validation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 14px;
}

.leading-validation-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.leading-state {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.leading-state-item {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.leading-state-item strong {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.leading-state-item span {
  color: #344252;
  font-size: 18px;
  font-weight: 800;
}

.direction-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.direction-pill.expected {
  background: var(--teal);
}

.direction-pill.contrary {
  background: var(--amber);
}

.staleness-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 7px;
  border-radius: 999px;
  color: #344252;
  background: #ddd8ca;
  font-size: 11px;
  font-weight: 800;
}

.staleness-pill.stale {
  color: #fff;
  background: var(--amber);
}

.source-item small,
.method-card small {
  color: var(--muted);
  line-height: 1.4;
}

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

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

.regime-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 7px;
  border-radius: 999px;
  vertical-align: middle;
}

.appendix-panel {
  margin-bottom: 0;
}

.appendix-panel summary {
  cursor: pointer;
  color: #344252;
  font-size: 14px;
  font-weight: 900;
}

.appendix-panel[open] summary {
  margin-bottom: 12px;
}

.appendix-rows {
  margin-top: 12px;
}

.appendix-rows .signal-pill {
  min-width: 0;
  text-transform: none;
}

.historical-panel {
  margin-bottom: 14px;
}

.historical-chart {
  min-height: 430px;
}

.historical-stat-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.historical-stat-card {
  min-height: 92px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.historical-stat-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.historical-stat-card strong {
  display: block;
  margin-bottom: 7px;
  font-size: 26px;
  line-height: 1;
}

.historical-stat-card small,
.event-table small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.drawdown-band {
  pointer-events: none;
}

.drawdown-band.correction {
  fill: rgba(181, 107, 29, 0.13);
}

.drawdown-band.major {
  fill: rgba(185, 65, 65, 0.14);
}

.drawdown-swatch.correction {
  background: rgba(181, 107, 29, 0.5);
}

.drawdown-swatch.major {
  background: rgba(185, 65, 65, 0.55);
}

.risk-threshold-line {
  stroke: rgba(185, 65, 65, 0.26);
  stroke-dasharray: 6 5;
  stroke-width: 1;
}

.drawdown-line {
  stroke-width: 2.2;
  stroke-dasharray: 5 4;
}

.event-table th:nth-child(8),
.event-table td:nth-child(8) {
  min-width: 310px;
  white-space: normal;
}

.severity-pill,
.prediction-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.severity-pill.correction {
  color: #6c3f0e;
  background: rgba(181, 107, 29, 0.16);
}

.severity-pill.major {
  color: #842b2b;
  background: rgba(185, 65, 65, 0.16);
}

.prediction-pill.yes {
  color: #842b2b;
  background: rgba(185, 65, 65, 0.16);
}

.prediction-pill.partial {
  color: #6c3f0e;
  background: rgba(181, 107, 29, 0.16);
}

.prediction-pill.no {
  color: #215f4f;
  background: rgba(31, 122, 107, 0.15);
}

.prediction-pill.n\/a {
  color: var(--muted);
  background: rgba(102, 113, 127, 0.13);
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--red);
}

.neutral {
  color: var(--muted);
}

.paper-card pre {
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.paper-card pre code,
.paper-card p code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

@media (max-width: 1050px) {
  .summary-grid,
  .dashboard-grid,
  .bar-stack,
  .method-grid,
  .leading-validation-grid,
  .model-hero,
  .compact-method-grid,
  .overlap-grid,
  .forecast-grid,
  .historical-stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dashboard-grid .wide {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar,
  .headline-panel {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar {
    position: static;
    padding: 16px;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .page {
    padding: 16px;
  }

  .summary-grid,
  .dashboard-grid,
    .bar-stack,
    .method-grid,
    .compact-method-grid,
    .validation-grid,
    .leading-validation-grid,
    .leading-state,
    .evidence-panel,
    .model-hero,
    .hero-side,
    .overlap-grid,
    .forecast-grid,
    .historical-stat-grid {
    grid-template-columns: 1fr;
  }

  .evidence-row {
    grid-template-columns: 1fr;
  }

  .flag-strip {
    justify-content: flex-start;
  }

  .chart,
  .chart.compact {
    min-height: 280px;
  }
}
