/* — CSS Variables — */
:root {
  --bg: #0f1117;
  --card: #1a1d27;
  --card-hover: #1f2233;
  --border: #2e3147;
  --accent: #6c63ff;
  --accent-hover: #7b73ff;
  --text: #e2e8f0;
  --text-secondary: #8892a4;
  --muted: #5a6178;
  --ok: #48bb78;
  --err: #fc8181;
  --warn: #f6ad55;
  --google: #4285f4;
  --azure: #0078d4;
  --ocrspace: #ff6b35;
  --radius: 10px;
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;
}

/* — Reset & base — */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* — Header — */
.header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 24px;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-icon { font-size: 1.4rem; }
.header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

/* — Cards — */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.card-hint {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

/* — Drop zone — */
.drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  margin-bottom: 20px;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(108, 99, 255, .06);
}
.drop-zone.has-file {
  border-color: var(--ok);
  background: rgba(72, 187, 120, .06);
}
.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.drop-zone-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: .9rem;
  pointer-events: none;
}
.drop-icon { font-size: 1.3rem; }
.drop-zone.has-file .drop-zone-inner { color: var(--ok); }

/* — Engine selector — */
.engine-section {
  margin-bottom: 20px;
}
.engine-section h3 {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.engine-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.engine-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  background: transparent;
  user-select: none;
}
.engine-chip:hover {
  border-color: var(--muted);
  background: var(--card-hover);
}
/* Hide both radio and checkbox inputs inside chips */
.engine-chip input[type="radio"],
.engine-chip input[type="checkbox"] {
  display: none;
}
.engine-chip.selected {
  border-color: var(--accent);
  background: rgba(108, 99, 255, .12);
  box-shadow: 0 0 0 1px var(--accent);
}
.engine-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.engine-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
}
.engine-badge-type {
  font-size: .65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255,255,255,.07);
  color: var(--text-secondary);
}
.engine-hint {
  font-size: .75rem;
  color: var(--muted);
  margin-top: 4px;
}

/* — Confidence badge in OCR cell — */
.conf-badge {
  display: inline-block;
  font-size: .68rem;
  font-family: var(--mono);
  color: var(--muted);
  margin-top: 4px;
  padding: 1px 6px;
  border-radius: 10px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
}
.conf-best {
  color: var(--ok);
  background: rgba(72,187,120,.1);
  border-color: rgba(72,187,120,.2);
}

/* — Hints row — */
.hints-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.hint-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 140px;
}
.hint-field label {
  font-size: .8rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.hint-field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: .85rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  font-family: var(--font);
}
.hint-field input:focus { border-color: var(--accent); }
.hint-field input::placeholder { color: var(--muted); }
.hint-tag {
  background: rgba(108, 99, 255, .15);
  color: var(--accent);
  font-size: .65rem;
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: 4px;
  font-weight: 600;
}

/* — Buttons — */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  font-family: var(--font);
  transition: background .15s, transform .1s, opacity .15s;
}
.btn:active { transform: scale(0.98); }
.btn-icon { font-size: .8rem; }
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  background: var(--muted);
  cursor: not-allowed;
  transform: none;
  opacity: .6;
}
.btn-sm {
  padding: 7px 14px;
  font-size: .8rem;
  border-radius: 6px;
}
.btn-secondary {
  background: rgba(255,255,255,.08);
  color: var(--text-secondary);
}
.btn-secondary:hover { background: rgba(255,255,255,.12); }

/* — Progress bar — */
.progress-bar-wrap {
  height: 6px;
  background: rgba(255,255,255,.06);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 12px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 3px;
  width: 0%;
  transition: width .3s ease;
}
.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.progress-meta span {
  font-size: .82rem;
  color: var(--text-secondary);
}
.progress-timer { font-variant-numeric: tabular-nums; }

