Note on company-mode overlay pop-up
By default, the company-mode pop-up that lists completion candidates is drawn using an overlay. This creates alignment issues every time it is placed above a piece of text that has a different height than the default.
The solution recommended by the project’s maintainer is to use an alternative front-end for drawing the pop-up which draws child frames instead of overlays.[1][2]
Also consider the corfu package.