:root {
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #1a2b3c;
  --muted: #5c6b7a;
  --primary: #1e5f8a;
  --primary-dark: #164a6d;
  --success: #1e7a4a;
  --danger: #b42318;
  --border: #d8e0ea;
  --shadow: 0 2px 8px rgba(26, 43, 60, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #1e3a5f, #1e5f8a);
  color: white;
}

.topbar h1 { margin: 0; font-size: 1.35rem; }
.topbar p { margin: 0.2rem 0 0; opacity: 0.85; font-size: 0.9rem; }

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 1.5rem 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.tab {
  border: none;
  background: transparent;
  padding: 0.65rem 1rem;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  font-weight: 600;
}

.tab.active {
  background: var(--bg);
  color: var(--primary);
}

main { padding: 1.25rem 1.5rem 2rem; }

.panel { display: none; }
.panel.active { display: block; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--card);
  border-radius: 10px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.card .value { font-size: 1.6rem; font-weight: 700; color: var(--primary); }
.card .label { color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

.card.highlight {
  border: 2px solid var(--success);
  background: #f0faf4;
}

.card.highlight .value { color: var(--success); }

.efficiency-note { font-size: 0.95rem; border-left-color: var(--success); }

h2 { margin: 1.5rem 0 0.75rem; font-size: 1.1rem; }

.table-wrap {
  overflow: auto;
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

th, td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef3f8;
  position: sticky;
  top: 0;
  z-index: 1;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: #e8eef4; color: var(--text); }
.btn.success { background: var(--success); color: white; }
.btn.danger { background: var(--danger); color: white; }
.btn.small { padding: 0.35rem 0.65rem; font-size: 0.8rem; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

.qa-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.qa-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
  min-height: 560px;
}

.review-card {
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1rem;
  min-height: 320px;
}

.hidden { display: none !important; }

.exec-card {
  background: var(--card);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
  line-height: 1.55;
  border-left: 4px solid var(--primary);
}

.exec-toolbar {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.badge {
  background: #e8f4ec;
  color: var(--success);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.playbook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.playbook-item {
  background: var(--card);
  border-radius: 8px;
  padding: 0.85rem;
  box-shadow: var(--shadow);
  font-size: 0.88rem;
}

.playbook-item strong { display: block; color: var(--primary); margin-bottom: 0.35rem; }

.risk-list { line-height: 1.5; }

.validation-summary-row {
  background: #e8f4ec;
  font-weight: 600;
}

.exemplar-card {
  background: #fff8f8;
  border: 1px solid #f0d4d4;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.disp-auto_accept { color: var(--success); font-weight: 700; }
.disp-human_verify { color: #b45309; font-weight: 700; }
.disp-exception { color: var(--danger); font-weight: 700; }
.disp-pending { color: var(--muted); font-weight: 600; }

.trust-params {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

@media (max-width: 1100px) {
  .qa-layout { grid-template-columns: 1fr; }
}

.qa-sidebar, .review-card {
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.pool-list {
  max-height: 420px;
  overflow: auto;
  margin-top: 0.5rem;
}

.pool-item {
  display: flex;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.record-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.record-pill {
  border: 1px solid var(--border);
  background: white;
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.record-pill.active { background: var(--primary); color: white; border-color: var(--primary); }
.record-pill.done { border-color: var(--success); color: var(--success); }

.sample-bulk-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}

.sample-bulk-actions.hidden { display: none; }

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

.record-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.field-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.field-row .field-name {
  font-weight: 700;
}

.field-row .ocr-value {
  background: #f7fafc;
  padding: 0.5rem;
  border-radius: 6px;
  margin: 0.5rem 0;
  font-family: Consolas, monospace;
  font-size: 0.82rem;
  word-break: break-word;
}

.field-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.field-actions input, .field-actions textarea {
  flex: 1;
  min-width: 160px;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.field-row.correct { border-left: 4px solid var(--success); }
.field-row.incorrect { border-left: 4px solid var(--danger); }
.field-row.no-validation { background: #fffdf8; }

.field-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.35rem;
  vertical-align: middle;
}

.field-badge.has-val { background: #e6fffa; color: #234e52; }
.field-badge.no-val { background: #fefcbf; color: #744210; }

.progress-bar {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  background: transparent;
  height: auto;
  overflow: visible;
}

.progress-track {
  background: #e8eef4;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--success);
  transition: width 0.3s;
}

.progress-label {
  font-size: 0.78rem;
  color: var(--muted, #64748b);
}

.field-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
}

.field-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}

.field-title {
  font-weight: 700;
}

.workflow-list li { margin-bottom: 0.75rem; line-height: 1.45; }

.stp-yes { color: var(--success); font-weight: 700; }
.stp-no { color: var(--danger); font-weight: 700; }

@media (max-width: 900px) {
  .qa-layout { grid-template-columns: 1fr; }
}

.history-audit { margin-top: 1.5rem; }

.gt-filters select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-width: 11rem;
}

.gt-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.gt-stat strong { color: var(--text, #1a202c); }

.gt-stat-true { color: var(--success); font-weight: 600; }
.gt-stat-false { color: var(--danger); font-weight: 600; }
.gt-stat-pending { color: #718096; font-weight: 600; }

.gt-table-wrap { max-height: 70vh; overflow: auto; }

.gt-table td { vertical-align: top; font-size: 0.82rem; }
.gt-table .gt-input {
  width: 100%;
  min-width: 8rem;
  padding: 0.3rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
}
.gt-table .gt-ocr-cell {
  max-width: 14rem;
  word-break: break-word;
  color: var(--muted);
}
.gt-table .gt-row-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.gt-table .btn.small {
  padding: 0.25rem 0.45rem;
  font-size: 0.75rem;
}

.gt-row-true { background: #f0fff4; }
.gt-row-false { background: #fff5f5; }
.gt-row-pending { background: transparent; }

.gt-match-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}
.gt-match-true { background: #c6f6d5; color: #22543d; }
.gt-match-false { background: #fed7d7; color: #742a2a; }
.gt-match-pending { background: #edf2f7; color: #4a5568; }

.gt-empty {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem !important;
}

.label-edit-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.label-edit-card.reviewed-correct { border-left: 4px solid var(--success); }
.label-edit-card.reviewed-incorrect { border-left: 4px solid var(--danger); }
.label-edit-card.unreviewed { border-left: 4px solid #cbd5e0; }

.label-meta { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.35rem; }

#sample-size { padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 6px; }
