Neurosurgery is the surgical specialty that focuses on diseases and injuries involving the brain , spinal cord and peripheral nervous system .