:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --ink: #1d1d1f;
  --muted: #6b6b70;
  --line: #dedbd4;
  --accent: #8b1a1a;
  --accent-ink: #ffffff;
  --accent-soft: #f6e9e7;
  --ok: #1f6f43;
  --ok-soft: #e4f2ea;
  --warn: #8a5a00;
  --warn-soft: #fbf0d9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.hidden { display: none !important; }

/* Kopfzeile */
.topbar {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: .75rem 1.25rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; letter-spacing: .01em; }
.brand small { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
.topbar nav { margin-left: auto; display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a, .topbar nav button {
  text-decoration: none; color: var(--ink); padding: .4rem .75rem; border-radius: 8px;
  background: none; border: 0; font: inherit; cursor: pointer;
}
.topbar nav a.active, .topbar nav a:hover, .topbar nav button:hover { background: var(--bg); }

.wrap { max-width: 1040px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
.wrap.narrow { max-width: 820px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem 1.4rem; margin-bottom: 1.25rem;
}
.card > h2:first-child { display: flex; align-items: baseline; gap: .5rem; }
.card h2 .para { color: var(--accent); font-weight: 700; }

/* Formulare */
label.f { display: block; margin-bottom: .8rem; }
label.f > span { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=tel], input[type=date], input[type=number], input[type=password], textarea, select {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 1px solid #cfcbc2; border-radius: 8px; padding: .6rem .7rem; min-height: 44px;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input:disabled, textarea:disabled, select:disabled { background: #f7f6f3; color: #555; }
.grid { display: grid; gap: 0 1rem; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 680px) { .g2, .g3 { grid-template-columns: 1fr; } }

.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .35rem 1rem; margin-bottom: .6rem; }
.check { display: flex; align-items: flex-start; gap: .6rem; padding: .45rem .2rem; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--accent); flex: 0 0 auto; }
.check.big { background: var(--bg); border-radius: 8px; padding: .8rem .9rem; margin: .6rem 0; }
.check.big.required { border-left: 4px solid var(--accent); }

/* Tabellen */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #faf9f6; }
.tbl-input td { padding: .3rem .25rem; }
.tbl-input input { min-height: 40px; padding: .45rem .5rem; }
.scroll-x { overflow-x: auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; padding: .6rem 1rem; min-height: 44px; border-radius: 8px;
  border: 1px solid #cfcbc2; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none;
}
.btn:hover { background: #faf9f6; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #a01818; }
.btn.small { min-height: 34px; padding: .3rem .7rem; font-size: .875rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* Status */
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.entwurf { background: #ecebe7; color: #555; }
.badge.offen { background: var(--warn-soft); color: var(--warn); }
.badge.unterschrieben { background: var(--ok-soft); color: var(--ok); }
.badge.abgelaufen { background: #fde2e2; color: #a01818; }

.note { border-radius: 8px; padding: .8rem 1rem; margin: .8rem 0; background: var(--bg); }
.note.ok { background: var(--ok-soft); color: #154b2e; }
.note.warn { background: var(--warn-soft); color: #5e3d00; }

/* Fließtexte */
.legal p { margin: 0 0 .7em; text-align: justify; hyphens: auto; }
.legal h4 { margin: 1em 0 .4em; font-size: .98rem; }
.legal ul { margin: 0 0 .7em; padding-left: 1.3rem; }
details.legal-box { border: 1px solid var(--line); border-radius: 8px; padding: .2rem 1rem; margin: .6rem 0; background: #fcfbf9; }
details.legal-box summary { cursor: pointer; font-weight: 600; padding: .6rem 0; }

/* Unterschrift */
.sigpad {
  position: relative; border: 2px dashed #b9b4a9; border-radius: 10px; background: #fff;
  height: 220px; touch-action: none;
}
.sigpad canvas { width: 100%; height: 100%; display: block; border-radius: 8px; cursor: crosshair; }
.sigpad .baseline { position: absolute; left: 6%; right: 6%; bottom: 52px; border-bottom: 1px solid #c9c4b9; pointer-events: none; }
.sigpad .hint { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; color: #9a958a; font-size: .85rem; pointer-events: none; }
.sigpad.signed .hint { display: none; }

.summary { background: var(--accent-soft); border-radius: 10px; padding: 1rem 1.2rem; margin: 1rem 0; }
.summary dl { display: grid; grid-template-columns: max-content 1fr; gap: .3rem 1rem; margin: 0; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; font-weight: 600; }

/* Link-Box */
.linkbox { display: grid; grid-template-columns: 1fr 180px; gap: 1.2rem; align-items: start; }
.linkbox img { width: 180px; height: 180px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
@media (max-width: 680px) { .linkbox { grid-template-columns: 1fr; } }
.copy { display: flex; gap: .4rem; }
.copy input { font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(20,20,20,.45); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal .card { width: min(640px, 100%); max-height: 92vh; overflow: auto; margin: 0; }

/* Meldungen */
#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 100;
  background: #222; color: #fff; padding: .7rem 1.1rem; border-radius: 8px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw;
}
#toast.show { opacity: 1; }
#toast.error { background: #a01818; }

.events { font-size: .85rem; }
.events td { padding: .35rem .4rem; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: .78rem; word-break: break-all; }

.login { max-width: 380px; margin: 12vh auto; }
footer.site { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem 1rem; }
