:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d8dee8;
  --line-strong: #bac5d3;
  --text: #172033;
  --muted: #677286;
  --brand: #0f5b63;
  --ok: #197443;
  --warn: #9a5b09;
  --bad: #a2393b;
  --blue: #285f9f;
  --visited: #5a3f91;
  --focus: #9cc9d0;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.45 Pretendard, "Segoe UI", Arial, sans-serif;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

a { color: var(--blue); }
a:visited { color: var(--visited); }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 20px;
}

.topbar,
.toolbar,
.modal-head,
.actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  letter-spacing: 0;
}

h1 { margin: 0; font-size: 22px; }
h2 { margin: 0; font-size: 15px; }
h3 { margin: 0; font-size: 13px; }

.userbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
}

.nav-action {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  font-weight: 750;
  text-decoration: none;
}

.nav-action:visited {
  color: var(--text);
}

.nav-action svg {
  width: 17px;
  height: 17px;
  fill: var(--brand);
  flex: 0 0 auto;
}

.toolbar {
  margin: 16px 0 10px;
}

.toolbar p { margin: 2px 0 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.table-panel { overflow-x: auto; }

.app-switcher {
  display: inline-flex;
  margin: 14px 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(23, 32, 51, .05);
}

.inline-upload {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.inline-upload input[type="text"] {
  width: 220px;
}

.panel-body {
  padding: 12px;
  justify-content: flex-start;
}

.project-table,
.result-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #eef3f7;
  font-size: 11px;
  text-transform: uppercase;
}

.project-table th:nth-child(1) { width: 23%; }
.project-table th:nth-child(3) { width: 15%; }
.project-table th:nth-child(5),
.project-table th:nth-child(6) { width: 12%; }
.project-table th:nth-child(9) { width: 84px; }

.project-row strong,
.project-row small {
  display: block;
}

.mono { font-family: "JetBrains Mono", Consolas, monospace; }
.muted { color: var(--muted); }
.bad-text { color: var(--bad); }
.truncate {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list-button {
  display: inline;
  max-width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  font: inherit;
  font-weight: 650;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}

.file-list-button:hover,
.file-list-button:focus-visible {
  color: var(--brand);
}

.file-list-inline {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.file-list-inline span {
  display: block;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 4px;
  padding: 2px 7px;
  background: #e8eef4;
  color: #263449;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.READY,
.READY_FOR_REVIEW,
.APPROVED,
.DRY_RUN_OK,
.SUCCEEDED,
.MATCHED,
.matched,
.available { background: #ddf3e5; color: var(--ok); }
.QUEUED,
.RUNNING,
.PENDING,
.NOT_RUN,
.CANDIDATE_MATCH,
.NEEDS_REVIEW,
.needs_review,
.candidate,
.multiple_candidates,
.within_tolerance,
.missing,
.erp_only,
.not_checked,
.missing_in_period { background: #fff0dc; color: var(--warn); }
.FAILED,
.REJECTED,
.CANCELLED,
.BLOCKED,
.VERIFY_FAILED,
.SUPPLIER_MISMATCH,
.CUSTOMER_MISMATCH,
.DATE_MISMATCH,
.BL_MISSING,
.mismatch,
.period_or_date_mismatch,
.matched_other_period { background: #fde5e5; color: var(--bad); }

.progress-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #eef3f7;
}

.progress-bar span {
  display: block;
  height: 100%;
  background: var(--brand);
  transition: width 180ms ease;
}

.primary,
.secondary,
.danger,
.logout,
.icon-button {
  min-height: 44px;
  border-radius: 5px;
  padding: 8px 11px;
  font-weight: 750;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

.primary {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
}

.primary:visited { color: #fff; }

.secondary,
.logout,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.source-action {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.danger {
  border: 1px solid #e6a1a3;
  background: #fff0f0;
  color: var(--bad);
}

.small-action {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
}

button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.message {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 9px 11px;
  background: var(--panel-soft);
}

.message.success {
  border-color: #9ac7ad;
  background: #eef8f1;
  color: #225a34;
}

.message.bad {
  border-color: #e6a1a3;
  background: #fff0f0;
  color: var(--bad);
}

.message.warn {
  border-color: #e2b36e;
  background: #fff8eb;
  color: var(--warn);
}

.message.good {
  border-color: #9bc8ad;
  background: #f0faf3;
  color: var(--ok);
}

.legacy-error { margin: 10px 0; }

.empty-row td,
.empty-state {
  padding: 20px;
  color: var(--muted);
}

.unread-dot {
  display: inline-flex;
  width: fit-content;
  margin-top: 4px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #fff0dc;
  color: var(--warn);
  font-size: 11px;
  font-weight: 750;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  max-width: 360px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 12px 14px;
  box-shadow: 0 10px 30px rgba(23, 32, 51, .14);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(23, 32, 51, .42);
}

.modal {
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 32px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 18px;
}

.file-list-modal {
  width: min(520px, 100%);
}

.modal-file-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding-left: 22px;
  overflow-wrap: anywhere;
}

.modal form,
.source-list {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 5px;
  font-weight: 650;
}

input[type="text"],
input[type="password"],
input:not([type]) {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 10px;
}

input[type="file"] {
  max-width: 230px;
}

.file-input-hidden {
  display: none;
}

.file-input-native {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  opacity: 0;
  cursor: pointer;
}

.file-pick-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  cursor: pointer;
}

.file-pick-button span {
  pointer-events: none;
}

.inline-upload .file-pick-button {
  width: auto;
}

.erp-bl-upload {
  max-width: 760px;
}

.erp-upload-selection {
  display: grid;
  flex: 1 1 100%;
  gap: 5px;
  min-width: 260px;
  color: var(--muted);
}

.erp-upload-selection > span {
  font-weight: 750;
}

.compact-selection-list {
  max-height: 116px;
}

.erp-upload-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 36px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
}

.erp-upload-file-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.erp-upload-file-row small {
  color: var(--muted);
}

.source-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--panel-soft);
}

.source-row {
  display: grid;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: var(--panel-soft);
}

.source-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.source-row strong,
.source-row span {
  display: block;
}

.source-row span {
  color: var(--muted);
  font-weight: 500;
}

.source-row[data-state="valid"] {
  border-color: #9bc8ad;
  background: #f0faf3;
}

.source-row[data-state="error"] {
  border-color: #e6a1a3;
  background: #fff0f0;
}

.source-row[data-state="partial"],
.source-row[data-state="loading"] {
  border-color: #e2b36e;
  background: #fff8eb;
}

.source-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}

.source-control {
  display: grid;
  gap: 4px;
}

.selection-list {
  display: grid;
  gap: 0;
  max-height: 170px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}

.source-chip strong,
.source-chip span {
  display: block;
}

.source-chip span {
  color: var(--muted);
  font-weight: 500;
}

.source-chip[data-state="valid"] {
  border-color: #9bc8ad;
  background: #f0faf3;
}

.source-chip[data-state="error"] {
  border-color: #e6a1a3;
  background: #fff0f0;
}

.source-chip[data-state="partial"],
.source-chip[data-state="loading"] {
  border-color: #e2b36e;
  background: #fff8eb;
}

.source-group {
  display: grid;
  gap: 8px;
}

.folder-pdf-panel {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  overflow: hidden;
}

.folder-pdf-head {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #eef3f7;
}

.folder-pdf-head span,
.folder-pdf-row small {
  color: var(--muted);
}

.folder-pdf-list {
  max-height: 220px;
  overflow: auto;
}

.folder-pdf-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 7px 10px 7px 0;
  border-bottom: 1px solid var(--line);
}

.drive-browser-panel {
  margin-top: 4px;
}

.drive-browser-actions {
  display: flex;
  gap: 6px;
}

.drive-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.breadcrumb-button,
.drive-folder-button {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--blue);
  padding: 5px 8px;
  cursor: pointer;
}

.drive-browser-list {
  max-height: 280px;
  overflow: auto;
}

.drive-browser-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 46px;
  padding: 7px 10px 7px 0;
  border-bottom: 1px solid var(--line);
}

