do the airlines have any grounds to sue Boeing for costs?
AIUI, yes - and also AIUI, that's already happening.
Basic contract law really. Airline buys an aircraft to perform specific duties - based on what the manufacturer says it can do (and being certified for commercial passenger carrying would be a very key point of the specifications). Aircraft doesn't work properly and is grounded - so the airlines have a case against Boing for selling them a product that doesn't meet the agreed specification.
But having said that, there's no way they'll recover all their losses. There'll be long lasting intangibles such as loss of customer (ie passenger) confidence which could hit the bottom line for years, and the other effect of having moved people to other modes of transport from which they might not return when airline capacity is back to normal.