bad door line up

You said the top was almost flush. If top is out like the bottom, carefully move the latch post inward. If the door still needs adjusted at the hindges, loosen the door to hindge bolts the retighten one just snug. Close the door and bump it with your hand to move it on the one snug bolt. Carefully open the door and retighten all.