AT ONE of Target’s shops in downtown Chicago, one recent weekend, customers congregated in the electronics department and the area that sells towels and bedding. Upstairs, the women’s clothes department was almost deserted. A quick examination of its stock revealed why: dowdy dresses, garish sweaters and jackets that any reasonably fashion-conscious woman under 60 would surely spurn.

For many shoppers, Target no longer hits the spot. In its annual results this week it admitted that the cost of retreating from a disastrous foray into Canada, and of closing underperforming shops in America, would be a whopping $5.1 billion.

It is an astonishing reversal of fortune. A decade ago Target had such a chic image that people called it “Tar-zhay” with a faux French accent. The Minneapolis-based discounter thrived after reinventing itself as a seller of designer-label clothing at affordable prices. It teamed up with designers such as Alexander McQueen, Proenza Schouler and Zac Posen, and attracted young, predominantly female shoppers with higher disposable incomes than those who usually go to discounters.

But in 2011 Target’s growth began to slow, and margins to shrink. Its designer lines had seemingly lost their sparkle, and the rest of its clothing range never was that impressive. The squeeze on Americans’ real incomes did not help, but it struggled to keep up with the rise of “fast-fashion” retailers such as Uniqlo and Zara.

Dissatisfied with its online sales, which it had been outsourcing to Amazon since 2001, Target took direct control of them, launching a slick new website. But by then its rivals were ahead of it in e-commerce. Target also expanded its food offering, hoping to coax shoppers to visit more often—and buy a higher-margin item such as a sweater even if they had only popped in for some milk. Great theory; didn’t work in practice. “They became too focused on food and consumables, and lost their Tar-zhay cachet,” says Brian Yarbrough of Edward Jones, an investment firm.

Things got far worse in 2013. During the pre-Christmas shopping season, the company suffered a massive hacking attack that compromised credit-card and other details of up to 70m customers. Shoppers deserted its stores, and profits plunged.

Meanwhile Target’s newly launched Canadian operations began bleeding money. “The Canadian debacle was a symptom of a broader set of problems,” says Sarah Kaplan, professor of management at the University of Toronto. Target seems to have stopped listening to its shoppers. The American executives it put in charge of the shops in Canada did not understand that Canadians tend to shop “off the flyer”: special-offer leaflets are the most effective way to tempt them into a store.

Last May Gregg Steinhafel, the chief executive, was shown the door. His successor, Brian Cornell, was horrified to find, on an unannounced visit to some of the Canadian shops, that they were deserted on the Saturday before Christmas. He concluded that all 133 stores north of the border must shut. Target’s first international expansion had ended in defeat.

Target’s share price has recovered sharply in recent months, as confidence has grown that Mr Cornell can turn it around. But there is much to be done. David Schick of Stifel, a stockbroker, says it needs to go back to “differentiated discount”, which means offering a selection of desirable items—a trendy handbag, say, or a novelty watch—which no rival is selling. The food department needs a facelift too, says David Strasser of Janney Montgomery Scott, a financial-services firm. He thinks Target should try to be more like Trader Joe’s, a thriving own-label supermarket chain that is part of Aldi, a German discount-grocery giant.

Target also needs to catch up with its more successful peers in becoming an “omni-channel” retailer, offering customers a seamless choice of how to shop: in stores, on internet browsers or on smartphone apps. It has only recently begun to switch its emphasis from huge, out-of-town stores towards smaller, more central ones that provide a “click-and-collect” service for online and smartphone orders.

Mr Cornell has made a good start, but it is far from certain that Target can return to its glory days in the home market. As for venturing abroad again, it would face so many nimble and successfully globalised rivals that its chances would be slim.