(CN) – U.S. border detention facilities must provide a minimum of comforts to temporary detainees, including sleeping mats and blankets if they are held for more than 12 hours, the Ninth Circuit ruled Friday.

The ruling by the three-judge panel stems from a lawsuit over conditions in Border Patrol Tucson Sector facilities, which house immigrants caught along the U.S.-Mexico border. In a lawsuit filed in 2015, detainee Norlan Flores, 34, of Nicaragua successfully sought class status for herself and potentially hundreds of thousands other detainees who pass through the facilities annually.

Flores said detainees are “packed into overcrowded and filthy holding cells with the lights glaring day and night; stripped of outer layers of clothing and forced to suffer in brutally cold temperatures; deprived of beds, bedding, and sleep; denied adequate food, water, medicine and medical care, and basic sanitation and hygiene items such as soap, sufficient toilet paper, sanitary napkins, diapers, and showers; and held incommunicado in these conditions for days.”

The government first argued detainees aren’t a legitimate class, because the conditions were not widespread enough. U.S. District Court Judge William Bury in Tucson last year called that argument “absurd,” allowing the lawsuit to move ahead.

Bury later ruled detainees – who are not criminally charged – deserve the same standard of treatment criminal prisoners deserve.

The government appealed Bury’s order that the Border Patrol must offer detainees blankets and sleeping mats after 12 hours, claiming it was unreasonable and that Bury misunderstood the standard set in a previous case, Bell v. Wolfish.

The detainees also appealed, arguing that blankets and mats are not enough and that the government should provide showers, beds and treatment by medical professionals.

But the Ninth Circuit split the appeals down the middle, ruling that providing mats and blankets are a reasonable balance between the narrow mission of the Border Patrol and the civil rights of detainees.

Flores and two unnamed plaintiffs are represented by an array of attorneys, including Morrison & Foerster, the American Immigration Council, the National Immigration Law Center, the ACLU of Arizona, and the Lawyers’ Committee for Civil Rights of the San Francisco Bay Area.

A lead attorney for the American Immigration Council did not immediately respond to a request for comment.