(Reuters) - Mattel Inc posted a surprise fourth-quarter profit on Thursday, as the toymaker benefited from a makeover of its iconic Barbie doll, while keeping a tight lid on costs, sending its shares soaring 19 percent in extended trading.

FILE PHOTO - Barbie dolls are seen inside the new flagship FAO Schwarz store in Rockefeller Plaza in New York, U.S., November 16, 2018. REUTERS/Shannon Stapleton

Barbie ended the year with its highest gross sales in five years, Mattel said, highlighting the company’s success in diversifying the traditionally blonde doll by giving it different skin tones and dressing it in attires ranging from hijabs to space suits.

“Barbie has got every career a girl could aspire to and especially in the current environment ... female empowerment is huge and that’s really helping Barbie do well at retail,” said Jackie Breyer, editorial director at trade magazine the Toy Book.

The Barbie Dreamhouse, which retails for $200, was among the top ten best-selling toys in the United States in 2018, according to market research firm NPD group.

Gross sales rose 12 percent for Barbie and 9 percent for Hot Wheels in the fourth quarter, handily beating analysts’ estimates for both brands.

To tap into the renewed popularity of the doll, Mattel has partnered with Warner Bros. to make a live-action feature movie on Barbie, starring Oscar-nominated actress Margot Robbie.

COST CONTROL

The company also benefited from its plans to streamline its operations, with costs falling 27 percent to $814.7 million in the quarter.

Mattel has been aiming to cut at least $650 million in net costs by the end of 2019 through job cuts and other measures such as looking at options for its manufacturing facilities.

“Restoring profitability for the company this year has been the core focus,” Chief Executive Officer Ynon Kreiz told Reuters, adding that he expects Mattel to exceed its cost-saving target.

Mattel reported net income of $14.9 million, or 4 cents per share, in the quarter ended Dec. 31, compared with a loss of $281.3 million, or 82 cents per share, a year earlier, when it took a one-time charge related to changes in U.S. tax laws.

Analysts had expected a loss of 16 cents per share, according to IBES data from Refinitiv.

However, gross sales in North America fell 10.1 percent to $744.5 million, reflecting Mattel’s struggles with finding a major retailer to make up for lost sales from the shuttering of Toys ‘R’ Us.

Overall, Mattel’s net revenue fell 5.4 percent to $1.52 billion, but was still above analysts’ estimates of $1.44 billion.