/* ===== Design Tokens ===== */
:root {
  --bg: #FFFFFF;
  --bg-soft: #F6F5F2;
  --accent: #FF6B4A;
  --accent-dark: #e85535;
  --deep: #163B3D;
  --text-primary: #1C1C1E;
  --text-secondary: #6B6B6B;
  --success: #2F8F5B;
  --danger: #E5484D;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(28,28,30,0.09);
  --shadow-sm: 0 2px 8px rgba(28,28,30,0.07);
  --nav-h: 80px;
  --font-head: 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  background: var(--bg-soft);
  color: var(--text-primary);
  min-height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

/* ===== Header ===== */
.app-header {
  background: var(--bg);
  padding: 20px 20px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid #EDEBE6;
}

.app-header h1 {
  font-family: var(--font-head);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
}

.app-header .sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.avatar-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--bg-soft);
  cursor: pointer;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
}

.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

/* ===== Tabs / Nav ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--nav-h);
  background: var(--bg);
  border-top: 1px solid #EDEBE6;
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-bottom: env(safe-area-inset-bottom, 8px);
  z-index: 20;
}

.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 20px;
  border: none; background: none;
  font-family: var(--font-body);
}

.nav-item.active { color: var(--deep); }
.nav-item svg { width: 22px; height: 22px; }
.nav-item span { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; }

/* ===== Content ===== */
.tab-content {
  display: none;
  padding: 16px 16px calc(var(--nav-h) + 72px);
}
.tab-content.active { display: block; }

/* ===== Ticket Cards ===== */
.ticket {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}

.ticket-main {
  flex: 1;
  padding: 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.ticket-info { flex: 1; min-width: 0; }
.ticket-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-sub  { font-size: 13px; color: var(--text-secondary); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ticket-actions { display: flex; gap: 6px; align-items: center; padding-right: 4px; }

.stub {
  width: 90px;
  border-left: 2px dashed #DEDCD6;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 12px 8px;
  position: relative;
  flex-shrink: 0;
}

.stub::before, .stub::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  background: var(--bg-soft);
  border-radius: 50%;
  left: -8px;
}
.stub::before { top: -8px; }
.stub::after  { bottom: -8px; }

.stub-amount {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 15px;
  text-align: center;
}

.stub-label {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-top: 3px;
}

.pos  { color: var(--success); }
.neg  { color: var(--danger); }
.zero { color: var(--text-secondary); }

/* ===== Avatar ===== */
.avatar {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 15px;
  color: #fff; flex-shrink: 0;
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ===== Badge ===== */
.badge {
  display: inline-block;
  background: var(--bg-soft);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  border-radius: 20px;
  padding: 2px 8px;
}
.badge.item-mit-betrag { background: #FFF1ED; color: var(--accent); }

/* ===== FAB ===== */
.fab {
  position: fixed;
  right: calc(50% - 240px + 20px);
  bottom: calc(var(--nav-h) + 12px);
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 8px 20px rgba(255,107,74,0.40);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  border: none; cursor: pointer;
  z-index: 15;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:active { transform: scale(0.94); box-shadow: 0 4px 12px rgba(255,107,74,0.35); }
@media (max-width: 480px) { .fab { right: 20px; } }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}
.empty-state svg { opacity: 0.25; margin-bottom: 12px; }
.empty-state p { font-size: 15px; }

/* ===== Modal ===== */
.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 30;
  align-items: flex-end;
  justify-content: center;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px 32px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.22s ease-out;
}
@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-handle {
  width: 40px; height: 4px; border-radius: 2px;
  background: #DEDCD6;
  margin: 0 auto 20px;
}

.modal h2 {
  font-family: var(--font-head);
  font-size: 20px;
  margin-bottom: 20px;
}

/* ===== Form ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid #E8E7E3;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg);
  appearance: none;
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus { border-color: var(--accent); }

.form-group .hint { font-size: 12px; color: var(--text-secondary); margin-top: 5px; }

.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0;
  border-bottom: 1px solid #F0EFEB;
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row label { font-size: 15px; font-weight: 500; cursor: pointer; }

/* Toggle Switch */
.toggle {
  position: relative; width: 44px; height: 26px;
}
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider {
  position: absolute; inset: 0;
  background: #DEDCD6;
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Teilnehmer Checkboxen */
.teilnehmer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.teilnehmer-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border: 1.5px solid #E8E7E3;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.teilnehmer-item.checked {
  border-color: var(--accent);
  background: #FFF1ED;
}
.teilnehmer-item input { display: none; }
.teilnehmer-item .t-name { font-size: 14px; font-weight: 500; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  border: none; cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}
.btn:active { opacity: 0.8; }
.btn-primary  { background: var(--accent); color: #fff; width: 100%; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-ghost    { background: transparent; color: var(--text-secondary); padding: 8px; }
.btn-sm       { padding: 7px 12px; font-size: 13px; }
.btn-outline  { background: transparent; border: 1.5px solid #E8E7E3; color: var(--text-primary); }

/* ===== Section Label ===== */
.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 20px 0 10px;
}

/* ===== Auswertung: Zahlung ===== */
.zahlung-card {
  background: var(--bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.zahlung-card.bezahlt { opacity: 0.55; }
.zahlung-text { flex: 1; font-size: 14px; line-height: 1.4; }
.zahlung-betrag { font-family: var(--font-head); font-weight: 700; font-size: 16px; color: var(--deep); }

/* ===== Auswertung: Detail-Klappbar ===== */
.saldo-detail {
  background: var(--bg-soft);
  border-radius: var(--radius-sm);
  padding: 0 14px;
  margin-top: 8px;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease, padding 0.3s;
}
.saldo-detail.open {
  max-height: 600px;
  padding: 12px 14px;
}
.posten-row {
  display: flex; justify-content: space-between;
  font-size: 13px; padding: 5px 0;
  border-bottom: 1px solid #EDEBE6;
  gap: 8px;
}
.posten-row:last-child { border-bottom: none; }
.posten-desc { color: var(--text-primary); flex: 1; }
.posten-anteil { color: var(--text-secondary); white-space: nowrap; }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--bg-soft);
}
.login-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 32px 24px;
  width: 100%;
  max-width: 360px;
}
.login-logo {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.login-sub { color: var(--text-secondary); font-size: 14px; margin-bottom: 28px; }

/* ===== Toast ===== */
.toast-container {
  position: fixed; top: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--deep);
  color: #fff;
  padding: 12px 20px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toastIn 0.22s ease-out;
  pointer-events: auto;
}
.toast.error { background: var(--danger); }
@keyframes toastIn {
  from { transform: translateY(-10px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

/* ===== Profil Modal ===== */
.profil-section { margin-bottom: 24px; }
.profil-avatar-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin-bottom: 24px;
}
.profil-avatar {
  width: 80px; height: 80px; border-radius: 50%;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 700; font-size: 28px;
  color: #fff;
}
.profil-avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ===== Admin Panel ===== */
.admin-list { }
.admin-user-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #F0EFEB;
}
.admin-user-row:last-child { border-bottom: none; }
.admin-user-info { flex: 1; }
.admin-user-name { font-weight: 600; font-size: 15px; }
.admin-user-un   { font-size: 13px; color: var(--text-secondary); }

/* ===== Spinner ===== */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Bezahlt-Checkbox ===== */
.check-box {
  width: 22px; height: 22px;
  border: 2px solid #DEDCD6;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.check-box.checked {
  background: var(--success);
  border-color: var(--success);
}
.check-box svg { display: none; }
.check-box.checked svg { display: block; }
