:root {
  color-scheme: light;
  --bg: #f6f7f2;
  --ink: #202321;
  --muted: #65706b;
  --line: #d8ddd2;
  --panel: #ffffff;
  --ddr4: #1f7a70;
  --ddr5: #b4472d;
  --accent: #2c5f9e;
  --shadow: 0 14px 30px rgba(31, 38, 35, 0.08);
}

* {
  box-sizing: border-box;
}

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

a {
  color: var(--accent);
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(20px, 4vw, 56px) 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

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

h1,
h2,
p {
  margin: 0;
}

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

h2 {
  font-size: 20px;
}

.meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
}

.meta span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: #fff;
}

main {
  width: min(1280px, calc(100vw - 32px));
  margin: 24px auto 56px;
}

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

.summary-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.summary-grid strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 32px;
  line-height: 1;
}

.summary-grid p,
.notes p,
.table-head p,
.chart-head p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
  padding: 14px;
  background: #eef1ea;
  border: 1px solid var(--line);
  border-radius: 8px;
}

label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  gap: 7px;
}

select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
  font: inherit;
}

.chart-band,
.stats-section,
.table-section,
.notes {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.chart-band {
  padding: 18px;
}

.stats-section {
  margin-top: 18px;
  padding: 18px;
}

.chart-head,
.table-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.zoom-controls {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 8px 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf5;
}

.zoom-controls button {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.zoom-controls button:hover {
  border-color: #aeb8b1;
}

.swatch {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-right: 6px;
}

.swatch.ddr4 {
  background: var(--ddr4);
}

.swatch.ddr5 {
  background: var(--ddr5);
}

#trendChart {
  width: 100%;
  height: 430px;
  display: block;
  overflow: visible;
}

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

.axis line,
.grid line {
  stroke: var(--line);
}

.series-line {
  fill: none;
  stroke-width: 2.5;
}

.dot {
  cursor: pointer;
  stroke: #fff;
  stroke-width: 2;
}

.dot.selected {
  stroke: #151817;
  stroke-width: 3;
}

.dot.low-confidence {
  opacity: 0.62;
}

.selection-panel {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8faf5;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.selection-panel strong {
  color: var(--ink);
}

.selection-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.selection-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  background: #fff;
}

.selection-grid span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.selection-grid b {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 14px;
}

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

.table-head input {
  max-width: 340px;
}

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

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

#statsTable {
  min-width: 820px;
}

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

th {
  position: sticky;
  top: 0;
  background: #eef1ea;
  color: #39413d;
  cursor: pointer;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8faf5;
}

.source-link {
  color: var(--accent);
  text-decoration: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.pill.ddr4 {
  background: var(--ddr4);
}

.pill.ddr5 {
  background: var(--ddr5);
}

.notes {
  margin-top: 18px;
  padding: 18px;
  display: grid;
  gap: 8px;
}

.tooltip {
  position: fixed;
  z-index: 20;
  max-width: 360px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  pointer-events: none;
}

.tooltip strong {
  display: block;
  margin-bottom: 4px;
}

@media (max-width: 900px) {
  .topbar,
  .chart-head,
  .table-head {
    display: grid;
  }

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

  .zoom-controls,
  .selection-grid {
    grid-template-columns: 1fr;
  }

  .meta {
    justify-content: flex-start;
  }
}

@media (max-width: 620px) {
  main {
    width: min(100vw - 20px, 1280px);
  }

  .summary-grid,
  .controls {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding-inline: 14px;
  }

  #trendChart {
    height: 360px;
  }
}
