/*
 * Visitenkarten-Dienst, Stylesheet
 *
 * Folgt dem Design-Kit von EiderForm, damit beide Werkzeuge wie ein Haus
 * wirken und nicht wie zwei Programme, die zufällig dieselbe Farbe benutzen.
 * Übernommen sind Farbwerte, Vokabular der Variablen, Maße und Bausteine.
 *
 * Zwei Regeln, ohne die es nicht dasselbe Design ist:
 *
 *   1. Nur Systemschriften. Keine Google Fonts, keine CDN, keine
 *      Schriftdatei von außen. Das ist keine Geschmacksfrage: eine fremde
 *      Schriftquelle meldet die IP jeder Besucherin an einen Dritten.
 *   2. Farben ausschließlich über die Variablen unten. Wer einen Hex-Wert
 *      direkt in eine Regel schreibt, hat ihn im dunklen Design vergessen,
 *      und das fällt erst auf, wenn es jemand benutzt.
 *
 * Mobile-first. Keine externen Requests, keine CDNs, keine Symbolschrift:
 * die Symbole liegen als Inline-SVG im Markup (siehe templates/icons.ts).
 */

:root {
  /* Amtsblau. Diese eine Farbe trägt das ganze Erscheinungsbild.
     Kein zweiter Akzent, kein Verlauf. Grün, Rot und Bernstein kommen
     ausschließlich als Zustand vor, nie als Gestaltung. */
  --primary: rgb(0, 104, 177);
  --primary-dark: #00517f;
  --primary-soft: #e8f2fa;
  /* Fläche und Schrift getrennt: --primary füllt, --accent schreibt.
     Im dunklen Design hellt nur --accent auf. */
  --accent: var(--primary);
  --accent-ink: #ffffff;
  /* Eigene Tokens statt der Hex-Werte, die drüben direkt in den Regeln
     stehen, sonst fehlten sie im dunklen Design. */
  --primary-hover: var(--primary-dark);
  --red-ink: #ffffff;
  /* Flächen, die in beiden Designs weiß bleiben MÜSSEN: ein QR-Code braucht
     den Kontrast zum Scannen, und ein Wappen auf dunklem Grund ist entweder
     unlesbar oder nicht mehr das Wappen. */
  --paper: #ffffff;
  /* Mittlere Stufe der Passwortstärke. Die Anzeige ist eine Messskala,
     keine Gestaltung, deshalb darf sie eine eigene Farbe führen. */
  --strength-mid: #a8b400;

  --ink: #1a2530;
  --ink-soft: #5b6b7a;
  --line: #dde5ec;

  --bg: #f2f6f9;
  --surface: #ffffff;
  --surface-2: #fbfdfe;
  --surface-3: #eef1f4;

  --green: #1e7f43;
  --green-bg: #e8f6ee;
  --red: #b3362c;
  --red-bg: #fbeceb;
  --amber-ink: #8a5c00;
  --amber-bg: #fdf4e3;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 42, 67, 0.06), 0 8px 24px rgba(16, 42, 67, 0.08);

  /* Deckend statt transparent: WCAG 2.1 SC 1.4.11 verlangt 3:1 für den
     Fokusindikator. Amtsblau deckend erreicht 5,4:1. */
  --focus-ring: #0068b1;
  --backdrop: rgba(13, 35, 54, 0.55);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;

  /* Abzeichenfarben, immer als Paar aus Fläche und Schrift setzen. */
  --chip-blue-bg: #e7f0fb;
  --chip-blue-ink: #3556b0;
  --chip-teal-bg: #e2f4f2;
  --chip-teal-ink: #0f766e;
  --chip-violet-bg: #efe9fb;
  --chip-violet-ink: #6b3fbf;
  --chip-grey-bg: #eef1f4;
  --chip-grey-ink: #475569;
}

/*
 * Dunkles Design.
 *
 * Zweimal derselbe Satz Werte, und das ist Absicht: die Attributform gilt,
 * sobald jemand umgeschaltet hat, die Medienabfrage greift ohne JavaScript.
 * CSS kann einen Wertesatz nicht an zwei Bedingungen hängen, ohne ihn zu
 * wiederholen, beide Blöcke werden deshalb aus derselben Quelle erzeugt und
 * können nicht auseinanderlaufen.
 */
