The starting point for Ma'ariv is the appearance of the stars: Mishnah Berakhot 1:1 establishes that the evening Shema — and with it the evening prayer — begins "from the time when the priests enter to partake of their teruma," which the Tur (Orach Chaim 235) identifies as tzeit ha-kokhavim, the emergence of the stars, requiring three medium stars as the Beit Yosef (Orach Chaim 235) specifies.
As for the outer limit, the Rambam (Hilchot Kriat Shema 1:9) rules that the ideal time for the evening Shema extends until midnight, and while one who delays and recites it before dawn still fulfills the obligation, the midnight cutoff was set "in order to distance us from negligent wrongdoing."
The Gemara itself records a dispute about whether the evening prayer has any fixed hour at all: Berakhot 27b reports that the phrase "the evening prayer has no fixed time" reflects the view that it is optional, yet Abaye there concludes the law follows the opinion that it is obligatory — meaning one should not treat it as freely deferrable throughout the night.
In practice, the Tur (Orach Chaim 235) rules that the time for Ma'ariv follows immediately upon Kriat Shema and its blessings, in keeping with Rabbi Yochanan's principle of adjoining the blessing of redemption to the Amidah even on weekday evenings.