ASKED what he thought of Donald Trump’s plan to build a wall on the border, a Mexican official smiled and reached for his smartphone. He called up a map of Mexico in 1824, when it included California, Texas and most of what is now the southwestern United States. We’ll gladly pay for a wall on that border, he joked.

For most Mexicans, the prospect of a Trump triumph—however unlikely—is less amusing. The Republican nominee says he would slap a 35% tariff on Mexican goods and maybe scrap the North American Free-Trade Agreement (NAFTA). Just the tariff would hit Mexico like a hurricane, says the central bank’s governor. Other economists think it would quickly knock 5% off Mexican GDP. The Peterson Institute, a think-tank in Washington, DC, predicts that Mr Trump’s protectionist policies would spark a trade war, push America into recession and destroy 4.8m American jobs by 2019.

A visit to the sunny sister cities of Tijuana (in Mexico) and San Diego (in California) gives a sense of what is at stake. The border that bisects them is the busiest in the Western hemisphere. Mexicans cross it to work, shop and visit friends. Americans head south for beaches and cheap dentistry. Kevin Faulconer, San Diego’s Republican mayor, is keen to encourage cross-border business. “My job is to take away roadblocks,” he says.

Such trade has risen more than sixfold since NAFTA passed (see chart). Mexico is America’s second largest export market; America is Mexico’s largest. The two countries “no longer simply sell finished products to one another. Instead, they build things together,” note Christopher Wilson and Duncan Wood of the Wilson Centre, a think-tank; they pool their comparative advantages to create an “ultra-competitive” regional economy.

In a gigantic factory in Tijuana, for example, hundreds of blue-uniformed workers assemble headphones and headsets. Many stare at screens that magnify the tiny components, so they can see what they are fiddling with. Plantronics, the American firm that owns the factory, is consistently voted one of the best employers in Mexico. It illustrates a trend that makes Mexico especially useful for American manufacturers: mass customisation. Consumers increasingly want to personalise purchases—from made-to-measure golf clubs to cars with cool gadgets—and have them delivered straight away. This is easier when they are made nearby. Plantronics lets customers choose colours and designs (“power blue” and sweat resistant, for example), and ships them to America and Canada within 48 hours. “Today’s production goes across the border tomorrow,” says Jorge Ruvalcaba, a vice-president of the firm. “We couldn’t do that from China.” Manufacturing in Mexico has become more attractive since wages for factory workers in China started to soar around 2010. (Mr Ruvalcaba adds that intellectual property is safer in Mexico, too.) The most sophisticated work tends to be done in the United States. But companies do not simply marry American brains with cheap Mexican brawn. Mexico produces more engineering graduates, relative to its population, than the United States, and has strong vocational training. Thermo Fisher Scientific, an American medical-technology firm, uses geeks in Tijuana to write software that helps doctors make sense of data generated by medical devices. Mexico cannot match China’s scale when it comes to mass-producing cheap goods. But it is well placed to offer services that are often more profitable. For example, 3DR, a firm based in Berkeley, California, sells aerial drones that are used to survey construction sites. The machines are assembled in China but the firm has a tech-savvy, English-speaking workforce in Tijuana to test them, repair them and offer technical support to customers. The real value is not the drone itself but the software and services that come with it, says Chris Anderson, the boss of 3DR (and a former journalist for The Economist).

The employment machine

Cross-border trade boosts jobs. Theodore Moran and Lindsay Oldenski of the Peterson Institute find that between 1990 and 2009, a 10% increase in employment at US firms’ Mexican operations was associated with a 1.3% increase in their US workforce. Granted, the new jobs tend to be for skilled workers, and some unskilled ones lose out. But everyone benefits from lower prices. If an American family saves $100 buying a washing machine made in Mexico and uses that money to go to the cinema, it supports the jobs of the ticket-seller, the cinema manager “and maybe even Brad Pitt”, argue Mr Wilson and Mr Wood.

Border businessfolk offer varying views of Mr Trump’s plan to disrupt this delicate ecosystem. Some are sure he will lose. Some are scared to speak up—unsurprisingly, given Mr Trump’s habit of chastising named firms for making things in Mexico. Others are openly aghast. “We’d have to shut down,” says one manager. The effect on the region would be “horrific”, says Mark Cafferty, head of the San Diego Regional Economic Development Corporation, a trade body. Cristina Hermosillo, his counterpart from Tijuana, agrees. This month the San Diego Union-Tribune, a conservative daily, endorsed Hillary Clinton—the first time in 148 years that it has backed a Democrat for president.

Mr Trump has already hurt Mexico. “Integration has been put on hold for a year,” says Sárah Martínez Pellégrini of the College of the Northern Border in Tijuana. “Just the possibility of a Trump victory makes Mexico less attractive for foreign investors.” And Mrs Clinton, fighting off Mr Trump and Bernie Sanders, her Democratic primary rival, has grown more protectionist (at least, in public). So a trans-Pacific trade deal, which would boost both Mexico and the US, is on hold. On the plus side, by depressing the peso, Mr Trump has made remittances from Mexicans in the US more valuable. Gracias, Señor Trump.