/* All-in-One Generator – Web-Oberfläche. Zuerst fürs Handy gebaut. */

:root {
  --flaeche: #EDF0F2;
  --karte: #FFFFFF;
  --eingabe: #F6F8F9;
  --tinte: #16222A;
  --leise: #5E6B74;
  --linie: #D3DAE0;
  --petrol: #0F6E78;
  --petrol-dunkel: #0B5861;
  --petrol-hell: #E0EFF0;
  --auf-petrol: #FFFFFF;
  --warn: #A85808;
  --gut: #2C7A4B;
  --leiste: #14252B;
  --leiste-aktiv: #234048;
  --leiste-text: #DCE6E9;
  --leiste-leise: #8FA3AA;
  --ueberblick: #14323A;
  --schrift: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  /* DIN-Schrift: die Schrift von Kennzeichen und Verkehrsschildern */
  --din: Bahnschrift, "DIN Alternate", "DIN Next", "Segoe UI", system-ui, sans-serif;
  --radius: 10px;
  --rand: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --flaeche: #12181C;
    --karte: #1B2329;
    --eingabe: #141B20;
    --tinte: #E6ECEF;
    --leise: #9AA7B0;
    --linie: #2E3A42;
    --petrol: #2AA3AF;
    --petrol-dunkel: #38B5C1;
    --petrol-hell: #1D3238;
    --auf-petrol: #06181B;
    --warn: #E3A548;
    --gut: #5CC08A;
    --leiste: #0C1215;
    --leiste-aktiv: #1B2D33;
    --ueberblick: #17343C;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--leiste); }
body {
  margin: 0;
  background: var(--flaeche);
  color: var(--tinte);
  font: 16px/1.45 var(--schrift);
}
[hidden] { display: none !important; }
.unsichtbar { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-appearance: none; appearance: none; }
button, a, label, input, select, textarea { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--petrol); outline-offset: 2px; }
.leise { color: var(--leise); }
h1, h2 { font-family: var(--din); letter-spacing: 0; }

/* ---------- Knöpfe ---------- */
.knopf {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 600;
  background: transparent;
}
.knopf.haupt { background: var(--petrol); color: var(--auf-petrol); }
.knopf.haupt:active { background: var(--petrol-dunkel); }
.knopf.umrandet, .umrandet { border: 1px solid var(--linie); background: var(--karte); font-weight: 500; }
.knopf.gross { min-height: 52px; font-size: 17px; }
.knopf.breit { width: 100%; }
.knopf.klein { min-height: 40px; padding: 0 14px; font-size: 15px; }
a.knopf { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; color: var(--tinte); }
.knopf.gefahr { color: var(--warn); }
.knopf:disabled { opacity: .45; cursor: default; }
@media (hover: hover) {
  .knopf.haupt:hover { background: var(--petrol-dunkel); }
  .knopf.umrandet:hover { background: var(--petrol-hell); }
}

/* ---------- Anmeldung ---------- */
.anmelden {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top) + var(--rand)) var(--rand) calc(env(safe-area-inset-bottom) + var(--rand));
  background: var(--leiste);
}
.anmelde-karte {
  width: 100%;
  max-width: 380px;
  background: var(--karte);
  border-radius: 14px;
  padding: 28px 24px;
}
.anmelde-karte h1 { margin: 0; font-size: 26px; }
.anmelde-karte p.leise { margin: 0 0 22px; }
.anmelde-karte label { display: block; font-size: 14px; color: var(--leise); margin-bottom: 4px; }
.anmelde-karte input { margin-bottom: 6px; }
.fehlertext { color: var(--warn); min-height: 1.4em; margin: 4px 0 12px; font-size: 14px; }

