EXCLUSIVE

Chris Brown annihilated his baby mama in custody court ... she lost so bad the judge ordered her to pay Chris back for the attorney fees he fronted her.

Sources connected to Chris tell us, Nia Guzman struck out on every single request regarding custody of 2-year-old Royalty. Nia wanted full custody -- DENIED. She wanted Chris to have monitored visitation -- DENIED. She wanted to deny Chris' mom the right to see the kid -- DENIED. She wanted Chris to submit to drug tests -- DENIED.

The judge maintained the status quo -- joint custody. Chris continues to get Royalty 12 days a month.

When Nia filed her legal docs asking for a change in custody the judge ordered Chris to pay her $20k so she could afford a lawyer. But she lost so hard, the judge said Nia wasn't entitled to the money and gave Chris a credit.

There was supposed to be a separate hearing on child support. Nia is currently getting $2,500 a month from Chris but she wanted nearly $16k. Nia has now dismissed her support petition.