/* Historical Invoice Review — side-by-side source image + extraction workbench. */

.hi-drawer .el-drawer__header {
  margin-bottom: 0;
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--dp-border, #e5e7eb);
}

.hi-drawer .el-drawer__body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 12px 20px 16px;
}

.hi-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

.hi-drawer-header__title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.hi-drawer-header__position {
  font-size: 12px;
  font-weight: 400;
  color: #6b7280;
  white-space: nowrap;
}

.hi-drawer-header__nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.hi-detail {
  display: grid;
  grid-template-columns: minmax(0, 45fr) minmax(0, 55fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.hi-detail__image {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.hi-detail__fields {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
}

.hi-detail__fields .el-descriptions {
  margin-bottom: 12px;
}

/* Dense editable line table: tighter inputs, always-visible horizontal scrollbar as the narrow-screen fallback. */
.hi-lines-table .el-input--small .el-input__wrapper {
  padding: 1px 6px;
}

.hi-lines-table .el-input--small .el-input__inner {
  font-variant-numeric: tabular-nums;
}

.hi-lines-table .el-scrollbar__bar.is-horizontal {
  opacity: 1;
}

.hi-lines-table .cell {
  padding: 0 6px;
}

.hi-lines-hint {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 400;
  color: #6b7280;
}

/* Money / count inputs that cannot be parsed are outlined; saving stays blocked until fixed. */
.hi-lines-table .el-input.is-invalid .el-input__wrapper,
.hi-summary .el-input.is-invalid .el-input__wrapper {
  box-shadow: 0 0 0 1px #ef4444 inset;
}

.hi-line-check {
  margin-top: 2px;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hi-line-check--match {
  color: #15803d;
}

.hi-line-check--mismatch {
  color: #b91c1c;
  font-weight: 600;
}

.hi-line-check--unknown {
  display: none;
}

.hi-drawer-header__match {
  letter-spacing: 0.04em;
}

.hi-summary {
  margin-top: 14px;
  border-color: var(--dp-border, #e5e7eb);
}

.hi-summary .el-card__header {
  padding: 10px 14px;
  background: #f8fafc;
}

.hi-summary .el-card__body {
  padding: 12px 14px 10px;
}

.hi-summary__title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.hi-summary__subtitle {
  font-size: 12px;
  font-weight: 400;
  color: #6b7280;
}

.hi-summary__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 18px;
}

.hi-summary__block {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--dp-border, #e5e7eb);
  border-radius: 8px;
  background: #fff;
}

.hi-summary__heading {
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #374151;
  text-transform: uppercase;
}

.hi-summary__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 30px;
  font-size: 13px;
}

.hi-summary__label {
  flex: none;
  color: #6b7280;
}

.hi-summary__value {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  text-align: right;
}

.hi-summary__value .el-input,
.hi-summary__value .el-tag {
  flex: none;
}

/* Source-value rows stack label over input so the editable field never gets squeezed at 3-column widths. */
.hi-summary__row--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-height: 0;
  margin-bottom: 8px;
}

.hi-summary__row--stacked .hi-summary__value {
  justify-content: flex-start;
  flex-wrap: wrap;
  text-align: left;
}

.hi-summary__number {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: #111827;
}

.hi-summary__muted {
  font-weight: 400;
  font-size: 12px;
  color: #9ca3af;
}

.hi-summary__input {
  width: 150px;
}

.hi-summary__input--short {
  width: 90px;
}

.hi-summary__input .el-input__inner {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hi-summary__status {
  margin-left: auto;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.hi-summary__note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: #6b7280;
}

.hi-summary__note--alert {
  color: #b91c1c;
  font-variant-numeric: tabular-nums;
}

.hi-summary__warnings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.hi-summary__actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

@media (max-width: 1500px) {
  .hi-summary__grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.hi-viewer {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--dp-border, #e5e7eb);
  border-radius: 8px;
  background: #f8fafc;
  overflow: hidden;
}

.hi-viewer__toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--dp-border, #e5e7eb);
  background: #fff;
}

.hi-viewer__toolbar .el-button-group .el-button {
  min-width: 40px;
  font-variant-numeric: tabular-nums;
}

.hi-viewer__zoom {
  font-size: 12px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.hi-viewer__spacer {
  flex: 1;
}

.hi-viewer__stage {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 240px;
  overflow: auto;
  background:
    linear-gradient(45deg, #e9edf3 25%, transparent 25%, transparent 75%, #e9edf3 75%),
    linear-gradient(45deg, #e9edf3 25%, #f3f5f9 25%, #f3f5f9 75%, #e9edf3 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
  touch-action: none;
}

.hi-viewer__stage.is-pannable {
  cursor: grab;
}

.hi-viewer__stage.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.hi-viewer__frame {
  position: relative;
  flex: none;
  margin: auto;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
  background: #fff;
}

.hi-viewer__frame.is-hidden {
  visibility: hidden;
}

.hi-viewer__img {
  position: absolute;
  left: 50%;
  top: 50%;
  max-width: none;
  max-height: none;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  image-orientation: none;
}

.hi-viewer__loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: #6b7280;
  pointer-events: none;
}

.hi-viewer__missing {
  margin: auto;
  padding: 28px 24px;
  max-width: 92%;
  text-align: center;
  font-size: 13px;
  color: #6b7280;
  background: #fff;
  border: 1px dashed #d1d5db;
  border-radius: 8px;
}

.hi-viewer__missing-title {
  margin-bottom: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #b91c1c;
}

.hi-viewer__missing .el-button {
  margin-top: 12px;
}

.hi-viewer__path {
  margin: 4px 0 0;
  word-break: break-all;
  font-size: 12px;
}

.hi-viewer__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  padding: 6px 10px;
  border-top: 1px solid var(--dp-border, #e5e7eb);
  background: #fff;
  font-size: 12px;
  color: #6b7280;
}

.hi-viewer__meta-file {
  color: #111827;
  word-break: break-all;
}

.hi-viewer__sha summary {
  cursor: pointer;
  color: #2563eb;
  user-select: none;
}

.hi-viewer__sha code {
  display: block;
  margin-top: 4px;
  word-break: break-all;
  font-size: 11px;
  color: #374151;
}

.hi-conflict {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid #f59e0b;
  border-left-width: 4px;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
}

.hi-conflict__title {
  margin-bottom: 6px;
  font-weight: 600;
}

.hi-conflict__row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  line-height: 1.6;
}

.hi-conflict__label {
  flex: none;
  min-width: 72px;
  color: #b45309;
}

.hi-conflict__row code {
  word-break: break-all;
  font-size: 12.5px;
  color: #7c2d12;
  background: rgba(245, 158, 11, 0.12);
  padding: 0 4px;
  border-radius: 3px;
}

.hi-detail__notice {
  margin-bottom: 10px;
}

/* Customer link block: Buyer No. → matched master customer → match method. */
.hi-customer-link {
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid var(--dp-border, #e5e7eb);
  border-left-width: 4px;
  border-radius: 8px;
  background: #f8fafc;
  font-size: 13px;
}

.hi-customer-link--exact,
.hi-customer-link--manual {
  border-left-color: #16a34a;
}

.hi-customer-link--unknown_code {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.hi-customer-link--source_conflict,
.hi-customer-link--master_conflict {
  border-left-color: #dc2626;
  background: #fef2f2;
}

.hi-customer-link__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.hi-customer-link__label {
  font-size: 12px;
  color: #6b7280;
}

.hi-customer-link__code {
  padding: 1px 6px;
  border-radius: 4px;
  background: #e5e7eb;
  font-size: 12.5px;
  color: #111827;
}

.hi-customer-link__customer {
  color: #111827;
}

.hi-customer-link__status {
  margin-left: auto;
  letter-spacing: 0.04em;
}

.hi-customer-link__conflict,
.hi-customer-link__note {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.5;
  color: #6b7280;
}

.hi-customer-link__conflict {
  color: #b91c1c;
}

.hi-customer-link__conflict code,
.hi-customer-link__note code {
  padding: 0 4px;
  border-radius: 3px;
  background: rgba(15, 23, 42, 0.08);
}

.hi-detail__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.hi-detail__actions-note {
  font-size: 12px;
  color: #b45309;
}

/* Shown in place of the detail when a completion action finds no further invoice in the current filter. */
.hi-completion {
  grid-column: 1 / -1;
  align-self: center;
  justify-self: center;
  max-width: 560px;
  padding: 40px 32px;
  text-align: center;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
}

.hi-completion__icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #dcfce7;
  color: #15803d;
  font-size: 26px;
  line-height: 48px;
  font-weight: 700;
}

.hi-completion__title {
  font-size: 17px;
  font-weight: 600;
  color: #111827;
}

.hi-completion__text {
  margin: 8px 0 18px;
  font-size: 13px;
  line-height: 1.6;
  color: #6b7280;
}

.hi-completion__actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.hi-detail__hint {
  margin-top: 8px;
  font-size: 12px;
  color: #6b7280;
}

.hi-detail__hint kbd {
  padding: 0 4px;
  border: 1px solid #d1d5db;
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #f9fafb;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: #374151;
}

.hi-lightbox.el-dialog {
  background: #0f172a;
}

.hi-lightbox .el-dialog__header {
  padding: 10px 16px;
  margin-right: 0;
}

.hi-lightbox .el-dialog__title {
  color: #e5e7eb;
  font-size: 14px;
}

.hi-lightbox .el-dialog__headerbtn .el-dialog__close {
  color: #e5e7eb;
}

.hi-lightbox .el-dialog__body {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 54px);
  padding: 0 12px 12px;
}

.hi-lightbox .hi-viewer {
  border-color: #1f2937;
  background: #111827;
}

.hi-lightbox .hi-viewer__toolbar,
.hi-lightbox .hi-viewer__meta {
  background: #111827;
  border-color: #1f2937;
  color: #cbd5e1;
}

.hi-lightbox .hi-viewer__meta-file {
  color: #e5e7eb;
}

.hi-lightbox .hi-viewer__stage {
  background:
    linear-gradient(45deg, #1f2937 25%, transparent 25%, transparent 75%, #1f2937 75%),
    linear-gradient(45deg, #1f2937 25%, #172033 25%, #172033 75%, #1f2937 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

@media (max-width: 1200px) {
  .hi-detail {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    overflow-y: auto;
  }

  .hi-detail__image {
    height: 60vh;
  }

  .hi-detail__fields {
    overflow: visible;
    padding-right: 0;
  }
}

/* Manual evidence drop zones (v16). */
.hi-dropzones {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hi-dropzone {
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: border-color .15s, background .15s;
}

.hi-dropzone:hover {
  border-color: #2563eb;
  background: #eff6ff;
}

.hi-dropzone.is-disabled {
  opacity: .5;
  cursor: not-allowed;
}

.hi-dropzone__title {
  font-size: 13px;
  font-weight: 600;
  color: #1f2937;
  margin-bottom: 4px;
}

.hi-dropzone__hint {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.5;
}

/* Feishu preload pool block (round 12): pending pool files awaiting owner row assignment */
.hi-preload-pool { background: #fffbeb; border: 1px solid #fde68a; border-radius: 6px; padding: 8px 10px; margin: 8px 0; }
.hi-preload-pool .el-button { margin-left: auto; }

/* Historical sales list thumbnails (workbench closeout): 40px image previews + doc badges */
.hi-thumb { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border: 1px solid #e5e7eb; border-radius: 4px; cursor: pointer; overflow: hidden; background: #f9fafb; }
.hi-thumb:hover { border-color: #2563eb; }
.hi-thumb__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hi-thumb__doc { font-size: 11px; font-weight: 600; color: #374151; padding: 2px 4px; }
.hi-thumb__count { position: absolute; right: 0; bottom: 0; background: rgba(29,78,216,.88); color: #fff; font-size: 10px; line-height: 1; padding: 2px 4px; border-radius: 3px 0 0 0; }
