/* Mobile-first Styles der Zeiterfassung. Firmenfarbe: dunkles Blau (#1b3a5b). */
:root {
  --blau: #1b3a5b;
  --blau-hell: #2c5885;
  --grau: #f2f4f7;
  --text: #1c2733;
  --ok: #2e7d32;
  --warn: #b45309;
  --fehler: #c62828;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--grau);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

/* Splash / Ladeanimation */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--blau);
  transition: opacity .5s ease;
}
.splash.aus { opacity: 0; pointer-events: none; }
/* Folge-Navigation im selben Tab: Splash gar nicht erst zeigen (s. base.html/app.js). */
.splash-weg .splash { display: none; }
.splash-logo {
  width: 60vw; max-width: 260px; height: auto;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(.92); opacity: .7; }
  50%      { transform: scale(1);   opacity: 1; }
}

/* Kopfzeile */
.app-header {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--blau); color: #fff;
}
.app-header-logo { height: 30px; width: auto; display: block; }
.app-header-title { font-weight: 600; font-size: 1.05rem; }
.app-header-ma { margin-left: auto; font-size: .85rem; opacity: .85; }
.app-header-logout { margin-left: auto; }
.app-header-ma + .app-header-logout { margin-left: 8px; }
.app-header-logout button {
  border: 1px solid rgba(255,255,255,.4); background: transparent; color: #fff;
  font-size: .8rem; padding: 5px 10px; border-radius: 8px; cursor: pointer;
}

.app-main { padding: 16px; max-width: 640px; margin: 0 auto; }

/* Karten / Menü */
.card {
  background: #fff; border-radius: var(--radius); padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 14px;
}
/* Startmenü: thematisch gruppierte Kachel-Blöcke mit Abschnittsüberschrift.
   Die Überschrift trägt rechts eine Trennlinie, die die Gruppen klar absetzt. */
.menu-gruppe { margin-bottom: 22px; }
.menu-gruppe-titel {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 2px 10px; font-size: .82rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: #64748b;
}
.menu-gruppe-titel::after {
  content: ""; flex: 1; height: 1px; background: #e2e8f0;
}
.menu { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.menu-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-decoration: none; color: var(--text);
  background: #fff; border-radius: var(--radius); padding: 20px 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08); min-height: 96px; text-align: center;
}
.menu-item .icon { font-size: 1.8rem; }
.menu-item.disabled { opacity: .55; }

