* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --rosa: #cc007a;
  --rosa-claro: #fff5f9;
  --rosa-borde: #fde0ec;
  --rosa-oscuro: #9d005d;
  --gris-bg: #f7f7f8;
  --gris-borde: #e5e7eb;
  --gris-texto: #6b7280;
  --texto: #1f2937;
  --verde: #10b981;
  --naranja: #f59e0b;
  --rojo: #ef4444;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--gris-bg);
  color: var(--texto);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
html {
  overflow-x: hidden;
}
.loading { text-align: center; padding: 4rem 2rem; color: var(--gris-texto); }

/* ===== LOGIN ===== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fff 0%, var(--rosa-claro) 100%);
  padding: 1rem;
}
.login-card {
  background: white;
  border-radius: 20px;
  padding: 2.5rem 2rem;
  box-shadow: 0 4px 24px rgba(204, 0, 122, 0.08);
  width: 100%;
  max-width: 380px;
  border: 1px solid var(--rosa-borde);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo h1 {
  color: var(--rosa);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.5px;
}
.login-logo p {
  color: var(--gris-texto);
  font-size: 13px;
  margin-top: 4px;
}
.form-group { margin-bottom: 1rem; }
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--gris-texto);
  margin-bottom: 6px;
  font-weight: 500;
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--gris-borde);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  background: white;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--rosa);
}
.btn {
  width: 100%;
  padding: 12px;
  border: 0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.05s;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--rosa);
  color: white;
}
.btn-primary:hover { background: var(--rosa-oscuro); }
.btn-secondary {
  background: white;
  color: var(--rosa);
  border: 1.5px solid var(--rosa);
}
.btn-danger {
  background: white;
  color: var(--rojo);
  border: 1.5px solid var(--rojo);
}
.btn-pequeno {
  padding: 6px 12px;
  font-size: 12px;
  width: auto;
}
.error-msg {
  background: #fee;
  color: #c00;
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 1rem;
}
.exito-msg {
  background: #ecfdf5;
  color: var(--verde);
  padding: 10px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 1rem;
}

/* ===== LAYOUT PRINCIPAL ===== */
.app-shell { min-height: 100vh; }
.topbar {
  background: var(--rosa);
  color: white;
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.topbar-titulo {
  font-size: 18px;
  font-weight: 500;
}
.topbar-usuario {
  font-size: 12px;
  opacity: 0.9;
}
.topbar-logout {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
}
.contenedor {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* ===== NAVTABS ===== */
.navtabs {
  background: white;
  border-bottom: 1px solid var(--gris-borde);
  display: flex;
  flex-wrap: wrap;            /* que envuelva en varias filas → se ven TODAS las pestañas */
  padding: 0 1rem;
  max-width: 1200px;
  margin: 0 auto;
}
.navtab {
  background: transparent;
  border: 0;
  padding: 14px 18px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  color: var(--gris-texto);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.navtab:hover { color: var(--rosa); }
.navtab.navtab-activa {
  color: var(--rosa);
  border-bottom-color: var(--rosa);
}

/* En tablet/móvil: padding más compacto en los tabs para que entren más */
@media (max-width: 1024px) {
  .navtab {
    padding: 12px 12px;
    font-size: 12px;
  }
  .navtabs {
    padding: 0 0.5rem;
  }
}

/* ===== CLIENTES ===== */
.clientes-tabla {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 12px;
  overflow: hidden;
}
.cliente-fila {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gris-borde);
  transition: background 0.1s;
}
.cliente-fila:last-child { border-bottom: 0; }
.cliente-fila:hover { background: var(--gris-bg); }
.cliente-fila-baja {
  opacity: 0.55;
  background: #fafafa;
}
.cliente-fila-codigo {
  background: var(--rosa-claro);
  color: var(--rosa);
  font-family: monospace;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  min-width: 50px;
  text-align: center;
}
.cliente-fila-info { flex: 1; min-width: 0; }
.cliente-fila-nombre {
  font-size: 13px;
  font-weight: 500;
  color: var(--texto);
  margin-bottom: 2px;
}
.cliente-fila-detalles {
  font-size: 11px;
  color: var(--gris-texto);
}
.cliente-baja-badge {
  display: inline-block;
  background: #fee;
  color: var(--rojo);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  font-weight: 500;
}
.paginacion {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 1.2rem;
}
.paginacion button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ===== COMERCIALES ===== */
.comerciales-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.comercial-card {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: space-between;
}
.comercial-card:hover { border-color: var(--rosa); }
.comercial-inactivo {
  opacity: 0.55;
  background: var(--gris-bg);
}
.comercial-card-info { flex: 1; min-width: 0; }
.comercial-card-cabecera {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.comercial-nombre {
  font-size: 14px;
  font-weight: 500;
  color: var(--texto);
}
.comercial-card-detalles {
  font-size: 12px;
  color: var(--gris-texto);
}
.comercial-card-acciones {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.rol-badge {
  display: inline-block;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.rol-admin {
  background: var(--rosa-claro);
  color: var(--rosa);
}
.rol-sales {
  background: #e0f2fe;
  color: #075985;
}
.rol-yo {
  background: #fef3c7;
  color: #92400e;
}
.rol-baja {
  background: #fee;
  color: var(--rojo);
}
@media (max-width: 640px) {
  .comercial-card { flex-direction: column; align-items: stretch; }
  .comercial-card-acciones { justify-content: flex-start; }
}

/* ===== LISTA DE CATALOGOS ===== */
.titulo-pagina {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.titulo-pagina h2 {
  font-size: 20px;
  color: var(--texto);
  font-weight: 600;
}
.catalogos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.catalogo-card {
  background: white;
  border-radius: 14px;
  border: 1px solid var(--gris-borde);
  padding: 1.2rem;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.05s;
}
.catalogo-card:hover {
  border-color: var(--rosa);
}
.catalogo-card:active { transform: scale(0.99); }
.catalogo-card-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}
.catalogo-card-tipo {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tipo-maestro { background: var(--rosa-claro); color: var(--rosa); }
.tipo-clon { background: #e0f2fe; color: #075985; }
.tipo-express { background: #fef3c7; color: #92400e; }
.catalogo-card-nombre {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 6px;
}
.catalogo-card-info {
  font-size: 12px;
  color: var(--gris-texto);
}
.catalogo-card-estado {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}
.estado-borrador { background: #f3f4f6; color: #6b7280; }
.estado-publicado { background: #d1fae5; color: #065f46; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 4rem 1rem;
  color: var(--gris-texto);
}
.empty-state-icono { font-size: 48px; margin-bottom: 1rem; opacity: 0.4; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--texto); }
.empty-state p { font-size: 14px; margin-bottom: 1.5rem; }

/* ===== MODAL ===== */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 99000; /* Más alto que el visor fullscreen para que el modal de anotar pedido salga por delante */
}
.modal-card {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}
.modal-header h3 { font-size: 17px; }
.modal-cerrar {
  background: none;
  border: 0;
  font-size: 22px;
  color: var(--gris-texto);
  cursor: pointer;
  line-height: 1;
}
.modal-acciones {
  display: flex;
  gap: 8px;
  margin-top: 1.5rem;
}
.modal-acciones .btn { flex: 1; }

/* ===== EDITOR DE CATALOGO ===== */
.editor-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.2rem;
}
@media (max-width: 768px) {
  .editor-grid { grid-template-columns: 1fr; }
}
.editor-panel {
  background: white;
  border-radius: 14px;
  border: 1px solid var(--gris-borde);
  padding: 1.2rem;
}
.editor-panel h3 {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 1rem;
  color: var(--texto);
}
.upload-zona {
  border: 2px dashed var(--rosa);
  background: var(--rosa-claro);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s;
}
.upload-zona:hover { background: #fef0f6; }
.upload-zona.upload-zona-pdf {
  border-color: #7c3aed;
  background: #f5f3ff;
}
.upload-zona.upload-zona-pdf .upload-zona-icono,
.upload-zona.upload-zona-pdf .upload-zona-texto {
  color: #7c3aed;
}
.upload-zona.upload-zona-pdf:hover { background: #ede9fe; }
.upload-zona-icono { font-size: 28px; color: var(--rosa); margin-bottom: 6px; }
.upload-zona-texto { color: var(--rosa); font-size: 13px; font-weight: 500; }
.upload-zona-sub { color: var(--gris-texto); font-size: 11px; margin-top: 4px; }

.lamina-fila {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--gris-bg);
  border: 1px solid var(--gris-borde);
  border-radius: 10px;
  margin-bottom: 6px;
  transition: border-color 0.15s;
}
.lamina-fila:hover {
  border-color: var(--rosa);
  background: white;
}
.lamina-numero {
  width: 32px;
  font-size: 13px;
  font-weight: 600;
  color: var(--rosa);
  text-align: center;
}
.lamina-mini {
  width: 54px;
  height: 70px;
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.lamina-mini:hover {
  transform: scale(1.6);
  z-index: 10;
  box-shadow: 0 8px 24px rgba(204, 0, 122, 0.25);
}
.lamina-info {
  flex: 1;
  min-width: 0;
}
.lamina-titulo {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}
.lamina-notas {
  font-size: 11px;
  color: var(--gris-texto);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lamina-acciones { display: flex; gap: 4px; }
.lamina-acciones button {
  background: white;
  border: 1px solid var(--gris-borde);
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
}
.lamina-acciones button:hover { border-color: var(--rosa); color: var(--rosa); }
.lamina-acciones button.btn-borrar:hover { border-color: var(--rojo); color: var(--rojo); }

/* Spinner para subidas */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--rosa-borde);
  border-top-color: var(--rosa);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.subida-progreso {
  background: var(--rosa-claro);
  border: 1px solid var(--rosa-borde);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--rosa);
}

/* ===== IMPERSONACION ===== */
.banner-impersonacion {
  background: #fef3c7;
  border-bottom: 2px solid #f59e0b;
  padding: 10px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: #78350f;
}
.banner-impersonacion b { color: #422006; }
.btn-volver-admin {
  background: white;
  border: 1px solid #f59e0b;
  color: #92400e;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.btn-volver-admin:hover {
  background: #f59e0b;
  color: white;
}
.topbar-action {
  background: rgba(255,255,255,0.15);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}
.topbar-action:hover {
  background: rgba(255,255,255,0.25);
}
.comercial-impersonar {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}
.comercial-impersonar:hover {
  border-color: var(--rosa);
  background: var(--rosa-claro);
}

/* ===== ASIGNACIONES catalogo-comerciales ===== */
.asignaciones-lista {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.asignacion-fila {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: white;
  border: 1.5px solid var(--gris-borde);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.asignacion-fila:hover {
  border-color: var(--rosa);
  background: var(--rosa-claro);
}
.asignacion-fila.asignacion-activa {
  border-color: var(--rosa);
  background: var(--rosa-claro);
}
.asignacion-fila input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--rosa);
}
.asignacion-info { flex: 1; min-width: 0; }
.asignacion-nombre {
  font-size: 13px;
  font-weight: 500;
  color: var(--texto);
  margin-bottom: 2px;
}
.asignacion-meta {
  font-size: 11px;
  color: var(--gris-texto);
}
.asg-status {
  font-size: 11px;
  color: var(--rosa);
  font-weight: 500;
  white-space: nowrap;
}

/* ============================================================================
   VISOR COMERCIAL — tablet vertical, modo presentación + mosaico
   ============================================================================ */
.visor-shell {
  background: #fafafa;
  min-height: calc(100vh - 110px);
}

.visor-cabecera {
  background: white;
  border-bottom: 1px solid var(--gris-borde);
  padding: 12px 14px;
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.visor-cabecera-fila {
  display: flex;
  align-items: center;
  gap: 10px;
}
.btn-icon-volver {
  background: var(--gris-bg);
  border: 1px solid var(--gris-borde);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  color: var(--rosa);
  font-weight: 500;
}
.btn-icon-volver:hover { background: var(--rosa-claro); border-color: var(--rosa); }
.visor-titulo-bloque {
  flex: 1;
  min-width: 0;
}
.visor-titulo {
  font-size: 15px;
  font-weight: 600;
  color: var(--texto);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.visor-subtitulo {
  font-size: 11px;
  color: var(--gris-texto);
  margin-top: 2px;
}
.visor-modo-switch {
  display: flex;
  gap: 4px;
  background: var(--gris-bg);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--gris-borde);
}
.visor-modo-btn {
  background: transparent;
  border: 0;
  width: 38px;
  height: 32px;
  border-radius: 7px;
  font-size: 16px;
  cursor: pointer;
  color: var(--gris-texto);
}
.visor-modo-btn.activo {
  background: white;
  color: var(--rosa);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.visor-buscador-fila {
  position: relative;
}
.visor-buscador {
  width: 100%;
  padding: 11px 38px 11px 14px;
  border: 1.5px solid var(--gris-borde);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: white;
  box-sizing: border-box;
}
.visor-buscador:focus { border-color: var(--rosa); }
.visor-buscador-clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: 0;
  color: var(--gris-texto);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
}

/* ===== Modo presentación ===== */
.visor-presentacion {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.visor-nav-superior {
  width: 100%;
  max-width: 720px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: white;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--gris-borde);
  flex-wrap: wrap;
}
.visor-nav-btn {
  background: var(--rosa);
  color: white;
  border: 0;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  min-width: 110px;
}
.visor-nav-btn:hover { background: var(--rosa-oscuro); }
.visor-nav-btn:disabled {
  background: var(--gris-borde);
  color: #888;
  cursor: not-allowed;
}
.visor-contador {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: inherit;
}
.visor-contador-num {
  font-size: 22px;
  font-weight: 700;
  color: var(--rosa);
}
.visor-contador-total {
  font-size: 13px;
  color: var(--gris-texto);
}

.visor-imagen-contenedor {
  width: 100%;
  max-width: 720px;
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 14px;
  padding: 8px;
  overflow: hidden;
  position: relative;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.visor-imagen-zoom {
  width: 100%;
  transform-origin: center center;
  transition: transform 0.15s;
  /* Aceleracion GPU para zoom/pan fluido en tablet */
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.visor-imagen {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  pointer-events: none;
  /* Mantener nitidez en zoom alto (PNG 150 dpi con textos pequenos) */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: high-quality;
  /* GPU layer para zoom fluido */
  transform: translateZ(0);
}
.visor-zoom-reset {
  position: absolute;
  top: 16px;
  right: 16px;
  background: rgba(204, 0, 122, 0.95);
  color: white;
  border: 0;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  z-index: 5;
}

.visor-info-lamina {
  width: 100%;
  max-width: 720px;
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 10px;
  padding: 12px 14px;
}
.visor-info-titulo {
  font-size: 14px;
  font-weight: 500;
  color: var(--texto);
  margin-bottom: 4px;
}
.visor-info-notas {
  font-size: 13px;
  color: var(--gris-texto);
  line-height: 1.4;
}
.visor-zoom-hint {
  font-size: 11px;
  color: var(--gris-texto);
  text-align: center;
  max-width: 720px;
  padding: 4px 8px;
}

.visor-vacio {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--gris-texto);
}
.visor-vacio h3 { font-size: 17px; margin-bottom: 6px; color: var(--texto); }
.visor-vacio p { font-size: 13px; }

/* ===== Modo mosaico ===== */
.visor-mosaico {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  padding: 14px;
}
.visor-mosaico-celda {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s, transform 0.05s;
}
.visor-mosaico-celda:hover {
  border-color: var(--rosa);
}
.visor-mosaico-celda:active {
  transform: scale(0.97);
}
.visor-mosaico-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}
.visor-mosaico-num {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(204, 0, 122, 0.92);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.visor-mosaico-titulo {
  padding: 6px 8px;
  font-size: 11px;
  color: var(--texto);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--gris-borde);
}

/* Mosaico denso en tablets pequeñas: 4 columnas */
@media (max-width: 900px) {
  .visor-mosaico { grid-template-columns: repeat(4, 1fr); }
  .visor-mosaico-img { height: 160px; }
}
@media (max-width: 640px) {
  .visor-mosaico { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; }
  .visor-mosaico-img { height: 140px; }
  .visor-nav-btn { min-width: 80px; padding: 9px 10px; font-size: 12px; }
}

/* ===== EDICION INLINE DE TAGS ===== */
.lamina-tags-input {
  width: 100%;
  padding: 6px 10px;
  margin-top: 4px;
  border: 1px dashed var(--gris-borde);
  border-radius: 6px;
  font-size: 11px;
  font-family: inherit;
  background: white;
  color: var(--texto);
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s, background 0.15s;
}
.lamina-tags-input::placeholder { color: #b0b0b0; font-size: 10.5px; }
.lamina-tags-input:focus { border-color: var(--rosa); border-style: solid; }
.lamina-tags-input.lamina-tags-dirty {
  border-color: #f59e0b;
  border-style: solid;
  background: #fffaf0;
}
.lamina-tags-input.lamina-tags-saved {
  border-color: var(--verde);
  border-style: solid;
  background: #ecfdf5;
}
.btn-guardar-tags {
  background: #fbbf24 !important;
  color: white !important;
  border: 0 !important;
  font-size: 13px !important;
  padding: 5px 10px !important;
  border-radius: 6px !important;
  cursor: pointer;
  animation: pulse-warn 1.5s ease-in-out infinite;
}
@keyframes pulse-warn {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

/* ===== DRAG & DROP REORDENAR LAMINAS ===== */
.drag-handle {
  color: #9ca3af;
  font-size: 14px;
  cursor: grab;
  padding: 0 4px;
  user-select: none;
  flex-shrink: 0;
  letter-spacing: -2px;
  font-family: monospace;
}
.drag-handle:hover { color: var(--rosa); }
.lamina-fila[draggable="true"] { cursor: grab; }
.lamina-fila[draggable="true"]:active { cursor: grabbing; }
.lamina-arrastrando {
  opacity: 0.4;
  transform: scale(0.98);
}
.lamina-arrastrando-target {
  border-color: var(--rosa) !important;
  border-width: 2px !important;
  background: var(--rosa-claro) !important;
  border-style: dashed !important;
}

/* ===== LIGHTBOX ===== */
.lightbox-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem 1rem;
  z-index: 200;
  cursor: zoom-out;
}
.lightbox-img {
  max-width: 95vw;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}
.lightbox-cerrar {
  position: absolute;
  top: 14px;
  right: 18px;
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  font-family: inherit;
}
.lightbox-cerrar:hover { background: rgba(255, 255, 255, 0.3); }
.lightbox-info {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  max-width: 90%;
  text-align: center;
}

/* Aumentar tamaño miniatura para que el click sea cómodo */
.lamina-mini { cursor: zoom-in; }

/* ============================================================================
   B5 - CATALOGOS EXPRESS
   ============================================================================ */

/* Linea del maestro padre en la card del listado */
.catalogo-card-parent {
  font-size: 11px;
  color: var(--gris-texto);
  margin-top: -4px;
  margin-bottom: 4px;
  font-style: italic;
}

/* Grid dos columnas del editor Express */
.express-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 900px) {
  .express-grid {
    grid-template-columns: 1fr;
  }
}

.express-panel {
  display: flex;
  flex-direction: column;
}
.express-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.express-lista {
  max-height: 70vh;
  overflow-y: auto;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  padding: 4px;
  background: #fafafa;
}

.express-fila {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
  background: white;
  border-radius: 4px;
  margin-bottom: 2px;
}
.express-fila:last-child { border-bottom: none; }

.express-fila .lamina-mini {
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.express-fila .lamina-info {
  flex: 1;
  min-width: 0;
}
.express-fila .lamina-titulo {
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.express-fila .lamina-numero {
  font-size: 11px;
  color: var(--gris-texto);
  min-width: 24px;
  text-align: center;
}

.express-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}
.express-check:disabled { cursor: not-allowed; opacity: 0.5; }

.express-fila-en-express {
  background: #f0fdf4;
  opacity: 0.7;
}

.express-badge-ya {
  font-size: 10px;
  background: #dcfce7;
  color: #166534;
  padding: 2px 6px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* Boton borrar especifico del Express (mas pequeno que en editor maestro) */
.express-lista .btn-borrar {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
  color: #c00;
}
.express-lista .btn-borrar:hover {
  background: #fee2e2;
}

/* ============================================================================
   B6 - VISITAS Y ANOTACIONES
   ============================================================================ */

/* Barra superior de visita activa */
.banner-visita {
  background: linear-gradient(90deg, #fef3c7, #fde68a);
  color: #78350f;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 2px solid #f59e0b;
  flex-wrap: wrap;
}

/* Cliente fila clickable */
.cliente-fila-clickable {
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  gap: 12px;
}
.cliente-fila-clickable:hover {
  background: #fafafa;
}
.cliente-fila-clickable:active {
  background: #f3f4f6;
}
.cliente-fila-chevron {
  color: var(--gris-texto);
  font-size: 20px;
  padding-right: 8px;
}

/* Detalle cliente: dos columnas */
.cliente-detalle-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
@media (max-width: 900px) {
  .cliente-detalle-grid {
    grid-template-columns: 1fr;
  }
}

/* Tabla key-value para ficha */
.kv-tabla {
  display: flex;
  flex-direction: column;
}
.kv-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.kv-row:last-child { border-bottom: none; }
.kv-label {
  color: var(--gris-texto);
  font-weight: 500;
}
.kv-val {
  word-break: break-word;
}

/* Historial de visitas */
.historial-visitas {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 70vh;
  overflow-y: auto;
}
.visita-fila {
  display: grid;
  grid-template-columns: 140px 1fr 24px;
  gap: 8px;
  padding: 10px;
  background: #fafafa;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  align-items: center;
}
.visita-fila:hover { background: #f3f4f6; }
.visita-fecha {
  font-size: 12px;
  color: var(--gris-texto);
}
.visita-titulo {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.visita-chevron {
  color: var(--gris-texto);
  font-size: 20px;
  text-align: right;
}
.visita-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #e5e7eb;
  color: #374151;
}
.visita-badge-draft { background: #fef3c7; color: #92400e; }
.visita-badge-confirmed { background: #dcfce7; color: #166534; }
.visita-badge-pedido { background: var(--rosa-claro); color: var(--rosa); }
.visita-badge-sin { background: #f3f4f6; color: #6b7280; }

/* Modal elegir catálogo para visita */
.lista-catalogos-visita {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 50vh;
  overflow-y: auto;
}
.btn-elegir-cat {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background 0.15s;
}
.btn-elegir-cat:hover {
  background: var(--rosa-claro);
  border-color: var(--rosa);
}

/* Panel anotaciones dentro del visor */
.visor-anotaciones {
  background: white;
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 12px;
  margin-top: 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.visor-anotaciones-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  color: #78350f;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}
.visor-anotaciones-vacio {
  font-size: 13px;
  color: var(--gris-texto);
  text-align: center;
  padding: 8px;
  font-style: italic;
}
.visor-anotaciones-lista {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.anot-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #fffbeb;
  border-radius: 8px;
  border-left: 3px solid #f59e0b;
}
.anot-chip-icon {
  font-size: 16px;
  flex-shrink: 0;
}
.anot-chip-texto {
  flex: 1;
  font-size: 13px;
  word-break: break-word;
}
.anot-chip-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 14px;
  flex-shrink: 0;
}
.anot-chip-btn:hover {
  background: rgba(0,0,0,0.06);
}
.anot-chip-btn-borrar:hover {
  background: #fee2e2;
}

/* Badge de anotaciones en mosaico */
.visor-mosaico-anots {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(245, 158, 11, 0.95);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
  z-index: 2;
}

/* Detalle visita: filas de anotaciones */
.anot-fila {
  display: flex;
  gap: 12px;
  padding: 10px;
  border-bottom: 1px solid #f3f4f6;
  align-items: center;
}
.anot-fila:last-child { border-bottom: none; }
.anot-fila .lamina-mini {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  object-fit: cover;
  border-radius: 6px;
}
.anot-info {
  flex: 1;
  min-width: 0;
}
.anot-titulo {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
}
.anot-texto {
  font-size: 13px;
  color: #374151;
  word-break: break-word;
  white-space: pre-wrap;
}

/* ============================================================================
   D - PLANTILLAS DE ANOTACION
   ============================================================================ */

/* Pantalla de gestión */
.plantilla-lista {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.plantilla-fila {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  cursor: grab;
  transition: background 0.15s;
}
.plantilla-fila:hover {
  background: #fafafa;
}
.plantilla-fila.lamina-arrastrando {
  opacity: 0.4;
}
.plantilla-tipo-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 500;
  flex-shrink: 0;
}
.tipo-pedido { background: #dcfce7; color: #166534; }
.tipo-devolucion { background: #fef3c7; color: #92400e; }
.tipo-nota { background: #e5e7eb; color: #374151; }
.plantilla-texto {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  min-width: 0;
  word-break: break-word;
}
.plantilla-acciones {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.plantilla-acciones button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px 6px;
  border-radius: 4px;
}
.plantilla-acciones button:hover {
  background: rgba(0,0,0,0.06);
}
.plantilla-acciones .btn-borrar:hover {
  background: #fee2e2;
}

/* Chips de plantillas en el modal de anotar */
.anot-chips-plantillas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 130px;
  overflow-y: auto;
  padding: 6px;
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid #f3f4f6;
}
.chip-plantilla {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 16px;
  padding: 5px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.chip-plantilla:hover {
  background: var(--rosa-claro);
  border-color: var(--rosa);
  color: var(--rosa);
}
.chip-plantilla:active {
  transform: scale(0.96);
}

/* ============================================================================
   C - CONFIGURACION DE EMAILS
   ============================================================================ */

/* Interruptor modo pruebas/produccion */
.modo-switch-bg {
  display: flex;
  background: #f3f4f6;
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
}
.modo-btn {
  flex: 1;
  padding: 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  color: #6b7280;
}
.modo-btn-activo.modo-btn-pruebas {
  background: white;
  color: #b91c1c;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.modo-btn-activo.modo-btn-prod {
  background: white;
  color: #166534;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Log de emails enviados en detalle visita */
.emails-lista {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.email-fila {
  display: flex;
  gap: 12px;
  padding: 10px;
  background: #fafafa;
  border-radius: 8px;
  border-left: 3px solid #166534;
  align-items: flex-start;
}
.email-fila-error {
  border-left-color: #dc2626;
  background: #fef2f2;
}
.email-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}
.email-badge-ok { background: #dcfce7; color: #166534; }
.email-badge-fail { background: #fee2e2; color: #991b1b; }
.email-badge-pruebas { background: #fee2e2; color: #b91c1c; }
.email-badge-prod { background: #dcfce7; color: #166534; }

/* form-group consistente con el resto de la app */
.editor-panel .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 4px;
}
.editor-panel .form-group input,
.editor-panel .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  box-sizing: border-box;
}
.editor-panel .form-group input:focus,
.editor-panel .form-group textarea:focus {
  border-color: var(--rosa);
}
.editor-panel .form-group {
  margin-bottom: 12px;
}

/* ============================================================================
   F - PANEL ULTIMA VISITA
   ============================================================================ */

.ultima-visita-panel {
  background: linear-gradient(180deg, #fffbeb, #fff);
  border: 1px solid #fde68a;
  border-radius: 12px;
  padding: 14px 16px;
  margin: 14px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* En el visor el panel se llama "privado" - rojo */
.ultima-visita-panel-privada {
  background: linear-gradient(180deg, #fef2f2, #fff);
  border-color: #fecaca;
}

.uv-cabecera, .uv-cabecera-modal {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.uv-cabecera-privada {
  background: #fee2e2;
  margin: -14px -16px 12px -16px;
  padding: 10px 16px;
  border-radius: 12px 12px 0 0;
  border-bottom: 1px solid #fca5a5;
}
.uv-titulo {
  font-size: 14px;
  font-weight: 600;
  color: #78350f;
}
.uv-titulo-privada {
  font-size: 14px;
  font-weight: 700;
  color: #991b1b;
  letter-spacing: 0.3px;
}
.uv-grupo {
  margin-bottom: 8px;
}
.uv-grupo:last-child {
  margin-bottom: 0;
}
.uv-grupo-titulo {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}
.uv-grupo-lista {
  margin: 0;
  padding-left: 22px;
  list-style: disc;
}
.uv-grupo-lista li {
  font-size: 13px;
  margin-bottom: 3px;
  color: #333;
}
.uv-grupo-texto {
  display: block;
  font-size: 12px;
  color: #555;
  margin-left: 0;
  margin-top: 1px;
  font-style: italic;
}
.uv-notas-generales {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #fde68a;
}
.ultima-visita-panel-privada .uv-notas-generales {
  border-top-color: #fecaca;
}

/* Modal ancho para mostrar lista de catalogos con resumen arriba */
.modal-card-ancho {
  max-width: 640px !important;
}

/* Botón "📋 Notas" en barra visor: estilo discreto pero localizable */
.visor-modo-btn-notas {
  background: #fef3c7 !important;
  border: 1px solid #fde68a !important;
  color: #92400e !important;
}
.visor-modo-btn-notas:hover {
  background: #fde68a !important;
}

/* ============================================================================
   G - PLANNING / RUTERO
   ============================================================================ */

.planning-filtros {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 12px;
  padding: 12px;
  margin: 14px 0;
}

.planning-chips-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.planning-chip {
  background: #f3f4f6;
  border: 1px solid var(--gris-borde);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.planning-chip:hover {
  background: #e5e7eb;
}
.planning-chip-activo {
  background: var(--rosa);
  color: white;
  border-color: var(--rosa);
  font-weight: 500;
}

.planning-inputs-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.planning-input {
  padding: 8px 12px;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  font-family: inherit;
  flex: 1;
  min-width: 180px;
}
.planning-input:focus { border-color: var(--rosa); }

.planning-resumen {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--gris-texto);
  margin-bottom: 10px;
}
.planning-resumen-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

.planning-lista {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.planning-fila {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: white;
  border-radius: 8px;
  border-left: 4px solid #6b7280;
  cursor: pointer;
  transition: background 0.15s;
}
.planning-fila:hover {
  background: #fafafa;
}

.planning-chip-estado {
  font-size: 18px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
}

.planning-fila-info {
  flex: 1;
  min-width: 0;
}
.planning-fila-nombre {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 2px;
}
.planning-fila-meta {
  font-size: 12px;
  color: #555;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.planning-fila-tiempo {
  font-size: 12px;
  color: var(--gris-texto);
  margin-top: 2px;
}

.planning-btn-visita {
  flex-shrink: 0;
}

/* Chip mini en lista clientes */
.planning-chip-mini {
  font-size: 14px;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  background: #f3f4f6;
  margin-right: 8px;
}

/* Botón link sutil dentro de la ficha */
.btn-link {
  background: none;
  border: none;
  color: var(--rosa);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  margin-left: 6px;
  text-decoration: underline;
  font-family: inherit;
}
.btn-link:hover {
  color: #a00060;
}

/* ============================================================================
   B7 - PINS X+Y SOBRE LAMINA
   ============================================================================ */

/* Wrapper relativo para posicionar pins */
.visor-imagen-wrapper {
  position: relative;
  display: inline-block;
  line-height: 0; /* sin gap bajo la imagen */
}
.visor-imagen-wrapper .visor-imagen {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Pin numerado tipo Google Maps */
.visor-pin {
  position: absolute;
  transform: translate(-50%, -100%);
  background: #166534;
  color: white;
  border: 2px solid white;
  border-radius: 50% 50% 50% 0;
  width: 36px;
  height: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  padding: 0;
  font-family: inherit;
  rotate: -45deg;
  transition: transform 0.15s ease;
}
.visor-pin:hover {
  transform: translate(-50%, -100%) scale(1.15);
  z-index: 100;
}
.visor-pin-num {
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  rotate: 45deg;
}
.visor-pin-icon {
  font-size: 9px;
  line-height: 1;
  margin-top: 1px;
  rotate: 45deg;
}

/* ============================================================================
   B7 - MODO PANTALLA COMPLETA
   ============================================================================ */

.visor-fullscreen-btn {
  background: var(--rosa);
  color: white;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}
.visor-fullscreen-btn:hover {
  background: var(--rosa-oscuro);
}

/* En tablet/móvil: solo icono para ahorrar espacio */
@media (max-width: 900px) {
  .visor-fullscreen-btn {
    padding: 9px 12px;
    min-width: 44px;
  }
  .visor-fullscreen-btn-texto {
    display: none;
  }
}

/* Cuando body tiene .visor-fullscreen-activo: ocultar todo lo que no sea la imagen */
body.visor-fullscreen-activo {
  overflow: hidden;
  background: #000;
}
/* Ocultar TODA la UI menos el contenedor de imagen */
body.visor-fullscreen-activo .nav-bar,
body.visor-fullscreen-activo .visor-cabecera,
body.visor-fullscreen-activo .visor-nav-superior,
body.visor-fullscreen-activo .visor-info-lamina,
body.visor-fullscreen-activo .visor-anotaciones,
body.visor-fullscreen-activo .visor-zoom-hint,
body.visor-fullscreen-activo .barra-visita-activa,
body.visor-fullscreen-activo .visor-buscador-fila,
body.visor-fullscreen-activo .editor-pestanas,
body.visor-fullscreen-activo .visor-modo-switch,
body.visor-fullscreen-activo .visor-titulo-bloque,
body.visor-fullscreen-activo .btn-icon-volver,
body.visor-fullscreen-activo .barra-impersonacion,
body.visor-fullscreen-activo .nav-tabs,
body.visor-fullscreen-activo header,
body.visor-fullscreen-activo .header-cabecera,
body.visor-fullscreen-activo .contenedor > *:not(#vista-contenido),
body.visor-fullscreen-activo .visor-shell > *:not(.visor-presentacion) {
  display: none !important;
}
/* Forzar la imagen y su contenedor a ocupar TODO el viewport */
body.visor-fullscreen-activo,
body.visor-fullscreen-activo .contenedor,
body.visor-fullscreen-activo #vista-contenido,
body.visor-fullscreen-activo .visor-shell,
body.visor-fullscreen-activo .visor-presentacion {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #000 !important;
  z-index: 9000;
}
body.visor-fullscreen-activo .visor-imagen-contenedor {
  width: 100vw !important;
  height: 100vh !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  margin: 0 !important;
  padding: 0 !important;
  background: #000 !important;
  overflow: hidden;
}
body.visor-fullscreen-activo .visor-imagen-zoom {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
body.visor-fullscreen-activo .visor-imagen-wrapper {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}
body.visor-fullscreen-activo .visor-imagen {
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Controles auto-ocultos */
.fullscreen-controles {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
body.visor-fullscreen-controles-visibles .fullscreen-controles {
  opacity: 1;
  pointer-events: auto;
}

/* Inyectamos los controles dinamicamente via JS, pero su CSS lo dejamos aqui */
.fs-btn {
  background: rgba(0,0,0,0.6);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  width: 56px;
  height: 56px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.fs-btn:hover { background: rgba(0,0,0,0.85); }
.fs-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ============================================================================
   B7 - MODAL PRIVADO (cuando se anota en fullscreen)
   ============================================================================ */

.modal-bg-discreto {
  background: rgba(0,0,0,0.4); /* menos oscuro que el normal */
  z-index: 10000;
}
.modal-card-privado {
  max-width: 420px !important;
  border: 2px solid #dc2626;
  box-shadow: 0 8px 24px rgba(220,38,38,0.4) !important;
}
.modal-cabecera-privada {
  background: #dc2626;
  color: white;
  padding: 8px 14px;
  margin: -16px -16px 12px -16px;
  border-radius: 12px 12px 0 0;
}
.modal-cabecera-privada-titulo {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-align: center;
}

/* ============================================================================
   H - MAPA
   ============================================================================ */

.contenedor-mapa {
  max-width: 1400px;
}

.mapa-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}
.mapa-chips-modo {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.mapa-info {
  font-size: 13px;
  color: var(--gris-texto);
}

.mapa-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 14px;
  min-height: 600px;
}
@media (max-width: 900px) {
  .mapa-layout {
    grid-template-columns: 1fr;
  }
}

.mapa-leaflet {
  height: 600px;
  border-radius: 12px;
  border: 1px solid var(--gris-borde);
  background: #f3f4f6;
}

.mapa-lateral {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  max-height: 600px;
}
.mapa-lateral h4 {
  margin-top: 0;
  font-size: 14px;
  color: #333;
}

.mapa-seleccionados-lista {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 10px;
}

.mapa-sel-fila {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: #fafafa;
  margin-bottom: 4px;
}
.mapa-sel-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.mapa-sel-info {
  flex: 1;
  min-width: 0;
}
.mapa-sel-nombre {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mapa-sel-meta {
  font-size: 11px;
  color: var(--gris-texto);
}
.mapa-sel-quitar {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #999;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
}
.mapa-sel-quitar:hover {
  background: #fee2e2;
  color: #dc2626;
}

.mapa-acciones {
  display: flex;
  gap: 8px;
}
.mapa-acciones .btn {
  flex: 1;
}

.mapa-ruta-info {
  margin-top: 10px;
}
.mapa-ruta-resumen {
  background: #fdf2f8;
  border: 1px solid #fbcfe8;
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  color: #831843;
}

/* Botones dentro de popups de Leaflet */
.leaflet-popup-btn {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
}
.leaflet-popup-btn:hover {
  border-color: var(--rosa);
  color: var(--rosa);
}
.leaflet-popup-btn-primary {
  background: var(--rosa);
  color: white;
  border-color: var(--rosa);
}
.leaflet-popup-btn-primary:hover {
  background: #a00060;
  color: white;
}

/* ============================================================================
   J - DESCARGAR CATALOGO
   ============================================================================ */

.catalogo-card-acciones {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #e5e7eb;
}

.btn-card-mini {
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  color: #444;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-card-mini:hover {
  background: #fef3f7;
  border-color: var(--rosa);
  color: var(--rosa);
}

.descargar-opciones {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.descargar-opcion {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  background: white;
  border: 2px solid var(--gris-borde);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all 0.15s;
}
.descargar-opcion:hover:not(:disabled) {
  border-color: var(--rosa);
  background: #fdf2f8;
}
.descargar-opcion:disabled {
  cursor: wait;
}

.descargar-opcion-icono {
  font-size: 32px;
  flex-shrink: 0;
}

.descargar-opcion-info {
  flex: 1;
}

.descargar-opcion-titulo {
  font-size: 15px;
  font-weight: 600;
  color: #333;
  margin-bottom: 2px;
}

.descargar-opcion-desc {
  font-size: 12px;
  color: var(--gris-texto);
  line-height: 1.4;
}

/* ============================================================================
   E - PESTAÑAS DEL EDITOR DE CATALOGO + HISTORIAL DE VERSIONES
   ============================================================================ */

.editor-pestanas {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--gris-borde);
  flex-wrap: wrap;
}

.editor-pestana {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  color: #666;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.editor-pestana:hover {
  color: var(--rosa);
}
.editor-pestana-activa {
  color: var(--rosa);
  font-weight: 600;
  border-bottom-color: var(--rosa);
}

.versiones-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.version-fila {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: #fafafa;
  border: 1px solid var(--gris-borde);
  border-radius: 10px;
}
.version-fila:hover {
  background: #fdf2f8;
  border-color: var(--rosa);
}

.version-badge {
  background: linear-gradient(135deg, #cc007a, #dc2675);
  color: white;
  font-weight: 700;
  font-size: 18px;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(204, 0, 122, 0.3);
}

.version-info {
  flex: 1;
  min-width: 0;
}

.version-cabecera {
  display: flex;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.version-titulo {
  font-size: 15px;
  font-weight: 600;
  color: #333;
}

.version-meta {
  font-size: 12px;
  color: var(--gris-texto);
}

.version-fecha {
  font-size: 12px;
  color: var(--gris-texto);
  margin-bottom: 4px;
}

.version-notas {
  font-size: 13px;
  color: #555;
  font-style: italic;
  margin-top: 6px;
  padding-left: 12px;
  border-left: 3px solid var(--rosa);
}

.version-acciones {
  display: flex;
  gap: 6px;
  flex-direction: column;
}

@media (max-width: 600px) {
  .version-fila {
    flex-wrap: wrap;
  }
  .version-acciones {
    flex-direction: row;
    width: 100%;
  }
  .version-acciones .btn-card-mini {
    flex: 1;
  }
}

/* ============================================================================
   I - MODO OFFLINE (PWA + IndexedDB)
   ============================================================================ */

/* Indicador de estado online/offline en topbar */
.indicador-online {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.indicador-online-on {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}
.indicador-online-off {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  animation: pulso-offline 2s ease-in-out infinite;
}
@keyframes pulso-offline {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Notificación in-app de cambio de estado online/offline */
.notif-online {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(-30px);
  color: white;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  opacity: 0;
  transition: all 0.35s ease;
  z-index: 99999;
  pointer-events: none;
}
.notif-online-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Badge en tarjeta de catálogo cuando está descargado offline */
.catalogo-card-offline {
  margin-left: auto;
  font-size: 16px;
  filter: drop-shadow(0 0 4px rgba(22, 163, 74, 0.4));
}

/* Botón "✅ Offline" cuando ya está descargado (estilo verde) */
.btn-card-offline-on {
  background: #dcfce7 !important;
  border-color: #86efac !important;
  color: #166534 !important;
  font-weight: 600;
}
.btn-card-offline-on:hover {
  background: #bbf7d0 !important;
  color: #14532d !important;
}

/* I.2 - Aviso offline en visor */
.visor-aviso-offline {
  background: #fef3c7;
  color: #78350f;
  padding: 8px 14px;
  font-size: 12px;
  border-bottom: 1px solid #fcd34d;
  text-align: center;
}

/* ============================================================================
   I.3 - SINCRONIZACIÓN Y VISITAS PENDIENTES
   ============================================================================ */

.indicador-pendientes {
  background: #d97706;
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  cursor: pointer;
  animation: pulso-pendiente 2.5s infinite;
}
.indicador-pendientes:hover {
  background: #b45309;
}
@keyframes pulso-pendiente {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.visita-pendiente-fila {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
}
.visita-pendiente-fila:last-child {
  border-bottom: none;
}
.visita-pendiente-info {
  flex: 1;
  min-width: 0;
}

/* ============================================================================
   PWA UPDATE BANNER - aviso "hay actualización disponible"
   ============================================================================ */

.pwa-update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #cc007a, #dc2675);
  color: white;
  padding: 10px 14px;
  display: none;
  align-items: center;
  gap: 10px;
  z-index: 999999;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
  font-size: 14px;
  font-family: inherit;
}

.pwa-update-banner-visible {
  display: flex;
  animation: pwa-update-banner-in 0.4s ease-out;
}

@keyframes pwa-update-banner-in {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.pwa-update-banner-texto {
  flex: 1;
  font-weight: 500;
}

.pwa-update-banner-btn {
  background: white;
  color: #cc007a;
  border: none;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s;
}
.pwa-update-banner-btn:hover {
  transform: scale(1.05);
}

.pwa-update-banner-cerrar {
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.pwa-update-banner-cerrar:hover {
  background: rgba(255,255,255,0.35);
}

/* Empujar contenido cuando banner está visible (evitar que tape topbar) */
body.con-banner-update {
  padding-top: 50px;
}

@media (max-width: 600px) {
  .pwa-update-banner {
    padding: 8px 10px;
    font-size: 13px;
    gap: 6px;
  }
  .pwa-update-banner-texto {
    font-size: 12px;
  }
  .pwa-update-banner-btn {
    padding: 5px 10px;
    font-size: 12px;
  }
  body.con-banner-update {
    padding-top: 45px;
  }
}

/* ============================================================================
   FASE 1 - PRODUCTOS
   ============================================================================ */

.productos-lista {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.producto-fila {
  display: grid;
  grid-template-columns: 85px 110px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  background: white;
  border: 1px solid var(--gris-borde);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.producto-fila:hover {
  border-color: var(--rosa);
  background: #fdf2f8;
}
.producto-fila-inactivo {
  opacity: 0.55;
}

.prod-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
}
.prod-badge-sage {
  background: #dbeafe;
  color: #1e40af;
}
.prod-badge-comercial {
  background: #fef3c7;
  color: #78350f;
}

.producto-codigo {
  font-family: monospace;
  font-size: 13px;
  font-weight: 600;
  color: #444;
}

.producto-info {
  min-width: 0;
}
.producto-nombre {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.producto-meta {
  font-size: 11px;
  color: var(--gris-texto);
  margin-top: 2px;
}

.producto-precios {
  text-align: right;
  font-size: 12px;
}
.producto-precio-pvp {
  color: #16a34a;
  font-weight: 600;
}
.producto-precio-pvf {
  color: var(--rosa);
  font-weight: 500;
  font-size: 11px;
}

@media (max-width: 600px) {
  .producto-fila {
    grid-template-columns: 70px 1fr;
    grid-template-areas:
      "badge codigo"
      "info info"
      "precios precios";
  }
  .producto-fila .prod-badge { grid-area: badge; }
  .producto-fila .producto-codigo { grid-area: codigo; }
  .producto-fila .producto-info { grid-area: info; }
  .producto-fila .producto-precios { grid-area: precios; text-align: left; }
}

/* ============================================================================
   FASE 2.a — Autocomplete de productos (modal anotar visita)
   ============================================================================ */
.ac-producto-wrap {
  position: relative;
}
.ac-producto-input {
  width: 100%;
  padding: 10px 36px 10px 12px;
  border: 1px solid var(--gris-borde, #e5e7eb);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  box-sizing: border-box;
}
.ac-producto-input:focus {
  border-color: var(--rosa-principal, #cc007a);
  outline: none;
  box-shadow: 0 0 0 3px rgba(204, 0, 122, 0.1);
}
.ac-producto-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: #f3f4f6;
  border: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ac-producto-clear:hover {
  background: #e5e7eb;
  color: #111827;
}
.ac-producto-resultados {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--gris-borde, #e5e7eb);
  border-radius: 8px;
  margin-top: 4px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  max-height: 320px;
  overflow-y: auto;
  z-index: 10000;
}
.ac-item {
  padding: 10px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover { background: #fdf2f8; }
.ac-item-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.ac-item-tipo { font-size: 14px; }
.ac-item-pvf {
  margin-left: auto;
  color: var(--rosa-principal, #cc007a);
  font-weight: 600;
  font-size: 12px;
}
.ac-item-row2 {
  color: #6b7280;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ac-loading, .ac-empty {
  padding: 14px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
  font-style: italic;
}
.ac-producto-seleccionado {
  margin-top: 8px;
}
.ac-producto-card {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
}
.ac-producto-card-row1 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.ac-producto-card-row2 {
  color: #14532d;
  font-size: 12px;
}
.ac-badge-sage, .ac-badge-promo {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.ac-badge-sage {
  background: #dbeafe;
  color: #1e40af;
}
.ac-badge-promo {
  background: #fef3c7;
  color: #78350f;
}
.ac-pvf {
  margin-left: auto;
  color: var(--rosa-principal, #cc007a);
  font-weight: 700;
}

/* ============================================================================
   FASE 2.b' — Editor de zonas sobre láminas
   ============================================================================ */
.zonas-editor-overlay {
  position: fixed;
  inset: 0;
  background: #1f2937;
  z-index: 20000;
  display: flex;
  flex-direction: column;
}
.zonas-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #111827;
  color: #fff;
  flex-shrink: 0;
}
.zonas-contador {
  background: #374151;
  color: #fff;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
}
.zonas-editor-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}
.zonas-editor-lienzo-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow: auto;
}
.zonas-ayuda {
  background: #1e3a5f;
  color: #bfdbfe;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
  flex-shrink: 0;
}
.zonas-lienzo-wrap {
  position: relative;
  display: inline-block;
  margin: 0 auto;
  max-width: 100%;
  cursor: crosshair;
  user-select: none;
  touch-action: none;
}
.zonas-lienzo-img {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  user-select: none;
}
.zonas-capa {
  position: absolute;
  inset: 0;
}
.zona-rect {
  position: absolute;
  border: 2px solid;
  box-sizing: border-box;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  cursor: pointer;
}
.zona-rect-asignada {
  border-color: #16a34a;
  background: rgba(22, 163, 74, 0.18);
}
.zona-rect-vacia {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.18);
  border-style: dashed;
}
/* Zona propuesta por IA (aun sin confirmar): distintivo visual */
.zona-rect-ia {
  border-color: #a855f7;
  background: rgba(168, 85, 247, 0.15);
  border-style: dashed;
  animation: pulse-ia 1.8s ease-in-out infinite;
}
@keyframes pulse-ia {
  0%, 100% { border-color: #a855f7; background: rgba(168, 85, 247, 0.12); }
  50% { border-color: #c084fc; background: rgba(168, 85, 247, 0.22); }
}
.zona-rect-sel {
  border-width: 3px;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.4);
  cursor: move;
}
/* Handles de las esquinas para redimensionar (solo en zona seleccionada) */
.zona-handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: #0ea5e9;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  z-index: 10;
}
.zona-handle-nw { top: -7px;    left: -7px;   cursor: nwse-resize; }
.zona-handle-ne { top: -7px;    right: -7px;  cursor: nesw-resize; }
.zona-handle-se { bottom: -7px; right: -7px;  cursor: nwse-resize; }
.zona-handle-sw { bottom: -7px; left: -7px;   cursor: nesw-resize; }
.zona-rect-temp {
  border-color: #0ea5e9;
  background: rgba(14, 165, 233, 0.15);
  border-style: dashed;
}
.zona-num {
  background: #111827;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 0 0 6px 0;
  line-height: 1.4;
}
.zonas-editor-panel {
  width: 320px;
  flex-shrink: 0;
  background: #fff;
  padding: 16px;
  overflow-y: auto;
}
.zona-lista-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 13px;
}
.zona-lista-item:hover { background: #f9fafb; }
.zona-lista-num {
  background: #111827;
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.zona-lista-info { flex: 1; }
.zona-producto-actual {
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  font-size: 13px;
}

/* Responsive: en móvil/tablet vertical el panel va abajo */
@media (max-width: 768px) {
  .zonas-editor-body { flex-direction: column; }
  .zonas-editor-panel {
    width: auto;
    max-height: 40vh;
    border-top: 2px solid #e5e7eb;
  }
  .zonas-lienzo-img { max-height: 50vh; }
}

/* FASE 2.b': botón crear producto al vuelo en el autocomplete */
.ac-crear {
  padding: 12px;
  text-align: center;
  cursor: pointer;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 13px;
  font-weight: 600;
  border-top: 1px solid #dbeafe;
}
.ac-crear:hover { background: #dbeafe; }

/* ============================================================================
   FASE 2.c' — Zonas clicables del comercial (E3: invisibles, iluminan al tocar)
   ============================================================================ */
.visor-zonas-capa {
  position: absolute;
  inset: 0;
  pointer-events: none; /* la capa no bloquea; solo las zonas individuales */
}
.visor-zona {
  position: absolute;
  pointer-events: auto;   /* la zona SÍ es clicable */
  cursor: pointer;
  border: 2px solid transparent;
  background: transparent;
  border-radius: 4px;
  transition: background 0.3s ease, border-color 0.3s ease;
  box-sizing: border-box;
}
/* E3: cuando se ilumina la capa (al tocar la lámina), las zonas se hacen visibles */
.visor-zonas-iluminadas .visor-zona {
  border-color: rgba(14, 165, 233, 0.9);
  background: rgba(14, 165, 233, 0.22);
  animation: zonaPulso 0.6s ease;
}
@keyframes zonaPulso {
  0% { background: rgba(14, 165, 233, 0.45); }
  100% { background: rgba(14, 165, 233, 0.22); }
}

/* FASE 2.c'-2: modal al pulsar zona (producto + cantidad + plantillas) */
.zona-modal-producto {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
}
.zona-cantidad-rapida {
  display: flex;
  gap: 8px;
}
.zona-cant-btn {
  flex: 1;
  padding: 10px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
}
.zona-cant-btn:hover {
  background: #fdf2f8;
  border-color: var(--rosa-principal, #cc007a);
}
/* Controles de zoom del lienzo del editor de zonas */
.zonas-zoom-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
  flex-wrap: wrap;
}
.zonas-zoom-ctrl button {
  min-width: 34px;
  padding: 5px 10px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  color: #374151;
}
.zonas-zoom-ctrl button:hover { background: #f5f3ff; border-color: #a855f7; }
.zonas-zoom-ctrl #zonas-zoom-label {
  min-width: 46px;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  color: #374151;
}

/* Distintivo de estado de zonas en la fila de lámina (editor admin) */
.lamina-estado-zonas {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin: 2px 0;
}
.lamina-estado-zonas.ok { background: #dcfce7; color: #15803d; }
.lamina-estado-zonas.auto { background: #ffedd5; color: #c2410c; }
.lamina-estado-zonas.none { background: #f3f4f6; color: #9ca3af; }

/* Zona-enlace en el visor: se pinta como un BOTÓN visible (deliberado) */
.visor-zona-enlace {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2563eb;
  border: 2px solid #1d4ed8 !important;
  border-radius: 10px;
  box-shadow: 0 3px 10px rgba(37, 99, 235, 0.45);
  cursor: pointer;
  overflow: hidden;
  padding: 2px;
}
.visor-zona-enlace:active { transform: scale(0.97); }
.visor-zona-enlace-txt {
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.15;
  text-align: center;
  padding: 2px 6px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.35);
  white-space: normal;
  overflow: hidden;
}

/* Barra fija arriba mientras estás en un catálogo enlazado */
.barra-enlace {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99600;
  background: #1e3a8a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 14px;
  font-size: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}
.barra-enlace-info { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-enlace-btn {
  background: #fff;
  color: #1e3a8a;
  border: 0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.barra-enlace-btn:active { transform: scale(0.96); }

/* Selector de familia (color x graduacion) en el modal de anotar */
.zona-familia-selector {
  background: #faf5ff;
  border: 1px solid #e9d5ff;
  border-radius: 10px;
  padding: 12px;
}
.fam-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
.fam-chip {
  padding: 8px 14px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
}
.fam-chip:hover {
  background: #f5f3ff;
  border-color: #a855f7;
}
.fam-chip.sel {
  background: #a855f7;
  border-color: #a855f7;
  color: #fff;
}
.zona-plantillas {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.zona-tpl-chip {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  background: #fff;
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  color: #374151;
}
.zona-tpl-chip:hover {
  background: #eff6ff;
  border-color: #3b82f6;
}

/* ============================================================================
   MOSAICO — reordenar láminas en cuadrícula
   ============================================================================ */
.mosaico-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  background: #1f2937;
  z-index: 20000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.mosaico-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #111827;
  color: #fff;
  flex-shrink: 0;
}
.mosaico-ayuda {
  background: #1e3a5f;
  color: #bfdbfe;
  padding: 8px 16px;
  font-size: 13px;
  flex-shrink: 0;
}
.mosaico-grid {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  grid-auto-rows: min-content;
  gap: 14px;
  align-content: start;
}
.mosaico-card {
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
  position: relative;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  height: 250px;
  display: flex;
  flex-direction: column;
}
.mosaico-card:active { cursor: grabbing; }
.mosaico-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}
.mosaico-arrastrando {
  opacity: 0.4;
  border: 2px dashed #0ea5e9;
}
.mosaico-num {
  position: absolute;
  top: 6px;
  left: 6px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  width: 32px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: 6px;
  text-align: center;
  z-index: 3;
  padding: 0;
  cursor: text;
  font-family: inherit;
}
.mosaico-num:hover {
  border-color: #0ea5e9;
}
.mosaico-num:focus {
  outline: none;
  border-color: #0ea5e9;
  background: #0ea5e9;
  width: 48px;
}
.mosaico-img {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  object-fit: contain;
  background: #f3f4f6;
  display: block;
}
.mosaico-titulo {
  padding: 8px;
  font-size: 12px;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* ============================================================================
   Resumen pre-envío de visita (revisar antes de enviar emails)
   ============================================================================ */
.resumen-preenvio-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #f9fafb;
  z-index: 20500;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.resumen-preenvio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.resumen-preenvio-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
.resumen-preenvio-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
}
.resumen-tabla-wrap {
  overflow-x: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}
.resumen-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.resumen-tabla th {
  background: #f9fafb;
  color: #374151;
  padding: 10px 12px;
  border-bottom: 2px solid #e5e7eb;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 700;
}
.resumen-tabla td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
}
.resumen-tabla tr:last-child td { border-bottom: none; }
.resumen-tabla tfoot td { background: #f9fafb; }
.resumen-borrar-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 15px;
  padding: 4px 6px;
  border-radius: 4px;
  color: #6b7280;
}
.resumen-borrar-btn:hover { background: #fee2e2; color: #b91c1c; }
.resumen-otras-lista {
  list-style: none;
  padding: 0;
  margin: 0;
  background: #fff;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}
.resumen-otras-lista li {
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: #374151;
}
.resumen-otras-lista li:last-child { border-bottom: none; }
.resumen-borrar-mini {
  margin-left: auto;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #9ca3af;
  padding: 2px 8px;
  border-radius: 4px;
  line-height: 1;
}
.resumen-borrar-mini:hover { background: #fee2e2; color: #b91c1c; }
.resumen-acciones {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid #e5e7eb;
  flex-wrap: wrap;
}

/* Responsive móvil/tablet vertical */
@media (max-width: 600px) {
  .resumen-tabla th, .resumen-tabla td { padding: 8px 6px; font-size: 12px; }
  .resumen-cant-input { width: 50px !important; }
}

/* ============================================================================
   Búsqueda global (Ctrl+K + icono lupa)
   ============================================================================ */
.navtab-lupa {
  font-size: 16px;
  padding: 6px 12px;
}
.busqueda-global-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 21000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}
.busqueda-global-modal {
  width: 100%;
  max-width: 640px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}
.busqueda-global-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
}
.busqueda-global-header input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  background: transparent;
}
.busqueda-global-cerrar {
  cursor: pointer;
  font-size: 22px;
  color: #9ca3af;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  line-height: 1;
}
.busqueda-global-cerrar:hover {
  background: #f3f4f6;
  color: #374151;
}
.busqueda-global-resultados {
  flex: 1;
  overflow-y: auto;
  min-height: 80px;
  padding: 6px 0;
}
.busqueda-global-hint {
  padding: 16px;
  text-align: center;
  color: #9ca3af;
  font-size: 13px;
}
.busqueda-global-seccion {
  padding: 8px 18px 6px;
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  background: #f9fafb;
  border-top: 1px solid #f3f4f6;
}
.busqueda-global-seccion:first-child { border-top: none; }
.busqueda-global-item {
  padding: 10px 18px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.busqueda-global-item:hover { background: #fdf2f8; }
.bg-item-titulo { color: #111827; }
.bg-item-subtitulo {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}

/* ============================================================================
   Estadísticas por cliente (bloque en su ficha)
   ============================================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.stat-card {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 12px;
}
.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #6b7280;
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-valor {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  line-height: 1.1;
}
.stat-sub {
  font-size: 11px;
  color: #6b7280;
  margin-top: 4px;
}
.stats-top-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.stats-top-tabla th {
  background: #f9fafb;
  padding: 8px 10px;
  font-size: 11px;
  text-transform: uppercase;
  color: #6b7280;
  font-weight: 700;
  border-bottom: 1px solid #e5e7eb;
}
.stats-top-tabla td {
  padding: 8px 10px;
  border-bottom: 1px solid #f3f4f6;
}
.stats-top-tabla tr:last-child td { border-bottom: none; }

/* ============================================================================
   Dashboard admin
   ============================================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}
.dash-widget {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.dash-widget-full {
  grid-column: 1 / -1;
}
.dash-widget h3 {
  margin: 0 0 14px 0;
  font-size: 15px;
  color: #111827;
  display: flex;
  align-items: center;
  gap: 8px;
}
.dash-badge {
  background: #f3f4f6;
  color: #6b7280;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.dash-kpi {
  background: #f9fafb;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.dash-kpi-valor {
  font-size: 26px;
  font-weight: 700;
  color: #111827;
  line-height: 1;
}
.dash-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #6b7280;
  font-weight: 600;
  margin-top: 6px;
}
.dash-kpi-sub {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 4px;
}
.dash-lista {
  list-style: none;
  padding: 0;
  margin: 0;
}
.dash-item {
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  font-size: 13px;
}
.dash-item:hover { background: #fdf2f8; }
.dash-item:last-child { border-bottom: none; }
.dash-item-titulo {
  color: #111827;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.dash-item-sub {
  font-size: 11px;
  color: #6b7280;
  margin-top: 3px;
}
.dash-rank {
  display: inline-block;
  width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  background: #111827;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
}
.dash-vacio {
  color: #9ca3af;
  font-size: 13px;
  text-align: center;
  padding: 12px 0;
  font-style: italic;
  margin: 0;
}
.dash-mas {
  font-size: 11px;
  color: #6b7280;
  text-align: center;
  margin-top: 6px;
  font-style: italic;
}
.dash-tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.dash-tabla th {
  padding: 6px 8px;
  background: #f9fafb;
  color: #6b7280;
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  border-bottom: 1px solid #e5e7eb;
}
.dash-tabla td {
  padding: 6px 8px;
  border-bottom: 1px solid #f3f4f6;
}
.dash-tabla tr:last-child td { border-bottom: none; }

/* Toggle notificaciones email */
.notif-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.notif-toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #cc007a;
}
.notif-toggle-text {
  font-size: 14px;
  color: #374151;
}

/* ============================================================================
   AULA DE FORMACIÓN
   ============================================================================ */
.aula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.aula-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s ease;
}
.aula-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.aula-card-icono {
  font-size: 38px;
  text-align: center;
  background: #f9fafb;
  border-radius: 8px;
  padding: 10px;
  line-height: 1;
}
.aula-card-cuerpo {
  flex: 1;
}
.aula-card-titulo {
  font-weight: 600;
  color: #111827;
  font-size: 14px;
  margin-bottom: 4px;
  line-height: 1.3;
}
.aula-card-tematica {
  display: inline-block;
  background: #fdf2f8;
  color: #be185d;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  margin-bottom: 6px;
}
.aula-card-meta {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 6px;
}
.aula-card-desc {
  font-size: 12px;
  color: #4b5563;
  line-height: 1.4;
}
.aula-card-acciones {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  border-top: 1px solid #f3f4f6;
  padding-top: 10px;
}
.aula-card-acciones .btn {
  flex: 1;
  min-width: 0;
  text-align: center;
}

/* ============================================================================
   SISTEMA DE AYUDAS — Tooltips contextuales (?)
   Uso: <span class="ayuda-tip" data-tip="texto explicativo">?</span>
   Aparece al pasar el ratón o al recibir foco (táctil).
   ============================================================================ */
.ayuda-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e5e7eb;
  color: #4b5563;
  font-size: 11px;
  font-weight: 700;
  font-family: Arial, sans-serif;
  cursor: help;
  position: relative;
  margin-left: 6px;
  vertical-align: middle;
  user-select: none;
  border: none;
  outline: none;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
  /* Forzar overflow visible para que el tooltip pueda salir del contenedor */
  overflow: visible !important;
}
.ayuda-tip:hover,
.ayuda-tip:focus {
  background: #cc007a;
  color: #fff;
}

/* El globo aparece al hover o focus, encima del icono */
.ayuda-tip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #111827;
  color: #fff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  width: max-content;
  max-width: 280px;
  text-align: left;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Flecha apuntando hacia el icono */
.ayuda-tip::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #111827;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.ayuda-tip:hover::after,
.ayuda-tip:hover::before,
.ayuda-tip:focus::after,
.ayuda-tip:focus::before {
  opacity: 1;
  visibility: visible;
}

/* Variante: tooltip que se abre hacia abajo (cuando el ? está cerca del borde superior) */
.ayuda-tip.tip-abajo::after {
  bottom: auto;
  top: calc(100% + 8px);
}
.ayuda-tip.tip-abajo::before {
  bottom: auto;
  top: calc(100% + 2px);
  border-top-color: transparent;
  border-bottom-color: #111827;
}

/* Variante: tooltip que se abre hacia la izquierda (cuando el ? está pegado al borde derecho) */
.ayuda-tip.tip-izq::after {
  left: auto;
  right: calc(100% + 8px);
  bottom: 50%;
  transform: translateY(50%);
}
.ayuda-tip.tip-izq::before {
  left: auto;
  right: calc(100% + 2px);
  bottom: 50%;
  transform: translateY(50%);
  border-top-color: transparent;
  border-left-color: #111827;
}

/* ============================================================================
   BOTONES SELECTOR CALIDAD PDF (alta / pequeña para WhatsApp)
   ============================================================================ */
.btn-calidad-pdf {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 2px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
  width: 100%;
}
.btn-calidad-pdf:hover:not(:disabled) {
  border-color: #cc007a;
  background: #fef3f9;
}
.btn-calidad-pdf:disabled {
  cursor: wait;
}
.bcp-icono {
  font-size: 32px;
  flex-shrink: 0;
}
.bcp-cuerpo {
  flex: 1;
}
.bcp-titulo {
  font-weight: 600;
  font-size: 15px;
  color: #111827;
  margin-bottom: 2px;
}
.bcp-sub {
  font-size: 12px;
  color: #4b5563;
  margin-bottom: 4px;
}
.bcp-tam {
  font-size: 11px;
  color: #9ca3af;
}

/* ============================================================================
   CATEGORÍAS / TAGS - chips y selector
   ============================================================================ */

/* Chips de categoría en la fila de cada lámina (admin editor) */
.lamina-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
}
.lamina-cat-chip {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* Gestión de categorías en Configuración */
.cat-fila {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
}
.cat-color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid #00000010;
}
.cat-nombre-input {
  flex: 1;
  border: 0;
  font-size: 14px;
  font-weight: 500;
  padding: 4px;
  background: transparent;
  outline: none;
  font-family: inherit;
}
.cat-nombre-input:focus {
  background: #f9fafb;
  border-radius: 4px;
}
.cat-color-input {
  width: 32px;
  height: 32px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  padding: 2px;
}
.cat-cuenta {
  font-size: 11px;
  color: #6b7280;
  white-space: nowrap;
}

/* Checkboxes de categorías en modal editar lámina */
.cat-chip-edit {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 3px;
  padding: 5px 10px;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  cursor: pointer;
  font-size: 12px;
  background: #fff;
  user-select: none;
  transition: background 0.15s, border-color 0.15s;
}
.cat-chip-edit:hover {
  background: #f9fafb;
  border-color: #9ca3af;
}
.cat-chip-edit input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
}
.cat-chip-edit:has(input:checked) {
  background: #fef3f9;
  border-color: #cc007a;
}
.cat-chip-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* Chips de filtro en visor */
.visor-chips-cats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.visor-chip-cat {
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  color: #4b5563;
  transition: all 0.15s;
  white-space: nowrap;
}
.visor-chip-cat:hover {
  border-color: #cc007a;
  color: #cc007a;
}
.visor-chip-cat-activo {
  background: #cc007a;
  color: #fff !important;
  border-color: #cc007a !important;
}

/* ============================================================================
   BACKUP LOCAL DE PEDIDOS - lista
   ============================================================================ */
.backup-fila {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.15s;
}
.backup-fila:hover {
  border-color: #cc007a40;
  background: #fefcfd;
}
.backup-icono {
  font-size: 26px;
  flex-shrink: 0;
}
.backup-info {
  flex: 1;
  min-width: 0;
}
.backup-nombre {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.backup-meta {
  font-size: 11px;
  color: #6b7280;
  margin-top: 2px;
}
.backup-acciones {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
@media (max-width: 600px) {
  .backup-meta { font-size: 10px; }
  .backup-acciones { gap: 2px; }
  .backup-acciones button { padding: 6px 8px; font-size: 11px; }
}
