:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e4e6eb;
  --line-strong: #c9cdd5;
  --ink: #0e0c19;
  --ink-2: #3c3a47;
  --ink-3: #6b7280;
  --accent: #023047;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --red: #dc2626;
  --amber: #d97706;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif; font-size: 14px; line-height: 1.45; }
.hidden { display: none !important; }

/* ---------- topbar ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand-mark { width: 18px; height: 18px; background: var(--accent); border-radius: 4px; align-self: center; }
.brand-name { font-weight: 700; letter-spacing: 0.12em; color: var(--accent); }
.brand-sep { color: var(--ink-3); }
.brand-app { color: var(--ink-2); letter-spacing: 0.02em; }
.env-tag { font-size: 11px; color: var(--ink-3); letter-spacing: 0.05em; padding: 4px 10px; background: var(--green-bg); color: var(--green); border-radius: 4px; font-weight: 600; }

/* Expandable Regula-style field rows */
.field-group { border-bottom: 1px solid var(--line); }
.field-group:last-child { border-bottom: none; }
.field-group > .field-head { display: flex; align-items: center; padding: 10px 16px; gap: 12px; cursor: pointer; user-select: none; }
.field-group > .field-head:hover { background: #fafbfc; }
.field-group .caret { width: 12px; color: var(--ink-3); transition: transform 0.15s; }
.field-group.open .caret { transform: rotate(90deg); }
.field-group .label { flex: 1; color: var(--ink-2); font-size: 13px; }
.field-group .value { color: var(--ink); font-weight: 500; font-size: 13px; max-width: 50%; text-align: right; overflow-wrap: anywhere; }
.field-group .status { width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0; position: relative; border: 1px solid var(--line); }
.field-group .status.ok { background: white; border-color: var(--green); }
.field-group .status.ok::after { content: ""; position: absolute; left: 5px; top: 3px; width: 4px; height: 8px; border: solid var(--green); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.field-group .status.muted { background: white; border-color: var(--line-strong); }
.field-group .status.muted::after { content: "—"; position: absolute; left: 4px; top: -3px; color: var(--line-strong); font-weight: 700; }
.field-group .status.fail { background: white; border-color: var(--red); }
.field-group .status.fail::after { content: "×"; position: absolute; left: 4px; top: -2px; color: var(--red); font-weight: 700; }
.field-group > .sub { display: none; padding: 4px 16px 10px 40px; background: #fafbfc; border-top: 1px solid var(--line); }
.field-group.open > .sub { display: block; }
.sub-source { padding: 8px 0; border-bottom: 1px dashed var(--line); }
.sub-source:last-child { border-bottom: none; }
.sub-source-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sub-source-name { font-weight: 600; font-size: 12px; color: var(--ink-2); letter-spacing: 0.04em; }
.sub-source-name .help { color: var(--ink-3); font-size: 11px; margin-left: 4px; }
.sub-source-value { font-size: 13px; color: var(--ink); }
.sub-source-detail { display: flex; gap: 24px; margin-top: 4px; font-size: 11px; color: var(--ink-3); letter-spacing: 0.05em; }
.sub-source-detail span b { color: var(--ink); font-weight: 600; margin-left: 4px; }
.sub-cross { display: flex; justify-content: space-between; align-items: center; padding-top: 8px; font-size: 12px; color: var(--ink-2); font-weight: 600; letter-spacing: 0.04em; }

/* Image quality tab — grouped per page */
.iq-page { border-bottom: 1px solid var(--line); }
.iq-page-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; }
.iq-page-head .name { color: var(--ink); font-weight: 500; font-size: 13px; }
.iq-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 16px 8px 32px; font-size: 12px; color: var(--ink-3); letter-spacing: 0.06em; text-transform: uppercase; }
.iq-row .status { width: 18px; height: 18px; border-radius: 50%; position: relative; border: 1px solid var(--line); }
.iq-row .status.ok { border-color: var(--green); }
.iq-row .status.ok::after { content: ""; position: absolute; left: 5px; top: 3px; width: 4px; height: 8px; border: solid var(--green); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.iq-row .status.fail { border-color: var(--red); }
.iq-row .status.fail::after { content: "×"; position: absolute; left: 4px; top: -2px; color: var(--red); font-weight: 700; }
.iq-row .status.muted { border-color: var(--line-strong); }
.iq-row .status.muted::after { content: "—"; position: absolute; left: 4px; top: -3px; color: var(--line-strong); }

/* ---------- drop ---------- */
.drop { min-height: 70vh; display: flex; align-items: center; justify-content: center; padding: 32px; }
.drop.dragover .drop-inner { border-color: var(--accent); background: #f0f7fb; }
.drop-inner { width: min(560px, 100%); background: var(--panel); border: 2px dashed var(--line-strong); border-radius: 14px; padding: 56px 32px; text-align: center; transition: all 0.15s; }
.drop-icon { width: 56px; height: 56px; line-height: 56px; margin: 0 auto 12px; background: #f0f7fb; color: var(--accent); border-radius: 50%; font-size: 22px; }
.drop h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; }
.drop p { margin: 0 0 18px; color: var(--ink-3); }
.btn-primary { background: var(--accent); color: white; border: none; padding: 10px 18px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.btn-primary:hover { filter: brightness(1.1); }
.drop-meta { margin-top: 14px; font-size: 12px; color: var(--ink-3); }

/* ---------- result header ---------- */
.result { padding: 16px 24px 32px; }
.result-header { display: flex; justify-content: space-between; gap: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.result-left { display: flex; gap: 16px; align-items: center; }
.badge { display: inline-flex; align-items: center; padding: 4px 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; border-radius: 4px; }
.badge-pending { background: #fef3c7; color: var(--amber); }
.badge-verified { background: var(--green-bg); color: var(--green); }
.badge-attention { background: #fee2e2; color: var(--red); }
.hdr-face { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; background: #f1f3f5; border: 1px solid var(--line); }
.hdr-id .hdr-name { font-size: 18px; font-weight: 700; letter-spacing: 0.01em; }
.hdr-id .hdr-sub { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.hdr-fields { display: grid; grid-template-columns: repeat(5, auto); gap: 4px 18px; margin: 0; }
.hdr-fields div { display: flex; flex-direction: column; }
.hdr-fields dt { font-size: 10px; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; }
.hdr-fields dd { margin: 0; font-size: 13px; color: var(--ink); font-weight: 500; }
.result-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.icon-btn { background: transparent; border: 1px solid var(--line); border-radius: 6px; width: 28px; height: 28px; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { background: #f1f3f5; }
.timings { display: grid; grid-template-columns: repeat(3, auto); gap: 4px 16px; margin-top: 4px; text-align: right; }
.timings div { display: flex; flex-direction: column; }
.timings span { font-size: 10px; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; }
.timings b { font-size: 13px; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- result body grid ---------- */
.result-body { display: grid; grid-template-columns: 220px 1fr 420px; gap: 16px; }

/* checklist rail */
.checks { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 0; height: fit-content; }
.checks ul { list-style: none; margin: 0; padding: 0; }
.checks li { display: flex; align-items: center; gap: 8px; padding: 8px 16px; color: var(--ink-2); font-size: 13px; }
.checks li i { width: 16px; height: 16px; border-radius: 50%; background: #e4e6eb; flex-shrink: 0; display: inline-block; position: relative; }
.checks li.ok i { background: var(--green); }
.checks li.ok i::after { content: ""; position: absolute; left: 4px; top: 2px; width: 4px; height: 8px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.checks li.fail i { background: var(--red); }
.checks li.fail i::after { content: "×"; position: absolute; left: 4px; top: -2px; color: white; font-weight: 700; }
.checks li.warn i { background: var(--amber); }

/* center column */
.center { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.center h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.bio-frame { background: #f1f3f5; border-radius: 6px; padding: 8px; }
.bio-frame img { width: 100%; max-height: 380px; object-fit: contain; display: block; }
.section-label { margin: 16px 0 8px; font-size: 11px; font-weight: 600; color: var(--ink-3); letter-spacing: 0.08em; text-transform: uppercase; }
.pages-strip { display: flex; gap: 8px; }
.pages-strip img { width: 110px; height: 80px; object-fit: cover; border: 1px solid var(--line); border-radius: 4px; }
.graphic-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.graphic-cell { display: flex; flex-direction: column; align-items: center; }
.graphic-cell .label { font-size: 10px; letter-spacing: 0.08em; color: var(--ink-3); text-transform: uppercase; margin-bottom: 4px; }
.graphic-cell img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border: 1px solid var(--line); border-radius: 4px; background: #f1f3f5; }
.graphic-cell.placeholder img { opacity: 0.25; }

/* right pane */
.rightpane { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; background: transparent; border: none; padding: 12px 8px; color: var(--ink-3); font-weight: 600; font-size: 12px; cursor: pointer; border-bottom: 2px solid transparent; }
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab-body { padding: 4px 0; max-height: 540px; overflow: auto; }

.field-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); gap: 12px; }
.field-row:last-child { border-bottom: none; }
.field-row .k { display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: 13px; }
.field-row .k::before { content: "›"; color: var(--ink-3); }
.field-row .v { color: var(--ink); font-weight: 500; font-size: 13px; text-align: right; max-width: 60%; overflow-wrap: anywhere; }
.field-row .check { width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0; position: relative; }
.field-row .check.ok { background: var(--green); }
.field-row .check.ok::after { content: ""; position: absolute; left: 4px; top: 2px; width: 4px; height: 8px; border: solid white; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.field-row .check.fail { background: var(--red); }
.field-row .check.muted { background: #e4e6eb; }

.mrz-band { background: #f1f3f5; padding: 12px 16px; }
.mrz-band img { width: 100%; border: 1px solid var(--line); }
.mrz-band pre { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: white; padding: 10px; border: 1px solid var(--line); border-radius: 4px; margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

pre.raw-json { font-family: ui-monospace, Menlo, monospace; font-size: 11px; padding: 16px; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }

@media (max-width: 1100px) {
  .result-body { grid-template-columns: 1fr; }
  .hdr-fields { grid-template-columns: repeat(2, auto); }
}
