*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --navy: #1A2E4A;
  --blue: #2D6CDF;
  --blue-dark: #255cc7;
  --blue-light: #EAF1FD;
  --grey: #6B7A8D;
  --text: #3C4556;
  --border: #E2E8F0;
  --bg: #F4F7FB;
  --white: #ffffff;
  --red: #C0392B;
  --red-light: #FDECEA;
  --green: #1E7F4F;
  --green-light: #E6F4EC;
}
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  color: var(--navy);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

header.top {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 20px;
}
.logo { font-size: 18px; font-weight: 700; letter-spacing: -0.5px; color: var(--navy); }
.logo .b { color: var(--blue); }
.logo:hover { text-decoration: none; }

main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 32px 16px 48px; }
main.wide { max-width: 860px; }

.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
}
.card + .card { margin-top: 16px; }

h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.4px; line-height: 1.25; }
h2 { font-size: 17px; font-weight: 600; margin: 24px 0 8px; }
p { font-size: 15px; color: var(--text); line-height: 1.6; }
.muted { color: var(--grey); font-size: 14px; }
.small { font-size: 13px; color: var(--grey); line-height: 1.5; }
.sender { margin-top: 8px; font-size: 15px; color: var(--text); }
.sender strong { color: var(--navy); }

label { display: block; font-size: 14px; font-weight: 600; color: var(--navy); margin: 24px 0 8px; }
input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 20px;
  letter-spacing: 1px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  color: var(--navy);
  background: var(--white);
  outline: none;
}
input[type="text"]:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-light); }
input[type="text"].error { border-color: var(--red); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  font: inherit; font-size: 16px; font-weight: 600;
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: var(--white); margin-top: 16px; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-primary:disabled { background: #9DB7E8; cursor: default; }
.btn-secondary { background: var(--blue-light); color: var(--blue); }
.btn-secondary:hover { background: #DCE8FB; }
.btn-danger { background: var(--red); color: var(--white); }
.btn-ghost { background: transparent; color: var(--grey); }
.btn-row { display: flex; gap: 12px; margin-top: 20px; }
.btn-row .btn { flex: 1; }

.link-danger { background: none; border: none; font: inherit; font-size: 14px; color: var(--red); cursor: pointer; padding: 0; text-decoration: underline; }

.alert { margin-top: 12px; padding: 12px 14px; border-radius: 10px; font-size: 14px; line-height: 1.5; }
.alert-error { background: var(--red-light); color: var(--red); }
.alert-info { background: var(--blue-light); color: var(--navy); }

.state-icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px; font-size: 24px;
}
.state-icon.info { background: var(--blue-light); color: var(--blue); }
.state-icon.warn { background: var(--red-light); color: var(--red); }
.state-icon.ok { background: var(--green-light); color: var(--green); }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--blue-light); border-top-color: var(--blue);
  animation: spin 0.8s linear infinite;
  margin: 24px auto;
}
.btn .spinner { width: 18px; height: 18px; border-width: 2px; margin: 0; border-color: rgba(255,255,255,.4); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

.pdf-view {
  margin-top: 20px;
  background: #EEF2F7;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex; flex-direction: column; gap: 12px; align-items: center;
}
.pdf-view canvas { width: 100%; height: auto; background: #fff; box-shadow: 0 1px 4px rgba(26,46,74,.12); border-radius: 4px; }

.doc-meta { margin-top: 6px; font-size: 14px; color: var(--grey); }
.divider { height: 1px; background: var(--border); margin: 24px 0; }

.legal { text-align: center; margin-top: 24px; font-size: 13px; color: var(--grey); }
.legal a { color: var(--grey); text-decoration: underline; }

/* Bestätigungsdialog */
.overlay {
  position: fixed; inset: 0; background: rgba(26,46,74,.45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; z-index: 50;
}
.dialog {
  background: var(--white); border-radius: 16px; padding: 24px;
  width: 100%; max-width: 420px;
}
.dialog h2 { margin-top: 0; }
@media (min-width: 600px) { .overlay { align-items: center; } }

/* Rechtstexte */
.content h2 { margin-top: 28px; }
.content p { margin-bottom: 10px; }

footer.bottom { text-align: center; padding: 20px 16px 28px; font-size: 13px; color: var(--grey); }
footer.bottom a { color: var(--grey); }

[hidden] { display: none !important; }
