:root {
  color-scheme: light;
  --bg: #f5f6f2;
  --ink: #202124;
  --muted: #67706f;
  --panel: #ffffff;
  --rule: #d9ddd5;
  --red: #c62828;
  --blue: #173b78;
  --green: #18725c;
  --amber: #a45f14;
  --shadow: 0 18px 45px rgba(33, 38, 34, 0.1);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button {
  font: inherit;
}

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

.topbar,
.panel-head,
.metrics {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.topbar {
  margin-bottom: 18px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
  max-width: 760px;
}

h2 {
  font-size: 18px;
}

.status {
  display: grid;
  gap: 8px;
  justify-items: end;
  color: var(--muted);
  font-size: 13px;
}

.status time {
  color: var(--ink);
  font-weight: 700;
}

.metrics {
  align-items: stretch;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 16px;
}

.metrics article,
.panel,
.table-section {
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metrics article {
  min-height: 126px;
  padding: 18px;
  display: grid;
  align-content: space-between;
  gap: 10px;
}

.metrics span,
.metrics small {
  color: var(--muted);
  font-size: 13px;
}

.metrics strong {
  font-size: 34px;
  line-height: 1;
}

.panel,
.table-section {
  padding: 18px;
  margin-top: 16px;
}

.gold-stack {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.gold-panel {
  margin-top: 0;
}

.panel-head {
  align-items: center;
  margin-bottom: 14px;
}

.panel-head p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 14px;
}

.panel-head.compact {
  margin-bottom: 10px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(4, 48px);
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: #f8faf7;
}

.gold-range {
  grid-template-columns: repeat(3, 56px);
}

.spdr-range {
  grid-template-columns: repeat(4, 64px);
}

.segmented button,
#refreshButton {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 36px;
  cursor: pointer;
}

.segmented button.active {
  background: var(--ink);
  color: white;
}

#refreshButton {
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 0 14px;
  color: var(--ink);
  background: #f8faf7;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: min(58vh, 520px);
  min-height: 360px;
}

.mini-chart-wrap {
  width: 100%;
  height: min(46vh, 420px);
  min-height: 320px;
}

#chart {
  width: 100%;
  height: 100%;
  display: block;
}

#chinaGoldChart,
#spdrGoldChart {
  width: 100%;
  height: 100%;
  display: block;
}

#chart .grid {
  stroke: #e5e8e1;
  stroke-width: 1;
}

#chart .zero {
  stroke: #4b524f;
  stroke-width: 1.2;
}

#chart .tick {
  stroke: #9ca39e;
  stroke-width: 1;
}

#chart .axis {
  fill: var(--muted);
  font-size: 12px;
}

#chart .left-label {
  text-anchor: end;
}

#chart .right-label {
  text-anchor: start;
}

#chart .date-label {
  text-anchor: middle;
}

#chart .series {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#chart .msci {
  stroke: var(--red);
}

#chart .liquidity {
  stroke: var(--blue);
}

#chart .hover-line {
  stroke: #202124;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

#chart .overlay,
#chinaGoldChart .overlay,
#spdrGoldChart .overlay {
  fill: transparent;
  cursor: crosshair;
}

#chart .empty {
  fill: var(--muted);
  font-size: 15px;
  text-anchor: middle;
}

#chinaGoldChart .grid,
#spdrGoldChart .grid {
  stroke: #e5e8e1;
  stroke-width: 1;
}

#chinaGoldChart .zero,
#spdrGoldChart .zero {
  stroke: #4b524f;
  stroke-width: 1.1;
}

#chinaGoldChart .axis,
#spdrGoldChart .axis {
  fill: var(--muted);
  font-size: 11px;
}

#chinaGoldChart .left-label,
#spdrGoldChart .left-label {
  text-anchor: end;
}

#chinaGoldChart .date-label,
#spdrGoldChart .date-label {
  text-anchor: middle;
}

#chinaGoldChart .bar-positive,
#spdrGoldChart .bar-positive {
  fill: rgba(24, 114, 92, 0.75);
}

#chinaGoldChart .bar-negative,
#spdrGoldChart .bar-negative {
  fill: rgba(198, 40, 40, 0.75);
}

#chinaGoldChart .empty,
#spdrGoldChart .empty {
  fill: var(--muted);
  font-size: 14px;
  text-anchor: middle;
}

#chinaGoldChart .hover-line,
#spdrGoldChart .hover-line {
  stroke: #202124;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

#spdrGoldChart .crosshair-line {
  stroke: #1f2933;
  stroke-opacity: 0.78;
}

#spdrGoldChart .crosshair-label-bg {
  fill: rgba(32, 33, 36, 0.92);
  rx: 4;
}

#spdrGoldChart .crosshair-label-text {
  fill: #ffffff;
  font-size: 11px;
  font-weight: 700;
}

.tooltip {
  position: fixed;
  z-index: 20;
  min-width: 190px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.15);
  pointer-events: none;
  font-size: 13px;
  line-height: 1.55;
}

.legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 14px;
  margin: 4px 0 12px;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.line {
  display: inline-block;
  width: 26px;
  height: 3px;
  border-radius: 99px;
}

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

.blue {
  background: var(--blue);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--rule);
  border-radius: 8px;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--rule);
  text-align: right;
  white-space: nowrap;
}

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

th {
  color: var(--muted);
  background: #f8faf7;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

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

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

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

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

  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .status {
    justify-items: start;
  }

  .metrics {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
    grid-template-columns: repeat(4, 1fr);
  }

  .gold-range {
    grid-template-columns: repeat(3, 1fr);
  }

  .spdr-range {
    grid-template-columns: repeat(4, 1fr);
  }

  .chart-wrap {
    min-height: 330px;
  }
}