/* — Summary — */
.summary-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  font-size: .95rem;
  margin-bottom: 14px;
}
.summary-item { color: var(--text-secondary); }
.summary-item strong { font-size: 1.1rem; color: var(--text); }
.summary-item.pass strong { color: var(--ok); }
.summary-item.fail strong { color: var(--err); }
.summary-item.manual strong { color: var(--warn); }

.controls-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: .82rem;
  color: var(--text-secondary);
  user-select: none;
}
.toggle-label input {
  cursor: pointer;
  accent-color: var(--accent);
}

/* — Results table — */
.table-wrap { overflow-x: auto; }
.results-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}
.results-table th {
  background: rgba(255,255,255,.03);
  text-align: left;
  padding: 10px 14px;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 2;
  white-space: nowrap;
}
.results-table th .engine-dot {
  display: inline-block;
  vertical-align: middle;
  margin-right: 5px;
  margin-bottom: 1px;
}
.results-table td {
  padding: 10px 14px;
  vertical-align: top;
  border-bottom: 1px solid rgba(255,255,255,.04);
  font-size: .85rem;
  color: var(--text);
}
.results-table tr:last-child td { border-bottom: none; }
.results-table tr:hover td { background: rgba(255,255,255,.02); }

/* Image thumbnail */
.thumb-wrap { position: relative; display: inline-block; }
.thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: opacity .15s;
}
.thumb:hover { opacity: .8; }
.thumb-missing {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: rgba(255,255,255,.02);
  color: var(--muted);
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.thumb-label {
  font-size: .7rem;
  color: var(--muted);
  margin-top: 4px;
  text-align: center;
}

/* Text columns */
.text-cell {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--mono);
  font-size: .78rem;
  max-width: 260px;
  min-width: 130px;
  line-height: 1.5;
}
.text-line { display: block; min-height: 1.4em; }

/* Status badge */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .03em;
}
.badge-pass   { background: rgba(72,187,120,.15);  color: var(--ok); }
.badge-fail   { background: rgba(252,129,129,.15); color: var(--err); }
.badge-manual { background: rgba(246,173,85,.15);  color: var(--warn); }
.badge-section {
  display: block;
  font-size: .68rem;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 400;
}

/* Engine badge in results (legacy, kept for compatibility) */
.engine-result-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .68rem;
  color: var(--text-secondary);
  margin-top: 5px;
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.06);
}
.engine-result-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Review buttons */
.review-cell { white-space: nowrap; }
.btn-ok {
  background: rgba(72,187,120,.12);
  color: var(--ok);
  border: 1px solid rgba(72,187,120,.25);
}
.btn-ok:hover { background: rgba(72,187,120,.2); }
.btn-err {
  background: rgba(252,129,129,.12);
  color: var(--err);
  border: 1px solid rgba(252,129,129,.25);
}
.btn-err:hover { background: rgba(252,129,129,.2); }
.decision-ok  { font-size: .78rem; color: var(--ok);  font-weight: 600; }
.decision-err { font-size: .78rem; color: var(--err); font-weight: 600; }

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 16px 0 0;
  flex-wrap: wrap;
}
.page-btn {
  width: 34px; height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: .85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  font-family: var(--font);
}
.page-btn:hover {
  background: var(--card-hover);
  border-color: var(--accent);
  color: var(--text);
}
.page-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.page-btn:disabled {
  opacity: .3;
  cursor: default;
}

/* — Lightbox — */
.lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.88);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.lightbox-overlay.open { display: flex; }
.lightbox-overlay img {
  max-width: 92vw;
  max-height: 92vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
}
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  background: rgba(255,255,255,.12);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,.2); }

/* — Error — */
.error-msg {
  background: rgba(252,129,129,.12);
  color: var(--err);
  border: 1px solid rgba(252,129,129,.2);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: .85rem;
  margin-bottom: 16px;
}

/* — Responsive — */
@media (max-width: 700px) {
  .thumb { width: 60px; height: 60px; }
  .engine-chips { flex-direction: column; }
  .text-cell { max-width: 160px; min-width: 100px; }
}
