:root {
  --bg-primary: #0b0b14;
  --bg-secondary: #13131f;
  --bg-tertiary: #1c1c2e;
  --bg-hover: #22223a;
  --gold: #c9a227;
  --gold-light: #f0c040;
  --gold-dim: rgba(201, 162, 39, 0.15);
  --text-primary: #e8e8f0;
  --text-secondary: #8888aa;
  --border: #2a2a45;
  --border-light: #33335a;

  /* Rollen-Farben */
  --c-gast: #4fc3f7;
  --c-gast-bg: rgba(79, 195, 247, 0.1);
  --c-nominiert: #ce93d8;
  --c-nominiert-bg: rgba(206, 147, 216, 0.1);
  --c-team: #81c784;
  --c-team-bg: rgba(129, 199, 132, 0.1);
  --c-sponsor: #ffb74d;
  --c-sponsor-bg: rgba(255, 183, 77, 0.1);
  --c-begleitung: #90a4ae;
  --c-begleitung-bg: rgba(144, 164, 174, 0.08);

  /* Status-Farben */
  --s-zugesagt: #66bb6a;
  --s-abgesagt: #ef5350;
  --s-deadline: #ffa726;
  --s-unbeantwortet: #ffd54f;

  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ─── Sync-Indikator ─── */
.sync-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block; flex-shrink: 0;
  transition: background 0.4s;
}
.sync-dot.online  { background: #4caf50; box-shadow: 0 0 0 2px rgba(76,175,80,0.3); animation: syncPulse 2s infinite; }
.sync-dot.offline { background: #666; box-shadow: none; animation: none; }
@keyframes syncPulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(76,175,80,0.3); }
  50%       { box-shadow: 0 0 0 5px rgba(76,175,80,0); }
}

/* ─── Header ─── */
.app-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo { height: 36px; object-fit: contain; }
.header-title { font-size: 1.1rem; font-weight: 600; color: var(--gold-light); flex: 1; }

.header-user {
  display: flex; align-items: center; gap: 8px;
  color: var(--text-secondary); font-size: 0.85rem;
}
.header-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gold-dim); border: 1px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  color: var(--gold); font-weight: 600; font-size: 0.9rem;
}

/* ─── Layout ─── */
.app-layout { display: flex; height: calc(100vh - 60px); }

.sidebar {
  width: 200px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
  overflow-y: auto;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; cursor: pointer;
  color: var(--text-secondary); font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: all 0.15s;
  user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--gold-dim); color: var(--gold-light); border-left-color: var(--gold); }
.nav-icon { font-size: 1rem; }

.main-content { flex: 1; overflow-y: auto; padding: 24px; }

/* ─── Stats Bar ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  text-align: center;
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.highlight .stat-value { color: var(--gold-light); }
.stat-card.green .stat-value { color: var(--s-zugesagt); }
.stat-card.red .stat-value { color: var(--s-abgesagt); }

/* ─── Toolbar ─── */
.toolbar {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; flex-wrap: wrap;
}

.search-input {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius);
  padding: 8px 14px; font-size: 0.9rem; outline: none;
  min-width: 220px; flex: 1; max-width: 360px;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: var(--gold); }
.search-input::placeholder { color: var(--text-secondary); }

.role-tabs {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.role-tab {
  padding: 6px 14px; border-radius: 20px; cursor: pointer;
  border: 1px solid var(--border); background: transparent;
  color: var(--text-secondary); font-size: 0.8rem; font-weight: 500;
  transition: all 0.15s; white-space: nowrap;
}
.role-tab:hover { border-color: var(--border-light); color: var(--text-primary); }
.role-tab.active { background: var(--gold-dim); border-color: var(--gold); color: var(--gold-light); }
.role-tab.r-gast.active { background: var(--c-gast-bg); border-color: var(--c-gast); color: var(--c-gast); }
.role-tab.r-nominiert.active { background: var(--c-nominiert-bg); border-color: var(--c-nominiert); color: var(--c-nominiert); }
.role-tab.r-team.active { background: var(--c-team-bg); border-color: var(--c-team); color: var(--c-team); }
.role-tab.r-sponsor.active { background: var(--c-sponsor-bg); border-color: var(--c-sponsor); color: var(--c-sponsor); }
.role-tab.r-begleitung.active { background: var(--c-begleitung-bg); border-color: var(--c-begleitung); color: var(--c-begleitung); }

/* ─── Buttons ─── */
.btn {
  padding: 8px 16px; border-radius: var(--radius); border: none;
  cursor: pointer; font-size: 0.85rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.15s; white-space: nowrap; text-decoration: none;
}
.btn-primary { background: var(--gold); color: #000; }
.btn-primary:hover { background: var(--gold-light); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn-danger { background: rgba(239,83,80,0.15); color: #ef5350; border: 1px solid rgba(239,83,80,0.3); }
.btn-danger:hover { background: rgba(239,83,80,0.25); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-icon { padding: 6px; border-radius: var(--radius); }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--bg-tertiary); padding: 10px 12px;
  text-align: left; font-size: 0.75rem; font-weight: 600;
  color: var(--text-secondary); text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 1px solid var(--border);
  white-space: nowrap; cursor: pointer; user-select: none;
}
thead th:hover { color: var(--text-primary); }

tbody tr { transition: background 0.1s; border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover) !important; }

td { padding: 9px 12px; vertical-align: middle; }
td.td-id { color: var(--text-secondary); font-size: 0.8rem; width: 60px; }
td.td-name { font-weight: 500; }
td.td-kuenstler { color: var(--gold-light); font-weight: 600; }
td.td-actions { white-space: nowrap; text-align: right; width: 1px; }

/* Zeilen-Färbung nach Rolle */
tr.r-gast td { background: rgba(79, 195, 247, 0.04); }
tr.r-nominiert td { background: rgba(206, 147, 216, 0.04); }
tr.r-team td { background: rgba(129, 199, 132, 0.04); }
tr.r-sponsor td { background: rgba(255, 183, 77, 0.04); }
tr.r-begleitung td { background: rgba(144, 164, 174, 0.03); opacity: 0.85; }

/* ─── Badges ─── */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge-gast { background: var(--c-gast-bg); color: var(--c-gast); border: 1px solid rgba(79,195,247,0.25); }
.badge-nominiert { background: var(--c-nominiert-bg); color: var(--c-nominiert); border: 1px solid rgba(206,147,216,0.25); }
.badge-team { background: var(--c-team-bg); color: var(--c-team); border: 1px solid rgba(129,199,132,0.25); }
.badge-sponsor { background: var(--c-sponsor-bg); color: var(--c-sponsor); border: 1px solid rgba(255,183,77,0.25); }
.badge-begleitung { background: var(--c-begleitung-bg); color: var(--c-begleitung); border: 1px solid rgba(144,164,174,0.2); }

.status-dot {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 0.8rem; white-space: nowrap;
}
.status-dot::before {
  content: ''; display: inline-block;
  width: 8px; height: 8px; border-radius: 50%;
}
.status-dot.zugesagt::before { background: var(--s-zugesagt); }
.status-dot.abgesagt::before { background: var(--s-abgesagt); }
.status-dot.deadline::before { background: var(--s-deadline); }
.status-dot.unbeantwortet::before { background: var(--s-unbeantwortet); }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow);
}
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 1.3rem; padding: 4px; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ─── Form ─── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 0.8rem; color: var(--text-secondary); font-weight: 500; }
input, select, textarea {
  background: var(--bg-tertiary); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius);
  padding: 9px 12px; font-size: 0.9rem; outline: none;
  font-family: inherit; transition: border-color 0.2s; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
