How long does it take a random walker to reach a given target point? This quantity, known as a first-passage time (FPT), has led to a growing number of theoretical investigations over the past decade. The importance of FPTs originates from the crucial role played by first encounter properties in various real situations, including transport in disordered media, neuron firing dynamics, spreading of diseases or target search processes. Most methods of determining FPT properties in confining domains have been limited to effectively one-dimensional geometries, or to higher spatial dimensions only in homogeneous media. Here we develop a general theory that allows accurate evaluation of the mean FPT in complex media. Our analytical approach provides a universal scaling dependence of the mean FPT on both the volume of the confining domain and the source-target distance. The analysis is applicable to a broad range of stochastic processes characterized by length-scale-invariant properties. Our theoretical predictions are confirmed by numerical simulations for several representative models of disordered media, fractals, anomalous diffusion and scale-free networks.