/* ============================================================
   OCR Scan-Invoice modal styles
   Every selector is prefixed with .ocr-modal so rules are
   scoped to the <div class="ocr-modal"> root in the template.
   Keyframe names are NOT prefixed (CSS @keyframes are global).
   ============================================================ */

/* ---- CSS custom properties (declared on the root element) ---- */
.ocr-modal {
  --line: #e3e6ea;
  --muted: #8a929c;
  --ink: #2b333d;
  --primary: #2f6fed;
  --warnbd: #ffd591;
  --warnbg: #fff7e6;
  --amber: #a86a00;
}

/* ---- Layout wrapper ---- */
.ocr-modal .modal-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(20,30,50,.14);
  overflow: hidden;
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
}

/* ---- Modal head ---- */
.ocr-modal .m-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.ocr-modal .m-head h4 {
  margin: 0;
  font-size: 17px;
  color: var(--ink);
  font-weight: 700;
}

.ocr-modal .m-x {
  color: var(--muted);
  font-size: 18px;
}

/* ---- Modal body ---- */
.ocr-modal .m-body {
  padding: 20px;
  color: var(--ink);
  max-height: 60vh;
  overflow: auto;
}

/* ---- Modal foot ---- */
.ocr-modal .m-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
}

.ocr-modal .foot-right {
  display: flex;
  gap: 10px;
}

/* ---- Buttons ---- */
.ocr-modal .btn {
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.ocr-modal .btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.ocr-modal .btn.link {
  border: none;
  background: none;
  color: var(--muted);
}

/* ---- Upload / dropzone ---- */
.ocr-modal .dropzone {
  border: 2px dashed #c4ccd6;
  border-radius: 10px;
  padding: 34px 20px;
  text-align: center;
  background: #fbfcfe;
}

.ocr-modal .dz-ic {
  font-size: 34px;
}

.ocr-modal .dz-main {
  font-weight: 700;
  margin: 10px 0 4px;
}

.ocr-modal .dz-sub {
  color: var(--muted);
  font-size: 12.5px;
}

.ocr-modal .chip {
  display: inline-block;
  background: #eef1f5;
  color: #525b66;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11.5px;
  margin: 2px;
}

/* Re-scan (force re-extract / bypass dedup) toggle under the dropzone. */
.ocr-modal .recheck {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
}

.ocr-modal .recheck input {
  margin: 0;
  cursor: pointer;
}

/* ---- Multi-file upload (one PDF xor up to 5 images) ---- */
.ocr-modal .ocr-mode-label {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 8px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.ocr-modal .ocr-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  flex-wrap: wrap;
}

.ocr-modal .ocr-file-row > span:first-child {
  flex: 1 1 auto;
  word-break: break-all;
}

/* full-width hint line under both the PDF row and the image grid */
.ocr-modal .ocr-file-row .dz-sub,
.ocr-modal .ocr-thumbs .dz-sub {
  flex: 1 0 100%;
}

.ocr-modal .ocr-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ocr-modal .ocr-thumb {
  position: relative;
  width: 96px;
  height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 11px;
  padding: 6px;
  overflow: hidden;
  word-break: break-all;
}

.ocr-modal .ocr-thumb-no {
  position: absolute;
  top: 4px;
  left: 6px;
  font-weight: 600;
  color: var(--ink);
}

/* filename inside an image thumb: clamp to 2 lines so it stays centered and
   never grows up into the corner page-number / remove (✕) badges */
.ocr-modal .ocr-thumb-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%;
  overflow: hidden;
  font-size: 10.5px;
  line-height: 1.25;
  word-break: break-all;
}

/* remove (✕): inline at the row's right edge, pinned to the corner inside a thumb */
.ocr-modal .ocr-x {
  cursor: pointer;
  color: var(--muted);
}

.ocr-modal .ocr-file-row .ocr-x {
  margin-left: auto;
}

.ocr-modal .ocr-thumb .ocr-x {
  position: absolute;
  top: 2px;
  right: 6px;
}

.ocr-modal .ocr-add {
  cursor: pointer;
  border-style: dashed;
  color: var(--primary);
  font-weight: 600;
}

/* ---- Processing (Phase B) ---- */
.ocr-modal .proc {
  text-align: center;
  padding: 14px 0 6px;
}

