:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-soft: #eef3f2;
  --text: #151a19;
  --muted: #5f6966;
  --faint: #8b9693;
  --border: #d9e2df;
  --grid: #e7eeeb;
  --ink: #182120;
  --teal: #0d8b7d;
  --red: #b24331;
  --green: #217a48;
  --shadow: 0 18px 46px rgba(18, 30, 28, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  overflow-x: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, #ffffff 0, #ffffff 104px, var(--bg) 300px),
    var(--bg);
  letter-spacing: 0;
}

button,
table {
  font: inherit;
}

a {
  color: var(--teal);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

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

h1 {
  margin-bottom: 10px;
  font-size: 42px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 21px;
  line-height: 1.25;
  letter-spacing: 0;
}

.site-shell {
  width: calc(100% - 32px);
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 0 44px;
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0 18px;
}

.eyebrow,
.section-kicker,
.source-label {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 780;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-summary {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.source-panel {
  flex: 0 0 270px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.source-panel strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.chart-section,
.data-section,
.notes-section {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.chart-section {
  padding: 18px;
}

.chart-head,
.section-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

#chartSubtitle {
  max-width: 650px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.series-controls {
  display: inline-flex;
  flex: 0 0 auto;
  gap: 6px;
  min-height: 38px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbfa;
}

.series-controls button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 78px;
  min-height: 30px;
  padding: 5px 10px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 780;
}

.series-controls button[aria-pressed="true"] {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 1px 6px rgba(24, 33, 32, 0.12);
}

.legend-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: min(66vh, 640px);
  min-height: 460px;
  margin-top: 18px;
  border: 1px solid var(--grid);
  border-radius: 8px;
  background: #fbfcfc;
  overflow: hidden;
}

.price-chart {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: pan-y;
}

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

.grid-line {
  stroke: var(--grid);
  stroke-width: 1;
}

.domain-line {
  stroke: #c5d1cd;
  stroke-width: 1.15;
}

.contract-marker {
  stroke: #a06d2e;
  stroke-width: 1;
  stroke-dasharray: 3 5;
  opacity: 0.72;
}

.series-area {
  opacity: 0.08;
}

.series-line {
  fill: none;
  stroke-width: 2.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.latest-price-line {
  stroke: #c7d1ce;
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.latest-dot,
.hover-dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.crosshair-line {
  stroke: #3e4c49;
  stroke-width: 1;
  stroke-dasharray: 4 4;
  opacity: 0.86;
}

.crosshair-line.horizontal {
  opacity: 0.58;
}

.crosshair-label-bg {
  fill: var(--ink);
}

.crosshair-label,
.price-label {
  fill: #ffffff;
  font-size: 12px;
  font-weight: 760;
}

.chart-tooltip[hidden] {
  display: none !important;
}

.chart-tooltip {
  position: absolute;
  z-index: 4;
  width: 286px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 16px 34px rgba(19, 35, 31, 0.16);
  pointer-events: none;
}

.tooltip-date {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 14px;
  font-weight: 780;
}

.tooltip-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 13px;
}

.tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.tooltip-row strong {
  font-variant-numeric: tabular-nums;
}

.tooltip-note {
  margin: 8px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--grid);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.tooltip-note.strong {
  color: #8b5b1c;
  font-weight: 780;
}

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

.stat-item {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--grid);
  border-radius: 8px;
  background: #fbfcfc;
}

.stat-item span:first-child {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.stat-item strong {
  display: block;
  color: var(--text);
  font-size: 22px;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}

.trend {
  display: inline-flex;
  align-items: center;
  min-height: 23px;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #edf3f1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.trend.up {
  background: #fff2ed;
  color: var(--red);
}

.trend.down {
  background: #eaf6ef;
  color: var(--green);
}

.data-section {
  padding: 18px;
}

.date-pill {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.table-wrap {
  width: 100%;
  margin-top: 14px;
  overflow-x: auto;
  border: 1px solid var(--grid);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  background: #fbfcfc;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--grid);
  text-align: right;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

th {
  color: var(--muted);
  background: #f3f7f5;
  font-weight: 780;
}

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

td .trend {
  margin-top: 0;
}

.notes-section {
  padding: 16px 18px;
}

.notes-section p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

@media (max-width: 900px) {
  .site-header,
  .chart-head,
  .section-row {
    align-items: stretch;
    flex-direction: column;
  }

  .source-panel {
    flex: 0 1 auto;
    width: 100%;
  }

  .series-controls {
    width: 100%;
  }

  .series-controls button {
    flex: 1 1 0;
  }

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

@media (max-width: 640px) {
  .site-shell {
    width: calc(100% - 22px);
    padding-top: 18px;
  }

  h1 {
    font-size: 32px;
  }

  h2 {
    font-size: 19px;
  }

  .header-summary {
    max-width: 360px;
    font-size: 15px;
  }

  .chart-section,
  .data-section,
  .notes-section {
    padding: 14px;
  }

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

  .chart-tooltip {
    width: min(300px, calc(100% - 16px));
  }

  .chart-stats {
    grid-template-columns: 1fr;
  }

  .stat-item {
    min-height: 66px;
  }
}
