How the heck do they make a profit?

Okay, so, I went to a new car dealer a few weeks ago and and learned something that still has me reeling. Apparently "the days of making [any profit, really?]" Are over. The manager allegedly showed me the invoice, and they were looking at a $400 difference between what they paid for it and their sticker price. Which seems like it should be impossible to make a profit from. How? How the hell do the make any profit, and how do I keep from getting screwed?