:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --surface: #ffffff;
  --input-border: #cbd5e1;
  --btn-bg: #0f172a;
  --btn-text: #ffffff;

  --green-bg: #f0fdf4;
  --green-line: #bbf7d0;
  --green-text: #166534;
  --amber-bg: #fffbeb;
  --amber-line: #fde68a;
  --amber-text: #92400e;
  --amber-text-alt: #ca8a04;
  --red-text: #dc2626;
  --red-bg: #fef2f2;
  --red-line: #fecaca;
  --live-green: #22c55e;
  --qr-bg: #f1f5f9;
  --empty-text: #94a3b8;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f1f5f9;
    --muted: #94a3b8;
    --line: #334155;
    --bg: #0b1220;
    --surface: #1e293b;
    --input-border: #475569;
    --btn-bg: #e2e8f0;
    --btn-text: #0f172a;

    --green-bg: #052e17;
    --green-line: #14532d;
    --green-text: #4ade80;
    --amber-bg: #431407;
    --amber-line: #78350f;
    --amber-text: #fbbf24;
    --amber-text-alt: #eab308;
    --red-text: #f87171;
    --red-bg: #450a0a;
    --red-line: #7f1d1d;
    --live-green: #22c55e;
    --qr-bg: #1e293b;
    --empty-text: #64748b;
  }
}

/* Manuelles Umschalten (überschreibt die Systemeinstellung) */
:root[data-theme="dark"] {
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --line: #334155;
  --bg: #0b1220;
  --surface: #1e293b;
  --input-border: #475569;
  --btn-bg: #e2e8f0;
  --btn-text: #0f172a;

  --green-bg: #052e17;
  --green-line: #14532d;
  --green-text: #4ade80;
  --amber-bg: #431407;
  --amber-line: #78350f;
  --amber-text: #fbbf24;
  --amber-text-alt: #eab308;
  --red-text: #f87171;
  --red-bg: #450a0a;
  --red-line: #7f1d1d;
  --live-green: #22c55e;
  --qr-bg: #1e293b;
  --empty-text: #64748b;
}
:root[data-theme="light"] {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --surface: #ffffff;
  --input-border: #cbd5e1;
  --btn-bg: #0f172a;
  --btn-text: #ffffff;

  --green-bg: #f0fdf4;
  --green-line: #bbf7d0;
  --green-text: #166534;
  --amber-bg: #fffbeb;
  --amber-line: #fde68a;
  --amber-text: #92400e;
  --amber-text-alt: #ca8a04;
  --red-text: #dc2626;
  --red-bg: #fef2f2;
  --red-line: #fecaca;
  --live-green: #22c55e;
  --qr-bg: #f1f5f9;
  --empty-text: #94a3b8;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { text-decoration: none; }

.page {
  max-width: 480px;
  margin: 0 auto;
  padding: 48px 16px;
}

.page-wide {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 16px;
}

.logo { display: block; width: 50%; height: auto; margin: 0 auto 20px; }

/* Zwei Logo-Dateien (hell: #005480, dunkel: #ffffff) statt Farbfilter,
   damit die Farbe exakt stimmt. Je nach Modus wird eine ausgeblendet. */
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .logo-light { display: none; }
  .logo-dark { display: block; }
}
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }
:root[data-theme="light"] .logo-light { display: block; }
:root[data-theme="light"] .logo-dark { display: none; }

.center { text-align: center; }

.theme-toggle, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--input-border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 15px;
  padding: 0;
}

h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; }
p.lead { color: var(--muted); margin: 0 0 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
}

.card + .card { margin-top: 12px; }

/* Card-Reihen (Stat-Tiles, Visitor-insights-Auswertungen): nutzen bereits
   `gap` für den Abstand, die generische .card+.card-Regel oben würde die
   Karten ab der zweiten zusätzlich um 12px nach unten verschieben — bei
   unterschiedlich hohem Inhalt (z.B. "Source" mit 2 Zeilen neben "Top boat
   models" mit 6 Zeilen) verhindert das den gleichmäßigen `align-items:
   stretch`-Effekt des Flex-Containers und lässt die Karten sichtbar
   ungleich hoch wirken. */
#zentrale-event-status-invitations > .card,
#zentrale-event-status-visitors > .card,
#zentrale-event-status-insights > .card {
  margin-top: 0;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}

input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  /* Mind. 16px, sonst zoomt iOS Safari beim Fokussieren automatisch hinein. */
  font-size: 16px;
  font-family: inherit;
  margin-bottom: 16px;
}

