  We investigate the structure of cold dark matter halos using advanced models
of spherical collapse and accretion in an expanding Universe. These base on
solving time-dependent equations for the moments of the phase-space
distribution function in the fluid approximation; our approach includes
non-radial random motions, and most importantly, an advanced treatment of both
dynamical relaxation effects that takes place in the infalling matter:
phase-mixing associated to shell crossing, and collective collisions related to
physical clumpiness. We find self-similar solutions for the
spherically-averaged profiles of mass density rho(r), pseudo phase-space
density Q(r) and anisotropy parameter beta(r). These profiles agree with the
outcomes of state-of-the-art N-body simulations in the radial range currently
probed by the latter; at smaller radii, we provide specific predictions. In the
perspective provided by our self-similar solutions we link the halo structure
to its two-stage growth history, and propose the following picture. During the
early fast collapse of the inner region dominated by a few merging clumps,
efficient dynamical relaxation plays a key role in producing a closely
universal mass density and pseudo phase-space density profiles; in particular,
these are found to depend only weakly on the detailed shape of the initial
perturbation and the related collapse times. The subsequent inside-out growth
of the outer regions feeds on the slow accretion of many small clumps and
diffuse matter; thus the outskirts are only mildly affected by dynamical
relaxation but are more sensitive to asymmetries and cosmological variance.
