Every detail was designed to mark Hillary Clinton’s moment in history — from the glass ceiling at Manhattan’s Javits Center, where her supporters were gathered, to her and hubby Bill’s suite at The Peninsula hotel, selected so she could personally see Trump Tower, home to the foe she was set to crush. Then came the voter returns. In this exclusive excerpt from their fascinating new book, “Shattered,’’ political reporters Jonathan Allen and Amie Parnes take readers inside Hillary Clinton’s world on the night that changed her life — and the nation — forever.

Hillary’s communications team decamped to the Javits Center in the Hell’s Kitchen section of Manhattan, where preparations for her victory party were being made. The venue, which would fill with Hillary aides, donors, friends and well-wishers over the course of the day, was chosen in large part because of its distinctive feature: a glass ceiling. If everything went as planned, it would be the glass ceiling of the presidency that lay shattered under Hillary by the end of the night.

A handful of key aides remained in the campaign’s Brooklyn headquarters for Election Night, but the top brass, including [campaign manager] Robby Mook, John Podesta, and Cheryl Mills, joined Hillary and Bill Clinton on their floor at the top of The Peninsula hotel, a five-star facility a block from Trump Tower. The Clintons had their own suite, and the rest of the floor had been rented out for staff workspace and for aides, including Podesta and Abedin, to have private bedrooms.

At the start of the night, the Javits Center was electric: it had the buzz of a debut performance on Broadway. Outside, a seemingly endless line formed down 40th Street, near artists who had sketched Hillary’s portrait next to Obama’s and vendors who sold buttons with the candidate’s name.

Supporters resplendent in their “I’m With Her” and “Madam President” T-shirts filed in and stood shoulder to shoulder as they watched the returns trickle in on the large television monitors overhead. Under the signature glass ceiling lit by an ocean-blue hue, they watched the network broadcasts and listened to a string of surrogates from pop star Katy Perry to Sen. Chuck Schumer fire up the crowd.

Clinton’s campaign anthem, “Fight Song,” blared across the room, and an official block party formed outside for a spillover crowd who held American flags and prepared for victory.

Mook and Jennifer Palmieri had been in a staff room on the same floor, watching CNN, when polls closed in Virginia and Florida at 7 p.m. As the first returns came in, Mook dashed into the room next door, where Elan Kriegel and a couple of his data analysts compared the results with the campaign’s projections. Having guided Terry McAuliffe’s gubernatorial campaign in 2013, with Kriegel at his side, Mook knew the nooks and crannies of Virginia precincts as well as anyone in the political universe.

It’s OK, he thought. It isn’t great, but it’s OK. Then a cluster of African-American-majority precincts around Jacksonville, Fla., came in. Those numbers looked strong, robust enough for a few fist pumps around the room.

“Florida started coming in fine,” one top Hillary aide said. “And then Florida started getting tight.”

F–k you, [Democratic pollster] John Anzalone thought. You’re being too pessimistic. From the boiler room, the veteran pollster and his fellow Clinton campaign consultant Jim Margolis were on the phone with Steve Schale, an old pal from their Obama days. It was 7:45 p.m., and Schale had called to say Hillary was in deep trouble in Florida.

No one in the party had a better feel for the state than Schale, a Tallahassee-based operative who had worked on the Draft Biden campaign in 2015. “It’s in real bad shape,” Schale warned his friends. “What the f–k are you talking about?” Anzalone asked. Hillary was on her way to turning out more Sunshine State voters than any previous candidate of either party. Yeah, Trump was winning exurban and rural areas, but surely Democratic hot spots like Miami-Dade and Broward would erase the deficit.

No, Schale explained, Trump’s numbers weren’t just big, they were unreal. In rural Polk County, smack-dab in the center of the state, Hillary would collect 3,000 more votes than Obama did in 2012 — but Trump would add more than 25,000 votes to Mitt Romney’s total. In Pasco County, a swath of suburbs north of Tampa-St. Petersburg, Trump outran Romney by 30,000 votes.

Pasco was one of the counties Schale was paying special attention to because the Tampa area tended to attract retirees from the Rust Belt — folks whose political leanings reflected those of hometowns in the industrial Midwest. In particular, Schale could tell, heavily white areas were coming in hard for Trump.

Hillary sat stone-faced, trying to process the unexpected and abrupt reversal of her fortunes. “OK,” she said over and over as she nodded. It was all she could muster.

Down in Florida, Craig Smith’s phone rang. The former White House political director, and the very first person hired onto Bill Clinton’s 1992 campaign, had been ignoring calls and texts. This one, he took. The raspy voice on the other end of the line asked him if Florida could be turned around.

“Sorry to be the one to tell you,” Smith said in an Arkansas drawl echoing the former president’s, “but we’re not going to win Florida.” Bill hung up and called Gov. Terry McAuliffe, who was eager to depart Virginia for the victory party at the Javits Center. Don’t bother coming, Bill told him.

