01
Distance comes from the odometer, never a guess
The gap between two consecutive charges that both carry an odometer reading is one leg. Distance, energy and cost are all taken from that same set of legs, so they cannot drift apart. A charge you logged without a reading still counts its energy and its spend, it just adds no miles. A reading that goes backwards, or jumps implausibly, is dropped rather than allowed to wreck every derived figure.