<!doctype html>
<html lang="de">
<head>
  <meta charset="utf-8">
  <title>{{ bericht_titel }} – {{ corporate_settings.stiftung_name }}</title>
  <style>
    {{ css_content }}
    /* Cover page styles */
    .cover-page {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      min-height: 85vh;
      text-align: center;
    }
    .cover-logo-img { max-height: 100px; max-width: 250px; margin-bottom: 30px; }
    .cover-title h1 {
      font-size: 24pt;
      color: {{ corporate_settings.primary_color|default:"#2c3e50" }};
      margin: 0 0 10px 0;
      border-bottom: none;
    }
    .cover-title h2 {
      font-size: 18pt;
      color: {{ corporate_settings.secondary_color|default:"#3498db" }};
      margin: 0 0 5px 0;
    }
    .cover-subtitle { font-size: 12pt; color: #666; }
    .cover-meta { margin-top: 40px; font-size: 11pt; color: #555; }
    .cover-meta p { margin: 5px 0; }
    .cover-footer { margin-top: 60px; font-size: 9pt; color: #999; }
    .cover-footer p { margin: 3px 0; }
    .cover-confidential {
      margin-top: 15px !important;
      font-weight: bold;
      color: {{ corporate_settings.primary_color|default:"#2c3e50" }} !important;
      font-size: 10pt;
    }
    /* Bilanz cards */
    .bilanz-grid {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 16px;
      margin-bottom: 20px;
    }
    .bilanz-card { border-radius: 8px; padding: 16px; text-align: center; }
    .bilanz-card.einnahmen { background: #d4edda; border: 1px solid #c3e6cb; }
    .bilanz-card.ausgaben { background: #f8d7da; border: 1px solid #f5c6cb; }
    .bilanz-card.netto-positiv { background: #d1ecf1; border: 1px solid #bee5eb; }
    .bilanz-card.netto-negativ { background: #fff3cd; border: 1px solid #ffeeba; }
    .bilanz-card .value { font-size: 1.5em; font-weight: bold; }
    .bilanz-card .label { font-size: 0.85em; margin-top: 4px; color: #555; }
    /* Status badges extra */
    .status-aktiv { background-color: #d4edda; color: #155724; }
    .status-beendet { background-color: #e2e3e5; color: #383d41; }
    .status-gekuendigt { background-color: #f8d7da; color: #721c24; }
    .status-geplant, .status-faellig { background-color: #e2e3e5; color: #383d41; }
    .status-abgeschlossen { background-color: #d4edda; color: #155724; }
  </style>
</head>
<body>
  {% if show_cover %}
  {% include "berichte/cover_page.html" %}
  {% endif %}

  <!-- Kopfzeile (auf jeder Seite nach dem Deckblatt) -->
  <div class="header">
    <div class="header-content">
      <div class="header-left">
        {% if logo_base64 %}
        <img src="{{ logo_base64 }}" alt="Logo" class="logo">
        {% endif %}
        <p class="stiftung-name">{{ corporate_settings.stiftung_name }}</p>
        <p class="document-title">{{ bericht_titel }}</p>
      </div>
      <div class="header-right">
        <div class="contact-info">
          {% if corporate_settings.address_line1 %}<p>{{ corporate_settings.address_line1 }}</p>{% endif %}
          {% if corporate_settings.address_line2 %}<p>{{ corporate_settings.address_line2 }}</p>{% endif %}
          {% if corporate_settings.phone %}<p>{{ corporate_settings.phone }}</p>{% endif %}
          {% if corporate_settings.email %}<p>{{ corporate_settings.email }}</p>{% endif %}
        </div>
      </div>
    </div>
    <div class="header-info">
      Erstellt am {% now "d.m.Y" %}{% if berichtszeitraum %} &middot; Zeitraum: {{ berichtszeitraum }}{% endif %}
    </div>
  </div>

  <!-- Dynamische Sektionen -->
  {% for sektion in sektionen %}
    {% if sektion == "bilanz" %}{% include "berichte/sektionen/bilanz.html" %}
    {% elif sektion == "unterstuetzungen" %}{% include "berichte/sektionen/unterstuetzungen.html" %}
    {% elif sektion == "foerderungen" %}{% include "berichte/sektionen/foerderungen.html" %}
    {% elif sektion == "grundstuecke" %}{% include "berichte/sektionen/grundstuecke.html" %}
    {% elif sektion == "verwaltungskosten" %}{% include "berichte/sektionen/verwaltungskosten.html" %}
    {% elif sektion == "destinataere_uebersicht" %}{% include "berichte/sektionen/destinataere_uebersicht.html" %}
    {% elif sektion == "konten_uebersicht" %}{% include "berichte/sektionen/konten_uebersicht.html" %}
    {% elif sektion == "verpachtungen" %}{% include "berichte/sektionen/verpachtungen.html" %}
    {% endif %}
  {% endfor %}

  <div class="footer">
    <p>{{ bericht_titel }} &mdash; automatisch generiert von der Stiftungsverwaltung</p>
    <p>{{ corporate_settings.stiftung_name }} &middot; {{ corporate_settings.footer_text }}</p>
  </div>
</body>
</html>