.ocr-modal .spinner {
  width: 42px;
  height: 42px;
  border: 4px solid #e6ebf2;
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.ocr-modal .msg-area {
  position: relative;
  height: 24px;
  margin-bottom: 6px;
}

.ocr-modal .msg {
  position: absolute;
  left: 0;
  right: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  opacity: 0;
}

.ocr-modal .msg.m1 { animation: msg1 6s infinite; }
.ocr-modal .msg.m2 { animation: msg2 6s infinite; }
.ocr-modal .msg.m3 { animation: msg3 6s infinite; }
.ocr-modal .msg.m4 { animation: msg4 6s infinite; }

@keyframes msg1 { 0%{opacity:1} 22%{opacity:1} 25%{opacity:0} 100%{opacity:0} }
@keyframes msg2 { 0%,25%{opacity:0} 28%{opacity:1} 47%{opacity:1} 50%{opacity:0} 100%{opacity:0} }
@keyframes msg3 { 0%,50%{opacity:0} 53%{opacity:1} 72%{opacity:1} 75%{opacity:0} 100%{opacity:0} }
@keyframes msg4 { 0%,75%{opacity:0} 78%{opacity:1} 100%{opacity:1} }

/* ---- Steps ---- */
.ocr-modal .steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 4px;
  flex-wrap: wrap;
}

.ocr-modal .step {
  font-size: 11.5px;
  padding: 6px 12px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  background: #eef1f5;
  color: #8a929c;
}

.ocr-modal .step .chk {
  margin-left: 6px;
  display: inline-block;
  opacity: 0;
  transform: scale(0);
}

.ocr-modal .step.s1 { animation: st1 6s infinite; }
.ocr-modal .step.s1 .chk { animation: ck1 6s infinite; }
.ocr-modal .step.s2 { animation: st2 6s infinite; }
.ocr-modal .step.s2 .chk { animation: ck2 6s infinite; }
.ocr-modal .step.s3 { animation: st3 6s infinite; }
.ocr-modal .step.s3 .chk { animation: ck3 6s infinite; }
.ocr-modal .step.s4 { animation: st4 6s infinite; }
.ocr-modal .step.s4 .chk { animation: ck4 6s infinite; }

