In USMC boot camp, this specific topic was addressed very early on. It’s “Good Morning” up until noon, after which it is “Good Afternoon” up until you eat evening chow, then it is “Good Evening” until midnight (at which point it becomes “Good Morning” again).
Of course, it’s all up to personal preference in the real world. If you’re out with your friends at a club and it’s after midnight but still very much dark out, you’re not going to be greeting people of the gender that you prefer to look at with “Good Morning”, because it is still ‘evening’ to you and them.