[data-theme="dark"] {
  --primary-dark: #3d9bd6;
  --primary-soft: rgba(61, 155, 214, 0.14);
  --accent: #58aede;
  --primary-hover: #1b7dc4;
  --red-ink: #14100f;

  --ink: #e7edf3;
  --ink-soft: #97a8b7;
  --line: #2b3946;

  --bg: #0f161d;
  --surface: #182230;
  --surface-2: #1d2a3a;
  --surface-3: #243244;

  --green: #4ec97f;
  --green-bg: rgba(46, 160, 92, 0.16);
  --red: #ef8078;
  --red-bg: rgba(211, 84, 74, 0.16);
  --amber-ink: #e0b566;
  --amber-bg: rgba(201, 138, 27, 0.16);

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
  --focus-ring: #58aede;
  --backdrop: rgba(2, 8, 14, 0.68);

  --chip-blue-bg: rgba(84, 120, 214, 0.18);
  --chip-blue-ink: #9cb2ea;
  --chip-teal-bg: rgba(20, 160, 150, 0.16);
  --chip-teal-ink: #63c9c0;
  --chip-violet-bg: rgba(148, 108, 230, 0.18);
  --chip-violet-ink: #bda2ec;
  --chip-grey-bg: rgba(148, 163, 184, 0.16);
  --chip-grey-ink: #aebccb;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary-dark: #3d9bd6;
    --primary-soft: rgba(61, 155, 214, 0.14);
    --accent: #58aede;
    --primary-hover: #1b7dc4;
    --red-ink: #14100f;

    --ink: #e7edf3;
    --ink-soft: #97a8b7;
    --line: #2b3946;

    --bg: #0f161d;
    --surface: #182230;
    --surface-2: #1d2a3a;
    --surface-3: #243244;

    --green: #4ec97f;
    --green-bg: rgba(46, 160, 92, 0.16);
    --red: #ef8078;
    --red-bg: rgba(211, 84, 74, 0.16);
    --amber-ink: #e0b566;
    --amber-bg: rgba(201, 138, 27, 0.16);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.35);
    --focus-ring: #58aede;
    --backdrop: rgba(2, 8, 14, 0.68);

    --chip-blue-bg: rgba(84, 120, 214, 0.18);
    --chip-blue-ink: #9cb2ea;
    --chip-teal-bg: rgba(20, 160, 150, 0.16);
    --chip-teal-ink: #63c9c0;
    --chip-violet-bg: rgba(148, 108, 230, 0.18);
    --chip-violet-ink: #bda2ec;
    --chip-grey-bg: rgba(148, 163, 184, 0.16);
    --chip-grey-ink: #aebccb;
  }
}

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.5rem;
  /* 500 entspricht dem Auftritt des Amtes, kräftig, aber nicht fett. */
  font-weight: 500;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.5rem;
}
h2 {
  font-size: 1.15rem;
}

p {
  margin: 0 0 0.85rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.1em 0.35em;
  overflow-wrap: anywhere;
}

.muted {
  color: var(--ink-soft);
}

.hint {
  color: var(--ink-soft);
  font-size: 0.87rem;
  margin: 0.4rem 0 0;
}

/* Skaliert mit der Schriftgröße des Umfelds, genau wie die Symbolschrift
   in EiderForm, die ihre Größe vom Text erbt. */
.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
}

/* --------------------------------------------------------------- Buttons */

/*
 * 44 Pixel Mindesthöhe überall (WCAG 2.1 SC 2.5.5). Anderthalb Pixel Rahmen,
 * nicht einer: eine Karte ist eine Fläche und bekommt einen Pixel, ein
 * Bedienelement lädt zum Anfassen ein und bekommt anderthalb. Das ist der
 * Grund, warum Schalter und Eingaben auf einer Karte greifbar wirken.
 *
 * Genau ein .btn-primary je Ansicht. Wenn zwei Schalter gleich wichtig
 * aussehen, ist keiner davon wichtig.
 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  min-height: 44px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease,
    transform 0.12s ease, box-shadow 0.18s ease;
}
/* Die einzige Rückmeldung, die man beim Drücken wirklich spürt. */
.btn:active {
  transform: scale(0.98);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}
