For a 10:45 departure you should be in line at NWA's Barajas check-in desk by 8:45. Yes, all flights arrive & depart Barajas airport. You would have to be on a 6 or 6:30 AM flight out of Barcelona to cut yourself any 'slack' at all. No, it would not be wise to depend on an early morning flight from Barcelona. If you fly in from Barcelona your flight will probably arrive at Terminal 2 or 3; your Detroit-bound flight will depart from the new International Terminal (at the other end of the airport).
As for time between Spanair arrival and Northwest Airlines departure, it's not relevant: With increased security, your bags will have to be re-checked at Northwest Airlines check-in.
If it were me, I would spend the night in Madrid (probably at an hotel that provides free airport shuttle service).
You don't have to take a train the day before; there are three airlines servicing the Barcelona-Madrid 'corridor' with hourly service.
P.S.
Several years ago I went thru Barajas the morning an Air Traffic Controllers' Strike was beginning. That was
Ugly!