:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #6b6a65;
  --gridline: #e1e0d9;
  --border: rgba(11, 11, 11, 0.12);
  --series-1: #2a78d6;
  --series-1-dark: #1c5cab;
  --good: #0ca30c;
  --seq-100: #cde2fb;
  --seq-250: #86b6ef;
  --seq-400: #3987e5;
  --seq-550: #1c5cab;
  --seq-700: #0d366b;
}

@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: #9a988f;
    --gridline: #2c2c2a;
    --border: rgba(255, 255, 255, 0.14);
    --series-1: #3987e5;
    --series-1-dark: #184f95;
    --good: #0ca30c;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #1a1a19;
  --page: #0d0d0d;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #9a988f;
  --gridline: #2c2c2a;
  --border: rgba(255, 255, 255, 0.14);
  --series-1: #3987e5;
  --series-1-dark: #184f95;
  --good: #0ca30c;
}

* { box-sizing: border-box; }

html, body {
  overscroll-behavior: none;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  background: var(--page);
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

.page-header {
  padding: 28px 20px 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.page-header h1 {
  font-size: 28px;
  margin: 0 0 6px;
}

.subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0 0 18px;
}

.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 18px;
  min-width: 110px;
}

.stat-tile .label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-tile .value {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 20px 0 16px;
  border-bottom: 2px solid var(--gridline);
  padding-bottom: 0;
}

.tab-btn {
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  color: var(--text-secondary);
  background: none;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
}

.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--series-1);
}

.panel { display: none; }
.panel.active { display: block; }

.section-note {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 0 0 14px;
}

.controls {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
}

.search-box, .num-box {
  font: inherit;
  font-weight: 700;
  font-size: 16px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-1);
  color: var(--text-primary);
}

.search-box { min-width: 220px; }
.num-box { width: 90px; }
select.num-box { width: auto; }

.min-starts-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--text-secondary);
}

.table-wrap {
  overflow: auto;
  overscroll-behavior: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-1);
  max-height: 70vh;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--gridline);
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--surface-1);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  user-select: none;
}

.data-table th.num, .data-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.data-table th.sort-asc::after { content: " ▲"; }
.data-table th.sort-desc::after { content: " ▼"; }

.data-table tbody tr {
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: color-mix(in srgb, var(--series-1) 8%, transparent);
}

.heatmap-table td {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.heatmap-table th {
  text-align: center;
}

.weight-bars {
  padding: 20px;
}

.weight-bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 70px;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.weight-bar-row .bucket-label {
  font-size: 14px;
  color: var(--text-secondary);
}

.weight-bar-track {
  background: var(--gridline);
  border-radius: 6px;
  height: 18px;
  overflow: hidden;
}

.weight-bar-fill {
  background: var(--series-1);
  height: 100%;
  border-radius: 6px 0 0 6px;
}

.weight-bar-row .bar-value {
  font-size: 14px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface-1);
  border-radius: 14px;
  padding: 24px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  overscroll-behavior: none;
  position: relative;
  border: 1px solid var(--border);
}

.modal h2 { margin-top: 0; font-size: 22px; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 22px;
  font-weight: 700;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
}

.detail-section h3 {
  font-size: 16px;
  margin: 18px 0 8px;
}

.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  margin-bottom: 8px;
}

.mini-table th, .mini-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--gridline);
  text-align: right;
}

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

.page-footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .page-header h1 { font-size: 22px; }
  .table-wrap { max-height: 60vh; }
}