.btn-secondary:hover {
  background: var(--primary-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-danger {
  background: var(--red);
  color: var(--red-ink);
}
.btn-danger:hover {
  filter: brightness(0.92);
}

.btn-danger-ghost {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}
.btn-danger-ghost:hover {
  background: var(--red-bg);
}

/* .btn-small ist der Name aus EiderForm, .btn-sm der hiesige. Beide gelten,
   damit Markup aus dem anderen Werkzeug ohne Umbenennen funktioniert. */
.btn-sm,
.btn-small {
  min-height: 36px;
  padding: 6px 14px;
  font-size: 0.88rem;
}

.btn-block {
  width: 100%;
}

/* Quadratischer Schalter für eine Handlung ohne Wort. */
.icon-btn,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease,
    transform 0.15s ease;
}
.icon-btn:hover,
.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.theme-toggle:active {
  transform: scale(0.94);
}
.icon-btn-danger:hover {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-bg);
}

/*
 * Fokus als deckender Ring, nicht als Umriss mit Abstand. Drei Pixel,
 * Amtsblau, Kontrast 5,4:1, WCAG 2.1 SC 1.4.11 verlangt mindestens 3:1.
 * Er wird nicht weggenommen, weil er stört: er stört genau die Personen
 * nicht, die ihn brauchen.
 */
.btn:focus-visible,
.icon-btn:focus-visible,
.theme-toggle:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.button-row,
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

/* Ladezustand. pointer-events: none verhindert das zweite Absenden. */
.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: var(--accent-ink);
  border-radius: 50%;
  display: none;
  animation: spin 0.7s linear infinite;
}
.btn.loading .btn-spinner {
  display: inline-block;
}
.btn.loading {
  pointer-events: none;
}
.btn-secondary .btn-spinner,
.btn-danger-ghost .btn-spinner {
  border-color: var(--focus-ring);
  border-top-color: var(--accent);
}

/* --------------------------------------------------------------- Banner */

.banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  text-align: center;
}

.banner-demo {
  background: var(--amber-bg);
  color: var(--amber-ink);
  border-bottom: 1px solid color-mix(in srgb, var(--amber-ink) 30%, transparent);
}

.alert {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  font-size: 0.94rem;
}
.alert p,
.alert ul {
  margin: 0;
}
.alert ul {
  padding-left: 1.15rem;
}
.alert-error {
  background: var(--red-bg);
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 35%, transparent);
}
.alert-success {
  background: var(--green-bg);
  color: var(--green);
  border-color: color-mix(in srgb, var(--green) 35%, transparent);
}
.alert-info {
  background: var(--surface-3);
  color: var(--ink);
  border-color: var(--line);
}

.callout {
  display: flex;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.2rem;
  font-size: 0.93rem;
}
.callout p {
  margin: 0.35rem 0 0;
}
.callout-warning {
  background: var(--amber-bg);
  color: var(--amber-ink);
}
.callout-danger {
  background: var(--red-bg);
  color: var(--red);
}

/* ------------------------------------------------------ Karten & Layout */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.panel {
  margin-bottom: 1.25rem;
}
.panel-danger {
  border-color: color-mix(in srgb, var(--red) 35%, var(--line));
}

.centered-form {
  max-width: 27rem;
  margin: 0 auto;
  padding: 2.5rem 1rem 3rem;
}

/* ------------------------------------------------- Öffentliche Profilseite */

.profile {
  max-width: 30rem;
  margin: 0 auto;
  padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom));
}

.card-head {
  text-align: center;
  padding-bottom: 0.35rem;
}

.avatar {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin: 0 auto 0.9rem;
  border: 3px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  background: var(--surface-3);
}

.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent-ink);
  background: var(--primary);
}

.person-name {
  font-size: 1.6rem;
  margin: 0 0 0.15rem;
}

.person-title {
  margin: 0;
  color: var(--ink);
  font-weight: 500;
}

