/* ==========================================================================
   Escaneo de facturas y boletas en "Registrar compra" (2026-11-26)
   ========================================================================== */
.scn { display: block; }
.scn-card {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 16px; align-items: center;
  padding: 16px; border-radius: var(--radius); isolation: isolate; overflow: hidden;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(241, 101, 34, .16), transparent 55%),
    linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid rgba(241, 101, 34, .38);
  box-shadow: 0 10px 30px -18px rgba(241, 101, 34, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
  animation: scnIn .45s var(--ease) both;
}
.scn-card::after { /* trama fina, como papel de calco */
  content: ''; position: absolute; inset: 0; z-index: -1; opacity: .35; pointer-events: none;
  background-image: linear-gradient(rgba(255, 255, 255, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 18px 18px; mask-image: linear-gradient(90deg, #000, transparent 70%);
}
@keyframes scnIn { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }
.scn-copy { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.scn-copy b { font-family: var(--display); font-size: 21px; font-weight: 700; letter-spacing: .01em; line-height: 1.1; }
.scn-copy small { font-size: 13.5px; color: var(--text-2); line-height: 1.35; }
.scn-copy small svg { width: 13px; height: 13px; vertical-align: -2px; color: var(--accent); }
.scn-acts { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; }
.scn-acts .btn { flex: 1 1 150px; }
.scn-acts.sm { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; }
.scn-acts.sm .btn { min-width: 0; white-space: nowrap; }
.scn-acts.sm .scn-x { width: 46px; padding: 0; }

/* --- reposo: ilustracion de una hoja que se escanea --- */
.scn-art { position: relative; width: 74px; height: 88px; display: grid; place-items: center; }
.scn-sheet {
  position: absolute; inset: 4px 10px; border-radius: 6px; background: #F4F1EA; transform: rotate(-5deg);
  box-shadow: 0 10px 20px -8px rgba(0, 0, 0, .6); display: flex; flex-direction: column; gap: 6px; padding: 12px 8px;
}
.scn-sheet i { display: block; height: 4px; border-radius: 2px; background: #C9C3B6; }
.scn-sheet i:nth-child(1) { width: 60%; background: #9B9486; }
.scn-sheet i:nth-child(3) { width: 80%; }
.scn-sheet i:nth-child(4) { width: 45%; margin-left: auto; background: var(--accent); opacity: .8; }
.scn-ray {
  position: absolute; left: 2px; right: 2px; height: 3px; top: 8px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, var(--accent) 20%, #FFC9A8 50%, var(--accent) 80%, transparent);
  box-shadow: 0 0 14px 3px rgba(241, 101, 34, .55); animation: scnRay 2.6s var(--ease) infinite;
}
@keyframes scnRay { 0%, 8% { top: 8px; opacity: 0; } 15% { opacity: 1; } 55% { top: 78px; opacity: 1; } 65%, 100% { top: 78px; opacity: 0; } }
.scn-art > svg { position: absolute; right: -2px; top: -4px; width: 22px; height: 22px; color: #FFC9A8; filter: drop-shadow(0 0 6px rgba(241, 101, 34, .8)); animation: scnTwinkle 2.6s ease-in-out infinite; }
@keyframes scnTwinkle { 50% { transform: scale(.7) rotate(20deg); opacity: .6; } }
.scn-or { display: flex; align-items: center; gap: 12px; margin: 4px 0 -2px; color: var(--muted); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; }
.scn-or::before, .scn-or::after { content: ''; flex: 1; height: 1px; background: var(--line-soft); }

/* --- miniaturas --- */
.scn-tiles { display: flex; gap: 8px; }
.scn-tile {
  position: relative; width: 58px; height: 74px; border-radius: 8px; overflow: hidden; flex: none; display: grid; place-items: center;
  background: #F4F1EA; border: 1px solid rgba(255, 255, 255, .14); box-shadow: 0 8px 16px -10px #000;
  animation: scnTile .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes scnTile { from { opacity: 0; transform: translateY(6px) rotate(-3deg); } to { opacity: 1; transform: none; } }
.scn-tile img { width: 100%; height: 100%; object-fit: cover; }
.scn-tile.pdf { background: var(--bg-deep); color: var(--accent); align-content: center; gap: 4px; padding: 6px; }
.scn-tile.pdf svg { width: 24px; height: 24px; }
.scn-tile.pdf small { font-size: 9.5px; color: var(--silver); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scn-tile.add { background: transparent; border: 1.5px dashed var(--line); color: var(--silver); cursor: pointer; gap: 2px; align-content: center; font: inherit; }
.scn-tile.add svg { width: 20px; height: 20px; }
.scn-tile.add small { font-size: 10px; }
.scn-tile.add:hover, .scn-tile.add:focus-visible { border-color: var(--accent); color: var(--accent); }

/* --- leyendo: haz de luz sobre el documento --- */
.scn-stage { position: relative; display: flex; gap: 8px; padding: 6px; }
.scn-tile.big { width: 76px; height: 98px; filter: saturate(.85); }
.scn-beam {
  position: absolute; left: 0; right: 0; top: 0; height: 30px; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(241, 101, 34, .28) 70%, rgba(255, 201, 168, .95) 96%, transparent);
  border-bottom: 2px solid #FFC9A8; box-shadow: 0 6px 18px rgba(241, 101, 34, .65);
  animation: scnBeam 1.6s cubic-bezier(.45, 0, .55, 1) infinite alternate;
}
@keyframes scnBeam { from { transform: translateY(-14px); } to { transform: translateY(96px); } }
.scn-corners i { position: absolute; width: 12px; height: 12px; border: 2px solid var(--accent); }
.scn-corners i:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 4px 0 0 0; }
.scn-corners i:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 4px 0 0; }
.scn-corners i:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 4px; }
.scn-corners i:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 4px 0; }
.scn-step.in { animation: scnStep .35s var(--ease) both; }
@keyframes scnStep { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.scn-progress { position: relative; display: block; height: 3px; border-radius: 3px; background: rgba(255, 255, 255, .08); overflow: hidden; margin-top: 8px; }
.scn-progress i { position: absolute; top: 0; bottom: 0; width: 38%; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--accent), transparent); animation: scnProg 1.25s ease-in-out infinite; }
@keyframes scnProg { from { left: -40%; } to { left: 100%; } }

/* --- resultado --- */
.scn-done { grid-template-columns: minmax(0, 1fr); gap: 10px; }
.scn-done-h { display: flex; gap: 12px; align-items: flex-start; }
.scn-badge { flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); animation: ckPop .45s var(--ease) both; }
.scn-badge svg { width: 22px; height: 22px; }
.scn-done.k-ok { border-color: rgba(52, 211, 153, .45); box-shadow: 0 10px 30px -18px rgba(52, 211, 153, .5); background: radial-gradient(120% 140% at 0% 0%, rgba(52, 211, 153, .13), transparent 55%), linear-gradient(180deg, var(--surface-2), var(--surface)); }
.scn-done.k-warn { border-color: rgba(251, 191, 36, .5); background: radial-gradient(120% 140% at 0% 0%, rgba(251, 191, 36, .13), transparent 55%), linear-gradient(180deg, var(--surface-2), var(--surface)); }
.scn-done.k-warn .scn-badge { background: rgba(251, 191, 36, .14); color: var(--warn); }
.scn-done.k-bad { border-color: rgba(248, 113, 113, .5); background: radial-gradient(120% 140% at 0% 0%, rgba(248, 113, 113, .13), transparent 55%), linear-gradient(180deg, var(--surface-2), var(--surface)); }
.scn-done.k-bad .scn-badge { background: var(--bad-soft); color: var(--bad); }
.scn-pill { justify-self: start; display: inline-flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 600; background: rgba(255, 255, 255, .06); color: var(--text-2); }
.scn-pill svg { width: 15px; height: 15px; flex: none; }
.scn-pill.ok { background: var(--ok-soft); color: var(--ok); }
.scn-pill.warn { background: rgba(251, 191, 36, .14); color: var(--warn); }
.scn-warns { margin: 0; padding: 0 0 0 18px; display: grid; gap: 4px; font-size: 13px; color: var(--text-2); }
.scn-warns li::marker { color: var(--warn); }
.scn-dup { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--bad-soft); color: #FFD4D4; font-size: 13.5px; font-weight: 600; }
.scn-dup svg { width: 18px; height: 18px; flex: none; color: var(--bad); }
.scn-dup span { flex: 1; }

/* --- lo que vino del documento, marcado en el formulario --- */
.pf input.ai, .pf-chosen.ai {
  border-color: rgba(241, 101, 34, .55);
  background-image: linear-gradient(90deg, rgba(241, 101, 34, .10), rgba(241, 101, 34, 0) 70%);
}
.pf-chosen.ai { box-shadow: inset 3px 0 0 var(--accent); }
.pf-ai { display: flex; gap: 6px; align-items: flex-start; margin-top: 5px; font-size: 12px; line-height: 1.3; color: var(--silver); }
.pf-ai svg { width: 13px; height: 13px; flex: none; margin-top: 1px; color: var(--accent); }
.pf-ai span { overflow-wrap: anywhere; }
.pf-ai.check { color: var(--warn); }
.pf-ai.check svg { color: var(--warn); }
.scn-fill .pf-line { animation: scnRow .5s var(--ease) both; }
.scn-fill .pf-line:nth-child(2) { animation-delay: .06s; } .scn-fill .pf-line:nth-child(3) { animation-delay: .12s; }
.scn-fill .pf-line:nth-child(4) { animation-delay: .18s; } .scn-fill .pf-line:nth-child(5) { animation-delay: .24s; }
.scn-fill .pf-line:nth-child(6) { animation-delay: .30s; } .scn-fill .pf-line:nth-child(7) { animation-delay: .36s; }
.scn-fill .pf-line:nth-child(n+8) { animation-delay: .42s; }
@keyframes scnRow { 0% { opacity: 0; transform: translateY(8px); box-shadow: 0 0 0 0 rgba(241, 101, 34, 0); } 45% { opacity: 1; transform: none; box-shadow: 0 0 0 3px rgba(241, 101, 34, .5); } 100% { box-shadow: 0 0 0 0 rgba(241, 101, 34, 0); } }

/* --- ficha de la compra: documento adjunto --- */
.scn-files { display: flex; gap: 10px; flex-wrap: wrap; }
.scn-file { width: 96px; height: 124px; border-radius: 10px; overflow: hidden; padding: 0; border: 1px solid var(--line); background: #F4F1EA; cursor: zoom-in; }
.scn-file img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scn-file.pdf { width: auto; height: auto; min-height: 48px; display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface-2); color: var(--text); text-decoration: none; cursor: pointer; }
.scn-file.pdf svg { width: 20px; height: 20px; color: var(--accent); }

@media (max-width: 520px) {
  .scn-card { grid-template-columns: 1fr; padding: 14px; }
  .scn-idle { grid-template-columns: 58px minmax(0, 1fr); }
  .scn-idle .scn-art { width: 58px; height: 70px; }
  .scn-copy b { font-size: 19px; }
}
@media (prefers-reduced-motion: reduce) {
  .scn-card, .scn-tile, .scn-ray, .scn-art > svg, .scn-beam, .scn-progress i, .scn-step.in, .scn-fill .pf-line, .scn-badge { animation: none !important; }
  .scn-beam { transform: translateY(40px); }
}

/* --- revision 2 (arbitro): dudas por linea, preparando, etiquetas --- */
.pf input.chk { border-color: rgba(251, 191, 36, .75); box-shadow: 0 0 0 3px rgba(251, 191, 36, .14); background-image: linear-gradient(90deg, rgba(251, 191, 36, .12), rgba(251, 191, 36, 0) 70%); }
.pf-ai b { display: block; margin-top: 2px; font-weight: 600; color: var(--warn); }
.scn-spin { width: 34px; height: 34px; border-radius: 50%; border: 3px solid rgba(241, 101, 34, .25); border-top-color: var(--accent); animation: spin .8s linear infinite; }
.scn-done.k-ok .scn-badge svg[data-i="doc"] { color: var(--ok); }
@media (prefers-reduced-motion: reduce) { .scn-spin { animation: none !important; } }
