Whenever I use the $detail attribute in the element viewer, a missing texture appears over the model. How can I fix this?
By providing a texture.
$detail requires a string texture path. You can read about it and its correlated parameters on the Valve Dev Wiki.
Be aware that SFM Material Overrides behave oddly when adding parameters that weren't already in a VMT. If you're changing an existing detail texture you should be fine, but if you're adding a detail texture to a material that didn't already have one, it may not work as you expected. You may need to modify the existing VMT to add the parameters you're trying to override, and then use mat_reloadallmaterials in console to hot-reload the VMT in SFM (or just restart SFM).