.drive-browser-row[data-folder="true"] {
  display: block;
  padding: 8px 10px;
}

.drive-browser-row strong,
.drive-browser-row small {
  display: block;
}

.drive-browser-row small {
  color: var(--muted);
}

.folder-pdf-row:last-child { border-bottom: 0; }

.folder-pdf-row input {
  justify-self: center;
  min-width: 20px;
  min-height: 20px;
}

.folder-pdf-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-pdf-row[data-selectable="false"] {
  color: var(--muted);
  background: #f8fafc;
}

.folder-pdf-empty {
  padding: 12px;
  color: var(--muted);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-gate {
  width: min(440px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 22px;
}

.login-gate h1 { margin-bottom: 18px; }
.login-button { display: block; }

.security-note {
  margin: 14px 0 0;
  color: var(--muted);
}

.dev-login {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.dev-login .secondary {
  width: 100%;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px 11px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
}

.result-panel { margin-top: 12px; }

.result-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: #eef3f7;
}

.tab-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  border: 2px solid transparent;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 8px 16px;
  color: var(--muted);
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.tab-button:first-child {
  border-radius: 6px 0 0 6px;
}

.tab-button:last-child {
  border-right: 0;
  border-radius: 0 6px 6px 0;
}

.tab-button:visited {
  color: var(--muted);
}

.tab-button:hover {
  background: #f8fafc;
  color: var(--text);
}

.tab-button.is-active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 8px 18px rgba(15, 91, 99, .2);
}

.tab-button.is-active:visited,
.tab-button.is-active:hover {
  color: #fff;
}

.tab-button.is-active::after {
  content: "선택됨";
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  border-radius: 4px;
  background: rgba(255, 255, 255, .18);
  padding: 1px 5px;
  color: #fff;
  font-size: 10px;
  font-weight: 750;
}

.tab-icon {
  display: inline-flex;
  min-width: 30px;
  min-height: 22px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--brand);
  font-size: 10px;
  line-height: 1;
}

