I have a big kitchen, old, and I need to replace 4 dozen hinges.
Work space from counter top to upper cupboards is 16" = you're good to go.
Leave a space (1/2"?) above the cupboards to get them all lined up with each other.
Cover that with a small molding, use a brad nailer. Get it straight.
You could plane off some of the high parts of the molding if the ceiling is really lumpy.
Otherwise, don't bother = nobody looks up there when they're hungry.
I did the demolition part of a total kitchen rebuild. Empty box, not even a light bulb.
The installer must have used 50+ shims. Jacked the upper cupboards into position with a motorcycle jack on a 2x4 sled. Trim around the top, I recall it wasn't even.