<header class="page-heading"><p class="eyebrow">ANÁLISIS HISTÓRICO</p><h1>Estadísticas imperiales</h1><p>Resultados netos de expediciones y combates, calculados desde los registros persistentes del universo.</p></header>
<div class="button-row"><a class="button" href="{{ url_for('statistics_export_action', format_name='csv') }}">Exportar estadísticas CSV</a><a class="button" href="{{ url_for('statistics_export_action', format_name='json') }}">Exportar estadísticas JSON</a><a class="button" href="{{ url_for('general_report_export_action', format_name='md') }}">Descargar informe general Markdown</a><a class="button" href="{{ url_for('general_report_export_action', format_name='bbcode') }}">Descargar informe general para foros</a><a class="button" href="{{ url_for('general_report_export_action', format_name='json') }}">Descargar informe general JSON</a></div>
<section class="panel" aria-labelledby="combat-statistics-title"><h2 id="combat-statistics-title">Combate</h2>
  <div class="metric-grid"><article><span>Batallas</span><strong>{{ combat_statistics.battles }}</strong><small>{{ combat_statistics.attacks }} ataques; {{ combat_statistics.defenses }} defensas</small></article><article><span>Victorias</span><strong>{{ combat_statistics.wins }}</strong><small>{{ combat_statistics.losses }} derrotas; {{ combat_statistics.draws }} empates</small></article><article><span>Bajas propias</span><strong>{{ combat_statistics.own_units_lost|number }}</strong><small>unidades registradas</small></article><article><span>Bajas rivales</span><strong>{{ combat_statistics.enemy_units_lost|number }}</strong><small>unidades registradas</small></article></div>
  <dl class="settings-list"><div><dt>Botín acumulado</dt><dd>{{ combat_statistics.loot.metal|number }} metal; {{ combat_statistics.loot.crystal|number }} cristal; {{ combat_statistics.loot.deuterium|number }} deuterio</dd></div><div><dt>Escombros generados</dt><dd>{{ combat_statistics.debris.metal|number }} metal; {{ combat_statistics.debris.crystal|number }} cristal; {{ combat_statistics.debris.deuterium|number }} deuterio</dd></div></dl>
  {% if combat_statistics.evolution %}<div class="table-wrap"><table><caption>Evolución mensual de la flota en combate.</caption><thead><tr><th scope="col">Período</th><th scope="col">Batallas</th><th scope="col">Victorias</th><th scope="col">Bajas propias</th><th scope="col">Bajas rivales</th></tr></thead><tbody>{% for period, values in combat_statistics.evolution.items() %}<tr><th scope="row">{{ period }}</th><td>{{ values.battles }}</td><td>{{ values.wins }}</td><td>{{ values.own_units_lost|number }}</td><td>{{ values.enemy_units_lost|number }}</td></tr>{% endfor %}</tbody></table></div>{% endif %}
  {% if combat_statistics.casualties_by_unit %}<div class="table-wrap"><table><caption>Distribución de bajas propias por unidad.</caption><thead><tr><th scope="col">Unidad</th><th scope="col">Bajas</th></tr></thead><tbody>{% for unit, amount in combat_statistics.casualties_by_unit.items() %}<tr><th scope="row">{{ SHIPS.get(unit, DEFENSES.get(unit, {})).get('name', unit) }}</th><td>{{ amount|number }}</td></tr>{% endfor %}</tbody></table></div>{% endif %}
</section>
<section class="panel" aria-labelledby="expedition-statistics-title"><h2 id="expedition-statistics-title">Expediciones</h2><p>Total lanzadas: {{ expedition_statistics.total }}.</p>
  {% if expedition_statistics.by_profile %}<div class="table-wrap"><table><caption>Coste, retorno y beneficio equivalente neto por objetivo.</caption><thead><tr><th scope="col">Perfil</th><th scope="col">Lanzadas</th><th scope="col">Éxitos</th><th scope="col">Exploradores de vuelta</th><th scope="col">Coste</th><th scope="col">Artefactos</th><th scope="col">Beneficio neto</th></tr></thead><tbody>{% for profile, values in expedition_statistics.by_profile.items() %}<tr><th scope="row">{{ EXPEDITION_PROFILES.get(profile,{}).get('name',profile) }}</th><td>{{ values.missions }}</td><td>{{ values.successes }}</td><td>{{ values.returned }}</td><td>{{ values.food_cost|number }} alimento; {{ values.deuterium_cost|number }} deuterio</td><td>{{ values.artifacts }}</td><td>{{ values.net_equivalent|number }} equivalentes de metal</td></tr>{% endfor %}</tbody></table></div>{% else %}<p class="empty-state">Aún no hay expediciones registradas.</p>{% endif %}
  {% if expedition_statistics.by_specialist %}<div class="table-wrap"><table><caption>Rendimiento por especialista.</caption><thead><tr><th scope="col">Especialista</th><th scope="col">Misiones</th><th scope="col">Éxitos</th><th scope="col">Beneficio neto</th></tr></thead><tbody>{% for specialist, values in expedition_statistics.by_specialist.items() %}<tr><th scope="row">{{ SPECIALISTS.get(specialist,{}).get('name',specialist) }}</th><td>{{ values.missions }}</td><td>{{ values.successes }}</td><td>{{ values.net_equivalent|number }}</td></tr>{% endfor %}</tbody></table></div>{% endif %}
  {% if expedition_statistics.by_risk %}<div class="table-wrap"><table><caption>Rendimiento por protocolo de riesgo.</caption><thead><tr><th scope="col">Riesgo</th><th scope="col">Misiones</th><th scope="col">Éxitos</th><th scope="col">Naves de vuelta</th><th scope="col">Beneficio neto</th></tr></thead><tbody>{% for risk, values in expedition_statistics.by_risk.items() %}<tr><th scope="row">{{ RISK_LEVELS.get(risk,{}).get('name',risk) }}</th><td>{{ values.missions }}</td><td>{{ values.successes }}</td><td>{{ values.returned }}</td><td>{{ values.net_equivalent|number }}</td></tr>{% endfor %}</tbody></table></div>{% endif %}
  <div class="table-wrap"><table><caption>Resumen por período.</caption><thead><tr><th scope="col">Período</th><th scope="col">Misiones</th><th scope="col">Éxitos</th><th scope="col">Beneficio bruto</th><th scope="col">Beneficio neto</th></tr></thead><tbody>{% for period, values in expedition_statistics.by_period.items() %}<tr><th scope="row">{{ period }}</th><td>{{ values.missions }}</td><td>{{ values.successes }}</td><td>{{ values.gross_equivalent|number }}</td><td>{{ values.net_equivalent|number }}</td></tr>{% endfor %}</tbody></table></div>
</section>
