:root {
  color-scheme: light;
  --surface-1:      #fcfcfb;
  --page:           #f9f9f7;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --gridline:       #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --series-1:       #2a78d6; /* blue */
  --series-2:       #eb6834; /* orange */
  --series-3:       #1baf7a; /* aqua */
  --series-4:       #eda100; /* yellow */
  --series-5:       #e87ba4; /* magenta */
  --series-6:       #008300; /* green */
  --series-7:       #4a3aa7; /* violet */
  --series-8:       #e34948; /* red */
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --gridline:       #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
    --series-1:       #3987e5;
    --series-2:       #d95926;
    --series-3:       #199e70;
    --series-4:       #c98500;
    --series-5:       #d55181;
    --series-6:       #008300;
    --series-7:       #9085e9;
    --series-8:       #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1:      #1a1a19;
  --page:           #0d0d0d;
  --text-primary:   #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted:     #898781;
  --gridline:       #2c2c2a;
  --baseline:       #383835;
  --border:         rgba(255,255,255,0.10);
  --series-1:       #3987e5;
  --series-2:       #d95926;
  --series-3:       #199e70;
  --series-4:       #c98500;
  --series-5:       #d55181;
  --series-6:       #008300;
  --series-7:       #9085e9;
  --series-8:       #e66767;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text-primary);
  line-height: 1.5;
}

header {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 20px 8px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.8em;
}

.tagline {
  color: var(--text-secondary);
  margin: 0;
  max-width: 65ch;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 40px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

section {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  align-items: start;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-group label {
  font-size: 0.85em;
  color: var(--text-secondary);
  font-weight: 600;
}

select, button {
  font: inherit;
  color: var(--text-primary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}

button {
  cursor: pointer;
}

button:hover {
  border-color: var(--series-1);
}

.toggle-group label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  display: flex;
  font-weight: 400;
  color: var(--text-primary);
}

.ware-picker {
  grid-column: 1 / -1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.ware-picker legend {
  font-size: 0.85em;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0 4px;
}

.ware-picker label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95em;
}

.ware-picker .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.ware-group-label {
  flex-basis: 100%;
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 6px;
}

.ware-group-label:first-of-type {
  margin-top: 0;
}

.index-badge {
  font-size: 0.7em;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
}

.chart-section {
  min-height: 420px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.table-toolbar h2, .sources-section h2 {
  margin: 0;
  font-size: 1.1em;
}

.table-scroll {
  overflow-x: auto;
}

table {
  border-collapse: collapse;
  width: 100%;
  font-variant-numeric: tabular-nums;
  font-size: 0.9em;
}

th, td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--gridline);
  text-align: right;
  white-space: nowrap;
}

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

thead th {
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--baseline);
  position: sticky;
  top: 0;
  background: var(--surface-1);
}

td.missing {
  color: var(--text-muted);
  font-style: italic;
}

.sources-section .ware-source {
  padding: 10px 0;
  border-bottom: 1px solid var(--gridline);
}

.sources-section .ware-source:last-child {
  border-bottom: none;
}

.sources-section .ware-source h3 {
  margin: 0 0 4px;
  font-size: 1em;
}

.sources-section .ware-source p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.9em;
}

.sources-section a {
  color: var(--series-1);
}

footer {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 20px 40px;
  color: var(--text-muted);
  font-size: 0.85em;
}