.person-department {
  margin: 0.1rem 0 0;
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.contact-list {
  margin: 1.35rem 0 0;
  border-top: 1px solid var(--line);
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.8rem 0.15rem;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  min-height: 56px;
}

a.contact-row:hover {
  background: var(--surface-3);
}

.contact-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  flex: none;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--accent);
}

.contact-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.contact-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
}

.contact-value {
  overflow-wrap: anywhere;
}

.card-actions {
  margin-top: 1.35rem;
  text-align: center;
}

.public-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.public-footer a {
  color: var(--ink-soft);
}
.footer-org {
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.card-message {
  text-align: center;
}

.card-legal h2 {
  margin-top: 1.5rem;
  font-size: 1.02rem;
}

.todo {
  background: var(--amber-bg);
  color: var(--amber-ink);
  border-left: 3px solid var(--amber-ink);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
}

.back-link {
  margin-top: 1.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

/* --------------------------------------------------------- Admin-Rahmen */

/* Die drei Pixel Amtsblau unter der Kopfzeile sind das stärkste
   Wiedererkennungsmerkmal der Oberfläche. Volle Breite, keine Ausnahme. */
.admin-header {
  background: var(--surface);
  border-bottom: 3px solid var(--primary);
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-header-inner {
  max-width: 68rem;
  margin: 0 auto;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  font-weight: 650;
  color: var(--ink);
  text-decoration: none;
  margin-right: auto;
}

/*
 * Reiterleiste. Der aktive Punkt ist gefüllt, nicht unterstrichen, so steht
 * er auch dann noch, wenn die Leiste seitlich gescrollt werden muss.
 */
.tabbar,
.admin-nav {
  display: flex;
  gap: 6px;
  padding: 5px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab,
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab:hover,
.nav-link:hover {
  color: var(--accent);
}
/* Der aktive Punkt ist gefüllt, nicht unterstrichen und nicht getönt. */
.tab.active,
.nav-link.is-active {
  background: var(--primary);
  color: var(--accent-ink);
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-user {
  font-size: 0.87rem;
  color: var(--ink-soft);
}

.admin-main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.page-head p {
  margin: 0;
}

@media (min-width: 44rem) {
  h1 {
    font-size: 1.75rem;
  }
}

/* ------------------------------------------------------------- Formulare */

.form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.field > span {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--ink);
}

input[type='text'],
input[type='email'],
input[type='url'],
input[type='tel'],
input[type='password'],
input[type='search'],
input[type='file'],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  min-height: 44px;
  font: inherit;
  /* Feste Pixelgröße, kein rem: alles unter 16px löst auf iOS beim Antippen
     automatisches Zoomen aus, und danach steht die Seite schief. Das ist der
     einzige Ort im Stylesheet mit einer festen Größe. */
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.25s ease;
}

input[type='file'] {
  padding: 0.45rem 0.5rem;
}

/* Im Fokus wechselt der Rahmen auf den Akzent UND es liegt ein Ring darum.
   Beides zusammen, nicht eines von beiden. */
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

textarea {
  min-height: 7rem;
  resize: vertical;
  font-family: inherit;
  line-height: 1.5;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 1.1rem center, right 0.75rem center;
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
  padding-right: 2.25rem;
}

/* Feste Rufnummernbasis direkt vor dem Eingabefeld der Nachwahl. */
.input-prefix {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
}

.input-prefix:focus-within {
  border-color: var(--accent);
}

.prefix-text {
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  background: var(--surface-3);
  border-right: 1px solid var(--line);
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.input-prefix input {
  border: none;
  border-radius: 0;
  background: transparent;
  max-width: 7rem;
  font-variant-numeric: tabular-nums;
}

.input-prefix input:focus {
  outline: none;
}

.field-grid {
  display: grid;
  gap: 1rem;
}

.unit-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 46rem) {
  .unit-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.unit-block {
  background: var(--surface-3);
}

.unit-block legend {
  color: var(--accent);
}

@media (min-width: 40rem) {
  .field-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 1rem;
  margin: 0;
}
.fieldset legend {
  padding: 0 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.93rem;
  cursor: pointer;
}
.checkbox input {
  margin-top: 0.25rem;
  width: 1.1rem;
  height: 1.1rem;
  flex: none;
}

.photo-current {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.9rem;
}
.photo-current img {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--line);
}

/* ----------------------------------------------------------- Suchleiste */

.search-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.25rem;
  position: relative;
}
.search-bar input {
  flex: 1 1 14rem;
  padding-left: 2.5rem;
}
.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-soft);
  pointer-events: none;
  display: flex;
}

