@font-face { font-family: 'Playfair Display'; src: url("fonts/playfair-display-v40-latin-regular.8a53e5ecdbff.woff2") format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Playfair Display'; src: url("fonts/playfair-display-v40-latin-700.9401d0214a93.woff2") format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  --bg: #f4f7fa;
  --side: #e6eef5;
  --card: #ffffff;
  --line: #d9e4ee;
  --line-strong: #9bb6ca;
  --input-line: #bcd0df;
  --pastel: #7fa8c4;
  --action: #3f6f8f;
  --action-dark: #2f5d7c;
  --ink: #1f3a4a;
  --muted: #4b6677;
  --accent: #e07a3c;
  --accent-soft: #fbe6d8;
  --ok: #2f7d5b;
  --danger: #b3382c;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 4px 14px rgba(63, 111, 143, 0.08);
  --serif: 'Playfair Display', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--sans); color: var(--ink); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--serif); margin: 0; font-weight: 700; }
h1 { font-size: 34px; }
h2 { font-size: 22px; }
p { margin: 0; }
a { color: var(--action); }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--pastel); outline-offset: 2px; border-radius: 6px; }

/* Bedienelemente */
.btn { min-height: 44px; padding: 0 20px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn-primary { background: var(--action); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--action-dark); color: #fff; }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--side); color: var(--ink); }
.btn-danger { background: #fff; color: var(--danger); border-color: #e3b5af; }
.btn-danger:hover:not(:disabled) { background: #fbeceb; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; min-height: 48px; border: 1px solid var(--input-line); border-radius: var(--radius-sm);
  padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink); background: #fff;
}
textarea { resize: vertical; min-height: 84px; }
input[type=file] { font: inherit; font-size: 15px; width: 100%; }
.field { margin-bottom: 16px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.error { background: #fbeceb; color: #7d231a; border: 1px solid #e3b5af; border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; margin-bottom: 16px; }
.notice { background: var(--side); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14px; color: var(--ink); }
.notice-warn { background: var(--accent-soft); border-color: #f0c7a9; }
.muted { color: var(--muted); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.pill { display: inline-block; font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--side); color: var(--ink); }
.pill-accent { background: var(--accent-soft); }
.pill-ok { background: #dff1e8; }
.pill-bad { background: #fbeceb; color: #7d231a; }

/* Karten */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.card h2 { margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.side { width: 248px; flex-shrink: 0; background: var(--side); border-right: 1px solid #d3e0ea; padding: 28px 20px; display: flex; flex-direction: column; gap: 28px; }
.brand { font-family: var(--serif); font-size: 30px; font-weight: 700; letter-spacing: 0.5px; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a { display: block; padding: 12px 14px; border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-size: 15px; }
.nav a:hover { background: #dbe7f0; }
.nav a[aria-current=page] { background: var(--action); color: #fff; font-weight: 600; }
.side-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.main { flex-grow: 1; padding: 40px 48px; max-width: 1120px; width: 100%; }
.page-head { margin-bottom: 28px; }
.page-head p { color: var(--muted); margin-top: 6px; font-size: 16px; }

/* Anmeldung */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-box { width: 100%; max-width: 440px; }
.auth-box .brand { text-align: center; margin-bottom: 8px; }
.auth-box .tagline { text-align: center; color: var(--muted); margin-bottom: 24px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--side); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 20px; }
.tabs button { min-height: 44px; border: 0; border-radius: 9px; background: transparent; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; }
.tabs button[aria-selected=true] { background: #fff; box-shadow: var(--shadow); }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--action); text-decoration: underline; cursor: pointer; }

.recovery-key { font-family: Menlo, Consolas, monospace; font-size: 20px; letter-spacing: 1px; text-align: center; background: var(--bg); border: 1px dashed var(--pastel); border-radius: var(--radius-sm); padding: 18px 12px; margin: 16px 0; word-break: break-all; user-select: all; }

/* Speicherbalken */
.bar { height: 12px; background: var(--side); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--pastel); border-radius: 999px; }
.bar.full > span { background: var(--accent); }

/* Listen und Tabellen */
.doc-list { display: flex; flex-direction: column; gap: 10px; }
.doc { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; flex-wrap: wrap; }
.doc-main { min-width: 0; flex: 1 1 260px; }
.doc-name { font-weight: 600; overflow-wrap: anywhere; }
.doc-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: #fff; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); }
.chip[aria-pressed=true] { background: var(--action); border-color: var(--action); color: #fff; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 600; color: var(--muted); white-space: nowrap; }
td select, td input[type=number], td input[type=text] { min-height: 38px; padding: 4px 8px; font-size: 14px; width: auto; }
.stat { font-family: var(--serif); font-size: 32px; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side { width: 100%; border-right: 0; border-bottom: 1px solid #d3e0ea; padding: 14px 16px; gap: 12px; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .brand { font-size: 24px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 4px; order: 3; width: 100%; }
  .nav a { padding: 10px 12px; }
  .side-bottom { margin-top: 0; margin-left: auto; flex-direction: row; }
  .side-bottom .hint { display: none; }
  .main { padding: 24px 16px; }
  h1 { font-size: 28px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
}

@media print {
  body * { visibility: hidden; }
  .printable, .printable * { visibility: visible; }
  .printable { position: absolute; left: 0; top: 0; width: 100%; padding: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Ergänzungen für die PHP-Version (keine Inline-Stile, damit die Schutzregeln streng bleiben) */
.tabs a { display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 9px; font-weight: 600; color: var(--ink); text-decoration: none; }
.tabs a[aria-current=page] { background: #fff; box-shadow: var(--shadow); }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }
.gap-16 { gap: 16px; } .w-full { width: 100%; } .center { text-align: center; } .nowrap { flex-wrap: nowrap; align-items: flex-start; }
.end { align-items: flex-end; } .span-all { grid-column: 1 / -1; }
.auth-box.wide { max-width: 560px; }
.check { width: 22px; height: 22px; min-height: 0; }
label.plain { font-weight: 400; margin: 0; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.inline-form form { margin: 0; }
progress { width: 100%; height: 12px; border: 0; border-radius: 999px; background: var(--side); overflow: hidden; display: block; appearance: none; -webkit-appearance: none; }
progress::-webkit-progress-bar { background: var(--side); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--pastel); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--pastel); border-radius: 999px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--action); text-decoration: underline; cursor: pointer; }
.side-bottom form { margin: 0; }

/* Schnell verlassen: immer oben sichtbar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: flex-end; align-items: center; gap: 16px; min-height: 60px; padding: 8px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar form { margin: 0; }
.topbar-note { font-size: 13px; color: var(--muted); }
.btn-exit { background: var(--ink); color: #fff; min-height: 44px; }
.btn-exit:hover { background: #12262f; color: #fff; }
.shell { min-height: calc(100vh - 61px); }
@media (max-width: 860px) { .topbar-note { display: none; } .topbar { padding: 8px 12px; } }

/* Häufige Fragen */
.faq { display: flex; flex-direction: column; gap: 10px; }
.faq-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 4px 16px; }
.faq-item summary { cursor: pointer; font-weight: 600; padding: 12px 0; list-style-position: outside; }
.faq-item[open] summary { border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.faq-item p { padding-bottom: 14px; color: var(--ink); }
.faq-public .card .page-head { margin-bottom: 18px; }

/* ---------- Ergänzungen TORG 0.2 (Python-Version) ---------- */
input[type=date], input[type=datetime-local], input[type=url], input[type=search], input[type=tel] {
  width: 100%; min-height: 48px; border: 1px solid var(--input-line); border-radius: var(--radius-sm);
  padding: 10px 12px; font: inherit; font-size: 16px; color: var(--ink); background: #fff;
}
input[type=checkbox] { width: 22px; height: 22px; min-height: 0; accent-color: var(--action); }
.field.check-field { display: flex; gap: 10px; align-items: center; }
.field.check-field label { margin: 0; font-weight: 400; }
.fehlertext { color: var(--danger); }
.form-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.topbar { justify-content: space-between; }
.topbar-links { display: flex; gap: 10px; align-items: center; }
.topbar-rechts { display: flex; gap: 16px; align-items: center; }
.side .hint { overflow-wrap: anywhere; }
.page-head.row { justify-content: space-between; align-items: flex-end; }
.page-head .row { gap: 8px; }
.banner { border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; font-size: 15px; border: 1px solid var(--line); background: var(--side); }
.banner.warnung { background: var(--accent-soft); border-color: #f0c7a9; }
.banner strong { margin-right: 6px; }
.meldung { margin-bottom: 16px; }
section.card { margin-bottom: 24px; }
.card h2 + .muted { margin-top: -6px; margin-bottom: 14px; }
tr.ueberfaellig td { background: #fbeceb; }
tr.erledigt td { color: var(--muted); }
.notiz { border-left: 3px solid var(--pastel); padding: 6px 14px; margin: 14px 0; }
.notiz .doc-meta { margin-bottom: 4px; }
.text { white-space: pre-line; }
.daten { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 0; }
.daten dt { color: var(--muted); font-size: 14px; }
.daten dd { margin: 0; }
details.neu { margin-top: 16px; }
details.neu > summary { cursor: pointer; font-weight: 600; color: var(--action); margin-bottom: 14px; }
.suchzeile { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.suchzeile input { flex: 1 1 260px; }
.seiten { display: flex; gap: 16px; align-items: center; margin-top: 16px; }
.qr { background: #fff; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); width: 220px; }
.qr svg { width: 100%; height: auto; display: block; }
.code { font-family: Menlo, Consolas, monospace; letter-spacing: 1px; }
.link-kopie { font-family: Menlo, Consolas, monospace; font-size: 13px; word-break: break-all; background: var(--bg); border: 1px dashed var(--pastel); border-radius: var(--radius-sm); padding: 10px 12px; user-select: all; }
.stat-zeile { display: flex; justify-content: space-between; gap: 12px; }
.kachel-link { text-decoration: none; color: inherit; display: block; }
.kachel-link:hover { border-color: var(--line-strong); }
.anker { scroll-margin-top: 80px; }
.aktionen-zeile { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.aktionen-zeile form { margin: 0; }
@media (max-width: 860px) { .daten { grid-template-columns: 1fr; } .topbar-note { display: none; } }
.grid2 > section.card, .grid3 > .card, .grid2 > .card { margin-bottom: 0; }
.grid2 { margin-bottom: 24px; }

/* ---------- 0.3: schmalere Formulare, Feldgruppen, Reiter, Speicherstatus ---------- */
.formkarte { max-width: 780px; }
fieldset { border: 0; border-top: 1px solid var(--line); margin: 0 0 8px; padding: 16px 0 0; }
fieldset:first-of-type { border-top: 0; padding-top: 0; }
legend { font-family: var(--serif); font-weight: 700; font-size: 18px; padding: 0 0 8px; }
.feldreihe { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.feldreihe.r-anrede { grid-template-columns: 180px 1fr; }
.feldreihe.r-art { grid-template-columns: 1fr 160px; }
.feldreihe.r-art2 { grid-template-columns: 1fr 220px; }
.feldreihe.r-plz { grid-template-columns: 140px 1fr; }
.speicherstatus { font-size: 13px; color: var(--muted); margin: -4px 0 14px; min-height: 18px; }
.speicherstatus.ok { color: var(--ok); }
.speicherstatus.fehler { color: var(--danger); font-weight: 600; }
.reiter-nav { display: flex; flex-wrap: wrap; grid-template-columns: none; margin-bottom: 24px; }
.reiter-nav a { padding: 0 16px; }
input.schmal { width: 80px; }
.field ul { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 6px; }
.field ul label { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 0; color: var(--ink); }
@media (max-width: 860px) {
  .feldreihe, .feldreihe.r-anrede, .feldreihe.r-art, .feldreihe.r-art2, .feldreihe.r-plz { grid-template-columns: 1fr; }
}

td input.schmal { width: 80px !important; }

/* Helferzugang: Aenderungsknoepfe ausblenden (die Sperre selbst liegt im Server und in der Datenbank) */
body.helfer details.neu, body.helfer .btn-danger, body.helfer a[href*="/bearbeiten/"], body.helfer a[href*="/neu/"],
body.helfer a[href*="/loeschen/"], body.helfer a[href*="/entfernen/"], body.helfer form[action*="/zuordnen/"],
body.helfer form[action*="/entfernen/"], body.helfer a[href$="/hochladen/"], body.helfer a[href*="/import/"] { display: none !important; }
