:root {
  --bg: #f4f6f6;
  --card: #ffffff;
  --ink: #16211f;
  --muted: #647470;
  --line: #dfe5e3;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --plus: #0b7a52;
  --minus: #b4443a;
  --warn: #8a5a00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 35, 30, .06), 0 6px 18px rgba(15, 35, 30, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101413;
    --card: #19201f;
    --ink: #e8efed;
    --muted: #94a5a1;
    --line: #2a3432;
    --brand: #2dd4bf;
    --brand-ink: #07211e;
    --plus: #4ade80;
    --minus: #f87171;
    --warn: #fbbf24;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }

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

.wrap {
  max-width: 680px;
  margin: 0 auto;
  padding: 16px 16px calc(96px + env(safe-area-inset-bottom));
}

/* ---------- Kopf ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px calc(12px); padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink);
}
.top-title { font-weight: 650; font-size: 1.05rem; text-decoration: none; color: inherit; }
.top-me { font-size: .85rem; text-decoration: none; color: inherit; opacity: .9;
  border: 1px solid currentColor; border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; vertical-align: middle; }

h1 { font-size: 1.4rem; margin: 4px 0 16px; }
h2 { font-size: 1.05rem; margin: 24px 0 10px; }
h2:first-child { margin-top: 0; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
a { color: var(--brand); }

/* ---------- Karten ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card.tight { padding: 0; overflow: hidden; }

.hero { text-align: center; padding: 22px 16px; }
.hero .label { color: var(--muted); font-size: .85rem; letter-spacing: .02em; }
.hero .big { font-size: 2.3rem; font-weight: 680; letter-spacing: -.02em; margin: 4px 0 2px;
  font-variant-numeric: tabular-nums; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: .78rem; }
.stat .v { font-size: 1.15rem; font-weight: 620; font-variant-numeric: tabular-nums; margin-top: 2px; }

.plus { color: var(--plus); }
.minus { color: var(--minus); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Listen ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .t { font-weight: 560; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .s { color: var(--muted); font-size: .82rem; }
.list a.row { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0;
  color: inherit; text-decoration: none; }

.chip { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--brand);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent); }
.chip.grey { background: transparent; color: var(--muted); border-color: var(--line); }

/* ---------- Formulare ---------- */
label { display: block; font-size: .85rem; color: var(--muted); margin: 14px 0 6px; }
label:first-child { margin-top: 0; }

input[type=text], input[type=number], input[type=date], input[type=password],
input[type=tel], select, textarea {
  width: 100%; padding: 12px 13px; font-size: 16px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 1px;
  border-color: var(--brand);
}

.amount-row { display: flex; gap: 8px; }
.amount-row input { flex: 1; font-size: 24px; font-weight: 600; text-align: right;
  font-variant-numeric: tabular-nums; }
.amount-row select { width: 92px; flex: none; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; font-size: 1rem; font-weight: 600; font-family: inherit;
  border-radius: 11px; border: 1px solid var(--brand); background: var(--brand);
  color: var(--brand-ink); cursor: pointer; text-decoration: none;
}
.btn.wide { width: 100%; }
.btn.ghost { background: transparent; color: var(--brand); }
.btn.quiet { background: transparent; color: var(--muted); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--minus); border-color: var(--minus); }
.btn.small { padding: 7px 12px; font-size: .85rem; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* Teilnehmer-Haekchen */
.people-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.people-pick label { margin: 0; }
.people-pick input { position: absolute; opacity: 0; pointer-events: none; }
.people-pick span {
  display: inline-block; padding: 9px 14px; border-radius: 999px; font-size: .92rem;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted); cursor: pointer;
  user-select: none;
}
.people-pick input:checked + span {
  background: var(--brand); border-color: var(--brand); color: var(--brand-ink); font-weight: 560;
}
.people-pick input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Foto-Feld */
.shot { display: block; border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 20px; text-align: center; color: var(--muted); cursor: pointer; background: var(--bg); }
.shot svg { width: 30px; height: 30px; stroke: currentColor; fill: none; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; display: block; margin: 0 auto 8px; }
.shot input { display: none; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); }

