"Sleep before midnight is the best!" is a widespread view. Sleep researchers share this only conditionally. Even those who do not come to rest before midnight need not worry about a sound sleep. The important thing is not the time, but the quality of sleep.
Deepest sleep in the REM phase
According to the current state of sleep research, sleep is the deepest and most intense in the first two hours, in the first REM phase (rapid eye movement), and thus has the most restorative effect. If these two hours are before midnight, sleep is actually the healthiest. However, those who fall asleep at midnight experience healthy sleep only later than the larks, which in the past extinguish the light.
For the feeling of well-being in the morning, the first half of the night's sleep is probably the most important, because there are particularly many deep sleep portions. It does not matter if this first half is before or after midnight.