:root {
  --gruen: #14532d;
  --gruen-hell: #dcfce7;
  --rot: #b91c1c;
  --rot-hell: #fee2e2;
  --orange: #c2410c;
  --orange-hell: #ffedd5;
  --blau: #1d4ed8;
  --blau-hell: #dbeafe;
  --grau: #6b7280;
  --rand: #e5e7eb;
  --flaeche: #ffffff;
  --hinter: #f4f5f2;
  --text: #1f2937;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--hinter);
}
[hidden] { display: none !important; }
h1, h2 { margin: 0 0 12px; }
h2 { font-size: 1.25rem; }

/* Knöpfe */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--rand);
  background: var(--flaeche); color: var(--text); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer; min-height: 44px;
}
.btn:active { transform: translateY(1px); }
.btn.primaer { background: var(--gruen); border-color: var(--gruen); color: #fff; }
.btn.rot { background: var(--rot); border-color: var(--rot); color: #fff; }
.btn.blau { background: var(--blau); border-color: var(--blau); color: #fff; }
.btn.geist { background: transparent; }
.btn.gross { width: 100%; padding: 14px; font-size: 1.1rem; }
.btn.klein { min-height: 34px; padding: 6px 10px; font-size: .9rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* Anmeldung */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(160deg, #14532d, #052e16); }
.login-box { background: var(--flaeche); border-radius: 18px; padding: 28px 24px; width: 100%;
  max-width: 360px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.login-box h1 { font-size: 1.35rem; margin: 10px 0 20px; }
.login-logo { width: 100%; max-width: 240px; height: auto; display: block; margin: 0 auto; }
/* Auf dem dunklen Grün wären die schwarzen Linien kaum lesbar – daher kleines helles Schild */
.kopf-logo { height: 40px; width: auto; background: #fff; border-radius: 8px; padding: 2px 4px; }
.login-box input { text-align: center; font-size: 1.6rem; letter-spacing: .3em; }

/* Kopfzeile */
.kopf {
  position: sticky; top: 0; z-index: 1000; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--gruen); color: #fff; flex-wrap: wrap;
}
.kopf .titel { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.kopf .btn.geist { color: #fff; border-color: rgba(255,255,255,.4); margin-left: auto; }
.kopf .btn.geist:not([hidden]) + .btn.geist { margin-left: 0; }
#standort-knopf.an { background: #16a34a; border-color: #16a34a; }
#standort-knopf.problem { background: var(--rot); border-color: var(--rot); }

/* Funkloch-Hinweis unter der Kopfzeile */
.offline-hinweis { order: 5; width: 100%; background: #fef3c7; color: #92400e; border-radius: 8px;
  padding: 8px 10px; font-weight: 700; font-size: .92rem; text-align: center; }

/* Kartenfilter */
.legende .filter { border: 2px solid var(--rand); background: #fff; border-radius: 999px; padding: 6px 12px;
  font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 38px; }
.legende .filter.aus { opacity: .45; text-decoration: line-through; }
.legende .filter.schnell { border-style: dashed; color: var(--gruen); }
.legende .filter .punkt, .legende .filter .farbpunkt { margin: 0; }

/* Fahrer-Standort auf der Karte */
.lkw { display: flex; align-items: center; gap: 4px; white-space: nowrap; filter: drop-shadow(0 1px 3px rgba(0,0,0,.4)); }
.lkw .symbol { width: 34px; height: 34px; border-radius: 50%; background: #fff; border: 3px solid; display: grid;
  place-items: center; font-size: 18px; }
.lkw .name { color: #fff; font-weight: 700; font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.lkw.alt { opacity: .5; }
.tabs { display: flex; gap: 4px; order: 3; width: 100%; overflow-x: auto; }
.tabs button {
  flex: 1; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 8px;
  padding: 10px 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.tabs button.aktiv { background: #fff; color: var(--gruen); }
@media (min-width: 760px) {
  .tabs { order: 0; width: auto; }
  .tabs button { flex: none; padding: 8px 16px; }
}

main { max-width: 900px; margin: 0 auto; padding: 12px 12px 110px; }
.seite { display: none; }
.seite.aktiv { display: block; }

.karte { background: var(--flaeche); border-radius: var(--radius); padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 12px; }

/* Formulare */
.formular label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .92rem; margin-bottom: 12px; flex: 1; }
.formular label small { font-weight: 400; color: var(--grau); }
.formular .zeile { display: flex; gap: 12px; flex-wrap: wrap; }
.formular .zeile > label { min-width: 200px; }
.formular .zeile > label.schmal { flex: 0 0 110px; min-width: 110px; }
.formular .zeile > label.nr-feld { flex: 0 0 170px; min-width: 150px; }
.formular .nr-feld input { font-size: 1.3rem; font-weight: 800; color: var(--gruen); padding-top: 4px; padding-bottom: 4px; }
.formular label.haken { flex-direction: row; align-items: center; gap: 10px; font-size: 1rem; }
.haken input { width: 22px; height: 22px; }
input, select, textarea {
  font: inherit; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 10px;
  background: #fff; color: var(--text); width: 100%; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #16a34a; outline-offset: 1px; border-color: #16a34a; }
.knoepfe { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

.werkzeuge { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.werkzeuge input { flex: 1 1 180px; width: auto; }
.werkzeuge select { flex: 0 1 190px; width: auto; }
.info { color: var(--grau); font-size: .9rem; margin: 6px 2px 10px; }
.fehlertext { color: var(--rot); min-height: 1.4em; margin: 10px 0 0; }

/* Ergebnis nach dem Speichern */
.ergebnis { text-align: center; }
.ergebnis .gross-nr { font-size: 4rem; font-weight: 800; color: var(--gruen); line-height: 1.1; }
.ergebnis .knoepfe { justify-content: center; flex-wrap: wrap; }

/* Hinweise zur Adresse */
.geo { border-radius: 10px; padding: 10px 12px; font-size: .92rem; margin: 8px 0; }
.geo.ok, .geo.manuell { background: var(--gruen-hell); color: #14532d; }
.geo.pruefen { background: var(--orange-hell); color: var(--orange); }
.geo.fehler, .geo.offen { background: var(--rot-hell); color: var(--rot); }

/* Auftragskarten */
.auftrag { display: flex; gap: 12px; align-items: flex-start; background: var(--flaeche);
  border-radius: var(--radius); padding: 12px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border: 2px solid transparent; }
.auftrag .nr { font-size: 1.5rem; font-weight: 800; color: var(--gruen); min-width: 64px; text-align: center; }
.auftrag .inhalt { flex: 1; min-width: 0; }
.auftrag .name { font-weight: 700; font-size: 1.05rem; }
.auftrag .adresse { color: #374151; }
.auftrag .details { color: var(--grau); font-size: .9rem; }
.auftrag .notiz { background: #fef9c3; border-radius: 6px; padding: 4px 8px; margin-top: 6px; font-size: .92rem; }
.auftrag .aktionen { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.auftrag.waehlbar { cursor: pointer; user-select: none; }
.auftrag.gewaehlt { border-color: var(--gruen); background: #f0fdf4; }
.auftrag .kaestchen { width: 30px; height: 30px; border-radius: 8px; border: 2px solid #94a3b8;
  flex: none; display: grid; place-items: center; font-weight: 800; color: #fff; margin-top: 4px; }
.auftrag.gewaehlt .kaestchen { background: var(--gruen); border-color: var(--gruen); }
.auftrag.erledigt { opacity: .55; }
.auftrag.naechster { border-color: var(--blau); }

.marke { display: inline-block; font-size: .78rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-right: 4px; }
.marke.offen { background: var(--orange-hell); color: var(--orange); }
.marke.geladen { background: var(--blau-hell); color: var(--blau); }
.marke.geliefert { background: var(--gruen-hell); color: var(--gruen); }
.marke.warnung { background: var(--rot-hell); color: var(--rot); }

/* Tour */
.pos { width: 44px; height: 44px; border-radius: 50%; background: var(--blau); color: #fff; font-weight: 800;
  display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.erledigt .pos { background: var(--gruen); }
.zeit { font-weight: 700; color: var(--blau); }
.zusammenfassung { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.zusammenfassung div { flex: 1 1 90px; background: var(--hinter); border-radius: 10px; padding: 8px; text-align: center; }
.zusammenfassung b { display: block; font-size: 1.3rem; }
.tour-knoepfe { display: flex; gap: 8px; flex-wrap: wrap; }
.tour-knoepfe .btn { flex: 1 1 200px; }

/* Karten (Leaflet) */
.landkarte { height: 300px; border-radius: var(--radius); margin-bottom: 12px; background: #e5e7eb; z-index: 0; }
.landkarte.gross { height: calc(100vh - 230px); min-height: 380px; margin: 0; }
.landkarte.klein { height: 220px; }
.kartennr { background: var(--blau); color: #fff; border: 2px solid #fff; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.kartennr.offen { background: var(--orange); }
.kartennr.geliefert { background: var(--gruen); }
.kartennr.markt { background: var(--rot); border-radius: 6px; }
.legende { font-size: .9rem; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.legende .aktualisiert { margin-left: auto; color: var(--grau); font-size: .8rem; }
.punkt { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-left: 8px; }
.punkt.offen { background: var(--orange); }
.punkt.geladen { background: var(--blau); }
.punkt.geliefert { background: var(--gruen); }
.punkt.markt { background: var(--rot); border-radius: 3px; }

/* Touren-Übersicht (Verkauf) */
.fahrer-titel { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 1.1rem; }
.fahrer-titel .rechts { margin-left: auto; font-size: .95rem; color: var(--grau); }
.farbpunkt { display: inline-block; width: 16px; height: 16px; border-radius: 50%; flex: none; }
.fortschritt { height: 8px; background: var(--hinter); border-radius: 999px; overflow: hidden; margin: 10px 0 6px; }
.fortschritt div { height: 100%; border-radius: 999px; }
.stopps { list-style: none; margin: 8px 0 0; padding: 0; }
.stopps li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--rand); }
.stopps li .kreis { width: 26px; height: 26px; border-radius: 50%; color: #fff; font-weight: 800; font-size: .85rem;
  display: inline-grid; place-items: center; flex: none; }
.stopps li.erledigt { color: var(--grau); }
.stopps li.erledigt .kreis { background: var(--gruen) !important; }
.stopps li .zeitangabe { margin-left: auto; white-space: nowrap; font-size: .9rem; }

/* Leiste unten (Fahrer) */
.leiste { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); box-shadow: 0 -2px 10px rgba(0,0,0,.12); z-index: 1000; }
.leiste .btn { max-width: 900px; margin: 0 auto; display: flex; }
.vorschlaege { max-width: 900px; margin: 0 auto 8px; }
.vorschlaege .titel { font-size: .85rem; color: var(--grau); margin-bottom: 4px; }
.vorschlaege .reihe { display: flex; gap: 6px; overflow-x: auto; }
.vorschlaege button { flex: none; border: 2px dashed var(--gruen); background: #f0fdf4; color: var(--gruen);
  border-radius: 10px; padding: 6px 10px; font: inherit; font-size: .9rem; font-weight: 700; cursor: pointer; text-align: left; }
.vorschlaege button small { display: block; font-weight: 400; color: var(--grau); }

.fahrer-kopf { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }

dialog { border: 0; border-radius: 16px; padding: 20px; width: min(640px, 96vw); max-height: 92vh; }
dialog::backdrop { background: rgba(0,0,0,.45); }

/* Oben anzeigen – unten liegen beim Fahrer Vorschläge und der Aufladen-Knopf */
.meldung { position: fixed; left: 50%; top: 120px; transform: translateX(-50%); z-index: 3000;
  background: #111827; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: 92vw;
  box-shadow: 0 6px 20px rgba(0,0,0,.3); font-weight: 600; }
.meldung.fehler { background: var(--rot); }
.leer { text-align: center; color: var(--grau); padding: 30px 10px; }

/* ---------------------------------------------------------------- Stopp-Karten in der Tour */
.auftrag.stopp { flex-direction: column; align-items: stretch; gap: 6px; }
.stopp-oben { display: flex; gap: 12px; align-items: flex-start; }
.stopp-aktionen { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.stopp-aktionen .btn { min-height: 54px; font-size: 1.05rem; }
.stopp-aktionen .abladen { grid-column: 1 / -1; min-height: 44px; font-size: .95rem; color: var(--grau); }

/* ---------------------------------------------------------------- Handy */
html { -webkit-text-size-adjust: 100%; }
button, .btn, a, input, select, textarea, .auftrag.waehlbar { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.kopf { padding-top: calc(8px + env(safe-area-inset-top)); }

@media (max-width: 640px) {
  body { font-size: 17px; }
  main { padding: 10px 10px 120px; }
  .karte { padding: 14px; }

  /* Kopf: Logo, Rolle, Abmelden in einer Zeile, Reiter groß darunter */
  .kopf { gap: 8px; padding-left: 10px; padding-right: 10px; }
  .kopf-logo { height: 36px; }
  .tabs { gap: 6px; }
  .tabs button { min-height: 48px; font-size: 1rem; padding: 10px 4px; border-radius: 10px; }

  /* Knöpfe groß genug für Daumen */
  .btn { min-height: 48px; }
  .btn.klein { min-height: 44px; padding: 8px 12px; font-size: .95rem; }
  .kopf .btn.klein { min-height: 40px; }

  /* Formulare: alles untereinander, nur PLZ + Ort nebeneinander */
  .formular .zeile { gap: 10px; }
  .formular .zeile > label, .formular .zeile > label.nr-feld { flex: 1 1 100%; min-width: 0; }
  .formular .zeile > label.schmal { flex: 0 0 100px; min-width: 100px; }
  .formular .zeile:has(> label.schmal) > label:not(.schmal) { flex: 1 1 0; }
  input, select, textarea { min-height: 50px; font-size: 17px; }
  .formular .nr-feld input { font-size: 1.4rem; }
  .haken input { width: 26px; height: 26px; }
  .formular .btn.gross { min-height: 56px; }

  /* Werkzeugleisten (Suche, Filter, Nummer eintippen) */
  .werkzeuge input { flex: 1 1 100%; }
  .werkzeuge select, .werkzeuge .btn { flex: 1 1 0; }
  #schnell-form input { flex: 1 1 0; }
  #schnell-form .btn { flex: 0 0 auto; }

  /* Auftragskarten */
  .auftrag { padding: 12px; gap: 10px; }
  .auftrag .nr { min-width: 52px; font-size: 1.35rem; }
  .auftrag .kaestchen { width: 34px; height: 34px; }
  .auftrag .aktionen { display: grid; grid-template-columns: repeat(3, 1fr); }
  .auftrag .aktionen .btn { width: 100%; padding-left: 4px; padding-right: 4px; }
  .auftrag.erledigt .aktionen { grid-template-columns: 1fr; }

  /* Tour */
  .tour-knoepfe .btn { flex: 1 1 100%; min-height: 52px; }
  .landkarte { height: 240px; }
  .landkarte.gross { height: calc(100vh - 200px); min-height: 320px; }
  .zusammenfassung div { flex: 1 1 70px; padding: 6px; }
  .zusammenfassung b { font-size: 1.15rem; }

  /* Touren-Übersicht: Uhrzeit unter den Namen statt daneben */
  .stopps li { display: grid; grid-template-columns: 26px 1fr; column-gap: 10px; align-items: start; }
  .stopps li .zeitangabe { grid-column: 2; margin-left: 0; color: var(--grau); }

  /* Vorschläge + Aufladen-Knopf unten */
  .leiste { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .leiste .btn.gross { min-height: 56px; }
  .vorschlaege button { padding: 8px 12px; min-height: 48px; }
  .seite[data-seite="laden"] { padding-bottom: 110px; }

  /* Dialog „Bearbeiten“ als Vollbild mit festen Knöpfen unten */
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom)); }
  dialog .knoepfe { position: sticky; bottom: -16px; background: #fff; padding: 10px 0; margin: 12px 0 0;
    box-shadow: 0 -6px 10px -8px rgba(0,0,0,.2); }
  dialog .knoepfe .btn { flex: 1; min-height: 52px; }

  .login-box { padding: 22px 18px; }
  .login-box input { min-height: 56px; }
  /* unter der (höheren) Kopfzeile, damit unten Vorschläge und Aufladen-Knopf frei bleiben */
  .meldung { top: calc(140px + env(safe-area-inset-top)); width: max-content; text-align: center; }
}
