A person gets up from Shiva (and ends Shloshim) on the morning of that particular day because of the principal of miktzas hayom kekulo, that part of the day counts as the entire day. Why does this not then allow shiva (or shloshim) to end after ma'ariv, the previous evening, which actually begins the final day?
According to halachipedia,
However, we do not apply this concept to keeping aveilus at night, and instead the mourners have visitors come in the morning and end aveilus when they leave. (note 18)
18 -- This is the practice as described by the Gemara Moed Kattan 21b. Tosfos there (s.v. “Afilu”) believe that the nighttime cannot count as a partial day, but Ramban (Toras HaAdam p. 215) disagrees. Maharam of Rothenberg, quoted in the Rosh (Moed Kattan 3:30) and paskened by Shulchan Aruch (Y.D. 395:1) held that the concept of מקצת היום ככולו can be applied to the nighttime in principle, and is therefore relevant for the thirty days of aveilus, but nighttime does not suffice for ending the seven days because of a need to have a seven day count, similar to the count of a niddah.
The Tosfos referred to on M"K 21b reads
י"ל מקצת היום ככולו לא הוי בלילה לענין שום דבר כדאמרינן במגילה בפ"ב (דף כ.) דשימור לילה לאו שימור הוא לענין שבעה נקיים:
This seems to be saying that the rule of the partial day counting for the whole doesn't include the evening regarding "shoom davar" which I see as an absolute exclusion and his evidence is that in Megilla, 20a, the counting of 7 clean days for the menstruant must include the morning of the seventh day:
MISHNA: One may not read the Megilla, nor perform a circumcision, nor immerse himself in a ritual bath, nor sprinkle water of purification to purify people and objects that had contracted ritual impurity through contact with a corpse until after sunrise.
The gemara there gives a specific list, and then goes through each of the examples given in the mishna and shows a textual source why the "day time" is a necessary component (even though, for example, the 7th day for a niddah begins in the evening). Why would that principle of day-time then be applied to any other unlisted (and not-textually supported) case?
I don't understand why computing the 7 days of shiva (or the 30 of shloshim) is inherently tied to the methodology of counting for a niddah or where that connection is codified.
The Shulchan Aruch's position is here and one should look at note #2 (it begs other questions about the categories it suggests).