/* Saalplan Trachtenverein Wasentegernbach
   Farbwelt aus dem Wappen: Loden-Grün, Kronen-Gold, Schild-Rot. App-Shell mit Kopfleiste,
   Karten-Flächen und unterer Tab-Leiste am Handy. */
:root {
  --bg: #f2f4f1;
  --surface: #ffffff;
  --surface-2: #f5f7f4;
  --surface-3: #e9ede8;
  --fg: #142019;
  --muted: #5f6d65;
  --line: #dde3dd;
  --brand: #173c2d;
  --brand-2: #22553f;
  --brand-fg: #ffffff;
  --gold: #c99a2e;
  --gold-soft: #f7edd3;
  --red: #a83a30;
  --red-soft: #f8e5e2;
  --ok: #2c7a4b;
  --ok-soft: #e1f2e7;
  --warn: #9a6400;
  --free: #ffffff;
  --free-line: #cdd6cf;
  --seat-s: 52%;
  --seat-l: 80%;
  --seat-fg: #142019;
  --shadow: 0 1px 2px rgba(20, 32, 25, .06), 0 8px 24px rgba(20, 32, 25, .06);
  --focus: #2f6fdb;
  --r: 18px;
  --r-sm: 12px;
  --font: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1310;
    --surface: #151d19;
    --surface-2: #1b2520;
    --surface-3: #232f29;
    --fg: #e7eee9;
    --muted: #93a39a;
    --line: #2a3630;
    --brand: #0f2a1f;
    --brand-2: #1b4433;
    --brand-fg: #f1f6f2;
    --gold: #e0b453;
    --gold-soft: #3a3020;
    --red: #ec7b70;
    --red-soft: #3b2220;
    --ok: #6cc48f;
    --ok-soft: #1c3527;
    --warn: #e5b04b;
    --free: #1b2520;
    --free-line: #34423b;
    --seat-s: 40%;
    --seat-l: 36%;
    --seat-fg: #f1f6f2;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    --focus: #84b2ff;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.eyebrow { font-size: .7rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.num { font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 0; min-width: 0; }
.row.tight { flex-wrap: nowrap; align-items: center; }
.stack { display: grid; gap: 14px; align-content: start; }

/* ---------- Buttons & Felder ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface-2);
  padding: 12px 16px; border-radius: var(--r-sm); font-weight: 700; font-size: .92rem;
  cursor: pointer; min-height: 46px; white-space: nowrap; transition: transform .08s, background-color .15s, border-color .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: var(--brand-fg); }
.btn.primary:hover { background: var(--brand); }
.btn.danger { color: var(--red); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; }
.iconbtn { border: 0; background: var(--surface-3); width: 36px; height: 36px; border-radius: 50%; cursor: pointer; font-size: .9rem; flex: none; }
.linkbtn { border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 8px; font-size: .85rem; }

.field { display: grid; gap: 6px; }
.field > span { font-size: .8rem; font-weight: 700; color: var(--muted); }
.field em { font-style: normal; font-weight: 500; }
input[type=text], input[type=password], input[type=search], input[type=number], input[type=datetime-local], input:not([type]), textarea {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--surface-2); min-height: 46px; font-size: 16px; /* 16px verhindert Zoom auf iOS */
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
input:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 22%, transparent); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; user-select: none; }
.check input { width: 20px; height: 20px; accent-color: var(--brand-2); }

.stepper { display: grid; grid-template-columns: 52px 1fr 52px; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; background: var(--surface-2); }
.stepper button { border: 0; background: transparent; font-size: 1.4rem; font-weight: 600; color: var(--brand-2); cursor: pointer; }
.stepper button:active { background: var(--surface-3); }
.stepper input { border: 0; border-radius: 0; background: transparent; text-align: center; font-weight: 800; font-size: 1.25rem; font-variant-numeric: tabular-nums; -moz-appearance: textfield; box-shadow: none !important; }
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.error { color: var(--red); font-weight: 600; font-size: .9rem; }

