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

:root {
  --bg:          #f8fafc;
  --bg2:         #ffffff;
  --bg3:         #f1f5f9;
  --surface:     #ffffff;
  --surface2:    #f8fafc;
  --border:      #e2e8f0;
  --border2:     #cbd5e1;
  --accent:      #4f46e5;
  --accent2:     #7c3aed;
  --accent-glow: rgba(79,70,229,0.15);
  --success:     #10b981;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --info:        #3b82f6;
  --text:        #0f172a;
  --text2:       #475569;
  --text3:       #64748b;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px rgba(0,0,0,0.05);
  --shadow-lg:   0 8px 48px rgba(0,0,0,0.08);
  --font:        'Inter', system-ui, sans-serif;
  --mono:        'JetBrains Mono', 'Fira Code', monospace;
  --sidebar-w:   260px;
}

html, body { height: 100%; overflow: hidden; }
body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }

/* ── Layout ───────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ──────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { flex-shrink: 0; }
.brand-name { font-weight: 700; font-size: 15px; color: var(--text); }
.brand-sub  { font-size: 11px; color: var(--text3); font-weight: 500; }

.sidebar-section { padding: 16px; border-bottom: 1px solid var(--border); }
.section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text3); margin-bottom: 10px;
}

/* Status list */
.status-list { display: flex; flex-direction: column; gap: 6px; }
.status-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text2); padding: 4px 0;
}
.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text3); flex-shrink: 0;
  box-shadow: 0 0 0 0 var(--success);
}
.status-item.ok   .status-dot { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-item.warn .status-dot { background: var(--warning); }
.status-item.err  .status-dot { background: var(--danger); }

/* Mode selector */
.mode-group { display: flex; flex-direction: column; gap: 6px; }
.mode-btn {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 10px 12px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: transparent; transition: all 0.2s;
}
.mode-btn:hover { border-color: var(--accent); background: var(--accent-glow); }
.mode-btn.active { border-color: var(--accent); background: var(--accent-glow); }
.mode-btn input[type=radio] { display: none; }
.mode-icon { font-size: 18px; }
.mode-title { font-size: 13px; font-weight: 600; color: var(--text); }
.mode-desc  { font-size: 11px; color: var(--text3); }

/* Select */
.select-ctrl {
  width: 100%; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm);
  font-family: var(--font); font-size: 13px; cursor: pointer; outline: none;
  transition: border-color 0.2s;
}
.select-ctrl:focus { border-color: var(--accent); }

.sidebar-bottom { margin-top: auto; padding: 16px; }
.accuracy-badge {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.accuracy-label { font-size: 11px; font-weight: 600; opacity: 0.85; margin-bottom: 2px; }
.accuracy-value { font-size: 20px; font-weight: 800; }

/* ── Main area ────────────────────────────────────────────────────── */
.main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; background: var(--bg);
}

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--bg2); flex-shrink: 0;
}
.page-title { font-size: 18px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.timing-badge {
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 12px;
  font-size: 12px; font-weight: 600; color: var(--accent);
}
.timing-icon { font-size: 13px; }

/* Workspace */
.workspace {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr;
  gap: 0; overflow: hidden;
}

/* Panel */
.panel {
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
}
.panel::-webkit-scrollbar { width: 4px; }
.panel::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.upload-panel { border-right: 1px solid var(--border); }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  background: var(--bg2); flex-shrink: 0; position: sticky; top: 0; z-index: 2;
}
.panel-title { font-size: 13px; font-weight: 700; color: var(--text); }
.panel-meta  { font-size: 11px; color: var(--text3); }
.panel-actions { display: flex; gap: 6px; }

/* Drop zone */
.drop-zone {
  margin: 20px; border: 2px dashed var(--border2); border-radius: var(--radius);
  padding: 40px 20px; text-align: center; cursor: pointer; transition: all 0.25s;
  background: var(--bg2);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent); background: var(--accent-glow);
}
.drop-icon  { font-size: 48px; margin-bottom: 14px; }
.drop-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.drop-sub   { font-size: 12px; color: var(--text3); margin-bottom: 18px; }

