:root {
  --ink: #1f1b18;
  --ink-soft: #514a43;
  --ink-faint: #8a8175;
  --navy: #15344f;
  --navy-deep: #0c263c;
  --navy-soft: #e8eef2;
  --red: #9e1b32;
  --red-deep: #741426;
  --gold: #b8893b;
  --gold-soft: #c9a668;
  --green: #4f735f;
  --cream: #f6f0e4;
  --cream-2: #f1e9d9;
  --cream-3: #e8deca;
  --line: #ded2bc;
  --white: #fffdf9;
  --serif: "Fraunces", "Noto Serif SC", "Songti SC", serif;
  --sans: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-width: 980px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--cream);
  background-image:
    radial-gradient(circle at 15% 10%, rgba(120, 90, 40, .035), transparent 38%),
    radial-gradient(circle at 88% 92%, rgba(21, 52, 79, .035), transparent 42%);
  font-family: var(--sans);
  font-size: 14px;
}
button, input { font: inherit; }
button { cursor: pointer; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  width: 228px;
  height: 100vh;
  flex: 0 0 228px;
  display: flex;
  flex-direction: column;
  background: var(--cream-2);
  border-right: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 5px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
}
.brand-x { color: var(--gold); font-style: italic; }
.brand small {
  width: 100%;
  margin-top: 3px;
  color: var(--gold);
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .18em;
}
.nav-group { padding: 22px 0; }
.nav-label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 20px 8px;
  color: var(--gold);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
}
.nav-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.nav-item {
  width: 100%;
  padding: 10px 20px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  border-left: 2px solid transparent;
  text-align: left;
  font-weight: 600;
}
.nav-item:hover { color: var(--ink); background: rgba(255, 255, 255, .55); }
.nav-item.active { color: var(--navy-deep); background: var(--white); border-left-color: var(--navy); }
.sidebar-note {
  margin-top: auto;
  padding: 16px 20px 20px;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.55;
}
.sidebar-note b { display: block; color: var(--ink-soft); font-size: 12px; }