.belege { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.belege a { display: block; }
.belege img { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; }

/* ---------- Meldungen ---------- */
.flashes { margin-bottom: 14px; }
.flash { padding: 11px 14px; border-radius: 11px; font-size: .92rem; margin-bottom: 8px; }
.flash.ok { background: color-mix(in srgb, var(--plus) 15%, transparent); color: var(--plus);
  border: 1px solid color-mix(in srgb, var(--plus) 32%, transparent); }
.flash.error { background: color-mix(in srgb, var(--minus) 14%, transparent); color: var(--minus);
  border: 1px solid color-mix(in srgb, var(--minus) 32%, transparent); }

.hint { background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  color: var(--warn); padding: 11px 14px; border-radius: 11px; font-size: .88rem; }

/* ---------- Abrechnung ---------- */
.transfer { display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-top: 1px solid var(--line); }
.transfer:first-child { border-top: 0; }
.transfer .arrow { color: var(--muted); flex: none; }
.transfer .who { flex: 1; min-width: 0; }
.transfer .who b { font-weight: 620; }
.transfer .amt { font-weight: 680; font-variant-numeric: tabular-nums; }

/* ---------- Mitbringliste ---------- */
.item { display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item.done .t { text-decoration: line-through; opacity: .5; }
.item form { margin: 0; }

/* ---------- Tab-Leiste ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px 7px; text-decoration: none; color: var(--muted); font-size: .68rem; }
.tabs a.on { color: var(--brand); }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.tabs a.add { background: var(--brand); color: var(--brand-ink); border-radius: 50%;
  width: 52px; height: 52px; justify-self: center; align-self: center; padding: 0;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 45%, transparent); }
.tabs a.add svg { width: 26px; height: 26px; stroke-width: 2.2; }

/* ---------- Tabellen ---------- */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 8px; border-top: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: .8rem; border-top: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }

hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.center { text-align: center; }
.hide { display: none; }
.dim { opacity: .65; }
.clip { white-space: nowrap; }
.warnish { color: var(--warn); }
.table-wrap { overflow-x: auto; }

.wrap.plain { padding-bottom: 32px; }

.head-row { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin: 4px 0 16px; }
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-inline { display: flex; gap: 8px; align-items: center; }
.row-inline > :first-child { flex: 1; min-width: 0; }

button.link { background: none; border: 0; color: var(--brand); font: inherit;
  font-size: .82rem; cursor: pointer; padding: 0; text-decoration: underline; }

label.inline { display: flex; align-items: center; gap: 9px; margin: 10px 0 0;
  color: var(--ink); font-size: .95rem; cursor: pointer; }
label.inline input { width: 19px; height: 19px; flex: none; accent-color: var(--brand); }

/* Startseite: eigene Bilanz */
.balance { display: flex; align-items: center; justify-content: space-between;
  gap: 12px; text-decoration: none; color: inherit; }
.big-ish { font-size: 1.7rem; font-weight: 660; letter-spacing: -.01em; margin: 2px 0; }
.chev { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--muted);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.nudge { display: block; text-decoration: none; color: var(--warn);
  background: color-mix(in srgb, var(--warn) 10%, var(--card));
  border-color: color-mix(in srgb, var(--warn) 28%, transparent); font-size: .92rem; }

.conv { min-height: 1.2em; margin-top: 6px; text-align: right; }

/* Anmeldung */
.gate { max-width: 420px; margin: 24px auto 0; }
.gate-logo { width: 62px; height: 62px; margin: 0 auto 16px; border-radius: 18px;
  background: var(--brand); display: grid; place-items: center; }
.gate-logo svg { width: 32px; height: 32px; fill: none; stroke: var(--brand-ink);
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

.pin-field { text-align: center; font-size: 26px; letter-spacing: .35em;
  font-variant-numeric: tabular-nums; padding-left: .35em; }

.who-list { display: grid; gap: 8px; }
.who-list label { margin: 0; }
.who-list input { position: absolute; opacity: 0; pointer-events: none; }
.who-list span { display: block; padding: 13px 16px; border-radius: 11px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.who-list input:checked + span { background: var(--brand); border-color: var(--brand);
  color: var(--brand-ink); font-weight: 600; }

.linkbox { background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; margin-bottom: 12px; }
.linkbox code { font-size: .82rem; word-break: break-all; color: var(--ink); }

.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 5px; }

/* kleine runde Knoepfe in Listen */
.x { background: none; border: 0; color: var(--muted); font-size: 1.5rem; line-height: 1;
  padding: 2px 6px; cursor: pointer; border-radius: 8px; flex: none; }
.x:hover { color: var(--minus); }

.check { width: 26px; height: 26px; flex: none; border-radius: 8px; cursor: pointer;
  border: 1.6px solid var(--line); background: var(--bg); display: grid; place-items: center;
  padding: 0; }
.check svg { width: 16px; height: 16px; fill: none; stroke: transparent; stroke-width: 2.6;
  stroke-linecap: round; stroke-linejoin: round; }
.check.on { background: var(--brand); border-color: var(--brand); }
.check.on svg { stroke: var(--brand-ink); }
.item form.tick { display: flex; }

/* Verwaltung */
body.admin .top { background: #1f2937; }
@media (prefers-color-scheme: dark) { body.admin:not([data-theme="light"]) .top { background: #0b1220; } }
body.admin .top-me { background: none; cursor: pointer; font-family: inherit; }

.trip-card { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.trip-card .t { font-weight: 600; }
.trip-card .s { font-size: .82rem; margin-top: 2px; }
.trip-card.faded { opacity: .6; }

.danger-zone { border-color: color-mix(in srgb, var(--minus) 35%, transparent); }

/* ---------- Zaehlerstaende ---------- */
.verbrauch { display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 11px; padding: 12px 14px; }
.verbrauch .k { color: var(--muted); font-size: .78rem; }
.verbrauch .v { font-size: 1.1rem; font-weight: 620; margin-top: 2px; }

.ablesungen { margin-top: 12px; border-top: 1px solid var(--line); }
.ablesungen li { padding-left: 0; padding-right: 0; }
.ablesungen .t { font-size: 1.02rem; }

img.mini { width: 44px; height: 44px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); display: block; flex: none; }

details summary { cursor: pointer; }
details summary::marker { color: var(--muted); }

/* ------------------------------------------------------------------
   Dokumentenscanner
------------------------------------------------------------------ */
body.scan-open { overflow: hidden; }

.scan {
  position: fixed; inset: 0; z-index: 100;
  background: #0b0f0e; color: #e8efed;
  display: flex; flex-direction: column;
}
.scan-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  font-size: .95rem; font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.scan-head button { font: inherit; cursor: pointer; border-radius: 9px; }
.scan-x { background: none; border: 0; color: #e8efed; font-size: 1.7rem; line-height: 1;
  padding: 0 8px; font-weight: 400; }
.scan-ok { background: #2dd4bf; border: 0; color: #07211e; padding: 9px 18px; font-weight: 650; }
.scan-ok:disabled { opacity: .6; }

.scan-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 12px; }
.scan-canvas { touch-action: none; border-radius: 6px; max-width: 100%; max-height: 100%;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }

.scan-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, .1); font-size: .88rem;
}
.scan-toggle { display: flex; align-items: center; gap: 9px; margin: 0; color: #e8efed;
  cursor: pointer; }
.scan-toggle input { width: 19px; height: 19px; accent-color: #2dd4bf; }
.scan-raw { background: none; border: 1px solid rgba(255, 255, 255, .3); color: #e8efed;
  padding: 8px 14px; border-radius: 9px; font: inherit; font-size: .85rem; cursor: pointer; }

.stack > * + * { margin-top: 10px; }