@keyframes st1 { 0%{background:#e6efff;color:#2f6fed;transform:scale(1.06)} 22%{background:#e6efff;color:#2f6fed;transform:scale(1.06)} 25%{background:#e7f6ec;color:#1f8a4c;transform:scale(1)} 100%{background:#e7f6ec;color:#1f8a4c} }
@keyframes st2 { 0%,22%{background:#eef1f5;color:#8a929c} 25%{background:#e6efff;color:#2f6fed;transform:scale(1.06)} 47%{background:#e6efff;color:#2f6fed;transform:scale(1.06)} 50%{background:#e7f6ec;color:#1f8a4c;transform:scale(1)} 100%{background:#e7f6ec;color:#1f8a4c} }
@keyframes st3 { 0%,47%{background:#eef1f5;color:#8a929c} 50%{background:#e6efff;color:#2f6fed;transform:scale(1.06)} 72%{background:#e6efff;color:#2f6fed;transform:scale(1.06)} 75%{background:#e7f6ec;color:#1f8a4c;transform:scale(1)} 100%{background:#e7f6ec;color:#1f8a4c} }
@keyframes st4 { 0%,72%{background:#eef1f5;color:#8a929c} 75%{background:#e6efff;color:#2f6fed;transform:scale(1.06)} 97%{background:#e6efff;color:#2f6fed;transform:scale(1.06)} 100%{background:#e7f6ec;color:#1f8a4c;transform:scale(1)} }

@keyframes ck1 { 0%,22%{opacity:0;transform:scale(0)} 27%{opacity:1;transform:scale(1.4)} 32%,100%{opacity:1;transform:scale(1)} }
@keyframes ck2 { 0%,47%{opacity:0;transform:scale(0)} 52%{opacity:1;transform:scale(1.4)} 57%,100%{opacity:1;transform:scale(1)} }
@keyframes ck3 { 0%,72%{opacity:0;transform:scale(0)} 77%{opacity:1;transform:scale(1.4)} 82%,100%{opacity:1;transform:scale(1)} }
@keyframes ck4 { 0%,97%{opacity:0;transform:scale(0)} 99%{opacity:1;transform:scale(1.4)} 100%{opacity:1;transform:scale(1)} }

/* ---- Review header ---- */
.ocr-modal .rev-head {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.ocr-modal .vbadge {
  font-weight: 700;
}

.ocr-modal .lock {
  font-size: 11px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  margin-left: 6px;
}

.ocr-modal .conf {
  font-size: 11px;
  font-weight: 700;
  color: #1f8a4c;
  background: #e7f6ec;
  border-radius: 20px;
  padding: 2px 8px;
}

/* ---- Invoice fields ---- */
.ocr-modal .inv-fields {
  display: flex;
  gap: 16px;
  margin: 10px 0 16px;
  flex-wrap: wrap;
}

.ocr-modal .inv-fields label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 3px;
}

.ocr-modal .inv-fields input {
  border: 1px solid #b9c2cd;
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 13px;
  width: 180px;
}

/* ---- Lines table toolbar ---- */
.ocr-modal .lines-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 0 8px;
}

.ocr-modal .sec-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin: 6px 0 8px;
}

.ocr-modal .sec-note {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
}

.ocr-modal .count {
  font-size: 11.5px;
  color: var(--muted);
}

/* ---- Lines table ---- */
.ocr-modal table.lines {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.ocr-modal table.lines th {
  text-align: left;
  color: var(--muted);
  font-weight: 600;
  font-size: 11px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
}

.ocr-modal table.lines td {
  padding: 9px 9px;
  border-bottom: 1px solid #f0f2f5;
  color: var(--ink);
  vertical-align: top;
}

.ocr-modal .lockedcell {
  color: #6b7480;
}

.ocr-modal .lk {
  font-size: 9.5px;
  color: #aab2bd;
  margin-left: 3px;
}

.ocr-modal .qty-edit {
  border: 1.5px solid var(--primary);
  border-radius: 6px;
  padding: 5px 9px;
  width: 64px;
  font-size: 12.5px;
  background: #fff;
}

.ocr-modal .qty-hint {
  font-size: 11px;
  color: var(--primary);
  margin-top: 6px;
}

/* ---- Price delta warning ---- */
.ocr-modal .pricedelta {
  font-size: 10.5px;
  color: var(--amber);
  margin-top: 3px;
  line-height: 1.3;
}

.ocr-modal .pricedelta s {
  color: #b9a06a;
}

.ocr-modal .okmark {
  color: #1f8a4c;
  font-size: 12px;
}

/* ---- Dots ---- */
.ocr-modal .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}

.ocr-modal .dot.hi { background: #1f8a4c; }
.ocr-modal .dot.lo { background: #e0a500; }

/* ---- Pager ---- */
.ocr-modal .pager {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ocr-modal .pager .pg {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  font-size: 12.5px;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ocr-modal .pager .pg.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 700;
}

.ocr-modal .pager .pg.disabled {
  color: #c2c8d0;
}

.ocr-modal .pagesize {
  font-size: 11.5px;
  color: var(--muted);
}

.ocr-modal .pagesize select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 12px;
}

/* ---- Skip panel ---- */
.ocr-modal .skip-panel {
  margin-top: 18px;
  border: 1px solid var(--warnbd);
  background: var(--warnbg);
  border-radius: 8px;
  padding: 12px 14px;
}

.ocr-modal .skip-title {
  font-weight: 700;
  color: var(--amber);
  font-size: 13px;
  margin-bottom: 8px;
}

.ocr-modal .skip-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px dashed #f0dfba;
  color: #8a7a55;
}

.ocr-modal .skip-row:last-child {
  border-bottom: none;
}

.ocr-modal .skip-row .raw {
  text-decoration: line-through;
}

.ocr-modal .skip-tag {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--amber);
  border: 1px solid var(--warnbd);
  border-radius: 5px;
  padding: 1px 6px;
  background: #fff;
}

/* ---- "Can't be added" panel: contract-expired / frozen-contractless items ---- */
.ocr-modal .invalid-panel {
  margin-top: 18px;
  border: 1px solid #f0c7c2;
  background: #fdf3f2;
  border-radius: 8px;
  padding: 12px 14px;
}

.ocr-modal .invalid-title {
  font-weight: 700;
  color: #b3261e;
  font-size: 13px;
  margin-bottom: 4px;
}

.ocr-modal .invalid-note {
  font-size: 11.5px;
  color: #8a6a66;
  margin-bottom: 10px;
  line-height: 1.45;
}

.ocr-modal .invalid-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px dashed #f1d6d2;
}

.ocr-modal .invalid-row:last-child {
  border-bottom: none;
}

.ocr-modal .invalid-name {
  flex: 1 1 auto;
  color: #5b4b49;
  font-size: 12.5px;
}

.ocr-modal .invalid-meta {
  font-size: 11.5px;
  color: #9a8a87;
  white-space: nowrap;
}

.ocr-modal .invalid-tag {
  font-size: 10.5px;
  font-weight: 700;
  color: #b3261e;
  border: 1px solid #f0c7c2;
  border-radius: 5px;
  padding: 1px 6px;
  background: #fff;
  white-space: nowrap;
}

/* Fresh-mode manual item picker in the needs-attention panel. */
.ocr-modal .ocr-pick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ocr-modal .ocr-pick .btn {
  white-space: nowrap;
}

/* ---- Legend ---- */
.ocr-modal .legend {
  margin-top: 14px;
  background: #f6f8fb;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 11.5px;
  color: #5b6470;
}

.ocr-modal .legend b {
  color: var(--ink);
}

/* ---- Step state classes (used by ng-class in the real flow) ---- */
.ocr-modal .step.s-active { background:#e6efff; color:#2f6fed; font-weight:700; transform:scale(1.06); transition:all .25s; }
.ocr-modal .step.s-done { background:#e7f6ec; color:#1f8a4c; transition:all .25s; }
.ocr-modal .step.s-done .chk { display:inline-block; animation:ck1 .4s ease-out; margin-left:6px; }

.ocr-item-badge { display:inline-block; font-size:9px; font-weight:700; letter-spacing:.03em; color:#2f6fed; background:#e6efff; border:1px solid #cddaff; border-radius:4px; padding:1px 5px; margin-left:6px; vertical-align:middle; }

/* ============================================================
   OCR Scan-Invoice modal — v2 "Guided Steps + Refined Medallion"
   Everything here is scoped under .ocr-modal.ocr-scan-v2 so it
   NEVER affects the shared Review modal (which is .ocr-modal alone).
   Only ocrScan.html carries the .ocr-scan-v2 class.
   ============================================================ */
.ocr-modal.ocr-scan-v2 {
  --g-blue: #2f6fed;
  --g-ink: #2b333d;
  --g-muted: #8a929c;
  --g-line: #e3e6ea;
}

/* Card: reuse the shared chrome, just narrow it for the upload flow */
.ocr-modal.ocr-scan-v2 .modal-card {
  max-width: 552px;
  border: none;
  box-shadow: 0 12px 40px rgba(43, 51, 61, .14), 0 2px 6px rgba(43, 51, 61, .06);
}

/* ---- Header ---- */
.ocr-modal.ocr-scan-v2 .guided-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px 16px 24px;
}
.ocr-modal.ocr-scan-v2 .guided-title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--g-ink);
  letter-spacing: -.1px;
}
.ocr-modal.ocr-scan-v2 .guided-close {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--g-muted);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.ocr-modal.ocr-scan-v2 .guided-close:hover { background: #f1f3f6; color: var(--g-ink); }
.ocr-modal.ocr-scan-v2 .guided-close svg { display: block; }

/* ---- Stepper (1 Upload / 2 Review / 3 Apply) ---- */
.ocr-modal.ocr-scan-v2 .guided-steps {
  display: flex;
  align-items: center;
  padding: 2px 24px 22px;
}
.ocr-modal.ocr-scan-v2 .guided-step { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.ocr-modal.ocr-scan-v2 .guided-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border: 1.5px solid var(--g-line);
  color: var(--g-muted);
  background: #fff;
  flex: 0 0 auto;
}
.ocr-modal.ocr-scan-v2 .guided-step-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--g-muted);
  letter-spacing: .1px;
  white-space: nowrap;
}
.ocr-modal.ocr-scan-v2 .guided-step.is-active .guided-dot {
  border-color: var(--g-blue);
  background: var(--g-blue);
  color: #fff;
}
.ocr-modal.ocr-scan-v2 .guided-step.is-active .guided-step-label { color: var(--g-ink); font-weight: 600; }
.ocr-modal.ocr-scan-v2 .guided-connector {
  flex: 1 1 auto;
  height: 1.5px;
  background: var(--g-line);
  margin: 0 12px;
  border-radius: 2px;
}

/* ---- Body + Refined Medallion dropzone ---- */
.ocr-modal.ocr-scan-v2 .guided-body { padding: 0 24px; }
.ocr-modal.ocr-scan-v2 .guided-drop {
  position: relative;
  display: block;
  margin: 0;
  font-weight: 400;
  border: 1.5px dashed var(--g-line);
  border-radius: 12px;
  background: #fafbfc;
  padding: 30px 24px 22px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.ocr-modal.ocr-scan-v2 .guided-drop:hover { border-color: #c2d2f7; background: #f7f9fe; }
.ocr-modal.ocr-scan-v2 .guided-drop:hover .guided-medallion { box-shadow: 0 5px 16px rgba(47, 111, 237, .18); }
.ocr-modal.ocr-scan-v2 .guided-medallion {
  width: 38px;
  height: 38px;
  margin: 0 auto 13px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(47, 111, 237, .07);
  color: var(--g-blue);
  box-shadow: 0 2px 8px rgba(47, 111, 237, .10);
  transition: box-shadow .18s ease;
}
.ocr-modal.ocr-scan-v2 .guided-medallion svg { display: block; }
.ocr-modal.ocr-scan-v2 .guided-drop-main {
  font-size: 14px;
  font-weight: 500;
  color: var(--g-ink);
  margin: 0;
  letter-spacing: -.1px;
}
.ocr-modal.ocr-scan-v2 .guided-browse { color: var(--g-blue); font-weight: 600; text-decoration: none; cursor: pointer; }
.ocr-modal.ocr-scan-v2 .guided-drop:hover .guided-browse { text-decoration: underline; }
.ocr-modal.ocr-scan-v2 .guided-drop-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--g-muted);
  margin: 8px 0 0;
  line-height: 1.45;
  letter-spacing: .2px;
  opacity: .7;
}
/* full-cover, transparent file input: click-anywhere + drop both work */
.ocr-modal.ocr-scan-v2 .guided-scan-file {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* ---- Selected files: shared remove control ---- */
.ocr-modal.ocr-scan-v2 .guided-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--g-muted);
  cursor: pointer;
  flex: 0 0 auto;
  transition: background .15s ease, color .15s ease;
}
.ocr-modal.ocr-scan-v2 .guided-x:hover { background: #f1f3f6; color: var(--g-ink); }
.ocr-modal.ocr-scan-v2 .guided-x svg { display: block; }

/* ---- Selected files: PDF row ---- */
.ocr-modal.ocr-scan-v2 .guided-selected { padding-top: 2px; }
.ocr-modal.ocr-scan-v2 .guided-filerow {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid var(--g-line);
  border-radius: 10px;
  background: #fff;
}
.ocr-modal.ocr-scan-v2 .guided-filerow-ic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: rgba(47, 111, 237, .07);
  color: var(--g-blue);
  flex: 0 0 auto;
}
.ocr-modal.ocr-scan-v2 .guided-filerow-name {
  flex: 1 1 auto;
  font-size: 13px;
  color: var(--g-ink);
  word-break: break-all;
}

/* ---- Selected files: image thumbs ---- */
.ocr-modal.ocr-scan-v2 .guided-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.ocr-modal.ocr-scan-v2 .guided-thumb {
  position: relative;
  width: 92px;
  height: 92px;
  border: 1px solid var(--g-line);
  border-radius: 10px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  overflow: hidden;
}
.ocr-modal.ocr-scan-v2 .guided-thumb-no {
  position: absolute;
  top: 5px;
  left: 7px;
  font-size: 11px;
  font-weight: 600;
  color: var(--g-ink);
}
.ocr-modal.ocr-scan-v2 .guided-thumb-x {
  position: absolute;
  top: 3px;
  right: 4px;
  width: 20px;
  height: 20px;
}
.ocr-modal.ocr-scan-v2 .guided-thumb-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  max-width: 100%;
  overflow: hidden;
  font-size: 10.5px;
  line-height: 1.25;
  color: var(--g-muted);
  word-break: break-all;
}
.ocr-modal.ocr-scan-v2 .guided-thumb-add {
  flex-direction: column;
  gap: 2px;
  margin: 0;
  font-weight: 400;
  border-style: dashed;
  color: var(--g-blue);
  cursor: pointer;
}
.ocr-modal.ocr-scan-v2 .guided-thumb-add:hover { border-color: #c2d2f7; background: #f7f9fe; }
.ocr-modal.ocr-scan-v2 .guided-thumb-add-plus { font-size: 18px; line-height: 1; }
.ocr-modal.ocr-scan-v2 .guided-thumb-add-text { font-size: 12px; font-weight: 600; }

.ocr-modal.ocr-scan-v2 .guided-selected-hint {
  font-size: 11.5px;
  color: var(--g-muted);
  margin: 9px 0 0;
}
.ocr-modal.ocr-scan-v2 .guided-inline-alert {
  margin-top: 10px;
  padding: 8px 11px;
  border-radius: 8px;
  background: var(--warnbg);
  border: 1px solid var(--warnbd);
  color: var(--amber);
  font-size: 12px;
}

/* ---- Re-scan toggle (one calm line) ---- */
.ocr-modal.ocr-scan-v2 .guided-rescan {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 17px 24px 3px;
  font-weight: 400;
  cursor: pointer;
  user-select: none;
}
.ocr-modal.ocr-scan-v2 .guided-rescan-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.ocr-modal.ocr-scan-v2 .guided-switch {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: #d3d8de;
  flex: 0 0 auto;
  transition: background .15s ease;
}
.ocr-modal.ocr-scan-v2 .guided-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(43, 51, 61, .25);
  transition: transform .15s ease;
}
.ocr-modal.ocr-scan-v2 .guided-rescan:hover .guided-switch { background: #c6ccd3; }
.ocr-modal.ocr-scan-v2 .guided-rescan-input:checked + .guided-switch { background: var(--g-blue); }
.ocr-modal.ocr-scan-v2 .guided-rescan-input:checked + .guided-switch::after { transform: translateX(14px); }
.ocr-modal.ocr-scan-v2 .guided-rescan-input:focus-visible + .guided-switch { box-shadow: 0 0 0 3px rgba(47, 111, 237, .25); }
.ocr-modal.ocr-scan-v2 .guided-rescan-text { font-size: 13px; font-weight: 400; line-height: 1.4; color: var(--g-ink); }
.ocr-modal.ocr-scan-v2 .guided-rescan-sub { color: var(--g-muted); }

/* ---- Processing: spinner + status + animated step tracker ---- */
.ocr-modal.ocr-scan-v2 .guided-proc {
  text-align: center;
  padding: 14px 24px 8px;
}
.ocr-modal.ocr-scan-v2 .guided-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e6ebf2;
  border-top-color: var(--g-blue);
  border-radius: 50%;
  margin: 4px auto 16px;
  animation: ocrv2-spin 1s linear infinite;
}
@keyframes ocrv2-spin { to { transform: rotate(360deg); } }
.ocr-modal.ocr-scan-v2 .guided-proc-msg {
  font-size: 15px;
  font-weight: 600;
  color: var(--g-ink);
  margin-bottom: 18px;
  min-height: 20px;
}
/* Each rotated status message gently fades in. The controller flips msgTick on every
   change, toggling msg-fa / msg-fb. The two classes use DISTINCT keyframe names so the
   computed animation-name actually changes on each toggle — that is what forces the
   browser to replay the animation (identical names would not restart it). */
@keyframes ocrv2-msgfade-a { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
@keyframes ocrv2-msgfade-b { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: translateY(0); } }
.ocr-modal.ocr-scan-v2 .guided-proc-msg.msg-fa { animation: ocrv2-msgfade-a .45s ease; }
.ocr-modal.ocr-scan-v2 .guided-proc-msg.msg-fb { animation: ocrv2-msgfade-b .45s ease; }
.ocr-modal.ocr-scan-v2 .guided-track {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.ocr-modal.ocr-scan-v2 .guided-track-step {
  font-size: 11.5px;
  padding: 6px 12px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  background: #eef1f5;
  color: var(--g-muted);
  transition: background .25s ease, color .25s ease;
}
.ocr-modal.ocr-scan-v2 .guided-track-step.is-active {
  background: #e6efff;
  color: var(--g-blue);
  font-weight: 700;
}
.ocr-modal.ocr-scan-v2 .guided-track-step.is-done {
  background: #e7f6ec;
  color: #1f8a4c;
}
.ocr-modal.ocr-scan-v2 .guided-track-chk { margin-left: 6px; }

/* ---- Error ---- */
.ocr-modal.ocr-scan-v2 .guided-error-body { padding: 18px 24px 6px; }
.ocr-modal.ocr-scan-v2 .guided-error {
  padding: 12px 14px;
  border-radius: 8px;
  background: #fdecea;
  border: 1px solid #f5c6c2;
  color: #b3261e;
  font-size: 13px;
  line-height: 1.45;
}

/* ---- Success: ripple check animation (plays ONCE on read success, then the
   controller hands off to the review page). Ported from the approved ripple test;
   keyframes are KEY-prefixed and use animation-fill-mode:forwards so the final
   state persists for the brief hold before review opens. ---- */
.ocr-modal.ocr-scan-v2 .guided-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 30px 24px 36px;
}
.ocr-modal.ocr-scan-v2 .guided-success-stage {
  position: relative;
  width: 104px;
  height: 104px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ocr-modal.ocr-scan-v2 .guided-success-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 64px;
  height: 64px;
  margin: -32px 0 0 -32px;
  border-radius: 50%;
  border: 2px solid #1f8a4c;
  opacity: 0;
  transform: scale(.55);
  animation: ocrv2-rp-sonar 1.5s cubic-bezier(.22, .61, .36, 1) forwards;
}
.ocr-modal.ocr-scan-v2 .guided-success-ring.r2 { animation-delay: .16s; }
.ocr-modal.ocr-scan-v2 .guided-success-ring.r3 { animation-delay: .32s; }
.ocr-modal.ocr-scan-v2 .guided-success-circle {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #1f8a4c;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0);
  box-shadow: 0 6px 16px rgba(31, 138, 76, .28);
  animation: ocrv2-rp-pop .62s cubic-bezier(.34, 1.56, .64, 1) .1s forwards;
}
.ocr-modal.ocr-scan-v2 .guided-success-circle::before {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  background: #e7f6ec;
  z-index: -1;
  opacity: 0;
  animation: ocrv2-rp-halo .9s ease-out .1s forwards;
}
.ocr-modal.ocr-scan-v2 .guided-success-check {
  width: 34px;
  height: 34px;
  stroke: #fff;
  stroke-width: 3.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}
.ocr-modal.ocr-scan-v2 .guided-success-check path {
  stroke-dasharray: 30;
  stroke-dashoffset: 30;
  animation: ocrv2-rp-draw .45s ease-out .45s forwards;
}
.ocr-modal.ocr-scan-v2 .guided-success-line {
  margin-top: 18px;
  font-size: 18px;
  font-weight: 600;
  color: var(--g-ink);
  letter-spacing: -.01em;
  opacity: 0;
  transform: translateY(6px);
  animation: ocrv2-rp-textin .5s ease-out .55s forwards;
}
.ocr-modal.ocr-scan-v2 .guided-success-sub {
  margin-top: 4px;
  font-size: 13.5px;
  color: var(--g-muted);
  opacity: 0;
  transform: translateY(6px);
  animation: ocrv2-rp-textin .5s ease-out .65s forwards;
}
@keyframes ocrv2-rp-pop { 0% { transform: scale(0); opacity: 0; } 60% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
@keyframes ocrv2-rp-halo { 0% { opacity: 0; transform: scale(.7); } 60% { opacity: .9; transform: scale(1); } 100% { opacity: .5; transform: scale(1); } }
@keyframes ocrv2-rp-draw { to { stroke-dashoffset: 0; } }
@keyframes ocrv2-rp-sonar { 0% { opacity: 0; transform: scale(.55); } 30% { opacity: .5; transform: scale(.7); } 100% { opacity: 0; transform: scale(2); } }
@keyframes ocrv2-rp-textin { to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) {
  .ocr-modal.ocr-scan-v2 .guided-success-ring,
  .ocr-modal.ocr-scan-v2 .guided-success-circle,
  .ocr-modal.ocr-scan-v2 .guided-success-circle::before,
  .ocr-modal.ocr-scan-v2 .guided-success-check path,
  .ocr-modal.ocr-scan-v2 .guided-success-line,
  .ocr-modal.ocr-scan-v2 .guided-success-sub {
    animation: none;
    opacity: 1;
    transform: none;
    stroke-dashoffset: 0;
  }
  .ocr-modal.ocr-scan-v2 .guided-success-circle { transform: scale(1); }
}

/* ---- Footer ---- */
.ocr-modal.ocr-scan-v2 .guided-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 24px 22px;
  background: transparent;
  border-top: none;
}
.ocr-modal.ocr-scan-v2 .guided-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.ocr-modal.ocr-scan-v2 .guided-btn-cancel { background: #fff; border-color: var(--g-line); color: var(--g-ink); }
.ocr-modal.ocr-scan-v2 .guided-btn-cancel:hover { background: #f6f7f9; }
.ocr-modal.ocr-scan-v2 .guided-btn-primary {
  background: var(--g-blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(47, 111, 237, .3);
}
.ocr-modal.ocr-scan-v2 .guided-btn-primary:hover { background: #2a63d4; }
.ocr-modal.ocr-scan-v2 .guided-btn-primary[disabled],
.ocr-modal.ocr-scan-v2 .guided-btn-primary:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

/* Fresh OCR-first vendor confirmation picker (close-call / low-confidence). */
.ocr-modal .ocr-vendor-confirm-msg {
  margin-bottom: 6px;
}
.ocr-modal .ocr-vendor-confirm-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.ocr-modal .ocr-vendor-confirm-row .ocr-vendor-select {
  flex: 1 1 auto;
  max-width: 360px;
}

/* Upload-phase accuracy disclaimer (ocrScan) */
.ocr-modal.ocr-scan-v2 .guided-disclaimer {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  margin: 12px 0 0;
  padding: 9px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: #8a6d3b;
  background: #fcf8ef;
  border: 1px solid #f0e2c4;
  border-radius: 8px;
}
.ocr-modal.ocr-scan-v2 .guided-disclaimer-ic {
  flex: 0 0 auto;
  margin-top: 1px;
  color: #c9962a;
}

/* Per-page read progress (ocrScan processing phase) */
.ocr-modal.ocr-scan-v2 .guided-pageprog {
  width: 100%;
  max-width: 320px;
  margin: 14px auto 0;
}
.ocr-modal.ocr-scan-v2 .guided-pageprog-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--g-line);
  overflow: hidden;
}
.ocr-modal.ocr-scan-v2 .guided-pageprog-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--g-blue);
  transition: width .4s ease;
}
.ocr-modal.ocr-scan-v2 .guided-pageprog-label {
  margin-top: 6px;
  text-align: center;
  font-size: 11.5px;
  color: var(--g-muted);
}

/* Large-invoice heads-up (ocrScan processing phase) */
.ocr-modal.ocr-scan-v2 .guided-largehint {
  margin: 10px auto 0;
  max-width: 320px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.4;
  color: #8a6d3b;
}

/* ============================================================
   Review modal — a little larger, and a footer that always
   keeps "Apply to entry" visible no matter how many pages.
   (Scoped to the review modal via its ocr-modal-lg window class.)
   ============================================================ */
.ocr-modal-lg .modal-dialog {
  width: 1080px;
  max-width: 96vw;
}
.ocr-modal-lg .modal-card {
  max-width: none;   /* fill the wider dialog instead of capping at 960px */
}
.ocr-modal-lg .m-body {
  max-height: 68vh;  /* a few more rows visible before scrolling */
}

/* Compact pager: the ellipsis chip is a non-clickable spacer, not a button. */
.ocr-modal .pager .pg.gap {
  border: none;
  background: transparent;
  min-width: 14px;
  padding: 0 2px;
  color: var(--muted);
  cursor: default;
}
/* Never let the pager push the action buttons out of view: the pager wraps,
   and the Apply/Cancel cluster holds its size and stays pinned to the right. */
.ocr-modal .m-foot { flex-wrap: wrap; }
.ocr-modal .pager { flex-wrap: wrap; min-width: 0; }
.ocr-modal .foot-right { flex-shrink: 0; margin-left: auto; }

/* ============================================================
   Review items table — per-item match-confidence indicator,
   with low-confidence rows highlighted for "review first".
   ============================================================ */
.ocr-modal .matchcell { white-space: nowrap; }
.ocr-modal .matchpill {
  display: inline-block;
  min-width: 44px;
  text-align: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.55;
}
.ocr-modal .matchpill.mp-high   { background: #e6f6ec; color: #1e7a44; }
.ocr-modal .matchpill.mp-medium { background: #fff3e0; color: #a8650a; }
.ocr-modal .matchpill.mp-low    { background: #fde7e7; color: #c0392b; }
.ocr-modal .matchpill.mp-na     { background: #eef0f2; color: #8a929c; }

/* Highlight weak matches so they stand out in the (A→Z) list. */
.ocr-modal .lines tr.ocr-match-low td { background: #fff6f6; }
.ocr-modal .lines tr.ocr-match-low td:first-child { box-shadow: inset 3px 0 0 #e05252; }
