{% extends 'base.html' %}
{% block title %}运营面板 - 配额视图{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-3">
  <h3>配额视图（全局 / 套餐 / 用户 / 域名额外）</h3>
  <div>
    <a class="btn btn-outline-secondary" href="{% url 'admin_panel:dashboard' %}">返回概览</a>
  </div>
</div>

<form method="get" class="row g-2 mb-3">
  <div class="col-md-3">
    <input type="number" name="user_id" value="{{ user_id }}" class="form-control" placeholder="用户ID（可选）" />
  </div>
  <div class="col-md-2">
    <button class="btn btn-primary" type="submit">筛选</button>
  </div>
</form>

<div class="table-responsive">
  <table class="table table-striped">
    <thead>
      <tr>
        <th>域名</th>
        <th>用户</th>
        <th>套餐流量（GB）</th>
        <th>用户默认覆盖（GB）</th>
        <th>全局默认（GB）</th>
        <th>域名本周期额外（GB）</th>
        <th>总可用（GB）</th>
      </tr>
    </thead>
    <tbody>
      {% for r in rows %}
      <tr>
        <td>{{ r.domain.name }}</td>
        <td>{{ r.domain.user.username }}</td>
        <td>{{ r.plan_quota }}</td>
        <td>{{ r.user_override }}</td>
        <td>{{ r.global_default }}</td>
        <td>{{ r.domain_extra }}</td>
        <td><strong>{{ r.total_quota }}</strong></td>
      </tr>
      {% empty %}
      <tr><td colspan="7" class="text-center">暂无数据</td></tr>
      {% endfor %}
    </tbody>
  </table>
</div>
{% endblock %}