:root {
  /* KPS-Gruppe Markenfarben */
  --brand: #3f146a;
  --brand-dark: #2c0d4b;
  --brand-mid: #6728a8;
  --accent: #a701ff;
  --brand-soft: #f4eefb;

  --bg: #f5f3f8;
  --card: #ffffff;
  --ink: #1f1330;
  --muted: #6b6478;
  --ok: #1a8754;
  --ok-soft: #e8f5ee;
  --warn: #9a5b00;
  --warn-soft: #fff4e0;
  --err: #b42318;
  --err-soft: #fdecea;
  --border: #e6e1ee;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.container { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px; }
.container--wide { max-width: 1280px; }

/* ---- Kopfzeile ---- */
.site-header { background: var(--brand); color: #fff; padding: 14px 0; }
.site-header__inner { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand__logo { height: 38px; width: auto; display: block; }
.brand__title { font-weight: 600; font-size: 1rem; opacity: .9; }
.accent-bar { height: 4px; background: linear-gradient(90deg, var(--accent) 0%, var(--brand-mid) 50%, var(--brand) 100%); }

.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a, .nav button {
  color: #fff; text-decoration: none; padding: 7px 11px; border-radius: 8px; font-size: .92rem;
  background: none; border: 0; cursor: pointer; font: inherit; font-size: .92rem;
}
.nav a:hover, .nav button:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.active { background: rgba(255,255,255,.2); }
.nav__user { opacity: .75; font-size: .85rem; padding: 0 6px; }
.nav form { margin: 0; }

main.container { padding-top: 24px; padding-bottom: 40px; }

.site-footer { color: var(--muted); font-size: .82rem; padding: 12px 0 28px; text-align: center; }
.site-footer p { margin: 2px 0; }

/* ---- Karten, Typografie ---- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: 0 2px 10px rgba(63, 20, 106, .06); margin-bottom: 20px;
}
h1 { font-size: 1.45rem; margin: 0 0 14px; color: var(--brand); line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 12px; color: var(--brand); }
h3 { font-size: 1rem; margin: 18px 0 8px; color: var(--brand); }
p { margin: 0 0 12px; }
a { color: var(--brand-mid); }
a:hover { color: var(--brand); }
.hint { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.nowrap { white-space: nowrap; }

/* ---- Formulare ---- */
.field { margin-bottom: 14px; }
.field label, .label { display: block; font-weight: 600; margin-bottom: 5px; font-size: .95rem; }
.field .opt { font-weight: 400; color: var(--muted); font-size: .85rem; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], input[type=search], select, textarea {
  width: 100%; padding: 11px 12px; border: 1px solid #cfc6dc; border-radius: 9px; font: inherit;
  font-size: 16px; /* verhindert Zoom auf iOS */ background: #fff; color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-mid); outline-offset: 1px; border-color: var(--brand-mid); }
.field--error input, .field--error select, .field--error textarea { border-color: var(--err); }
.field__error { color: var(--err); font-size: .87rem; margin-top: 4px; }
.row { display: grid; grid-template-columns: 1fr 1fr; column-gap: 12px; }
@media (max-width: 480px) { .row { grid-template-columns: 1fr; } }

.check { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; font-size: .95rem; }
.check input { width: 22px; height: 22px; flex: none; margin: 1px 0 0; accent-color: var(--brand); }
.check--inline { margin: 8px 0 0; font-weight: 400; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600;
  background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; font-size: 1rem;
}
.btn:hover { background: var(--brand-dark); color: #fff; }
.btn--block { width: 100%; }
.btn--big { padding: 16px 20px; font-size: 1.1rem; }
.btn--light { background: #fff; color: var(--brand); border-color: #cfc6dc; }
.btn--light:hover { background: var(--brand-soft); color: var(--brand); }
.btn--ok { background: var(--ok); }
.btn--ok:hover { background: #136b42; }
.btn--danger { background: #fff; color: var(--err); border-color: #efc3bd; }
.btn--danger:hover { background: var(--err-soft); color: var(--err); }
.btn--small { padding: 6px 11px; font-size: .88rem; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inline { display: inline; margin: 0; }

/* ---- Meldungen ---- */
.alert { border-radius: 10px; padding: 12px 14px; margin-bottom: 16px; font-size: .95rem; }
.alert--ok { background: var(--ok-soft); color: #0f5132; border: 1px solid #b7e0c8; }
.alert--err { background: var(--err-soft); color: var(--err); border: 1px solid #f3c1bb; }
.alert--warn { background: var(--warn-soft); color: var(--warn); border: 1px solid #f1d49c; }
.alert--info { background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #e0d0f2; }

/* ---- Besucher: Code + QR ---- */
.code-box {
  text-align: center; background: var(--brand-soft); border: 2px dashed #c9b1e6; border-radius: 14px;
  padding: 16px; margin: 16px 0;
}
.code-box__label { font-size: .9rem; color: var(--muted); }
.code-box__code { font-size: 2.8rem; font-weight: 800; letter-spacing: .35em; color: var(--brand); padding-left: .35em; line-height: 1.2; }
.qr { display: block; margin: 8px auto; width: 220px; max-width: 70%; height: auto; image-rendering: pixelated; }
.summary { margin: 0; }
.summary > div { display: flex; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.summary > div:last-child { border-bottom: 0; }
.summary dt { width: 130px; color: var(--muted); flex: none; }
.summary dd { margin: 0; font-weight: 600; word-break: break-word; }
.big-icon { font-size: 3rem; text-align: center; line-height: 1; margin-bottom: 8px; }
.linkbox { font-size: .8rem; word-break: break-all; color: var(--muted); background: #faf8fc; border-radius: 8px; padding: 8px; }

/* ---- Tabellen (Backend) ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat__num { font-size: 1.9rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.stat__label { color: var(--muted); font-size: .88rem; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar h1 { margin: 0 auto 0 0; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #faf8fc; }
tr:hover td { background: #fcfbfe; }
td .sub { color: var(--muted); font-size: .83rem; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge--in { background: var(--ok-soft); color: #0f5132; }
.badge--out { background: #eeecf1; color: #5c5566; }
.badge--auto { background: var(--warn-soft); color: var(--warn); }
.badge--admin { background: var(--brand-soft); color: var(--brand); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }
.live { font-size: .82rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #bbb; }
.live.on::before { background: var(--ok); box-shadow: 0 0 0 3px rgba(26,135,84,.18); }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.filters .field { margin: 0; }
details.edit summary { cursor: pointer; color: var(--brand-mid); font-size: .9rem; }
details.edit[open] { background: #faf8fc; border-radius: 8px; padding: 8px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---- Hilfe ---- */
.nav a.nav__help { background: rgba(255,255,255,.14); }
.nav a.nav__help:hover { background: rgba(255,255,255,.24); }
.help { display: grid; grid-template-columns: 250px 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .help { grid-template-columns: 1fr; } }
.help__toc { position: sticky; top: 16px; }
@media (max-width: 900px) { .help__toc { position: static; } }
.help__toc ol { margin: 0; padding-left: 20px; line-height: 1.9; font-size: .93rem; }
.help__content section { scroll-margin-top: 16px; }
.help__content ul, .help__content ol { padding-left: 22px; margin: 0 0 12px; }
.help__content li { margin-bottom: 5px; }
.help__content .steps li { margin-bottom: 8px; }
.help__content h3 { margin-top: 14px; }
.help__content section:target { outline: 2px solid var(--brand-mid); outline-offset: 2px; }
.help__admin-label {
  margin: 28px 0 12px; font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-mid);
  border-bottom: 2px solid var(--brand-soft); padding-bottom: 6px;
}
.faq dt { font-weight: 600; color: var(--brand); margin-top: 12px; }
.faq dd { margin: 3px 0 0; }

/* ---- Evakuierungsliste (Druck) ---- */
.print-only { display: none; }
@media print {
  .site-header, .accent-bar, .no-print, .site-footer { display: none !important; }
  .print-only { display: block; }
  .help { display: block; }
  .help__content section { break-inside: avoid; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; padding: 0; }
  main.container { padding: 0; max-width: none; }
  table { font-size: 11pt; }
  th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---- Unterschriftsfeld ---- */
.sig {
  position: relative; height: 180px; background: #fff; border: 2px dashed #c9b1e6; border-radius: 12px;
  touch-action: none; user-select: none; -webkit-user-select: none; overflow: hidden;
}
.sig--active { border-style: solid; border-color: var(--brand-mid); }
.field--error .sig { border-color: var(--err); }
.sig__canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; display: block; }
.sig__line { position: absolute; left: 18px; right: 18px; bottom: 30%; border-bottom: 1px solid #d9d2e4; pointer-events: none; }
.sig__placeholder {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #a79fb3; font-size: 1.05rem; pointer-events: none; transition: opacity .15s;
}
.sig--filled .sig__placeholder, .sig--active .sig__placeholder { opacity: 0; }
.sig__clear {
  position: absolute; top: 8px; right: 8px; z-index: 1; font: inherit; font-size: .85rem; cursor: pointer;
  background: #fff; color: var(--brand); border: 1px solid #cfc6dc; border-radius: 8px; padding: 4px 10px;
}
.sig__hint { margin: 6px 0 0; }
.sig-preview { max-width: 360px; max-height: 140px; display: block; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
