/* ==========================================================================
   AAA Citation Auditor – Stylesheet
   ========================================================================== */

/* ── Custom properties ─────────────────────────────────────────────────── */
:root {
  --primary:        #1a3557;
  --primary-dark:   #122540;
  --primary-hover:  #1e4069;
  --accent:         #2563eb;
  --bg:             #ffffff;
  --surface:        #f8fafc;
  --surface-2:      #f1f5f9;
  --border:         #e2e8f0;
  --border-strong:  #cbd5e1;
  --text:           #1e293b;
  --text-2:         #475569;
  --text-muted:     #94a3b8;
  --green:          #15803d;
  --green-bg:       #dcfce7;
  --red:            #b91c1c;
  --red-bg:         #fee2e2;
  --amber:          #b45309;
  --amber-bg:       #fef3c7;
  --blue:           #1d4ed8;
  --blue-bg:        #eff6ff;
  --teal:           #0f766e;
  --teal-bg:        #ccfbf1;
  --radius:         8px;
  --radius-sm:      4px;
  --shadow-sm:      0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow:         0 2px 8px rgba(0, 0, 0, 0.10);
  --font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                    "Helvetica Neue", Arial, sans-serif;
  --font-mono:      ui-monospace, SFMono-Regular, "SF Mono", Menlo,
                    Consolas, monospace;
}

/* ── Reset & base ──────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9375rem;
  line-height: 1.6;
  margin: 0;
  padding: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4, h5 {
  color: var(--primary);
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 0.75rem;
}

h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1.05rem; }
h5 { font-size: 0.95rem; }

p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }

ul, ol {
  margin: 0 0 0.75rem;
  padding-left: 1.4rem;
}

code {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85em;
  padding: 0.1em 0.35em;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
  margin: 0 auto;
  max-width: 1060px;
  padding: 0 1.5rem;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
  background: var(--primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  align-items: center;
  display: flex;
  height: 56px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1060px;
  padding: 0 1.5rem;
}

.brand {
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand:hover {
  color: #e2e8f0;
  text-decoration: none;
}

header nav {
  align-items: center;
  display: flex;
  gap: 0.25rem;
}

header nav a {
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.80);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

header nav a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  text-decoration: none;
}

header nav a.active {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.nav-user {
  color: rgba(255, 255, 255, 0.70);
  font-size: 0.8125rem;
  max-width: 140px;
  overflow: hidden;
  padding: 0.35rem 0.5rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main content ───────────────────────────────────────────────────────── */