.tab-button.is-active .tab-icon {
  border-color: rgba(255, 255, 255, .58);
  background: rgba(255, 255, 255, .14);
  color: #fff;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.admin-panel .panel-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #eef3f7;
}

.admin-panel .panel-head span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.admin-config-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.admin-config-list div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.admin-config-list dt {
  color: var(--muted);
  font-weight: 750;
}

.admin-config-list dd {
  margin: 0;
}

.admin-user-table th:nth-child(1) { width: 28%; }
.admin-user-table th:nth-child(4) { width: 24%; }

.admin-user-form,
.inline-admin-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  padding: 12px;
}

.admin-user-form label,
.inline-admin-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
}

.admin-user-form input,
.admin-user-form select,
.inline-admin-form input,
.inline-admin-form select {
  min-height: 36px;
  min-width: 120px;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 9px;
  background: #fff;
  color: var(--text);
}

.inline-admin-form {
  padding: 0 0 6px;
}

.inline-admin-form input {
  max-width: 150px;
}

.muted-row {
  color: var(--muted);
}

.actions-row {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 12px;
}

.workflow-topbar {
  align-items: center;
}

.stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.step-pill {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  padding: 6px 9px;
  color: var(--muted);
  font-weight: 750;
  text-decoration: none;
}

.step-pill.is-active {
  border-color: var(--brand);
  background: #eaf4f5;
  color: var(--brand);
}

.workflow-grid {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 12px;
}

.step-rail {
  display: grid;
  align-content: start;
  gap: 12px;
  position: sticky;
  top: 12px;
}

.step-rail section {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.side-stepper {
  display: grid;
  gap: 2px;
  margin-top: 9px;
}

.side-step {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-height: 54px;
  border-radius: 6px;
  padding: 8px;
  color: var(--muted);
  text-decoration: none;
}

.side-step::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 38px;
  bottom: -18px;
  width: 1px;
  background: var(--line);
}

.side-step:last-child::before {
  display: none;
}

.side-step-marker {
  position: relative;
  z-index: 1;
  display: inline-grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  font-family: "JetBrains Mono", Consolas, monospace;
}

