After years of profitability and reliable service, Delta Air Lines struggled mightily last week with two basic functions of its business -- flying airplanes and accommodating passengers.

Severe weather that pounded Atlanta in the middle of spring break caused a five-day meltdown across Delta's flight network, leaving passengers fuming and its own crews waiting for instructions.

The weather is, of course, out of Delta's control. But the chaos was amplified by the phenomenal complexity of running a modern-day mega-airline, according to interviews with Delta pilots, flight attendants and other staffers.

The episode was out of character for America's second-biggest carrier. Its chief operating officer, Gil West, apologized and said the recovery from the storm had "not been ideal."

Delta canceled more than 3,500 flights from Wednesday through Sunday. By Monday, the airline was getting back to normal, a spokesman said, but the effects of the storms still lingered.

Storms early in the week had left Delta vulnerable, but Wednesday brought the wildest weather. High wind and hail hit the Southeast -- hundreds of reports in all, including tornadoes. The ramp at Atlanta's Hartsfield-Jackson International Airport, Delta's home base, closed five separate times after seven rounds of thunderstorms rolled through. West called the storms "unprecedented."

Airplanes were already packed with spring break travelers, leaving little room on other flights to accommodate stranded passengers. Some passengers had four flights canceled.

Delta called in staff from headquarters to volunteer. It even bought 700 pizzas for passengers. But the breakdown wore on.

One reason was that Delta often takes extreme measures to avoid canceling flights. This time, it only left the airline with even more headaches.

Canceling flights early allows an airline to stop and reset rather than chasing the delay, which cascades across the network. Opting for long rolling delays on Wednesday instead of cancellations in many cases amplified the problem for Delta by putting crews and planes out of position for their next runs.

For crews, delays mean the next flight might be delayed waiting for them. And crews routinely jump from plane to plane, rather than staying paired with an aircraft hopping from city to city. If the delays pile up, crews "time out" on tightly regulated work rules. They can only work a certain number of hours in a row, and must have a certain number of hours off between flying.

The storms were "so drawn out on Wednesday that they couldn't keep up, and started losing track of where people were," one Delta flight attendant said.

It set the stage for what a senior Delta operations leader "one of the most challenging recovery efforts we've seen as an airline."

"Without the ability to flow traffic in/out of Atlanta for the majority of Wednesday, the recovery has taxed every resource, system and process we have," the official wrote in an internal message to employees.

A Delta spokesman Monday had no additional comment.

Related: Delta meltdown: Pilots are on hold, too

The fiasco is a stain on an otherwise enviable reputation.

In 2016, Delta had 241 days without canceling a single mainline flight, up from 143 in 2015 and zero in 2010.

Delta is widely considered to be one of the best run of the large U.S. airlines. Leadership at United Airlines (UAL) and American Airlines (AAL) regularly acknowledge they envy the Atlanta carrier's operational and financial track record.

And Delta makes a lot of money along the way: The airline finished 2016 with record pre-tax earnings of $6.1 billion.

Delta has used that money to buy new jets and refurbish older ones. It rolled out high-tech bag tracking and other passenger-friendly innovations. It opened new airport lounges and spas. It created a hub in Seattle. High-fashion uniforms are coming for the staff. Delta's new business class seat, the first with a closing door, has won a coveted industry award before its first flight.

Delta passengers enjoy those benefits every day. But when thousands of flights are canceled, "there's no lounge big enough, there's no pizza oven big enough, there's not enough rental cars to solve your problems," said Robert Mann, principal at R.W. Mann & Company, an airline industry consultancy.

Delta operates an enormous fleet of 1,250 aircraft that features more types of airplanes than any other U.S. airline. That was born of its marriage to Northwest Airlines in 2008. Mann said the mix of jets makes the recovery more complex. Delta said 60% of those aircraft fly through Atlanta every day.

With so many kinds of aircraft, Delta can put the proper size on the right route at the right time. But when things go wrong and crews and planes are out of place, matching an available pilot with an available airplane gets considerably harder.

"You can't use a 737 pilot on an MD-80," Mann said. "Delta has far more aircraft spares on a given day, but they have no more crew."

In a debacle like last week's, by the time the right pilot is located or a flight attendant is moved to meet staffing requirements, duty hours may have expired, forcing the airline to cancel more flights. Delta spokesman Michael Thomas said Sunday's cancellations were largely to meet these guidelines.

Delta has managed that complexity for years to its great benefit. But last week's meltdown was a bold illustration of what can happen when extreme weather collides with phenomenal complexity.

"It's like a huge gamble. In the normal everyday blue sky, these complexities don't matter so much," one Delta staffer said. "But when you lose the bet, you lose it hard."