<section id="intelligence-center" aria-labelledby="intelligence-center-title" data-tab-panel data-tab-id="mando-inteligencia" data-tab-label="Inteligencia">
  <p class="eyebrow">MEMORIA, NO OMNISCIENCIA</p><h2 id="intelligence-center-title" class="section-title">Inteligencia y objetivos conocidos</h2>
  <div class="dashboard-grid">
    <section class="panel" aria-labelledby="bookmarks-title"><h3 id="bookmarks-title">Registro estratégico</h3><form method="post" action="{{ url_for('bookmark_save_action') }}" class="stacked-form"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}"><label>Planeta conocido<select name="planet_id">{% for target in rival_planets %}<option value="{{ target.id }}">{{ target.empire_name }} · {{ target.name }} [{{ target.galaxy }}:{{ target.system }}:{{ target.position }}]</option>{% endfor %}</select></label><label>Etiqueta<input name="label" maxlength="48" placeholder="Ejemplo: socio de deuterio"></label><label>Prioridad<select name="priority">{% for key, label in BOOKMARK_PRIORITIES.items() %}<option value="{{ key }}">{{ label }}</option>{% endfor %}</select></label><label>Nota<textarea name="note" rows="3" maxlength="240"></textarea></label><button class="button" type="submit">Guardar o actualizar marcador</button></form>
      {% if bookmarks %}<ul class="bookmark-list">{% for bookmark in bookmarks %}<li><article><h4>{{ bookmark.label or bookmark.planet_name }}</h4><p>{{ BOOKMARK_PRIORITIES[bookmark.priority] }} · {{ bookmark.empire_name }} · [{{ bookmark.galaxy }}:{{ bookmark.system }}:{{ bookmark.position }}]</p>{% if bookmark.note %}<p>{{ bookmark.note }}</p>{% endif %}<div class="button-row"><a class="button" href="{{ url_for('game_view', section='fleet', galaxy=bookmark.galaxy, system=bookmark.system, position=bookmark.position) }}">Preparar misión</a><form method="post" action="{{ url_for('bookmark_delete_action') }}"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}"><input type="hidden" name="bookmark_id" value="{{ bookmark.id }}"><button class="button button-danger" type="submit">Eliminar marcador</button></form></div></article></li>{% endfor %}</ul>{% endif %}
    </section>
    <section class="panel" aria-labelledby="intel-reports-title"><h3 id="intel-reports-title">Últimos espionajes persistentes</h3>{% if intelligence_reports %}<ol class="intel-list">{% for report in intelligence_reports %}<li><article><h4>{{ report.target_name }} [{{ report.galaxy }}:{{ report.system }}:{{ report.position }}]</h4><p>{{ report.target_empire_name }} · observado hace {{ (now-report.observed_at)|duration }} · detalle {{ report.detail_level }} de 4 · confianza global {{ report.confidence }} %{% if report.possibly_false %} · posibles señuelos{% endif %}</p><details><summary>Consultar estimaciones y confianza</summary>{% set estimates = report.estimates_json|from_json %}{% if estimates %}{% for category, details in estimates.items() %}<h5>{{ category }}: {{ details.label }}, {{ details.confidence }} %</h5>{% if details['values'] %}<ul>{% for key, value in details['values'].items() %}<li>{{ key }}: {% if value is mapping %}entre {{ value.min }} y {{ value.max }}{% else %}{{ value }} confirmado{% endif %}</li>{% endfor %}</ul>{% else %}<p>Sin datos.</p>{% endif %}{% endfor %}{% else %}<p>Informe antiguo sin desglose de confianza; vuelve a observar el objetivo antes de asumir cifras exactas.</p>{% endif %}</details></article></li>{% endfor %}</ol>{% else %}<p class="empty-state">Los próximos espionajes se archivarán aquí con la información que realmente alcance tu tecnología.</p>{% endif %}</section>
  </div>
</section>