.side-step-copy {
  display: grid;
  gap: 1px;
}

.side-step-copy strong {
  color: var(--text);
  font-size: 13px;
}

.side-step-copy small {
  color: var(--muted);
  font-size: 11px;
}

.side-step:hover {
  background: #f5f8fb;
}

.side-step[aria-current="step"],
.side-step.is-active {
  background: #edf7f8;
  color: var(--brand);
}

.side-step[aria-current="step"] .side-step-marker,
.side-step.is-active .side-step-marker {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  box-shadow: 0 0 0 3px #d7eff2;
}

.side-step[aria-current="step"] .side-step-copy strong,
.side-step.is-active .side-step-copy strong {
  color: var(--brand);
}

.legend {
  display: block;
  margin-top: 6px;
}

.legend {
  border-left: 4px solid var(--line);
  padding-left: 7px;
}

.legend.matched { border-color: var(--ok); }
.legend.partial { border-color: var(--warn); }
.legend.mismatch,
.legend.missing { border-color: var(--bad); }

.workflow-main {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 11px 13px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.panel-head span {
  color: var(--muted);
}

.source-card-grid,
.extract-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
}

.source-card,
.extract-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 10px;
}

.source-card span,
.extract-card dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.source-card strong,
.extract-card dd {
  display: block;
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.extract-card dl {
  display: grid;
  gap: 5px;
  margin: 8px 0;
}

.review-matrix-wrap {
  overflow-x: auto;
}

.review-matrix {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

.review-matrix th:nth-child(1) { width: 160px; }
.review-matrix th:nth-child(2) { width: 110px; }
.review-matrix th:nth-child(6) { width: 120px; }
.review-matrix th:nth-child(7) { width: 110px; }

.review-matrix small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.source-value {
  min-height: 28px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: left;
  cursor: default;
}

.source-highlight {
  border-radius: 2px;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  padding: 0 2px;
}

.pdf-value-stack {
  display: grid;
  gap: 4px;
  min-width: 0;
  align-items: start;
}

.pdf-value-crop {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(172px, 100%);
  min-height: 34px;
  max-height: 60px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #f7f9fb;
}

.pdf-value-crop span {
  padding: 4px 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.pdf-value-crop img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}

.pdf-value-crop[data-crop-state="ready"] {
  background: #fff;
}

.pdf-value-crop[data-crop-state="missing"],
.pdf-value-crop[data-crop-state="failed"] {
  border-style: dashed;
}

.pdf-value-text {
  display: inline-block;
  justify-self: start;
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.source-highlight.mismatch {
  background: #ffd8d6;
  box-shadow: inset 0 -2px 0 #d34f4f;
}

.source-highlight.attention {
  background: #fff1d6;
  box-shadow: inset 0 -2px 0 #d99b2b;
}

.source-highlight.missing {
  background: #fff1d6;
  color: var(--warn);
  box-shadow: inset 0 -2px 0 #e5bd7a;
}

.erp-keyin-metrics {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 12px;
}

.erp-keyin-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, auto) minmax(220px, .5fr);
  gap: 10px;
  align-items: end;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--line);
}

.erp-keyin-downloads,
.erp-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.erp-keyin-panel .small-action {
  min-height: 44px;
}

.erp-approval-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.erp-approval-form input[type="file"] {
  max-width: 100%;
}

.erp-execute-note {
  display: grid;
  gap: 2px;
  min-height: 44px;
  align-content: center;
  border-left: 4px solid var(--warn);
  padding-left: 8px;
  color: var(--muted);
}

.erp-execute-note strong {
  color: var(--warn);
}

.disabled-execute {
  min-width: 96px;
}

.erp-filter-bar {
  padding: 12px 12px 8px;
}

.erp-filter-bar .is-active {
  border-color: var(--brand);
  color: var(--brand);
  background: #eaf4f5;
}

.mobile-queue-open {
  display: none;
  margin: 0 12px 10px;
}

.erp-keyin-table {
  min-width: 1320px;
}

