:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2230;
  --muted: #687085;
  --line: #e2e5eb;
  --accent: #2f5bd3;
  --accent-ink: #ffffff;
  --bar: #4f74db;
  --ok-bg: #e7f5ec;
  --ok: #1f7a43;
  --bad-bg: #fdecec;
  --bad: #b42323;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171d;
    --surface: #1d2129;
    --text: #e8eaf0;
    --muted: #9aa1b2;
    --line: #2e333e;
    --accent: #7c9bf0;
    --accent-ink: #10131a;
    --bar: #7c9bf0;
    --ok-bg: #173324;
    --ok: #7fd3a0;
    --bad-bg: #3a1c1c;
    --bad: #f19a9a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.6rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }

.top {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  padding: .8rem 1rem; background: var(--surface); border-bottom: 1px solid var(--line);
}
.top nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.top nav a { text-decoration: none; color: var(--text); }
.brand { font-weight: 700; text-decoration: none; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.mark {
  display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 6px;
  background: var(--accent); color: var(--accent-ink); font-style: italic; font-family: Georgia, serif;
}
img.mark { background: none; width: 1.6rem; height: 1.6rem; border-radius: 6px; }
.notice { background: var(--ok-bg); color: var(--ok); padding: .6rem .9rem; border-radius: 8px; }
.welcome { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--radius); padding: 1rem 1.2rem; margin-bottom: 1rem; }
.welcome h2 { margin-bottom: .3rem; }
.welcome ol { margin: .4rem 0 0; padding-left: 1.2rem; }
.danger-zone { border-color: var(--bad-bg); }
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head p { margin: .2rem 0 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.links { display: flex; gap: .9rem; flex-wrap: wrap; }

.btn {
  display: inline-block; font: inherit; padding: .45rem .9rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); margin-left: auto; }
.btn.small { padding: .25rem .6rem; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: wait; }

.sources { display: flex; gap: .4rem; flex-wrap: wrap; margin: 0 0 .5rem; }
.pill { font-size: .8rem; padding: .15rem .6rem; border-radius: 99px; }
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.off { background: var(--line); color: var(--muted); }
.status { min-height: 1.4em; margin: .3rem 0 .8rem; font-size: .9rem; }
.status.bad { color: var(--bad); }
.alert { background: var(--bad-bg); color: var(--bad); padding: .5rem .8rem; border-radius: 8px; }
.err { display: block; font-size: .75rem; color: var(--bad); cursor: help; text-decoration: underline dotted; }

.range {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; margin: 0 0 1rem;
  padding: .7rem .9rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.range-label { font-weight: 600; font-size: .9rem; }
.range label { display: flex; align-items: center; gap: .35rem; font-size: .9rem; color: var(--muted); }
.range input {
  width: 5.5rem; font: inherit; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text);
}
.presets { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip {
  font-size: .8rem; padding: .2rem .65rem; border-radius: 99px; border: 1px solid var(--line);
  text-decoration: none; color: var(--text);
}
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.warn { color: #b26a00; }
@media (prefers-color-scheme: dark) { .warn { color: #f0b45c; } }
.alltime { border-top: 1px solid var(--line); padding-top: .5rem; }

.panel-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem; margin-bottom: .6rem; }
.panel-head h2 { margin: 0; }
.tabs { display: flex; gap: .25rem; background: var(--bg); padding: .2rem; border-radius: 8px; }
.tab { font: inherit; font-size: .85rem; border: 0; background: none; color: var(--muted); padding: .3rem .7rem; border-radius: 6px; cursor: pointer; }
.tab.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: .45rem; }
.bars li { display: grid; grid-template-columns: minmax(8rem, 16rem) 1fr auto; gap: .7rem; align-items: center; font-size: .9rem; }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: .7rem; background: var(--bg); border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--bar); border-radius: 99px; }
.bar-n { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 4.5rem; text-align: right; }
@media (max-width: 600px) {
  .bars li { grid-template-columns: 1fr auto; }
  .bar-track { grid-column: 1 / -1; grid-row: 2; }
}

