I remember staying in the black even incomewise while finishing 100%.

key is judicious amount of military and also developed farming.

while enjoying the benefits of trade, you should be maxing farming so that when you lose it, you'll still be in business.