:root {
  --bg: #f4f5f7; --card: #ffffff; --ink: #1d2329; --muted: #66727f; --line: #dde2e7;
  --brand: #171717; --accent: #88070b; --accent-ink: #ffffff; --ok: #2e7d32; --warn: #ef6c00;
  --danger: #c62828; --p90: #c62828; --p70: #ef6c00; --p40: #f9a825; --p0: #78909c;
  --radius: 12px; --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}
#watermark {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: url("/assets/watermark.png") center 55% / auto 62vh no-repeat;
  opacity: .3;
}
#app { position: relative; z-index: 1; min-height: 100vh; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; padding: 40px 16px; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 28px 24px; }
.auth-logo { display: block; width: 96px; margin: 0 auto 12px; }
.auth h1 { text-align: center; font-size: 1.25rem; }
.auth .sub { text-align: center; color: var(--muted); margin: -4px 0 20px; font-size: .9rem; }
.auth .links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 14px; font-size: .9rem; }
.auth .foot { text-align: center; color: var(--muted); font-size: .75rem; margin-top: 18px; }

/* ---------- Formulare ---------- */
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; min-height: 44px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #1565c055; border-color: #1565c0; }
.check { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: .95rem; }
.check input { width: 20px; min-height: 20px; height: 20px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 600px) { .grid2 { grid-template-columns: 1fr; } }

button, .btn {
  font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
}
button:hover { filter: brightness(.97); }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.dark { background: var(--brand); color: #fff; border-color: var(--brand); }
.danger { color: var(--danger); border-color: #f2c4c4; }
.full { width: 100%; margin-top: 16px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row > .grow { flex: 1 1 200px; width: auto; }
.err { color: var(--danger); font-size: .9rem; margin-top: 10px; min-height: 1em; }
.ok { color: var(--ok); }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--brand); color: #fff;
  display: flex; align-items: center; gap: 12px; padding: 8px 16px; padding-top: max(8px, env(safe-area-inset-top));
}
.topbar img { height: 36px; }
.topbar .title { font-weight: 600; flex: 1; font-size: 1rem; }
.topbar .title small { display: block; font-weight: 400; color: #bbb; font-size: .75rem; }
.topbar button { background: transparent; color: #fff; border-color: #444; min-height: 38px; padding: 6px 12px; }
nav.tabs { display: flex; gap: 4px; padding: 8px 16px 0; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 52px; z-index: 19; overflow-x: auto; }
nav.tabs button { border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 10px 14px; color: var(--muted); }
nav.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; padding-bottom: 96px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.disclaimer { color: #b71c1c; font-size: .8rem; margin-top: 8px; }

/* Mobil: Navigation unten */
@media (max-width: 700px) {
  nav.tabs { position: fixed; bottom: 0; top: auto; left: 0; right: 0; justify-content: space-around; padding: 0 0 env(safe-area-inset-bottom); border-top: 1px solid var(--line); border-bottom: none; }
  nav.tabs button { flex: 1; font-size: .78rem; padding: 10px 4px; border-bottom: none; border-top: 3px solid transparent; }
  nav.tabs button.active { border-top-color: var(--accent); }
  .topbar .title small { display: none; }
  main { padding: 12px; padding-bottom: 96px; }
}

/* ---------- Abgleich ---------- */
.capture { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.capture button { min-height: 92px; flex-direction: column; font-size: 1rem; font-weight: 600; }
.capture button .ico { font-size: 1.9rem; line-height: 1; }
.dropzone { border: 2px dashed #90a4ae; border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); margin-top: 12px; }
.dropzone.over { border-color: #1565c0; background: #e3f2fd; color: #1565c0; }
@media (pointer: coarse) { .dropzone { display: none; } }
.overview { width: 100%; border-radius: 10px; background: #263238; display: block; }
.facechips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0; }
.facechip { border: 2px solid var(--line); border-radius: 10px; padding: 0; background: #fff; min-height: 0; flex: 0 0 auto; }
.facechip img { width: 64px; height: 64px; border-radius: 8px; display: block; }
.facechip.active { border-color: var(--accent); }
.warnline { color: var(--warn); font-size: .85rem; }

.match { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: #fff; margin-bottom: 8px; cursor: pointer; }
.match:hover { border-color: #b0bec5; }
.match img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.match .name { font-weight: 600; }
.match .meta { font-size: .82rem; color: var(--muted); }
.bar { height: 22px; border-radius: 6px; background: #eceff1; position: relative; overflow: hidden; margin-top: 6px; }
.bar > span { position: absolute; inset: 0 auto 0 0; border-radius: 6px; }
.bar > b { position: relative; display: block; text-align: center; font-size: .8rem; line-height: 22px; color: #000; }
.p90 { color: var(--p90); } .p70 { color: var(--p70); } .p40 { color: #b28704; } .p0 { color: var(--p0); }
.bg-p90 { background: var(--p90); } .bg-p70 { background: var(--p70); } .bg-p40 { background: var(--p40); } .bg-p0 { background: var(--p0); }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.compare figure { margin: 0; }
.compare img { width: 100%; border-radius: 10px; display: block; background: #eceff1; }
.compare figcaption { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; white-space: pre-wrap; }

/* ---------- Liste ---------- */
.plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.pitem { display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; align-items: center; }
.pitem:hover { border-color: #b0bec5; }
.pitem img, .pitem .noimg { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; background: #eceff1; }
.pitem .gz { font-size: .8rem; color: var(--muted); }
.pitem .nm { font-weight: 600; }
.pitem .ds { font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pitem.inactive { opacity: .6; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; border: 1px solid currentColor; }
.st-aktiv { color: #c62828; } .st-festgenommen { color: #2e7d32; } .st-erledigt, .st-widerrufen { color: #757575; }
.counts { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; margin-top: 8px; }

.imgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.imgcard { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #fff; }
.imgcard img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; }
.imgcard .lbl { font-size: .8rem; margin: 6px 0; }
.imgcard select, .imgcard input { min-height: 36px; padding: 6px 8px; font-size: .85rem; margin-top: 4px; }
.imgcard .star { color: #b28704; font-weight: 700; }
.imgcard button { min-height: 34px; padding: 4px 8px; font-size: .8rem; margin-top: 6px; width: 100%; }

/* ---------- Tabellen ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tbl th, .tbl td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.scroll { overflow-x: auto; }
.userrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.userrow .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; align-items: center; }
.userrow select { width: auto; min-height: 38px; padding: 6px 8px; }
.userrow button { min-height: 38px; padding: 6px 10px; font-size: .85rem; }
.pending { background: #fff8e1; border-radius: 8px; padding-left: 8px; padding-right: 8px; }
@media (max-width: 700px) { .userrow { grid-template-columns: 1fr; } .userrow .acts { justify-content: flex-start; } }

/* ---------- Dialog ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet { background: #fff; width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 701px) { .modal { align-items: center; } .modal .sheet { border-radius: 16px; } }
.sheet .head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.sheet .head h2 { margin: 0; }
.choose { display: flex; gap: 10px; flex-wrap: wrap; }
.choose button { padding: 4px; min-height: 0; }
.choose img { width: 96px; height: 96px; border-radius: 8px; display: block; }

#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 60; background: #263238; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .9rem; max-width: 92vw; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: .96; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid #ccc; border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.linkbox { font-family: monospace; font-size: .8rem; word-break: break-all; background: #f5f5f5; padding: 8px; border-radius: 8px; }
