:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #7b8794;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --border: #e4e7eb;
  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --error-bg: #fef2f2;
  --error-text: #991b1b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.brand { font-weight: 700; font-size: 1.25rem; color: var(--primary); text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 1rem; }
.site-nav a { color: var(--text); text-decoration: none; }
.site-nav a:hover { color: var(--primary); }

.container { max-width: 880px; margin: 2rem auto; padding: 0 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card.narrow { max-width: 420px; margin-inline: auto; }

h1 { margin-top: 0; }

label { display: block; margin-bottom: 1rem; font-weight: 600; }
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
}

.btn {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.link-btn { background: none; border: none; color: var(--text); cursor: pointer; font: inherit; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
@media (max-width: 540px) { .form-grid { grid-template-columns: 1fr; } }

.row { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1.25rem; }
.row input { width: auto; flex: 1 1 180px; margin-top: 0; }
.inline { display: inline; }
.check-row { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.check-row input { width: auto; margin: 0; }

table.data { width: 100%; border-collapse: collapse; margin-top: 1rem; }
table.data th, table.data td { text-align: left; padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
.actions { display: flex; gap: 0.4rem; }

.status-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  margin-bottom: 0.3rem;
}
.status-badge.status-pending { background: #fef3c7; color: #92400e; }
.status-badge.status-registered { background: #d1fae5; color: #065f46; }
.status-badge.status-cancelled { background: #e5e7eb; color: #4b5563; }

.muted { color: var(--muted); }
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin: 1rem 0; }
.alert.success { background: var(--success-bg); color: var(--success-text); }
.alert.error { background: var(--error-bg); color: var(--error-text); }

.event-link { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }

.site-footer { text-align: center; color: var(--muted); padding: 2rem 0; }
.event-page { position: relative; }
.event-logo {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  max-height: 64px;
  max-width: 160px;
  object-fit: contain;
}
.event-page h1 { padding-right: 180px; }
.logo-thumb { max-height: 40px; max-width: 100px; object-fit: contain; vertical-align: middle; }
.logo-preview { margin: 0.25rem 0 0.75rem; }
.logo-preview img { max-height: 80px; max-width: 240px; object-fit: contain; border: 1px solid var(--border); border-radius: 6px; padding: 4px; background: #fff; }
.inline-check { font-weight: 400; }
.inline-check input { display: inline; width: auto; margin-right: 0.4rem; }
.event-page .event-date { color: var(--muted); font-weight: 600; }
/* Honeypot: aus dem sichtbaren/fokussierbaren Fluss entfernen, aber im DOM lassen */
.hp-field { position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }
.event-section { margin: 1.25rem 0; }
.event-section h2 { font-size: 1.05rem; margin-bottom: 0.35rem; color: var(--primary-dark); }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md img { max-width: 100%; height: auto; }
.md pre { background: #f3f4f6; padding: 0.75rem; border-radius: 6px; overflow: auto; }
.md code { background: #f3f4f6; padding: 0.1rem 0.3rem; border-radius: 4px; }
.md blockquote { margin: 0.5rem 0; padding-left: 0.9rem; border-left: 3px solid var(--border); color: var(--muted); }
.event-page hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
label em { font-weight: 400; color: var(--muted); font-size: 0.85em; }

/* ---- App-Shell mit linker Sidebar (authentifizierter Bereich) ---- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: #111827;
  color: #e5e7eb;
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  gap: 1.25rem;
}
.sidebar .brand { color: #fff; font-size: 1.3rem; font-weight: 700; text-decoration: none; }

.tenant-switch { display: flex; flex-direction: column; gap: 0.4rem; }
.switch-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: #9ca3af; }
.switch-select {
  width: 100%;
  margin-top: 0;
  padding: 0.5rem;
  background: #1f2937;
  color: #fff;
  border: 1px solid #374151;
  border-radius: 6px;
}
.tenant-current { font-weight: 600; color: #fff; }

.side-nav { display: flex; flex-direction: column; gap: 0.25rem; }
.side-nav a {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  color: #d1d5db;
  text-decoration: none;
}
.side-nav a:hover { background: #1f2937; color: #fff; }
.side-nav a.active { background: var(--primary); color: #fff; }

.sidebar-foot { margin-top: auto; border-top: 1px solid #374151; padding-top: 1rem; }
.user-email { font-size: 0.8rem; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-foot .link-btn { color: #d1d5db; padding: 0; margin-top: 0.35rem; }
.sidebar-foot .link-btn:hover { color: #fff; text-decoration: underline; }

.app-main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  padding: 0.85rem 1.5rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.context-label { font-weight: 600; color: var(--text); }
.app-main .container { margin: 1.5rem auto; width: 100%; }

@media (max-width: 720px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: auto; flex-basis: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .sidebar-foot { margin-top: 0; border-top: none; padding-top: 0; }
}
