Shares of electric-car pioneer Tesla (TSLA 1.85%) surged 16% on Thursday, following the company's second-quarter earnings report. Tesla predicted that production of its Model 3 sedan will continue to rise steadily in the coming quarters, while earnings and cash flow will turn positive. It didn't hurt that CEO Elon Musk seemed even-keeled during Tesla's earnings call -- and even apologized for shutting down analysts' questions on the first-quarter call.

Still, many bears were flummoxed by Tesla stock's big jump, given that the company posted a record loss last quarter. However, the massive loss can be explained by launch costs related to ramping up Model 3 production. Investors should be far more concerned about management's forecast that Model 3 gross margin will remain below 25% through the end of 2018.

Tesla lost a lot of money last quarter

On Wednesday, Tesla reported a net loss attributable to common stockholders of $718 million for the second quarter of 2018. That was slightly greater than its first-quarter loss and more than double the loss it recorded in the year-earlier period. Results didn't look much better on a non-GAAP basis, either, as Tesla's loss more than doubled year over year to $520 million, or $3.06 per share.

Tesla's net loss was somewhat bigger than what most analysts had projected. That said, the company predicted it will turn profitable in the back half of the year, despite an expected headwind from higher Chinese auto tariffs. While that forecast isn't new, many investors have been skeptical that it was achievable.

A Tesla Model S

Tesla expects to turn profitable in the second half of 2018. Image source: Tesla.

However, it makes sense that Tesla would see a sharp improvement in profitability during the second half of 2018. The company expects to nearly double Model 3 production this quarter compared with the second quarter, which will help it cover fixed costs and boost gross margin.

Gross margin is finally rising

In the first quarter of 2018, Tesla's gross margin for Model 3 production was negative. In other words, Tesla wasn't even covering all of its production costs for the Model 3, let alone paying for development costs, selling expenses, or corporate overhead. Last quarter, "Model 3 gross margin turned slightly positive," according to the company.

Tesla expects dramatic improvement on this front in the second half of 2018, due to higher production -- it expects to build 50,000 to 55,000 Model 3s this quarter -- and the introduction of the pricier dual-motor and performance variants. Tesla says Model 3 gross margin is likely to reach 15% in the third quarter and 20% in the fourth quarter.

This outlook would appear to put Tesla on track to hit its 25% gross margin target sometime in 2019. That's just what the company says it expects.

This vehicle mix is unsustainable

While Model 3 gross margin is set to improve dramatically over the next two quarters, it still isn't clear that the 25% goal is within reach. It's important to note that Model 3 gross margin is being boosted by a mix heavily tilted toward the most profitable versions in the second half of 2018. This rich mix is clearly unsustainable.

As I have previously noted, the cheapest Model 3 variant currently available costs $49,000, far more than the base price of $35,000. With the dual-motor and performance versions having entered production recently, the Model 3 average transaction price could easily be around $60,000 in the second half of 2018.

There is clearly a meaningful pool of demand for Model 3s in this price range. Nevertheless, the vast majority of buyers can't afford to spend this much -- especially as the U.S. electric-vehicle tax credit phases out for Tesla purchases.

A Tesla Model 3

The Model 3 versions currently being sold are too expensive for most consumers. Image source: Tesla.

Indeed, there are hundreds of thousands of Tesla customers in the U.S. and Canada who have ordered or reserved a Model 3. Customers who want to buy dual-motor or performance variants have had a big incentive to place their orders ASAP, since the tax credit will start to phase out on Jan. 1. Instead, Tesla has opened up ordering to non-reservation holders, with a lead time of just a few months, or roughly one quarter. This move implies that far fewer than 100,000 reservation holders have placed orders. The rest are waiting for cheaper Model 3 versions to become available -- or have decided to cancel their reservations.

A downshift in the model mix will hurt profitability

Options and upgrade packages typically carry very high margins for automakers. If Tesla expects to earn a $12,000 gross profit on a $60,000 car by the fourth quarter, a 20% gross margin, it's likely that it would only break even on a $35,000 base model.

Tesla will probably be able to squeeze out some additional cost efficiencies in 2019. But given that it already expects to be building 6,000 Model 3s per week by the fourth quarter, there will be limited room for gross margin improvement. To look at it another way, going from producing an average of 4,000 Model 3s per week in the third quarter to 6,000 per week in the fourth quarter is expected to lift gross margin from 15% to only 20%.

Meanwhile, the production mix is likely to shift dramatically toward cheaper models next year. This could more than offset Tesla's underlying cost reductions. As a result, Tesla probably won't be nearly as profitable as it expects.