/* -------------------------------------------------------------- Tabelle */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}

.table th,
.table td {
  text-align: left;
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  background: var(--surface-3);
  white-space: nowrap;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.row-inactive {
  opacity: 0.62;
}

.cell-person {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.mini-avatar {
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: var(--accent-ink);
}
.mini-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.mini-initials {
  font-size: 0.8rem;
  font-weight: 600;
}

.cell-person-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.cell-name {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}
.cell-name:hover {
  color: var(--accent);
}
.cell-sub {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.cell-actions {
  white-space: nowrap;
}
.inline-form {
  display: inline;
}

/*
 * Zwei Sorten Abzeichen, und der Unterschied ist inhaltlich:
 *
 *   .tag / .badge   rund und laut, für den EINEN Hauptzustand einer Zeile
 *   .fbadge         eckig und leise, für Eigenschaften, von denen mehrere
 *                   nebeneinander stehen
 *
 * Die Doppelnamen sind Absicht: .tag und .fbadge sind die Namen aus
 * EiderForm, .badge der hiesige. Beide gelten, damit Markup aus dem anderen
 * Werkzeug ohne Umbenennen funktioniert.
 */
.tag,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}
.tag-yes,
.badge-active {
  background: var(--green-bg);
  color: var(--green);
}
.tag-no {
  background: var(--red-bg);
  color: var(--red);
}
.badge-inactive {
  background: var(--surface-3);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

.fbadge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 7px;
  font-size: 0.74rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: default;
}
.fbadge-blau {
  background: var(--chip-blue-bg);
  color: var(--chip-blue-ink);
}
.fbadge-warn {
  background: var(--amber-bg);
  color: var(--amber-ink);
}
.fbadge-aus {
  background: var(--surface-3);
  color: var(--ink-soft);
}
.fbadge-grau {
  background: var(--chip-grey-bg);
  color: var(--chip-grey-ink);
}

@media (max-width: 52rem) {
  .hide-sm {
    display: none;
  }
}

.empty-state {
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 2.5rem 1.25rem;
  text-align: center;
  color: var(--ink-soft);
}
.empty-state .icon {
  width: 2.4rem;
  height: 2.4rem;
  margin-bottom: 0.5rem;
}

/* ------------------------------------------------------------ QR & Infos */

.qr-preview {
  display: flex;
  justify-content: center;
  padding: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}
.qr-preview img {
  width: 220px;
  height: 220px;
  display: block;
}

.info-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.4rem 1.25rem;
  margin: 0 0 1rem;
  font-size: 0.92rem;
}
.info-list dt {
  color: var(--ink-soft);
}
.info-list dd {
  margin: 0;
}

.file-list,
.rule-list {
  margin: 0.5rem 0 0;
  padding-left: 1.15rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.details {
  margin-top: 1rem;
  font-size: 0.92rem;
}
.details summary {
  cursor: pointer;
  font-weight: 600;
}

/* ------------------------------------------------------- Passwort-Stärke */

.strength {
  margin-top: -0.35rem;
}

.strength-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  overflow: hidden;
}
.strength-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--red);
  transition: width 0.2s ease, background-color 0.2s ease;
}

.strength[data-level='2'] .strength-bar span {
  background: var(--amber-ink);
}
.strength[data-level='3'] .strength-bar span {
  background: var(--strength-mid);
}
.strength[data-level='4'] .strength-bar span {
  background: var(--green);
}

