:root {
  --bg: #f7f7f5; --surface: #ffffff; --text: #1d1d1b; --muted: #5d5d58; --border: #d9d9d3;
  --accent: #1f5f4a; --accent-text: #ffffff; --danger: #a12626; --focus: #1a56c4; --chip: #e9efe9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161715; --surface: #20221f; --text: #ecece6; --muted: #aeaea6; --border: #3a3d38;
    --accent: #5fbf9a; --accent-text: #0e1a15; --danger: #ff8a80; --focus: #8ab4ff; --chip: #2a2f2a;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; overflow-wrap: anywhere; }
main { max-width: 42rem; margin: 0 auto; padding: 16px; outline: none; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 12px; }
h2 { font-size: 1.2rem; margin: 20px 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.nav { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.nav .brand { font-weight: 700; margin-right: auto; }
.nav a, .nav button.linklike { color: var(--accent); background: none; border: 0; font: inherit; padding: 8px 0; cursor: pointer; text-decoration: underline; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin: 0 0 12px; }
.field { display: block; margin: 0 0 16px; }
.field > span.label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; min-height: 44px; padding: 10px 12px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
}
textarea { min-height: 120px; resize: vertical; }
input[type=checkbox] { width: 24px; height: 24px; vertical-align: middle; margin-right: 8px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
button, .btn {
  min-height: 44px; padding: 10px 16px; font: inherit; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
button.primary, .btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.small { min-height: 44px; padding: 6px 12px; font-size: .9rem; }
.choices { display: grid; gap: 8px; margin: 0 0 16px; }
.choices button { justify-content: flex-start; text-align: left; padding: 14px 16px; }
.choices button small { display: block; color: var(--muted); font-weight: 400; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.error { color: var(--danger); font-weight: 600; margin: 0 0 12px; }
.badge { display: inline-block; background: var(--chip); border-radius: 999px; padding: 2px 10px; font-size: .8rem; margin-right: 6px; }
.progress { font-size: .9rem; color: var(--muted); margin-bottom: 8px; }
.spinner { width: 28px; height: 28px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; margin: 12px 0; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.hint { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.card-link { display: block; text-decoration: none; color: inherit; }
.qlabel { display: block; font-weight: 600; margin-bottom: 4px; }
[hidden] { display: none !important; }

.table-wrap { overflow-x: auto; margin: 0 0 12px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
td.num { text-align: right; white-space: nowrap; }
tr.total th, tr.total td { font-weight: 700; border-top: 2px solid var(--border); }
td input[type=text] { min-width: 5rem; }
.tag { display: inline-block; border-radius: 999px; padding: 0 8px; font-size: .75rem; border: 1px solid var(--border); white-space: nowrap; }
.tag-sourced { background: var(--chip); }
.tag-assumed { border-style: dashed; }
.report-section { margin: 0 0 8px; }
.report-header h1 { margin-bottom: 4px; }
dl { margin: 0 0 12px; } dt { font-weight: 600; } dd { margin: 0 0 8px; }
.sources a { word-break: break-all; }
th, td { overflow-wrap: normal; word-break: normal; }
.row > input[type=checkbox] { flex: none; }
.np td:first-child, .np th:first-child { white-space: nowrap; }
tr.unselected { opacity: .55; }
