:root {
  --meer: #0b2a3c;
  --meer-hell: #14435e;
  --gold: #d4a017;
  --papier: #fbf6ea;
  --tinte: #1f2a30;
  --grau: #5b7083;
  --orange: #d9822b;
  --rot: #c0392b;
  --rand: #d9cfb8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--tinte);
  overscroll-behavior: none;
}

h1, h2, h3 { margin: 0 0 4px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; margin-top: 12px; }
.untertitel { color: var(--grau); margin: 0 0 12px; }
.fehler { color: var(--rot); font-weight: 600; }
.laden { color: var(--meer-hell); }

/* Ansichten */
.ansicht { position: fixed; inset: 0; }
.ansicht--hafen {
  background: var(--meer);
  overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 24px) 16px 24px;
}
.ansicht--karte { display: flex; flex-direction: column; }
.karte-papier {
  background: var(--papier);
  border-radius: 16px;
  padding: 20px;
  max-width: 440px;
  margin: 0 auto;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.logo { font-size: 48px; text-align: center; }
#anmelde-formular h1, #anmelde-formular .untertitel { text-align: center; }

.hafen-kopf { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.plz-zeile { display: flex; gap: 8px; margin: 8px 0; }
.plz-zeile input { margin: 0; font-size: 20px; letter-spacing: 2px; }
.gebietsliste, .leadliste, .mannschaftsliste { list-style: none; margin: 8px 0; padding: 0; }
.gebietsliste li, .leadliste li, .mannschaftsliste li {
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 8px;
}
.gebietsliste button {
  width: 100%;
  border: 0;
  background: none;
  padding: 12px;
  text-align: left;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.gebietsliste small, .leadliste small, .mannschaftsliste small { color: var(--grau); }

/* Kopfleiste */
.kopf {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: var(--meer);
  color: var(--papier);
  z-index: 1000;
}
.kopf__gebiet {
  border: 0;
  background: none;
  color: var(--papier);
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  padding: 0;
}
.kopf__statistik {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  font-size: 13px;
  overflow-x: auto;
  white-space: pre;
}
.kopf__knopf {
  background: var(--meer-hell);
  color: var(--papier);
  border: 0;
  border-radius: 8px;
  font-size: 20px;
  width: 40px;
  height: 36px;
  flex: none;
}

#karte { flex: 1; }

/* Hausnummern-Marker */
.haus-icon { background: none; border: 0; }
.haus {
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 7px;
  min-width: 26px;
  justify-content: center;
  border-radius: 12px;
  border: 2px solid #fff;
  background: var(--meer-hell);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.haus--benannt { background: #2f6f8f; }
.haus--nicht_angetroffen { background: var(--grau); }
.haus--anforderungen { background: var(--orange); opacity: .8; }
.haus--kein_interesse { background: var(--rot); opacity: .8; }
.haus--lead { background: var(--gold); color: var(--tinte); }
.haus--sperre { background: #3b0d0d; color: #fff; border: 2px solid var(--rot); }

/* Hinweis-Toast */
.hinweis {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 60px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(11, 42, 60, .92);
  color: var(--papier);
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 14px;
  z-index: 1100;
  max-width: 90vw;
  text-align: center;
}

/* Standort-Knopf */
.kompass {
  position: fixed;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom) + 24px);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  background: var(--meer);
  font-size: 26px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
  z-index: 1000;
}

/* Umschalter Karte / Luftbild – über dem Kompass */
.ansicht-knopf {
  position: fixed;
  right: 14px;
  bottom: calc(env(safe-area-inset-bottom) + 90px);
  width: 54px;
  height: 54px;
  border-radius: 50%;
  border: 0;
  background: var(--papier);
  font-size: 26px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
  z-index: 1000;
}
.ansicht-knopf:disabled { opacity: .6; }
/* Auf dem Luftbild brauchen die Hausnummern mehr Kontrast */
.karte--luftbild .haus { box-shadow: 0 0 0 2px rgba(255, 255, 255, .85), 0 1px 4px rgba(0, 0, 0, .6); }

/* Formular-Blatt */
.blatt {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--papier);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, .3);
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 16px);
  z-index: 1200;
}
.blatt__griff {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--rand);
  margin: 0 auto 8px;
}
.blatt__kopf {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.blatt__adresse { font-weight: 700; font-size: 17px; }
.blatt__gruss { color: var(--meer-hell); font-style: italic; margin-top: 2px; }
.blatt__schliessen {
  border: 0;
  background: none;
  font-size: 20px;
  padding: 4px 8px;
}
.blatt__aktionen {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
/* Speichern steht immer allein in der letzten Zeile, rechts; Nebenaktionen davor */
.blatt__aktionen > span { flex: 1 0 auto; }
.blatt__aktionen > [type="submit"] { margin-left: auto; }
.blatt__aktionen > .knopf--leise { padding: 8px 6px; font-size: 14px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0;
}
input, textarea, select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  font-size: 16px; /* verhindert Zoom auf iOS */
  border: 1px solid var(--rand);
  border-radius: 8px;
  background: #fff;
  font-family: inherit;
  color: var(--tinte);
}
.feldgruppe { display: flex; gap: 8px; }
.feldgruppe > label { flex: 1; min-width: 0; }
.feldgruppe > label.schmal { flex: 0 0 80px; }

/* Status-Knöpfe */
.status-wahl {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0;
}
.status-knopf {
  border: 2px solid var(--rand);
  background: #fff;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: left;
  font-size: 14px;
  line-height: 1.25;
  color: var(--tinte);
}
.status-knopf small { display: block; color: var(--grau); font-size: 12px; }
.status-knopf[aria-pressed="true"] { border-color: var(--status-farbe); background: var(--status-farbe); color: #fff; }
.status-knopf[aria-pressed="true"] small { color: rgba(255, 255, 255, .85); }

.lead {
  border: 2px solid var(--gold);
  border-radius: 10px;
  padding: 4px 12px 8px;
  margin: 0 0 8px;
}
.lead legend { font-weight: 700; padding: 0 4px; }
.lead-info { font-size: 12px; color: var(--grau); margin: 4px 0 0; }
.lead-gesperrt {
  background: #fff6dc;
  border: 1px solid var(--gold);
  border-radius: 10px;
  padding: 10px;
  font-size: 14px;
}
.energie__titel { font-weight: 700; margin-top: 8px; }

.besuche { font-size: 13px; color: var(--grau); }
.besuche ul { margin: 4px 0 0; padding-left: 18px; }

.knopf {
  display: inline-block;
  border: 1px solid var(--rand);
  background: #fff;
  color: var(--tinte);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  margin: 0;
}
.knopf:disabled { opacity: .6; }
.knopf--haupt { background: var(--meer); color: var(--papier); border-color: var(--meer); }
.knopf--leise { background: none; color: var(--rot); border-color: transparent; }
.knopf--breit { display: block; width: 100%; margin-top: 8px; }
.knopf--klein { padding: 6px 10px; font-size: 13px; }

/* Dialoge */
.dialog {
  border: 0;
  border-radius: 14px;
  background: var(--papier);
  width: min(92vw, 420px);
  max-height: 90vh;
  padding: 16px 18px;
  color: var(--tinte);
}
.dialog--gross { width: min(96vw, 560px); }
.dialog::backdrop { background: rgba(0, 0, 0, .5); }
.dialog__aktionen { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }

.leadliste li { padding: 10px 12px; }
.leadliste .lead-kopf { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.leadliste a { color: var(--meer-hell); }

/* Kapitänskajüte */
.reiter {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  margin: 8px 0 12px;
  border-bottom: 2px solid var(--rand);
}
.reiter button {
  border: 0;
  background: none;
  padding: 6px 2px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--grau);
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reiter button span { display: block; font-size: 18px; }
.reiter button[aria-selected="true"] { color: var(--meer); border-bottom-color: var(--gold); }

.kajuete-liste { list-style: none; margin: 8px 0; padding: 0; }
.kajuete-liste > li {
  border: 1px solid var(--rand);
  border-radius: 10px;
  background: #fff;
  margin-bottom: 8px;
  padding: 10px 12px;
}
.kajuete-liste > li.eingerueckt { margin-left: calc(min(var(--tiefe, 0), 4) * 16px); }
.kajuete-liste > li.inaktiv { opacity: .55; }
.kajuete-liste small { color: var(--grau); }
.zeile-kopf { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.zeile-aktionen { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: flex-end; }
.zeile-aktionen > label { flex: 1 1 140px; margin: 0; font-size: 13px; }
.zeile-aktionen select { margin: 2px 0 0; padding: 6px; font-size: 14px; }
.zeile-formular { margin-top: 8px; }
.zeile-formular label { font-size: 13px; }
.kajuete-formular { border-top: 1px solid var(--rand); margin-top: 8px; }
input[type="color"] { padding: 2px; height: 40px; }

.tarifliste { list-style: none; margin: 8px 0 0; padding: 0; font-size: 14px; }
.tarifliste li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px dashed var(--rand);
}
.tarifliste li.inaktiv { opacity: .55; }
.tarif-neu { border-top: 1px dashed var(--rand); padding-top: 4px; }
.tarif-neu .feldgruppe > label.schmal { flex-basis: 130px; }

/* Akademie */
.balken { height: 6px; background: var(--rand); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.balken > div { height: 100%; background: var(--gold); border-radius: 3px; transition: width .3s; }
.pflicht-hinweis { background: #fff6dc; border: 1px solid var(--gold); border-radius: 8px; padding: 8px 10px; font-size: 14px; margin: 8px 0; }
.erfolg { color: #2e7d32; font-weight: 600; }
.abzeichen { font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 6px; white-space: nowrap; }
.abzeichen--pflicht { background: var(--rot); color: #fff; }
.zurueck { border: 0; background: none; color: var(--meer-hell); font-size: 14px; font-weight: 600; padding: 4px 0; margin-bottom: 4px; cursor: pointer; }

.modulliste, .lektionsliste, .crewliste { list-style: none; margin: 8px 0; padding: 0; }
.modulliste li, .crewliste li { border: 1px solid var(--rand); border-radius: 10px; background: #fff; margin-bottom: 8px; }
.crewliste li { padding: 10px 12px; }
.modulliste button { width: 100%; border: 0; background: none; padding: 12px; text-align: left; font-size: 15px; color: var(--tinte); cursor: pointer; }
.modulliste small, .crewliste small { color: var(--grau); display: block; }
.modul-kopf { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.lektionsliste li button {
  width: 100%; border: 1px solid var(--rand); border-radius: 8px; background: #fff;
  padding: 10px 12px; margin-bottom: 6px; text-align: left; font-size: 15px; color: var(--tinte); cursor: pointer;
}

.lektion { line-height: 1.55; font-size: 15px; }
.lektion h3 { font-size: 18px; margin: 16px 0 6px; }
.lektion h4 { font-size: 16px; margin: 12px 0 4px; }
.lektion p { margin: 8px 0; }
.lektion ul, .lektion ol { padding-left: 22px; margin: 6px 0; }
.lektion li { margin: 3px 0; }
.lektion img { max-width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--rand); margin: 6px 0; }
.lektion a { color: var(--meer-hell); }
.lektion code, .format-hilfe code, .datei-zeile code { background: #efe7d3; border-radius: 4px; padding: 1px 4px; font-size: 13px; }
.hinweis-box { background: #e8f1f6; border-left: 4px solid var(--meer-hell); border-radius: 6px; padding: 8px 12px; margin: 10px 0; }
.video { position: relative; aspect-ratio: 16 / 9; max-width: 100%; margin: 8px 0; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 8px; }
.downloads { margin-top: 12px; }
.downloads small { color: var(--grau); font-weight: 400; }
.lektion-aktionen { display: flex; gap: 8px; margin: 14px 0 4px; }
.lektion-aktionen .knopf:nth-child(2) { flex: 1; }

.quizfrage { border: 1px solid var(--rand); border-radius: 10px; background: #fff; margin: 0 0 10px; padding: 8px 12px; }
.quizfrage legend { font-weight: 700; padding: 0 4px; }
.quizfrage--richtig { border-color: #2e7d32; }
.quizfrage--falsch { border-color: var(--rot); background: #fdecea; }
.quizantwort { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin: 6px 0; font-size: 15px; }
.quizantwort input { width: auto; margin: 3px 0 0; }
.quiz-ergebnis { border: 2px solid var(--orange); border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: #fff; }
.quiz-ergebnis--bestanden { border-color: var(--gold); background: #fff6dc; }

/* Akademie-Verwaltung */
.editor { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.45; }
.format-hilfe { font-size: 12px; color: var(--grau); margin: 0 0 8px; line-height: 1.9; }
.format-hilfe summary { cursor: pointer; font-weight: 600; }
.pflicht-auswahl { border: 1px solid var(--rand); border-radius: 8px; padding: 6px 10px; margin: 8px 0; }
.pflicht-auswahl legend { font-size: 13px; font-weight: 700; }
.haken { display: flex; gap: 8px; align-items: center; font-weight: 400; font-size: 14px; margin: 4px 0; }
.haken input { width: auto; margin: 0; }
.dateien { border-top: 1px dashed var(--rand); padding-top: 6px; margin: 6px 0; }
.datei-zeile { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 13px; padding: 4px 0; }
.datei-zeile small { display: block; color: var(--grau); }
.datei-knopf { cursor: pointer; }
.antwort-zeile { display: flex; gap: 8px; align-items: center; }
.antwort-zeile input[type="checkbox"] { width: auto; margin: 0; }
.antwort-zeile input:not([type="checkbox"]) { flex: 1; min-width: 0; width: auto; margin: 4px 0; }
.antwort-zeile .knopf { flex: 0 0 auto; }
.vorschau { border: 1px dashed var(--meer-hell); border-radius: 8px; padding: 8px 12px; margin-top: 8px; background: #fff; }

/* Pipeline */
/* display nur im geöffneten Zustand setzen – sonst bleibt der geschlossene Dialog sichtbar */
.dialog--voll { width: min(98vw, 1200px); max-width: 98vw; height: 92vh; max-height: 92vh; flex-direction: column; }
.dialog--voll[open] { display: flex; }
.dialog--voll > #pipeline-inhalt { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.pipeline-filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.pipeline-filter input[type="search"] { flex: 1 1 200px; margin: 0; }
.pipeline-filter select { flex: 0 1 200px; margin: 0; }
.pipeline-filter .haken { margin: 0; }

.board {
  flex: 1;
  min-height: 260px;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 8px;
}
.spalte {
  flex: 1 0 min(80vw, 180px);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  background: #f3ecdb;
  border-radius: 10px;
  border-top: 5px solid var(--stufe-farbe);
  max-height: 100%;
}
.spalte--ziel { outline: 3px dashed var(--stufe-farbe); outline-offset: -3px; }
.spalte-kopf { display: flex; justify-content: space-between; gap: 6px; padding: 8px 10px; font-weight: 700; font-size: 14px; }
.zaehler { background: var(--stufe-farbe); color: #fff; border-radius: 10px; padding: 0 8px; font-size: 12px; line-height: 20px; }
.spalte-karten { flex: 1; overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 6px; }
.spalte-karten .leer { color: var(--grau); text-align: center; margin: 8px 0; }
.lead-karte {
  display: flex; flex-direction: column; gap: 2px; text-align: left;
  border: 1px solid var(--rand); border-left: 4px solid var(--stufe-farbe);
  background: #fff; border-radius: 8px; padding: 8px 10px; font-size: 14px; color: var(--tinte); cursor: pointer;
}
.lead-karte[draggable="true"] { cursor: grab; }
.lead-karte small { color: var(--grau); font-size: 12px; }
.lead-karte .verlust { color: var(--rot); }

.lead-details { display: flex; flex-direction: column; gap: 4px; background: #fff; border: 1px solid var(--rand); border-radius: 10px; padding: 10px 12px; }
.lead-details a { color: var(--meer-hell); }
.lead-details small { color: var(--grau); }
.stufen-wahl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; margin: 8px 0; }
.stufen-knopf { margin: 0; }
.stufen-knopf input { position: absolute; opacity: 0; pointer-events: none; }
.stufen-knopf span {
  display: block; border: 2px solid var(--stufe-farbe); border-radius: 8px; padding: 8px; font-size: 13px; font-weight: 600;
  background: #fff; color: var(--tinte); cursor: pointer; text-align: center;
}
.stufen-knopf input:checked + span { background: var(--stufe-farbe); color: #fff; }
.stufen-knopf input:focus-visible + span { outline: 3px solid var(--gold); }
.stufen-abzeichen { display: inline-block; background: var(--stufe-farbe); color: #fff; border-radius: 6px; padding: 2px 8px; font-weight: 600; }
.verlauf { list-style: none; margin: 8px 0; padding: 0; font-size: 14px; }
.verlauf li { border-left: 3px solid var(--rand); padding: 4px 0 6px 10px; }
.verlauf small { color: var(--grau); }

/* Datenschutz */
.sperr-hinweis { background: #fdecea; border: 2px solid var(--rot); border-radius: 10px; padding: 10px; font-size: 14px; margin: 8px 0; }
.status-knopf:disabled { opacity: .4; }
.einwilligung { border-top: 1px dashed var(--rand); margin-top: 10px; padding-top: 6px; }
.einwilligung .haken { align-items: flex-start; }
.einwilligung .haken input { margin-top: 3px; }
.einwilligung small { color: var(--grau); font-weight: 400; line-height: 1.4; }
.qr { display: block; margin: 8px auto; width: min(220px, 60vw); height: auto; border-radius: 8px; background: #fff; padding: 6px; }
.datenschutz-kurz { padding-left: 18px; font-size: 14px; line-height: 1.5; }

/* Gebietsliste: Öffnen und Entfernen nebeneinander */
.gebietsliste li { display: flex; align-items: stretch; }
.gebietsliste .gebiet-oeffnen { flex: 1; min-width: 0; }
.gebietsliste .gebiet-entfernen {
  flex: 0 0 48px; border: 0; border-left: 1px solid var(--rand); background: none;
  font-size: 18px; cursor: pointer; border-radius: 0 10px 10px 0;
}
.gebietsliste li > small { display: block; padding: 10px 12px; }

/* Eigentümer oder Mieter */
.wohnverhaeltnis { border: 1px solid var(--rand); border-radius: 8px; padding: 6px 10px 8px; margin: 8px 0; }
.wohnverhaeltnis legend { font-size: 13px; font-weight: 700; padding: 0 4px; }
.wohnverhaeltnis legend small { color: var(--rot); font-weight: 600; }
.auswahl-zeile { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.auswahl { margin: 4px 0; }
.auswahl input { position: absolute; opacity: 0; pointer-events: none; }
.auswahl span {
  display: block; text-align: center; padding: 10px 6px; border: 2px solid var(--rand); border-radius: 10px;
  background: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.auswahl input:checked + span { border-color: var(--meer); background: var(--meer); color: var(--papier); }
.auswahl input:focus-visible + span { outline: 3px solid var(--gold); }

/* Kalender: belegte Zeiten des Beraters */
.termin-belegt { font-size: 13px; color: var(--meer-hell); background: #e8f1f6; border-radius: 6px; padding: 6px 8px; margin: -2px 0 8px; }
.termin-belegt--konflikt { color: var(--rot); background: #fdecea; font-weight: 600; }