/* Preview */
.preview-wrap { margin: 0 20px 0; }
.img-canvas-wrap {
  position: relative; display: inline-block; width: 100%;
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
}
#preview-img {
  display: block; width: 100%; height: auto; max-height: 300px;
  object-fit: contain; background: var(--surface);
}
#overlay-canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
}

/* Process button */
.btn-process {
  margin: 16px 20px 20px; padding: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  border: none; border-radius: var(--radius); color: #fff;
  font-size: 15px; font-weight: 700; cursor: pointer; display: flex;
  align-items: center; justify-content: center; gap: 8px;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}
.btn-process:hover { transform: translateY(-1px); box-shadow: 0 6px 28px rgba(99,102,241,0.55); }
.btn-process:active { transform: translateY(0); }
.btn-process:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-process-icon { font-size: 18px; }

/* Buttons */
.btn-primary {
  padding: 9px 18px; background: var(--accent); border: none;
  border-radius: var(--radius-sm); color: #fff; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.btn-primary:hover { background: var(--accent2); }
.btn-primary.small { padding: 5px 12px; font-size: 11px; }
.btn-ghost {
  padding: 7px 14px; background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text2); font-size: 13px;
  font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost.small { padding: 5px 10px; font-size: 11px; }
.btn-ghost.danger { border-color: rgba(239,68,68,0.4); color: #ef4444; }
.btn-ghost.danger:hover { background: rgba(239,68,68,0.15); }
.full-width { width: 100%; }

/* ── Inline Header Action Buttons (Input Document Bar) ────────── */
.btn-extract-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.35);
}
.btn-extract-inline:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.5);
}
.btn-extract-inline:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}
.btn-clear-inline {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  background: transparent;
  color: var(--text3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-clear-inline:hover {
  border-color: #ef4444;
  color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}

/* ── Crop Action Bar ────────────────────────────────────────────── */
.crop-btn-auto {
  padding: 6px 14px; border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  color: #fff; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 10px rgba(99,102,241,0.35);
}
.crop-btn-auto:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(99,102,241,0.5); }
.crop-btn-auto.small { padding: 4px 10px; font-size: 11px; }

.crop-btn-manual {
  padding: 6px 14px; border: 1px solid #10b981; border-radius: var(--radius-sm);
  background: rgba(16,185,129,0.12); color: #10b981;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}
.crop-btn-manual:hover { background: rgba(16,185,129,0.25); transform: translateY(-1px); }
.crop-btn-manual.small { padding: 4px 10px; font-size: 11px; }

.crop-btn-revert {
  padding: 5px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text3);
  font-size: 12px; cursor: pointer; transition: all 0.2s;
}
.crop-btn-revert:hover { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.08); }

.crop-status-badge {
  padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600;
}
.crop-status-badge.auto {
  background: rgba(99,102,241,0.15); color: var(--accent); border: 1px solid rgba(99,102,241,0.3);
}
.crop-status-badge.manual {
  background: rgba(16,185,129,0.15); color: #10b981; border: 1px solid rgba(16,185,129,0.3);
}

/* ── Results panel ────────────────────────────────────────────────── */
.results-panel { background: var(--bg); }

.empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 60px 20px; text-align: center;
}
.empty-icon  { font-size: 52px; margin-bottom: 16px; opacity: 0.6; }
.empty-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-sub   { font-size: 13px; color: var(--text3); }

