Context. Star-forming galaxies emit bright molecular and atomic lines in the submillimeter and far-infrared (FIR) domains. However, it is not always clear which gas heating mechanisms dominate and which feedback processes drive their excitation. Aims. The Sgr B2 complex is an excellent template to spatially resolve the main OB-type star-forming cores from the extended cloud environment and to study the properties of the warm molecular gas in conditions likely prevailing in distant extragalactic nuclei. Methods. We present 168 arcmin2 spectral images of Sgr B2 taken with Herschel/SPIRE-FTS in the complete ~450−1545 GHz band. We detect ubiquitous emission from mid-J CO (up to J = 12−11), H2O 21,1−20,2, [C I] 492, 809 GHz, and [N II] 205 μm lines. We also present velocity-resolved maps of the SiO (2−1), N2H+, HCN, and HCO+ (1−0) emission obtained with the IRAM 30 m telescope. Results. The cloud environment (~1000 pc2 around the main cores) dominates the emitted FIR (~80%), H2O 752 GHz (~60%) mid-J CO (~91%), [C I] (~93%), and [N II] 205 μm (~95%) luminosity. The region shows very extended [N II] 205 μm emission (spatially correlated with the 24 and 70 μm dust emission) that traces an extended component of diffuse ionized gas of low ionization parameter (U ≃ 10−3) and low LFIR / MH2 ≃ 4−11 L⊙M⊙−1 ratios (scaling as ∝Tdust6). The observed FIR luminosities imply a flux of nonionizing photons equivalent to G0 ≈ 103. All these diagnostics suggest that the complex is clumpy and this allows UV photons from young massive stars to escape from their natal molecular cores. The extended [C I] emission arises from a pervasive component of neutral gas with nH ≃ 103 cm−3. The high ionization rates in the region, produced by enhanced cosmic-ray (CR) fluxes, drive the gas heating in this component to Tk ≃ 40−60 K. The mid-J CO emission arises from a similarly extended but more pressurized gas component (Pth / k ≃ 107 K cm−3): spatially unresolved clumps, thin sheets, or filaments of UV-illuminated compressed gas (nH ≃ 106 cm−3). Specific regions of enhanced SiO emission and high CO-to-FIR intensity ratios (ICO / IFIR ≳ 10−3) show mid-J CO emission compatible with C-type shock models. A major difference compared to more quiescent star-forming clouds in the disk of our Galaxy is the extended nature of the SiO and N2H+ emission in Sgr B2. This can be explained by the presence of cloud-scale shocks, induced by cloud-cloud collisions and stellar feedback, and the much higher CR ionization rate (>10−15 s−1) leading to overabundant H3+ and N2H+. Conclusions. Sgr B2 hosts a more extreme environment than star-forming regions in the disk of the Galaxy. As a usual template for extragalactic comparisons, Sgr B2 shows more similarities to nearby ultra luminous infrared galaxies such as Arp 220, including a “deficit” in the [C I] / FIR and [N II] / FIR intensity ratios, than to pure starburst galaxies such as M 82. However, it is the extended cloud environment, rather than the cores, that serves as a useful template when telescopes do not resolve such extended regions in galaxies.