/* Layout: ein Club-Ausweis – Wappenkopf, drei Register (Sitzung / Übersicht / Verwaltung), unten die Rechnung der Sitzung */
:root {
  --navy: #000066;
  --navy-raised: #0b0b78;
  --navy-deep: #00004a;
  --line: rgba(226, 182, 51, .22);
  --gold: #E2B633;
  --gold-soft: rgba(226, 182, 51, .68);
  --gold-faint: rgba(226, 182, 51, .12);
  --ink-on-gold: #000066;
  --warn: #F08A6C;
  --font-display: "Federant", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: "Alegreya Sans", "Gill Sans", "Trebuchet MS", system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { background: var(--navy); color: var(--gold); }
body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.45;
  min-height: 100%;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--navy); }
.wrap {
  max-width: 880px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* Kopf */
header.top { padding-block: 18px 6px; }
.crest { display: flex; align-items: center; gap: 14px; }
.crest img { width: 64px; height: 64px; border-radius: 10px; border: 1px solid var(--line); flex: none; }
.crest h1 { font-family: var(--font-display); font-weight: 400; font-size: 1.7rem; line-height: 1.1; margin: 0; text-wrap: balance; }
.crest .res { font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-soft); margin-top: 3px; }

/* Register */
nav.tabs {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--navy);
  border-bottom: 1px solid var(--line);
}
nav.tabs .wrap { display: flex; gap: 4px; }
nav.tabs button {
  background: none; border: 0; padding: 12px 12px 10px;
  font-size: .95rem; letter-spacing: .08em; text-transform: uppercase; font-weight: 700;
  color: var(--gold-soft); border-bottom: 3px solid transparent;
}
nav.tabs button[aria-selected="true"] { color: var(--gold); border-bottom-color: var(--gold); }

main { padding-block: 18px 140px; }
section[role="tabpanel"] { display: grid; gap: 18px; }
h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.45rem; margin: 0; text-wrap: balance; }
h3 { font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-soft); margin: 0; font-weight: 700; }
.muted { color: var(--gold-soft); }
.small { font-size: .85rem; }

.btn {
  border: 1px solid var(--gold); background: transparent; border-radius: 999px;
  padding: 8px 16px; font-weight: 700; letter-spacing: .02em;
}
.btn.solid { background: var(--gold); color: var(--ink-on-gold); }
.btn.danger { border-color: var(--warn); color: var(--warn); }
.btn:disabled { opacity: .4; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }

input[type="text"], input[type="number"], input[type="date"], input[type="password"] {
  background: var(--navy-deep); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; min-width: 0; color: var(--gold);
}
input::placeholder { color: var(--gold-soft); }
label.field { display: grid; gap: 4px; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--gold-soft); font-weight: 700; }
label.field input { font-size: 1rem; letter-spacing: 0; text-transform: none; }

/* Leerzustände und Hinweise */
.notice { border: 1px dashed var(--line); border-radius: 12px; padding: 18px; color: var(--gold-soft); }
.notice strong { color: var(--gold); }

/* Sitzungskopf */
.session-head { display: grid; gap: 4px; }
.session-head .label { font-family: var(--font-display); font-size: 1.6rem; }

/* Zählkarten */
.counter-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); }
.counter {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  background: var(--navy-raised); border: 1px solid var(--line); border-radius: 14px; padding: 12px 12px 12px 16px;
}
.counter .who { min-width: 0; }
.counter .name { font-weight: 800; font-size: 1.2rem; overflow-wrap: anywhere; }
.counter .tot { font-size: .82rem; color: var(--gold-soft); }
.counter .count { font-size: 2.1rem; font-weight: 800; min-width: 2.2ch; text-align: right; line-height: 1; }
.counter .count.zero { color: var(--gold-soft); opacity: .55; }
.counter .ctl { display: flex; align-items: center; gap: 6px; }
.mini {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: transparent;
  font-weight: 800; font-size: .95rem; display: grid; place-items: center; padding: 0;
}
.plus {
  width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--gold); color: var(--ink-on-gold);
  font-weight: 800; font-size: 1.35rem; padding: 0; touch-action: manipulation;
  box-shadow: 0 2px 0 rgba(0,0,0,.35);
}
.plus:active { transform: translateY(1px) scale(.97); }
@media (prefers-reduced-motion: no-preference) {
  .count.bump { animation: bump .35s ease-out; }
  @keyframes bump { 0% { transform: scale(1.35); } 100% { transform: scale(1); } }
}

