:root {
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #1c1917;
  --muted: #78716c;
  --border: #e7e5e4;
  --border-strong: #a8a29e;
  --accent: #0f766e;
  --accent-soft: #ccfbf1;
  --flagged: #b91c1c;
  --flagged-soft: #fee2e2;
  --open: #a16207;
  --open-soft: #fef3c7;
  --clear: #15803d;
  --clear-soft: #dcfce7;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161514;
    --surface: #1f1e1c;
    --text: #f5f5f4;
    --muted: #a8a29e;
    --border: #33312e;
    --border-strong: #57534e;
    --accent: #2dd4bf;
    --accent-soft: #134e4a;
    --flagged: #f87171;
    --flagged-soft: #450a0a;
    --open: #fbbf24;
    --open-soft: #422006;
    --clear: #4ade80;
    --clear-soft: #052e16;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 16px/1.55 var(--font);
  background: var(--bg);
  color: var(--text);
}

a { color: var(--accent); }

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }

.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; gap: 12px; height: 56px; }
.brand { font-weight: 650; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.brand img { display: block; }
.site-nav { margin-left: auto; display: flex; gap: 18px; font-size: 15px; }
.site-nav a { color: var(--text); text-decoration: none; }
.site-nav a:hover { color: var(--accent); }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 14px; padding: 24px 0 32px; }
.site-footer h2 { font-size: 14px; color: var(--text); margin: 0 0 8px; }
.site-footer ul { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-wrap: wrap; gap: 6px 20px; }
.site-footer p { margin: 0; }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }


main { padding-bottom: 48px; }
main section { margin: 32px 0; }
h1 { font-size: 30px; line-height: 1.2; margin: 0 0 12px; }
h2 { font-size: 19px; margin: 0 0 12px; }
.lede { font-size: 17px; max-width: 70ch; }
.meta, .hint { color: var(--muted); font-size: 14px; }
.empty { color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile-value { display: block; font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; }
.tile-label { color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-flagged { background: var(--flagged); }
.dot-open_items { background: var(--open); }
.dot-no_ties_found { background: var(--clear); }

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.finding { color: var(--muted); }

.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.badge-flagged { background: var(--flagged-soft); color: var(--flagged); }
.badge-open_items { background: var(--open-soft); color: var(--open); }
.badge-no_ties_found { background: var(--clear-soft); color: var(--clear); }

.crumbs { margin-top: 20px; font-size: 14px; }
.entity-head h1 { display: inline; margin-right: 10px; }
.entity-head .badge { vertical-align: middle; }

.findings { padding: 0; list-style: none; }
.findings li { border-left: 3px solid; padding: 6px 12px; margin-bottom: 8px; background: var(--surface); }
.finding-hit { border-color: var(--flagged); }
.finding-open { border-color: var(--open); }
.ref { font-size: 13px; text-decoration: none; margin-left: 2px; }

.graph { height: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.graph-empty { display: grid; place-items: center; height: 120px; color: var(--muted); }

.evidence li { margin-bottom: 14px; }
.evidence blockquote { margin: 0 0 4px; padding-left: 12px; border-left: 2px solid var(--border-strong); font-style: italic; }

.button {
  display: inline-block; font: inherit; font-weight: 600; color: #fff; background: var(--accent);
  border: 0; border-radius: 8px; padding: 9px 18px; text-decoration: none; cursor: pointer;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .button { color: #042f2e; } }
.steps { padding-left: 20px; max-width: 70ch; }
.steps li { margin-bottom: 8px; }

.login { max-width: 420px; }
.login form { display: grid; gap: 8px; margin: 20px 0; }
.login label { font-weight: 600; font-size: 14px; }
.login input[type="password"] {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 12px;
}
.login .button { justify-self: start; margin-top: 4px; }
.form-error { color: var(--flagged); margin: 0; font-size: 14px; }

.interpretations { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin: 24px 0; }
.interpretations summary { cursor: pointer; font-weight: 600; }
.interpretations ul { list-style: none; padding: 0; margin: 8px 0 0; }
.interpretations li { border-top: 1px solid var(--border); padding: 10px 0 4px; }
.interpretations li.sensitive .question > span:first-child { font-weight: 600; }
.interpretations .question { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.interpretations .meta { margin: 4px 0 0; }
.toggle { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.toggle label { padding: 3px 12px; font-size: 14px; cursor: pointer; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle label:has(input:checked) { background: var(--accent); color: var(--bg); font-weight: 600; }
.toggle label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Guides */
.guide { max-width: 72ch; }
.guide h2 { margin-top: 32px; }
.guide p, .guide li { line-height: 1.65; }
.guide sup a { text-decoration: none; font-size: 12px; margin-left: 1px; }
.facts { margin: 12px 0 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
.facts.lists td { font-size: 14px; }
.formula, .example { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 6px; padding: 12px 16px; margin: 12px 0; }
.formula { font-weight: 600; }
.example p { margin: 0; }
.questions dt { font-weight: 600; margin-top: 12px; }
.questions dd { margin: 4px 0 0; color: var(--muted); }
.outcomes { list-style: none; padding: 0; }
.outcomes li { margin-bottom: 8px; }
.sources { font-size: 14px; color: var(--muted); border-top: 1px solid var(--border); margin-top: 40px; padding-top: 8px; }
.sources li { margin-bottom: 4px; }
.more-guides { max-width: 72ch; margin-top: 40px; }
.more-guides ul, .guide-list { list-style: none; padding: 0; display: grid; gap: 12px; }
.more-guides li, .guide-list li { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.more-guides li a { font-weight: 600; display: block; }
.more-guides .meta { display: block; margin-top: 4px; }
.guide-list { max-width: 72ch; }
.guide-list a { text-decoration: none; }
.guide-list h2 { color: var(--accent); margin: 0 0 4px; }
.guide-list p { margin: 0; color: var(--muted); }

@media (max-width: 600px) {
  .site-nav { gap: 12px; font-size: 14px; }
  .tag { display: none; }
  .interpretations .question { flex-direction: column; gap: 6px; }
  h1 { font-size: 24px; }
  .tiles { grid-template-columns: 1fr; }
  .graph { height: 340px; }
}
