Fast-fashion retailer H&M has agreed to pay $36 million to settle claims it illegally pocketed millions of dollars in unused gift card balances.

According to New York Attorney General Letitia James, the Swedish company held more than $18 million in unused gift card balances in H&M’s bank accounts since at least 2008.

H&M should have sent the unused balances to New York’s Abandoned Property Fund. James said H&M repeatedly misled authorities about the missing money by blaming an Ohio company that handled its card business.

“My office has zero tolerance for companies that disregard the law and line their pockets with money that belongs to hardworking people,” she said in a statement. “Violating the law is not trendy or tolerable.”

Gift-card rules vary from state to state. In California, it’s against the law for store gift cards or gift certificates to have an expiration date or dormancy fees.

If the balance on the card is less than $10, Californians can redeem it for cash.

Even so, unused gift cards represent money in the bank for retailers, who have revenue from the card purchase but haven’t had to part with any inventory.

Bankrate estimates that just over half of all Americans have unused gift cards sitting in a drawer, with the average consumer leaving $116 on the table.

That’s more than $15 billion in wasted money.

Also, make a point of checking the California controller’s website once a year or so to see if there’s any unclaimed property with your name on it.

It’s easy. Go to the search page, enter the required info and see what turns up.

It’s your money. Don’t just give it away.