/* ---------- Grundaufbau Handy ---------- */
.app { min-height: 100vh; min-height: 100dvh; background: var(--flaeche); }
.leiste {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--leiste);
  color: var(--leiste-text);
  padding: calc(env(safe-area-inset-top) + 10px) calc(env(safe-area-inset-right) + var(--rand)) 0 calc(env(safe-area-inset-left) + var(--rand));
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}
.marke { display: flex; align-items: baseline; min-width: 0; }
.marke-by { margin-left: 8px; white-space: nowrap; }
.marke { margin-right: 10px; }
/* Kleine iPhones (SE, 5s): Kopf kompakter */
@media (max-width: 374px) {
  .marke-by { display: none; }
  .marke-name { font-size: 16px; }
  .wahl button { font-size: 15px; padding: 0 4px; }
  #hl-weiter { min-width: 116px; }
}
.marke-name { font: 700 17px/1.2 var(--din); color: #fff; white-space: nowrap; }
.marke-by { font-size: 13px; color: var(--leiste-leise); }
.menue-knopf {
  background: transparent;
  border: 1px solid #3B5760;
  border-radius: 8px;
  color: var(--leiste-text);
  min-height: 40px;
  padding: 0 14px;
}
.schritte {
  grid-column: 1 / -1;
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 0 12px;
  scrollbar-width: none;
}
.schritte::-webkit-scrollbar { display: none; }
.schritt {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: var(--leiste-text);
  font-size: 15px;
}
.schritt + .schritt { margin-left: 6px; }
.schritt > * + * { margin-left: 8px; }
.schritt .nr { color: var(--leiste-leise); font-variant-numeric: tabular-nums; }
.schritt.aktiv { background: var(--leiste-aktiv); color: #fff; }
.schritt .status { display: inline-grid; place-items: center; height: 20px; min-width: 16px; font-size: 13px; line-height: 1; font-weight: 700; }
.schritt .status.offen { color: #E3A548; }
.schritt .status.fertig { color: #5CC08A; }
.menue {
  grid-column: 1 / -1;
  display: none;
  flex-direction: column;
  padding: 0 0 14px;
}
.menue.auf { display: flex; }
.menue button + button { margin-top: 4px; }
.menue button {
  text-align: left;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--leiste-text);
  padding: 0 12px;
}
.menue button.aktiv { background: var(--leiste-aktiv); }
.menue .umrandet { border: 1px solid #3B5760; background: transparent; text-align: center; margin-top: 6px; }

.haupt-bereich {
  padding: 18px calc(env(safe-area-inset-right) + var(--rand)) calc(96px + env(safe-area-inset-bottom)) calc(env(safe-area-inset-left) + var(--rand));
  max-width: 760px; margin: 0 auto;
}
.kopf h1 { font-size: 26px; margin: 0; line-height: 1.15; }
.kopf p { margin: 4px 0 16px; font-size: 15px; }

/* ---------- Karten und Felder ---------- */
.karte {
  background: var(--karte);
  border-radius: var(--radius);
  padding: 16px 16px 18px;
  margin-bottom: 12px;
}
.karte h2 { font-size: 18px; margin: 0 0 2px; }
.karte > p.leise { margin: 0 0 4px; font-size: 14px; }
.raster { display: grid; grid-template-columns: 1fr; gap: 12px 14px; margin-top: 10px; }
.feld { display: flex; flex-direction: column; min-width: 0; }
.feld > label, .feld > .etikett { font-size: 14px; color: var(--leise); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--linie);
  border-radius: 8px;
  background: var(--eingabe);
  color: var(--tinte);
  font: 16px var(--schrift); /* 16px: iOS zoomt sonst beim Antippen */
}
input, select, textarea { -webkit-appearance: none; appearance: none; }
select {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235E6B74' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}
input[type="date"] { display: block; line-height: 24px; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
textarea { min-height: 88px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--petrol); box-shadow: 0 0 0 3px var(--petrol-hell); }
input:disabled { opacity: .5; }
.fehlt input, .fehlt select, input.fehlt { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.hinweis { font-size: 13px; margin-top: 4px; min-height: 0; }
.hinweis.warn { color: var(--warn); }
.hinweis.gut { color: var(--gut); }
.info { font-size: 14px; color: var(--leise); margin: 12px 0 0; }
.info.stark { color: var(--tinte); font-weight: 600; }

/* Auswahl mit mehreren Möglichkeiten */
.wahl {
  display: grid;
  grid-template-columns: repeat(var(--spalten, 2), minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--linie);
  border-radius: 10px;
  background: var(--eingabe);
}
.wahl button {
  min-width: 0;
  line-height: 1.2;
  -webkit-hyphens: auto;
  hyphens: auto;
  overflow-wrap: break-word;
  min-height: 42px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--tinte);
  padding: 0 6px;
}
.wahl button[aria-pressed="true"] { background: var(--petrol); color: var(--auf-petrol); font-weight: 600; }

/* Schalter */
.schalter { display: flex; align-items: center; min-height: 44px; cursor: pointer; position: relative; }
.schalter .bahn { margin-right: 12px; }
.schalter input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.schalter .bahn {
  flex: 0 0 auto;
  width: 46px; height: 28px;
  border-radius: 14px;
  background: var(--linie);
  position: relative;
  transition: background .15s;
}
.schalter .bahn::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 22px; height: 22px; border-radius: 50%;
  background: #fff;
  transition: transform .15s;
}
.schalter input:checked + .bahn { background: var(--petrol); }
.schalter input:checked + .bahn::after { transform: translateX(18px); }
.schalter input:focus-visible + .bahn { outline: 2px solid var(--petrol); outline-offset: 2px; }

/* Adresssuche */
.adresse { position: relative; }
.adresse input[type="search"] { border-color: var(--petrol); }
.vorschlaege {
  margin-top: 4px;
  border: 1px solid var(--linie);
  border-radius: 8px;
  background: var(--karte);
  overflow: hidden;
}
.vorschlaege button {
  display: block; width: 100%; text-align: left;
  min-height: 46px; padding: 8px 12px;
  border: 0; border-bottom: 1px solid var(--linie);
  background: transparent;
}
.vorschlaege button:last-child { border-bottom: 0; }
.vorschlaege button:active { background: var(--petrol-hell); }
.quelle { font-size: 12px; color: var(--leise); margin-top: 4px; }
.quelle.warn { color: var(--warn); }

/* Unterschrift und Logo */
.unterschrift-bild {
  min-height: 76px;
  margin-top: 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--linie);
  display: grid; place-items: center;
  padding: 8px;
  color: #7C868D; font-size: 14px; text-align: center;
}
.unterschrift-bild img { max-width: 100%; max-height: 64px; }
.logo-zeile { display: flex; flex-wrap: wrap; align-items: center; margin: 0 -10px -10px 0; }
.logo-zeile > * { margin: 0 10px 10px 0; }
.logo-zeile img { max-height: 40px; max-width: 160px; background: #fff; border-radius: 4px; padding: 2px; }
.datei-knopf { position: relative; overflow: hidden; display: inline-flex; align-items: center; }
.datei-knopf input { position: absolute; top: 0; right: 0; bottom: 0; left: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; min-height: 0; font-size: 16px; }

/* ---------- Fuß mit Zurück/Weiter ---------- */
.fuss { display: none; justify-content: space-between; margin-top: 8px; }

/* ---------- Überblick ---------- */
.ueberblick {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  max-height: 86vh;
  max-height: 86dvh;
  -webkit-overflow-scrolling: touch;
  overflow-y: auto;
  background: var(--flaeche);
  border-radius: 16px 16px 0 0;
  padding: 16px var(--rand) calc(16px + env(safe-area-inset-bottom));
  transform: translateY(105%);
  transition: transform .22s ease-out;
  box-shadow: 0 -6px 30px rgba(0, 0, 0, .25);
}
.ueberblick.auf { transform: translateY(0); }
.blatt-zu {
  display: block; margin: -6px 0 10px auto; min-height: 40px; padding: 0 14px;
  border: 1px solid var(--linie); border-radius: 8px; background: var(--karte);
}
.ub-karte { background: var(--ueberblick); color: #C9D8DC; border-radius: 12px; padding: 18px 20px; }
.ub-karte p { margin: 0; }
.ub-typ { font: 700 18px/1.25 var(--din); color: #fff; }
.ub-zeile { margin-top: 4px !important; }
.ub-karte hr { border: 0; border-top: 1px solid #2D4C55; margin: 14px 0 10px; }
.ub-preis { font: 700 34px/1.1 var(--din); color: #fff; font-variant-numeric: tabular-nums; }
.ub-details { margin-top: 6px !important; font-size: 14px; white-space: pre-line; }
#erstellen { margin-top: 14px; }
.offen { margin-top: 14px; }
.offen h3 { font-size: 15px; margin: 0 0 4px; }
.offen button {
  display: block; width: 100%; text-align: left;
  min-height: 40px; border: 0; background: transparent;
  color: var(--warn); padding: 0 8px; border-radius: 6px;
}
.offen .alles-da { color: var(--gut); margin: 0; }
.meldung { font-size: 14px; margin: 12px 0 0; color: var(--gut); }
.meldung.warn { color: var(--warn); }
#zwischen { margin-top: 12px; }
.schleier { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 35; background: rgba(0, 0, 0, .4); }

.handy-leiste {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  padding: 10px calc(env(safe-area-inset-right) + var(--rand)) calc(10px + env(safe-area-inset-bottom)) calc(env(safe-area-inset-left) + var(--rand));
  background: var(--karte);
  border-top: 1px solid var(--linie);
}
.blatt-knopf {
  flex: 1;
  display: flex; flex-direction: column; align-items: flex-start;
  border: 0; background: transparent; padding: 0; min-height: 44px; justify-content: center;
}
.hl-preis { font: 700 20px/1.15 var(--din); font-variant-numeric: tabular-nums; }
.hl-offen { font-size: 13px; color: var(--warn); }
.hl-offen.gut { color: var(--gut); }
#hl-weiter { min-width: 140px; margin-left: 10px; }
/* Während getippt wird, verdeckt die untere Leiste sonst die Felder */
body.tippt .handy-leiste { display: none; }

/* ---------- Vorgänge und Ergebnis ---------- */
.suchfeld { margin-bottom: 12px; background: var(--karte); }
.vorgang h2 { font-size: 16px; font-family: var(--schrift); font-weight: 700; margin: 0; }
.vorgang p { margin: 2px 0 0; font-size: 14px; }
.knopfreihe { display: flex; flex-wrap: wrap; margin: 12px -8px -8px 0; }
.knopfreihe > * { margin: 0 8px 8px 0; }
.pdf-liste { margin-top: 10px; display: grid; gap: 6px; }
.pdf-zeile {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 12px; border: 1px solid var(--linie); border-radius: 8px;
}
.pdf-zeile .name { grid-column: 1 / -1; font-weight: 600; }
@media (min-width: 560px) {
  .pdf-zeile { grid-template-columns: 1fr auto auto; align-items: center; }
  .pdf-zeile .name { grid-column: auto; }
}
details summary { cursor: pointer; min-height: 40px; display: flex; align-items: center; color: var(--petrol); font-weight: 600; }
.pdf-zeile.sammel { border-color: var(--petrol); background: var(--petrol-hell); }
.leer { color: var(--leise); padding: 24px 4px; }

/* ---------- Große Bildschirme ---------- */
@media (min-width: 980px) {
  .app {
    display: grid;
    grid-template-columns: 236px minmax(0, 1fr) 330px;
    min-height: 100vh;
  }
  .leiste {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; align-items: stretch;
    padding: 22px 12px 16px;
  }
  .marke { flex-direction: column; align-items: flex-start; padding: 0 8px 18px; }
  .marke-by { margin-left: 0; }
  .marke-name { white-space: normal; font-size: 18px; }
  .menue-knopf { display: none; }
  .schritte { flex-direction: column; overflow: visible; padding: 0; flex: 1; }
  .schritt + .schritt { margin-left: 0; margin-top: 2px; }
  .schritt { width: 100%; justify-content: flex-start; }
  .schritt .status { margin-left: auto; }
  .menue { display: flex; padding: 0; }
  .haupt-bereich { padding: 24px 28px 28px; max-width: 900px; width: 100%; }
  .raster { grid-template-columns: 1fr 1fr; }
  .raster .breit { grid-column: 1 / -1; }
  .fuss { display: flex; }
  .ueberblick {
    position: sticky; top: 0; height: 100vh; max-height: none;
    transform: none; box-shadow: none; border-radius: 0;
    padding: 22px 20px 20px 0;
    background: transparent;
  }
  .handy-leiste, .schleier, .blatt-zu { display: none !important; }
  .haupt-bereich { padding-bottom: 28px; }
}
@media (min-width: 560px) and (max-width: 979px) {
  .raster { grid-template-columns: 1fr 1fr; }
  .raster .breit { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
