FFXIV crafting and gathering profit: material cost against market price by class and level

Crafted and gathered items can be sold to other players on the market board. The production comparison lists everything your class can make or gather in a level range, prices the materials and the result, and ranks the rows by profit per craft.
Where do the costs come from?
For each material the comparison takes the cheaper of two prices: a gil vendor's price, when a vendor sells it, and the cheapest market listing including the market tax. The result is priced at its cheapest current listing of the quality you choose to sell. A row whose material or result has no price shows what is missing and is not ranked; nothing unknown counts as free.
What does the quality choice change?
Selling as high quality compares the result's high-quality listings. Items that cannot be high quality keep their normal price. The comparison does not estimate how often a craft turns out high quality.
Gathering classes
For miners, botanists and fishers the rows are the items gathered from the chosen levels, priced at their lowest listing, since they need no materials.
Worked example
A leatherworker between levels 15 and 17 sees the Hard Leather Skullcap. Its recipe takes two Hard Leather, one Cotton Yarn and two shards. Hard Leather costs 31 gil and Cotton Yarn 22 gil at vendors, cheaper than most listings, so those come from the vendor; the shards come from the market. The skullcap's lowest listing minus those 106-odd gil is the profit of one craft, and the Plan button sends one craft to the Crafting Planner.