/* Minimal base styles. Phase 7 expands these. */
:root {
  --bg: #ffffff;
  --fg: #1f2933;
  --muted: #616e7c;
  --accent: #1f6feb;
  --border: #d9dee3;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.site-header .brand { font-weight: 600; color: var(--fg); text-decoration: none; }
.site-header nav a { margin-left: 1rem; color: var(--accent); text-decoration: none; }
.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem; }
.flashes { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 4px; margin-bottom: 0.5rem; }
.flash-error { border-color: #d14343; }
.flash-success { border-color: #2e8b57; }
.muted { color: var(--muted); font-size: 0.875rem; }
.error-page h1 { margin-top: 0; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 0.5rem; max-width: 360px; }
.form label { font-weight: 600; margin-top: 0.5rem; }
.form input { padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.button { margin-top: 1rem; padding: 0.6rem 1rem; background: var(--accent); color: #fff; border: 0; border-radius: 4px; font: inherit; cursor: pointer; }
.auth-card { max-width: 420px; margin: 2rem auto; }
.inline-form { display: inline; margin-left: 1rem; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }

/* Tables and page headers */
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.page-header h1 { margin: 0; }
.table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
.table th, .table td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); }
.table th { font-weight: 600; }
a.button { display: inline-block; text-decoration: none; margin-top: 0; }

/* Upload form */
.form select { padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.file-list { list-style: none; padding: 0; margin: 0.5rem 0 0; font-size: 0.9rem; }
.file-ok { color: var(--fg); }
.file-bad { color: #b42318; }
.button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Document details */
.form-wide { max-width: 640px; }
.form textarea { padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; resize: vertical; }
.field-error { color: #b42318; font-size: 0.875rem; margin: 0; }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; margin: 0.5rem 0 1rem; }
.details dt { font-weight: 600; }
.details dd { margin: 0; overflow-wrap: anywhere; }
.check-report { background: #f6f6f6; border: 1px solid var(--border); border-radius: 4px; padding: 0.75rem; font-size: 0.85rem; white-space: pre-wrap; }
.text-error { color: #b42318; }
.text-preview summary { cursor: pointer; color: var(--accent); margin-bottom: 0.5rem; }
.batch-form { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }
.batch-form .button { margin-top: 0; }

/* Research */
.search-form { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }
.search-form .button { margin-top: 0; }
.search-form label { font-weight: 600; }
.search-input { flex: 1 1 320px; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.search-count { width: 4.5rem; padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; }
.checkbox { font-weight: normal; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Reports */
.job { padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 4px; margin: 1rem 0; }
.job-queued, .job-running { border-color: var(--accent); }
.job-failed { border-color: #d14343; }
.report-section { margin-bottom: 1.25rem; }
.report-section h3 { margin-bottom: 0.25rem; }

/* Review */
.badge { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.05rem 0.5rem; border-radius: 999px; border: 1px solid var(--border); vertical-align: middle; margin-left: 0.4rem; }
.badge-approved { border-color: #2e8b57; color: #2e8b57; }
.badge-rejected { border-color: #d14343; color: #b42318; }
.badge-stale { border-color: #b7791f; color: #975a16; }
.button-small { padding: 0.3rem 0.6rem; font-size: 0.85rem; margin-left: 0.5rem; }
.review-form { display: flex; flex-direction: column; gap: 0.4rem; max-width: 640px; margin-top: 0.5rem; }
.review-form .choices label { margin-right: 1rem; font-weight: normal; }
.review-form textarea { padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; font: inherit; resize: vertical; }
.review-form .button { margin-top: 0.25rem; align-self: flex-start; }
.evidence { margin: 0.5rem 0 0; padding-left: 1.2rem; font-size: 0.9rem; }
.evidence li { margin-bottom: 0.4rem; }
.evidence blockquote { margin: 0.2rem 0 0; padding-left: 0.6rem; border-left: 3px solid var(--border); color: var(--muted); white-space: pre-wrap; }
.verdict { border: 1px solid var(--border); border-radius: 4px; padding: 0.75rem 1rem; margin: 1rem 0; }

/* Dashboard */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.75rem; margin: 1rem 0 1.5rem; }
.card { display: flex; flex-direction: column; gap: 0.15rem; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: 6px; color: var(--fg); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card-number { font-size: 1.75rem; font-weight: 600; line-height: 1.1; }
.card-label { font-weight: 600; }

/* Doctor */
.doctor-table td:first-child { font-weight: 600; white-space: nowrap; }
.status-ok { color: #2e8b57; }
.status-fail { color: #b42318; }
.status-warn { color: #975a16; }
.doctor-fix { font-size: 0.875rem; color: var(--muted); }

/* Reference */
.tier-adversarial { border-color: #d14343; color: #b42318; }
.tier-smoke { border-color: #b7791f; color: #975a16; }
.tier-standard { border-color: var(--border); color: var(--muted); }
.marks td.mark-yes { background: #e6f4ea; text-align: center; font-weight: 600; }
.marks td.mark-no { text-align: center; color: #c5ccd3; }

/* Findings grid (Phase 11d): wide table, scrolls sideways inside its criterion section */
.grid-scroll { overflow-x: auto; margin-bottom: 1rem; }
.grid-table { font-size: 0.85rem; min-width: 1400px; }
.grid-table td { vertical-align: top; }
.grid-table th:first-child, .grid-table td:first-child { width: 3rem; }
.grid-source { margin-top: 0.25rem; overflow-wrap: anywhere; }
.grid-hi td { background: #fff7f5; }

/* Jobs (Phase 11f) */
.inline-actions { margin: 0.5rem 0 1rem; }
.inline-actions .inline-form { margin-left: 0; margin-right: 1rem; }
.form label.radio { font-weight: 400; margin-top: 0; }
.job-progress [data-field="why"] { display: block; margin-top: 0.25rem; }

/* Human review (Phase 11j) */
.review-row { border: 1px solid var(--border); border-radius: 4px; padding: 0.5rem 0.75rem; margin-bottom: 0.5rem; }
.thread { list-style: none; padding: 0; }
.thread .msg { border-left: 3px solid var(--border); padding: 0.25rem 0.75rem; margin-bottom: 0.5rem; }
.thread .msg-assistant { border-left-color: #2e8b57; }
.thread .msg-system { border-left-color: #b42318; }

/* Stage buttons (Phase 11m) */
.stage-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.5rem 0; }
.stage-buttons .inline-form { margin: 0; }
.stage-buttons .button { margin: 0; }

/* Help page */
.help { max-width: 60rem; }
.help h2 { margin-top: 2rem; }
.help ol > li, .help ul > li { margin-bottom: 0.5rem; }
.help .verdict ol { margin-bottom: 0; }
.page-intro { max-width: 60rem; margin: 0.25rem 0 1rem; color: var(--fg); }
