:root {
  --bg: #f5f6f4;
  --panel: #ffffff;
  --text: #1d2420;
  --muted: #5f6b64;
  --line: #dde2de;
  --accent: #2f6b4f;
  --healthy: #2e7d4f;
  --healthy-bg: #e3f2e8;
  --watch: #a86a00;
  --watch-bg: #fbf0d9;
  --risk: #b3261e;
  --risk-bg: #fbe4e2;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --panel: #1d2320;
    --text: #e6ebe8;
    --muted: #9aa69f;
    --line: #2f3833;
    --accent: #7cc39b;
    --healthy: #6fcf97;
    --healthy-bg: #1f3a2a;
    --watch: #f2b84b;
    --watch-bg: #3d3018;
    --risk: #f28b82;
    --risk-bg: #462120;
  }
}

* { 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 { margin: 0; font-size: 1.6rem; }
h2 { margin: 2rem 0 0.25rem; font-size: 1.2rem; }
h3 { margin: 0; font-size: 1.05rem; }
h4 { margin: 0.75rem 0 0.25rem; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.top, main, footer { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.top { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 0.5rem; padding-top: 1.5rem; }
.sub, .hint, .muted { color: var(--muted); }
.sub { margin: 0.25rem 0 0; }
.hint { margin: 0 0 0.75rem; }
.muted { font-size: 0.85rem; }
footer { margin: 3rem auto 2rem; color: var(--muted); font-size: 0.85rem; }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 1.5rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-top: 4px solid; border-radius: 8px; padding: 12px 16px; }
.stat.healthy { border-top-color: var(--healthy); }
.stat.watch { border-top-color: var(--watch); }
.stat.at-risk { border-top-color: var(--risk); }
.stat-label { font-weight: 600; }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat-note { color: var(--muted); font-size: 0.85rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--risk); border-radius: 8px; padding: 14px 16px; }
.card-head { display: flex; justify-content: space-between; gap: 12px; }
.big-score { font-size: 1.8rem; font-weight: 700; color: var(--risk); }
.card ul { margin: 0; padding-left: 1.2rem; }
.next { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--line); }
.action { display: inline-block; font-weight: 600; color: var(--accent); margin-right: 0.25rem; }
.empty { color: var(--muted); }

.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; margin-top: 0.75rem; }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.score { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.score span { width: 2ch; font-weight: 600; }
.bar { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.fill { height: 100%; }
.fill.healthy { background: var(--healthy); }
.fill.watch { background: var(--watch); }
.fill.at-risk { background: var(--risk); }

.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.pill.healthy { background: var(--healthy-bg); color: var(--healthy); }
.pill.watch { background: var(--watch-bg); color: var(--watch); }
.pill.at-risk { background: var(--risk-bg); color: var(--risk); }

.weights { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 4px 16px 16px; margin-top: 2rem; }
.weights h2 { margin-top: 1rem; }
#weights { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px 24px; }
.weight { display: grid; grid-template-columns: 150px 1fr 2.5ch; align-items: center; gap: 8px; }
.weight input { accent-color: var(--accent); }
.weight output { text-align: right; font-weight: 600; }
.thresholds { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; margin-top: 1rem; }
.thresholds input { width: 4.5em; padding: 4px; }
button { padding: 6px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--text); cursor: pointer; font: inherit; }

/* How it works page */
.prose { max-width: 760px; }
.prose table { min-width: 0; background: var(--panel); border: 1px solid var(--line); }

@media (max-width: 640px) {
  .summary { grid-template-columns: 1fr; }
  .weight { grid-template-columns: 120px 1fr 2.5ch; }
}