.strength-label {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.strength-rules {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  font-size: 0.84rem;
  color: var(--ink-soft);
  display: grid;
  gap: 0.15rem;
}
.strength-rules li::before {
  content: '✕ ';
  color: var(--red);
}
.strength-rules li.ok::before {
  content: '✓ ';
  color: var(--green);
}

/* -------------------------------------------------------------- Stepper */

.stepper {
  display: flex;
  gap: 0.4rem;
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  font-size: 0.83rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--ink-soft);
  flex: 1;
  min-width: 0;
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-weight: 600;
}

.step-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.step.is-current {
  color: var(--accent);
}
.step.is-current .step-number {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--accent-ink);
}
.step.is-done .step-number {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}

/* Nicht verhandelbar. WCAG 2.1 SC 2.3.3, für Menschen mit vestibulären
   Beschwerden ist Bewegung körperlich unangenehm. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* -------------------------------------------------------- Bereichs-vCards */

/*
 * Logo statt Portrait: unbeschnitten und mit erhaltenem Seitenverhältnis.
 * Ein Wortmarken-Logo ist breit und würde im runden Avatar der Personenseite
 * bis zur Unkenntlichkeit zugeschnitten.
 */
.team-logo {
  display: block;
  max-width: min(260px, 100%);
  max-height: 120px;
  width: auto;
  height: auto;
  margin: 0 auto 0.9rem;
  object-fit: contain;
}

.mini-logo img {
  object-fit: contain;
  background: var(--paper);
}

.logo-preview {
  max-width: 180px;
  max-height: 96px;
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  padding: 0.4rem;
}

/* ------------------------------------------------------- Rollen & Anträge */

.nav-count {
  display: inline-block;
  min-width: 1.35em;
  padding: 0.05em 0.4em;
  margin-left: 0.3em;
  border-radius: 999px;
  background: var(--primary);
  color: var(--accent-ink);
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.5;
}

.badge-role-admin {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
}
.badge-role-editor {
  background: var(--surface-3);
  color: var(--ink);
  border: 1px solid var(--line);
}
.badge-role-staff {
  background: var(--surface-3);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}

/* Startpasswort gross und eindeutig lesbar, es wird nur einmal gezeigt. */
.start-password code {
  display: inline-block;
  margin: 0.4rem 0;
  padding: 0.5rem 0.9rem;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  background: var(--surface);
  border: 1px solid var(--line);
  user-select: all;
}