input.input-error, select.input-error, textarea.input-error {
  border-color: var(--red-text);
  background: var(--red-bg);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

input:disabled, select:disabled, textarea:disabled {
  background: var(--bg);
  color: var(--muted);
  cursor: not-allowed;
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* <button> elements size their content box from an internal control-height
   metric rather than padding + line-height, so they render taller than a
   same-padding input/select unless an explicit height forces parity. */
.btn-input-height {
  height: 41px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

button, .btn {
  -webkit-appearance: none;
  appearance: none;
  display: inline-block;
  background: var(--btn-bg);
  color: var(--btn-text);
  border: none;
  border-radius: 8px;
  padding: 6px 18px;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
}

button:disabled { opacity: 0.5; cursor: default; }
button.full, .btn.full { width: 100%; }

.tabs { display: flex; border: 1px solid var(--input-border); border-radius: 8px; overflow: hidden; margin-bottom: 24px; }
.tabs a { flex: 1; text-align: center; padding: 10px; text-decoration: none; font-size: 14px; font-weight: 500; color: var(--ink); background: var(--surface); }
.tabs a.active { background: var(--btn-bg); color: var(--btn-text); }

.msg { padding: 12px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.msg.success { background: var(--green-bg); border: 1px solid var(--green-line); color: var(--green-text); }
.msg.warning { background: var(--amber-bg); border: 1px solid var(--amber-line); color: var(--amber-text); }
.msg.error { background: var(--red-bg); border: 1px solid var(--red-line); color: var(--red-text); }

.section-label {
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
  margin: 0 0 12px;
}

.visitor-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.visitor-card-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.visitor-card .name { font-weight: 500; }
.visitor-card .meta { font-size: 14px; color: var(--muted); }
.contact-link { color: inherit; }
.contact-link:hover { color: var(--ink); }

.wait-time-green { color: var(--green-text); font-weight: 600; }
.wait-time-yellow { color: var(--amber-text-alt); font-weight: 600; }
.wait-time-red { color: var(--red-text); font-weight: 600; }

.visitor-info { min-width: 0; }
.contact-row {
  display: block;
}
.visitor-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
/* Button-Group: mehrere Buttons, die nebeneinander stehen, wachsen zu einer
   verbundenen Einheit zusammen statt einzelne Pillen mit Abstand zu sein
   (gleiches Prinzip wie Bootstraps .btn-group) — kein Abstand dazwischen,
   nur die äußeren Ecken gerundet, Ränder überlappen sich zu einer Linie. */
.visitor-actions-buttons, .btn-row { display: flex; }
/* .grow steht neben .btn-row in vielen Zeilen (User/Events/Invitations/...)
   und soll den verfügbaren Platz füllen — ohne min-width:0 kann ein Flex-Item
   aber nicht unter die Breite seines Inhalts schrumpfen (CSS-Default), lange
   E-Mails/Titel drücken die Buttons dadurch aus dem sichtbaren Bereich
   (v.a. auf schmalen Handy-Bildschirmen). */
.grow { flex: 1 1 0%; min-width: 0; overflow-wrap: break-word; }
.btn-row { flex-shrink: 0; }
.visitor-actions-buttons > button,
.visitor-actions-buttons > .btn,
.btn-row > button,
.btn-row > .btn {
  border-width: 1px;
  border-style: solid;
  border-radius: 0;
  margin-left: -1px;
  position: relative;
}
/* Buttons ohne eigenen Farb-Modifier (z.B. "Save") haben normalerweise gar
   keinen Rand — damit sie sich trotzdem sauber einreihen, bekommen sie
   einen Rand in der eigenen Hintergrundfarbe (im Boxmodell vorhanden, aber
   unsichtbar). :not(...) lässt Modifier-Klassen wie .btn-secondary/
   .btn-danger-subtle unangetastet, die bringen ihre eigene border-color
   schon mit. */
.visitor-actions-buttons > button:not(.btn-secondary):not(.btn-danger-subtle):not(.btn-warning):not(.btn-success-subtle),
.btn-row > button:not(.btn-secondary):not(.btn-danger-subtle):not(.btn-warning):not(.btn-success-subtle) {
  border-color: var(--btn-bg);
}
.visitor-actions-buttons > button:hover,
.visitor-actions-buttons > .btn:hover,
.btn-row > button:hover,
.btn-row > .btn:hover {
  z-index: 1;
}
.visitor-actions-buttons > button:first-child,
.visitor-actions-buttons > .btn:first-child,
.btn-row > button:first-child,
.btn-row > .btn:first-child {
  margin-left: 0;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}
.visitor-actions-buttons > button:last-child,
.visitor-actions-buttons > .btn:last-child,
.btn-row > button:last-child,
.btn-row > .btn:last-child {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
}

@media (max-width: 600px) {
  .visitor-card-summary {
    flex-direction: column;
    align-items: stretch;
  }
  .visitor-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
  }
  .visitor-actions > .meta {
    text-align: left;
  }
  .visitor-actions-buttons {
    justify-content: flex-end;
  }

  /* .user-row-summary (User/Events/Invitations/...) hält Titel und
     Button-Gruppe nebeneinander in einer Zeile — bei mehreren textreichen
     Buttons (z.B. "Pre-registration"/"Manage"/"Archive") beansprucht die
     Gruppe allein schon fast die gesamte Zeilenbreite und drückt den Titel
     trotz .grow/min-width:0 auf 0px zusammen. Wie bei .visitor-card-summary
     bricht die Zeile daher mobil auf zwei Zeilen um: Titel oben, Buttons
     darunter über die volle Breite. */
  .user-row-summary {
    flex-direction: column;
    align-items: stretch;
  }

  /* Seiten-Header mit Titel/Beschreibung + einzelnem Action-Button
     (z.B. "+ New event") nebeneinander — der Button ist wegen der
     `button { width: 100% }`-Regel oben bereits volle Breite, was ihn in
     dieser space-between-Zeile ohne Umbruch über den Rand hinaus schiebt. */
  .page-header-row {
    flex-direction: column;
    align-items: stretch !important;
  }

  /* Ein einzelnes Eingabefeld + Button nebeneinander (z.B. "Registration
     link" + "Copy") soll auf einer Zeile bleiben, statt umzubrechen — die
     `button { width: 100% }`-Regel unten würde den Button sonst über die
     gesamte Zeilenbreite aufblasen und das Feld daneben auf 0px drücken. */
  .input-with-button > button,
  .input-with-button > .btn {
    width: auto;
  }

  /* Buttons nutzen mobil die volle Breite, außer sie stehen als Gruppe
     nebeneinander (dort teilen sie sich die Zeile gleichmäßig auf). */
  button, .btn {
    width: 100%;
  }
  .visitor-actions-buttons button,
  .visitor-actions-buttons .btn,
  .btn-row button,
  .btn-row .btn {
    width: auto;
    flex: 1;
  }
}

.flag {
  font-size: 16px;
  line-height: 1;
  vertical-align: middle;
  position: relative;
  top: -0.15em;
  cursor: pointer;
}

.flag-tooltip {
  position: fixed;
  background: var(--ink);
  color: var(--bg);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: none;
  z-index: 300;
  white-space: nowrap;
}

.empty { color: var(--empty-text); font-size: 14px; }

.app-header {
  margin-bottom: 24px;
}
.app-header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.app-header-top h1 {
  margin: 0;
}
.app-header-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.header-select {
  flex: 1 1 140px;
  min-width: 0;
  width: auto;
  margin: 0;
  padding: 6px 10px;
  font-size: 14px;
}
.app-header-icons {
  display: flex;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--live-green);
}
.live-dot.offline { background: var(--red-text); }

#qr-reader { border-radius: 8px; overflow: hidden; background: var(--qr-bg); }

.user-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.user-row-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.user-row-summary .name { font-weight: 500; }
.user-row-summary .meta { font-size: 14px; color: var(--muted); }
.user-row-edit {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.brand-badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
  margin: 2px 4px 2px 0;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
}
.brand-badge.main {
  background: var(--green-bg);
  border: 1px solid var(--green-line);
  color: var(--green-text);
}
.brand-badge.secondary {
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  color: var(--amber-text);
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--input-border);
}
summary.btn-secondary {
  display: inline-block;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
summary.btn-secondary::-webkit-details-marker { display: none; }

.collapsible > summary {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  cursor: pointer;
  list-style: none;
}
.collapsible > summary::-webkit-details-marker { display: none; }
.collapsible > summary .chevron {
  margin-left: auto;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.collapsible[open] > summary .chevron { transform: rotate(180deg); }
.btn-secondary.active {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-color: var(--btn-bg);
}
.btn-danger { background: var(--red-text); color: #fff; }
.btn-danger-subtle {
  background: var(--red-bg);
  color: var(--red-text);
  border: 1px solid var(--red-line);
}
.btn-warning {
  background: var(--amber-bg);
  color: var(--amber-text);
  border: 1px solid var(--amber-line);
}
.btn-success-subtle {
  background: var(--green-bg);
  color: var(--green-text);
  border: 1px solid var(--green-line);
}

.note-edit {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.note-edit textarea { margin-bottom: 8px; }

.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 20;
  margin-top: -12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  max-height: 220px;
  overflow-y: auto;
}
.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--bg); }
.autocomplete-item.active { background: var(--green-bg); color: var(--green-text); }
.autocomplete-item .name { font-size: 14px; font-weight: 500; }
.autocomplete-item .meta { font-size: 12px; color: var(--muted); }

.assign-to-list {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 16px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}
.overlay-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
}
