:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-strong: #111827;
  --text: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --green: #138a57;
  --green-soft: #e7f6ef;
  --red: #bf3b3b;
  --red-soft: #faeaea;
  --amber: #ad6b12;
  --amber-soft: #fff2d8;
  --blue: #2869c9;
  --blue-soft: #e7eefc;
  --shadow: 0 18px 45px rgba(27, 39, 64, 0.08);
}

* {
  box-sizing: border-box;
}

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

button {
  font: inherit;
}

.app-shell {
  width: min(1420px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 44px;
}

.topbar,
.hero-grid,
.section-heading,
.metric-head,
.metric-foot,
.status-row,
.topbar-actions,
.tabs {
  display: flex;
}

.topbar {
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.topbar h1,
.section-heading h2,
.metric-card h3,
.liquidity-card h3,
.source-panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 34px;
  line-height: 1.08;
}

.subtitle,
.section-note,
.source-panel p,
.metric-detail,
.label {
  color: var(--muted);
}

.subtitle {
  margin: 9px 0 0;
  font-size: 15px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-button,
.ghost-button,
.tab {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 15px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.primary-button {
  background: var(--panel-strong);
  border-color: var(--panel-strong);
  color: #fff;
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.hero-grid {
  align-items: stretch;
  gap: 16px;
  margin-bottom: 16px;
}

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

.score-panel {
  flex: 1 1 auto;
  min-height: 260px;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
  align-items: center;
  padding: 24px;
}

.liquidity-score-panel {
  display: grid;
  grid-template-columns: 210px 1fr;
  gap: 22px;
  align-items: center;
  margin: 0 0 14px;
}

.compact-ring {
  width: 180px;
}

.compact-ring span {
  font-size: 46px;
}

.liquidity-weight-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.brief-panel {
  width: 360px;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.update-panel {
  margin: 0 0 16px;
}

.update-badge {
  flex: 0 0 auto;
  min-height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 4px 11px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.update-badge.good {
  background: var(--green-soft);
  color: var(--green);
}

.update-badge.bad {
  background: var(--red-soft);
  color: var(--red);
}

.update-badge.neutral {
  background: var(--amber-soft);
  color: var(--amber);
}

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

.change-row {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 11px 12px;
}

.change-row.good {
  border-color: rgba(19, 138, 87, 0.25);
  background: var(--green-soft);
}

.change-row.bad {
  border-color: rgba(191, 59, 59, 0.25);
  background: var(--red-soft);
}

.change-row strong,
.change-row span {
  display: block;
}

.change-row strong {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}

.change-row span {
  font-size: 13px;
  line-height: 1.35;
}

.brief-item {
  min-height: 48px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.brief-item:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.brief-item strong,
.brief-item span {
  display: block;
}

.brief-item strong {
  margin-top: 4px;
  font-size: 15px;
}

.label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.score-ring {
  width: 228px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--amber) 0deg, var(--line) 0deg);
  position: relative;
}

.score-ring::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: var(--panel);
  box-shadow: inset 0 0 0 1px var(--line);
}

.score-ring > div {
  position: relative;
  text-align: center;
}

.score-ring span {
  font-size: 58px;
  line-height: 1;
  font-weight: 850;
}

.score-ring small {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin-top: 4px;
}

.score-copy {
  min-width: 0;
}

.status-row {
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.status-row p {
  margin: 0;
  font-size: 28px;
  font-weight: 850;
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--amber);
}

.status-dot.good {
  background: var(--green);
}

.status-dot.bad {
  background: var(--red);
}

.status-dot.neutral {
  background: var(--amber);
}

.score-copy > p {
  margin: 0;
  max-width: 700px;
  color: var(--muted);
  line-height: 1.6;
}

.regime-scale {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 26px;
}

.regime-scale span {
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #eef2f7;
  color: #4b5565;
  font-size: 12px;
  font-weight: 750;
  text-align: center;
  padding: 4px;
}

.tabs {
  gap: 8px;
  margin: 20px 0 16px;
  overflow-x: auto;
}

.tab {
  min-width: 128px;
  font-weight: 750;
}

.tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.tab-page {
  display: none;
}

.tab-page.active {
  display: block;
}

.section-heading {
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin: 20px 0 14px;
}

.section-heading.compact {
  margin-top: 0;
}

.section-heading.compact .signal-pill {
  margin-top: 4px;
}

.section-heading h2 {
  font-size: 24px;
}

.section-note {
  margin: 0;
  max-width: 620px;
  line-height: 1.5;
}

.indicator-grid,
.liquidity-grid {
  display: grid;
  gap: 14px;
}

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

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

.metric-card,
.liquidity-card,
.wide-panel {
  padding: 16px;
}

.metric-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  min-height: 54px;
}

.metric-source {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

.metric-card h3,
.liquidity-card h3 {
  font-size: 16px;
  line-height: 1.25;
}

.signal-pill {
  flex: 0 0 auto;
  min-width: 76px;
  min-height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
  background: var(--amber-soft);
  color: var(--amber);
}

.signal-pill.good {
  background: var(--green-soft);
  color: var(--green);
}

.signal-pill.bad {
  background: var(--red-soft);
  color: var(--red);
}

.signal-pill.neutral {
  background: var(--amber-soft);
  color: var(--amber);
}

.metric-main {
  margin: 16px 0 8px;
  min-height: 54px;
}

.metric-value {
  display: block;
  font-size: 24px;
  line-height: 1.15;
}

.metric-detail {
  display: block;
  margin-top: 5px;
  font-size: 13px;
  line-height: 1.35;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.metric-foot {
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 26px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.weight {
  font-weight: 800;
}

.data-status {
  text-align: right;
}

.wide-panel {
  margin-top: 14px;
}

#breadthChart {
  min-height: 84px;
}

.breadth-note {
  max-width: 860px;
  margin-bottom: 4px;
}

.breadth-main {
  min-height: 44px;
  margin-top: 12px;
}

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

.source-grid > div,
.formula-box,
.source-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.source-panel h3 {
  font-size: 16px;
  margin-bottom: 8px;
}

.source-panel p {
  margin: 0;
  line-height: 1.55;
}

.formula-box {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.source-list {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.source-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 130px minmax(220px, 2fr);
  gap: 12px;
  align-items: center;
  font-size: 13px;
}

.source-row span:nth-child(2) {
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 1180px) {
  .hero-grid {
    flex-direction: column;
  }

  .brief-panel {
    width: 100%;
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .app-shell {
    width: min(100% - 20px, 760px);
    padding-top: 18px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .score-panel {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .liquidity-score-panel {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .score-copy {
    width: 100%;
  }

  .brief-panel,
  .indicator-grid,
  .liquidity-grid,
  .change-list,
  .source-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .source-row {
    grid-template-columns: 1fr;
    gap: 3px;
  }
}
