<!doctype html>
<html lang="{{ 'de' if language_code.startswith('de') else 'en' }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ 'Verzeichnis von Verarbeitungstätigkeiten / Löschkonzept' if language_code.startswith('de') else 'Record of Processing Activities / Retention Concept' }}</title>
<style>
  :root { color-scheme: light; font-family: Arial, Helvetica, sans-serif; color: #172033; background: #fff; }
  body { max-width: 1180px; margin: 0 auto; padding: 2rem; line-height: 1.45; }
  h1 { margin-bottom: .35rem; }
  h2 { margin-top: 2rem; border-bottom: 2px solid #20a5df; padding-bottom: .35rem; }
  h3 { margin-top: 1.4rem; }
  .meta { color: #526173; margin-bottom: 1.5rem; }
  .notice { border: 1px solid #d9a400; background: #fff8d8; padding: .8rem 1rem; border-radius: .45rem; }
  dl { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: .35rem 1rem; }
  dt { font-weight: 700; }
  dd { margin: 0; white-space: pre-wrap; }
  table { width: 100%; border-collapse: collapse; margin: .8rem 0 1.5rem; font-size: .92rem; }
  th, td { border: 1px solid #b7c2ce; padding: .5rem .6rem; text-align: left; vertical-align: top; white-space: pre-wrap; }
  th { background: #d9eaf7; }
  .category { break-inside: avoid; page-break-inside: avoid; }
  .category table th { width: 24%; }
  code { overflow-wrap: anywhere; }
  @media print { body { max-width: none; padding: 0; } h2 { break-after: avoid; } a { color: inherit; text-decoration: none; } }
</style>
</head>
<body>
{% set de = language_code.startswith('de') %}
<h1>{{ 'Verzeichnis von Verarbeitungstätigkeiten / Löschkonzept' if de else 'Record of Processing Activities / Retention Concept' }}</h1>
<div class="meta">{{ 'Erzeugt' if de else 'Generated' }}: {{ generated_at }} · AssetManager {{ app_version }} · {{ 'Dokumentversion' if de else 'Document version' }}: {{ activity.document_version or '-' }}</div>
<div class="notice">{{ 'Dieser Bericht dokumentiert die konfigurierten Regeln. Automatische Löschungen sind noch nicht aktiv. Prüfläufe und manuell bestätigte Löschläufe sind für ausgewählte AssetManager-Kategorien verfügbar.' if de else 'This report documents the configured rules. Automatic deletion is not active. Dry runs and manually confirmed deletion runs are available for selected AssetManager categories.' }}</div>

<h2>{{ '1. Verarbeitungstätigkeit und Verantwortlichkeit' if de else '1. Processing activity and responsibility' }}</h2>
<dl>
  <dt>{{ 'Bezeichnung' if de else 'Title' }}</dt><dd>{{ activity.title or '-' }}</dd>
  <dt>{{ 'Verantwortlicher' if de else 'Controller' }}</dt><dd>{{ activity.controller or '-' }}</dd>
  <dt>{{ 'Fachbereich' if de else 'Responsible department' }}</dt><dd>{{ activity.responsible_department or '-' }}</dd>
  <dt>{{ 'Verantwortliche Personen' if de else 'Responsible people' }}</dt><dd>{{ activity.responsible_people or '-' }}</dd>
  <dt>{{ 'Datenschutzkontakt' if de else 'Data protection contact' }}</dt><dd>{{ activity.data_protection_contact or '-' }}</dd>
</dl>

<h2>{{ '2. Zwecke' if de else '2. Purposes' }}</h2>
<ul>{% for item in activity.purposes %}<li>{{ item }}</li>{% else %}<li>-</li>{% endfor %}</ul>

<h2>{{ '3. Rechtsgrundlage und betroffene Personen' if de else '3. Legal basis and data subjects' }}</h2>
<dl><dt>{{ 'Rechtsgrundlage' if de else 'Legal basis' }}</dt><dd>{{ activity.legal_basis or '-' }}</dd><dt>{{ 'Betroffene Personengruppen' if de else 'Data subject groups' }}</dt><dd>{{ activity.data_subject_groups or '-' }}</dd></dl>

<h2>{{ '4. Empfänger und Drittlandübermittlung' if de else '4. Recipients and third-country transfers' }}</h2>
<dl>
  <dt>{{ 'Interne Empfänger' if de else 'Internal recipients' }}</dt><dd>{{ activity.internal_recipients or '-' }}</dd>
  <dt>{{ 'Externe Empfänger' if de else 'External recipients' }}</dt><dd>{{ activity.external_recipients or '-' }}</dd>
  <dt>{{ 'Drittlandübermittlung' if de else 'Third-country transfer' }}</dt><dd>{{ ('Ja' if activity.third_country_transfer else 'Nein') if de else ('Yes' if activity.third_country_transfer else 'No') }}</dd>
  <dt>{{ 'Details' if de else 'Details' }}</dt><dd>{{ activity.third_country_details or '-' }}</dd>
</dl>

<h2>{{ '5. Systeme und Sicherungen' if de else '5. Systems and backups' }}</h2>
<dl>
  <dt>{{ 'Systeme' if de else 'Systems' }}</dt><dd>{{ activity.systems or '-' }}</dd>
  <dt>{{ 'Backup-System' if de else 'Backup system' }}</dt><dd>{{ activity.backup_system or '-' }}</dd>
  <dt>{{ 'Backup-Aufbewahrung' if de else 'Backup retention' }}</dt><dd>{{ activity.backup_retention_days if activity.backup_retention_days is not none else '-' }} {{ 'Tage' if de else 'days' }}</dd>
  <dt>{{ 'Verfahren nach Wiederherstellung' if de else 'Restore procedure' }}</dt><dd>{{ activity.restore_deletion_procedure or '-' }}</dd>
</dl>

<h2>{{ '6. Datenkategorien und Löschfristen' if de else '6. Data categories and retention' }}</h2>
{% for category in settings.categories %}
<section class="category">
<h3>6.{{ loop.index }} {{ category.name }}</h3>
<table>
<tr><th>{{ 'System' if de else 'System' }}</th><td>{{ category.system or '-' }}</td></tr>
<tr><th>{{ 'Betroffene Personen' if de else 'Data subjects' }}</th><td>{{ category.data_subjects or '-' }}</td></tr>
<tr><th>{{ 'Personenbezogene Daten' if de else 'Personal data' }}</th><td>{{ category.personal_data or '-' }}</td></tr>
<tr><th>{{ 'Zweck' if de else 'Purpose' }}</th><td>{{ category.purpose or '-' }}</td></tr>
<tr><th>{{ 'Löschart' if de else 'Retention type' }}</th><td>{{ category.retention_type or '-' }}</td></tr>
<tr><th>{{ 'Löschfrist' if de else 'Retention period' }}</th><td>{{ category.retention_days if category.retention_days is not none else '-' }} {{ 'Tage' if de else 'days' }}</td></tr>
<tr><th>{{ 'Fristbeginn/Auslöser' if de else 'Trigger' }}</th><td>{{ category.retention_trigger or '-' }}</td></tr>
<tr><th>{{ 'Automatisch technisch möglich' if de else 'Automatic deletion technically possible' }}</th><td>{{ ('Ja' if category.automatic_possible else 'Nein') if de else ('Yes' if category.automatic_possible else 'No') }}</td></tr>
<tr><th>{{ 'Manuelles Verfahren' if de else 'Manual procedure' }}</th><td>{{ category.manual_procedure or '-' }}</td></tr>
<tr><th>{{ 'Behandlung in Sicherungen' if de else 'Backup handling' }}</th><td>{{ category.backup_handling or '-' }}</td></tr>
<tr><th>{{ 'Verantwortlich' if de else 'Responsible' }}</th><td>{{ category.responsible or '-' }}</td></tr>
<tr><th>{{ 'Hinweise' if de else 'Notes' }}</th><td>{{ category.notes or '-' }}</td></tr>
</table>
</section>
{% endfor %}

<h2>{{ '7. Technische und organisatorische Maßnahmen' if de else '7. Technical and organisational measures' }}</h2>
<ul>{% for item in activity.toms %}<li>{{ item }}</li>{% else %}<li>-</li>{% endfor %}</ul>

<h2>{{ '8. Dokumentenprüfung' if de else '8. Document review' }}</h2>
<dl>
  <dt>{{ 'Prüfintervall' if de else 'Review interval' }}</dt><dd>{{ activity.review_interval_months or 12 }} {{ 'Monate' if de else 'months' }}</dd>
  <dt>{{ 'Zuletzt geprüft' if de else 'Last reviewed' }}</dt><dd>{{ activity.last_reviewed_at or '-' }}</dd>
  <dt>{{ 'Freigegeben durch' if de else 'Approved by' }}</dt><dd>{{ activity.approved_by or '-' }}</dd>
</dl>

<h2>{{ '9. Änderungsprotokoll' if de else '9. Policy audit' }}</h2>
<table><thead><tr><th>{{ 'Zeitstempel UTC' if de else 'Timestamp UTC' }}</th><th>{{ 'Aktion' if de else 'Action' }}</th><th>{{ 'Geändert von' if de else 'Changed by' }}</th><th>Details</th></tr></thead><tbody>
{% for row in privacy_audit %}<tr><td>{{ row.timestamp_utc }}</td><td>{{ row.action }}</td><td>{{ row.changed_by }}</td><td><code>{{ row.details }}</code></td></tr>{% else %}<tr><td colspan="4">-</td></tr>{% endfor %}
</tbody></table>
</body>
</html>