.diff-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}
.diff-table th,
.diff-table td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.diff-table th {
  color: var(--ink-soft);
  font-weight: 600;
  width: 12rem;
}
.diff-old {
  color: var(--ink-soft);
  text-decoration: line-through;
}
.diff-new {
  color: var(--ink);
  font-weight: 600;
}
.diff-row-changed {
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

/* ================================================================== Import */

/*
 * Vorschau des EiderForm-Imports. Die Statusfarben unterscheiden bewusst
 * zwischen "entsteht neu", "ändert etwas" und "unklar", beim Überfliegen
 * einer langen Liste ist genau das die Frage.
 */
.badge-import-new {
  background: var(--green-bg);
  color: var(--green);
}
.badge-import-update {
  background: var(--primary-soft);
  color: var(--accent);
  border: 1px solid var(--accent);
}
.badge-import-unclear {
  background: var(--amber-bg);
  color: var(--amber-ink);
}

.import-pick {
  width: 5.5rem;
  text-align: center;
}

/* Die Auswahl fuellt ihre Spalte, damit lange Bezeichnungen lesbar bleiben. */
.import-map {
  width: 100%;
  min-width: 11rem;
}

.import-details {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  line-height: 1.5;
}
.import-details li {
  margin-bottom: 0.15rem;
}
.import-details li:last-child {
  margin-bottom: 0;
}
.import-note {
  color: var(--amber-ink);
}
.import-skip {
  color: var(--ink-soft);
}
.import-match {
  color: var(--ink-soft);
}

/* ============================================================== Wellenmotiv */

/*
 * Der Verlauf liegt als fester Hintergrund hinter der gesamten Seite. Dadurch
 * laufen die Bänder seitlich an der Visitenkarte vorbei und darunter weiter,
 * statt über ihr abzuschneiden.
 *
 * position: fixed statt absolute: beim Scrollen längerer Profile bleibt der
 * Verlauf stehen, die Karte wandert darüber. Das wirkt ruhiger, als wenn das
 * Motiv mitscrollt und unten ausgeht.
 */
.wave-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.wave-bg-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* Wortmarke oben links im dunklen Feld, wie auf dem Briefkopf. */
.public .wordmark {
  display: block;
  max-width: 30rem;
  margin: 0 auto;
  padding: 1.15rem 1.25rem 0;
  color: var(--paper);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.profile-with-wave {
  max-width: 30rem;
  margin: 0 auto;
  padding: 1.1rem 1rem calc(2rem + env(safe-area-inset-bottom));
}

/* Die Karte hebt sich vom Verlauf ab, statt darin unterzugehen. */
.profile-with-wave .card {
  box-shadow: 0 2px 6px rgba(4, 32, 62, 0.18), 0 18px 40px rgba(4, 32, 62, 0.22);
}

/* Fusszeile steht auf hellem Grund unterhalb des Verlaufs. */
.profile-with-wave .public-footer {
  color: var(--ink-soft);
}

/* Schmales Band als oberer Abschluss der Verwaltung. */
.wave-strip {
  display: block;
  width: 100%;
  height: 6px;
}

@media (min-width: 44rem) {
  .public .wordmark {
    font-size: 1.1rem;
    padding-left: 1rem;
  }
}

/* ---------------------------------------------------- Impressum & Datenschutz */

.legal-lead {
  font-size: 1.02rem;
  color: var(--ink);
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--line);
}

.legal-value {
  margin: 0 0 0.9rem;
}

/*
 * Fehlende Pflichtangabe deutlich markieren. Eine Datenschutzerklärung mit
 * stillen Lücken sieht vollständig aus und ist es nicht, die Lücke muss
 * beim Lesen auffallen.
 */
.card-legal ul {
  margin: 0 0 0.9rem;
  padding-left: 1.2rem;
}
.card-legal li {
  margin-bottom: 0.25rem;
}


/* ------------------------------------------------------------- Fußzeile */

.site-footer {
  margin-top: auto;
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}
.footer-inner {
  max-width: 68rem;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  align-items: center;
  justify-content: space-between;
  color: var(--ink-soft);
}
.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}
.footer-links a {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 4px 0;
}
.footer-links a:hover,
.footer-links a:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

/* Die Fußzeile sitzt unten, auch wenn die Seite kurz ist. */
body.admin {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/*
 * min-width: 0 ist hier kein Detail, sondern der Unterschied zwischen einer
 * Seite, die passt, und einer, die sich quer scrollen lässt: die automatische
 * Mindestbreite eines Flex-Elements ist der Inhalt, und die seitlich
 * scrollbare Reiterleiste schiebt sie sonst über die Fensterbreite hinaus.
 */
body.admin > * {
  min-width: 0;
}
body.admin .admin-main {
  flex: 1;
  width: 100%;
}

/* In der gestapelten Ansicht dürfen die Schalter umbrechen. */
@media (max-width: 640px) {
  .stack-table .cell-actions {
    flex-wrap: wrap;
    white-space: normal;
  }
}

/* ==================================================== Bausteine aus EiderForm

   Ergänzt, damit beide Werkzeuge dieselben Bausteine haben. Die Klassennamen
   sind die von drüben, damit sich Markup zwischen den Anwendungen bewegen
   lässt, ohne umbenannt zu werden.
   ========================================================================= */

/* Sprungmarke. Erstes fokussierbares Element der Seite, sichtbar nur beim
   Tastaturfokus. WCAG 2.1 SC 2.4.1, Pflicht, nicht Gestaltung. */
.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 0 0 10px 10px;
  background: var(--primary);
  color: var(--accent-ink);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: 0;
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Nur für Screenreader. Nicht display:none, das nähme auch das Vorlesen weg. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Hinweiskasten im Formularfluss, in der Leitfarbe statt in Warnfarbe. */
.info-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--primary-soft);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 0.95rem;
}
.info-note .icon {
  color: var(--accent);
  margin-top: 2px;
}