.bench-opts { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin-bottom: .8rem; }
.bench-opts label { display: grid; gap: .2rem; font-size: .8rem; color: var(--muted); }
.bench-opts select {
  font: inherit; font-size: .88rem; padding: .3rem .5rem; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text);
}
.bench-table th[scope="row"] { font-weight: 500; white-space: nowrap; }
.bench-table .pct { display: flex; align-items: center; gap: .6rem; min-width: 11rem; }
.pct-track { position: relative; flex: 1; height: .55rem; background: var(--bg); border-radius: 99px; }
.pct-mid { position: absolute; left: 25%; right: 25%; top: 0; bottom: 0; background: var(--line); }
.pct-dot {
  position: absolute; top: 50%; width: .85rem; height: .85rem; border-radius: 50%; transform: translate(-50%, -50%);
  border: 2px solid var(--surface); background: var(--bar);
}
.pct-dot.high { background: var(--ok); }
.pct-dot.low { background: #c77a14; }
.pct-n { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 2.6rem; text-align: right; }
@media (max-width: 600px) {
  .bench-table .avg { display: none; }
  .bench-table th, .bench-table td { padding: .5rem .45rem; }
  .bench-table .pct { min-width: 0; display: table-cell; text-align: right; }
  .bench-table .pct-track { display: none; }
  .bench-table thead th, .bench-table thead th.n { white-space: normal; font-size: .78rem; }
  .bench-table th[scope="row"] { white-space: normal; }
}
.examples { margin-top: .6rem; }
.examples summary { cursor: pointer; color: var(--accent); }
.examples ul { margin: .5rem 0 0; padding-left: 1.1rem; display: grid; gap: .25rem; }

/* ---- Promotion panels */
h3 { font-size: .95rem; margin: 1.2rem 0 .5rem; }
.sections { display: flex; flex-wrap: wrap; gap: .3rem .9rem; margin: -.3rem 0 1rem; }
.sections a { text-decoration: none; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .7rem; margin-bottom: .6rem; }
.tile { display: grid; gap: .1rem; padding: .7rem .8rem; background: var(--bg); border-radius: 8px; align-content: start; }
.tile-n { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile-text { font-size: 1.05rem; }
.tile-l { font-size: .85rem; font-weight: 600; }
.tile-s { font-size: .75rem; color: var(--muted); }
.link { font: inherit; background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; }
.key-list { margin: 0 0 1rem; padding-left: 1.2rem; display: grid; gap: .7rem; }
.key-title { font-weight: 600; font-size: .92rem; margin-bottom: .3rem; }
.key-title .link { font-weight: 400; font-size: .8rem; margin-left: .4rem; }
.key-list textarea, .crit textarea, .narrative {
  width: 100%; font: inherit; font-size: .9rem; padding: .45rem .6rem; border: 1px solid var(--line);
  border-radius: 8px; background: var(--surface); color: var(--text); transition: border-color .3s;
}
textarea.saved { border-color: var(--ok); }
textarea.unsaved, select.unsaved { border-color: var(--bad); }
.narrative { line-height: 1.6; }
.sortbar { display: flex; gap: .35rem; align-items: center; margin: .3rem 0 .6rem; }
button.chip { font: inherit; background: none; cursor: pointer; }
.works-table td { font-size: .88rem; }
.works-table td:first-child { min-width: 0; width: 2rem; }
.works-table td:nth-child(2) { min-width: 16rem; }
.works-table tr.more { display: none; }
.works-table tbody.all tr.more { display: table-row; }
.star { font-size: 1.15rem; line-height: 1; background: none; border: 0; cursor: pointer; color: var(--muted); padding: .1rem; }
.star.on { color: #d49b00; }
.badge { display: inline-block; font-size: .72rem; font-weight: 600; padding: .1rem .45rem; border-radius: 99px; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.badge.gold { background: #fdf0c8; color: #8a6200; }
.split { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: 1.5rem; }
.split h3 { margin-top: 0; }
.facts { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; margin: 0 0 .6rem; font-size: .9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.crit-list { margin: 0; padding-left: 1.2rem; display: grid; gap: .8rem; }
.crit-list > li { display: flex; gap: .8rem; align-items: flex-start; justify-content: space-between; }
.crit-text { flex: 1; display: grid; gap: .35rem; }
.crit select {
  font: inherit; font-size: .85rem; padding: .3rem .4rem; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); max-width: 12rem;
}
.crit select.status-met { border-color: var(--ok); background: var(--ok-bg); }
.crit select.status-partly { border-color: #c77a14; }
.crit select.status-not { border-color: var(--bad); }
.checks { list-style: none; margin: 0 0 .6rem; padding: 0; display: grid; gap: .55rem; }
.check { display: flex; gap: .6rem; align-items: flex-start; font-size: .92rem; }
.check-icon {
  flex: none; display: grid; place-items: center; width: 1.35rem; height: 1.35rem; border-radius: 50%;
  font-size: .8rem; font-weight: 700; background: var(--ok-bg); color: var(--ok);
}
.check.warn .check-icon { background: #fdf0c8; color: #8a6200; }
.check.info .check-icon { background: var(--line); color: var(--muted); }
.chips-row { display: flex; flex-wrap: wrap; gap: .35rem; }
.input, .form select {
  font: inherit; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text);
}
@media (max-width: 600px) {
  .crit-list > li { flex-direction: column; }
  .works-table td:nth-child(2) { min-width: 12rem; }
}

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: .6rem .8rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid th { font-size: .85rem; white-space: nowrap; }
.grid th small { display: block; font-weight: 400; color: var(--muted); font-size: .72rem; }
.grid .n { text-align: right; white-space: nowrap; }
.grid td:first-child { min-width: 11rem; }
.grid .name { font-weight: 600; text-decoration: none; }
.grid .big { display: block; font-size: 1.05rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.grid .sub { display: block; font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.empty { text-align: center; padding: 3rem 1rem; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.panel { margin-bottom: 1rem; }
.card .metric .big { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.card dl { display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; margin: .5rem 0; }
.card dt { color: var(--muted); }
.card dd { margin: 0; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.card p { margin: .4rem 0 0; }

.chart { width: 100%; height: auto; display: block; }
.chart rect { fill: var(--bar); }
.chart line { stroke: var(--line); }
.chart .yr { fill: var(--muted); font-size: 11px; text-anchor: middle; }
.chart g:hover rect { fill: var(--accent); opacity: .8; }

.form { max-width: 680px; display: grid; gap: 1rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; font-size: .92rem; }
.form input, .form textarea {
  font: inherit; font-weight: 400; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); width: 100%;
}
.form input:focus, .form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.form fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; display: grid; gap: 1rem; margin: 0; }
.form legend { font-weight: 700; padding: 0 .3rem; }
.hint { font-weight: 400; font-size: .8rem; color: var(--muted); }
.row { display: flex; gap: .5rem; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; }
.row input { flex: 1; }
.results { display: grid; gap: .4rem; }
.result {
  text-align: left; font: inherit; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text); cursor: pointer;
}
.result:hover { border-color: var(--accent); }

body.login { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
body.login .form { width: min(360px, 100%); }
body.login h1 { display: flex; gap: .5rem; align-items: center; font-size: 1.3rem; }

@media (max-width: 600px) {
  main { padding: 1rem; }
  .row { flex-direction: column; }
}