main {
  min-height: calc(100vh - 56px - 52px);
  padding: 2rem 0 3rem;
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.footer-inner {
  align-items: center;
  color: var(--text-muted);
  display: flex;
  font-size: 0.8rem;
  height: 52px;
  justify-content: space-between;
  margin: 0 auto;
  max-width: 1060px;
  padding: 0 1.5rem;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  padding: 1.5rem;
}

.card-title {
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
}

.card-title h2,
.card-title h3,
.card-title h4 {
  margin-bottom: 0;
}

/* ── Sections ───────────────────────────────────────────────────────────── */
section {
  margin-bottom: 1.5rem;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
button,
.btn {
  align-items: center;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-sm);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  gap: 0.4rem;
  justify-content: center;
  line-height: 1;
  padding: 0.5rem 1.1rem;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

button:hover,
.btn:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  text-decoration: none;
}

button:disabled,
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

button[type="button"],
.btn-secondary {
  background: var(--bg);
  border-color: var(--border-strong);
  color: var(--text-2);
}

button[type="button"]:hover,
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-danger {
  background: var(--red);
  border-color: var(--red);
  color: #ffffff;
}

.btn-danger:hover {
  background: #991b1b;
  border-color: #991b1b;
}

.btn-sm {
  font-size: 0.8125rem;
  padding: 0.3rem 0.7rem;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

label {
  color: var(--text);
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9375rem;
  outline: none;
  padding: 0.5rem 0.75rem;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input[type="number"] {
  min-width: 120px;
  width: auto;
}

select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-position: right 0.65rem center;
  background-repeat: no-repeat;
  background-size: 11px;
  padding-right: 2rem;
}

textarea {
  min-height: 180px;
  resize: vertical;
}

small {
  color: var(--text-muted);
  display: block;
  font-size: 0.8rem;
  margin-top: 0.2rem;
}

input[type="checkbox"] {
  accent-color: var(--accent);
  height: 1em;
  margin-right: 0.4rem;
  width: 1em;
}

label:has(input[type="checkbox"]) {
  align-items: center;
  display: flex;
  font-weight: 400;
  gap: 0;
}

/* ── Validation / Alert messages ─────────────────────────────────────────── */
.validation-message {
  color: var(--red);
  font-weight: 600;
}

.success-message {
  background: var(--green-bg);
  border: 1px solid #86efac;
  border-radius: var(--radius-sm);
  color: var(--green);
  font-weight: 600;
  padding: 0.5rem 0.75rem;
}

.warning-box {
  background: var(--amber-bg);
  border: 1px solid #fcd34d;
  border-left: 4px solid #d97706;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
}

.warning-box h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

/* ── Status badges ──────────────────────────────────────────────────────── */
.verification-badge {
  border-radius: var(--radius-sm);
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.2rem 0.55rem;
  text-transform: uppercase;
}

.status-verified           { background: var(--green-bg);   color: var(--green); }
.status-not_found          { background: var(--amber-bg);   color: var(--amber); }
.status-ambiguous          { background: #fff7ed;            color: #c2410c; }
.status-derived            { background: var(--blue-bg);    color: var(--blue); }
.status-statute_detected   { background: var(--teal-bg);    color: var(--teal); }
.status-statute_verified   { background: var(--green-bg);   color: var(--green); }
.status-error              { background: var(--red-bg);     color: var(--red); }
.status-unverified_no_token { background: var(--surface-2); color: var(--text-2); }

/* ── Status summary grid ────────────────────────────────────────────────── */
.summary-grid {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  margin: 1rem 0;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  text-align: center;
}

.summary-status {
  color: var(--text-2);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.summary-count {
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0.2rem;
}

.summary-card-derived           { background: var(--blue-bg);   border-color: #bfdbfe; }
.summary-card-statute           { background: var(--teal-bg);   border-color: #99f6e4; }
.summary-card-statute-verified  { background: var(--green-bg);  border-color: #86efac; }
.summary-card-active   { outline: 2px solid var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent); font-weight: 700; }
.filter-note           { font-size: 0.85rem; color: var(--text-2); margin: 0.25rem 0 0.5rem; }

/* ── Result groups ──────────────────────────────────────────────────────── */
.result-group {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  padding: 1.25rem 1.5rem;
}

.result-group h4 {
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
  padding-bottom: 0.6rem;
}

.citation-cap-warning {
  margin-bottom: 1rem;
}

/* ── Citation items ─────────────────────────────────────────────────────── */
.citation-item {
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.citation-item:last-child {
  border-bottom: none;
}

.citation-item p {
  margin-bottom: 0.35rem;
}

/* ── Snippet ────────────────────────────────────────────────────────────── */
.snippet {
  background: var(--surface);
  border-left: 3px solid var(--border-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-2);
  font-size: 0.875rem;
  margin-top: 0.25rem;
  padding: 0.4rem 0.75rem;
}

/* ── Filters ────────────────────────────────────────────────────────────── */
.result-filters {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 1rem;
}

.result-filters label {
  font-weight: 500;
  margin-bottom: 0;
  white-space: nowrap;
}

.result-filters select {
  min-width: 160px;
  width: auto;
}

.jump-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  margin: 0.5rem 0 1rem;
  padding: 0;
}

.jump-links li {
  margin: 0;
  padding: 0;
}

.jump-links a {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-2);
  font-size: 0.85rem;
  padding: 0.25rem 0.8rem;
  text-decoration: none;
}

.jump-links a:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  text-decoration: none;
}

/* ── AI Memo box ────────────────────────────────────────────────────────── */
.ai-memo-box {
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  margin: 1rem 0;
  padding: 1rem 1.25rem;
}

.ai-memo-box h3,
.ai-memo-box h5 {
  color: var(--primary);
  font-size: 0.95rem;
  margin-bottom: 0.6rem;
}

.advisory-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.75rem;
}

.memo-source {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.empty-state {
  color: var(--text-2);
  font-style: italic;
}

/* ── Export links ───────────────────────────────────────────────────────── */
.export-links {
  align-items: center;
  color: var(--text-2);
  display: flex;
  font-size: 0.875rem;
  gap: 0.4rem;
  margin: 0.5rem 0;
}

.export-links a {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.8rem;
  padding: 0.25rem 0.6rem;
  text-decoration: none;
}

.export-links a:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  text-decoration: none;
}

/* ── Help-verify links (NOT_FOUND) ─────────────────────────────────────── */
.help-verify-links {
  font-size: 0.875rem;
  margin: 0.25rem 0;
}
.help-verify-links a {
  color: var(--primary);
  text-decoration: underline;
}
.help-verify-links a:hover {
  text-decoration: none;
}

/* ── Verify action box (NOT_FOUND prominent) ───────────────────────────── */
.verify-action-box {
  background: var(--surface-1, #f8f9fa);
  border: 1px solid var(--warning, #f59e0b);
  border-left: 4px solid var(--warning, #f59e0b);
  border-radius: 6px;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
}
.verify-action-title {
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 0 0 0.25rem 0;
}
.verify-action-desc {
  font-size: 0.875rem;
  color: var(--text-muted, #666);
  margin: 0 0 0.5rem 0;
}
.verify-action-links {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
}
.verify-action-links li {
  margin-bottom: 0.2rem;
}
.verify-action-links a {
  color: var(--primary);
  text-decoration: underline;
}
.verify-action-links a:hover {
  text-decoration: none;
}

/* ── Disambiguate hint ──────────────────────────────────────────────────── */
.disambiguate-hint {
  background: var(--amber-bg);
  border-radius: var(--radius-sm);
  color: var(--amber);
  font-size: 0.875rem;
  padding: 0.4rem 0.75rem;
}

/* ── Candidate list ─────────────────────────────────────────────────────── */
.candidate-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
}

.candidate-list li {
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
}

.candidate-list li:last-child {
  border-bottom: none;
}

.candidate-list form {
  align-items: center;
  display: flex;
  gap: 0.75rem;
}

.candidate-list button {
  flex-shrink: 0;
  font-size: 0.8125rem;
  padding: 0.3rem 0.7rem;
}

.candidate-list button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

details > summary {
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.25rem 0;
  user-select: none;
}

details > summary:hover {
  color: var(--primary);
}

/* ── History items ──────────────────────────────────────────────────────── */
.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.history-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  padding: 1.25rem 1.5rem;
}

.history-item-header {
  align-items: flex-start;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.history-item h3 {
  font-size: 1rem;
  margin-bottom: 0.2rem;
}

.run-meta {
  color: var(--text-2);
  font-size: 0.85rem;
}

.run-meta span + span::before {
  color: var(--text-muted);
  content: "·";
  margin: 0 0.4rem;
}

/* ── Drop zone ──────────────────────────────────────────────────────────── */
.drop-zone {
  background: var(--surface);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius);
  cursor: pointer;
  padding: 1.5rem;
  text-align: center;
  transition: background 0.15s, border-color 0.15s;
}

.drop-zone p {
  color: var(--text-2);
  font-size: 0.9rem;
  margin: 0;
}

.drop-zone:hover,
.drop-zone.dragging {
  background: #eff6ff;
  border-color: var(--accent);
}

.drop-zone input[type="file"] {
  display: none;
}

.selected-files {
  font-size: 0.875rem;
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
}

.selected-files li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  margin-bottom: 0.3rem;
  padding: 0.3rem 0.75rem;
}

/* ── Loading spinner ────────────────────────────────────────────────────── */
.audit-loading {
  display: none;
  padding: 3rem 1rem;
  text-align: center;
}

.audit-loading.visible {
  display: block;
}

.spinner {
  animation: aaa-spin 0.8s linear infinite;
  border: 3px solid var(--border);
  border-radius: 50%;
  border-top-color: var(--accent);
  display: inline-block;
  height: 36px;
  width: 36px;
}

@keyframes aaa-spin {
  to { transform: rotate(360deg); }
}

.loading-message {
  color: var(--text-2);
  font-size: 0.9rem;
  margin-top: 0.75rem;
}

/* ── 404 page ───────────────────────────────────────────────────────────── */
.error-page {
  padding: 4rem 1rem;
  text-align: center;
}

.error-code {
  color: var(--border-strong);
  font-size: 6rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: 0.5rem;
}

/* ── Audit mode toggle ──────────────────────────────────────────────────── */
.audit-mode-toggle {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.audit-mode-option {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-weight: 500;
  padding: 0.45rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-1);
  transition: border-color 0.15s, background 0.15s;
}

.audit-mode-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--blue-bg);
  color: var(--accent);
}

.audit-mode-option input[type="radio"] {
  accent-color: var(--accent);
}

/* ── Mode badges ─────────────────────────────────────────────────────────── */
.mode-badge {
  display: inline-block;
  font-size: 0.73rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  vertical-align: middle;
  text-transform: uppercase;
}

.mode-badge-opposing {
  background: var(--amber-bg);
  color: var(--amber);
}

.mode-badge-self {
  background: var(--green-bg);
  color: var(--green);
}

/* ── Opposing mode banner (results header) ──────────────────────────────── */
.opposing-mode-banner {
  font-size: 1.0rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

/* ── Opposing-mode per-citation notes ───────────────────────────────────── */
.opposing-citation-note {
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.3rem 0.7rem;
  border-radius: var(--radius-sm);
  margin: 0.25rem 0 0.5rem;
  display: inline-block;
}

.opposing-note-weak    { background: var(--red-bg);   color: #b91c1c; }
.opposing-note-caution { background: var(--amber-bg); color: var(--amber); }
.opposing-note-ok      { background: var(--green-bg); color: var(--green); }

/* ── Provenance badges ──────────────────────────────────────────────────── */
.provenance-badge {
  border-radius: var(--radius-sm);
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 0.2rem 0.55rem;
}

.provenance-direct           { background: var(--green-bg);   color: var(--green); }
.provenance-heuristic        { background: var(--blue-bg);    color: var(--blue); }
.provenance-user             { background: var(--teal-bg);    color: var(--teal); }
.provenance-short-cite       { background: var(--blue-bg);    color: var(--blue); }
.provenance-search           { background: var(--amber-bg);   color: var(--amber); }

/* Cached variants — muted to indicate served from local cache */
.provenance-direct-cached,
.provenance-heuristic-cached,
.provenance-user-cached,
.provenance-short-cite-cached,
.provenance-search-cached    { background: var(--surface-2);  color: var(--text-2); border: 1px solid var(--border); }

.provenance-ambiguous        { background: #fff7ed;            color: #c2410c; }
.provenance-not-found        { background: var(--amber-bg);   color: var(--amber); }
.provenance-derived          { background: var(--blue-bg);    color: var(--blue); }
.provenance-statute-detected { background: var(--teal-bg);    color: var(--teal); }
.provenance-statute-verified { background: var(--green-bg);   color: var(--green); }
.provenance-error            { background: var(--red-bg);     color: var(--red); }
.provenance-unverified       { background: var(--surface-2);  color: var(--text-2); }
.provenance-unknown          { background: var(--surface-2);  color: var(--text-muted); }

/* ── Provenance breakdown bar ───────────────────────────────────────────── */
.provenance-breakdown {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.8rem;
  gap: 0.4rem;
  margin: 0 0 0.75rem;
}

.provenance-breakdown-label {
  color: var(--text-2);
  font-weight: 500;
}

.provenance-breakdown-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  padding: 0.15rem 0.5rem;
}

/* ── Provenance help section ────────────────────────────────────────────── */
.provenance-help-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 1.5rem;
  padding: 0.75rem 1rem;
}

.provenance-help-section > summary {
  color: var(--text-2);
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.1rem 0;
  user-select: none;
}

.provenance-help-section > summary:hover {
  color: var(--primary);
}

.provenance-help-list {
  margin: 0.75rem 0 0;
}

.provenance-help-list dt {
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: 0.6rem;
}

.provenance-help-list dd {
  color: var(--text-2);
  font-size: 0.85rem;
  margin: 0.1rem 0 0 1rem;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .header-inner {
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.25rem;
    height: auto;
    padding: 0.5rem 1rem;
  }

  .header-inner .brand {
    flex: 1 0 auto;
    line-height: 36px;
  }

  header nav {
    flex-wrap: wrap;
    gap: 0.15rem;
    width: 100%;
  }

  header nav a {
    font-size: 0.78rem;
    padding: 0.25rem 0.45rem;
  }

  .nav-user {
    font-size: 0.78rem;
    max-width: 120px;
    padding: 0.25rem 0.35rem;
  }

  .container {
    padding: 0 1rem;
  }

  main {
    padding: 1rem 0 2rem;
  }

  .card {
    padding: 1rem;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .result-filters {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-filters select {
    width: 100%;
  }

  .history-item-header {
    flex-direction: column;
    gap: 0.5rem;
  }

  .candidate-list form {
    flex-wrap: wrap;
  }

  .footer-inner {
    flex-direction: column;
    gap: 0.25rem;
    height: auto;
    padding: 0.75rem 1rem;
    text-align: center;
  }
}

/* ── Print ──────────────────────────────────────────────────────────────── */
@media print {
  header, footer, .audit-loading, .result-filters,
  .jump-links, .export-links, nav {
    display: none !important;
  }

  body {
    font-size: 12pt;
  }

  .card, .result-group, .history-item {
    border: 1px solid #ccc;
    box-shadow: none;
  }
}
