:root {
  --brand-from: #2a68ff;
  --brand-to: #5ae6ff;
  --brand-serif: Georgia, "Times New Roman", serif;
  --surface: #ffffff;
  --card: #f5f8fc;
  --text: #182639;
  --muted: #4c5e75;
  --line: #c7d2e1;
  --accent: #1d4eb9;
  --good: #199e70;
  --warn: #915509;
}

[data-theme="dark"] {
  --surface: #10151f;
  --card: #171e29;
  --text: #edf2f8;
  --muted: #adb9ca;
  --line: #394656;
  --accent: #6caeff;
  --good: #4ad9a8;
  --warn: #ffc56f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  transition: background .15s ease, color .15s ease;
}

main { max-width: 1180px; margin: 0 auto; padding: 44px 22px 90px; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 36px;
}

.wordmark {
  font-family: var(--brand-serif);
  font-weight: 700;
  font-size: 20px;
  background: linear-gradient(90deg, var(--brand-from), var(--brand-to));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.theme-toggle {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 6px 14px; font-size: 12px; cursor: pointer;
}

.tag {
  display: inline-block; color: var(--accent); font-weight: 800; letter-spacing: .12em;
  text-transform: uppercase; font-size: 12px; margin-bottom: 10px;
}

h1 {
  font-size: clamp(36px, 6vw, 60px); line-height: 1.02; margin: .1em 0 .3em;
  background: linear-gradient(90deg, var(--brand-from), var(--brand-to));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  display: inline-block;
}

.lede { max-width: 760px; color: var(--muted); font-size: 18px; margin: 0 0 24px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 34px; }
.btn {
  color: var(--text); text-decoration: none; border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 15px; background: var(--card); font-size: 14px;
}
.btn.primary {
  background: linear-gradient(90deg, var(--brand-from), var(--brand-to));
  color: #08111f; border-color: transparent; font-weight: 800;
}

.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0 0 40px; }
.fact {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
}
.fact b { display: block; font-size: 24px; }
.fact span { color: var(--muted); font-size: 13px; }

h2 { margin: 46px 0 14px; font-size: 22px; }

.method { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.method-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
}
.method-card b { display: block; color: var(--accent); font-size: 15px; margin-bottom: 4px; }
.method-card span { color: var(--muted); font-size: 13px; }
.formula {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px;
  color: var(--muted); font-size: 14px; margin-top: 14px;
}
.formula code { color: var(--text); }

.note { color: var(--muted); font-size: 13px; margin: 6px 0 16px; }
.note.warn { color: var(--warn); }

.table-wrap {
  overflow: auto; border: 1px solid var(--line); border-radius: 14px; background: var(--card);
  max-height: 1200px;
}
table { border-collapse: collapse; width: 100%; min-width: 900px; font-size: 13.5px; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; white-space: normal; }
th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted);
  position: sticky; top: 0; background: var(--surface); text-align: right;
}
th:first-child { text-align: left; }
tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.rank { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 4px; }
.sys-name { color: var(--text); text-decoration: none; }
.sys-name:hover { text-decoration: underline; }
.score { color: var(--good); font-weight: 800; font-variant-numeric: tabular-nums; }

.bar-cell { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; width: 100%; }
.bar-track { width: 56px; height: 6px; border-radius: 4px; background: var(--line); overflow: hidden; flex: none; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--brand-from), var(--brand-to)); }
.bar-num { font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }

.badge {
  display: inline-block; border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px;
  font-size: 10.5px; font-weight: 600; color: var(--muted); background: var(--surface);
}

.error { padding: 26px; color: #e0576a; text-align: center; }

footer.foot { margin-top: 60px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); padding-top: 20px; }
footer.foot a { color: var(--accent); }

@media (max-width: 760px) {
  .facts, .method { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 460px) {
  .facts, .method { grid-template-columns: 1fr; }
}
