Why is HBr colorless while Br2 isn't?
The colour of molecules come from electronic transitions that are very sensitive to the nature of the molecule
To simplify a little, molecules absorb light when the energy difference between electrons in an occupied orbital and an unoccupied orbital match the energy of a photon of light (and that light will have a specific colour). This much you already understand.
But the energy levels of the electrons that matter for colour are usually the bonds in the molecule that join one atom to another, not the other electrons in the atom that don't get involved in the bonding. So atoms are rarely thought of as having an inherent colour that is independent of what they are attached to (some isolated atoms do have colour: sodium vapour has narrow absorption bands in the yellow, for example, but this isn't important in sodium compounds).
The assumption you make that is false is that &quot;If we look at the molecules, it seems to me that they are basically the same&quot;. If this were true there would be very little interesting in the whole subject of chemistry. When bromine reacts with benzene a Br-Br bond is replaced by a Br-C bond and a Br-H bond. Those are very, very different bonds. A Br-Br molecule has a readily accessible electron transition that results in a dark red colour. That this particular transition is very sensitive to the exact nature of the molecule is obvious as other dihalogens (with very similar electronic structures) have very different colours (iodine is dark purple, chlorine is light yellow). But the orbitals available in other Br-X bonds will be very different as will their energy. Often the corresponding colour of light will be in the UV and there will be no visible colour.
The essential point is that colour comes from electronic transitions that vary a great deal with the atoms involved in the bond. And in many colourful compounds those transitions involve molecular orbitals including multiple atoms across the whole molecule. There is no simple relationship between atoms and the colours of molecules. Every bond is (very) different.