Gap Inc.'s (GPS) fiscal second-quarter profit fell 0.4% as the casual-clothing retailer posted lower sales across all four of its divisions, but margins and online sales improved.

The retailer, which suffered from fashion misfires before the recession, has been focusing on a leaner inventory and traffic-driving promotions. The company also launched its premium denim line earlier this month, as it hopes to take market share away from pricer lines such as True Religion and 7 for All Mankind.

For the quarter ended Aug. 1, Gap reported earnings of $228 million, or 33 cents a share, down from $229 million, or 32 cents a share, a year earlier. The latest quarter had fewer shares outstanding. Earlier this month, the company projected per-share earnings of 30 cents to 32 cents, above analysts' estimates at the time.

Earlier this month, Gap reported net sales declined 7.4% to $3.24 billion as same-store sales dropped 8%. Same-store sales continued to fall across all four divisions, with the largest decline of 15% at higher-end Banana Republic, and Gap and Old Navy same-store sales down 10% and 4%, respectively. International sales dropped 5%. Gap last reported a monthly increase in same-store sales for January 2008.

Still, the results at Old Navy were an improvement from a year ago, when same-store sales slumped 16%. Gap has been focusing on providing better merchandise at Old Navy.

Gross margin grew to 39.7% from 38.2%.

Online sales improved 17% to $224 million. Inventory slid 14%.

The company, which is the largest independent clothing retailer by revenue, opened 12 stores and closed 16 during the quarter, ending with 3,145 locations. It still expects to open 50 stores and close 100 stores, with capital spending of $350 million for the fiscal year.

Gap is also testing an accessories-only branch of Banana Republic called Edition, which it launched in May. Jewelry and bags can yield a higher profit margin and the goods take up less space and have a more timeless appeal.

Shares rose 1.5% to $19.14 in after-hours trading. The stock has been rebounding recently, and is up by over a third this year.

-By John Kell, Dow Jones Newswires; 212-416-2480; john.kell@dowjones.com