/* ---------- Gate (Installieren / Anmelden) ---------- */
.gate {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 84px) max(16px, env(safe-area-inset-right, 0px)) calc(env(safe-area-inset-bottom, 0px) + 24px) max(16px, env(safe-area-inset-left, 0px));
  background:
    radial-gradient(1200px 500px at 50% -10%, color-mix(in srgb, var(--gold) 22%, transparent), transparent 60%),
    linear-gradient(180deg, var(--brand) 0%, var(--brand-2) 55%, var(--bg) 55.1%);
}
.gate-card {
  width: 100%; max-width: 440px; background: var(--surface); border-radius: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.18);
  padding: 28px 22px 22px; display: grid; gap: 14px; text-align: center; justify-items: center;
}
.gate-card > * { width: 100%; }
.gate-crest { width: 108px !important; height: auto; margin-top: -78px; filter: drop-shadow(0 8px 18px rgba(0,0,0,.25)); }
.gate .lead { color: var(--muted); }
.gate .field { text-align: left; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-3); border-radius: 999px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 9px 10px; font-weight: 700; font-size: .88rem; cursor: pointer; color: var(--muted); }
.seg button[aria-selected=true] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; text-align: left; }
.steps li { display: flex; gap: 12px; align-items: flex-start; background: var(--surface-2); border-radius: var(--r-sm); padding: 12px 14px; }
.steps .n { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-2); color: var(--brand-fg); display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.steps small { display: block; color: var(--muted); margin-top: 2px; }
.ico { width: 20px; height: 20px; vertical-align: -4px; color: #2f7bf6; margin-left: 2px; }
.note { font-size: .85rem; background: var(--gold-soft); border-radius: var(--r-sm); padding: 10px 12px; text-align: left; }
.note.ok { background: var(--ok-soft); color: var(--ok); font-weight: 700; }

/* ---------- App-Shell ---------- */
.appbar {
  position: sticky; top: 0; z-index: 10; background: var(--brand); color: var(--brand-fg);
  padding-top: env(safe-area-inset-top, 0px);
}
.appbar-in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); }
.appbar-crest { width: 40px; height: 40px; object-fit: contain; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }
.appbar-title { display: grid; line-height: 1.2; min-width: 0; }
.appbar-title .eyebrow { color: color-mix(in srgb, var(--brand-fg) 65%, transparent); font-size: .62rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-title strong { font-size: 1.1rem; font-weight: 800; }
.topnav { margin-left: auto; display: flex; gap: 4px; background: rgba(255,255,255,.08); padding: 4px; border-radius: 999px; }
.topnav button { border: 0; background: transparent; color: color-mix(in srgb, var(--brand-fg) 75%, transparent); padding: 8px 16px; border-radius: 999px; font-weight: 700; cursor: pointer; }
.topnav button.on { background: var(--brand-fg); color: var(--brand); }
@media (max-width: 760px) { .topnav { display: none; } }

.content { max-width: 1280px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 16px; }
@media (max-width: 760px) { .content { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); } }

.tabbar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 6px max(8px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
}
.tabbar button { flex: 1; border: 0; background: none; display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: .72rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabbar svg { width: 26px; height: 26px; }
.tabbar button.on { color: var(--brand-2); }
@media (prefers-color-scheme: dark) { .tabbar button.on { color: var(--gold); } }
@media (max-width: 760px) { .tabbar { display: flex; } }
body.role-helfer .admin-only, body.role-admin .helfer-only { display: none !important; }

.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head.wrap { flex-wrap: wrap; }
.banner { border-radius: var(--r-sm); padding: 10px 14px; font-size: .88rem; font-weight: 600; }
.banner.warn { background: var(--gold-soft); color: var(--warn); }

/* Vorstellungen-Leiste */
.showbar { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -4px; padding: 2px 4px; }
.showbar::-webkit-scrollbar { display: none; }
.showchip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; padding: 9px 14px; cursor: pointer; text-align: left; display: grid; gap: 1px; min-width: 150px; box-shadow: var(--shadow); }
.showchip b { font-size: .9rem; }
.showchip span { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.showchip .bar { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; margin-top: 5px; }
.showchip .bar i { display: block; height: 100%; background: var(--gold); }
.showchip.on { background: var(--brand-2); border-color: var(--brand-2); color: var(--brand-fg); }
.showchip.on span { color: color-mix(in srgb, var(--brand-fg) 75%, transparent); }
.showchip.on .bar { background: rgba(255,255,255,.2); }

/* ---------- Buchen ---------- */
.booking-layout { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 980px) { .booking-layout { grid-template-columns: minmax(0, 1fr); } }
.form { display: grid; gap: 14px; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); }
@media (max-width: 980px) { .form { position: static; } }
.form .card-head { margin-bottom: 0; }
.result { border-radius: var(--r-sm); padding: 12px 14px; background: var(--surface-2); font-size: .9rem; color: var(--muted); }
.result strong { display: block; color: var(--fg); font-size: 1.05rem; margin-bottom: 2px; }
.result.ok { background: var(--ok-soft); color: var(--ok); }
.result.ok strong { color: var(--ok); }
.result.bad { background: var(--red-soft); color: var(--red); }
.result.bad strong { color: var(--red); }
.noshow { text-align: center; display: grid; gap: 10px; justify-items: center; padding: 32px 18px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; display: grid; }
.stat b { font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat span { font-size: .72rem; color: var(--muted); font-weight: 600; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); font-weight: 600; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 12px; height: 12px; border-radius: 4px; border: 1px solid var(--free-line); background: var(--free); }
.legend .lg-booked { background: hsl(150 var(--seat-s) var(--seat-l)); border-color: transparent; }
.legend .lg-sel { background: var(--gold); border-color: var(--gold); }

