@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --bg: #121316;
  --surface: #1b1d22;
  --surface-2: #24272e;
  --surface-3: #2e323b;
  --border: #34383f;
  --text: #f1f0ec;
  --text-muted: #90939c;
  --text-faint: #5c5f68;

  --gold: #e3b04b;
  --gold-dim: #7a6127;
  --gold-soft: rgba(227, 176, 75, 0.14);

  --ok: #58b787;
  --ok-soft: rgba(88, 183, 135, 0.14);
  --danger: #e2574c;
  --danger-soft: rgba(226, 87, 76, 0.14);

  --radius: 14px;
  --radius-sm: 9px;

  --font-display: 'Space Grotesk', 'Inter', sans-serif;
  --font-body: 'Inter', -apple-system, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SF Mono', monospace;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(227,176,75,0.06), transparent 45%),
    radial-gradient(circle at 90% 100%, rgba(88,183,135,0.05), transparent 40%);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button, input, textarea {
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

input, button, textarea {
  font-size: 16px; /* verhindert Auto-Zoom in Mobile Safari */
}

a { color: inherit; text-decoration: none; }

::selection { background: var(--gold-soft); color: var(--gold); }

/* ---------- Layout shells ---------- */
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 2px 18px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 4px;
}
.back-link:active { color: var(--text); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

/* ---------- Home ---------- */
.home-header {
  text-align: center;
  padding: 28px 0 8px;
}
.home-header .eyebrow { display: block; margin-bottom: 8px; }
.home-header h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  color: var(--text);
}

/* Split-flap style counter — the signature element */
.counter-card {
  margin: 22px 0 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.counter-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(227,176,75,0.06), transparent 60%);
  pointer-events: none;
}
.counter-digits {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 56px;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  gap: 2px;
}
.counter-digits span {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  min-width: 0.72em;
  text-align: center;
}
.counter-label {
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}
.counter-label b { color: var(--text); font-weight: 600; }

.nav-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
}

/* Ticket-stub buttons */
.ticket-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.ticket-btn:active { transform: scale(0.98); background: var(--surface-2); }

.ticket-btn .tb-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
}
.ticket-btn .tb-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}
.ticket-btn .tb-icon {
  font-size: 22px;
  color: var(--gold);
  flex-shrink: 0;
}
.ticket-btn.perforated::after {
  content: '';
  position: absolute;
  right: 66px;
  top: 10px;
  bottom: 10px;
  width: 0;
  border-left: 2px dashed var(--surface-3);
}

.admin-entry {
  margin-top: auto;
  padding-top: 26px;
  text-align: center;
}
.admin-entry a {
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 500;
  padding: 10px;
  display: inline-block;
}
.admin-entry a:active { color: var(--text-muted); }

/* ---------- Search / Check-in ---------- */
.search-wrap { position: sticky; top: 0; background: var(--bg); padding-bottom: 12px; z-index: 5; }

.search-input {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s ease;
}
.search-input::placeholder { color: var(--text-faint); font-weight: 500; }
.search-input:focus { border-color: var(--gold); }

.list-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  padding: 10px 4px 4px;
}

.guest-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.guest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.guest-item:active { transform: scale(0.985); }

.guest-item.is-in {
  border-color: rgba(88,183,135,0.35);
  background: linear-gradient(180deg, var(--ok-soft), var(--surface) 70%);
}

.guest-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.guest-item:not(.is-in) .guest-name { color: #cfd1d6; }

.guest-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-faint);
  white-space: nowrap;
  flex-shrink: 0;
}
.guest-item.is-in .guest-status { color: var(--ok); }

.status-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.guest-item.is-in .status-dot { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

.check-glyph {
  font-size: 15px;
  line-height: 1;
}

.empty-state {
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  padding: 40px 10px;
}
/* ---------- Entry-type modal (Bezahlt / Frei) ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 13, 0.72);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.modal-overlay.show { display: flex; }

.modal-box {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  animation: modalUp 0.18s ease;
}
@keyframes modalUp {
  from { transform: translateY(16px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}
.modal-actions .btn { flex: 1; }

.modal-cancel {
  width: 100%;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 14px;
  font-weight: 500;
  padding: 10px;
}

.entry-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: 6px;
}
.entry-badge.bezahlt { background: var(--ok-soft); color: var(--ok); }
.entry-badge.frei { background: var(--gold-soft); color: var(--gold); }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 13px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 50;
  max-width: 90vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: rgba(88,183,135,0.4); }
.toast.err { border-color: rgba(226,87,76,0.4); }

/* ---------- Forms (Abendkasse / Admin) ---------- */
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}
.field input, .field textarea {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}
.field input:focus, .field textarea:focus { border-color: var(--gold); }

.amount-input-wrap { position: relative; }
.amount-input-wrap input { padding-right: 44px; font-family: var(--font-mono); font-weight: 600; }
.amount-suffix {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-weight: 600; font-family: var(--font-mono);
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.1s ease;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

.btn-primary { background: var(--gold); color: #1a1406; }
.btn-ok { background: var(--ok); color: #0d1f16; }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border: 1px solid rgba(226,87,76,0.35); }

.page-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
}
.page-sub {
  font-size: 13.5px;
  color: var(--text-muted);
  margin: 0 0 22px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}
.card h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--text);
}

/* ---------- Abendkasse confirmation ---------- */
.paid-confirm {
  text-align: center;
  padding: 30px 10px;
}
.paid-confirm .icon-circle {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  margin: 0 auto 18px;
}
.paid-confirm h2 {
  font-family: var(--font-display);
  font-size: 19px;
  margin: 0 0 6px;
}
.paid-confirm p { color: var(--text-muted); font-size: 14px; margin: 0 0 26px; }

/* ---------- Admin: login ---------- */
.login-shell {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box { width: 100%; }

/* ---------- Admin: dashboard ---------- */
.tabs {
  display: flex;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 20px;
}
.tab-btn {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 8px;
  border-radius: 999px;
  cursor: pointer;
}
.tab-btn.active { background: var(--gold); color: #1a1406; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.stat-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.stat-box {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
}
.stat-box .num {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.stat-box .lbl {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 500;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding-top: 10px;
  overflow-x: auto;
}
.bar-col {
  flex: 0 0 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  gap: 6px;
}
.bar {
  width: 14px;
  background: var(--gold);
  border-radius: 4px 4px 0 0;
  min-height: 3px;
}
.bar-col .bar-hour {
  font-size: 9px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
}

.sales-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.sales-table th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
}
.sales-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--surface-2);
  color: var(--text);
}
.sales-table td.amount { font-family: var(--font-mono); font-weight: 600; color: var(--ok); text-align: right; }
.sales-table td.time { color: var(--text-muted); font-family: var(--font-mono); font-size: 12px; }

.guest-admin-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 4px;
  border-bottom: 1px solid var(--surface-2);
  font-size: 14px;
}
.guest-admin-row .g-name { font-weight: 500; }
.guest-admin-row .g-del {
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 10px;
}

.upload-drop {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 22px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  cursor: pointer;
  position: relative;
}
.upload-drop input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}
.upload-drop.has-file { border-color: var(--gold); color: var(--text); }

.msg-line {
  font-size: 13px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.msg-line.ok { background: var(--ok-soft); color: var(--ok); }
.msg-line.err { background: var(--danger-soft); color: var(--danger); }

.logout-row { text-align: center; margin-top: 22px; }
.logout-row button {
  background: none; border: none; color: var(--text-faint);
  font-size: 13px; font-weight: 500; padding: 8px;
}

/* Loading spinner */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
