:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b2030;
  --line: #262c3d;
  --text: #e8ebf2;
  --muted: #8a93a8;
  --accent: #3b82f6;
  --accent-2: #2563eb;
  --pos: #22c55e;
  --neg: #ef4444;
  --warn: #f59e0b;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
h2, h3 { margin: 0 0 12px; }
.small { font-size: 13px; }
.muted { color: var(--muted); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.msg { min-height: 1.2em; margin: 8px 0 0; font-size: 14px; color: var(--neg); }
.msg.ok { color: var(--pos); }

/* Knöpfe */
.primary, .secondary, .ghost {
  border: 0; border-radius: 12px; padding: 12px 16px; cursor: pointer;
  font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  min-height: 46px;
}
.primary { background: var(--accent); color: #fff; }
.primary:active { background: var(--accent-2); }
.primary[disabled] { opacity: .5; }
.secondary { background: var(--panel-2); color: var(--text); }
.ghost { background: transparent; color: var(--muted); }
.wide { width: 100%; }
.icon { background: transparent; border: 0; color: var(--muted); padding: 8px; cursor: pointer; }

/* Boot */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Anmeldung */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 18px; padding: 24px 20px; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; font-size: 18px; }
.mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; font-weight: 800; }
.field { display: block; margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.field input {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; min-height: 48px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 12px; font-size: 17px; color: var(--text);
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.with-btn { display: flex; gap: 8px; margin-top: 6px; }
.with-btn input { margin-top: 0; }
.secret { display: block; background: var(--bg); border-radius: 10px; padding: 12px; font: 15px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; white-space: pre-wrap; margin: 8px 0 14px; user-select: all; }

/* Kopf */
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: rgba(11, 13, 18, .92);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
.brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kasse { margin-left: auto; text-align: right; font-size: 12px; color: var(--muted); line-height: 1.2; }
.kasse b { display: block; font-size: 15px; color: var(--text); }

main { padding: 16px 16px calc(90px + var(--safe-b)); max-width: 720px; margin: 0 auto; }

/* Untere Leiste */
.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr);
  background: rgba(20, 24, 33, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.bottom a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 0 8px; color: var(--muted); text-decoration: none; font-size: 12px; }
.bottom a.on { color: var(--accent); }

/* Karten */
.hero { background: linear-gradient(160deg, #1d2a4a, var(--panel)); border-radius: 18px; padding: 18px; margin-bottom: 14px; }
.hero .label { color: var(--muted); font-size: 13px; }
.hero .big { font-size: 34px; font-weight: 800; letter-spacing: -.5px; margin: 2px 0 8px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--panel); border-radius: var(--radius); padding: 14px; }
.tile .label { color: var(--muted); font-size: 12px; }
.tile .val { font-size: 19px; font-weight: 700; margin-top: 2px; }
.hero .tile { background: rgba(0, 0, 0, .22); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.section-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; margin: 18px 2px 8px; }
.locked { display: flex; align-items: center; gap: 10px; background: rgba(245, 158, 11, .1); color: var(--warn); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; font-size: 14px; }

.toolbar { display: flex; gap: 10px; margin-bottom: 12px; }
.toolbar input { flex: 1; min-width: 0; padding: 12px 14px; min-height: 46px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--text); font-size: 16px; }
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cards li { background: var(--panel); border-radius: var(--radius); padding: 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.cards li:active { background: var(--panel-2); }
.cards .avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-weight: 700; color: var(--muted); flex: none; }
.cards .main { flex: 1; min-width: 0; }
.cards .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cards .sub { color: var(--muted); font-size: 12px; }
.cards .right { text-align: right; flex: none; }
.cards .right b { display: block; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px; background: var(--panel-2); color: var(--muted); }
.badge.void { background: rgba(239, 68, 68, .15); color: var(--neg); }

.settle { background: var(--panel); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.settle-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.settle table { width: 100%; border-collapse: collapse; font-size: 14px; }
.settle td { padding: 4px 0; }
.settle td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.settle .void td { text-decoration: line-through; color: var(--muted); }

/* Dialoge als Bodensheet */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 520px; background: var(--panel); color: var(--text);
  border-radius: 20px 20px 0 0; max-height: 92dvh;
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .6); }
dialog.sheet form { padding: 20px 16px calc(16px + var(--safe-b)); }
@media (min-width: 600px) { dialog.sheet { margin: auto; border-radius: 20px; } }
.row { display: flex; gap: 10px; margin-top: 8px; }
.row > * { flex: 1; }
.seg { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { border: 0; background: transparent; padding: 10px; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--panel-2); color: var(--text); }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: -4px 0 6px; }
.quick button { border: 0; background: var(--panel-2); border-radius: 10px; padding: 10px 0; cursor: pointer; font-weight: 600; }
.pd-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.pd-stats .tile { background: var(--bg); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-b)); z-index: 20;
  background: #111827; border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; max-width: calc(100% - 32px);
}
.num { font-variant-numeric: tabular-nums; }
