Detroit, you're not alone.
Across the nation, cities and states are watching Detroit's largest-ever municipal bankruptcy filing with great trepidation. Years of underfunded retirement promises to public sector workers, which helped lay Detroit low, could plunge them into a similar and terrifying financial hole.
A CNBC.com analysis of more than 120 of the nation's largest state and local pension plans finds they face a wide range of burdens as their aging workforces near retirement.
Thanks to a patchwork of accounting practices and rosy investment assumptions, it's not even clear just how big a financial hole many states and cities have dug for themselves. That may soon change, thanks to a new set of government accounting standards that could serve as a nasty wake-up call to states and cities relying on rosy scenarios and head-in-the-sand accounting.
Even less clear is who will pay to clean up the messes. Will it be the millions of retirees owed trillions of dollars in benefits, the bondholders who lent states and cities trillions more, or local taxpayers who may have to pay more to cover the shortfalls or see deeper cuts in public services?
Regardless, the painful process will likely play out for years.
"Moving pension plans is like steering a blimp: You turn the wheel and you go 6 miles before it starts to turn," said John Tuohy, Arlington County, Va., deputy treasurer, who chairs the pension committee of the Government Finance Officers Association. "In the political process, that kind of patience is very difficult."
Many state and local governments have set aside enough money to comfortably make good on promised retirement benefits. Seventeen states have funded more than 80 percent of their projected pension liability, a level that's generally seen as financially sound. Most of the rest have been scrambling to make up investment losses inflicted by the 2008 market collapse and the shortfalls in sales, property and incomes taxes produced by the Great Recession.
But even as the economy and housing markets have recovered, most states are still falling behind in closing their pension funding gaps. In the last year, 34 states have seen their pension funds stretched further as they've failed to make the full contributions needed to meet the projected cost of retirement promises.
Much like a family that fails to save regularly to build a retirement nest egg, shortchanging those contributions increases the risk that the fund eventually will go broke.
(Read more: If Detroit cuts pensions, will your city be next? )
Nine states-Hawaii, Alaska, Kansas, Rhode Island, New Hampshire, Louisiana, Connecticut, Kentucky and Illinois-have now set aside less than 60 percent of what they need. Illinois has saved just 43 cents to cover every dollar of what it needs to pay 350,000 retirees and 500,000 current plan participants who are counting on a pension check.
In Detroit, city officials argue that pension payments to retirees simply have to be cut because the money just isn't there to pay them. But union officials there and in other cash-strapped cities say that's the city's problem.
"Our members were promised certain things," said Tom Ryan, president of the firefighters' union in Chicago, where years of underfunding have prompted proposals to cut workers' retirement benefits. "They enter dangerous situations every day, and the only thing they want to look forward to when they can no longer perform their duties is to be able to retire with some sort of security. People expect us to be there, and we are always there. We expect that the city holds up their end of the bargain when we signed on to be firefighters and paramedics for the city of Chicago."
Without a pension check, public sector workers face a bleak retirement. Many are ineligible for Social Security.
"If we were talking about doing this to people with Social Security there would be rioting in the street," said Ryan. "But because it's public servants on pensions it seems to be OK to do this."
Most cities and states with funding gaps still have time to fix the problem. Of the roughly 20,000 municipalities in the country, only a handful have completely run out of cash and been forced to seek shelter in bankruptcy court.
(Read more: Detroit joins list of failed US towns )
What's less clear is whether those states and cities have the political will to make the necessary, unpopular decisions, according to Jean-Pierre Aubry, assistant director of state and local research at the Center for Retirement Research at Boston College.
"Even the ones that are really up against it have somewhere around 10 to 15 years of a window to turn things around," he said. "That's not a whole lot of time. And it's not clear if these governments that couldn't make contributions when times were good and the economy was better will be able to make them now or going forward."
That political challenge is playing out in Illinois, where a $95 billion pension fund gap has deadlocked the state legislature over reform proposals for two years. In March, the nation's fifth most populous state settled with the Securities and Exchange Commission after the agency charged Illinois with fraud for misleading bond investors about its pension funding problems between 2005 and 2009.
After lawmakers adjourned in May without fixing the problem, the state's credit rating was slashed, raising future borrowing costs. Earlier this summer, Gov. Pat Quinn used a budget line-item veto to freeze lawmakers' salaries effective August. Last week, the Illinois House speaker and Senate president hauled Quinn into court to get their pay restored.
Such gridlock only increases the cost of fixing the problem. As pension payments consume a greater share of tax dollar-for example, Illinois' badly underfunded pensions now consume a fifth of the state's revenues-other services are starved of funds.
"This is happening in too many cities and towns across America, where social services, because they can be cut, are cut, financial analyst Meredith Whitney, CEO and founder of Meredith Whitney Advisory Group, told CNBC: "(But) because pensions and bonds constitutionally cannot be cut, they're the protected class. I think you're going to see a real issue of neighbor against neighbor on these very issues."
But as Detroit has demonstrated, budget-balancing service cuts only lower the quality of life in a community, chasing residents away and further eroding the tax base. Raising taxes, on the other hand discourages new business expansion, further reducing revenues. For cities and states that have failed to fund their pension promises, it's a vicious cycle.
To be sure, many jurisdictions have avoided falling into that the trap by keeping up with their pension promises.
Even after sustaining heavy losses in the 2008 stock market crash, seven states-Wisconsin, South Dakota, North Carolina, Washington, New York, Tennessee and Delaware-have set aside more than 90 percent of their estimated future pension payments.
"There are great stories about the cities and towns that are doing well that are investing in key things and being mindful of their fiscal discipline," said Whitney.
Assessing the financial health of a jurisdiction is compounded by the fuzzy math used to calculate just how much a state or city needs to set aside to meet its pension promises.
Even in the best of times, pension accounting is fertile ground for voodoo economics and political expediency because those projections are based on a series of all but unknowable assumptions. It's hard to predict with precision, for example, just how many years of service a current employee will accumulate or how many checks they'll collect in their lifetime.
Future pension cost estimates have been made more problematic by a common practice known as "spiking"-in which retirement-ready workers rack up hours of overtime and apply unused vacation to swell their last paychecks to lock in a higher monthly pension payment.
Managers of many underfunded plans have come up with a neat trick to make the problem seem to disappear. By simply assuming a higher investment return in the future, they can lowball the reported amount needed to meet future payments.
Even as low interest rates have badly depressed investment performance, many fund managers continue to project returns of 8 percent or higher.
In 2011, the latest data available, the 100 largest public pension funds projected an average return of 7.84 percent. But their actual return over the prior 10 years was just 5.6 percent a year, according to a survey by Pensions and Investments, a trade publication.
Eventually, those assumptions come home to roost, according to Rhode Island state Treasurer Gina Raimondo, who helped shepherd an overhaul of the state's ailing pension system in 2011.
"Real people get hurt when politicians aren't honest and realistic about the magnitude of these issues," she said. "If you use a set of assumptions that makes the problem look smaller on paper today, that's irrelevant 10 years from now when the cash runs out and someone needs a pension check."
Many fund managers also use a technique called "smoothing"-which allows them to book investment gains and losses slowly for as long as five years. In good times, the scheme lets state and city officials ride a bull market years after it's over, underfunding pensions to pay other government expenses, cut taxes or increase pension benefits without paying for the added longer-term cost.
"The boom of the '90s was probably the worst thing that happened because (states and cities) ended up with a number of overfunded plans," said Arlington County's Tuohy. "And promises were made based on those overfunded plans."
But smoothing also prolongs the pain of a severe market downturn, including heavy losses like those sustained in the 2008 market collapse. Thanks to smoothing, the burden of those investment losses continues to weigh on pension funds even as the stock market has recovered in the past year.
That's one reason the Government Accounting Standards Board, which sets the bookkeeping rules for pension plan managers, has banned smoothing and requires underfunded plans to put away their rose-colored glasses when estimating future investment returns.
When implemented next year, the new rules will paint a bleaker funding picture, cutting the average funding ratio of assets to liability, which stood at 75 percent in 2011, to 57 percent, according to a study by the Center for Retirement Research.
Bond rating agency Moody's recently issued its own state-by-state reality check, based on its estimates of "adjusted" pension fund shortfalls that better reflect the new accounting realities.
Moody's figures that 15 states are in better shape than the current reporting rules would indicate. The rest have bigger liabilities (some much bigger) than found in their current financial statements. Based on the adjusted funding gaps, nine states-Massachusetts, Pennsylvania, Colorado, Louisiana, Hawaii, New Jersey, Kentucky and Connecticut-would see their funding liabilities exceed an entire year's worth of state revenues. In Illinois, the adjusted funding gap amounts to 241 percent of state revenues.
Since the Great Recession officially lifted in 2009, all 50 states have undertaken ever-more intense reforms as the pension funding problem deepened. This year alone, more than 1,200 bills have been introduced covering a range of fixes.
The list includes suspending cost of living increases for retirees and shifting some of the investment risk on future retirees with the addition of a defined contribution plan similar to a 401(k). Some states have gone further by raising employee contributions or shifting the entire burden onto new workers with defined contribution plans.
"That deals with the next generation," said Verne Sedlacek, president of Commonfund. "But we've got this whole group of people who worked for city and state governments for decades who had an expectation of payment. And they can't be paid."
The most drastic reforms also leave jurisdictions at a marked disadvantage when they go to recruit the next generation of police, firefighters and teachers. Because cuts to public pension plans haven't been offset with wage increases, they leave public workers making about 20 percent less than their counterparts in the private sector, according to a Center for Retirement Research study.
"So you now have two people with the same human capital-and the one in the private sector makes 20 percent more than the one in the public sector," said Boston College's Aubry. "The question is how are you going to attract and retain quality public sector employees with that disparity?"
-By CNBC's John W. Schoen. Follow him on Twitter @johnwschoen.
More From CNBC