.scroller { overflow-x: auto; margin: 0 -18px; padding: 0 18px 6px; }
.grid { display: grid; gap: 4px; min-width: max-content; margin: 0 auto 10px; }
.stage {
  text-align: center; font-weight: 800; letter-spacing: .4em; font-size: .75rem; padding: 10px;
  background: linear-gradient(180deg, var(--brand-2), var(--brand)); color: var(--brand-fg);
  border-radius: 10px 10px 50% 50% / 10px 10px 18px 18px; margin-bottom: 12px;
}
.colnum, .rownum { font-size: .66rem; color: var(--muted); font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.seat {
  height: 46px; min-width: 56px; border-radius: 8px 8px 12px 12px; border: 1px solid var(--free-line); background: var(--free);
  cursor: pointer; padding: 3px 4px; font-size: .66rem; font-weight: 700; line-height: 1.1; color: var(--seat-fg);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; position: relative; text-align: center;
}
.seat .sn { display: block; font-size: .58rem; opacity: .55; font-weight: 600; }
.seat:hover { border-color: var(--muted); }
.seat.booked { background: hsl(var(--h) var(--seat-s) var(--seat-l)); border-color: transparent; }
.seat.dim { opacity: .3; }
.seat.focus { box-shadow: 0 0 0 2px var(--fg); z-index: 1; }
.seat.sel { background: var(--gold); border-color: var(--gold); color: #1e1606; }
.seat.sel .sn { opacity: .75; }
@media (max-width: 760px) {
  .grid { min-width: 0; gap: 3px; }
  .scroller { margin: 0 -10px; padding: 0 10px 6px; }
  .seat { min-width: 0; height: 32px; font-size: 0; padding: 0; border-radius: 5px 5px 8px 8px; }
  .seat .sn { font-size: .6rem; opacity: .5; }
  .seat.booked .sn { opacity: .7; }
}
@media (prefers-reduced-motion: no-preference) { .seat { transition: background-color .15s, opacity .15s, box-shadow .15s; } }

/* ---------- Liste ---------- */
.card-head input[type=search] { width: 220px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.chips button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-weight: 700; font-size: .8rem; cursor: pointer; color: var(--muted); }
.chips button.on { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.list { display: grid; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 8px; }
.item:hover { background: var(--surface-2); }
.item:last-child { border-bottom: 0; }
.item .nm { font-weight: 700; }
.item .meta { grid-column: 2 / 4; font-size: .85rem; color: var(--muted); }
.item .cnt { font-weight: 800; font-variant-numeric: tabular-nums; }
.swatch { width: 14px; height: 14px; border-radius: 5px; background: hsl(var(--h) var(--seat-s) var(--seat-l)); flex: none; }
.pill { display: inline-block; font-size: .68rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; margin-left: 6px; vertical-align: 1px; }
.pill.paid { background: var(--ok-soft); color: var(--ok); }
.pill.open { background: var(--gold-soft); color: var(--warn); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ---------- Admin ---------- */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; align-items: start; }
.show-list { display: grid; gap: 8px; }
.show-row { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; }
.show-row div { flex: 1; min-width: 0; }
.show-row b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.show-row span { font-size: .8rem; color: var(--muted); }
.show-row .btn { min-height: 36px; padding: 6px 12px; font-size: .82rem; flex: none; }

.dates { display: grid; gap: 8px; }
.date-row { display: flex; gap: 8px; align-items: center; }
.date-row input { flex: 1; min-width: 0; }
.date-row .iconbtn { width: 40px; height: 40px; }
.btn.ghost { background: transparent; border-style: dashed; color: var(--brand-2); }
@media (prefers-color-scheme: dark) { .btn.ghost { color: var(--gold); } }
.play { display: grid; gap: 6px; }
.play + .play { margin-top: 8px; }
.play-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.play-head b { font-size: 1rem; }
.play-head span { font-size: .8rem; color: var(--muted); white-space: nowrap; }

/* ---------- Detail-Blatt ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; }
.sheet {
  position: fixed; z-index: 31; background: var(--surface); box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  left: 0; right: 0; bottom: 0; border-radius: 24px 24px 0 0; display: grid; gap: 14px;
  padding: 10px max(20px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  max-height: 85vh; overflow-y: auto;
}
@media (min-width: 761px) { .sheet { left: auto; right: 24px; bottom: 24px; width: 380px; border-radius: 22px; padding: 18px 20px 20px; } .sheet-grip { display: none; } }
.sheet-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto; }
.sheet-head { display: flex; align-items: center; gap: 10px; }
.sheet-head h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: .92rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 600; }
.confirm { background: var(--red-soft); border-radius: var(--r-sm); padding: 12px; display: grid; gap: 10px; color: var(--red); font-weight: 600; }
@media (prefers-reduced-motion: no-preference) {
  .sheet:not([hidden]) { animation: up .22s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg);
  padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: .9rem; box-shadow: 0 10px 30px rgba(0,0,0,.25);
  max-width: calc(100% - 32px); text-align: center;
}
@media (max-width: 760px) { .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }
