/* ==========================================================
   SISTEMA DE ETIQUETAS — Sistema de diseño
   Rediseño 2026-08-05. Las reglas @media print del final son
   INTOCABLES: main.js inyecta sobre ellas los tamaños exactos.
   ========================================================== */

:root {
  /* Marca */
  --primary-color: #6366F1;
  --primary-hover: #4F46E5;
  --accent-color: #38BDF8;
  --accent-hover: #0EA5E9;
  --success-color: #10B981;
  --success-hover: #059669;
  --warning-color: #F59E0B;
  --warning-hover: #D97706;
  --danger-color: #EF4444;
  --danger-hover: #DC2626;

  /* Superficies */
  --bg-color: #0B1120;
  --surface-1: #111B2E;
  --surface-2: #16233A;
  --surface-3: #1E2E4A;
  --card-bg: #131F35;
  /* Alias: main.js genera el diálogo de selección de Odoo usando estos
     nombres. Nunca estuvieron definidos → el popup salía transparente. */
  --bg-card: #16233A;
  --bg-main: #111B2E;
  --border-color: rgba(148, 163, 184, 0.16);
  --border-strong: rgba(148, 163, 184, 0.30);

  /* Texto */
  --text-main: #F1F5F9;
  --text-color: #F1F5F9;
  --text-muted: #94A3B8;
  --text-dim: #64748B;

  /* Escalas */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --sp-1: 0.25rem;
  --sp-2: 0.5rem;
  --sp-3: 0.75rem;
  --sp-4: 1rem;
  --sp-5: 1.5rem;
  --sp-6: 2rem;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, 0.5);
  --ring: 0 0 0 3px rgba(56, 189, 248, 0.28);

  --t-fast: 0.14s cubic-bezier(0.4, 0, 0.2, 1);
  --t-med: 0.24s cubic-bezier(0.4, 0, 0.2, 1);

  /* Valores por defecto para etiquetas */
  --label-width: 5cm;
  --label-height: 6.5cm;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  /* La app nunca se arrastra de lado. `clip` recorta sin crear contexto de
     scroll, así que —a diferencia de `hidden`— NO rompe position: sticky. */
  overflow-x: clip;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeSpeed;
}

/* Fondo decorativo en capa propia: no repinta al hacer scroll
   (background-attachment:fixed destruye el rendimiento en móvil). */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 12% 0%, rgba(99, 102, 241, 0.20), transparent 60%),
    radial-gradient(ellipse 60% 50% at 92% 12%, rgba(56, 189, 248, 0.14), transparent 60%);
}

::selection { background: rgba(99, 102, 241, 0.4); }

/* Scrollbars discretas */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-thumb:hover { background: #2C4062; background-clip: padding-box; }

/* ==========================================================
   LAYOUT
   ========================================================== */

.admin-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--sp-5) var(--sp-5) var(--sp-6);
}

.glass-header {
  background: linear-gradient(180deg, rgba(22, 35, 58, 0.96), rgba(19, 31, 53, 0.96));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--r-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
  box-shadow: var(--shadow-md);
  position: sticky;
  top: var(--sp-3);
  z-index: 50;
}

.glass-header h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5ch;
  white-space: nowrap;
}

.glass-header h1 span {
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.controls {
  display: flex;
  gap: var(--sp-3);
  align-items: center;
  flex-wrap: wrap;
}

.input-group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.65rem;
  border-radius: var(--r-sm);
}

.input-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

.input-group input[type="number"] {
  background: transparent;
  border: none;
  padding: 0.25rem 0;
  width: 62px;
  font-weight: 600;
}
.input-group input[type="number"]:focus { box-shadow: none; }

.input-group input[type="checkbox"] {
  accent-color: var(--accent-color);
  width: 17px;
  height: 17px;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(360px, 5fr) minmax(0, 7fr);
  gap: var(--sp-5);
  align-items: start;
}

/* Un grid item nace con min-width:auto y NO puede encogerse por debajo del
   ancho mínimo de su contenido: eso desbordaba la app en el celular. */
.dashboard > * { min-width: 0; }

.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  box-shadow: var(--shadow-md);
}

.form-section { position: sticky; top: 6.5rem; min-width: 0; }

/* min-width:0 permite que la tabla haga scroll propio
   en vez de estirar la columna de la rejilla. */
.list-section { min-width: 0; }

.glass-card h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: var(--sp-4);
}

.glass-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* ==========================================================
   CONTROLES DE FORMULARIO
   ========================================================== */

input[type="number"],
input[type="text"],
input[type="password"],
select,
textarea {
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.65rem 0.85rem;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  width: 100%;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  -webkit-appearance: none;
  appearance: none;
}

textarea { resize: vertical; min-height: 76px; line-height: 1.5; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394A3B8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}
select option { background: var(--surface-2); color: var(--text-main); }

input::placeholder, textarea::placeholder { color: var(--text-dim); }

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-color);
  box-shadow: var(--ring);
  background: var(--surface-2);
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-color);
  cursor: pointer;
  flex: 0 0 auto;
}

/* Campo con etiqueta */
.form-row {
  display: flex;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
  flex-wrap: wrap;
}

.form-group {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0;
}

.form-group label,
.field-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

/* Casilla en línea (etiqueta pequeña) */
.check-inline {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.75rem;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  user-select: none;
}
.check-inline:hover { border-color: var(--border-strong); background: var(--surface-2); }
.check-inline label,
.check-inline span {
  font-size: 0.9rem;
  color: var(--text-main);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  cursor: pointer;
  margin: 0;
}

/* ==========================================================
   BOTONES
   ========================================================== */

button {
  cursor: pointer;
  padding: 0.65rem 1.15rem;
  border-radius: var(--r-sm);
  border: none;
  font-weight: 600;
  font-size: 0.92rem;
  font-family: inherit;
  color: var(--text-main);
  transition: background var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast), opacity var(--t-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5ch;
  line-height: 1.2;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }

button:active { transform: translateY(1px) scale(0.995); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35); }

.btn-secondary { background: var(--surface-2); color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-strong); }

.btn-success { background: var(--success-color); color: #fff; width: 100%; padding: 0.85rem 1.2rem; }
.btn-success:hover { background: var(--success-hover); box-shadow: 0 4px 14px rgba(16, 185, 129, 0.32); }

.btn-warning { background: var(--warning-color); color: #1A1206; width: 100%; padding: 0.85rem 1.2rem; }
.btn-warning:hover { background: var(--warning-hover); }

.btn-danger { background: var(--danger-color); color: #fff; padding: 0.55rem 1rem; }
.btn-danger:hover { background: var(--danger-hover); }

/* Botón fantasma para acciones destructivas secundarias */
.btn-ghost-danger {
  background: rgba(239, 68, 68, 0.10);
  color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, 0.30);
  padding: 0.55rem 1rem;
}
.btn-ghost-danger:hover { background: rgba(239, 68, 68, 0.20); color: #FEE2E2; }

.action-btn {
  background: transparent;
  padding: 0.3rem 0.4rem;
  border: none;
  font-size: 1.05rem;
  border-radius: 6px;
}
.action-btn:hover { background: rgba(255, 255, 255, 0.10); }

.delete-btn { background: transparent; color: var(--danger-color); padding: 0.3rem 0.5rem; }
.delete-btn:hover { background: rgba(239, 68, 68, 0.14); }

/* Lupa de consulta al catálogo */
.btn-search-remote {
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--r-sm);
  flex: 0 0 42px;
  width: 42px;
  padding: 0;
  font-size: 0.95rem;
}
.btn-search-remote:hover { background: var(--accent-color); border-color: var(--accent-color); color: #06283D; }

/* Cámara que lee un número largo y lo escribe en el código.
   Nada que ver con el escáner de códigos de barras (Validar). */
.btn-ocr-codigo {
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  border-radius: var(--r-sm);
  flex: 0 0 40px;
  width: 40px;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-height: 40px;
}
.btn-ocr-codigo:hover { background: var(--accent-color); border-color: var(--accent-color); color: #06283D; }
.btn-ocr-codigo:active { transform: scale(0.94); }

.ocr-capa {
  position: fixed;
  inset: 0;
  z-index: 100003;
  background: #05080F;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.ocr-barra {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.ocr-titulo { font-weight: 800; font-size: 0.95rem; color: #E2E8F0; }
.ocr-x {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  color: #E2E8F0;
  border-radius: 10px;
  width: 38px; height: 38px;
  font-size: 1rem; cursor: pointer;
}
.ocr-escena { flex: 1 1 auto; position: relative; overflow: hidden; min-height: 0; }
.ocr-video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  background: #000;
  transform-origin: center center;
  will-change: transform;
}

/* Acercamiento: del aparato si lo tiene, si no ampliando la imagen */
.ocr-zoom {
  position: absolute;
  right: 10px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(3, 7, 18, 0.72);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 99px;
  padding: 0.25rem 0.35rem;
  z-index: 4;
}
.ocr-zbtn {
  background: rgba(255,255,255,0.10);
  border: none;
  color: #E2E8F0;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}
.ocr-zbtn:active { background: var(--accent-color); color: #06283D; }
.ocr-znivel {
  min-width: 3.1rem;
  text-align: center;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: #BAE6FD;
}
.ocr-motor { color: #7DD3FC; font-weight: 700; }
.ocr-aviso-foto {
  text-align: center;
  font-size: 0.72rem;
  color: #64748B;
  margin-top: -0.25rem;
}

/* Semáforo de nitidez: dice si la imagen está quieta antes de disparar */
.ocr-nitidez {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-size: 0.8rem;
  color: #94A3B8;
}
.ocr-nluz {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: #475569;
  flex: 0 0 auto;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.ocr-nluz.mala { background: #F87171; box-shadow: 0 0 8px rgba(248,113,113,0.6); }
.ocr-nluz.regular { background: #FCD34D; box-shadow: 0 0 8px rgba(252,211,77,0.6); }
.ocr-nluz.buena { background: #34D399; box-shadow: 0 0 10px rgba(52,211,153,0.7); }
/* El velo oscurece TODO menos la ventana del marco */
.ocr-velo {
  position: absolute; inset: 0;
  background: rgba(3, 7, 18, 0.62);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  padding: calc(50% - 52px) 7%;
  pointer-events: none;
}
.ocr-marco {
  position: absolute;
  left: 7%; right: 7%;
  top: 50%;
  height: 104px;
  transform: translateY(-50%);
  border: 2px solid var(--accent-color);
  border-radius: 10px;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.5), 0 0 22px rgba(56,189,248,0.35);
  pointer-events: none;
}
.ocr-marco::after {
  content: '';
  position: absolute;
  left: 8px; right: 8px; top: 50%;
  height: 1px;
  background: rgba(56,189,248,0.55);
}
.ocr-pie {
  flex: 0 0 auto;
  padding: 0.9rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.ocr-estado {
  text-align: center;
  color: #94A3B8;
  font-size: 0.88rem;
  line-height: 1.45;
  min-height: 1.3rem;
}
.ocr-estado.mal { color: #FCA5A5; }
.ocr-estado.bien { color: #6EE7B7; }
.ocr-numero {
  display: block;
  font-family: 'Roboto Mono', monospace;
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #E2E8F0;
}
.ocr-pista { display: block; font-size: 0.76rem; color: #94A3B8; margin-top: 2px; }
.ocr-acciones { display: flex; gap: 0.5rem; justify-content: center; margin-top: 0.7rem; flex-wrap: wrap; }
.ocr-botones { display: flex; gap: 0.6rem; align-items: center; justify-content: center; }
.ocr-btn {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: #E2E8F0;
  border-radius: 10px;
  padding: 0.55rem 1rem;
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}
.ocr-btn.ocr-usar { background: var(--success-color); border-color: var(--success-color); color: #052e1c; }
.ocr-btn.activo { background: var(--accent-color); border-color: var(--accent-color); color: #06283D; }
.ocr-disparar {
  background: var(--accent-color);
  border: none;
  color: #06283D;
  border-radius: 99px;
  padding: 0.8rem 2.2rem;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(56,189,248,0.35);
}
.ocr-disparar:disabled { opacity: 0.55; cursor: default; }

/* ==========================================================
   PESTAÑAS
   ========================================================== */

.tabs,
.form-toggle-tabs {
  display: flex;
  gap: 0.35rem;
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  padding: 0.3rem;
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar,
.form-toggle-tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  cursor: pointer;
  border-radius: var(--r-sm);
  font-weight: 600;
  white-space: nowrap;
  flex: 1 1 auto;
  transition: background var(--t-fast), color var(--t-fast);
}
.tab-btn:hover { color: var(--text-main); background: var(--surface-2); }

.tab-btn.active {
  background: linear-gradient(135deg, var(--primary-color), #7C7DF5);
  color: #fff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}
.tab-btn.active:hover { color: #fff; }

.tab-btn .count {
  display: inline-block;
  min-width: 1.35em;
  padding: 0 0.35em;
  margin-left: 0.35ch;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.78em;
  font-weight: 700;
  line-height: 1.5;
}

/* ==========================================================
   PANELES DEL FORMULARIO
   Los paneles se muestran/ocultan por JS con style.display.
   Aquí solo definimos su disposición interna.
   ========================================================== */

#validate-form,
#admin-data-form,
#availability-form {
  flex-direction: column;
  gap: var(--sp-4);
}

.panel-box {
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}

.barcodes-section { margin: var(--sp-4) 0; }
.barcodes-section > label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin-bottom: 0.45rem;
}

#barcode-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.barcode-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.barcode-row .barcode-input { flex: 2; min-width: 0; }
.barcode-row .barcode-val-input { flex: 1; min-width: 0; }

/* Cantidad de la parte: NO entra en el código de barras, solo multiplica
   el valor y se imprime como "CODIGO x N". */
.barcode-row .barcode-qty-input {
  flex: 0 0 58px;
  width: 58px;
  min-width: 0;
  padding-left: 0.5rem;
  padding-right: 0.35rem;
  text-align: center;
  font-weight: 700;
  -moz-appearance: textfield;
  appearance: textfield;
}
.barcode-row .barcode-qty-input::-webkit-outer-spin-button,
.barcode-row .barcode-qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
@media (max-width: 420px) {
  .barcode-row .barcode-qty-input { flex: 0 0 50px; width: 50px; }
}

/* Bloque plegable de datos opcionales */
details {
  margin: var(--sp-4) 0;
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  background: var(--surface-1);
  overflow: hidden;
  transition: border-color var(--t-fast);
}
details[open] { border-color: var(--border-strong); }
details > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.8rem var(--sp-4);
  outline: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5ch;
  color: var(--text-muted);
  transition: color var(--t-fast), background var(--t-fast);
}
details > summary:hover { color: var(--text-main); background: var(--surface-2); }
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: '▸';
  display: inline-block;
  transition: transform var(--t-fast);
  font-size: 0.8em;
}
details[open] > summary::before { transform: rotate(90deg); }
.details-body {
  padding: 0 var(--sp-4) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}

/* Cajas de foto */
.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
}
.photo-upload-box {
  position: relative;
  width: 100%;
  height: 104px;
  background: var(--surface-2);
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.photo-upload-box:hover { border-color: var(--accent-color); background: var(--surface-3); }
.photo-upload-box input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 10;
}
.photo-upload-box .preview-slot { pointer-events: none; text-align: center; }

.form-actions { margin-top: var(--sp-4); }

/* Entrada de escaneo destacada */
.scan-input {
  padding: 1rem !important;
  font-size: 1.05rem !important;
  border: 2px solid var(--accent-color) !important;
  background: var(--surface-2) !important;
  letter-spacing: 0.02em;
}

/* Barra de búsqueda con botón */
.search-bar {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}
.search-bar input { flex: 1; min-width: 0; }
.search-bar button { width: auto; flex: 0 0 auto; padding: 0 1.2rem; }

/* Resultados de disponibilidad / validación */
.results-scroll {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  max-height: 420px;
  overflow-y: auto;
  padding-right: 2px;
}

.result-block {
  background: var(--surface-1);
  padding: var(--sp-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border-color);
}

.result-media {
  text-align: center;
  margin-bottom: var(--sp-3);
}
.result-media img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--r-sm);
  object-fit: contain;
}

.result-title {
  margin-bottom: var(--sp-3);
  color: var(--accent-color);
  font-size: 1.02rem;
  font-weight: 700;
  line-height: 1.35;
}

/* Código validado: se toca y se copia al portapapeles */
.code-copy {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  margin: 0 0 var(--sp-3);
  padding: 0.6rem 0.8rem;
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  color: var(--text-main);
  font-family: 'Roboto Mono', monospace;
  font-size: 1.02rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.code-copy:hover { background: var(--surface-3); border-color: var(--accent-color); }
.code-copy .code-copy-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.code-copy .code-copy-icon { flex: 0 0 auto; font-size: 0.95rem; opacity: 0.75; }
.code-copy.copiado {
  background: rgba(16, 185, 129, 0.16);
  border-color: var(--success-color);
  border-style: solid;
  color: #6EE7B7;
}
.code-copy.fallo {
  background: rgba(245, 158, 11, 0.16);
  border-color: var(--warning-color);
  border-style: solid;
  color: #FCD34D;
}
.code-copy.copiado .code-copy-icon,
.code-copy.fallo .code-copy-icon { opacity: 1; }

.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  font-size: 0.92rem;
}
.result-grid strong { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; display: block; margin-bottom: 0.15rem; }

.result-highlight {
  grid-column: 1 / -1;
  background: var(--surface-3);
  padding: 0.75rem;
  border-radius: var(--r-sm);
  text-align: center;
  font-size: 1.02rem;
}
.result-highlight span { font-weight: 800; color: var(--accent-color); }

/* Listas de administración (categorías / ubicaciones) */
.admin-list {
  margin-top: var(--sp-3);
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.admin-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  border-radius: var(--r-sm);
  padding: 0.55rem 0.75rem;
  font-size: 0.92rem;
}

/* ==========================================================
   LISTA / TABLAS
   ========================================================== */

.list-header {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}

.list-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.list-header-top h2 { margin: 0; }

.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  background: var(--surface-1);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

th, td {
  padding: 0.7rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

tbody tr { transition: background var(--t-fast); }
tbody tr:hover { background: rgba(56, 189, 248, 0.05); }
tbody tr:last-child td { border-bottom: none; }

td { font-size: 0.9rem; vertical-align: middle; }

/* Estado vacío */
.empty-state {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--text-dim);
  font-size: 0.92rem;
}

/* ==========================================================
   MODALES
   ========================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 16, 0.72);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: overlay-in var(--t-fast) ease-out;
}

.modal-content {
  max-width: 420px;
  width: 100%;
  padding: var(--sp-5);
  border-radius: var(--r-lg);
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  animation: modal-in var(--t-med) cubic-bezier(0.16, 1, 0.3, 1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h3 { color: var(--accent-color); margin-top: 0; margin-bottom: var(--sp-3); font-size: 1.05rem; }
.modal-content p { color: var(--text-muted); font-size: 0.93rem; }
.modal-content label { font-size: 0.85rem; color: var(--text-muted); display: block; margin-bottom: 0.4rem; }

.modal-field { margin: var(--sp-4) 0; }
.modal-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-4); }
.modal-actions button { flex: 1; padding: 0.8rem; }

@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: none; } }

/* ==========================================================
   LOGIN
   ========================================================== */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: var(--sp-4);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: var(--sp-6) var(--sp-5);
  text-align: center;
}

.login-container h2 {
  margin-bottom: 0.35rem;
  font-weight: 800;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.login-sub {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-bottom: var(--sp-5);
}

.login-container form { display: flex; flex-direction: column; gap: var(--sp-3); text-align: left; }
.login-container input { padding: 0.85rem; font-size: 16px; }
.login-container button { margin-top: var(--sp-2); padding: 0.9rem; font-size: 1rem; }

.login-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #FCA5A5;
  padding: 0.7rem 0.9rem;
  border-radius: var(--r-sm);
  margin-bottom: var(--sp-4);
  font-size: 0.88rem;
}

/* ==========================================================
   APP MÓVIL (articulos.php)
   ========================================================== */

.app-container { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  padding: 0.85rem var(--sp-4);
  background: rgba(11, 17, 32, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding-top: max(0.85rem, env(safe-area-inset-top));
}
.app-header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5ch;
}
.app-header h1 span {
  background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logout-btn {
  background: rgba(239, 68, 68, 0.12);
  color: #FCA5A5;
  border: 1px solid rgba(239, 68, 68, 0.30);
  padding: 0.5rem 0.85rem;
  border-radius: var(--r-sm);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
  width: auto;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.logout-btn:hover { background: rgba(239, 68, 68, 0.22); color: #FEE2E2; }

/* Lector de cámara */
.scanner-frame {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 2px solid var(--border-strong);
  background: #000;
}
.scanner-frame video { display: block; width: 100%; }

/* ==========================================================
   RESPONSIVO
   ========================================================== */

@media (max-width: 1080px) {
  .dashboard { grid-template-columns: 1fr; }
  .form-section { position: static; }
}

@media (max-width: 720px) {
  .admin-container { padding: var(--sp-3) var(--sp-3) var(--sp-5); }
  .glass-header {
    position: static;
    padding: var(--sp-4);
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp-3);
  }
  .glass-header h1 { font-size: 1.05rem; justify-content: center; }
  .controls { justify-content: center; }
  .glass-card { padding: var(--sp-4); }
  .grid-2, .photo-grid, .result-grid { grid-template-columns: 1fr; }
  /* 16px evita el zoom automático de iOS al enfocar */
  input, select, textarea { font-size: 16px; }
  th, td { padding: 0.6rem 0.65rem; }
  .tab-btn { padding: 0.6rem 0.7rem; font-size: 0.84rem; }
}

/* Áreas táctiles cómodas en pantallas de dedo */
@media (pointer: coarse) {
  button, .tab-btn, .logout-btn { min-height: 44px; }
  .action-btn { min-height: 38px; min-width: 38px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================
   NAVEGACIÓN DE VISTAS (Inventario / Destrucción / Liquidación)
   ========================================================== */

.top-nav {
  display: flex;
  gap: 0.4rem;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  padding: 0.4rem;
  margin-bottom: var(--sp-5);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  scrollbar-width: none;
}
.top-nav::-webkit-scrollbar { display: none; }

.top-nav-btn {
  flex: 1 1 auto;
  background: transparent;
  color: var(--text-muted);
  border: none;
  padding: 0.8rem 1rem;
  border-radius: var(--r-sm);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.top-nav-btn:hover { color: var(--text-main); background: var(--surface-2); }
.top-nav-btn.active {
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  color: #fff;
  box-shadow: 0 3px 14px rgba(99, 102, 241, 0.35);
}
.top-nav-btn.active:hover { color: #fff; }

.catalog-view { animation: view-in var(--t-med) ease-out; }
@keyframes view-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.catalog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  flex-wrap: wrap;
}
.catalog-head h2 { margin: 0; }
.catalog-count {
  display: inline-block;
  min-width: 1.6em;
  padding: 0.05rem 0.5em;
  margin-left: 0.5ch;
  border-radius: 99px;
  background: var(--surface-3);
  color: var(--accent-color);
  font-size: 0.8rem;
  font-weight: 700;
  vertical-align: middle;
}
.catalog-refresh { width: auto; padding: 0.55rem 1rem; font-size: 0.85rem; }

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-4);
}

.catalog-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  transition: transform var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}
.catalog-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent-color);
  box-shadow: var(--shadow-md);
}
.catalog-card:active { transform: translateY(-1px); }

.cat-thumb {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.cat-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cat-thumb-empty { font-size: 2.4rem; opacity: 0.35; }

.cat-body { padding: 0.7rem 0.8rem; display: flex; flex-direction: column; gap: 0.35rem; }
.cat-ref {
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.3;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cat-price { display: flex; align-items: baseline; gap: 0.5ch; flex-wrap: wrap; }
.cat-final { font-weight: 800; color: var(--accent-color); font-size: 0.98rem; }
.cat-orig { font-size: 0.8rem; color: var(--text-dim); text-decoration: line-through; }

/* Popup de detalle */
.detail-modal-content {
  max-width: 620px;
  position: relative;
  padding-top: 2.6rem;
}
.detail-close {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-main);
  font-size: 0.9rem;
  line-height: 1;
}
.detail-close:hover { background: var(--danger-color); color: #fff; }

.detail-gallery {
  display: flex;
  gap: var(--sp-3);
  overflow-x: auto;
  margin-bottom: var(--sp-4);
  padding-bottom: 0.3rem;
}
.detail-photo {
  height: 220px;
  border-radius: var(--r-md);
  object-fit: cover;
  flex: 0 0 auto;
  max-width: 100%;
  border: 1px solid var(--border-color);
}
.detail-nophoto {
  width: 100%;
  padding: var(--sp-6);
  text-align: center;
  color: var(--text-dim);
  background: var(--surface-1);
  border-radius: var(--r-md);
  border: 1px dashed var(--border-strong);
}
.detail-ref { color: var(--text-main) !important; font-size: 1.15rem; margin-bottom: var(--sp-4); }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.detail-grid > div {
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.75rem;
}
.detail-grid span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.detail-grid b { font-size: 1rem; color: var(--text-main); }
.detail-final { color: var(--accent-color) !important; }
.detail-block {
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--r-sm);
  padding: 0.7rem 0.85rem;
  margin-bottom: var(--sp-3);
}
.detail-block > span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}
.detail-block p { color: var(--text-main); line-height: 1.5; white-space: pre-wrap; }
.detail-block code {
  display: inline-block;
  background: var(--surface-3);
  color: var(--accent-color);
  padding: 0.15rem 0.5rem;
  border-radius: 5px;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.85rem;
  margin: 0.15rem 0.15rem 0 0;
}

@media (max-width: 720px) {
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .detail-photo { height: 170px; }
  .top-nav-btn { padding: 0.7rem 0.6rem; font-size: 0.88rem; }
}

/* ==========================================================
   DISPONIBILIDAD (Stock): filtro de sede + tarjetas
   ========================================================== */

.sede-filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.7rem;
  margin-bottom: var(--sp-3);
}
.sede-filter-bar label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  margin: 0;
}
.sede-filter-bar select { flex: 1; padding: 0.45rem 0.6rem; font-size: 0.9rem; }

.stock-card {
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.stock-card-media { text-align: center; }
.stock-card-media img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: var(--r-sm);
}
.stock-card h4 {
  margin: 0;
  color: var(--accent-color);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.stock-card-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-color);
}
.stock-price { font-size: 1.15rem; font-weight: 800; color: var(--text-main); }
.stock-price-none { font-size: 0.92rem; font-weight: 600; color: var(--text-dim); }
.stock-total { font-size: 0.85rem; color: var(--text-muted); }
.stock-total strong { color: var(--accent-color); font-size: 1rem; }

.stock-locs {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.stock-locs li {
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.7rem;
  border-radius: var(--r-sm);
  display: flex;
  justify-content: space-between;
  gap: var(--sp-2);
  font-size: 0.88rem;
}
.stock-locs strong { color: var(--accent-color); white-space: nowrap; }

/* ==========================================================
   "VER MUESTRA": foto oficial de boconcept.com
   ========================================================== */

.btn-ver-muestra {
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.55rem 0.9rem;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  font-weight: 600;
}
.btn-ver-muestra:hover { background: var(--accent-color); border-color: var(--accent-color); color: #06283D; }
.btn-ver-muestra:disabled { opacity: 0.6; }

.muestra-content { max-width: 620px; padding-top: 2.6rem; position: relative; }
.muestra-titulo {
  color: var(--text-main) !important;
  font-size: 0.95rem;
  line-height: 1.35;
  margin-bottom: var(--sp-3);
  word-break: break-word;
}
.muestra-marco {
  background: #fff;              /* las fotos vienen con fondo transparente */
  border-radius: var(--r-md);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3);
  overflow: hidden;
}
.muestra-marco img { max-width: 100%; max-height: 58vh; object-fit: contain; display: block; }
.muestra-estado {
  margin-top: var(--sp-3);
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: center;
}
.muestra-estado.ok { color: #6EE7B7; }
.muestra-estado.aviso { color: #FCD34D; }
.muestra-estado.error { color: #FCA5A5; }
.muestra-link {
  display: block;
  margin-top: var(--sp-3);
  text-align: center;
  color: var(--accent-color);
  font-size: 0.85rem;
  text-decoration: none;
}
.muestra-link:hover { text-decoration: underline; }

/* ==========================================================
   OVERLAY DE SESIÓN CERRADA (guardián de sesión)
   ========================================================== */
.session-overlay { z-index: 100000; }
.session-lock-icon { font-size: 3rem; margin-bottom: 0.4rem; line-height: 1; }
#session-expired-overlay .modal-content { max-width: 380px; text-align: center; }
#session-expired-overlay h3 { color: var(--warning-color); margin-bottom: 0.6rem; }
#session-expired-overlay p { color: var(--text-muted); line-height: 1.5; }

/* ==========================================================
   STOCK · pestaña "Base" (BD Axapta)
   ========================================================== */
.base-card {
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.base-card h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-main);
}
.base-codigo {
  font-family: 'Roboto Mono', monospace;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  color: var(--accent-color);
}
.base-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
  padding-top: 0.35rem;
  border-top: 1px solid var(--border-color);
}
.base-precio { font-size: 1.05rem; font-weight: 800; color: var(--text-main); }
.base-precio em { font-style: normal; }
.base-unidades { font-size: 1rem; font-weight: 700; color: var(--accent-color); }
.base-unidades small { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); }

/* ==========================================================
   COMPARADOR (pegar kardex de Axapta)
   ========================================================== */
.comp-ayuda { color: var(--text-muted); font-size: 0.9rem; margin-bottom: var(--sp-3); }
.comp-pegado {
  width: 100%;
  min-height: 110px;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre;
  overflow-x: auto;
}
.comp-aviso {
  margin-top: var(--sp-3);
  padding: 0.6rem 0.8rem;
  border-radius: var(--r-sm);
  font-size: 0.88rem;
  background: var(--surface-2);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}
.comp-aviso.ok    { border-color: rgba(16,185,129,0.35); color: #6EE7B7; background: rgba(16,185,129,0.10); }
.comp-aviso.error { border-color: rgba(245,158,11,0.35); color: #FCD34D; background: rgba(245,158,11,0.10); }

.comp-resumen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.comp-dato {
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.comp-dato span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 700;
}
.comp-dato b { font-size: 1.5rem; font-weight: 800; color: var(--text-main); font-variant-numeric: tabular-nums; }
.comp-dato.comp-total {
  background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(56,189,248,0.12));
  border-color: var(--accent-color);
}
.comp-dato.comp-total b { font-size: 2rem; }
.comp-pos { color: #6EE7B7 !important; }
.comp-neg { color: #FCA5A5 !important; }

#comp-tabla { font-size: 0.85rem; }
#comp-tabla td { white-space: nowrap; }

/* ==========================================================
   COMPARADOR · TRAZABILIDAD
   ========================================================== */
.comp-traza { margin-top: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.comp-traza-titulo { font-size: 1rem; font-weight: 800; }

.comp-desglose {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.comp-desglose b { color: var(--accent-color); }
.comp-desglose code {
  background: var(--surface-3); color: var(--accent-color);
  padding: 0.1rem 0.4rem; border-radius: 5px;
  font-family: 'Roboto Mono', monospace; font-size: 0.82em;
}

.comp-bodegas { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: var(--sp-3); }
.comp-bodega {
  background: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--r-md);
  padding: 0.7rem 0.8rem;
  display: flex; flex-direction: column; gap: 0.1rem;
}
.comp-bodega span { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.comp-bodega b { font-size: 1.4rem; font-weight: 800; color: var(--text-dim); }
.comp-bodega small { color: var(--text-dim); font-size: 0.72rem; }
.comp-bodega.con-stock { border-color: var(--success-color); background: rgba(16,185,129,0.08); }
.comp-bodega.con-stock b { color: #6EE7B7; }
.comp-bodega.con-stock small { color: #6EE7B7; }

.comp-lote {
  background: var(--surface-1);
  border: 1px solid var(--accent-color);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}
.comp-lote.anomalia { border-color: var(--danger-color); background: rgba(239,68,68,0.07); }
.comp-lote-cab { font-weight: 700; font-size: 0.95rem; margin-bottom: var(--sp-3); }
.comp-lote-cab code, .comp-paso code, .comp-vida code {
  background: var(--surface-3); color: var(--accent-color);
  padding: 0.1rem 0.4rem; border-radius: 5px;
  font-family: 'Roboto Mono', monospace; font-size: 0.82em;
}

.comp-cadena { display: flex; flex-direction: column; gap: 0; }
.comp-paso {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.55rem 0 0.55rem 0.2rem;
  position: relative;
  font-size: 0.9rem; color: var(--text-muted); line-height: 1.45;
}
.comp-paso + .comp-paso { border-top: 1px dashed var(--border-color); }
.comp-paso b { color: var(--text-main); }
.comp-paso.actual { background: rgba(56,189,248,0.07); border-radius: var(--r-sm); padding-left: 0.5rem; }
.comp-ico { font-size: 1.25rem; flex: 0 0 auto; line-height: 1.2; }
.comp-abierto { color: #FCD34D !important; }
.comp-cerrado { color: #6EE7B7 !important; }

.comp-vida { margin-top: var(--sp-3); background: var(--surface-2); border-color: var(--border-color); }
.comp-vida summary { font-size: 0.82rem; padding: 0.55rem 0.8rem; }
.comp-vida ul { list-style: none; padding: 0 0.9rem 0.8rem; display: flex; flex-direction: column; gap: 0.3rem; }
.comp-vida li { font-size: 0.82rem; color: var(--text-muted); }
.comp-vida li span { font-family: 'Roboto Mono', monospace; color: var(--text-dim); margin-right: 0.4ch; }

/* ---------- FILTROS del listado + badges de etiqueta ---------- */
.filtros-bar {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: 0.45rem; margin-top: 0.7rem;
}
.filtro-chip {
  background: var(--surface-2); border: 1px solid var(--border-color);
  color: var(--text-muted); border-radius: 99px;
  padding: 0.32rem 0.75rem; font-size: 0.8rem; font-weight: 700;
  cursor: pointer; transition: all 0.15s ease;
}
.filtro-chip.active {
  background: var(--accent-color); border-color: var(--accent-color);
  color: #0B1220; box-shadow: 0 3px 10px rgba(56, 189, 248, 0.35);
}
.filtro-chip.filtro-limpiar { border-color: var(--danger-color); color: #FCA5A5; }
.filtro-fecha {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.75rem; font-weight: 700; color: var(--text-muted);
}
.filtro-fecha input[type="date"] {
  background: var(--surface-2); border: 1px solid var(--border-color);
  color: var(--text-main); border-radius: 8px;
  padding: 0.28rem 0.45rem; font-size: 0.78rem;
  font-family: inherit; color-scheme: dark; max-width: 9.5rem;
}
.filtro-resumen { font-size: 0.78rem; font-weight: 700; color: var(--accent-color); margin-left: auto; }

.badge-etq {
  display: inline-block; font-size: 0.66rem; font-weight: 800;
  letter-spacing: 0.05em; border-radius: 5px;
  padding: 0.14rem 0.42rem; margin-left: 0.3rem;
  vertical-align: middle; white-space: nowrap;
}
.badge-pequena { background: rgba(56, 189, 248, 0.18); color: #7DD3FC; border: 1px solid rgba(56, 189, 248, 0.45); }
.badge-destruccion { background: rgba(239, 68, 68, 0.16); color: #FCA5A5; border: 1px solid rgba(239, 68, 68, 0.45); }

/* ---------- FLUJO: reproducción animada del kardex ---------- */
.comp-traza-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.btn-flujo {
  background: linear-gradient(135deg, var(--accent-color), #7DD3FC);
  color: #0B1220; border: none; border-radius: 99px;
  font-weight: 800; font-size: 0.85rem; padding: 0.45rem 1rem;
  cursor: pointer; box-shadow: 0 4px 14px rgba(56, 189, 248, 0.35);
}
.btn-flujo:active { transform: scale(0.96); }

.flujo-stage { background: var(--surface-1); border: 1px solid var(--border-strong); border-radius: var(--r-md); padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); }
.flujo-top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.flujo-fecha { font-family: 'Roboto Mono', monospace; font-weight: 800; color: var(--accent-color); font-size: 0.95rem; }
.flujo-fecha.salto { animation: flujoPulso 0.55s ease; }
.flujo-controles { display: flex; gap: 0.35rem; }
.flujo-btn { background: var(--surface-3); border: 1px solid var(--border-color); color: var(--text-main); border-radius: 8px; padding: 0.3rem 0.6rem; font-weight: 700; font-size: 0.85rem; cursor: pointer; }
.flujo-progreso { height: 5px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
#flujo-progreso { height: 100%; width: 0%; background: var(--accent-color); transition: width 0.4s ease; }

.flujo-escenario { position: relative; overflow: hidden; border-radius: var(--r-sm); background: var(--surface-2); padding: 5.2rem 0.5rem 0.6rem; min-height: 240px; display: flex; flex-direction: column; justify-content: flex-end; }
.flujo-palabra { position: absolute; top: 0.7rem; left: 0; right: 0; text-align: center; pointer-events: none; z-index: 2; }
.flujo-palabra b { display: block; font-size: 1.45rem; font-weight: 900; letter-spacing: 0.05em; color: var(--text-main); }
.flujo-palabra small { color: var(--text-muted); font-size: 0.78rem; }
.flujo-palabra.pos b { color: #6EE7B7; }
.flujo-palabra.neg b { color: #FCA5A5; }
.flujo-palabra.mov b { color: #7DD3FC; }
.flujo-palabra.gap b { color: var(--text-dim); font-size: 1.15rem; }
.flujo-palabra.fin b { color: var(--accent-color); }
.flujo-anim { animation: flujoPalabra 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.15); }
@keyframes flujoPalabra { from { opacity: 0; transform: translateY(-10px) scale(0.9); } }

.flujo-bodegas { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: var(--sp-3); }
.flujo-bodega { background: var(--surface-1); border: 1px solid var(--border-color); border-radius: var(--r-md); padding: 0.55rem 0.6rem; text-align: center; transition: border-color 0.35s ease, box-shadow 0.35s ease; }
.flujo-bodega span { display: block; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.flujo-bodega b { display: inline-block; font-size: 1.45rem; font-weight: 800; color: var(--text-dim); }
.flujo-bodega.flujo-hit-pos { border-color: var(--success-color); box-shadow: 0 0 16px rgba(16, 185, 129, 0.35); }
.flujo-bodega.flujo-hit-pos b { color: #6EE7B7; animation: flujoPulso 0.55s ease; }
.flujo-bodega.flujo-hit-neg { border-color: var(--danger-color); box-shadow: 0 0 16px rgba(239, 68, 68, 0.3); }
.flujo-bodega.flujo-hit-neg b { color: #FCA5A5; animation: flujoPulso 0.55s ease; }
@keyframes flujoPulso { 35% { transform: scale(1.3); } }

.flujo-ficha { position: absolute; z-index: 3; transform: translate(-50%, -50%); background: #94A3B8; color: #0B1220; font-weight: 800; font-size: 0.85rem; border-radius: 99px; padding: 0.28rem 0.65rem; white-space: nowrap; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45); pointer-events: none; }
.flujo-esfumar { animation: flujoEsfumar 1s ease forwards; }
@keyframes flujoEsfumar {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.1); filter: blur(5px); }
}

.flujo-pie { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.flujo-vivas { font-size: 0.85rem; color: var(--text-muted); }
.flujo-vivas b { color: var(--accent-color); font-size: 1.1rem; }
.flujo-leyenda { display: flex; gap: 0.55rem; flex-wrap: wrap; }
.flujo-leyenda span { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; color: var(--text-dim); font-family: 'Roboto Mono', monospace; }
.flujo-leyenda i, .flujo-final-lote i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

.flujo-final { background: var(--surface-2); border: 1px solid var(--accent-color); border-radius: var(--r-md); padding: var(--sp-4); display: flex; flex-direction: column; gap: 0.65rem; }
.flujo-final h4 { font-size: 0.95rem; font-weight: 800; }
.flujo-final-lote { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }
.flujo-final-lote i { margin-top: 0.4rem; }
.flujo-final-lote b { color: var(--text-main); }
.flujo-final-lote code { background: var(--surface-3); color: var(--accent-color); padding: 0.1rem 0.4rem; border-radius: 5px; font-family: 'Roboto Mono', monospace; font-size: 0.82em; }
.flujo-final-acciones { display: flex; justify-content: flex-end; }

/* ==========================================================
   VISOR DE IMAGEN CON ZOOM (Stock)
   ========================================================== */
.zoom-overlay {
  position: fixed;
  inset: 0;
  z-index: 100002;
  background: rgba(2, 6, 16, 0.96);
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.zoom-barra {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: 0.8rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.zoom-titulo {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-main);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.zoom-x {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-main);
  font-size: 1.05rem;
  padding: 0;
}
.zoom-x:hover { background: var(--danger-color); color: #fff; }

.zoom-marco {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;                 /* fondo claro: las fotos son recortadas */
  touch-action: none;               /* el pellizco lo maneja la app */
}
.zoom-marco.ampliado { cursor: grab; }
.zoom-marco.ampliado:active { cursor: grabbing; }
.zoom-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  transition: transform 0.08s linear;
  user-select: none;
  -webkit-user-drag: none;
  display: block;
}

.zoom-pie {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.zoom-btn {
  min-width: 54px;
  min-height: 46px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-main);
  border-radius: var(--r-sm);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
}
.zoom-btn:hover { background: var(--surface-3); }
.zoom-reset { font-size: 0.85rem; font-weight: 600; padding: 0 0.9rem; }
.zoom-nivel {
  min-width: 62px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Imagen de la pestaña Base (viene del catálogo BoConcept) */
.base-media {
  background: #fff;
  border-radius: var(--r-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 190px;
}
.base-media img {
  max-width: 100%;
  max-height: 190px;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}
/* Las imágenes de Stock también se pueden ampliar */
.stock-card-media img { cursor: zoom-in; }

/* ==========================================================
   VISOR DE CÓDIGOS TEMPORALES (pantalla completa)
   Fondo BLANCO a propósito: es lo que mejor lee un escáner.
   ========================================================== */
.codigos-overlay {
  position: fixed;
  inset: 0;
  z-index: 100001;
  background: #fff;
  display: flex;
  flex-direction: column;
  color: #000;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.codigos-barra {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.9rem 1.1rem;
  border-bottom: 1px solid #e5e7eb;
}
.codigos-ref {
  flex: 1 1 0%;
  min-width: 0;
  text-align: center;
  font-weight: 800;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.codigos-contador {
  font-weight: 800;
  font-size: 1.05rem;
  color: #111;
  letter-spacing: 0.02em;
}
.codigos-x {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #111;
  font-size: 1.15rem;
  font-weight: 700;
  padding: 0;
  border: 1px solid #e5e7eb;
}
.codigos-x:hover { background: #e2e8f0; }

.codigos-centro {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 0.8rem 0.6rem;
  min-height: 0;
}
.codigos-svg {
  width: 100%;
  max-width: 100%;
  height: clamp(120px, 34vh, 260px);
  display: block;
}
.codigos-texto {
  font-family: 'Roboto Mono', monospace;
  font-size: clamp(1rem, 5vw, 1.6rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: #111;
  text-align: center;
  word-break: break-all;
  padding: 0 0.6rem;
}
.codigos-valor {
  font-size: clamp(1.5rem, 8vw, 2.6rem);
  font-weight: 800;
  color: #000;
  text-align: center;
  line-height: 1.1;
}
.codigos-valor small { font-size: 0.5em; font-weight: 600; color: #475569; }

.codigos-nav {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.1rem 1.2rem;
  border-top: 1px solid #e5e7eb;
}
.codigos-flecha {
  flex: 1;
  min-height: 60px;
  background: #111;
  color: #fff;
  border-radius: 12px;
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}
.codigos-flecha:hover { background: #333; }
.codigos-flecha:active { transform: scale(0.98); }

/* Ocultar impresor en modo web */
#print-container {
  display: none;
}

/* ==========================================================
   CONFIGURACIÓN DE IMPRESIÓN EXACTA
   ========================================================== */
@media print {
  @page {
    size: letter portrait;
  }

  .admin-container {
    display: none !important;
  }

  body {
    background: white;
    min-height: auto;
  }

  #print-container {
    display: grid !important;
    gap: 0;
    width: max-content;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    padding: 0;
  }

  /* ETIQUETAS INDIVIDUALES */
  .label-card {
    box-sizing: border-box;
    border: 1px dashed #ccc; /* Guía súper fina de corte */
    background: white;
    color: black;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    padding: 2mm; /* Pequeño margen interno para que la tinta no llegue justo al borde del corte */
    margin: 0;
  }

  /* --- Frontal --- */
  .label-front {
    justify-content: center;
    align-items: center;
    text-align: center;
    font-family: 'Inter', sans-serif;
  }

  .label-front .outlet-text {
    font-size: 24pt;
    font-weight: 900;
    line-height: 1;
    margin-bottom: 2mm;
  }

  .label-front .original-price {
    font-size: 14pt;
    text-decoration: line-through;
    color: #555;
    margin-bottom: 1mm;
  }

  .label-front .discount {
    font-size: 22pt;
    font-weight: 800;
    color: black;
    margin-bottom: 1mm;
  }

  .label-front .final-price {
    font-size: 18pt;
    font-weight: 800;
  }

  .size-markers {
    position: absolute;
    bottom: 10px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 4px;
  }

  .size-circle {
    width: 12px;
    height: 12px;
    border: 1px solid black;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 6pt;
    font-weight: 700;
    background: transparent;
  }

  /* --- Trasera --- */
  .label-back {
    justify-content: flex-start;
    align-items: center;
    font-family: 'Roboto Mono', monospace;
    padding-top: 2mm;
  }

  .barcode-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 1.5mm;
  }

  .barcode-wrapper svg {
    /* La altura se fuerza a 15px en la generación, pero aseguramos max aquí */
    max-height: 15px;
    width: 100%;
  }

  .barcode-text {
    font-size: 11pt;
    font-family: 'Roboto Mono', monospace;
    line-height: 1;
    margin-top: 1px;
  }

  .reference-text {
    position: absolute;
    bottom: 2mm;
    font-size: 9pt;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    text-align: center;
    width: 100%;
    left: 0;
    /* Anclada abajo y recortada a 2 líneas: un nombre kilométrico
       jamás invade la zona de los códigos de barras. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.15;
  }
}
