DALLAS (AP) — A judge ordered Texas to make sweeping changes to its foster care system on Friday, two years after she found it unconstitutionally broken.

In the scathing final order, U.S. District Judge Janis Graham Jack told the state the overhaul must include improvements in record keeping, caseworker visits and where children are placed. The changes were based on recommendations from experts the judge appointed to help craft a plan to improve the lives of children in long-term foster care.

However, an appeals court temporarily stayed Jack's ruling after the Texas Attorney General's Office filed an immediate appeal. A three-judge 5th U.S. Circuit Court of Appeals panel said the stay will remain in place until it can consider arguments against Jack's ruling.

The judge appointed the two experts after ruling in December 2015 that people labeled permanent wards of the state "almost uniformly leave state custody more damaged than when they entered." The state has fought Jack's oversight and objected to previous recommendations made by the experts. In her ruling Friday, Jack wrote that the Texas Department of Family and Protective Services "has demonstrated an unwillingness to take tangible steps to fix the broken system."

The state quickly filed its appeal, leading to the stay. Attorney General Ken Paxton said the judge's "unfunded and unrealistic mandates" were misguided, and he noted legislation last year that funds improvements to the system.

But in her final order, Jack said there was no explanation about where the nearly $1 billion in additional funding that the Legislature provided last session would go. "Two years and one legislative session later, the foster care system of Texas remains broken," she wrote.

Among directives from Jack is that foster children have access to a phone to report abuse to a 24-hour hotline. She said that the state should either require all placements to have a landline for such use or present the court with another plan for giving children such access. She noted that the state has said a landline requirement would require extra funds but said officials have provided no evidence of cost. She also noted that the cost of landlines seems "trivial" compared with the $1 billion the Legislature provided to the agency.

Other directives include that the state must ensure that children get monthly face-to-face visits with caseworkers outside the presence of caregivers. She also ordered the state to come up with a plan for an integrated computer system that incorporates records on each child, including educational and medical records. She also says any sexualized children — whether victim or aggressor — should be placed in single-child homes.

The order came in a case filed in 2011 by New York advocacy group Children's Rights and Texas lawyers on behalf of those in long-term foster care. Unlike most states faced with such lawsuits, Texas fought it instead of settling.

At a 2014 trial in the class-action lawsuit, former foster children testified of abuse they suffered as they were shuffled from placement to placement.

Jack's 2015 opinion detailed the sufferings of foster youths, including a girl identified as S.A. who entered the foster care system at age 5 and within months reported being raped by an older child. She was moved more than 45 times, including to psychiatric hospitals, and missed several chances for adoption because of paperwork delays. At 18, after aging out of the system, she walked into traffic and survived being hit by a car.

Texas continued to fight after Jack's 2015 ruling, even as crisis after crisis emerged in the state's child welfare system: Some children taken from their families had to sleep in state offices, motels or emergency shelters because of a lack of other options and children believed to be at risk weren't being promptly seen, if at all. Jack's order Friday says no child can be placed in an office overnight.

While state officials repeatedly acknowledged serious problems, they objected to oversight by a federal judge, saying they had been working on their own changes. Yet when the experts appointed by Jack filed their recommendations last month, they noted that "in numerous instances" the state had declined to "implement policy changes or develop implementation plans."

Jack wrote Friday that the state has taken "minimal" steps to help the experts she appointed in crafting corrective policies, "limiting their participation to providing requested information."

The lead lawyer for the plaintiffs, Paul Yetter, called the order "a turning point for Texas foster children." He said the order "largely adopts the careful, well-thought-out roadmap to reform" that the appointed experts laid out.

Jack appointed monitors to make sure the state complies with her order, serving until the court no longer deems it necessary.

___

Associated Press writer Paul J. Weber contributed to this report from Austin.

___

Sign up for the AP's weekly newsletter showcasing our best reporting from the Midwest and Texas: http://apne.ws/2u1RMfv