/* Köhler-Dispo — ruhig, sachlich, hoher Kontrast.
   Bedienung mit Arbeitshandschuhen: Flaechen mindestens 15 mm hoch. */

:root {
  color-scheme: light dark;

  --grund:      #f4f5f7;
  --flaeche:    #ffffff;
  --flaeche-2:  #eceef2;
  --schrift:    #14181f;
  --gedaempft:  #5a6472;
  --linie:      #d3d8e0;
  --linie-satt: #aab2be;

  --gruen:      #14713a;
  --gruen-hell: #e4f3e9;
  --bernstein:  #9a5b00;
  --bernstein-hell: #fdf0dc;
  --rot:        #a3231f;
  --rot-hell:   #fbe6e5;
  --blau:       #1c4e93;
  --blau-hell:  #e6eefb;
  --grau-satt:  #4a5361;

  --radius:  10px;
  --schrift-familie: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                     "Helvetica Neue", Arial, sans-serif;
  --tast: 15mm;                       /* Mindesthoehe fuer Handschuhbedienung */
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund:      #0e1116;
    --flaeche:    #161b22;
    --flaeche-2:  #1e242d;
    --schrift:    #e9eef5;
    --gedaempft:  #9aa5b4;
    --linie:      #29313d;
    --linie-satt: #3d4756;

    --gruen:      #2ea25a;
    --gruen-hell: #133020;
    --bernstein:  #d18f1f;
    --bernstein-hell: #33270f;
    --rot:        #e0625d;
    --rot-hell:   #331715;
    --blau:       #6aa3f0;
    --blau-hell:  #12203a;
    --grau-satt:  #8b94a3;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--grund);
  color: var(--schrift);
  font-family: var(--schrift-familie);
  font-size: 17px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ul { list-style: none; padding: 0; }
button { font: inherit; color: inherit; }

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 14px) 14px calc(env(safe-area-inset-bottom) + 24px);
}
.app.weit { max-width: 1180px; }

/* ---------------------------------------------------------------- Bausteine */

.karte {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.karte h2 {
  font-size: 15px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--gedaempft);
  font-weight: 600;
  margin-bottom: 10px;
}

.knopf {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: var(--tast);
  padding: 14px 18px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--flaeche-2);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}
.knopf:active { transform: translateY(1px); filter: brightness(.94); }
.knopf:focus-visible { outline: 3px solid var(--blau); outline-offset: 2px; }
.knopf[disabled] { opacity: .45; cursor: default; }

.knopf.gross   { min-height: 26mm; font-size: 27px; margin-bottom: 12px; }
.knopf.klein   { min-height: 13mm; font-size: 17px; width: auto; padding: 10px 16px; }
.knopf.zeile   { width: auto; min-height: 11mm; font-size: 16px; padding: 8px 14px; }

