Latest Time for Maariv
Krias Shema
22. L’chatchila one should say Krias Shema right at tzeis to fulfill זריזין מקדימים למצוות . The Chachamim determined that the l’chatchila zman is until chatzos (להרבה ראשונים, עי' ביאה''ל ד''ה וזמנה ). If one was lax and said it after chatzos but before alos, he is yotzei (שו''ע סי' רל''ה ס''ג ). If he didn’t say Shema due to oneis, e.g., he was ill or drunk, he is yotzei by saying it until neitz (שו''ע ס''ד ).
Maariv
23. L’chatchila until chatzos. Some poskim hold it is only Shema which should be said before chatzos l’chatchila (above, 22), but the tefilla of Maariv may l’chatchila be said all night until alos (אורח נאמן סי' ק''ח סק''ז, קצוה''ש סי כ''ז סקי''ג, פמ''ג סי' ק''ח משב''ז סק''ג ). Others hold one should l’chatchila also daven Maariv before chatzos (ערוה''ש סי''ב ).
24. Until alos. One may only daven Shemoneh Esrei until alos. After that, he may not, as Maariv was instituted for the night, and after alos is considered day for all purposes (מ''ב סי' רל''ה סקל''ד ).
25. Oneis. If one davens and says Shema after alos and before neitz due to a situation beyond his control (above, 22), he should say the brachos of Shema and Shema, but not the bracha of השכיבנו , as after alos is not “a time of lying down” [זמן שכיבה] (שו''ע שם ס''ד ). Also, he should neither say ברוך ה' לעולם nor daven Shemoneh Esrei, as mentioned (מ''ב סקל''ד ).