Why I don’t understand federal financing

The feds had a huge debt in the late 1990s. But their budget was less than their revenues. So they declared a budget surplus even though that pesky trillion dollar debt still existed. I don’t get it. If you still owe money, how do you have a surplus? And why can’t I balance my budget that way?