/* Rechnung unten */
.bill {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--gold); color: var(--ink-on-gold);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bill .wrap { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding-block: 10px; }
.bill .row { flex-wrap: nowrap; }
.bill .fig { display: grid; line-height: 1.1; }
.bill .fig span { font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 700; opacity: .8; }
.bill .fig b { font-size: 1.4rem; }
.bill .btn { border-color: var(--ink-on-gold); color: var(--ink-on-gold); padding: 6px 14px; white-space: nowrap; flex: none; }

/* Übersicht */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.stat { background: var(--navy); padding: 14px 16px; display: grid; gap: 2px; }
.stat span { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--gold-soft); font-weight: 700; }
.stat b { font-size: 1.6rem; font-weight: 800; }
.tablebox { overflow-x: auto; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-soft); font-weight: 700; }
th:nth-child(2), td:nth-child(2) { text-align: left; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { border-top: 2px solid var(--gold); border-bottom: 0; font-weight: 800; }
td.rank { color: var(--gold-soft); width: 2.5em; }
td.nm { font-weight: 700; }
.bar { height: 4px; background: var(--gold-faint); border-radius: 2px; margin-top: 5px; min-width: 80px; }
.bar i { display: block; height: 100%; background: var(--gold); border-radius: 2px; }
tr.inactive td.nm { color: var(--gold-soft); }
.hist-row { cursor: pointer; }
.hist-row:hover td { background: var(--gold-faint); }
.chip { display: inline-block; font-size: .7rem; letter-spacing: .1em; text-transform: uppercase; font-weight: 800; border: 1px solid currentColor; border-radius: 999px; padding: 1px 8px; vertical-align: 2px; }
.chip.live { background: var(--gold); color: var(--ink-on-gold); border-color: var(--gold); }

/* Korrektur-Panel */
.panel { border: 1px solid var(--gold); border-radius: 14px; padding: 16px; display: grid; gap: 14px; background: var(--navy-deep); }
.edit-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); }
.edit-item { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; align-items: center; }
.edit-item input { width: 5.5em; text-align: right; }
.confirm { border: 1px solid var(--warn); border-radius: 10px; padding: 12px; color: var(--warn); display: grid; gap: 10px; }

/* Verwaltung */
.member-row { display: grid; grid-template-columns: minmax(0, 1fr) 7em auto; gap: 8px; align-items: end; padding-block: 10px; border-bottom: 1px solid var(--line); }
.member-row input { width: 100%; }
.toggle { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--gold-soft); padding-bottom: 8px; }
.toggle input { accent-color: var(--gold); width: 18px; height: 18px; }

/* Meldung */
.toast {
  position: fixed; left: 0; right: 0; margin-inline: auto; width: fit-content;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px)); z-index: 20;
  background: var(--navy-deep); border: 1px solid var(--gold); border-radius: 999px;
  padding: 8px 8px 8px 18px; display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px);
  box-shadow: 0 6px 20px rgba(0,0,0,.4);
}
.toast button { background: var(--gold); color: var(--ink-on-gold); border: 0; border-radius: 999px; padding: 6px 14px; font-weight: 800; }
.toast.noaction { padding-right: 18px; }

@media (max-width: 480px) {
  .crest img { width: 52px; height: 52px; }
  .crest h1 { font-size: 1.4rem; }
  nav.tabs button { padding-inline: 8px; font-size: .85rem; }
  .mini { width: 36px; height: 36px; }
  .counter { padding-left: 12px; gap: 8px; }
  .bill .fig b { font-size: 1.2rem; }
  th, td { padding: 9px 6px; }
  th { white-space: normal; font-size: .66rem; letter-spacing: .06em; }
  td.rank { width: 1.8em; }
  .bar { min-width: 56px; }
  table { font-size: .95rem; }
  .bill .row { gap: 14px !important; }
}

[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; }
header.top { padding-top: calc(18px + env(safe-area-inset-top, 0px)); }
.crest .role { margin-left: auto; align-self: center; }
.crest > div:nth-child(2) { min-width: 0; }

/* PIN und Ersteinrichtung */
.pin-form { display: grid; gap: 12px; }
.pin-form input[type="password"] { font-size: 1.3rem; letter-spacing: .3em; width: 100%; max-width: 14em; }
.err { color: var(--warn); font-weight: 700; }

.offline {
  position: fixed; left: 0; right: 0; top: 0; z-index: 30; text-align: center;
  background: var(--warn); color: var(--ink-on-gold); font-weight: 700; font-size: .85rem;
  padding: calc(4px + env(safe-area-inset-top, 0px)) 16px 4px;
}
