[hidden] { display: none !important; }
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1c2330;
  --muted: #6a7383;
  --line: #e1e4ea;
  --accent: #b5002b;          /* hinomaru red, used sparingly */
  --accent-ink: #ffffff;
  --hi: #157a4a;  --hi-bg: #e3f4ea;
  --mid: #9a6200; --mid-bg: #fdf0d8;
  --lo: #b42318;  --lo-bg: #fde4e1;
  --ed: #1d4ed8;  --ed-bg: #e2eaff;
  --radius: 6px;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
button { font: inherit; }

.topbar {
  height: 44px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: var(--ink); color: #fff;
}
.brand { font-weight: 600; letter-spacing: .02em; }
.brand::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); margin-right: 8px; vertical-align: 0; box-shadow: 0 0 0 2px #fff; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.who { color: #b8c0cc; margin-right: 6px; }
.topbar .btn.ghost { color: #fff; border-color: #3b4557; }
.topbar .btn.ghost:hover { background: #2b3444; }

.layout {
  height: calc(100vh - 44px);
  display: grid; grid-template-columns: minmax(380px, 44%) 1fr; gap: 10px; padding: 10px;
}
.left { display: grid; grid-template-rows: 38% 1fr; gap: 10px; min-height: 0; }
.pane, .right {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 0;
}
.pane-head, .right-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-bottom: 1px solid var(--line); min-height: 44px;
}
.pane-head h2 { font-size: 13px; margin: 0; font-weight: 600; white-space: nowrap; }
.filename { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.status { white-space: nowrap; font-weight: 500; }
.status.ok { color: var(--hi); } .status.warn { color: var(--mid); } .status.err { color: var(--lo); }

.drop { position: relative; flex: 1; min-height: 0; margin: 8px; border: 2px dashed var(--line);
  border-radius: var(--radius); display: flex; outline: none; cursor: pointer; }
.drop:focus-visible, .drop.over { border-color: var(--accent); background: #fff6f8; }
.drop.has-file { border-style: solid; border-color: var(--line); cursor: default; }
.drop-hint { margin: auto; text-align: center; color: var(--muted); font-size: 14px; line-height: 1.6; padding: 10px; }
.drop-hint span { display: block; font-size: 12px; }
.viewer { position: absolute; inset: 0; overflow: auto; background: #eceef1; }
.viewer img { display: block; max-width: 100%; max-height: 100%; margin: auto; cursor: zoom-in; }
.viewer.zoom img { max-width: none; max-height: none; width: 220%; cursor: zoom-out; }
.viewer.scroll img { max-height: none; width: 100%; margin-bottom: 6px; cursor: default; }
.viewer iframe { width: 100%; height: 100%; border: 0; display: block; }
.pane-passport .viewer { display: flex; }

.mrz { margin: 0 8px 8px; padding: 6px 8px; font: 11px/1.4 ui-monospace, Menlo, Consolas, monospace;
  background: #f7f8fa; border: 1px solid var(--line); border-radius: 4px; white-space: pre; overflow-x: auto; color: #39414f; }

/* ---------- right column ---------- */
.right { min-width: 0; }
.right-head { justify-content: space-between; }
.legend { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.review-count { margin-left: 8px; color: var(--lo); font-weight: 600; }
.fields { flex: 1; overflow-y: auto; padding: 6px 12px 16px; }

fieldset.group { border: 0; margin: 0; padding: 8px 0 4px; border-bottom: 1px solid var(--line); }
fieldset.group:last-child { border-bottom: 0; }
.group-head { display: flex; align-items: center; gap: 8px; margin: 2px 0 6px; }
.group-head legend, .group-head h3 { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px 10px; }
.f { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.f.wide { grid-column: 1 / -1; }
.f-top { display: flex; align-items: center; gap: 6px; min-height: 16px; }
.f-top label { font-size: 11.5px; color: #4b5463; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.f input[type=text], .f textarea {
  width: 100%; font: inherit; font-size: 13px; padding: 5px 7px; color: var(--ink);
  border: 1px solid #cfd4dc; border-radius: 4px; background: #fff; resize: vertical;
}
.f textarea { min-height: 46px; }
.f input:focus, .f textarea:focus { outline: 2px solid #9db4ff; outline-offset: -1px; border-color: #6b8cff; }
.f.lo input, .f.lo textarea { border-color: var(--lo); background: #fffafa; }
.f.mid input, .f.mid textarea { border-color: #e2b25a; }
.f .note { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.f.lo .note { color: var(--lo); }

.seg { display: flex; flex-wrap: wrap; gap: 0; }
.seg label { padding: 4px 9px; border: 1px solid #cfd4dc; margin-left: -1px; cursor: pointer; background: #fff; font-size: 12.5px; user-select: none; }
.seg label:first-of-type { border-radius: 4px 0 0 4px; margin-left: 0; }
.seg label:last-of-type { border-radius: 0 4px 4px 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg input:checked + span { font-weight: 600; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); position: relative; z-index: 1; }
.seg label:has(input:focus-visible) { outline: 2px solid #9db4ff; }
.f.lo .seg label { border-color: var(--lo); }

.badge { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 10px; white-space: nowrap; line-height: 15px; }
.badge.hi { color: var(--hi); background: var(--hi-bg); }
.badge.mid { color: var(--mid); background: var(--mid-bg); }
.badge.lo { color: var(--lo); background: var(--lo-bg); }
.badge.ed { color: var(--ed); background: var(--ed-bg); }

.btn { border: 1px solid #cfd4dc; background: #fff; color: var(--ink); padding: 6px 12px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f1f3f6; }
.btn.small { padding: 2px 8px; font-size: 11.5px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { background: #95001f; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.busy { position: relative; color: transparent !important; }
.btn.busy::after { content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px;
  border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 16px; border-radius: 6px; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 10; max-width: 80vw; }
.toast.err { background: var(--lo); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; }
.login { width: 320px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 26px; }
.login h1 { font-size: 17px; margin: 0 0 18px; }
.login label { display: block; font-size: 12px; color: #4b5463; margin: 10px 0 4px; }
.login input { width: 100%; padding: 8px 10px; font: inherit; border: 1px solid #cfd4dc; border-radius: 4px; }
.login .btn { width: 100%; margin-top: 18px; padding: 9px; }
.login .err { color: var(--lo); min-height: 18px; margin-top: 10px; font-size: 12px; }
