:root {
  --bg: #f4f6f9; --card: #fff; --line: #dde3ea; --text: #1d2733; --muted: #6b7785;
  --pri: #1f5fbf; --pri-d: #184c99;
  --ok: #1a7f37; --ok-bg: #e6f4ea; --check: #8a5a00; --check-bg: #fff4cc; --bad: #c62828; --bad-bg: #fde8e8;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); min-height: 1.4em; margin: 6px 0 0; white-space: pre-line; }
.mono { font-family: "DejaVu Sans Mono", Menlo, Consolas, monospace; letter-spacing: .5px; }
h3 { margin: 0 0 10px; font-size: 16px; }

button { font: inherit; border: 1px solid var(--pri); background: var(--pri); color: #fff; border-radius: 8px; padding: 7px 14px; cursor: pointer; }
button:hover { background: var(--pri-d); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: #fff; color: var(--pri); }
button.ghost:hover { background: #eef3fb; }
button.danger { border-color: var(--bad); color: var(--bad); }
button.big { padding: 10px 18px; font-size: 16px; font-weight: 600; }
button.small { padding: 4px 10px; font-size: 13px; }
button.link { background: none; border: none; color: var(--pri); padding: 4px 0; text-decoration: underline; }
input, select { font: inherit; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus { outline: 2px solid #b9cff3; border-color: var(--pri); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }

/* 登录 */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 10px; }
.login h1 { margin: 0; font-size: 24px; }

/* 顶栏 */
header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; font-size: 18px; }
.batchbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.batchbar select { width: auto; min-width: 180px; max-width: 320px; }
.spacer { flex: 1; }

main { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; padding: 14px 16px 0; align-items: start; }
#left { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
#review, .rv-photo, .rv-fields, .fmain, .mrzbox { min-width: 0; }
.drop { text-align: center; border: 2px dashed #b9cff3; background: #f7faff; }
.drop.over { background: #e8f0ff; border-color: var(--pri); }
.drop .big { width: 100%; }

.queue { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.queue li { display: flex; gap: 8px; align-items: center; padding: 6px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.queue li:hover { background: #f7faff; }
.queue li.active { border-color: var(--pri); background: #eef3fb; }
.queue img { width: 54px; height: 40px; object-fit: cover; border-radius: 4px; background: #eee; flex: none; }
.queue .qt { flex: 1; min-width: 0; }
.queue .qn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.spin { display: inline-block; width: 12px; height: 12px; border: 2px solid #b9cff3; border-top-color: var(--pri); border-radius: 50%; animation: sp 0.8s linear infinite; vertical-align: -2px; }
@keyframes sp { to { transform: rotate(360deg); } }
.legend-card div { margin: 4px 0; }

.chip { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12.5px; white-space: nowrap; font-weight: 600; }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.check { background: var(--check-bg); color: var(--check); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }

/* 核对面板 */
#review { min-height: 300px; }
.empty { padding: 60px 0; text-align: center; }
.rv-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.rv-title { font-size: 17px; font-weight: 700; }
.rv-grid { display: grid; grid-template-columns: minmax(280px, 44%) minmax(0, 1fr); gap: 16px; align-items: start; }
.rv-photo { position: sticky; top: 64px; }
.rv-photo > img { width: 100%; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; background: #eee; }
.mrzbox { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; background: #fafbfc; display: flex; flex-direction: column; gap: 6px; }
.mrzbox img { width: 100%; border-radius: 4px; }
.mrzbox input { font-size: 12.5px; padding: 5px 6px; }
.mrz-title { font-size: 13px; font-weight: 600; display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }
.mrz-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: space-between; }

.banner { border-radius: 8px; padding: 8px 12px; margin: 6px 0; font-weight: 600; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.banner.check { background: var(--check-bg); color: var(--check); }
.banner.info { background: #eef3fb; color: var(--pri-d); font-weight: 500; }

.frow { display: grid; grid-template-columns: 112px 1fr; gap: 10px; padding: 9px 8px; border-bottom: 1px solid #eef1f4; border-left: 4px solid transparent; }
.frow.st-ok { border-left-color: #8cd3a0; }
.frow.st-check { border-left-color: #f0c34a; background: #fffdf3; }
.frow.st-bad { border-left-color: #ef7c7c; background: #fff8f8; }
.flabel { font-weight: 600; padding-top: 6px; }
.flabel small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.fmain { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fline { display: flex; gap: 8px; align-items: center; }
.fline input, .fline select { font-size: 16px; font-weight: 600; letter-spacing: .3px; }
.hint { font-size: 13px; color: var(--muted); }
.notes { font-size: 13px; color: var(--muted); }
.frow.st-bad .notes { color: var(--bad); }
.frow.st-check .notes { color: var(--check); }
.evidence { max-width: 100%; max-height: 64px; align-self: flex-start; border: 1px solid var(--line); border-radius: 4px; }
.confirm { display: inline-flex; gap: 6px; align-items: center; font-weight: 600; color: var(--check); cursor: pointer; padding: 3px 0; }
.confirm input { width: 18px; height: 18px; }
.suggest { align-self: flex-start; }
.ack { display: flex; gap: 8px; align-items: center; margin: 10px 8px; color: var(--bad); font-weight: 600; }
.ack input { width: 18px; height: 18px; }
.blockers { margin: 10px 8px 0; font-size: 13px; color: var(--check); white-space: pre-line; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 8px 4px; }

/* 已登记表格 */
#tableCard { margin: 14px 16px 24px; }
.tablehead { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { border-bottom: 1px solid var(--line); padding: 6px 8px; text-align: left; white-space: nowrap; }
th { background: #f2f5f9; font-weight: 600; }
td input { padding: 4px 6px; min-width: 120px; }
td .ops { display: flex; gap: 6px; }

dialog { border: none; border-radius: 12px; padding: 18px; width: min(620px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,30,40,.45); }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; margin: 6px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; }
.warnline { color: var(--check); font-weight: 600; }

#viewer { position: fixed; inset: 0; background: rgba(0,0,0,.85); z-index: 50; overflow: auto; cursor: zoom-out; }
#viewer img { display: block; margin: 0 auto; max-width: none; width: auto; min-width: 100%; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1d2733; color: #fff; padding: 9px 16px; border-radius: 8px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 60; max-width: 90vw; white-space: pre-line; }
#toast.show { opacity: .95; }

@media (max-width: 900px) {
  header { position: static; padding: 8px 10px; gap: 6px; }
  .brand { font-size: 16px; }
  .legend-card { display: none; }
  main { grid-template-columns: minmax(0, 1fr); padding: 10px 10px 0; }
  .rv-grid { grid-template-columns: minmax(0, 1fr); }
  .mrzbox input { font-size: 10px; letter-spacing: 0; }
  .rv-photo { position: static; }
  #tableCard { margin: 10px; }
  .frow { grid-template-columns: 1fr; gap: 4px; }
  .flabel { padding-top: 0; }
  .flabel small { display: inline; margin-left: 6px; }
  .actions { position: sticky; bottom: 0; background: #fff; padding: 10px 0; margin: 10px 0 0; border-top: 1px solid var(--line); }
  .batchbar select { min-width: 140px; }
  .grid2 { grid-template-columns: 1fr; }
}
