MIAMI has drifted south. That is the impression you get flying over the seafront skyscrapers into Panama City’s Tocumen international airport, where rich Latin Americans—especially crisis-racked Venezuelans—arrive looking for a bolthole to work, play and go shopping.

Like Miami, Panama wants to be Latin America’s business hub. Its canal is becoming the backbone of a transoceanic logistics network. Its airline, Copa, connects much of Latin America. Its offshore-banking sector sucks in Latin American money, some of it because Miami’s money-laundering regulations have become too strict.

Yet Panama remains rough enough around the edges that in the past five years Ricardo Martinelli, its supermarket-magnate-turned-president, has found plenty to splurge on. Public investment, including a $5.2 billion expansion of the canal, has been a whopping $19 billion. That is not far short of Panama’s $24 billion GDP when he took office in 2009. The spending spree has seen growth average 8% annually during his term in office.

Little wonder that during his tenure Mr Martinelli maintained high poll ratings. Yet on May 4th his hand-picked candidate to succeed him lost heavily in elections. Making things worse for the outgoing president, the victor, Juan Carlos Varela, is his vice-president turned arch-enemy.

Mr Varela, whom no opinion poll had tipped to win, took 39% of the vote compared with 31% for José Domingo Arias, Mr Martinelli’s protégé. On the campaign trail, Mr Varela chipped away at Mr Arias’s credibility by portraying him as the president’s puppet. This played well with voters who retain bitter memories of Manuel Noriega’s military dictatorship in 1983-89. They worried that Mr Martinelli was stealthily trying to keep his hands on the levers of power, especially after his wife was chosen as Mr Arias’s running-mate.

Mr Varela, the scion of a rum dynasty, also campaigned on a pledge to clean up politics. “The game’s over for those who see politics as a business, not a service,” he says. This is a direct dig at Mr Martinelli’s administration, among others. During the campaign, press reports said Italian prosecutors had linked the president to an alleged €18m ($25m) scandal involving contracts to do business in Panama. Mr Martinelli has publicly ridiculed the allegations, as has his attorney-general.

Mr Varela says he will appoint a new attorney-general after taking office on July 1st and would like him to launch an investigation. But whether he will really try to make a spectacle of Mr Martinelli is a matter of debate. His coalition won only 12 seats in the 71-seat National Assembly; Mr Martinelli remains head of the party with the biggest bloc of 30 seats.

The new president has other balancing acts to perform. Under Mr Martinelli, Panama City received a new metro, a giant causeway around the old part of town and a jungle of new skyscrapers. But urban planning has not kept pace. In the tallest buildings, electricity and water are rationed. When it rains, the streets around them overflow because the drainage system cannot cope.

Mr Varela says he will keep spending $3 billion a year on public investment, which he hopes will generate 7% growth. Instead of pouring concrete, though, many multinationals would like him to spend the money on education, especially English-language training, to generate workers capable of staffing the new office towers.

As it is, the economy is in danger of overheating. Last month construction workers launched a general strike in pursuit of huge pay increases, which has left the project to enlarge the Panama Canal paralysed for the second time this year (the first occasion was a row with a construction consortium about cost overruns). Mr Varela has promised to tackle rising food prices with draconian controls in at least the first six months of his administration. That raises questions about his commitment to free-market policies. “Straight-up Venezuelan-style price controls are not a winning strategy,” says one analyst.

His other priority, to change the constitution to strengthen the independence of the Supreme Court, the comptroller-general and other organs of government over which Mr Martinelli sought to centralise control, wins a warmer reception. Mario Cuevas, who works for the Inter-American Development Bank, says that “one of the best investments from now onwards is in strengthening institutions.”