First-principles approach to electrical transport in atomic-scale nanostructures