/* Recibir por marca (dueno-recibir-marca.js) */
.drm-capa { position: fixed; inset: 0; z-index: 9470; display: none; flex-direction: column; background: #eef2f7; color: #0f172a; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
.drm-capa.abierta { display: flex; }
.drm-tope { position: sticky; top: 0; z-index: 3; background: #eef2f7; }
.drm-cabeza { display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 14px 10px; background: #eef2f7; }
.drm-cabeza h2 { margin: 0; font-size: 19px; }
.drm-atras { padding: 10px 16px; border: 0; border-radius: 999px; background: #fff !important; color: #1d5fd1 !important; font-weight: 800; box-shadow: 0 2px 8px rgba(15, 23, 42, .08); }
.drm-marcas { display: flex; gap: 8px; padding: 4px 14px 12px; overflow-x: auto; background: #eef2f7; scrollbar-width: none; }
.drm-marcas::-webkit-scrollbar { display: none; }
.drm-marca { flex: none; display: grid; gap: 1px; justify-items: start; min-width: 104px; width: auto; padding: 10px 14px; border: 2px solid transparent; border-radius: 16px; background: var(--marca) !important; color: #fff !important; text-align: left; opacity: .62; }
.drm-marca b { font-size: 15px; }
.drm-marca small { font-size: 11.5px; opacity: .92; }
.drm-marca.activa { opacity: 1; border-color: #fff; box-shadow: 0 0 0 3px var(--marca), 0 6px 14px rgba(15, 23, 42, .22); }
.drm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 4px 14px calc(120px + env(safe-area-inset-bottom)); }
.drm-tarjeta { display: grid; gap: 5px; align-content: start; justify-items: center; padding: 10px 8px; border: 1px solid #cbd5e1; border-radius: 16px; background: #fff; text-align: center; }
.drm-tarjeta.con-entrada { border: 2px solid #18b88f; background: #ecfdf3; }
.drm-foto { display: grid; place-items: center; width: 100%; aspect-ratio: 1; border-radius: 12px; background: #f1f5f9; overflow: hidden; }
.drm-foto img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.drm-nombre { font-size: 12.5px; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.4em; }
.drm-hay { padding: 2px 10px; border-radius: 999px; background: #e2e8f0; color: #334155; font-size: 12.5px; font-weight: 800; }
.drm-hay.poco { background: #fee2e2; color: #b91c1c; }
.drm-cantidad { display: grid; grid-template-columns: 38px minmax(0, 1fr) 38px; gap: 4px; width: 100%; }
.drm-cantidad button { height: 40px; border: 0; border-radius: 10px; background: #e2e8f0 !important; color: #0f172a !important; font-size: 22px; font-weight: 800; }
.drm-cantidad input { width: 100%; min-width: 0; height: 40px; border: 2px solid #cbd5e1; border-radius: 10px; text-align: center; font-size: 18px; font-weight: 800; background: #fff; color: #0f172a; }
.drm-atajos { display: flex; gap: 4px; width: 100%; }
.drm-atajos button { flex: 1; padding: 6px 0; border: 0; border-radius: 8px; background: #dbeafe !important; color: #1d4ed8 !important; font-size: 12px; font-weight: 800; }
.drm-pie { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #cbd5e1; box-shadow: 0 -8px 24px rgba(15, 23, 42, .1); font-size: 14px; }
.drm-confirmar { padding: 14px 22px; border: 0; border-radius: 14px; background: #18b88f !important; color: #04223f !important; font-size: 16px; font-weight: 800; }
.drm-confirmar:disabled { opacity: .45; }
body.drm-abierta { overflow: hidden; }
:root.oscuro .drm-capa, :root.oscuro .drm-tope, :root.oscuro .drm-cabeza, :root.oscuro .drm-marcas { background: #0b1220; color: #f1f5f9; }
:root.oscuro .drm-atras { background: #1e293b !important; color: #93c5fd !important; }
:root.oscuro .drm-tarjeta { background: #1e293b; border-color: #475569; }
:root.oscuro .drm-tarjeta.con-entrada { background: #064e3b; border-color: #18b88f; }
:root.oscuro .drm-foto { background: #0f172a; }
:root.oscuro .drm-hay { background: #334155; color: #e2e8f0; }
:root.oscuro .drm-hay.poco { background: #7f1d1d; color: #fee2e2; }
:root.oscuro .drm-cantidad input { background: #0f172a; color: #f1f5f9; border-color: #475569; }
:root.oscuro .drm-cantidad button { background: #334155 !important; color: #f1f5f9 !important; }
:root.oscuro .drm-pie { background: #0f172a; border-color: #334155; color: #f1f5f9; }
@media (min-width: 768px) { .drm-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); padding-left: 28px; padding-right: 28px; } .drm-marcas, .drm-cabeza { padding-left: 28px; } }
@media (min-width: 560px) { .drm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
#drmBoton { grid-column: 1 / -1; }
.drm-logo { position: relative; display: block; width: 100%; height: 48px; margin-bottom: 6px; border-radius: 10px; background: #fff; overflow: hidden; }
.drm-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.drm-marca:has(.drm-logo) { width: 168px; min-width: 168px; }

/* Buscador + escaner arriba */
.drm-buscar { display: flex; gap: 8px; padding: 2px 14px 10px; }
.drm-buscar input { flex: 1; min-width: 0; height: 46px; padding: 0 16px; border: 2px solid #cbd5e1; border-radius: 14px; background: #fff; color: #0f172a; font-size: 16px; }
.drm-buscar input:focus { outline: 0; border-color: #1d5fd1; box-shadow: 0 0 0 4px rgba(29, 95, 209, .15); }
.drm-escanear { flex: none; display: flex; align-items: center; gap: 6px; height: 46px; padding: 0 14px; border: 0; border-radius: 14px; background: #1d5fd1 !important; color: #fff !important; font-weight: 800; font-size: 14px; }
.drm-escanear svg { width: 22px; height: 22px; }
.drm-vacio { grid-column: 1 / -1; padding: 24px 8px; text-align: center; color: #64748b; font-weight: 700; }

/* Pie: el total se toca y abre el resumen */
.drm-resumen-abrir { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border: 0; background: transparent !important; color: inherit !important; font: inherit; text-align: left; }
.drm-resumen-abrir:disabled { opacity: .6; }
.drm-flecha { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: #dbeafe; color: #1d4ed8; font-size: 15px; }
.drm-resumen-abrir:disabled .drm-flecha { background: #e2e8f0; color: #94a3b8; }

/* Resumen a pantalla completa */
.drm-resumen { position: fixed; inset: 0; z-index: 9480; display: flex; flex-direction: column; background: #eef2f7; color: #0f172a; animation: drmSube .2s ease; }
@keyframes drmSube { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.drm-res-cabeza { display: flex; align-items: center; gap: 12px; padding: calc(12px + env(safe-area-inset-top)) 14px 10px; }
.drm-res-cabeza h2 { margin: 0; font-size: 19px; }
.drm-res-bajar { padding: 10px 16px; border: 0; border-radius: 999px; background: #fff !important; color: #1d5fd1 !important; font-weight: 800; box-shadow: 0 2px 8px rgba(15, 23, 42, .08); }
.drm-res-cuerpo { flex: 1; overflow-y: auto; padding: 4px 14px calc(110px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
.drm-res-marca { display: flex; align-items: baseline; justify-content: space-between; margin: 14px 0 8px; padding: 8px 12px; border-radius: 12px; background: var(--marca) !important; color: #fff; font-size: 15px; }
.drm-res-marca small { font-size: 12px; opacity: .92; }
.drm-res-lista { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.drm-res-fila { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 14px; background: #fff; }
.drm-res-foto { width: 52px; height: 52px; border-radius: 10px; background: #f1f5f9; overflow: hidden; }
.drm-res-foto img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.drm-res-texto { display: grid; gap: 2px; min-width: 0; }
.drm-res-texto b { font-size: 13.5px; line-height: 1.2; overflow-wrap: anywhere; }
.drm-res-texto small { color: #047857; font-weight: 800; font-size: 12.5px; }
.drm-res-cant { display: grid; grid-template-columns: 34px 46px 34px; gap: 4px; }
.drm-res-cant button { height: 38px; border: 0; border-radius: 10px; background: #e2e8f0 !important; color: #0f172a !important; font-size: 20px; font-weight: 800; }
.drm-res-cant input { width: 100%; height: 38px; border: 2px solid #cbd5e1; border-radius: 10px; text-align: center; font-size: 16px; font-weight: 800; background: #fff; color: #0f172a; }
.drm-res-pie { z-index: 1; }
body.drm-con-resumen { overflow: hidden; }

/* Tarjetita corta al escanear */
.drm-aviso { position: fixed; left: 12px; right: 12px; top: calc(14px + env(safe-area-inset-top)); z-index: 9800; display: none; align-items: center; gap: 12px; max-width: 520px; margin: 0 auto; padding: 10px 14px 10px 10px; border-radius: 16px; border-left: 6px solid #18b88f; background: #fff; color: #0f172a; box-shadow: 0 14px 34px rgba(5, 42, 99, .3); }
.drm-aviso.visible { display: flex; }
.drm-aviso.error { border-left-color: #dc2626; }
.drm-aviso-foto { flex: none; width: 52px; height: 52px; border-radius: 12px; background: #f1f5f9; overflow: hidden; }
.drm-aviso-foto:empty { display: none; }
.drm-aviso-foto img { width: 100%; height: 100%; object-fit: contain; }
.drm-aviso-texto { flex: 1; min-width: 0; display: grid; }
.drm-aviso-texto b { font-size: 15px; line-height: 1.2; }
.drm-aviso-texto small { color: #64748b; font-size: 12.5px; }
.drm-aviso-n { flex: none; padding: 6px 12px; border-radius: 999px; background: #18b88f; color: #04223f; font-weight: 800; font-size: 16px; }

:root.oscuro .drm-buscar input { background: #1e293b; border-color: #475569; color: #f1f5f9; }
:root.oscuro .drm-flecha { background: #1e3a8a; color: #bfdbfe; }
:root.oscuro .drm-resumen { background: #0b1220; color: #f1f5f9; }
:root.oscuro .drm-res-bajar { background: #1e293b !important; color: #93c5fd !important; }
:root.oscuro .drm-res-fila { background: #1e293b; border-color: #475569; }
:root.oscuro .drm-res-foto { background: #0f172a; }
:root.oscuro .drm-res-texto small { color: #6ee7b7; }
:root.oscuro .drm-res-cant button { background: #334155 !important; color: #f1f5f9 !important; }
:root.oscuro .drm-res-cant input { background: #0f172a; color: #f1f5f9; border-color: #475569; }
:root.oscuro .drm-aviso { background: #1e293b; color: #f1f5f9; }
@media (min-width: 768px) { .drm-res-cuerpo { padding-left: 28px; padding-right: 28px; max-width: 900px; width: 100%; margin: 0 auto; box-sizing: border-box; } .drm-buscar { padding-left: 28px; padding-right: 28px; } }

/* Lineas dentro de la marca (Doritos, Cheetos, Bolzaza... / Aguas, Fanta...) */
.drm-lineas { display: flex; gap: 6px; padding: 0 14px 10px; overflow-x: auto; scrollbar-width: none; }
.drm-lineas:empty { display: none; }
.drm-lineas::-webkit-scrollbar { display: none; }
.drm-linea { flex: none; display: flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid #cbd5e1; border-radius: 999px; background: #fff !important; color: #334155 !important; font-size: 14px; font-weight: 800; }
.drm-linea small { padding: 1px 7px; border-radius: 999px; background: #e2e8f0; color: #475569; font-size: 12px; }
.drm-linea.activa { background: #0f172a !important; border-color: #0f172a; color: #fff !important; }
.drm-linea.activa small { background: rgba(255, 255, 255, .22); color: #fff; }
:root.oscuro .drm-linea { background: #1e293b !important; border-color: #475569; color: #e2e8f0 !important; }
:root.oscuro .drm-linea small { background: #334155; color: #cbd5e1; }
:root.oscuro .drm-linea.activa { background: #f1f5f9 !important; color: #0f172a !important; }
@media (min-width: 768px) { .drm-lineas { padding-left: 28px; padding-right: 28px; } }

/* Facturas por recibir (Recepcion inteligente) y proveedor al recibir a mano */
.drm-facturas:empty { display: none; }
.drm-facturas { padding: 0 14px 8px; }
.drm-facturas-lista { display: flex; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.drm-facturas-lista::-webkit-scrollbar { display: none; }
.drm-facturas-lista > span { flex: none; font-size: 12.5px; font-weight: 800; color: #475569; }
.drm-factura-chip { flex: none; display: grid; gap: 1px; justify-items: start; padding: 8px 14px; border: 2px solid #0f766e; border-radius: 14px; background: #ecfdf5 !important; color: #064e3b !important; text-align: left; }
.drm-factura-chip b { font-size: 14px; }
.drm-factura-chip small { font-size: 11.5px; opacity: .85; }
.drm-factura-banner { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; padding: 10px 12px; border: 2px solid #0f766e; border-radius: 16px; background: #ecfdf5; color: #064e3b; }
.drm-factura-banner > div { display: grid; min-width: 0; }
.drm-factura-banner b { font-size: 15px; overflow-wrap: anywhere; }
.drm-factura-banner small { font-size: 12px; opacity: .85; }
.drm-factura-todo { padding: 9px 14px; border: 0; border-radius: 12px; background: #0f766e !important; color: #fff !important; font-weight: 800; font-size: 13px; }
.drm-factura-salir { padding: 9px 12px; border: 1px solid #94a3b8; border-radius: 12px; background: #fff !important; color: #334155 !important; font-weight: 700; font-size: 13px; }
.drm-factura-aviso { grid-column: 1 / -1; margin: 0; padding: 8px 10px; border-radius: 10px; background: #fef3c7; color: #92400e; font-size: 12.5px; font-weight: 700; }
.drm-factura-aviso button { padding: 0; border: 0; background: transparent !important; color: #1d5fd1 !important; font-weight: 800; text-decoration: underline; }
.drm-capa.drm-modo-factura .drm-marcas { display: none; }
.drm-esperado { padding: 2px 10px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; font-size: 12.5px; font-weight: 800; }
.drm-esperado.dif { background: #fef3c7; color: #92400e; }
.drm-llego { flex: 1; padding: 8px 0 !important; background: #d1fae5 !important; color: #065f46 !important; font-size: 13px !important; }

.drm-hoja-fondo { position: fixed; inset: 0; z-index: 9900; display: flex; align-items: flex-end; justify-content: center; background: rgba(15, 23, 42, .55); }
.drm-hoja { width: min(560px, 100%); max-height: 80vh; display: flex; flex-direction: column; gap: 10px; padding: 18px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 22px 22px 0 0; background: #fff; color: #0f172a; box-shadow: 0 -12px 34px rgba(0, 0, 0, .3); }
.drm-hoja h3 { margin: 0; font-size: 18px; }
.drm-hoja p { margin: 0; color: #475569; font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.drm-hoja-lista { display: grid; gap: 8px; overflow-y: auto; }
.drm-hoja-lista button { padding: 14px; border: 1px solid #cbd5e1; border-radius: 14px; background: #f8fafc !important; color: #0f172a !important; font-weight: 800; font-size: 15px; text-align: left; }
.drm-hoja-sin { padding: 13px; border: 0; border-radius: 14px; background: #e2e8f0 !important; color: #334155 !important; font-weight: 800; }
.drm-hoja-cancelar { padding: 11px; border: 0; background: transparent !important; color: #64748b !important; font-weight: 700; }
:root.oscuro .drm-factura-chip, :root.oscuro .drm-factura-banner { background: #064e3b !important; border-color: #10b981; color: #d1fae5 !important; }
:root.oscuro .drm-facturas-lista > span { color: #94a3b8; }
:root.oscuro .drm-esperado { background: #1e3a8a; color: #bfdbfe; }
:root.oscuro .drm-hoja { background: #0f172a; color: #f1f5f9; }
:root.oscuro .drm-hoja p { color: #94a3b8; }
:root.oscuro .drm-hoja-lista button { background: #1e293b !important; border-color: #475569; color: #f1f5f9 !important; }

/* Facturas por recibir: boton de esquina en la cabeza (antes una franja que ocupaba espacio) y chips de tipo de producto */
.drm-fact-lugar { margin-left: auto; display: flex; }
.drm-fact-lugar:empty { display: none; }
.drm-fact-btn { display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 12px; border: 2px solid #0f766e; border-radius: 999px; background: #ecfdf5 !important; color: #064e3b !important; font-size: 17px; }
.drm-fact-btn b { min-width: 22px; padding: 2px 7px; border-radius: 999px; background: #0f766e; color: #fff; font-size: 13px; text-align: center; }
.drm-hoja-lista button small { display: block; margin-top: 2px; color: #64748b; font-size: 12.5px; font-weight: 600; }
.drm-tipos { padding-top: 2px; }
.drm-tipos .drm-linea { border-color: #94a3b8; font-weight: 800; }
.drm-tipos .drm-linea.activa { background: #0f172a !important; color: #fff !important; border-color: #0f172a; }
:root.oscuro .drm-fact-btn { background: #064e3b !important; border-color: #10b981; color: #d1fae5 !important; }

/* Mientras se busca: las lineas de la marca se esconden y las tarjetas de marca que coinciden quedan a color */
.drm-capa.drm-buscando .drm-lineas { display: none; }

/* Entrada suave al abrir (antes aparecia de golpe) */
.drm-capa.abierta { animation: drmEntra .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes drmEntra { from { transform: translateY(28px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .drm-capa.abierta { animation: none; } }

/* Fluidez: lo que esta fuera de pantalla no se dibuja, y mientras carga se ve un esqueleto */
.drm-tarjeta { content-visibility: auto; contain-intrinsic-size: auto 250px; }
.drm-esq { gap: 10px; pointer-events: none; }
.drm-esq-foto { width: 100%; aspect-ratio: 1; border-radius: 12px; }
.drm-esq-linea { width: 80%; height: 12px; border-radius: 6px; }
.drm-esq-linea.corta { width: 50%; }
.drm-esq-fila { padding: 0 14px 12px; }
.drm-esq-bloque { display: block; height: 46px; border-radius: 14px; }
.drm-esq-foto, .drm-esq-linea, .drm-esq-bloque { background: linear-gradient(100deg, #e2e8f0 30%, #f1f5f9 50%, #e2e8f0 70%); background-size: 200% 100%; animation: drmBrillo 1.2s linear infinite; }
:root.oscuro .drm-esq-foto, :root.oscuro .drm-esq-linea, :root.oscuro .drm-esq-bloque { background: linear-gradient(100deg, #1e293b 30%, #334155 50%, #1e293b 70%); background-size: 200% 100%; }
@keyframes drmBrillo { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .drm-esq-foto, .drm-esq-linea, .drm-esq-bloque { animation: none; } }
