: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; }

@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; }
}

@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; }
}
