If you ask your friends and family who have gone through the home-buying process, it's unlikely they will say that it cost less than they planned for. So it's often useful to over-estimate on your costs. Avoid using language -- either out loud or in your own head -- like "I can afford between X and Y" because numbers tend to climb slowly until final figures are beyond what you should be budgeting. You might hear words like "you should expect to pay" or "your monthly mortgage will be about" during meetings with financers. Get rid of the "should" and "about" and "between" words and demand real numbers.
A good way to start is with a realistic debt-to-income ratio. It can gives a clearer picture of what you can spend on housing without having to dine on peanut butter and jelly sandwiches for the next 10 years or more, and you should be able to find several online calculators and forms that will calculate the numbers based on your inputs.