The European Union is a historic compromise that’s gradually gotten stronger over its half-century existence.

Until 2016. That’s when British citizens, by a very narrow margin, voted to leave the European Union.

It’s hard to come up with Brexit’s price tag for the British. The administrative costs alone of the separation will be about $60 billion. But that’s nothing compared to the longer-term effect.

Much depends on the terms of the divorce.

A “hard exit” that doesn’t preserve U.K. access to Europe’s single market would mean the loss of hundreds of thousands of jobs as European businesses and financial institutions relocate to the continent. Also at risk is all the outside investment that’s flowed to the U.K. because of its connection to the European Union. U.S. business alone brought in $600 billion in 2015.

A “soft exit,” meanwhile, may preserve privileged access to the EU market, but only if the U.K. permits the free movement of people — exactly what motivated many British to push the reject button in the first place. Even this compromise may not save the British economy from weaker growth, higher unemployment and more debt.

Brexit might also cost Britain its very unity. Scotland, which overwhelmingly backed continued EU membership, has already indicated that it will push for another referendum on independence from the U.K.

In this lose-lose proposition, however, the EU might suffer the greater consequences.

With Brexit, the EU loses its largest military spender, one of its two U.N. Security Council seats, and its second most powerful IMF vote. The EU budget will also get hit hard since the U.K., as the second largest economy in the body, is also the second largest contributor: about $13 billion a year.

More important, the EU loses its reputation for inevitability. European integration has meant peace, prosperity and stability for the continent ever since the carnage of World War II. Indeed, after centuries of internecine slaughter in Europe, no wars have broken out among member states in the last 70 years. And the EU, collectively, is quite nearly the top economic performer in the world.

The prospect of eventual EU membership has even helped to repair the links among the warring parts of what had once been Yugoslavia. Former members of the Soviet Union have joined the EU, while other parts (like Ukraine and Moldova) dream of one day joining with their western cousins.

Not everyone, however, values the EU.

Brexit has encouraged far right-wing, anti-immigrant, and Islamophobic groups such as the National Front in France and the Freedom Party in The Netherlands to pursue their own anti-EU agendas. Both Vladimir Putin and Donald Trump have supported these Euroskeptics for their own narrow, nationalist purposes as well.

Let’s be honest: There are good reasons for the British, or anyone else in Europe, to be disenchanted with the EU. It’s not a particularly democratic institution. A cadre of officials in Brussels make most of the important decisions, and the European Parliament doesn’t have sufficient authority to serve as a popular check on that power.

On the economic side, the EU has gradually moved away from its social democratic origins to remove barriers to the flow of capital. The rules for Eurozone members make it very difficult for national governments to use traditional levers such as deficit spending to overcome economic crises.

Moreover, instead of helping poorer member states attain the level of their richer cousins as it once did, the EU has watched countries like Greece and Spain fall further behind, while Eastern European members have failed to close the gap with the West after more than a quarter century.

But reasons for disenchantment are not the same as reasons for disengagement. After all, the EU remains a far greener and more equitable economic space than the United States. Brexit is a wake-up call for proponents of European integration to transform the EU into a more perfect union: by making its political structures more accountable and its economic benefits more evenly distributed.

The U.K. could have been part of this solution by advocating for such reforms. Instead, it’s part of the problem. Let’s hope that the EU can get its act together before it suffers another defection. The continent’s peaceful and prosperous future depends on it.