While I am familiar with the difference between line and staff officers, I'm not familiar with the distinction between restricted and unrestricted line officers.
In USN terms, a restricted line officer is essentially the same as a staff corps officer, except that their specialty does not have its own corps (intelligence, public relations, HR, crypto, oceanography and so on). They cannot succeed to command of a vessel.
There doesn't seem to be anything "restricted" about Scotty's line officer status.
The badges and colors were a little more mixed in WNMHGB, though not in any kind of system I can figure out. In the regular production run, though, the colors and badges do seem to correspond one-to-one.