Herbivores occupy the second trophic level because producers constitute the first. Primary consumers obtain carbon and energy directly from plants, algae, or other autotrophs; predators that eat herbivores occupy the third level. Trophic level is determined by feeding position, not taxonomy, so an omnivorous species can operate at more than one fractional trophic level. Detritivores are often treated separately because their food integrates material derived from several levels, although their energy ultimately originated in primary production. Quantitative interpretation requires explicit system boundaries and time scales; otherwise export, migration, storage, or seasonal turnover can appear to violate energy balance. Thermodynamic constraints set broad patterns, but species traits, defenses, body size, habitat structure, and disturbance determine the efficiencies observed in a particular ecosystem. Real communities are networks rather than isolated chains, so omnivory, detrital links, and changes in interaction strength modify the simplified trophic sequence. Energy budgets must distinguish stocks from rates: standing biomass can remain high or low even when production and transfer through that compartment are rapid.
Ref:
Fundamentals of Ecology, Odum & Barrett, 5th Ed., Ch. 3