.main-area { flex: 1; min-width: 0; }
.crumbbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 28px;
  color: var(--ink-faint);
  background: rgba(246, 240, 228, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  font-size: 11.5px;
  letter-spacing: .04em;
}
.crumbbar b { color: var(--ink-soft); }
.crumb-separator { color: var(--gold); }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-weight: 600; }
.avatar {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--navy);
  border-radius: 50%;
  font-size: 11px;
}
.workspace { max-width: 1500px; margin: 0 auto; padding: 28px 28px 64px; }
.mode-notice {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  margin-bottom: 30px;
  padding: 9px 14px;
  color: var(--ink-soft);
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  font-size: 12px;
}
.mode-notice b { color: var(--navy-deep); letter-spacing: .06em; }
.login-link { margin: 0 4px; color: var(--navy); font-weight: 700; }
.session-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 11px 14px;
  color: var(--red-deep);
  background: rgba(158, 27, 50, .07);
  border: 1px solid rgba(158, 27, 50, .28);
  border-left: 3px solid var(--red);
  font-size: 12px;
  line-height: 1.6;
}
.session-alert b { font-weight: 700; white-space: nowrap; }
.logout-button {
  margin-left: 4px;
  padding: 3px 10px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.logout-button:hover:not(:disabled) { color: var(--navy-deep); border-color: var(--navy); }

.login-body { min-width: 0; display: grid; place-items: center; padding: 32px 20px; }
.login-shell { width: 100%; max-width: 520px; }
.login-card {
  padding: 34px 34px 30px;
  background: var(--white);
  border: 1px solid var(--line);
  border-top: 3px solid var(--navy);
}
.login-brand { padding: 0 0 18px; margin-bottom: 22px; }
.login-card h1 {
  margin: 10px 0 14px;
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.login-card h1 span { color: var(--navy); }
.login-intro { margin: 0 0 22px; color: var(--ink-soft); line-height: 1.75; }
.login-button {
  display: inline-flex;
  justify-content: center;
  width: 100%;
  text-decoration: none;
}
.login-notes {
  margin: 22px 0 0;
  padding: 16px 0 0 18px;
  color: var(--ink-faint);
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  line-height: 1.85;
}
.login-footnote { margin: 16px 2px 0; color: var(--ink-faint); font-size: 11px; line-height: 1.7; }

.audit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  margin: 0 0 16px;
  background: var(--line);
  border: 1px solid var(--line);
}
.audit-grid > div { padding: 9px 11px; background: var(--white); }
.audit-grid dt { color: var(--gold); font-size: 9.5px; font-weight: 800; letter-spacing: .12em; }
.audit-grid dd { margin: 4px 0 0; color: var(--ink-soft); font-size: 12px; font-variant-numeric: tabular-nums; }

.page-heading { margin-bottom: 28px; }
.kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
}
.kicker::before { content: ""; width: 24px; height: 1px; background: var(--gold); }
.page-heading h1 {
  margin: 10px 0 7px;
  font-family: var(--serif);
  font-size: clamp(32px, 3.2vw, 43px);
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1.15;
}
.page-heading h1 span { color: var(--navy); }
.page-heading > p:last-child { margin: 0; color: var(--ink-soft); line-height: 1.7; }
.workflow-tabs {
  position: sticky;
  top: 46px;
  z-index: 15;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
  background: var(--cream);
  border: 1px solid var(--line);
}
.workflow-tab {
  min-width: 0;
  min-height: 70px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 11px;
  align-content: center;
  padding: 12px 18px;
  color: var(--ink-soft);
  background: var(--cream-2);
  border: 0;
  text-align: left;
}
.workflow-tab + .workflow-tab { border-left: 1px solid var(--line); }
.workflow-tab > span {
  grid-row: 1 / span 2;
  align-self: center;
  color: var(--gold);
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
}
.workflow-tab b { color: var(--navy-deep); font-size: 14px; }
.workflow-tab small { margin-top: 3px; color: var(--ink-faint); font-size: 10.5px; }
.workflow-tab:hover { background: #fff; }
.workflow-tab.active { background: var(--navy); box-shadow: inset 0 -3px 0 var(--gold-soft); }
.workflow-tab.active > span, .workflow-tab.active b, .workflow-tab.active small { color: #fff; }
.workflow-tab:focus-visible { position: relative; z-index: 1; outline: 3px solid rgba(184, 137, 59, .38); outline-offset: -3px; }
.bulk-panel { margin-bottom: 20px; }
.bulk-body { padding: 20px; }
.bulk-source-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.bulk-source {
  min-width: 0;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-top: 2px solid var(--gold-soft);
}
.bulk-source.ready { border-top-color: var(--green); }
.bulk-source-heading { display: flex; align-items: flex-start; gap: 10px; }
.bulk-source-heading > span { color: var(--gold); font-family: var(--serif); font-size: 17px; line-height: 1; }
.bulk-source-heading div { min-width: 0; display: grid; gap: 3px; }
.bulk-source-heading b { color: var(--navy-deep); font-size: 13px; }
.bulk-source-heading small { color: var(--ink-faint); font-size: 9.5px; line-height: 1.45; }
.bulk-source-status {
  min-height: 33px;
  margin: 12px 0;
  padding: 8px 9px;
  overflow: hidden;
  color: var(--ink-soft);
  background: var(--cream-2);
  font-size: 10.5px;
  line-height: 1.5;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bulk-source.ready .bulk-source-status { color: var(--green); }
.bulk-source-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.bulk-source-actions label { position: relative; min-height: 30px; display: inline-flex; align-items: center; }
.bulk-source-actions input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.bulk-clear { padding: 5px 7px; color: var(--ink-faint); background: transparent; border: 0; font-size: 10.5px; }
.bulk-clear:hover { color: var(--red); text-decoration: underline; }
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-top: 14px;
  padding: 14px 0 0;
  border-top: 1px solid var(--line);
}
.bulk-toolbar > div { min-width: 0; flex: 1; }
.bulk-toolbar b { display: block; color: var(--ink-soft); font-size: 12px; }
.bulk-toolbar span { display: block; margin-top: 3px; color: var(--ink-faint); font-size: 10.5px; line-height: 1.55; }
.pairing-preview { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.pairing-title { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.pairing-title > div { display: flex; align-items: baseline; gap: 9px; }
.pairing-title b { color: var(--navy-deep); font-family: var(--serif); font-size: 17px; }
.pairing-title span { color: var(--ink-faint); font-size: 10.5px; }
.pairing-help { margin: 0 0 13px; color: var(--ink-faint); font-size: 11px; line-height: 1.6; }
.pairing-card-list { display: grid; gap: 14px; }
.pairing-card { overflow: hidden; background: #fff; border: 1px solid var(--line); }
.pairing-card.confirmed { border-color: rgba(79, 115, 95, .75); box-shadow: inset 3px 0 0 var(--green); }
.pairing-card-header {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 16px;
  background: var(--cream-2);
  border-bottom: 1px solid var(--line);
}
.pairing-card-header > div { min-width: 0; display: grid; gap: 3px; }
.pairing-card-header span { color: var(--gold); font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.pairing-card-header b { overflow: hidden; color: var(--navy-deep); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.pairing-card-header em { flex: 0 0 auto; font-size: 10.5px; font-style: normal; font-weight: 700; }
.pairing-status-ready { color: var(--green); }
.pairing-status-wait { color: var(--red); }
.pairing-card-body { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(330px, .7fr); }
.pairing-card-labels, .pairing-card-documents { min-width: 0; padding: 16px; }
.pairing-card-documents { display: grid; gap: 16px; border-left: 1px solid var(--line); }
.pairing-card h3 { margin: 0 0 10px; color: var(--navy-deep); font-size: 12px; }
.pairing-card h3 small { margin-left: 6px; color: var(--ink-faint); font-size: 9.5px; font-weight: 500; }
.pairing-document-block + .pairing-document-block { padding-top: 15px; border-top: 1px solid var(--line); }
.label-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label-preview, .document-preview, .document-file { min-width: 0; padding: 8px; background: var(--cream-2); border: 1px solid var(--line); }
.image-preview-button { width: 100%; display: block; padding: 0; overflow: hidden; background: #fff; border: 1px solid transparent; }
.image-preview-button:hover, .image-preview-button:focus-visible { border-color: var(--gold); outline: none; }
.label-preview img { width: 100%; height: clamp(180px, 20vw, 260px); display: block; object-fit: contain; background: #fff; }
.document-preview img { width: 100%; height: 190px; display: block; object-fit: contain; background: #fff; }
.label-preview b, .document-preview b, .document-file b { display: block; margin-top: 7px; color: var(--navy-deep); font-size: 10px; }
.label-preview span, .document-preview span, .document-file span { display: block; margin-top: 3px; overflow: hidden; color: var(--ink-faint); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.document-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 10px; }
.standards-preview { grid-template-columns: 1fr; }
.coa-selector { min-width: 0; }
.coa-selector select {
  width: 100%;
  min-height: 34px;
  padding: 6px 28px 6px 9px;
  color: var(--navy-deep);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 0;
  font: inherit;
}
.coa-selector small { display: block; margin-top: 5px; color: var(--ink-faint); line-height: 1.4; }
.coa-selector .pairing-auto { color: var(--green); font-weight: 700; }
.pairing-missing { color: var(--red); font-weight: 700; }
.pairing-confirm { padding: 13px 16px; background: #fff; border-top: 1px solid var(--line); }
.pairing-confirm label { display: flex; align-items: flex-start; gap: 10px; color: var(--ink-soft); line-height: 1.45; }
.pairing-confirm input { width: 18px; height: 18px; margin: 0; accent-color: var(--navy); }
.pairing-confirm label > span { display: grid; gap: 2px; }
.pairing-confirm b { color: var(--navy-deep); font-size: 11.5px; }
.pairing-confirm small { color: var(--ink-faint); line-height: 1.4; }
.pairing-footer { display: flex; align-items: center; gap: 18px; margin-top: 12px; }
.pairing-footer p { min-width: 0; flex: 1; margin: 0; color: var(--ink-faint); font-size: 10.5px; line-height: 1.55; }
.pairing-footer p.error-text { color: var(--red); }
.view-grid { display: grid; grid-template-columns: minmax(470px, .9fr) minmax(560px, 1.1fr); gap: 20px; align-items: start; }

.panel { background: var(--white); border: 1px solid var(--line); }
.section-heading {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}
.section-heading > div { display: flex; align-items: baseline; gap: 10px; }
.section-number { color: var(--gold); font-family: var(--serif); font-size: 22px; font-weight: 400; }
.section-heading h1, .section-heading h2 { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 600; }
.section-meta { color: var(--ink-faint); font-size: 9.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.panel-body { padding: 20px; }
.batch-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}
.batch-toolbar > div { display: flex; align-items: baseline; gap: 9px; }
.batch-toolbar span { color: var(--gold); font-size: 9.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.batch-toolbar b { color: var(--ink-soft); font-size: 11.5px; }
.compact-button { min-height: 32px; padding: 0 12px; font-size: 11px; }
.compact-button:disabled { cursor: not-allowed; color: var(--ink-faint); background: var(--cream-2); border-color: var(--line); }
.batch-tabs {
  display: grid;
  grid-auto-columns: minmax(148px, 1fr);
  grid-auto-flow: column;
  gap: 7px;
  margin-bottom: 16px;
  padding-bottom: 5px;
  overflow-x: auto;
  scrollbar-color: var(--gold-soft) transparent;
  scrollbar-width: thin;
}
.batch-tab {
  position: relative;
  min-width: 148px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  background: var(--cream-2);
  border: 1px solid var(--line);
  transition: border-color .15s, background .15s;
}
.batch-tab:hover { border-color: var(--gold-soft); }
.batch-tab.active { background: #fff; border-color: var(--navy); box-shadow: inset 0 -2px 0 var(--navy); }
.batch-tab.processing { border-color: var(--gold); }
.batch-tab.completed:not(.active) { border-color: rgba(79, 115, 95, .55); }
.batch-tab.failed:not(.active) { border-color: rgba(158, 27, 50, .6); }
.batch-tab-main {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 10px 11px;
  color: var(--ink-soft);
  background: transparent;
  border: 0;
  text-align: left;
}
.batch-tab-main span { color: var(--gold); font-size: 8.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.batch-tab-main b { overflow: hidden; color: var(--navy-deep); font-size: 11.5px; text-overflow: ellipsis; white-space: nowrap; }
.batch-tab-main em { color: var(--ink-faint); font-size: 9.5px; font-style: normal; }
.batch-tab.ready .batch-tab-main em, .batch-tab.completed .batch-tab-main em { color: var(--green); }
.batch-tab.processing .batch-tab-main em { color: var(--gold); }
.batch-tab.failed .batch-tab-main em { color: var(--red); }
.remove-batch {
  align-self: stretch;
  padding: 0 8px;
  color: var(--ink-faint);
  background: transparent;
  border: 0;
  border-left: 1px solid var(--line);
  font-size: 9.5px;
}
.remove-batch:hover { color: var(--red); background: rgba(158, 27, 50, .04); }
.batch-field { display: block; margin-bottom: 16px; }
.batch-field > span {
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .1em;
}
.batch-field em { color: var(--ink-faint); font-style: normal; font-weight: 600; }
.batch-field input {
  width: 100%;
  height: 43px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 2px;
  outline: none;
  font-size: 14px;
}
.batch-field input:focus { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(184, 137, 59, .12); }

.upload-list { display: grid; gap: 9px; }
.upload-group { background: #fff; border: 1px solid var(--line); transition: border-color .15s, background .15s; }
.upload-group.ready { border-left: 3px solid var(--green); }
.upload-group.dragging { background: var(--navy-soft); border-color: var(--navy); }
.upload-header {
  min-height: 54px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 12px;
}
.upload-number { color: var(--gold); font-family: var(--serif); font-size: 15px; }
.upload-title { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.upload-title strong { font-size: 13.5px; }
.upload-title span { color: var(--ink-faint); font-size: 10.5px; }
.file-count { min-width: 48px; color: var(--ink-faint); font-size: 11px; font-weight: 700; text-align: right; }
.upload-group.ready .file-count { color: var(--green); }
.file-button {
  min-width: 78px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  color: var(--navy-deep);
  background: #fff;
  border: 1px solid var(--gold-soft);
  border-radius: 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}
.file-button:hover { color: #fff; background: var(--navy); border-color: var(--navy); }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.drop-zone { border-top: 1px dashed var(--line); }
.empty-file-state { display: flex; justify-content: space-between; gap: 12px; padding: 10px 13px 11px 50px; color: var(--ink-faint); font-size: 11px; }
.empty-file-state b { color: var(--ink-soft); font-weight: 500; }
.file-list { display: grid; }
.file-item {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 10px 7px 12px;
  border-top: 1px solid #eee7d9;
}
.file-item:first-child { border-top: 0; }
.file-thumbnail {
  width: 54px;
  height: 44px;
  flex: 0 0 54px;
  padding: 0;
  overflow: hidden;
  background: var(--cream-2);
  border: 1px solid var(--line);
}
.file-thumbnail img { width: 100%; height: 100%; display: block; object-fit: contain; background: #fff; }
.file-thumbnail:hover, .file-thumbnail:focus-visible { border-color: var(--gold); outline: 2px solid rgba(184, 137, 59, .18); }
.file-type {
  width: 54px;
  height: 44px;
  flex: 0 0 54px;
  display: grid;
  place-items: center;
  color: var(--red-deep);
  background: rgba(158, 27, 50, .06);
  border: 1px solid rgba(158, 27, 50, .18);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .08em;
}
.file-meta { min-width: 0; display: flex; flex: 1; align-items: baseline; gap: 8px; }
.file-meta b { min-width: 0; overflow: hidden; color: var(--ink-soft); font-size: 11.5px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.file-meta span { flex: 0 0 auto; color: var(--ink-faint); font-size: 10px; }
.remove-file { padding: 4px 6px; color: var(--ink-faint); background: transparent; border: 0; font-size: 10.5px; }
.remove-file:hover { color: var(--red); text-decoration: underline; }

.upload-footer {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.upload-footer > div { min-width: 0; flex: 1; }
.upload-footer b { display: block; color: var(--ink-soft); font-size: 11.5px; }
.upload-footer span { color: var(--ink-faint); font-size: 10.5px; }
.upload-footer .error-text { color: var(--red); }
.primary-button, .secondary-button {
  min-height: 40px;
  padding: 0 18px;
  border-radius: 2px;
  font-weight: 700;
  letter-spacing: .04em;
  transition: background .15s, border-color .15s, color .15s;
}
.primary-button { color: #fff; background: var(--navy); border: 1px solid var(--navy); }
.primary-button:hover:not(:disabled) { background: var(--navy-deep); border-color: var(--navy-deep); }
.primary-button:disabled { cursor: not-allowed; color: #a89f93; background: var(--cream-3); border-color: var(--cream-3); }
.secondary-button { color: var(--navy-deep); background: #fff; border: 1px solid var(--gold-soft); }
.secondary-button:hover:not(:disabled) { color: #fff; background: var(--navy); border-color: var(--navy); }
.button-spinner { display: none; width: 14px; height: 14px; margin-left: 7px; border: 2px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
.primary-button.loading .button-spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-content { min-height: 546px; padding: 20px; }
.result-batch-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 6px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.result-batch-tab {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 7px;
  padding: 9px 10px;
  color: var(--ink-soft);
  background: var(--cream-2);
  border: 1px solid var(--line);
  text-align: left;
}
.result-batch-tab span { grid-row: 1 / span 2; align-self: center; color: var(--gold); font-family: var(--serif); font-size: 15px; }
.result-batch-tab b { overflow: hidden; color: var(--navy-deep); font-size: 10.5px; text-overflow: ellipsis; white-space: nowrap; }
.result-batch-tab em { color: var(--ink-faint); font-size: 9px; font-style: normal; }
.result-batch-tab.active { color: #fff; background: var(--navy); border-color: var(--navy); }
.result-batch-tab.active span, .result-batch-tab.active b, .result-batch-tab.active em { color: #fff; }
.result-batch-tab.failed:not(.active) { border-color: rgba(158, 27, 50, .55); }
.result-batch-tab.failed:not(.active) em { color: var(--red); }
.result-batch-tab.completed:not(.active) em { color: var(--green); }
.processing-state {
  min-height: 250px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink-faint);
  background: var(--cream-2);
  border: 1px solid var(--line);
  text-align: center;
}
.processing-state::before {
  content: "";
  width: 26px;
  height: 26px;
  margin-bottom: 6px;
  border: 2px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
.processing-state b { color: var(--navy-deep); font-family: var(--serif); font-size: 18px; }
.processing-state span { font-size: 11px; }
.empty-result { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.empty-kicker { margin: 0; color: var(--gold); font-size: 9.5px; font-weight: 800; letter-spacing: .2em; }
.empty-result h3 { margin: 10px 0 6px; font-family: var(--serif); font-size: 23px; font-weight: 500; }
.empty-result > p:last-child { max-width: 360px; margin: 0; color: var(--ink-faint); line-height: 1.7; }
.result-summary { display: flex; align-items: center; gap: 12px; padding: 13px 15px; color: var(--red-deep); background: rgba(158, 27, 50, .07); border-left: 3px solid var(--red); }
.result-summary span { color: var(--red); font-size: 9.5px; font-weight: 800; letter-spacing: .14em; }
.result-summary b { font-family: var(--serif); font-size: 17px; }
.result-summary.error { background: rgba(158, 27, 50, .09); }
.mock-caption { margin: 10px 0 16px; color: var(--ink-faint); font-size: 10.5px; }
.finding-list { border: 1px solid var(--line); }
.finding { display: grid; grid-template-columns: 48px 1fr; min-height: 126px; background: #fff; }
.finding + .finding { border-top: 1px solid var(--line); }
.finding-index { display: grid; place-items: start center; padding-top: 16px; color: var(--gold); background: var(--cream-2); font-family: var(--serif); font-size: 14px; }
.finding-main { min-width: 0; }
.finding-header { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 13px; border-bottom: 1px solid var(--line); }
.finding-header b { font-size: 13px; }
.finding-header span { padding: 4px 8px; color: var(--red); background: rgba(158,27,50,.07); font-size: 10.5px; font-weight: 700; }
.comparison-grid { display: grid; grid-template-columns: 1fr 1fr; }
.finding-value { min-width: 0; min-height: 78px; padding: 13px; color: var(--ink-soft); line-height: 1.55; overflow-wrap: anywhere; }
.finding-value + .finding-value { border-left: 1px solid var(--line); }
.source-label { display: block; margin-bottom: 6px; color: var(--gold); font-size: 9.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.no-findings { padding: 50px 24px; color: var(--ink-soft); background: var(--cream-2); border: 1px solid var(--line); text-align: center; line-height: 1.7; }
.review-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.review-actions button { min-width: 136px; }
.follow-button { width: auto; }
.review-status { margin-top: 12px; padding: 10px 12px; color: var(--green); background: rgba(79, 115, 95, .09); border-left: 3px solid var(--green); font-weight: 600; }
.error-message { color: var(--red); line-height: 1.6; }

.image-lightbox {
  width: min(94vw, 1180px);
  max-width: none;
  height: min(92vh, 900px);
  max-height: none;
  padding: 0;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--gold-soft);
  box-shadow: 0 24px 80px rgba(12, 38, 60, .32);
}
.image-lightbox::backdrop { background: rgba(12, 38, 60, .76); backdrop-filter: blur(3px); }
.image-lightbox-bar {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 14px 10px 18px;
  background: var(--cream-2);
  border-bottom: 1px solid var(--line);
}
.image-lightbox-bar p { min-width: 0; margin: 0; overflow: hidden; color: var(--navy-deep); font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.image-lightbox-bar button { min-height: 34px; padding: 0 13px; color: var(--navy-deep); background: #fff; border: 1px solid var(--gold-soft); font-size: 11px; font-weight: 700; }
.image-lightbox > img { width: 100%; height: calc(100% - 55px); display: block; padding: 18px; object-fit: contain; background: #fff; }

.history-panel { max-width: 1160px; margin: 0 auto; }
.history-heading h1 { font-size: 20px; }
.history-note { margin: 16px 20px 0; color: var(--ink-faint); font-size: 11px; }
.history-content { min-height: 460px; padding: 14px 20px 24px; }
.history-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); }
.history-table th { padding: 10px 12px; color: var(--gold); border-bottom: 1px solid var(--gold-soft); font-size: 9.5px; letter-spacing: .12em; text-align: left; }
.history-table td { padding: 12px; color: var(--ink-soft); border-bottom: 1px solid var(--line); font-size: 12px; }
.history-table tr:last-child td { border-bottom: 0; }
.history-table button { color: var(--navy); background: transparent; border: 0; font-weight: 700; }
.history-empty { padding: 80px 0; color: var(--ink-faint); text-align: center; }
.history-sample { color: var(--gold); font-weight: 600; }
.history-row.status-failed td[data-status]::before { content: "▲ "; }
.history-row.status-needs_follow_up td[data-status]::before { content: "● "; }
.history-row.status-completed td[data-status]::before { content: "✓ "; }
.history-row.status-review_pending td[data-status]::before { content: "○ "; }
.history-row.status-processing td[data-status]::before { content: "◐ "; }
.history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: flex-end;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--cream-2);
}
.history-filters label { display: grid; gap: 4px; font-size: 11px; color: var(--ink-soft); }
.history-filters label > span { letter-spacing: .04em; }
.history-filters input, .history-filters select {
  padding: 7px 9px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.history-filters .history-toggle { flex-direction: row; align-items: center; display: flex; gap: 6px; }
.history-filter-actions { display: flex; gap: 8px; margin-left: auto; }
.history-pagination { display: flex; gap: 12px; align-items: center; justify-content: flex-end; padding: 0 20px 20px; }
.page-lede { max-width: 760px; margin: 0 0 16px; color: var(--ink-soft); font-size: 13px; }
.sidebar-toggle {
  position: fixed;
  left: 8px;
  bottom: 12px;
  z-index: 5;
  padding: 5px 10px;
  color: var(--navy);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 11px;
}
.sidebar.collapsed { width: 0; flex-basis: 0; overflow: hidden; border-right: 0; }

.result-rows { display: grid; gap: 8px; padding: 14px 20px 20px; }
.result-row {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold-soft);
}
.result-row.failed { border-left-color: var(--red); }
.result-row.completed { border-left-color: var(--green); }
.result-row-index { color: var(--ink-faint); font-family: var(--serif); }
.result-row-main { display: grid; gap: 2px; flex: 1; }
.result-row-main span { color: var(--ink-soft); font-size: 12px; }
.result-row button { margin-left: auto; }

/* ---- batch detail ---- */
.detail-view { display: block; }
.detail-navbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.detail-position { color: var(--ink-soft); font-size: 12px; }
.detail-button {
  padding: 6px 11px;
  color: var(--navy);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 12px;
}
.detail-button:hover:not(:disabled) { border-color: var(--gold); }
.detail-button:disabled { color: var(--ink-faint); background: var(--cream-3); cursor: not-allowed; }
.detail-button.primary { color: var(--white); background: var(--navy); border-color: var(--navy-deep); }
.detail-button.finish { color: var(--white); background: var(--green); border-color: var(--green); }
.detail-button.finish:disabled, .detail-button.primary:disabled { color: var(--ink-faint); background: var(--cream-3); border-color: var(--line); }
:where(.detail-view) :is(button, [tabindex], input, select, textarea):focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}
.detail-header { padding: 10px 14px; background: var(--cream-2); border: 1px solid var(--line); }
.detail-header-top { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.detail-identity { display: flex; gap: 18px; flex-wrap: wrap; }
.detail-code { display: grid; gap: 1px; }
.detail-code span { color: var(--ink-faint); font-size: 10px; letter-spacing: .08em; }
.detail-code b { color: var(--ink); font-size: 14px; }
.detail-code b[data-available="false"] { color: var(--ink-faint); font-style: italic; font-weight: 500; }
.detail-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-tag {
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--white);
  font-size: 11px;
}
.detail-tag.ai-mock { color: var(--gold); border-color: var(--gold-soft); }
.detail-tag.ai-failed { color: var(--red); border-color: var(--red); }
.detail-tag.ai-real { color: var(--navy); border-color: var(--navy); }
.detail-tag.review-completed { color: var(--green); border-color: var(--green); }
.detail-tag.review-needs_follow_up { color: var(--red-deep); border-color: var(--red-deep); }
.detail-audit-toggle { margin-left: auto; }
.detail-sample-banner {
  margin: 8px 0 0;
  padding: 7px 10px;
  color: var(--red-deep);
  background: #fdf5e6;
  border: 1px solid var(--gold);
  font-size: 12px;
  font-weight: 600;
}
.detail-audit { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; margin: 10px 0 0; }
.detail-field dt { color: var(--ink-faint); font-size: 10px; letter-spacing: .06em; }
.detail-field dd { margin: 1px 0 0; color: var(--ink-soft); font-size: 12px; }
.detail-originals-notice, .detail-error {
  margin: 8px 0 0;
  padding: 8px 10px;
  border: 1px solid var(--gold-soft);
  background: #fdf7ec;
  font-size: 12px;
}
.detail-error { color: var(--red-deep); border-color: var(--red); background: #fbf0f1; }
.detail-split { display: grid; gap: 0; margin-top: 10px; align-items: stretch; }
.detail-splitter { background: var(--line); cursor: col-resize; }
.detail-splitter:focus-visible { background: var(--navy); }
.detail-documents, .detail-review { min-width: 0; background: var(--white); border: 1px solid var(--line); }
.detail-categories, .detail-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); background: var(--cream-2); }
.detail-category, .detail-tab {
  padding: 6px 10px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid transparent;
  font-size: 12px;
}
.detail-category.active, .detail-tab.active {
  color: var(--navy);
  background: var(--white);
  border-color: var(--line);
  border-bottom-color: var(--white);
  font-weight: 700;
}
.detail-files { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.detail-file { max-width: 240px; overflow: hidden; padding: 4px 8px; color: var(--ink-soft); background: var(--cream); border: 1px solid var(--line); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.detail-file.active { color: var(--navy); background: var(--white); border-color: var(--gold); font-weight: 700; }
.detail-toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.detail-pages { display: inline-flex; gap: 6px; align-items: center; font-size: 12px; }
.detail-page-notice { color: var(--ink-faint); font-size: 11px; }
.detail-viewer { display: grid; gap: 8px; padding: 10px; background: var(--cream-3); min-height: 420px; }
.detail-viewer.comparing { grid-template-columns: 1fr 1fr; }
.detail-viewer-pane { display: grid; gap: 6px; align-content: start; overflow: auto; background: var(--white); border: 1px solid var(--line); padding: 8px; }
.detail-viewer-name { margin: 0; color: var(--ink-faint); font-size: 11px; word-break: break-all; }
.detail-image { max-width: 100%; transform-origin: top left; }
.detail-pdf { width: 100%; min-height: 460px; border: 0; }
.detail-unavailable { color: var(--red-deep); font-size: 12px; }
.detail-reattach { display: grid; gap: 4px; font-size: 12px; }
.detail-tab-body { padding: 10px; max-height: 62vh; overflow: auto; }
.detail-review { display: grid; align-content: start; }
.detail-issues { border-bottom: 1px solid var(--line); }
.detail-section-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--cream-2);
  border-bottom: 1px solid var(--line);
}
.detail-section-title { margin: 0; font-family: var(--serif); font-size: 15px; }
.detail-issue-summary { color: var(--ink-soft); font-size: 12px; }
.detail-issue-pending { color: var(--red-deep); font-size: 12px; }
.detail-issue-filter { margin-left: auto; font-size: 11px; }
.detail-issue-note { margin: 0; padding: 6px 10px; color: var(--ink-soft); background: var(--cream); font-size: 11px; }
.detail-issues-body { padding: 10px; max-height: 46vh; overflow: auto; }
.detail-section { border-top: 1px solid var(--line); }
.detail-section-toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--cream-2);
  border: 0;
  text-align: left;
}
.detail-section-caret { margin-left: auto; color: var(--ink-faint); font-size: 11px; }
.detail-section-toggle[aria-expanded="true"] .detail-section-caret::before { content: "▾ "; }
.detail-section-toggle[aria-expanded="false"] .detail-section-caret::before { content: "▸ "; }
.detail-section-body { padding: 10px; max-height: 46vh; overflow: auto; }
.detail-finding.from-comparison { border-left-color: var(--navy-deep); }
.detail-finding-body[data-resolved="true"] { background: var(--cream); }
.detail-origin-tag { padding: 1px 7px; border: 1px solid var(--line); background: var(--white); font-size: 11px; }
.detail-issue-sources { display: grid; gap: 6px; }
.detail-value-state { display: block; margin-top: 4px; color: var(--ink-faint); font-size: 11px; }
.detail-export-notice { margin: 0; color: var(--ink-soft); font-size: 11px; }
.detail-export-state { margin: 0; font-size: 11px; }
.detail-export-state.error { color: var(--red-deep); font-weight: 700; }
.operation-export { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.operation-export-notice { margin: 0; color: var(--ink-soft); font-size: 11px; }
.operation-export-state { margin: 0; font-size: 11px; }
.operation-export-state.error { color: var(--red-deep); font-weight: 700; }
.detail-empty { padding: 28px 10px; color: var(--ink-soft); text-align: center; }
.detail-findings { display: grid; gap: 10px; }
.detail-finding { border: 1px solid var(--line); border-left: 3px solid var(--gold); }
.detail-finding.kind-unreadable { border-left-color: var(--navy); }
.detail-finding.kind-missing { border-left-color: var(--red); }
.detail-finding-head { display: flex; gap: 8px; align-items: center; padding: 7px 9px; background: var(--cream-2); }
.detail-kind { padding: 1px 7px; border: 1px solid var(--line); border-radius: 2px; background: var(--white); font-size: 11px; }
.detail-kind.kind-difference::before { content: "≠ "; }
.detail-kind.kind-unreadable::before { content: "? "; }
.detail-kind.kind-missing::before { content: "— "; }
.detail-finding-count { color: var(--ink-faint); font-size: 11px; }
.detail-finding-body { padding: 8px 9px; border-top: 1px solid var(--line); }
.detail-finding-message { margin: 0 0 6px; color: var(--ink); font-size: 12px; }
.detail-source-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-source { padding: 6px; background: var(--cream); border: 1px solid var(--line); }
.detail-source-link { padding: 0; color: var(--navy); background: none; border: 0; border-bottom: 1px dotted var(--navy); font-size: 11px; text-align: left; }
.detail-source-plain { color: var(--ink-faint); font-size: 11px; }
.detail-source-value { margin: 4px 0 0; color: var(--ink); font-size: 12px; word-break: break-word; }
.detail-disposition-row { display: grid; gap: 6px; margin-top: 8px; }
.detail-disposition-buttons { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-disposition { padding: 4px 9px; color: var(--ink-soft); background: var(--white); border: 1px solid var(--line); font-size: 11px; }
.detail-disposition.active { color: var(--white); background: var(--navy); border-color: var(--navy-deep); font-weight: 700; }
.detail-disposition.active::before { content: "✓ "; }
.detail-item-note, .detail-note { width: 100%; padding: 6px; border: 1px solid var(--line); font-size: 12px; resize: vertical; }
.detail-disposition-state { margin: 0; color: var(--ink-faint); font-size: 11px; }
.detail-comparison { display: grid; gap: 6px; }
.detail-comparison-item { border: 1px solid var(--line); }
.detail-comparison-summary {
  display: flex;
  gap: 8px;
  align-items: center;
  width: 100%;
  padding: 7px 9px;
  color: var(--ink);
  background: var(--cream-2);
  border: 0;
  text-align: left;
}
.detail-comparison-summary[aria-expanded="true"] { background: var(--white); border-bottom: 1px solid var(--line); }
.detail-comparison-caret { margin-left: auto; color: var(--ink-faint); font-size: 11px; }
.detail-comparison-summary[aria-expanded="true"] .detail-comparison-caret::before { content: "▾ "; }
.detail-comparison-summary[aria-expanded="false"] .detail-comparison-caret::before { content: "▸ "; }
.detail-comparison-status { padding: 1px 7px; border: 1px solid var(--line); background: var(--white); font-size: 11px; }
.detail-comparison-status.status-match { color: var(--green); }
.detail-comparison-status.status-match::before { content: "= "; }
.detail-comparison-status.status-difference { color: var(--red-deep); }
.detail-comparison-status.status-difference::before { content: "≠ "; }
.detail-comparison-status.status-unreadable::before { content: "? "; }
.detail-comparison-status.status-missing::before { content: "— "; }
.detail-comparison-status.status-not_applicable::before { content: "· "; }
.detail-comparison-table { width: 100%; border-collapse: collapse; }
.detail-comparison-table th, .detail-comparison-table td { padding: 6px 8px; border-top: 1px solid var(--line); font-size: 12px; text-align: left; vertical-align: top; }
.detail-comparison-table th { width: 96px; color: var(--ink-faint); font-weight: 600; }
.detail-comparison-table td[data-state="unreadable"], .detail-comparison-table td[data-state="missing"] { color: var(--red-deep); font-style: italic; }
.detail-comparison-table td[data-state="not_applicable"] { color: var(--ink-faint); }
.detail-events { display: grid; gap: 8px; margin: 0; padding-left: 18px; }
.detail-event { padding: 7px 9px; background: var(--cream); border: 1px solid var(--line); }
.detail-event-head { display: flex; gap: 8px; align-items: baseline; font-size: 12px; }
.detail-event-head time { margin-left: auto; color: var(--ink-faint); font-size: 11px; }
.detail-event-note { margin: 4px 0 0; color: var(--ink-soft); font-size: 12px; }
.detail-event-changes { margin: 4px 0 0; padding-left: 16px; color: var(--ink-soft); font-size: 11px; }
.detail-footer { display: grid; gap: 8px; padding: 10px; border-top: 1px solid var(--line); background: var(--cream-2); }
.detail-save-state { margin: 0; font-size: 12px; }
.detail-save-state.state-saved { color: var(--green); }
.detail-save-state.state-saved::before { content: "✓ "; }
.detail-save-state.state-dirty { color: var(--red-deep); }
.detail-save-state.state-dirty::before { content: "● "; }
.detail-save-state.state-error { color: var(--red); font-weight: 700; }
.detail-save-state.state-error::before { content: "▲ "; }
.detail-save-state.state-saving::before { content: "… "; }
.detail-release-notice { margin: 0; color: var(--ink-soft); font-size: 11px; }
.detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.detail-blocked-reason { margin: 0; color: var(--red-deep); font-size: 11px; }
.detail-viewer-hint { color: var(--ink-faint); font-size: 11px; }
.detail-navbar { flex-wrap: wrap; }
.detail-splitter { touch-action: none; }

/* Full-window document reader. An embedded webview refuses requestFullscreen(), so the enlarged
   view is an ordinary overlay that works the same in every container. */
.detail-reader {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  background: var(--cream);
}
.detail-reader-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--cream-2);
  border-bottom: 1px solid var(--line);
}
.detail-reader-name { color: var(--ink); font-size: 13px; word-break: break-all; }
.detail-reader-controls { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.detail-reader-page { font-size: 12px; }
.detail-reader-bar .primary { margin-left: auto; }
.detail-reader-body { flex: 1; display: grid; gap: 8px; padding: 10px; overflow: auto; }
.detail-reader-body.comparing { grid-template-columns: 1fr 1fr; }
.detail-reader-body .detail-viewer-pane { overflow: auto; background: var(--white); }
.detail-reader-body .detail-pdf { min-height: 78vh; }

/* In-page confirmation, used instead of a blocking native dialog for normal app actions. */
.detail-dialog {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(12, 38, 60, .45);
}
.detail-dialog-panel {
  width: min(460px, 100%);
  padding: 18px 20px;
  background: var(--white);
  border: 1px solid var(--gold-soft);
  border-top: 3px solid var(--navy);
  box-shadow: 0 18px 44px rgba(12, 38, 60, .22);
}
.detail-dialog-title { margin: 0 0 8px; font-family: var(--serif); font-size: 16px; color: var(--navy); }
.detail-dialog-body { margin: 0 0 16px; color: var(--ink-soft); font-size: 13px; line-height: 1.6; }
.detail-dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.detail-button.danger { color: var(--white); background: var(--red); border-color: var(--red-deep); }
.detail-dialog-cancel { font-weight: 700; }

/* 核对作业 — one confirmed upload submission and its material batches. The same compact
   vocabulary as the record history: no oversized ornament, states carried by text and shape. */
.operations-host, .operation-host { padding: 14px 20px 20px; }
.operation-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px;
  background: var(--cream-2);
  border: 1px solid var(--line);
}
.operation-filter-input {
  min-height: 32px;
  padding: 6px 9px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 12px;
}
.operation-presets { display: flex; gap: 4px; flex-wrap: wrap; }
.operation-preset { min-height: 32px; padding: 0 10px; font-size: 11px; }
.operation-preset.active { color: #fff; background: var(--navy); border-color: var(--navy); }
.operation-custom-range { display: flex; gap: 6px; }
.operation-toggle { display: flex; gap: 6px; align-items: center; font-size: 11px; color: var(--ink-soft); }
.operation-filter-actions { display: flex; gap: 8px; margin-left: auto; }
.operation-date-basis { flex-basis: 100%; margin: 0; color: var(--ink-faint); font-size: 11px; }
.operation-rows { display: grid; gap: 8px; margin-top: 12px; }
.operation-row {
  display: grid;
  gap: 6px;
  padding: 11px 13px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold-soft);
}
.operation-row[data-complete="true"] { border-left-color: var(--green); }
.operation-row-head { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.operation-row-head b { font-family: var(--serif); font-size: 15px; }
.operation-row-head span { color: var(--ink-soft); font-size: 12px; }
.operation-row-size { color: var(--ink) !important; font-weight: 600; }
.operation-progress { margin-left: auto; color: var(--navy) !important; font-weight: 600; }
.operation-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.operation-count {
  padding: 2px 8px;
  color: var(--ink-soft);
  background: var(--cream-2);
  border: 1px solid var(--line);
  border-radius: 2px;
  font-size: 11px;
}
/* Shape as well as colour, so no state is conveyed by colour alone. */
.operation-count.state-not_submitted::before { content: "○ "; }
.operation-count.state-processing::before { content: "◐ "; }
.operation-count.state-failed::before { content: "▲ "; color: var(--red); }
.operation-count.state-pending_review::before { content: "◇ "; }
.operation-count.state-needs_follow_up::before { content: "● "; }
.operation-count.state-completed::before { content: "✓ "; color: var(--green); }
.operation-sample, .operation-matched { margin: 0; font-size: 11px; }
.operation-sample { color: var(--gold); font-weight: 600; }
.operation-matched { color: var(--ink-soft); }
.operation-row button { justify-self: start; }
.operation-header {
  display: grid;
  gap: 8px;
  padding: 12px 13px;
  background: var(--cream-2);
  border: 1px solid var(--line);
}
.operation-header-top { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.operation-header-top b { font-family: var(--serif); font-size: 17px; }
.operation-header-top span { color: var(--ink-soft); font-size: 12px; }
.operation-notice, .operation-release-notice { margin: 0; color: var(--ink-faint); font-size: 11px; }
.operation-members { display: grid; gap: 8px; margin-top: 12px; }
.operation-member {
  display: grid;
  gap: 6px;
  padding: 11px 13px;
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
}
.operation-member.state-completed { border-left-color: var(--green); }
.operation-member.state-failed { border-left-color: var(--red); }
.operation-member.state-needs_follow_up { border-left-color: var(--gold); }
.operation-member.state-not_submitted { background: var(--cream-2); }
.member-identity { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.member-position { color: var(--ink-faint); font-family: var(--serif); }
.member-identity b { font-size: 14px; }
.member-identity span { color: var(--ink-soft); font-size: 12px; }
.member-facts { display: flex; gap: 12px; flex-wrap: wrap; color: var(--ink-soft); font-size: 11px; }
.member-state { font-weight: 600; color: var(--ink); }
.member-state[data-state="failed"]::before { content: "▲ "; }
.member-state[data-state="needs_follow_up"]::before { content: "● "; }
.member-state[data-state="completed"]::before { content: "✓ "; }
.member-state[data-state="pending_review"]::before { content: "◇ "; }
.member-state[data-state="processing"]::before { content: "◐ "; }
.member-state[data-state="not_submitted"]::before { content: "○ "; }
.member-sample { margin: 0; color: var(--gold); font-size: 11px; font-weight: 600; }
.member-error { margin: 0; color: var(--red-deep); font-size: 11px; }
.member-notice { margin: 0; color: var(--ink-faint); font-size: 11px; }
.operation-member button { justify-self: start; }
.legacy-notice { color: var(--gold); }
.pending-member-notice {
  max-width: 760px;
  margin: 0 0 16px;
  padding: 9px 12px;
  color: var(--navy-deep);
  background: var(--navy-soft);
  border-left: 3px solid var(--navy);
  font-size: 12px;
}
.result-operation {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 20px 20px;
  padding: 10px 12px;
  background: var(--cream-2);
  border: 1px solid var(--line);
}
.result-operation span { color: var(--ink-soft); font-size: 12px; }
.result-operation button { margin-left: auto; }
.nav-item-secondary { font-size: 11px; }
.detail-operation-context { color: var(--navy); font-size: 12px; font-weight: 600; }
.detail-operation-skip { color: var(--ink-faint); font-size: 11px; }
.detail-versions { display: grid; gap: 8px; }
.detail-versions-note { margin: 0; color: var(--ink-faint); font-size: 11px; }
.detail-version-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.detail-version {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  padding: 8px 10px;
  background: var(--white);
  border: 1px solid var(--line);
  font-size: 12px;
}
.detail-version.current { border-color: var(--navy); background: var(--navy-soft); }
.detail-version-operation { color: var(--navy); font-weight: 600; }
.detail-version-sample { color: var(--gold); }
.detail-version-current { margin-left: auto; color: var(--navy); font-weight: 700; }
.detail-version button { margin-left: auto; }

@media (max-width: 1180px) {
  body { min-width: 760px; }
  .sidebar { width: 190px; flex-basis: 190px; }
  .workspace { padding: 24px 20px 50px; }
  .bulk-source-grid { grid-template-columns: 1fr; }
  .pairing-card-body { grid-template-columns: 1fr; }
  .pairing-card-documents { border-top: 1px solid var(--line); border-left: 0; }
  .view-grid { grid-template-columns: 1fr; }
  .result-content { min-height: 400px; }
  /* Narrow Feishu viewport: the two panes stack so neither becomes unreadable. */
  .detail-split { grid-template-columns: 1fr !important; }
  .detail-splitter { display: none; }
  /* Issues first in one column: the whole point of the panel is what still needs confirming,
     and a full-height original reader above it pushes that off the first screen. The desktop
     split keeps its own order, so only the stacked layout is affected. */
  .detail-review { order: 1; }
  .detail-documents { order: 2; }
  .detail-viewer { min-height: 320px; }
  .detail-viewer.comparing { grid-template-columns: 1fr; }
  .detail-source-pair { grid-template-columns: 1fr; }
  .detail-tab-body { max-height: none; }
  .detail-issues-body, .detail-section-body { max-height: none; }
  .history-filters { flex-direction: column; align-items: stretch; }
  .history-filter-actions { margin-left: 0; }
  .operation-filters { flex-direction: column; align-items: stretch; }
  .operation-filter-actions { margin-left: 0; }
  .operation-progress { margin-left: 0; }
  /* Every control stays reachable in one column rather than being clipped. */
  .operation-presets, .operation-counts, .member-facts { overflow-x: auto; }
  /* Single column, and every control stays reachable rather than being clipped. */
  .detail-toolbar, .detail-files, .detail-categories, .detail-actions { overflow-x: auto; }
  .detail-viewer-pane { overflow: auto; }
  .detail-audit { grid-template-columns: 1fr 1fr; }
  .detail-reader-body.comparing { grid-template-columns: 1fr; }
  .detail-reader-bar .primary { margin-left: 0; }
}

@media (max-width: 820px) {
  body { min-width: 0; }
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; display: block; }
  .brand { padding: 14px 16px 11px; }
  .nav-group { display: flex; gap: 4px; padding: 7px 10px; }
  .nav-label, .sidebar-note { display: none; }
  .nav-item { width: auto; padding: 8px 12px; border-left: 0; border-bottom: 2px solid transparent; }
  .nav-item.active { border-bottom-color: var(--navy); }
  .crumbbar { padding: 0 14px; }
  .workspace { padding: 18px 12px 40px; }
  .mode-notice { margin-bottom: 22px; }
  .page-heading h1 { font-size: 31px; }
  .workflow-tabs { top: 46px; }
  .workflow-tab { min-height: 62px; grid-template-columns: 26px minmax(0, 1fr); padding: 9px 11px; }
  .workflow-tab > span { font-size: 21px; }
  .workflow-tab small { display: none; }
  .bulk-body { padding: 14px; }
  .bulk-toolbar, .pairing-footer { align-items: stretch; flex-direction: column; }
  .bulk-toolbar .primary-button, .pairing-footer .primary-button { width: 100%; }
  .view-grid { display: block; }
  .result-panel { margin-top: 14px; }
  .section-meta { display: none; }
  .panel-body, .result-content { padding: 14px; }
  .batch-toolbar { align-items: stretch; }
  .batch-toolbar > div { display: grid; gap: 2px; }
  .batch-tabs { grid-auto-columns: minmax(138px, 72%); }
  .upload-title span { display: none; }
  .label-pair { grid-template-columns: 1fr; }
  .label-preview img { height: min(55vh, 360px); }
  .document-preview img { height: min(40vh, 280px); }
  .document-preview-grid { grid-template-columns: 1fr; }
  .empty-file-state, .file-item { padding-left: 12px; }
  .upload-footer { align-items: stretch; flex-direction: column; }
  .upload-footer .primary-button { width: 100%; }
  .comparison-grid { grid-template-columns: 1fr; }
  .finding-value + .finding-value { border-left: 0; border-top: 1px solid var(--line); }
  .review-actions { flex-direction: column; }
  .review-actions button { width: 100%; }
  .result-batch-tabs { display: flex; overflow-x: auto; }
  .result-batch-tab { min-width: 136px; }
  .operations-host, .operation-host { padding: 12px; }
  .operation-row-head, .operation-header-top { gap: 8px; }
  .operation-row button, .operation-member button { width: 100%; }
  .result-operation { align-items: stretch; flex-direction: column; }
  .result-operation button { width: 100%; margin-left: 0; }
  .detail-version { gap: 6px; }
  .detail-version button, .detail-version-current { margin-left: 0; }
}
