:root {
  --bg: #f1ede3;
  --ink: #242722;
  --muted: #646b5f;
  --line: #d9ddcf;
  --panel: #ffffff;
  --soft: #eef1e7;
  --gold: #b4813f;
  --green: #3a785e;
  --red: #b96043;
  --blue: #315f8d;
  --shadow: 0 16px 40px rgba(31, 35, 26, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 0%, rgba(180, 129, 63, 0.12), transparent 32%),
    var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.eyebrow,
.label {
  margin: 0 0 6px;
  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(30px, 5vw, 58px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
  letter-spacing: 0;
}

.timestamp {
  min-width: 230px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  border-radius: 8px;
}

.timestamp span,
.metric span,
.confidence span,
.data-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.timestamp strong {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

.timestamp small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

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

.timestamp button {
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
  cursor: pointer;
}

.timestamp button:hover,
.timestamp button:focus-visible {
  border-color: var(--gold);
  outline: none;
}

.timestamp button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

.stance-panel,
.band,
.panel {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.stance-panel {
  padding: 22px;
}

.stance-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.stance {
  font-size: clamp(34px, 6vw, 72px);
  font-weight: 820;
  line-height: 1;
  letter-spacing: 0;
}

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

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

.stance.neutral {
  color: var(--gold);
}

.confidence {
  min-width: 92px;
  padding: 12px;
  text-align: center;
  background: var(--soft);
  border-radius: 8px;
}

.confidence strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.score-meter {
  margin-top: 20px;
}

.meter-track {
  position: relative;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), #d1b45f, var(--green));
}

.meter-mid {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  background: rgba(255, 255, 255, 0.85);
}

.meter-needle {
  position: absolute;
  top: -4px;
  width: 6px;
  height: 24px;
  border-radius: 4px;
  background: var(--ink);
  transform: translateX(-3px);
}

.meter-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary {
  margin: 20px 0 0;
  color: #30352d;
  line-height: 1.65;
}

.metric,
.score-explainer {
  padding: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 118px;
}

.metric strong {
  display: block;
  margin-top: 16px;
  font-size: 30px;
  line-height: 1;
}

.compact-metric {
  min-height: 86px;
}

.compact-metric strong {
  margin-top: 10px;
  font-size: 26px;
}

.score-explainer {
  display: flex;
  min-height: 100%;
  flex-direction: column;
  justify-content: center;
}

.score-result {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.score-result strong {
  font-size: clamp(44px, 6vw, 72px);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.score-result span {
  color: var(--muted);
  font-weight: 800;
}

.score-formula {
  margin: 18px 0 10px;
  font-weight: 780;
}

.score-bands {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  overflow: hidden;
  border-radius: 6px;
  color: #fff;
  font-size: 9px;
  font-weight: 750;
  text-align: center;
}

.score-bands span {
  padding: 8px 3px;
  background: var(--red);
}

.score-bands span:nth-child(2) { background: #c98c68; }
.score-bands span:nth-child(3) { background: #8b9188; }
.score-bands span:nth-child(4) { background: #6d9b82; }
.score-bands span:nth-child(5) { background: var(--green); }

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

.band,
.panel {
  padding: 20px;
  margin-bottom: 16px;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.section-head p {
  max-width: 520px;
  margin-bottom: 2px;
  color: var(--muted);
  line-height: 1.5;
}

.section-head.compact {
  display: block;
}

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

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

.horizon-card {
  min-height: 320px;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 5px solid var(--gold);
  border-radius: 8px;
  background: #fbfcf8;
}

.horizon-card.positive {
  border-top-color: var(--green);
}

.horizon-card.negative {
  border-top-color: var(--red);
}

.horizon-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  min-height: 58px;
}

.horizon-head span,
.horizon-score span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.horizon-head h3 {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.15;
}

.horizon-head > strong {
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--soft);
  font-size: 14px;
}

.horizon-score {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.horizon-score strong {
  font-size: 32px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.horizon-score small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.horizon-forecast {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.horizon-forecast strong {
  float: right;
  color: var(--ink);
}

.horizon-card ul {
  margin: 14px 0 12px;
  padding-left: 18px;
  color: #30352d;
  line-height: 1.55;
}

.horizon-card li + li {
  margin-top: 5px;
}

.horizon-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.news-overview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 220px));
  gap: 12px;
  margin-bottom: 12px;
}

.news-list {
  display: grid;
  gap: 12px;
}

.news-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gold);
  border-radius: 8px;
  background: #fbfcf8;
}

.news-card.positive {
  border-left-color: var(--green);
}

.news-card.negative {
  border-left-color: var(--red);
}

.news-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.news-head span,
.news-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.news-head a {
  display: block;
  margin-top: 5px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 750;
  line-height: 1.35;
  text-decoration: none;
}

.news-head a:hover {
  color: var(--blue);
}

.news-head > strong {
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--soft);
  font-size: 13px;
  white-space: nowrap;
}

.news-card ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.news-card li {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.news-card li strong,
.news-card li span {
  display: inline-block;
  margin-right: 8px;
}

.news-card li span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.news-card li p {
  margin: 6px 0 0;
  color: #30352d;
  font-size: 13px;
  line-height: 1.45;
}

.data-card {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.data-card strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 24px;
  line-height: 1;
}

.data-card small {
  color: var(--muted);
  line-height: 1.35;
}

.data-state {
  display: inline-block;
  margin-top: 10px;
  padding: 3px 6px;
  border-radius: 5px;
  color: var(--green);
  background: rgba(58, 120, 94, 0.1);
  font-size: 10px;
  font-style: normal;
  font-weight: 800;
}

.data-state.cached,
.data-state.partial {
  color: #8b622d;
  background: rgba(180, 129, 63, 0.12);
}

.factor-list {
  display: grid;
  gap: 12px;
}

.factor-row {
  display: grid;
  grid-template-columns: 160px minmax(180px, 1fr) 88px;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.factor-name strong {
  display: block;
  font-size: 16px;
}

.factor-name small {
  color: var(--muted);
}

.bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: #e5e9dc;
}

.bar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -4px;
  width: 1px;
  height: 20px;
  background: #aab19f;
}

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

.bar-fill.positive {
  left: 50%;
  background: var(--green);
}

.bar-fill.negative {
  right: 50%;
  background: var(--red);
}

.factor-score {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.factor-score small,
.factor-score span,
.factor-score strong {
  display: block;
}

.factor-score small,
.factor-score span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.factor-score strong {
  margin: 3px 0;
  font-size: 22px;
}

.context-head {
  margin-top: 22px;
}

.context-head h3 {
  margin: 0;
  font-size: 17px;
}

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

.context-card {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(238, 241, 231, 0.55);
}

.context-card > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.context-card span,
.context-card p {
  color: var(--muted);
  font-size: 12px;
}

.context-card p {
  margin: 9px 0 0;
  line-height: 1.5;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
}

td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.slow-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.slow-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
}

.slow-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.slow-card strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
}

.notes {
  color: #30352d;
  line-height: 1.65;
}

.notes p:last-child {
  margin-bottom: 0;
}

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

.source-health {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.health-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: #fbfcf8;
}

.health-row.cached,
.health-row.partial {
  border-left-color: var(--gold);
}

.health-row > div span,
.health-row p {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.health-row em {
  color: var(--green);
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.health-row.cached em,
.health-row.partial em {
  color: #8b622d;
}

.health-row p {
  grid-column: 1 / -1;
  margin: 3px 0 0;
  line-height: 1.4;
}

.source-list a {
  display: block;
  padding: 12px 14px;
  color: var(--blue);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcf8;
  overflow-wrap: anywhere;
}

.source-list a:hover {
  border-color: var(--blue);
}

@media (max-width: 900px) {
  .topbar,
  .hero,
  .two-col,
  .section-head {
    display: block;
  }

  .timestamp,
  .horizon-grid,
  .news-overview,
  .market-grid,
  .source-list,
    .slow-panel,
    .source-health,
    .context-grid {
    margin-top: 14px;
  }

  .horizon-grid,
  .news-overview,
  .market-grid,
  .source-list,
    .slow-panel,
    .source-health,
    .context-grid {
    grid-template-columns: 1fr 1fr;
  }

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

  .news-head,
  .news-card ul {
    grid-template-columns: 1fr;
  }

  .factor-score {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 16px;
  }

  .horizon-grid,
  .news-overview,
  .market-grid,
  .source-list,
    .slow-panel,
    .source-health,
    .context-grid {
    grid-template-columns: 1fr;
  }

  .stance-top {
    display: block;
  }

  .confidence {
    margin-top: 14px;
  }
}