<section id="logistics-orders" aria-labelledby="logistics-orders-title" data-tab-panel data-tab-id="mando-logistica" data-tab-label="Logística">
  <p class="eyebrow">RUTAS REPETIBLES, DECISIONES HUMANAS</p><h2 id="logistics-orders-title" class="section-title">Órdenes logísticas guardadas</h2>
  <p>Guarda una ruta de abastecimiento, comercio, ayuda o patrulla. Cada salida requiere pulsar Ejecutar ahora y vuelve a comprobar naves, carga, combustible, relaciones y ranuras.</p>
  <div class="dashboard-grid">
    <section class="panel" aria-labelledby="new-logistics-title"><h3 id="new-logistics-title">Definir una orden</h3>{% if fleet_templates %}<form method="post" action="{{ url_for('logistics_save_action') }}" class="stacked-form"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}"><label>Nombre<input name="name" maxlength="48" required placeholder="Ejemplo: Cristal para la capital"></label><label>Origen<select name="origin_planet_id">{% for own in planets %}<option value="{{ own.id }}">{{ own.name }} [{{ own.galaxy }}:{{ own.system }}:{{ own.position }}]</option>{% endfor %}</select></label><label>Destino<select name="target_planet_id">{% for target in all_planets_for_logistics %}<option value="{{ target.id }}">{{ target.empire_name }} · {{ target.name }} [{{ target.galaxy }}:{{ target.system }}:{{ target.position }}]</option>{% endfor %}</select></label><label>Plantilla<select name="template_id">{% for template in fleet_templates %}<option value="{{ template.id }}">{{ template.name }}</option>{% endfor %}</select></label><label>Tipo de ruta<select name="mission"><option value="transport">Transporte</option><option value="relief">Ayuda humanitaria</option><option value="trade_route">Ruta comercial</option><option value="patrol">Patrulla aliada</option></select></label><fieldset><legend>Carga de esta orden</legend><div class="form-grid"><label>Metal<input name="cargo_metal" type="number" min="0" value="0"></label><label>Cristal<input name="cargo_crystal" type="number" min="0" value="0"></label><label>Deuterio<input name="cargo_deuterium" type="number" min="0" value="0"></label><label>Alimento<input name="cargo_food" type="number" min="0" value="0"></label></div></fieldset><button class="button" type="submit">Guardar orden sin ejecutarla</button></form>{% else %}<p class="empty-state">Crea primero una plantilla de flota.</p>{% endif %}</section>
    <section class="panel" aria-labelledby="saved-logistics-title"><h3 id="saved-logistics-title">Órdenes disponibles</h3>{% if logistics_orders %}<ul class="logistics-list">{% for order in logistics_orders %}<li><article><h4>{{ order.name }}</h4><p>{{ MISSIONS[order.mission] }} · {{ order.origin_name }} a {{ order.target_name or 'destino desaparecido' }} [{{ order.galaxy }}:{{ order.system }}:{{ order.position }}] · {{ order.template_name or 'sin plantilla' }}</p><p>{% if order.last_run %}Última ejecución hace {{ (now-order.last_run)|duration }}{% else %}Nunca ejecutada{% endif %}</p><div class="button-row"><form method="post" action="{{ url_for('logistics_execute_action') }}"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}"><input type="hidden" name="order_id" value="{{ order.id }}"><button class="button button-primary" type="submit" {% if not order.target_planet_id or not order.fleet_template_id %}disabled{% endif %}>Ejecutar ahora</button></form><form method="post" action="{{ url_for('logistics_delete_action') }}"><input type="hidden" name="csrf_token" value="{{ csrf_token() }}"><input type="hidden" name="order_id" value="{{ order.id }}"><button class="button button-danger" type="submit">Eliminar orden</button></form></div></article></li>{% endfor %}</ul>{% else %}<p class="empty-state">No hay órdenes guardadas.</p>{% endif %}</section>
  </div>
</section>
