History of Railroad Uniforms?

What is the origin and history of passenger train crew uniforms?

Is there some basis in the Civil War?

I’m particularly interested in the origins of the bars on the sleeve
indicating seniority.