select option { background: var(--bg-tertiary); }
textarea { resize: vertical; min-height: 70px; }

/* ─── Empty State ─── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-secondary);
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-title { font-size: 1.1rem; color: var(--text-primary); margin-bottom: 8px; }

/* ─── Abspann ─── */
.abspann-list { display: flex; flex-direction: column; gap: 4px; }
.abspann-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  transition: background 0.1s;
}
.abspann-item:hover { background: var(--bg-hover); }
.abspann-drag { cursor: grab; color: var(--text-secondary); font-size: 1rem; }
.abspann-position { color: var(--text-secondary); font-size: 0.8rem; min-width: 160px; }
.abspann-name { flex: 1; font-weight: 500; color: var(--text-primary); }
.abspann-name.empty { color: var(--text-secondary); font-style: italic; }
.abspann-category {
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}
.abspann-category-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); margin-bottom: 8px; }

/* ─── Loading ─── */
.loading { text-align: center; padding: 40px; color: var(--text-secondary); }
.spinner {
  display: inline-block; width: 24px; height: 24px;
  border: 2px solid var(--border); border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Toast ─── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px; z-index: 300;
}
.toast {
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 18px;
  font-size: 0.9rem; box-shadow: var(--shadow);
  animation: toastIn 0.2s ease;
  max-width: 320px;
}
.toast.success { border-left: 3px solid var(--s-zugesagt); }
.toast.error { border-left: 3px solid var(--s-abgesagt); }
.toast.info { border-left: 3px solid var(--gold); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── Import ─── */
.drop-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 40px; text-align: center; cursor: pointer;
  color: var(--text-secondary); transition: all 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--gold); color: var(--text-primary); background: var(--gold-dim);
}
.drop-icon { font-size: 2.5rem; margin-bottom: 8px; }

/* ─── Print ─── */
@media print {
  .sidebar, .app-header, .toolbar, td.td-actions, .no-print { display: none !important; }
  .app-layout { display: block; }
  .main-content { padding: 0; overflow: visible; }
  body { background: #fff; color: #000; }
  table { font-size: 11px; }
  thead th { background: #eee; color: #000; }
  .badge { border: 1px solid #ccc; color: #333; background: #f5f5f5; }
  tr.r-gast td { background: #e3f2fd; }
  tr.r-nominiert td { background: #ede7f6; }
  tr.r-team td { background: #e8f5e9; }
  tr.r-sponsor td { background: #fff3e0; }
  tr.r-begleitung td { background: #f5f5f5; }
}

/* ─── Mobile Bottom Nav ─── */
.mobile-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 150;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.mobile-nav-inner {
  display: flex; align-items: stretch;
}
.mobile-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 10px 4px 8px;
  color: var(--text-secondary); font-size: 0.65rem; font-weight: 500;
  cursor: pointer; border: none; background: none;
  gap: 4px; transition: color 0.15s; text-decoration: none;
  border-top: 2px solid transparent;
}
.mobile-nav-item .nav-icon { font-size: 1.2rem; }
.mobile-nav-item.active { color: var(--gold-light); border-top-color: var(--gold); }
.mobile-nav-item:hover { color: var(--text-primary); }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .mobile-nav { display: block; }
  .app-layout { padding-bottom: 64px; }
  .form-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  td.hide-mobile { display: none; }
  .header-user span#userName { display: none; }
  .toolbar { gap: 8px; }
  .toolbar .role-tabs { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 2px; }
  .toolbar > div[style*="margin-left:auto"] { margin-left: 0 !important; }
  .main-content { padding: 16px; }
  #toast-container { bottom: 74px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }
  .btn-sm { padding: 6px 10px; }
}

.settings-section { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.settings-section-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--gold); font-weight: 600; margin-bottom: 16px; }

.page { display: none; }
.page.active { display: block; }

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.section-title { font-size: 1.2rem; font-weight: 600; }
