: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; }

.logo-footer { height: 14px; width: auto; margin: 0; }

.center { text-align: center; }

.theme-toggle {
  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; }

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: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 { color: var(--red-text); font-size: 14px; }

.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;
}
.visitor-actions-buttons { display: flex; gap: 6px; }
.btn-row { display: flex; gap: 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;
  }

  /* 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; }

.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);
}

.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;
}
