We all knew things were bad at the California Department of Motor Vehicles. But an eye-opening new state audit documents how shockingly bad.

The audit, by the state Department of Finance, paints a picture of management incompetence and antiquated computer systems that use a programming language more than half a century old.

The agency’s dysfunction is at the heart of why Californians have had to wait in lines for hours to renew driver licenses and register vehicles.

And why the Department of Motor Vehicles appointment system is a joke. On Thursday, the next available appointment in the San Jose, Oakland and Concord offices was nearly three months away. And be prepared to take time off from work because an appointment in the early morning or late afternoon is impossible.

Gov. Gavin Newsom has promised to clean up this mess. It will be a huge task. But it must be done — quickly — for the sake of the public and for the governor’s political survival.

It’s been nearly a year since monumental lines started snaking out of DMV offices. While some progress has been made, exactly how much is impossible to determine because, as the state audit makes clear, the DMV data on wait times is completely unreliable.

The DMV, which last fiscal year handled 38 million transactions, is one of the most public faces of the state’s bureaucracy. Most California adults deal with it at least once a year, either online, by mail or in person.

Yet, despite the importance of the agency, it is plagued by stunning organizational ineptitude. Examples from the audit include:

• Visits to 30 field offices found an average of about 30 percent of service windows closed during business hours. Little wonder lines are so long. The lack of reliable data on employee absenteeism might help explain part of the problem.

• The DMV calculates how many employees it needs statewide to meet the overall demand, but it lacks an effective system for allocating those employees to where they are most needed to handle demand and reduce customer wait times.

• DMV officials told auditors they had conducted an analysis to maximize the number of available customer appointments while maintaining acceptable wait times for those without appointments. However, they could not produce documentation of the analysis.

• DMV officials have known since 2005 that they would face a surge in demand when the federal government implemented tougher standards for identification cards to board domestic flights. They created a dedicated unit and director to prepare for the so-called “REAL ID” program, but discontinued that unit in 2009.

• DMV did not make the computer programming for REAL ID a priority until 2017. And security testing of the system was not performed before the agency started using it in January 2018.

• Assembler, the primary programming language used in DMV field office computer applications, was created around the 1950s and is less commonly used today. With a significant portion of the agency’s IT workers approaching retirement age, DMV faces a potential shortfall of workers with skills to program its computers.

• DMV’s classification system for its offices, which considers the size of the offices and the volume of transactions to allocate resources, was last approved in 1990.

Unfortunately, the administration’s response to the audit reads like business-as-usual. “Through these findings, along with upcoming recommendations by the DMV Strike Team,” Transportation Secretary Brian Annis said in a statement, “I am confident that the DMV will see improvement for both staff and customers in the years ahead.”

Years? Years! Californians won’t wait years. The sooner Newsom recognizes that, the less the chance that the DMV fiasco he inherited from Jerry Brown will become his political legacy as well.