.knopf.kommen    { background: var(--gruen);     color: #fff; }
.knopf.wechseln  { background: var(--bernstein); color: #fff; }
.knopf.feier     { background: transparent; color: var(--schrift); border-color: var(--linie-satt); }
.knopf.haupt     { background: var(--blau);      color: #fff; }
.knopf.abbruch   { background: transparent; color: var(--schrift); border-color: var(--linie-satt); }
.knopf.gefahr    { background: var(--rot);       color: #fff; }

@media (prefers-color-scheme: dark) {
  .knopf.kommen   { color: #06170d; }
  .knopf.wechseln { color: #241802; }
  .knopf.haupt    { color: #06152b; }
}

/* ---------------------------------------------------------------- Meldungsband */

.band {
  position: sticky;
  top: 0;
  z-index: 40;
  padding: calc(env(safe-area-inset-top) + 8px) 14px 8px;
  background: var(--bernstein-hell);
  color: var(--schrift);
  border-bottom: 1px solid var(--linie);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.band.fehler { background: var(--rot-hell); }
.band.ruhig  { background: var(--blau-hell); }

/* ---------------------------------------------------------------- Statusbild */

.status {
  border-radius: var(--radius);
  padding: 22px 18px;
  margin-bottom: 14px;
  border: 2px solid var(--linie-satt);
  background: var(--flaeche);
}
.status.aktiv { border-color: var(--gruen); background: var(--gruen-hell); }

.status .zeile-oben {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 15px;
  color: var(--gedaempft);
  margin-bottom: 6px;
}
.status .gross-text {
  font-size: clamp(30px, 8.4vw, 44px);
  line-height: 1.08;
  font-weight: 800;
  letter-spacing: -.015em;
}
.status.aktiv .gross-text { color: var(--gruen); }
.status .seit {
  font-size: clamp(19px, 5vw, 24px);
  font-weight: 600;
  margin-top: 8px;
}
.status .ort {
  font-size: clamp(21px, 5.6vw, 27px);
  font-weight: 700;
  margin-top: 2px;
}
.status .nachlauf { margin-top: 10px; font-size: 15px; color: var(--gedaempft); }

.plan li {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--linie);
  font-size: 17px;
}
.plan li:first-child { border-top: 0; }
.plan .zeit { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.plan .leer { color: var(--gedaempft); }

.person-zeile {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  color: var(--gedaempft);
  margin: 18px 2px 10px;
}

/* ---------------------------------------------------------------- Kamera */

.scanner {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
}
.scanner[hidden] { display: none; }
.scanner video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.scan-maske {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scan-fenster {
  position: relative;
  width: min(74vw, 62vh);
  height: min(74vw, 62vh);
  box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5);
  border-radius: 14px;
}
.scan-fenster i {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 5px solid #fff;
}
.scan-fenster i:nth-child(1) { top: -3px;    left: -3px;  border-right: 0; border-bottom: 0; border-radius: 12px 0 0 0; }
.scan-fenster i:nth-child(2) { top: -3px;    right: -3px; border-left: 0;  border-bottom: 0; border-radius: 0 12px 0 0; }
.scan-fenster i:nth-child(3) { bottom: -3px; left: -3px;  border-right: 0; border-top: 0;    border-radius: 0 0 0 12px; }
.scan-fenster i:nth-child(4) { bottom: -3px; right: -3px; border-left: 0;  border-top: 0;    border-radius: 0 0 12px 0; }

.scan-kopf {
  position: relative;
  z-index: 2;
  padding: calc(env(safe-area-inset-top) + 16px) 18px 16px;
  text-align: center;
  text-shadow: 0 1px 4px rgba(0, 0, 0, .9);
}
#scan-titel { font-size: 24px; font-weight: 800; }
.scan-hinweis { font-size: 16px; margin-top: 4px; color: #e6e8ea; }
.scan-hinweis.warnung { color: #ffd27a; font-weight: 700; }

.scan-fuss {
  position: relative;
  z-index: 2;
  margin-top: auto;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 16px 14px calc(env(safe-area-inset-bottom) + 20px);
}
.scan-fuss .knopf {
  background: rgba(255, 255, 255, .16);
  color: #fff;
  border-color: rgba(255, 255, 255, .5);
  backdrop-filter: blur(6px);
}

/* ---------------------------------------------------------------- Blatt (Dialog) */

.blatt {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.blatt[hidden] { display: none; }
.blatt-inhalt {
  width: 100%;
  max-width: 620px;
  max-height: 94vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--grund);
  border-radius: 16px 16px 0 0;
  border-top: 1px solid var(--linie);
  padding: 20px 16px calc(env(safe-area-inset-bottom) + 18px);
}
@media (min-width: 700px) {
  .blatt { align-items: center; }
  .blatt-inhalt { border-radius: 16px; border: 1px solid var(--linie); }
}
.blatt h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--gedaempft); }
.blatt .frage { font-size: clamp(24px, 6.4vw, 32px); font-weight: 800; margin: 6px 0 4px; line-height: 1.15; }
.blatt .detail { font-size: 20px; color: var(--gedaempft); margin-bottom: 18px; }
.blatt .detail b { color: var(--schrift); font-variant-numeric: tabular-nums; }

/* Zifferntastatur */
.anzeige {
  font-size: 40px;
  font-weight: 800;
  letter-spacing: .22em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  background: var(--flaeche);
  border: 2px solid var(--linie-satt);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  min-height: 66px;
}
.tasten { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.tasten .knopf { min-height: 16mm; font-size: 26px; background: var(--flaeche); border-color: var(--linie); }

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

.kopfzeile {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 14px;
}
.kopfzeile h1 { font-size: 24px; font-weight: 800; }
.kopfzeile .rechts { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.tabellen-rahmen { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--linie); vertical-align: middle; }
th { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--gedaempft); font-weight: 600; white-space: nowrap; }
td.zahl { font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.hat-hinweis td { background: var(--bernstein-hell); }
.hinweis-text { display: block; font-size: 14px; color: var(--bernstein); font-weight: 600; margin-top: 2px; }

.marke {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
  border: 1px solid;
}
.marke.offen           { background: var(--flaeche-2); color: var(--gedaempft); border-color: var(--linie-satt); }
.marke.quittiert       { background: var(--blau-hell); color: var(--blau); border-color: var(--blau); }
.marke.synchronisiert  { background: var(--gruen-hell); color: var(--gruen); border-color: var(--gruen); }
.marke.fakturiert      { background: var(--gruen); color: #fff; border-color: var(--gruen); }
.marke.warn            { background: var(--bernstein-hell); color: var(--bernstein); border-color: var(--bernstein); }
@media (prefers-color-scheme: dark) { .marke.fakturiert { color: #06170d; } }

.datum-feld, .text-feld {
  font: inherit;
  padding: 10px 12px;
  min-height: 12mm;
  background: var(--flaeche);
  color: var(--schrift);
  border: 1px solid var(--linie-satt);
  border-radius: var(--radius);
}

.link-zeile {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--linie);
  flex-wrap: wrap;
}
.link-zeile:first-child { border-top: 0; }
.link-zeile .name { font-weight: 700; min-width: 190px; }
.link-zeile code {
  flex: 1 1 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--gedaempft);
  background: var(--flaeche-2);
  padding: 8px 10px;
  border-radius: 8px;
  word-break: break-all;
}

.ergebnis { margin-top: 12px; }
.ergebnis li { padding: 8px 0; border-top: 1px solid var(--linie); font-size: 16px; }
.ergebnis li:first-child { border-top: 0; }

.fuss { margin-top: 26px; text-align: center; font-size: 14px; color: var(--gedaempft); }
.fuss a { color: var(--gedaempft); }

.hinweis-kasten {
  border-left: 4px solid var(--bernstein);
  background: var(--bernstein-hell);
  padding: 12px 14px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 12px;
  font-size: 16px;
}
.hinweis-kasten.fehler { border-color: var(--rot); background: var(--rot-hell); }
.hinweis-kasten.gut    { border-color: var(--gruen); background: var(--gruen-hell); }

/* ---------------------------------------------------------------- Toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%);
  z-index: 90;
  max-width: min(92vw, 520px);
  padding: 14px 18px;
  border-radius: var(--radius);
  background: #14181f;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
}
.toast[hidden] { display: none; }
.toast.fehler { background: var(--rot); color: #fff; }
.toast.gut    { background: var(--gruen); color: #fff; }
@media (prefers-color-scheme: dark) {
  .toast { background: #e9eef5; color: #14181f; }
  .toast.gut { color: #06170d; }
  .toast.fehler { color: #2b0b0a; }
}

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

/* Ergebnis von Uebertragung und Wochenlauf kurz hervorheben */
#ergebnis-karte.frisch { animation: frisch-blitz 1.6s ease-out 1; }
@keyframes frisch-blitz {
  0%   { box-shadow: 0 0 0 3px var(--akzent, #0F7D74); }
  100% { box-shadow: 0 0 0 0 transparent; }
}
