:root {
  --paper: #f3efe7;
  --ink: #1b1e24;
  --muted: #5b616b;
  --line: #d8d1c6;
  --card: #fffcf7;
  --blue: #0b3a6e;
  --blue-2: #14539a;
  --ok: #1f7a4d;
  --ok-bg: #e8f6ee;
  --warn: #9a4d08;
  --warn-bg: #f8eedf;
  --bad: #a31d16;
  --bad-bg: #f8e8e6;
  --shadow: 0 10px 30px rgba(27, 30, 36, 0.08);
  --radius: 16px;
  font-family: "Source Han Sans SC", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--paper); color: var(--ink); }
body { min-height: 100vh; }

.top {
  max-width: 1160px;
  margin: 0 auto;
  padding: 28px 24px 8px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--blue); color: #fff;
  display: grid; place-items: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px; font-weight: 700;
}
h1 { margin: 0; font-size: 24px; letter-spacing: 0.02em; }
.brand p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.rule-pill {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--blue);
}

main { max-width: 1160px; margin: 0 auto; padding: 16px 24px 64px; }
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 20px;
}
.hidden { display: none !important; }

.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; text-align: center;
  border: 1.5px dashed #b9c5d4;
  background: #f7fafc;
  border-radius: 14px;
  padding: 42px 20px;
  cursor: pointer;
}
.drop:hover, .drop.dragover { border-color: var(--blue); background: #eef4fb; }
.drop strong { font-size: 18px; }
.drop span { color: var(--muted); font-size: 14px; max-width: 640px; line-height: 1.6; }
.drop em { font-style: normal; color: var(--blue); min-height: 1.2em; margin-top: 6px; }

.actions { display: flex; justify-content: flex-end; margin-top: 16px; }
button {
  appearance: none; border: 0; cursor: pointer;
  background: var(--blue); color: #fff;
  border-radius: 10px; padding: 10px 18px;
  font-size: 15px; font-weight: 600;
}
button:hover { background: var(--blue-2); }
button:disabled { background: #9aa7b5; cursor: not-allowed; }
button.ghost {
  background: transparent; color: var(--blue);
  border: 1px solid #c5d0dc;
}
button.ghost:hover { background: #eef4fb; }
button.download { width: 100%; margin-top: 4px; }

.job-meta {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}
.label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; }
.steps li { padding: 4px 0 8px; border-top: 1px solid var(--line); }
.steps li:first-child { border-top: 0; }
.step-head { display: flex; gap: 12px; align-items: flex-start; }
.step-no {
  width: 28px; height: 28px; border-radius: 50%;
  background: #e6edf5; color: var(--blue);
  display: grid; place-items: center; font-weight: 700; flex: none;
}
.steps li.active .step-no { background: var(--blue); color: #fff; }
.steps li.done .step-no { background: var(--ok); color: #fff; }
.step-head h2 { margin: 0; font-size: 16px; }
.step-head p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.step-count { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.bar { height: 8px; background: #ece7df; border-radius: 99px; overflow: hidden; margin: 10px 0 0 40px; }
.bar i { display: block; height: 100%; width: 0; background: var(--blue); border-radius: 99px; transition: width 0.25s ease; }
#step-classify .bar i { background: #7a4e12; }
#step-split.done .bar i { background: var(--ok); }
.error { color: var(--bad); background: var(--bad-bg); padding: 10px 12px; border-radius: 10px; }

.results-head { display: flex; justify-content: space-between; align-items: center; margin: 8px 2px 14px; }
.results-head h2 { margin: 0; font-size: 20px; }
.groups { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.group {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  min-height: 200px;
  display: flex; flex-direction: column; gap: 10px;
}
.group h3 { margin: 0; font-size: 17px; display: flex; justify-content: space-between; align-items: baseline; }
.group h3 b { font-size: 22px; }
.group.ok h3 { color: var(--ok); }
.group.sender h3 { color: var(--warn); }
.group.issue h3 { color: var(--bad); }
.cards { display: flex; flex-direction: column; gap: 10px; overflow: auto; max-height: 70vh; }
.card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
  cursor: zoom-in;
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
}
.card:hover { border-color: var(--blue); }
.thumb {
  width: 86px; height: 120px;
  background: #f0ece4;
  border-radius: 8px;
  overflow: hidden;
  display: grid; place-items: center;
}
.thumb canvas { width: 100%; height: 100%; object-fit: contain; }
.card-body { font-size: 13px; line-height: 1.45; }
.card-body .page { font-weight: 700; margin-bottom: 4px; }
.card-body .addr { color: var(--ink); }
.card-body .reason { color: var(--muted); margin-top: 4px; }
.group.ok .card { background: var(--ok-bg); }
.group.sender .card { background: var(--warn-bg); }
.group.issue .card { background: var(--bad-bg); }
.empty { color: var(--muted); text-align: center; padding: 28px 8px; }

.lightbox {
  position: fixed; inset: 0; background: rgba(12, 16, 22, 0.72);
  display: grid; place-items: center; z-index: 40; padding: 24px;
}
.lightbox-card {
  background: #fff; border-radius: 16px; max-width: 720px; width: min(720px, 100%);
  max-height: 92vh; overflow: auto; padding: 20px 20px 24px; position: relative;
}
.lightbox-card canvas { width: 100%; height: auto; background: var(--paper); border-radius: 8px; }
.close {
  position: absolute; right: 12px; top: 10px;
  background: transparent; color: var(--ink); font-size: 28px; line-height: 1; padding: 4px 10px;
}
.lightbox-meta h3 { margin: 0 36px 8px 0; }
.lightbox-meta p { margin: 0 0 6px; }
.lightbox-meta .reason { color: var(--muted); margin-bottom: 12px; }

@media (max-width: 960px) {
  .groups { grid-template-columns: 1fr; }
  .job-meta { grid-template-columns: 1fr; }
}

.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 650; margin-bottom: 6px; }
.field .req { color: var(--bad); font-weight: 600; font-size: 12px; margin-left: 6px; }
.field input, .filter input {
  width: 100%; max-width: 420px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; background: #fff; color: var(--ink);
}
.field .hint { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.job-meta { grid-template-columns: 0.8fr 1.2fr 1fr; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.results-head .sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.filter { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter input { max-width: 240px; }
.customer-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; }
.chip {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 4px 10px; font-size: 13px; cursor: pointer; color: var(--blue);
}
.chip:hover, .chip.active { background: #eef4fb; border-color: var(--blue); }
.history-table-wrap { overflow: auto; }
table.history { width: 100%; border-collapse: collapse; font-size: 14px; }
table.history th, table.history td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.history th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.history td.mono { font-size: 12px; }
.status-pill { display: inline-block; border-radius: 999px; padding: 2px 8px; font-size: 12px; }
.status-done { background: var(--ok-bg); color: var(--ok); }
.status-failed { background: var(--bad-bg); color: var(--bad); }
.status-other { background: #eef4fb; color: var(--blue); }
@media (max-width: 960px) {
  .job-meta { grid-template-columns: 1fr; }
  .filter { width: 100%; }
}
