:root {
  --bg: #f3f4f1;
  --surface: #ffffff;
  --ink: #1b2230;
  --muted: #687082;
  --line: #e1e3dd;
  --accent: #0f5bd8;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefc;
  --ok: #157a46;
  --ok-soft: #e3f4ea;
  --warn: #b35c00;
  --warn-soft: #fdf0e1;
  --err: #b42318;
  --err-soft: #fdeceb;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1b2029;
    --ink: #e8eaee;
    --muted: #98a0b0;
    --line: #2c3340;
    --accent: #5b93f5;
    --accent-ink: #0b1220;
    --accent-soft: #1d2a44;
    --ok: #5fcf8f;
    --ok-soft: #173326;
    --warn: #f0a650;
    --warn-soft: #3a2a16;
    --err: #f08a80;
    --err-soft: #3d1f1d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }
.wrap.schmal { max-width: 440px; padding-top: 10vh; }
.wrap.breit { max-width: 1100px; }

h1 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); }
.zahl { font-variant-numeric: tabular-nums; white-space: nowrap; }

.karte {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

/* Kopfzeile */
.kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.kopf .aktionen { display: flex; gap: 8px; flex-shrink: 0; }

/* Formulare */
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 4px; }
.feld { margin-bottom: 14px; }
.feld .hilfe { font-size: .82rem; color: var(--muted); margin-top: 3px; }
input[type=text], input[type=email], input[type=number], input[type=password], input[type=date],
input[type=datetime-local], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 44px;
}
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--accent); }
.code-eingabe { font-size: 1.6rem !important; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }

button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 16px;
  min-height: 44px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:disabled { opacity: .55; cursor: default; }
button.zweit, .btn.zweit { background: var(--surface); color: var(--ink); border-color: var(--line); }
button.text { background: none; color: var(--accent); padding: 6px 8px; min-height: 36px; }
button.klein { padding: 6px 10px; min-height: 36px; font-size: .9rem; }
button.gefahr { background: var(--err); color: #fff; }
button.icon { background: none; color: var(--muted); padding: 6px; min-height: 36px; min-width: 36px; }
button.icon:hover { color: var(--ink); background: var(--bg); }
button.voll { width: 100%; }
.zeile { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.zeile.rechts { justify-content: flex-end; }

/* Hinweise */
.banner { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; font-size: .95rem; }
.banner.offen { background: var(--accent-soft); }
.banner.zu { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.fehler { background: var(--err-soft); color: var(--err); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: .92rem; }

/* Saldo */
.saldo-grid { display: grid; grid-template-columns: 1fr auto; gap: 4px 16px; }
.saldo-grid .gross { font-size: 1.25rem; font-weight: 700; padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; }
.status { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: .82rem; font-weight: 700; }
.status.offen { background: var(--warn-soft); color: var(--warn); }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.guthaben { background: var(--accent-soft); color: var(--accent); }
.status.leer { background: var(--bg); color: var(--muted); }
.ueberweisung { margin-top: 14px; padding: 12px; border-radius: 8px; background: var(--bg); font-size: .93rem; }
.ueberweisung dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
.ueberweisung dt { color: var(--muted); }
.ueberweisung dd { margin: 0; font-weight: 600; word-break: break-word; }

/* Positionen */
.gruppe { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow); }
.gruppe-kopf {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px;
  padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--line);
}
.gruppe-kopf .titel { font-weight: 700; }
.gruppe-kopf .meta { font-size: .88rem; color: var(--muted); }
.gruppe-kopf .haken { display: flex; gap: 14px; font-size: .85rem; }
.gruppe-kopf .haken .check { font-weight: 600; align-items: center; }
.position { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.position:last-child { border-bottom: 0; }
.position .art { font-weight: 600; }
.position .details { font-size: .9rem; color: var(--muted); }
.position .preis { text-align: right; }
.position .preis .einzel { font-size: .85rem; color: var(--muted); }
.position .fuss { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.position .fuss .haken { display: flex; gap: 14px; font-size: .85rem; }
.position .fuss .haken .check { font-weight: 500; align-items: center; }
.leer-hinweis { text-align: center; padding: 28px 16px; color: var(--muted); }
.summe-leiste {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.summe-leiste .innen { max-width: 760px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.summe-leiste .betrag { font-size: 1.15rem; font-weight: 700; }

/* Dialog */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); max-height: calc(100vh - 24px);
}
dialog::backdrop { background: rgba(10, 15, 25, .5); }
dialog .innen { padding: 18px; }
dialog .preisvorschau { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin: 4px 0 16px; display: flex; justify-content: space-between; font-weight: 600; }

/* Tabellen (Admin) */
.tabelle-wrap { overflow-x: auto; }
table.liste { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.liste th, table.liste td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.liste th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
table.liste td.r, table.liste th.r { text-align: right; }
table.liste tr.klickbar { cursor: pointer; }
table.liste tr.klickbar:hover td { background: var(--bg); }
table.liste tr.detail > td { background: var(--bg); padding: 14px; }
table.liste tfoot td { font-weight: 700; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; color: var(--muted); border-radius: 8px 8px 0 0; border-bottom: 2px solid transparent; }
.tabs button.aktiv { color: var(--ink); border-bottom-color: var(--accent); }
.filter { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filter > * { width: auto; flex: 1 1 180px; }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px;
  font-size: .93rem; z-index: 50; max-width: calc(100vw - 32px);
}
.versteckt { display: none !important; }

@media (max-width: 520px) {
  h1 { font-size: 1.3rem; }
  .kopf { flex-direction: column; }
}