/* Formulare / Buttons */
label { display: block; font-weight: 600; margin: 10px 0 6px; }
select, input[type="text"], input[type="email"], input[type="number"], textarea {
  width: 100%; padding: 12px; font-size: 1rem;
  border: 1px solid #cbd5e1; border-radius: 10px; background: #fff;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px; font-size: 1.05rem; font-weight: 600;
  border: 0; border-radius: 12px; background: var(--blau-hell); color: #fff;
  cursor: pointer; margin-top: 10px;
}
.btn:active { transform: translateY(1px); }
.btn-ok { background: var(--ok); }
.btn-warn { background: var(--warn); }
.btn-ghost { background: #e2e8f0; color: var(--text); }
.btn:disabled { opacity: .5; }

/* Stoppuhr */
.uhr { font-size: 2.6rem; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; margin: 8px 0; }

/* Smiley-Bewertung */
.smileys { display: flex; justify-content: space-between; gap: 6px; margin-top: 6px; }
.smiley {
  flex: 1; font-size: 1.9rem; padding: 8px 0; background: #fff;
  border: 2px solid #cbd5e1; border-radius: 12px; cursor: pointer;
}
.smiley.aktiv { border-color: var(--blau); background: #e8f0f8; }

/* Fahrer-Info: Transportkarten (hinbringen/abholen) */
.fahrt { border-left: 6px solid #cbd5e1; }
.fahrt-hinbringen { border-left-color: var(--blau-hell); }
.fahrt-abholen { border-left-color: var(--ok); }
.fahrt-kopf { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fahrt-richtung { font-weight: 700; }
.fahrt-tag { font-size: .85rem; color: #64748b; }
.fahrt-gebinde { font-size: 1.15rem; font-weight: 600; margin-top: 6px; }
.fahrt-route { margin-top: 4px; }
.fahrt-meta { margin-top: 4px; font-size: .85rem; color: #64748b; }

/* Prio-Liste: nächste Gebinde einer Arbeitsstation */
.hinweis { margin-top: 10px; font-size: .85rem; color: #64748b; }
/* Orte-Formular: GPS-Standortübernahme (orte.js). Lat/Lon nebeneinander, darunter
   eine Statuszeile (Genauigkeit bzw. Fehlerhinweis). */
.gps-koordinaten { display: flex; gap: 10px; }
.gps-koordinaten > div { flex: 1; min-width: 0; }
.gps-status { margin-top: 6px; }
.gps-status-fehler { color: var(--fehler); font-weight: 600; }
.prio-kopf { display: flex; align-items: center; gap: 10px; }
.prio-rang {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--blau); color: #fff; font-weight: 700; font-size: .9rem;
}
.prio-gebinde { flex: 1; font-weight: 600; }
.prio-tag { font-size: .85rem; color: #64748b; }
.prio-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.prio-minuten { font-weight: 700; font-variant-numeric: tabular-nums; }
.prio-menge { font-size: .85rem; color: #64748b; margin-left: auto; }
/* Heimarbeit-Stücklohn (€/1000) in der Prio-Liste; ohne hinterlegten Preis
   erscheint ehrlich "kein Preis hinterlegt" statt gar nichts. */
.prio-lohn { font-size: .85rem; color: var(--ok); font-weight: 600; font-variant-numeric: tabular-nums; }
.prio-lohn-fehlt { color: var(--warn); font-weight: 400; font-style: italic; }
.quelle { font-size: .75rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.quelle-mitarbeiter { background: #e8f0f8; color: var(--blau); }
.quelle-gesamt { background: #fdf0e0; color: var(--warn); }
.quelle-plan { background: #eef1f5; color: #64748b; }
.quelle-tempern-ok { background: #e6f4ea; color: var(--ok); }
/* Prominenter Warnhinweis "noch nicht getempert" (voller Warnton, weiße Schrift). */
.quelle-tempern-offen { background: var(--warn); color: #fff; font-size: .8rem; padding: 3px 10px; }
.quelle-weiss { background: #f2f4f7; color: #334155; border: 1px solid #cbd5e1; }
.prio-schritt { font-size: .85rem; color: #64748b; }
.prio-versand { font-size: .85rem; color: #64748b; margin-left: auto; }
/* Aktueller Status (geplant/in Arbeit + extern/intern) und Standort des Gebindes:
   zugewiesener Heimarbeiter und zuletzt per 'Gesehen' erfasster Ort. */
.prio-status { font-size: .8rem; padding: 2px 8px; border-radius: 999px; background: #eef1f5; color: #334155; font-weight: 600; }
.prio-standort { font-size: .85rem; color: #64748b; }

/* Stationssicht je Schritt (bereit / blockiert), z.B. Vereisen, Tempern */
.station { border-left: 6px solid #cbd5e1; }
.station-bereit { border-left-color: var(--blau-hell); }
.station-blockiert { border-left-color: var(--warn); }
.station-status { font-size: .75rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; flex: none; }
.station-status-bereit { background: #e8f0f8; color: var(--blau); }
.station-status-blockiert { background: #fdf0e0; color: var(--warn); }

/* Externe Übergabe: Sendungen (offen/abgeholt) mit Aktions-Datum */
.sendung { border-left: 6px solid var(--blau-hell); }
.sendung-abgeholt { border-left-color: var(--ok); opacity: .9; }
.sendung-kopf { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sendung-badge { font-size: .75rem; padding: 2px 8px; border-radius: 999px; font-weight: 600; flex: none; }
.sendung-badge-offen { background: #e8f0f8; color: var(--blau); }
.sendung-badge-abgeholt { background: #e6f4ea; color: var(--ok); }
.sendung-gebinde { margin: 6px 0; padding-left: 18px; font-size: .9rem; }
.sendung-aktion { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sendung-aktion label { font-size: .85rem; color: #64748b; }
.sendung-aktion input[type="date"] { padding: 10px; border-radius: 10px; border: 1px solid #cbd5e1; }
.sendung-aktion .btn { flex: 1; min-width: 150px; margin-top: 0; }

/* Mehrfach-Buchung: gescannte Gebinde als entfernbare Chips vor dem Absenden */
.station-buchen-aktionen { display: flex; gap: 8px; flex-wrap: wrap; }
.station-buchen-aktionen .btn { flex: 1; min-width: 140px; }
/* Multi-Scan: je gescanntem Gebinde eine Zeile (Nummer · Matchcode · Link · ✕). */
.gebinde-chips { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 0; }
.gebinde-chip {
  display: flex; align-items: center; gap: 8px;
  background: #e8f0f8; color: var(--blau); font-weight: 600;
  padding: 6px 8px 6px 12px; border-radius: 10px; font-variant-numeric: tabular-nums;
}
.gebinde-chip-nr { flex: 0 0 auto; }
.gebinde-chip-info {
  flex: 1 1 auto; min-width: 0; font-weight: 400; font-size: .8rem; color: #475569;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gebinde-chip-info a { color: var(--blau); }
.gebinde-chip-x {
  flex: 0 0 auto; margin-left: auto;
  border: none; background: rgba(0, 0, 0, .12); color: inherit; cursor: pointer;
  width: 20px; height: 20px; border-radius: 50%; line-height: 1; font-size: .8rem;
}

/* Einzel-Scan: Ergebniszeile (Matchcode + Arbeitsanweisungs-Link) unter dem Feld. */
.scan-info a { color: var(--blau); font-weight: 600; }

/* Artikelweise Stationssicht: eine kompakte Zeile je Artikel (Matchcode + Menge/Gebinde) */
.artikel-zeile {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 6px; border-radius: 10px;
  background: #fff; border-left: 6px solid #cbd5e1;
}
.artikel-bereit { border-left-color: var(--blau-hell); }
/* Noch nicht bearbeitbar (Vorschritte offen): ausgegraut, damit die bereiten
   Artikel in der gemeinsamen Prio-Liste optisch hervortreten. */
.artikel-blockiert { border-left-color: var(--warn); opacity: .75; }
/* Blockiert + Vorschritt (z.B. Tempern) offen: dringend anschieben – heller
   Warnton, volle Deckkraft (überstimmt die Ausgrauung). */
.artikel-dringend { background: #fff7ed; box-shadow: inset 0 0 0 1px #fed7aa; opacity: 1; }
/* Bedarf ohne Produktionsgebinde ("blind" produziert): ausgegraut, nur Hinweis. */
.artikel-bedarf { border-left-color: #cbd5e1; background: #f8fafc; opacity: .6; }
.artikel-status { flex: none; font-size: 1.1rem; }
/* Kleines Artikelbild in der Zeile; Klick vergrößert (Lightbox, stationsliste.js). */
.artikel-bild {
  flex: none; width: 44px; height: 44px; object-fit: cover;
  border-radius: 8px; border: 1px solid #e2e8f0; background: #fff; cursor: zoom-in;
}
.artikel-name { flex: 1; font-weight: 600; min-width: 40%; }
.artikel-menge { font-weight: 700; font-variant-numeric: tabular-nums; }
/* Link zur Vereisungsvorschrift (Outline) je Zeile der Vereisungsliste */
.artikel-vereisung { font-size: .8rem; color: var(--blau); white-space: nowrap; text-decoration: none; }
.artikel-vereisung:hover { text-decoration: underline; }
.artikel-versand { font-size: .85rem; color: #64748b; margin-left: auto; white-space: nowrap; }
/* Wochen-Bucket eines Bedarfs ("Sofort", "KW 35"): wann die Menge gebraucht wird */
.bedarf-fenster { font-size: .75rem; padding: 2px 8px; border-radius: 999px; font-weight: 600;
  background: #eef1f5; color: #64748b; white-space: nowrap; }
.bedarf-fenster-sofort { background: var(--warn); color: #fff; }
/* Versandtermin-Ampel (Frist = Versandtermin − Vorlaufzeit des Schritts). */
.versand-rot { color: #fff; background: var(--fehler); padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.versand-orange { color: #fff; background: var(--warn); padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.versand-gruen { color: #fff; background: var(--ok); padding: 2px 8px; border-radius: 999px; font-weight: 700; }
.versand-neutral { color: #64748b; }

/* KW-Block: alle Artikel einer Frist-Kalenderwoche unter einer durchgehenden,
   farbigen Seitenlinie (--kw) auf leicht getöntem Grund (--kw-tint). Die Farbe
   wechselt je Woche zyklisch (kw-w0..kw-w5), sodass "diese Woche" und "nächste
   Woche" sofort unterscheidbar sind; Sofort/überfällig ist rot. */
.kw-block {
  margin: 0 0 16px; padding-bottom: 6px; border-radius: 12px;
  border-left: 6px solid var(--kw, #cbd5e1);
  background: var(--kw-tint, #f8fafc);
}
.kw-block.kw-dringend { box-shadow: inset 0 0 0 2px var(--kw, #cbd5e1); }
.kw-kopf {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px 8px;
}
.kw-titel { font-weight: 800; font-size: 1.02rem; color: var(--kw-text, var(--text)); }
.kw-nummer {
  font-size: .76rem; font-weight: 700; color: #fff; background: var(--kw, #94a3b8);
  padding: 2px 9px; border-radius: 999px; letter-spacing: .02em;
}
.kw-spanne { font-size: .84rem; color: #475569; font-variant-numeric: tabular-nums; }
.kw-anzahl { margin-left: auto; font-size: .78rem; color: #64748b; font-weight: 600; }
/* Zeilen sitzen weiß auf der Tönung, damit sie klar hervortreten. */
.kw-block .artikel-zeile { margin: 0 10px 6px; }
/* Farbpalette (zyklisch): Seitenlinie/Badge = --kw, Blockgrund = --kw-tint. */
.kw-sofort { --kw: var(--fehler);   --kw-tint: #fef2f2; --kw-text: var(--fehler); }
.kw-w0     { --kw: var(--blau-hell); --kw-tint: #eef4fb; }
.kw-w1     { --kw: #0d9488;          --kw-tint: #ecfdf5; }
.kw-w2     { --kw: #7c3aed;          --kw-tint: #f5f3ff; }
.kw-w3     { --kw: #d97706;          --kw-tint: #fff7ed; }
.kw-w4     { --kw: #db2777;          --kw-tint: #fdf2f8; }
.kw-w5     { --kw: #0891b2;          --kw-tint: #ecfeff; }
.kw-ohne   { --kw: #94a3b8;          --kw-tint: #f8fafc; }

/* Lightbox: Artikelbild groß über dem Inhalt (Klick/ESC schließt). */
.bild-lightbox {
  position: fixed; inset: 0; z-index: 1000; display: flex;
  align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .8); padding: 20px; cursor: zoom-out;
}
.bild-lightbox[hidden] { display: none; }
.bild-lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

/* Meldungen */
.messages { list-style: none; padding: 0; margin: 0 0 12px; }
.msg { padding: 12px 14px; border-radius: 10px; margin-bottom: 8px; color: #fff; }
.msg-success { background: var(--ok); }
.msg-info { background: var(--blau-hell); }
.msg-warning { background: var(--warn); }
.msg-error { background: var(--fehler); }

/* Auswertungssicht (Desktop): breiter als die mobile 640px-Spalte */
.app-main-weit { max-width: 1200px; }
.agg-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
@media (min-width: 900px) { .agg-grid { grid-template-columns: 1fr 1fr; } }
.auswertung-filter label { display: block; font-size: .85rem; margin-top: 8px; }
.table-wrap { overflow-x: auto; }
.tabelle { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabelle th, .tabelle td {
  padding: 6px 8px; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: top;
}
.tabelle th { color: #64748b; font-weight: 600; white-space: nowrap; }
.tabelle tbody tr:hover { background: #f8fafc; }
.tabelle .nowrap { white-space: nowrap; }
.tabelle .notiz { max-width: 260px; }
.tabelle a { text-decoration: none; margin-right: 6px; }

/* Qualitätskontrolle: Zurückweisungs-Karten (Nachbesserung / Gebinde-Status) */
.qk-karte { border-left: 6px solid var(--fehler); }
.qk-zeile { padding: 6px 0; border-top: 1px solid #e2e8f0; }
.qk-zeile:first-of-type { border-top: 0; }
.qk-medien { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.qk-karte .notiz { margin: 6px 0; }

/* QS-Ausschuss-Dashboard: Einbuchungszeilen über der 5%-Grenze rot hinterlegt */
.tabelle tr.ausschuss-alarm td { background: #ffc7ce; }
.tabelle tr.ausschuss-alarm:hover td { background: #ffb3bd; }
.auswertung-filter .check-label { display: flex; align-items: center; gap: 6px; }
.auswertung-filter .check-label input { width: auto; }

/* Feedback: 'Ist das Gebinde fertig?' – Auswahl Noch nicht / Fertig (abholbereit) */
.fb-erledigt { display: flex; flex-direction: column; gap: 8px; margin: 6px 0; }
.fb-erledigt-option { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.fb-erledigt-option input { width: auto; }

/* Prozesskette (Gebinde-Verlauf) */
.verlauf-liste { margin-top: 10px; }
.verlauf-ev {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--grau);
}
.verlauf-ev:first-child { border-top: none; }
.verlauf-zeit {
  flex: 0 0 84px; font-size: 12px; color: #6b7785; line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.verlauf-icon { flex: 0 0 auto; font-size: 16px; line-height: 1.3; }
.verlauf-text { flex: 1 1 auto; min-width: 0; }
.verlauf-titel { font-weight: 600; color: var(--text); font-size: 14px; }
.verlauf-detail { font-size: 12.5px; color: #6b7785; margin-top: 1px; }

/* Standort-Mini-Karte (Gebinde-Status) + Vollbild-Overlay (Leaflet/OSM) */
.standort-karte {
  height: 180px; width: 100%; margin: 8px 0 2px;
  border: 1px solid var(--grau); border-radius: 10px;
  cursor: pointer; z-index: 0;
}
.standort-karte .leaflet-container { border-radius: 10px; }
/* Mini-Karte je Standort-Ereignis in der Prozesskette (etwas kompakter) */
.verlauf-karte-mini {
  height: 140px; width: 100%; max-width: 320px; margin: 6px 0 2px;
  border: 1px solid var(--grau); border-radius: 8px;
  cursor: pointer; z-index: 0;
}
.verlauf-karte-mini .leaflet-container { border-radius: 8px; }
.standort-vollbild {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0, 0, 0, 0.55);
}
.standort-vollbild-karte { position: absolute; inset: 0; }
.standort-vollbild-zu {
  position: absolute; z-index: 2001;
  top: calc(10px + env(safe-area-inset-top, 0px)); right: 12px;
  width: 44px; height: 44px; padding: 0;
  border: none; border-radius: 50%;
  background: #fff; color: var(--blau);
  font-size: 22px; line-height: 44px; text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35); cursor: pointer;
}
body.standort-vollbild-offen { overflow: hidden; }