Hillary was still surprisingly calm, unable or unwilling to delve into the details of how her dream was turning into a nightmare. Bill was less reticent. He’d had a sinking feeling that the British vote to leave the European Union had been a harbinger for a kind of screw-it vote in the United States. He’d seen the trans-Atlantic phenomenon of populist rage at rallies across the country, and warned friends privately of his misgivings about its effect on Hillary’s chances. Now his focus turned back to the international movement he’d seen gathering. “It’s like Brexit,” he lamented. “I guess it’s real.”

At 11:11 p.m., White House political director David Simas was seated at a conference table in the West Wing looking at results with fellow Obama aides and perusing Twitter when the AP called North Carolina for Trump. At the time, Hillary was leading in Pennsylvania, but many of her strongholds had already reported vote counts.

Twenty minutes later, Fox News called Wisconsin for Trump — a judgment that other news agencies declined to validate for hours. At the White House, the writing on the wall was clear. It was just a matter of time before Donald Trump would be declared successor to Obama.

When he was sure there was no path to victory, and after having conferred with the president, Simas placed a call to Mook, who was in Hillary’s suite at The Peninsula. “What’s going on in your camp?” Obama’s aide asked. “I don’t think we’re going to win,” Mook replied. “I don’t think you are either,” Simas agreed. “POTUS doesn’t think it’s wise to drag this out.”

Mook now stood between a president interested in ensuring the smooth, democratic transfer of power after Trump had complained for months that the election might be rigged and a candidate who hadn’t yet given up on the idea that Rust Belt states might flip in her direction.

The president wants you to concede, Mook told her, adding his own analysis: “I don’t see how you win this.”

“I understand,” she said. But she used her place in history as a shield in the same way Mook just had with Simas. “I’m not ready to go give this speech.” Though she focused her pushback on the nature of her remarks — How should she frame the election of Donald Trump? What would she say to little girls and elderly women who treated her as a champion? Could she hit the right notes? — the effect was the same. Hillary wasn’t quite ready to put an end to the dream she’d pursued for at least the past decade.

“You need to concede,” President Obama told his former secretary of state. For the past eight years, their interests had aligned almost perfectly. She’d lent him credibility with her own supporters and in the Washington establishment. He’d given her the State Department springboard from which to relaunch her political career.

He needed to ensure that the end of his presidency didn’t devolve into a post-election circus. He had vouched for the sanctity of the electoral process and he needed Hillary to follow along.

She wasn’t ready yet. But she was getting there. One by one, the obstacles were being removed. Pennsylvania was gone. The AP had just declared Trump the winner of the election. Now the president — the one who had convinced her to take the State job by framing it as a patriotic call to duty — was asking her to do the right thing for the good of her country. He wanted her to make it abundantly clear to the public that she wasn’t going to fight the result.

Kellyanne Conway picked up Huma Abedin’s call and handed her phone to Trump. Hillary took Huma’s phone and faked a smile with her voice. “Congratulations, Donald,” she said, suppressing the anger that touched every nerve in her body. “I’ll be supportive of the country’s success, and that means your success as president.” Trump credited her for being a smart opponent who ran a tough campaign. The denouement lasted all of about a minute.

The news spread fast because Mook was on a conference call with other top officials. Hillary’s voice carried over his open line. “She’s literally in the background,” one campaign aide said. “You could hear her talking to Trump, conceding.”

Original Hillarylander Capricia Marshall, the former White House social secretary and chief protocol officer of the United States, couldn’t come to terms with the decision. She retreated to the living room, finding a spot on the couch that had been Bill Clinton’s home for most of the night.

Now, as Trump made his way to the podium at the Hilton, Bill chomped on the back end of a cigar. Philippe Reines, a third refugee from the discussion around Hillary, came in to watch Trump’s victory speech. Bill looked over at the man who had played Trump in debate-prep sessions. “I wish it was you up there,” he said wistfully.

In the fog of a shocking defeat, there was one moment that crystallized everything for Hillary. Not long after the concession call, Abedin approached her once again, phone in hand. “It’s the president,” she said.

Hillary winced. She wasn’t ready for this conversation. When she’d spoken with Obama just a little bit earlier, the outcome of the election wasn’t final yet. Now, though, with the president placing a consolation call, the reality and dimensions of her defeat hit her all at once. She had let him down. She had let herself down. She had let her party down. And she had let her country down. Obama’s legacy and her dreams of the presidency lay shattered at Donald Trump’s feet. This was on her. Reluctantly, she rose from her seat and took the phone from Abedin’s hand.

“Mr. President,” she said softly. “I’m sorry.”

Reprinted from “Shattered: Inside Hillary Clinton’s Doomed Campaign.” Copyright © 2017 by Jonathan Allen and Amie Parnes. Published by Crown, an imprint of Penguin Random House LLC.