<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<style>
@page {
  size: A4 landscape;
  margin: 1.5cm 2cm;
  @bottom-center {
    content: "Seite " counter(page) " von " counter(pages);
    font-size: 9px;
    color: #666;
  }
}
body {
  font-family: 'Helvetica', 'Arial', sans-serif;
  font-size: 11px;
  color: #222;
  margin: 0;
  padding: 0;
}
h1 {
  font-size: 20px;
  color: #1a365d;
  margin-bottom: 4px;
}
.subtitle {
  font-size: 10px;
  color: #666;
  margin-bottom: 20px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  background: #1a365d;
  color: #fff;
  padding: 8px 10px;
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tbody td {
  padding: 6px 10px;
  border-bottom: 1px solid #e0e0e0;
}
tbody tr:nth-child(even) {
  background: #f7f7f7;
}
@media print {
  body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
}
</style>
</head>
<body>
<h1>{{ title|default('Firmenliste') }}</h1>
<div class="subtitle">Erstellt am: {{ generated_at|default('') }} &nbsp;|&nbsp; Anzahl: {{ companies|length }}</div>
<table>
  <thead>
    <tr>
      <th>#</th>
      <th>Firmenname</th>
      <th>Adresse</th>
      <th>PLZ / Ort</th>
      <th>Telefon</th>
      <th>E-Mail</th>
      <th>Ansprechpartner</th>
    </tr>
  </thead>
  <tbody>
    {% for company in companies %}
    <tr>
      <td>{{ loop.index }}</td>
      <td>{{ company.name|default('') }}</td>
      <td>{{ company.address|default('—') }}</td>
      <td>{{ company.zip|default('') }} {{ company.city|default('') }}</td>
      <td>{{ company.phone|default('—') }}</td>
      <td>{{ company.email|default('—') }}</td>
      <td>{{ company.contact_person|default('—') }}</td>
    </tr>
    {% endfor %}
  </tbody>
</table>
{% if companies|length == 0 %}
<p style="text-align:center; padding:40px; color:#999;">Keine Firmen gefunden.</p>
{% endif %}
</body>
</html>
