先輩 is defined by one fact: they were here first. A second-year student is the first-year's 先輩; whoever joined the company a year ahead of you is your 先輩 there — hires of the same intake year are 同期, peers. With the word come mild obligations in both directions — the senior looks after, teaches, sometimes pays for lunch; the junior speaks politely and learns. It is a relationship word the way 兄 and 妹 are, which is why it has no real English equivalent.
先生 is earned by role, not arrival. Teachers, doctors, lawyers, authors — people whose position itself teaches or leads. Your club's third-year captain taught you everything you know, and is still 先輩, not 先生. Promoting them sounds like a joke; demoting a teacher to 先輩 is simply wrong.
上司 is org-chart vocabulary. Your boss is 上司 whether they arrived before you or not, and a 先輩 with no authority over you at all is still your 先輩. The two axes cross: a younger manager can be your 上司 while you are their 先輩 — an awkwardness Japanese offices genuinely feel, because both words keep claiming their own kind of respect.
And the meme? English internet Japanese — “notice me, senpai” — grew out of anime crush plots, where the word is what a junior calls the upperclassman they admire. The usage is real; the desperation is the joke. In actual Japanese, calling someone 先輩 is about as charged as calling a colleague “boss” in English — routine, mildly warm, and entirely unremarkable.