{% extends "base.html" %}{% block content %}
<div class="page-header">
 <div class="titles">
  <h1>Dashboard</h1>
  <p class="subtitle">Local operator console — managing live cloud resources.</p>
 </div>
</div>

<div class="card">
 <p class="card-title">Cost <span class="badge badge-neutral">estimate</span></p>
 <div class="card-body">
  <!-- COST_PANEL -->
  {% if cost and cost.lines %}
  <div class="stat-grid">
   <div class="stat"><div class="num">&euro;{{ "%.4f"|format(cost.hourly) }}</div><div class="label">per hour</div></div>
   <div class="stat"><div class="num">&euro;{{ "%.2f"|format(cost.daily) }}</div><div class="label">per day</div></div>
   <div class="stat"><div class="num" style="color:#43a047">&euro;{{ "%.2f"|format(cost.monthly) }}</div><div class="label">per month (projected)</div></div>
   <div class="stat"><div class="num">&euro;{{ "%.2f"|format(cost.accrued) }}</div><div class="label">accrued so far</div></div>
  </div>
  <div class="table-wrap" style="margin-top:1rem">
   <table>
    <thead><tr><th>Resource</th><th>Type</th><th>Spec</th><th class="num">Rate/h</th><th class="num">Age</th><th class="num">Accrued</th></tr></thead>
    <tbody>
    {% for ln in cost.lines %}
     <tr>
      <td class="mono">{{ ln.name }}</td>
      <td><span class="badge {% if ln.kind == 'server' %}badge-info{% elif ln.kind == 'volume' %}badge-neutral{% else %}badge-warn{% endif %}">{{ ln.kind }}</span></td>
      <td>{{ ln.detail }}</td>
      <td class="num">&euro;{{ "%.4f"|format(ln.hourly) }}{% if ln.kind == 'server' and not ln.exact %}*{% endif %}</td>
      <td class="num">{% if ln.age_hours is not none %}{{ "%.1f"|format(ln.age_hours) }}h{% else %}&mdash;{% endif %}</td>
      <td class="num">&euro;{{ "%.4f"|format(ln.accrued) }}</td>
     </tr>
    {% endfor %}
    </tbody>
   </table>
  </div>
  <p class="muted" style="margin-top:.75rem;font-size:.8rem">
   Best-effort Infomaniak public-cloud rates (June 2026), configurable &mdash; verify against your invoice.
   {% if cost.any_estimated %}<br>* rate estimated from flavor specs (not in the price table).{% endif %}
  </p>
  {% else %}
  <div class="placeholder">No billable resources.</div>
  {% endif %}
 </div>
</div>

<div class="stat-grid">
 <div class="stat"><div class="num">{{ vms|length }}</div><div class="label">VMs</div></div>
 <div class="stat"><div class="num">{{ volumes|length }}</div><div class="label">Volumes</div></div>
 <div class="stat"><div class="num">{{ fips|length }}</div><div class="label">Floating IPs</div></div>
 <div class="stat"><div class="num">{{ secgroups|length }}</div><div class="label">Security groups</div></div>
 <div class="stat"><div class="num">{{ keypairs|length }}</div><div class="label">Keypairs</div></div>
 <div class="stat"><div class="num">{{ containers|length }}</div><div class="label">Containers</div></div>
</div>
{% endblock %}
