/* Mobile-first: das hier wird am Handy im Restaurant bedient, nicht am
   Schreibtisch. Große Touch-Ziele, wenig Schnickschnack, dunkler Modus. */

:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #14181f;
  --muted: #5c6673;
  --line: #dfe3e8;
  --accent: #1f6feb;
  --plus: #17803d;
  --minus: #c22a2a;
  --radius: 14px;
  --tap: 48px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --card: #171b22;
    --text: #e8ecf1;
    --muted: #9aa5b1;
    --line: #2a313b;
    --accent: #4c8dff;
    --plus: #3fb950;
    --minus: #f46c6c;
  }
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 700; color: var(--text); text-decoration: none; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
}

h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 24px 0 10px; }
.muted { color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.alert {
  background: color-mix(in srgb, var(--minus) 14%, var(--card));
  border: 1px solid var(--minus);
  color: var(--text);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin: 0 0 14px;
}

/* --- Bilanz-Zeilen --- */

.balance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.balance-row:last-child { border-bottom: 0; }

.balance-name { font-weight: 600; }
.amount { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.amount.plus { color: var(--plus); }
.amount.minus { color: var(--minus); }
.amount.zero { color: var(--muted); }

.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  margin-left: 8px;
  vertical-align: middle;
}

/* --- Formulare --- */

label { display: block; font-weight: 600; font-size: 0.9rem; margin: 12px 0 6px; }

input[type="text"], input[type="date"], input[type="password"],
input[type="number"], select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* unter 16px zoomt iOS beim Fokus hinein */
}

textarea { min-height: 90px; resize: vertical; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

button.secondary, .btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--line);
}

button.danger, .btn.danger {
  background: transparent;
  color: var(--minus);
  border: 1px solid var(--line);
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

button.wide { width: 100%; margin-top: 16px; }

/* --- "Für wen": alle vorausgewählt, Klick wählt ab --- */

.people { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }

.person input { position: absolute; opacity: 0; pointer-events: none; }

.person span {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.person input:checked + span {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border-color: var(--accent);
  color: var(--accent);
}

.person input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Listen --- */

.item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.item:last-child { border-bottom: 0; }
.item-main { min-width: 0; }
.item-title { font-weight: 600; }
.item-sub { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.item-side { text-align: right; white-space: nowrap; }

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

/* --- QR-Codes --- */

.invite { text-align: center; }
.invite img { width: 200px; height: 200px; image-rendering: pixelated; border-radius: 8px; background: #fff; padding: 8px; }
.invite-link {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  word-break: break-all;
  color: var(--muted);
  background: var(--bg);
  padding: 8px;
  border-radius: 8px;
  margin-top: 8px;
}

details summary {
  min-height: var(--tap);
  display: flex;
  align-items: center;
  font-weight: 600;
  cursor: pointer;
  color: var(--accent);
}

.hidden { display: none; }