.erp-keyin-table th:nth-child(1) { width: 190px; }
.erp-keyin-table th:nth-child(2) { width: 180px; }
.erp-keyin-table th:nth-child(3) { width: 170px; }
.erp-keyin-table th:nth-child(4),
.erp-keyin-table th:nth-child(5) { width: 132px; }
.erp-keyin-table th:nth-child(6) { width: 130px; }
.erp-keyin-table th:nth-child(7) { width: 110px; }
.erp-keyin-table th:nth-child(8),
.erp-keyin-table th:nth-child(9) { width: 120px; }

.erp-keyin-table td {
  vertical-align: top;
  white-space: nowrap;
}

.erp-keyin-table strong,
.erp-keyin-table small {
  display: block;
}

.erp-keyin-table .mono {
  margin-top: 5px;
  font-size: 12px;
  overflow-wrap: normal;
  white-space: nowrap;
}

.erp-keyin-table small,
.erp-keyin-table .clamped-text {
  white-space: normal;
}

.erp-keyin-table .clamped-text {
  display: -webkit-box;
  max-height: 38px;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.erp-keyin-row[hidden] {
  display: none !important;
}

.evidence-modal {
  width: min(1120px, 100%);
}

.evidence-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, .8fr);
  gap: 12px;
}

.pdf-proof-viewer,
.evidence-inspector {
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.pdf-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-height: 46px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: #eef3f7;
}

.pdf-toolbar span {
  color: var(--muted);
  font-family: "JetBrains Mono", Consolas, monospace;
}

.pdf-canvas-stage {
  position: relative;
  min-height: 420px;
  overflow: auto;
  background: #e5eaf0;
  padding: 12px;
}

.evidence-overlay {
  position: absolute;
  inset: 12px;
  pointer-events: none;
}

.evidence-box {
  position: absolute;
  border: 2px solid var(--blue);
  background: rgba(40, 95, 159, .16);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .8);
}

.pdf-canvas-stage canvas {
  display: block;
  max-width: none;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 4px 18px rgba(23, 32, 51, .16);
}

.pdf-fallback-frame {
  display: block;
  width: 100%;
  min-height: 680px;
  border: 0;
  border-radius: 4px;
  background: #fff;
}

.pdf-status {
  position: absolute;
  inset: 12px;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  pointer-events: none;
}

.ocr-text {
  max-height: 280px;
  margin: 0;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
  background: #fff;
}

.evidence-inspector {
  padding: 12px;
}

.evidence-targets {
  display: grid;
  gap: 8px;
  margin: 10px 0;
}

.evidence-target-button {
  display: grid;
  justify-items: start;
  width: 100%;
  text-align: left;
}

.evidence-target-button[aria-pressed="true"] {
  border-color: var(--brand);
  background: #eaf4f5;
  color: var(--brand);
}

.evidence-target-button small {
  color: var(--muted);
  font-weight: 500;
}

.other-evidence {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px;
}

.other-evidence summary {
  cursor: pointer;
  font-weight: 750;
}