/* Loading */
.loading-state {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px;
}
.spinner-ring {
  width: 48px; height: 48px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin-bottom: 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-steps { display: flex; flex-direction: column; gap: 6px; text-align: center; }
.loading-step { font-size: 13px; color: var(--text3); }
.loading-step.active { color: var(--accent); font-weight: 600; }

/* Results content */
.results-content { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

/* Badges row */
.badges-row { display: flex; flex-wrap: wrap; gap: 8px; }
.badge {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  border: 1px solid transparent;
}
.badge-ok      { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.3); color: #10b981; }
.badge-warn    { background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.3); color: #f59e0b; }
.badge-err     { background: rgba(239,68,68,0.12);  border-color: rgba(239,68,68,0.3);  color: #ef4444; }
.badge-info    { background: rgba(99,102,241,0.12); border-color: rgba(99,102,241,0.3); color: #818cf8; }
.badge-neutral { background: var(--surface); border-color: var(--border); color: var(--text2); }

/* Structured KV grid */
.structured-section { border-color: rgba(99,102,241,0.5); }
.doc-type-badge {
  margin-left: auto; padding: 2px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 700; background: rgba(99,102,241,0.2);
  color: #818cf8; border: 1px solid rgba(99,102,241,0.4);
}
.kv-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px;
  background: var(--border);
}
.kv-card {
  padding: 12px 16px; background: var(--surface);
  display: flex; flex-direction: column; gap: 4px;
}
.kv-card:nth-child(odd) { border-right: 1px solid var(--border); }
.kv-card-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text3); display: flex;
  align-items: center; justify-content: space-between;
}
.kv-card-value {
  font-size: 14px; font-weight: 600; color: var(--text);
  font-family: var(--mono); word-break: break-all;
}

/* Source tags */
.source-tag {
  padding: 2px 8px; border-radius: 10px; font-size: 10px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  white-space: nowrap;
}
.src-mrz      { background: rgba(16,185,129,0.15); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.src-vlm      { background: rgba(139,92,246,0.15); color: #a78bfa; border: 1px solid rgba(139,92,246,0.3); }
.src-template { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.src-ocr      { background: rgba(99,102,241,0.15); color: #818cf8; border: 1px solid rgba(99,102,241,0.3); }

/* Annotated image */
.annotated-img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); display: block; }

/* Section */
.result-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.section-title {
  padding: 12px 16px; font-size: 12px; font-weight: 700;
  color: var(--text2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg2);
}

/* MRZ section */
.mrz-section { border-color: rgba(99,102,241,0.4); }
.mrz-badge {
  margin-left: auto; padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 700;
}
.mrz-raw {
  padding: 12px 16px; font-family: var(--mono); font-size: 12px;
  color: #0369a1; background: #f0f9ff; letter-spacing: 0.06em;
  white-space: pre-wrap; word-break: break-all; line-height: 2;
  border-bottom: 1px solid var(--border);
}
.mrz-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0; }
.mrz-field {
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.mrz-field:nth-child(even) { border-right: none; }
.mrz-field-label { font-size: 10px; color: var(--text3); font-weight: 600; text-transform: uppercase; margin-bottom: 3px; }
.mrz-field-value { font-size: 13px; font-weight: 600; color: var(--text); }

/* Fields table */
.fields-table { width: 100%; border-collapse: collapse; }
.fields-table th {
  padding: 10px 14px; text-align: left; font-size: 10px;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text3); border-bottom: 1px solid var(--border);
  background: var(--bg2);
}
.fields-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); }
.fields-table tr:last-child td { border-bottom: none; }
.fields-table tr:hover td { background: var(--surface2); }
.field-name { font-weight: 600; font-size: 13px; }
.field-value { font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.conf-bar-wrap { display: flex; align-items: center; gap: 6px; }
.conf-bar {
  height: 4px; width: 48px; background: var(--border);
  border-radius: 4px; overflow: hidden;
}
.conf-bar-fill { height: 100%; border-radius: 4px; }
.conf-text { font-size: 11px; font-weight: 600; }

/* Pipeline steps */
.pipeline-steps { padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.pipe-step {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; background: var(--bg2); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.pipe-step-name { flex: 1; font-size: 12px; font-weight: 500; }
.pipe-step-ms   { font-size: 11px; color: var(--accent); font-family: var(--mono); font-weight: 600; }
.pipe-step-note { font-size: 11px; color: var(--text3); }

/* Faces */
.faces-row { display: flex; gap: 10px; padding: 12px 16px; flex-wrap: wrap; }
.face-chip { border-radius: var(--radius-sm); overflow: hidden; border: 2px solid var(--accent); }
.face-chip img { width: 80px; height: 90px; object-fit: cover; display: block; }

/* ── MODALS & TEMPLATE ANNOTATOR STYLES ────────────────────────── */
.modal-backdrop {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(8px);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-content {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.editor-modal-content {
  width: 95vw; height: 92vh; max-width: 1400px;
}
.drawer-modal-content {
  width: 600px; max-height: 80vh;
}
.modal-header {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-sub   { font-size: 12px; color: var(--text3); margin-top: 2px; }
.modal-close {
  background: transparent; border: none; font-size: 24px;
  color: var(--text3); cursor: pointer; transition: color 0.2s;
}
.modal-close:hover { color: #fff; }

/* Editor Workspace */
.editor-workspace {
  flex: 1; display: grid; grid-template-columns: 1fr 360px;
  overflow: hidden;
}
.editor-canvas-container {
  background: #050608; display: flex; align-items: center;
  justify-content: center; padding: 20px; overflow: auto;
  position: relative;
}
.editor-canvas-wrap {
  position: relative; display: inline-block;
  box-shadow: 0 0 30px rgba(0,0,0,0.8); border: 1px solid var(--border2);
}
#editor-bg-img {
  display: block; max-width: 100%; max-height: 78vh; object-fit: contain;
}
#editor-canvas {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  cursor: crosshair;
}

/* Editor Sidebar */
.editor-sidebar {
  background: var(--bg); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px; gap: 12px;
  overflow-y: auto;
}
.editor-sidebar-header { display: flex; flex-direction: column; gap: 6px; }
.input-label { font-size: 11px; font-weight: 700; uppercase; color: var(--text3); }
.text-input {
  width: 100%; padding: 8px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-family: var(--font); font-size: 13px; outline: none;
}
.text-input:focus { border-color: var(--accent); }

.editor-actions-row { display: flex; gap: 8px; }
.editor-fields-list {
  flex: 1; display: flex; flex-direction: column; gap: 8px;
  overflow-y: auto; padding-right: 4px;
}
.editor-field-card {
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px; display: flex;
  flex-direction: column; gap: 6px; cursor: pointer; transition: all 0.2s;
}
.editor-field-card:hover { border-color: var(--accent); }
.editor-field-card.selected { border-color: var(--accent); background: var(--accent-glow); }

.field-card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.field-card-input {
  flex: 1; padding: 4px 8px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text); font-size: 12px; font-weight: 600;
}
.field-card-select {
  padding: 4px 6px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text2); font-size: 11px;
}

.editor-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }

/* Master templates list drawer */
.templates-list { padding: 16px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.template-item-card {
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); display: flex; align-items: center;
  justify-content: space-between;
}
.template-item-name { font-weight: 700; font-size: 14px; }
.template-item-meta { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* Responsive */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .workspace { grid-template-columns: 1fr; overflow-y: auto; }
  .upload-panel { border-right: none; border-bottom: 1px solid var(--border); }
  html, body { overflow: auto; }
  .app { height: auto; min-height: 100vh; }
  .main { overflow: visible; }
  .kv-grid { grid-template-columns: 1fr; }
  .editor-workspace { grid-template-columns: 1fr; }
}

/* ── Topbar Enhancements ─────────────────────────────────────────── */
.topbar-title-wrap { display: flex; align-items: center; gap: 12px; }
.mode-pill {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px;
  background: var(--accent-glow); color: var(--accent); border: 1px solid rgba(79,70,229,0.3);
}

/* ── Active Engines / Capabilities Badges ────────────────────────── */
.engine-badge-list { display: flex; flex-direction: column; gap: 8px; }
.engine-badge-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 12px;
}
.engine-badge-left { display: flex; align-items: center; gap: 8px; }
.status-dot-active {
  width: 7px; height: 7px; border-radius: 50%; background: #10b981;
  box-shadow: 0 0 6px rgba(16,185,129,0.6); display: inline-block;
}
.engine-badge-title { font-weight: 600; color: var(--text); }
.engine-badge-tag {
  font-size: 10px; font-family: var(--mono); padding: 2px 6px;
  border-radius: 4px; background: var(--bg3); color: var(--text3); font-weight: 500;
}
.tag-purple { background: rgba(124,58,237,0.12); color: #7c3aed; }
.tag-green  { background: rgba(16,185,129,0.12); color: #10b981; }

/* ── Authenticity & ID Forgery Card ──────────────────────────────── */
.forgery-card {
  margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; background: var(--bg2); box-shadow: var(--shadow);
}
.forgery-card-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px; margin-bottom: 12px;
}
.forgery-header-left { display: flex; align-items: center; gap: 10px; }
.forgery-main-icon { font-size: 24px; }
.forgery-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.forgery-title { font-weight: 700; font-size: 14px; color: var(--text); }
.forgery-desc { font-size: 12px; color: var(--text3); margin-top: 2px; }
.forgery-verdict-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.verdict-genuine { background: rgba(16,185,129,0.15); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.verdict-warn    { background: rgba(245,158,11,0.15); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.verdict-fail    { background: rgba(239,68,68,0.15); color: #ef4444; border: 1px solid rgba(239,68,68,0.3); }

.forgery-header-right { display: flex; align-items: center; gap: 12px; }
.forgery-score-block { text-align: right; }
.forgery-score-label { font-size: 11px; color: var(--text3); display: block; }
.forgery-score-val { font-weight: 800; font-size: 16px; font-family: var(--mono); color: var(--text); }

.forgery-chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.forgery-chip {
  display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600;
  padding: 4px 10px; border-radius: 20px; font-family: var(--mono);
}
.forgery-chip-pass { background: rgba(16,185,129,0.1); color: #10b981; border: 1px solid rgba(16,185,129,0.25); }
.forgery-chip-fail { background: rgba(239,68,68,0.1); color: #ef4444; border: 1px solid rgba(239,68,68,0.25); }
.forgery-chip-warn { background: rgba(245,158,11,0.1); color: #f59e0b; border: 1px solid rgba(245,158,11,0.25); }

.forgery-issues-box {
  margin-top: 10px; padding: 10px 14px; border-radius: var(--radius-sm);
  background: rgba(239,68,68,0.06); border: 1px solid rgba(239,68,68,0.2); font-size: 12px;
}
.forgery-issues-title { font-weight: 700; color: #ef4444; margin-bottom: 4px; }
.forgery-issues-list { margin: 0; padding-left: 18px; color: var(--text2); }

.forgery-details-collapsible { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 10px; }

/* Parity table */
.parity-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.parity-table th, .parity-table td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.parity-table th { font-weight: 600; color: var(--text3); font-size: 11px; text-transform: uppercase; }

/* General OCR Summary & Views */
.general-summary-card {
  padding: 14px 16px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 14px; box-shadow: var(--shadow);
}
.fulltext-box {
  background: var(--bg0, #0f172a); color: #e2e8f0; font-family: var(--mono);
  font-size: 12px; line-height: 1.6; padding: 14px 16px; border-radius: var(--radius-sm);
  max-height: 280px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}

/* Modal Overlay & Dialog */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-card {
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  max-width: 480px; width: 100%; box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between;
}
.modal-close-btn {
  background: none; border: none; font-size: 16px; color: var(--text3);
  cursor: pointer; padding: 4px;
}
.modal-close-btn:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg3);
  display: flex; justify-content: flex-end; gap: 8px;
}

/* ── Professional Status / Notice Dialog ────────────────────────────── */
.status-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 29, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
  animation: modalFadeIn 0.22s ease-out;
}

.status-modal-card {
  background: var(--bg1, #151d30);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  padding: 28px 24px;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: modalScaleUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.status-modal-icon-wrap {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.status-modal-icon {
  font-size: 26px;
  line-height: 1;
}

.status-modal-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text, #f8fafc);
  margin: 0;
  letter-spacing: -0.01em;
}

.status-modal-message {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text2, #94a3b8);
  margin: 0;
}

.status-modal-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-top: 6px;
}

.status-modal-btn {
  flex: 1;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  border: none;
}

.status-modal-btn.primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.status-modal-btn.primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  transform: translateY(-1px);
}

.status-modal-btn.secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text2, #cbd5e1);
}

.status-modal-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