/* Kennzahlen. Große Zahl in der Leitfarbe, Beschriftung darunter. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 22px;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent);
}
.stat-yes .stat-value {
  color: var(--green);
}
.stat-no .stat-value {
  color: var(--red);
}
.stat-label {
  color: var(--ink-soft);
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------------------- Dialoge */

/*
 * window.alert und window.confirm kommen nicht vor: beide sehen nach
 * Betriebssystem aus statt nach Amt, blockieren alles und lassen sich nicht
 * beschriften. Stattdessen dieser Baustein, bedient von assets/ui.js.
 */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  background: var(--backdrop);
  backdrop-filter: blur(3px);
  animation: fade-in 0.18s ease both;
}
.modal-backdrop.ui-leave {
  opacity: 0;
  transition: opacity 0.15s ease;
}
.ui-dialog {
  width: 100%;
  max-width: 400px;
  margin: auto;
  text-align: center;
  animation: pop-in 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.ui-dialog-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--accent);
  font-size: 1.5rem;
}
.ui-dialog-icon-danger {
  background: var(--red-bg);
  color: var(--red);
}
.ui-dialog-title {
  font-size: 1.15rem;
  margin: 0 0 6px;
}
.ui-dialog-message {
  margin: 0 0 6px;
  color: var(--ink-soft);
  font-size: 0.95rem;
  white-space: pre-line;
}
.ui-dialog-btns {
  justify-content: center;
  margin-top: 18px;
}

/* Kurzmeldung unten rechts. Nicht anklickbar, verschwindet von selbst. */
.ui-toast-wrap {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.ui-toast {
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 340px;
  padding: 11px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  font-weight: 600;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.ui-toast-show {
  opacity: 1;
  transform: none;
}
.ui-toast-ok .icon {
  color: var(--green);
}
.ui-toast-error .icon {
  color: var(--red);
}
.ui-toast-info .icon {
  color: var(--accent);
}

/* ------------------------------------------------------------ Bewegungen */

/*
 * Genau vier Bewegungen im ganzen Haus. In einer Verwaltungsanwendung sitzt
 * jemand acht Stunden davor, und was beim ersten Mal charmant ist, ist beim
 * fünfzigsten Mal im Weg.
 */
.fade-in {
  animation: fade-in 0.45s ease both;
}
@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* ------------------------------------------------------------- Responsiv */

@media (max-width: 860px) {
  .card {
    padding: 24px 20px;
  }
}

@media (max-width: 640px) {
  .card {
    padding: 20px 16px;
    border-radius: 12px;
  }
  .tabbar,
  .admin-nav {
    position: sticky;
    top: 8px;
    z-index: 10;
    box-shadow: var(--shadow);
  }
  .tab,
  .nav-link {
    padding: 9px 12px;
    font-size: 0.88rem;
  }
  .admin-header-inner {
    padding: 10px 14px;
  }
  .stat-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .stat-card {
    padding: 10px 12px;
    border-radius: 12px;
  }
  .stat-value {
    font-size: 1.4rem;
  }
  .stat-label {
    font-size: 0.74rem;
  }
  .button-row,
  .btn-row {
    flex-direction: column;
    align-items: stretch;
  }
  .button-row .btn,
  .btn-row .btn {
    width: 100%;
  }
  .ui-dialog-btns {
    flex-direction: column-reverse;
  }

  /*
   * Tabellen werden zu gestapelten Karten. Die Spaltenüberschrift wandert
   * über data-label vor den Wert, sonst steht dort eine Kolonne aus Werten
   * ohne Bedeutung.
   */
  .stack-table thead {
    display: none;
  }
  .stack-table,
  .stack-table tbody,
  .stack-table tr,
  .stack-table td {
    display: block;
    width: 100%;
  }
  .stack-table tr {
    margin-bottom: 12px;
    padding: 6px 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
  }
  .stack-table td {
    display: flex;
    gap: 12px;
    align-items: baseline;
    padding: 6px 14px;
    border: 0;
  }
  .stack-table td[data-label]::before {
    content: attr(data-label);
    flex: 0 0 38%;
    max-width: 38%;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
  }
}

@media (max-width: 380px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .stat-card {
    flex-direction: row;
    align-items: baseline;
    gap: 10px;
  }
}
