Not sure why you’re getting down-voted.
If unexpected costs are shrinking your margin, you’re failing either:
1. …to negotiate the terms of your agreement correctly (what constitutes additional scope and therefore additional charges?). I will never take another client project without first agreeing on an SRS for this reason.
2. …to negotiate a fee with a margin proportional to the likelihood of unexpected situations arising. This is a function of the accuracy of requirements by simple/complicated/complex problem domains. I think this is what parent is suggesting.
If clients don’t like (2) they will work with you more on (1) by providing more accurate requirements, which lets you bucket some problems into more readily estimable domains.