<!-- Sektion: Pachtbericht -->
<div class="section">
  <h2>Pachtbericht{% if jahr %} {{ jahr }}{% endif %}</h2>

  {% if pacht_statistik %}
  <div class="stats-grid">
    <div class="stat-card">
      <div class="value">{{ pacht_statistik.aktive_vertraege }}</div>
      <div class="label">Aktive Pachtvertr&auml;ge</div>
    </div>
    <div class="stat-card">
      <div class="value">&#8364;{{ pacht_statistik.total_pachtzins|floatformat:2 }}</div>
      <div class="label">Gesamtpachtzins p.a.</div>
    </div>
    <div class="stat-card">
      <div class="value">{{ pacht_statistik.total_flaeche|floatformat:0 }} qm</div>
      <div class="label">Verpachtete Fl&auml;che</div>
    </div>
    <div class="stat-card">
      <div class="value">{{ pacht_statistik.auslaufend_12m }}</div>
      <div class="label">Laufen in 12 Mon. aus</div>
    </div>
  </div>
  {% endif %}

  {% if pacht_auslaufend %}
  <h3>Auslaufende Vertr&auml;ge (n&auml;chste 12 Monate)</h3>
  <table>
    <thead>
      <tr>
        <th>L&auml;nderei</th>
        <th>P&auml;chter</th>
        <th>Pachtende</th>
        <th>Pachtzins</th>
      </tr>
    </thead>
    <tbody>
      {% for v in pacht_auslaufend %}
      <tr>
        <td>{{ v.land }}</td>
        <td>{{ v.paechter.get_full_name }}</td>
        <td>{{ v.pachtende|date:"d.m.Y" }}</td>
        <td class="amount">&#8364;{{ v.pachtzins_pauschal|floatformat:2 }}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
  {% endif %}

  {% if verpachtungen %}
  <h3>Alle Verpachtungen</h3>
  <table>
    <thead>
      <tr>
        <th>L&auml;nderei</th>
        <th>P&auml;chter</th>
        <th>Fl&auml;che</th>
        <th>Pachtzins</th>
        <th>Beginn</th>
        <th>Ende</th>
        <th>Status</th>
      </tr>
    </thead>
    <tbody>
      {% for v in verpachtungen %}
      <tr>
        <td>{{ v.land }}</td>
        <td>{{ v.paechter.get_full_name }}</td>
        <td class="amount">{{ v.verpachtete_flaeche|floatformat:0 }} qm</td>
        <td class="amount">&#8364;{{ v.pachtzins_pauschal|floatformat:2 }}</td>
        <td>{{ v.pachtbeginn|date:"d.m.Y" }}</td>
        <td>{% if v.pachtende %}{{ v.pachtende|date:"d.m.Y" }}{% else %}unbefristet{% endif %}</td>
        <td>
          <span class="status-badge status-{{ v.status }}">{{ v.get_status_display }}</span>
        </td>
      </tr>
      {% endfor %}
    </tbody>
    <tfoot>
      <tr style="font-weight: bold; background: #f0f7f4;">
        <td colspan="3">Gesamtpachtzins</td>
        <td class="amount">&#8364;{{ total_pachtzins|floatformat:2 }}</td>
        <td colspan="3"></td>
      </tr>
    </tfoot>
  </table>
  {% endif %}
</div>
