:root {
  --bg: #f6f7f5;
  --card: #ffffff;
  --text: #1e2a23;
  --muted: #6b7a72;
  --line: #e2e6e2;
  --accent: #2f855a;
  --accent-text: #ffffff;
  --red: #d64545;
  --yellow: #d9a400;
  --green: #2f855a;
  --grey: #a0aaa4;
  --warn-bg: #fff8e1;
  --warn-line: #e6c34a;
  --danger-bg: #fdecec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.05);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111614;
    --card: #1b221e;
    --text: #e8ede9;
    --muted: #93a099;
    --line: #2a332e;
    --accent: #3fa56f;
    --warn-bg: #2e2a15;
    --warn-line: #8a7a2a;
    --danger-bg: #3a1f1f;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(96px + var(--safe-bottom));
}
a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 20px; color: var(--text); letter-spacing: .3px; }
.iconbtn { font-size: 22px; color: var(--muted); padding: 4px 8px; }
.topbar nav { display: flex; align-items: center; gap: 6px; }
.langswitch { border: 1px solid var(--line); background: var(--card); color: var(--muted); border-radius: 8px; padding: 4px 8px; font-size: 13px; font-weight: 600; cursor: pointer; }

.view { padding: 12px 16px; max-width: 640px; margin: 0 auto; }
h1 { font-size: 22px; margin: 8px 0 12px; }
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 20px 0 8px; }
p.muted, .muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; }
.error { color: var(--red); }
.center { text-align: center; }

/* Karten & Liste */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px;
}
.item {
  display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; align-items: center;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; margin-bottom: 8px; color: var(--text);
}
.item .dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: var(--red); } .dot.yellow { background: var(--yellow); }
.dot.green { background: var(--green); } .dot.grey { background: var(--grey); }
.item .name { font-weight: 600; }
.item .sub { color: var(--muted); font-size: 14px; }
.item .badge { font-size: 13px; font-weight: 600; text-align: right; white-space: nowrap; }
.badge.red { color: var(--red); } .badge.yellow { color: #a37b00; } .badge.green { color: var(--green); } .badge.grey { color: var(--muted); }
@media (prefers-color-scheme: dark) { .badge.yellow { color: var(--yellow); } }

.chips { display: flex; gap: 8px; margin: 4px 0 12px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card); border-radius: 999px;
  padding: 6px 14px; font-size: 14px; cursor: pointer;
}
.chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.search { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); margin-bottom: 10px; }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* FAB */
.fab {
  position: fixed; right: 20px; bottom: calc(20px + var(--safe-bottom)); z-index: 20;
  width: 60px; height: 60px; border-radius: 50%; border: none;
  background: var(--accent); color: var(--accent-text); font-size: 34px; line-height: 60px; text-align: center;
  box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-block; width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 600; text-align: center; cursor: pointer; margin-bottom: 10px;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { background: var(--danger-bg); color: var(--red); border-color: transparent; }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; margin: 0; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.btn-row .btn { flex: 1; margin-bottom: 0; }
.big { font-size: 18px; padding: 18px 16px; }

/* Formulare */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
}
.field textarea { min-height: 70px; resize: vertical; }
.field.warn input, .field.warn select { border-color: var(--warn-line); background: var(--warn-bg); }
.field .note { font-size: 13px; color: #8a6d00; margin-top: 4px; }
@media (prefers-color-scheme: dark) { .field .note { color: var(--yellow); } }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row21 { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; }
.segment { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card); }
.segment label { flex: 1; text-align: center; padding: 11px 4px; cursor: pointer; margin: 0; color: var(--text); font-size: 15px; }
.segment input { display: none; }
.segment input:checked + span { display: block; margin: -11px -4px; padding: 11px 4px; background: var(--accent); color: var(--accent-text); }
.preview { font-size: 14px; color: var(--muted); margin: -6px 0 14px; }
.warnings { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }
.warnings ul { margin: 4px 0 0; padding-left: 18px; }
.rawtext { white-space: pre-wrap; font-size: 13px; color: var(--muted); background: var(--card); border-radius: 10px; padding: 10px; border: 1px solid var(--line); }

/* Foto / Scanner */
.photo { width: 100%; max-height: 260px; object-fit: contain; border-radius: 12px; background: #000; margin-bottom: 12px; }
.spinner { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.scanner { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.scanner video { flex: 1; width: 100%; object-fit: cover; }
.scanner .bar { padding: 14px 16px calc(14px + var(--safe-bottom)); background: #111; color: #fff; display: flex; justify-content: space-between; align-items: center; }
.scanner .frame { position: absolute; left: 10%; right: 10%; top: 35%; height: 25%; border: 3px solid rgba(255,255,255,.8); border-radius: 12px; pointer-events: none; }

/* PIN */
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 20px auto; }
.pinpad button { padding: 18px 0; font-size: 22px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); cursor: pointer; }
.pindots { text-align: center; font-size: 28px; letter-spacing: 10px; min-height: 40px; }

/* Historie */
.history { list-style: none; padding: 0; margin: 0; }
.history li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.history li:last-child { border-bottom: none; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-bottom)); transform: translateX(-50%);
  background: #222; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 100;
  max-width: 90vw; text-align: center; box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.toast.error { background: var(--red); }
.toast.ok { background: var(--green); }
