<% content_for :title, "#{@aircraft.tail_number} Oil & Fuel" %> <%= render "shared/aircraft_header", aircraft: @aircraft %>
<% [@oil, @fuel].each do |stats| %>

<%= stats.oil? ? "Oil Consumption" : "Fuel Burn" %>

<%= link_to "+ Add #{stats.oil? ? 'Oil' : 'Fuel'}", new_aircraft_consumable_record_path(@aircraft, type: stats.record_type), class: "btn-secondary btn-sm" %>
<%= stats.recent || "—" %> <%= stats.metric_label %>, last ~<%= stats.recent_window_hours %> hrs
<%= stats.lifetime || "—" %> lifetime
<% if stats.points.size >= 2 %> <%= line_chart stats.chart_data, xtitle: "Tach hours", ytitle: stats.metric_label, height: "220px", curve: false, points: false, library: { scales: { x: { type: "linear" } } }, colors: [stats.oil? ? "#b45309" : "#0369a1"] %>

Rolling <%= stats.chart_window_hours %>-hour window: total <%= stats.oil? ? "oil" : "fuel" %> added ÷ hours flown, so partial fills average out.<%= " Higher is better." if stats.oil? %>

<% else %> <%= empty_state "Not enough history yet (need more than #{stats.chart_window_hours} tach hours of records)." %> <% end %>
<% end %>

Records

<% if @records.any? %> <%= render "consumable_records/records", records: @records, page: @page, more: @more %> <% else %> <%= empty_state "No oil or fuel records yet." %> <% end %>