.other-evidence div {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 0;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.link-button:disabled {
  color: var(--muted);
  text-decoration: none;
}

.erp-stage-track {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.stage-chip {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  padding: 5px 8px;
  color: var(--muted);
  font-weight: 750;
}

.stage-chip.is-done {
  border-color: #9bc8ad;
  background: #f0faf3;
  color: var(--ok);
}

.erp-field-table {
  min-width: 760px;
}

.evidence-inspector dl {
  display: grid;
  gap: 8px;
}

.evidence-inspector dt {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.evidence-inspector dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

[hidden] { display: none !important; }

@media (max-width: 899px) {
  .shell { padding: 12px; }
  .topbar,
  .toolbar {
    display: grid;
    align-items: start;
  }
  .userbar { justify-content: flex-start; }
  .summary-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-grid { grid-template-columns: 1fr; }
  .erp-keyin-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .erp-keyin-toolbar { grid-template-columns: 1fr; }
}

@media (max-width: 599px) {
  .project-table,
  .project-table thead,
  .project-table tbody,
  .project-table tr,
  .project-table td {
    display: block;
    width: 100%;
  }

  .project-table thead { display: none; }

  .project-row {
    border-bottom: 1px solid var(--line);
    background: #fff;
    padding: 9px 10px;
  }

  .project-row td {
    display: none;
    border-bottom: 0;
    padding: 4px 0;
  }

  .project-row td:nth-child(1),
  .project-row td:nth-child(2),
  .project-row td:nth-child(3),
  .project-row td:nth-child(7),
  .project-row td:nth-child(9) {
    display: block;
  }

  .project-row td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    text-transform: uppercase;
  }

  .empty-row td { display: block; }
  .source-chip { grid-template-columns: 1fr; }
  .source-controls,
  .source-card-grid,
  .extract-card-grid,
  .workflow-grid,
  .evidence-layout {
    grid-template-columns: 1fr;
  }
  .step-pill {
    min-height: 44px;
  }
  .step-rail {
    display: none;
  }
  .review-matrix-wrap {
    overflow: visible;
  }
  .review-matrix,
  .review-matrix tbody,
  .review-matrix tr,
  .review-matrix td {
    display: block;
    width: 100%;
    min-width: 0;
  }
  .review-matrix {
    table-layout: auto;
  }
  .review-matrix thead {
    display: none;
  }
  .review-row {
    border-bottom: 1px solid var(--line);
    background: #fff;
    padding: 9px 10px;
  }
  .review-row td {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    border-bottom: 0;
    padding: 4px 0;
  }
  .review-row td[data-label]::before,
  .review-note-row td[data-label]::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 10px;
    font-weight: 750;
    line-height: 1.4;
    text-transform: uppercase;
  }
  .review-row td[data-label="PDF"] {
    grid-template-columns: 1fr;
    margin-bottom: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
  }
  .review-row td[data-label="PDF"]::before {
    display: none;
  }
  .source-value {
    display: inline-flex;
    min-height: 40px;
    align-items: center;
    width: 100%;
  }
  .review-status-form button {
    width: 100%;
  }
  .review-note-row {
    display: block;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
    padding: 8px 10px 10px;
  }
  .review-note-row td {
    display: none;
    border-bottom: 0;
    padding: 0;
    background: transparent;
  }
  .review-note-row td[data-label] {
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 8px;
  }
  .review-note-row strong {
    display: none;
  }
  .review-note-row span,
  .review-note-row small {
    display: block;
    margin-right: 0;
  }
  .erp-keyin-metrics {
    grid-template-columns: 1fr;
  }
  .erp-keyin-toolbar,
  .erp-approval-form {
    grid-template-columns: 1fr;
  }
  .erp-keyin-downloads,
  .erp-filter-bar {
    align-items: stretch;
  }
  .erp-keyin-downloads > *,
  .erp-filter-bar > * {
    flex: 1 1 140px;
  }
  .mobile-queue-open {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .erp-keyin-table-shell {
    overflow: auto;
    max-height: calc(100vh - 118px);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    scroll-margin-top: 8px;
  }
  .erp-keyin-table,
  .erp-keyin-table tbody,
  .erp-keyin-table tr,
  .erp-keyin-table td {
    display: revert;
    width: auto;
    min-width: initial;
  }
  .erp-keyin-table {
    display: table;
    min-width: 1120px;
    table-layout: fixed;
  }
  .erp-keyin-table thead {
    display: table-header-group;
  }
  .erp-keyin-table tbody {
    display: table-row-group;
  }
  .erp-keyin-table tr {
    display: table-row;
    padding: 0;
  }
  .erp-keyin-table td {
    display: table-cell;
    border-bottom: 1px solid var(--line);
    padding: 8px 9px;
  }
  .erp-keyin-table td[data-label]::before {
    display: none;
  }
  .evidence-modal {
    padding: 12px;
  }
  .pdf-toolbar .small-action {
    min-height: 40px;
  }
  .pdf-canvas-stage {
    min-height: 300px;
    max-height: 56vh;
    padding: 8px;
  }
  input[type="file"] { max-width: 100%; }
  .modal-actions { display: grid; }
  .summary-band { grid-template-columns: 1fr; }
}
