/* LOEWE PSA-Lager — helles Etiketten-Design im Loewe-Branding.
   Fläche = heller Beton, Karten = Etiketten-Weiß, Tinte = Anthrazit der
   Wortmarke, Loewe-Grün nur für Primäraktion/Marke, Signalrot für Ausgabe. */
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

:root {
  --beton:       #f2f3f0;                 /* Seitenfläche */
  --etikett:     #ffffff;                 /* Karten/Leisten */
  --feld:        #f7f8f5;                 /* Eingabefelder: leicht eingelassen */
  --linie:       rgba(29, 29, 27, 0.12);
  --linie-sanft: rgba(29, 29, 27, 0.07);
  --linie-stark: rgba(29, 29, 27, 0.28);
  --tinte:       #1d1d1b;                 /* Anthrazit der Wortmarke */
  --tinte-2:     #5c5f58;
  --tinte-3:     #90938b;

  --loewe:        #008639;                /* Loewe-Grün */
  --loewe-dunkel: #006e2f;
  --loewe-hell:   #e6f2ea;                /* grüne Tönung für Badges/aktiv */
  --signal:       #c23a1d;                /* Ausgabe / Fehler */
  --signal-dunkel:#a52f15;
  --signal-hell:  #faeae5;
  --warn:         #a05a0a;                /* Mindestbestand */
  --warn-hell:    #fbf1df;

  --radius: 10px;
  --schatten: 0 0 0 1px rgba(29,29,27,0.06), 0 1px 2px -1px rgba(29,29,27,0.08), 0 4px 12px rgba(29,29,27,0.08);
  --schnell: 160ms cubic-bezier(0.23, 1, 0.32, 1);

  --z-header: 10;
  --z-nav: 10;
  --z-toast: 30;
}

body {
  font-family: "Bahnschrift", "DIN Alternate", "Segoe UI", system-ui, sans-serif;
  background: var(--beton);
  color: var(--tinte);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Kopfzeile / Marke ---------- */
header {
  position: sticky; top: 0; z-index: var(--z-header);
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--linie);
  padding: 0.6rem 1rem;
  padding-top: calc(0.6rem + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 0.7rem; min-width: 0; }
.header-logo { display: block; height: 24px; width: auto; }
.header-app {
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--tinte-2);
  border-left: 1px solid var(--linie); padding-left: 0.7rem;
  white-space: nowrap;
}

/* ---------- Layout ---------- */
.view { padding: 1rem; max-width: 640px; margin: 0 auto 5.5rem; }
.view-head {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.view-head h2 {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--tinte-2);
}

nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: var(--z-nav);
  display: flex;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 0.55rem 0 0.5rem; border: 0; background: none;
  color: var(--tinte-3); cursor: pointer; position: relative;
  transition: color var(--schnell);
}
.nav-btn svg {
  width: 22px; height: 22px; fill: none;
  stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.btn-icon {
  width: 19px; height: 19px; fill: none; vertical-align: -0.22em; margin-right: 0.5em;
  stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.nav-btn span { font-size: 0.68rem; font-weight: 600; letter-spacing: 0.02em; }
.nav-btn.active { color: var(--loewe); }
.nav-btn.active::before {
  content: ""; position: absolute; top: -1px; left: 25%; right: 25%;
  height: 2px; background: var(--loewe); border-radius: 0 0 2px 2px;
}

/* ---------- Buttons & Formulare ---------- */
.btn {
  display: block; width: 100%; padding: 0.8rem; margin-top: 0.75rem;
  border: 0; border-radius: var(--radius); font-size: 1rem; font-weight: 600;
  font-family: inherit; cursor: pointer; color: var(--tinte);
  transition: background var(--schnell), transform var(--schnell), filter var(--schnell);
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--loewe); color: #fff; }
.btn-primary:hover { background: var(--loewe-dunkel); }
.btn-big { padding: 1rem; font-size: 1.05rem; }
.btn-klein { width: auto; margin-top: 0; padding: 0.5rem 0.85rem; font-size: 0.85rem; }
.btn-plain {
  background: var(--etikett); border: 1px solid var(--linie);
  border-radius: var(--radius); padding: 0.6rem 0.9rem;
  color: var(--tinte); font-size: 0.95rem; font-family: inherit; cursor: pointer;
  transition: background var(--schnell), border-color var(--schnell), transform var(--schnell);
}
.btn-plain:hover { background: var(--feld); }
.btn-plain:active { transform: scale(0.98); }
.btn-gefahr {
  background: var(--etikett); border: 1px solid var(--signal);
  color: var(--signal); font-size: 0.95rem;
}
.btn-gefahr:hover { background: var(--signal-hell); }
header .btn-plain { padding: 0.4rem 0.75rem; font-size: 0.85rem; color: var(--tinte-2); }
:is(button, input, select):focus-visible {
  outline: 2px solid var(--loewe); outline-offset: 2px;
}
input, select {
  width: 100%; padding: 0.72rem; margin-top: 0.3rem;
  border: 1px solid var(--linie); border-radius: calc(var(--radius) - 2px);
  font-size: 1rem; font-family: inherit;
  background: var(--feld); color: var(--tinte);
  transition: border-color var(--schnell), background var(--schnell);
}
input::placeholder { color: var(--tinte-3); }
input:focus, select:focus { border-color: var(--loewe); background: var(--etikett); outline: none; }
label {
  display: block; margin-top: 0.9rem;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--tinte-2);
}
.check-line {
  display: flex; align-items: center; gap: 0.55rem;
  text-transform: none; letter-spacing: 0; font-size: 0.95rem; font-weight: 600;
  color: var(--tinte); padding: 0.35rem 0;
}
.check-line input { width: 1.25rem; height: 1.25rem; margin: 0; flex: none; accent-color: var(--loewe); }
.form-titel { font-weight: 700; font-size: 1.02rem; }

/* ---------- Buchen ---------- */
.mode-toggle {
  display: flex; gap: 4px; padding: 4px;
  background: var(--etikett); border: 1px solid var(--linie); border-radius: var(--radius);
}
.mode-btn {
  flex: 1; padding: 0.75rem; border: 0; border-radius: calc(var(--radius) - 4px);
  background: transparent; font-size: 1rem; font-weight: 700; font-family: inherit;
  cursor: pointer; color: var(--tinte-2);
  transition: background var(--schnell), color var(--schnell);
}
#mode-aus.active { background: var(--signal); color: #fff; }
#mode-ein.active { background: var(--loewe); color: #fff; }
.btn-aus { background: var(--signal); color: #fff; }
.btn-aus:hover { background: var(--signal-dunkel); }
.btn-ein { background: var(--loewe); color: #fff; }
.btn-ein:hover { background: var(--loewe-dunkel); }
.mode-toggle.klein { margin-bottom: 0.75rem; }
.mode-toggle.klein .mode-btn { padding: 0.55rem; font-size: 0.88rem; }
.mode-toggle.klein .mode-btn.active { background: var(--tinte); color: #fff; }

/* Ausgabeliste */
.liste-kopf {
  margin-top: 1.4rem;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--tinte-2);
}
.posten-rechts { display: flex; align-items: center; gap: 0.55rem; flex: none; }
.btn-x {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--linie); background: var(--etikett);
  color: var(--tinte-2); font-size: 1.1rem; line-height: 1; cursor: pointer;
  transition: background var(--schnell), color var(--schnell), border-color var(--schnell);
}
.btn-x:hover { background: var(--signal-hell); color: var(--signal); border-color: var(--signal); }

#scanner {
  margin-top: 0.75rem; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--loewe);
  box-shadow: 0 0 0 1px rgba(0, 134, 57, 0.25), 0 0 24px rgba(0, 134, 57, 0.18);
  animation: scan-puls 2.2s ease-in-out infinite;
}
#scanner video { display: block; width: 100%; }
@keyframes scan-puls {
  0%, 100% { box-shadow: 0 0 0 1px rgba(0,134,57,0.2), 0 0 24px rgba(0,134,57,0.12); }
  50%      { box-shadow: 0 0 0 1px rgba(0,134,57,0.4), 0 0 32px rgba(0,134,57,0.28); }
}

.search-box { position: relative; margin-top: 0.75rem; }
.result-list { border-radius: var(--radius); margin-top: 0.4rem; }
.result-list:not(:empty) { box-shadow: var(--schatten); }
.result-list div {
  padding: 0.75rem 0.9rem; background: var(--etikett);
  border-bottom: 1px solid var(--linie-sanft); cursor: pointer;
  transition: background var(--schnell);
}
.result-list div:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.result-list div:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom: 0; }
.result-list div:only-child { border-radius: var(--radius); }
.result-list div:hover { background: var(--feld); }
.result-list small { color: var(--tinte-2); }

.card {
  background: var(--etikett); border: 1px solid var(--linie);
  border-radius: var(--radius); padding: 1rem; margin-top: 0.9rem;
}
.artikel-card { border-left: 3px solid var(--loewe); }
.card .name { font-weight: 700; font-size: 1.1rem; }
.card .meta { color: var(--tinte-2); font-size: 0.85rem; margin-top: 0.25rem; }
.card .meta b { color: var(--tinte); }

/* ---------- Listen ---------- */
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 0.6rem;
  background: var(--etikett); border: 1px solid var(--linie);
  border-radius: var(--radius); padding: 0.7rem 0.95rem; margin-top: 0.5rem;
}
.row .sub { color: var(--tinte-2); font-size: 0.8rem; margin-top: 0.1rem; }
.row .menge { font-weight: 700; white-space: nowrap; font-size: 1.02rem; }
/* Kantenstreifen wie Regalkennzeichnung: grün = Eingang, rot = Ausgabe */
.row.typ-ein { border-left: 3px solid var(--loewe); }
.row.typ-aus { border-left: 3px solid var(--signal); }
.row.warnung { border-left: 3px solid var(--warn); background: var(--warn-hell); }
.row.warnung .menge, .row.warnung .sub { color: var(--warn); }
.badge-ein { color: var(--loewe); }
.badge-aus { color: var(--signal); }
.hint { color: var(--tinte-2); font-size: 0.85rem; margin-top: 0.5rem; }
.etikett-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }
.etikett-actions .btn { margin-top: 0; width: auto; flex: 1; }
.check-row { justify-content: flex-start; }
.check-row input {
  width: 1.25rem; height: 1.25rem; margin: 0; flex: none; accent-color: var(--loewe);
}

/* ---------- Admin: Benutzer ---------- */
.user-row { cursor: pointer; transition: background var(--schnell); }
.user-row:hover { background: var(--feld); }
.badges { display: flex; gap: 0.3rem; flex: none; }
.badge {
  font-size: 0.66rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  padding: 0.18rem 0.55rem; border-radius: 999px; white-space: nowrap;
}
.badge-admin { background: var(--loewe-hell); color: var(--loewe-dunkel); }
.badge-inaktiv { background: var(--signal-hell); color: var(--signal); }
.badge-offen { background: rgba(29, 29, 27, 0.08); color: var(--tinte-2); }
.badge-unterschrieben { background: var(--loewe-hell); color: var(--loewe-dunkel); }
.badge-versendet { background: var(--tinte); color: #fff; }
.view-head.abschnitt { margin-top: 1.8rem; }
.schein-row { cursor: pointer; transition: background var(--schnell); }
.schein-row:hover { background: var(--feld); }

/* ---------- Ausgabeschein-Panel ---------- */
.panel {
  position: fixed; inset: 0; z-index: 20;
  background: var(--beton); overflow-y: auto;
}
.panel-inhalt { max-width: 640px; margin: 0 auto; padding: 1rem 1rem 3rem; }
.panel-kopf {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.panel-sub { color: var(--tinte-2); font-size: 0.85rem; margin-top: 0.2rem; }
#unterschrift-pad {
  display: block; width: 100%; height: 200px; margin-top: 0.3rem;
  background: var(--etikett); border: 1px dashed var(--linie-stark);
  border-radius: var(--radius); touch-action: none; cursor: crosshair;
}
.pad-actions { display: flex; gap: 0.5rem; }
.pad-actions .btn { flex: 1; }
.pad-actions .btn-plain { margin-top: 0.75rem; }
#unterschrift-bild { display: block; max-width: 100%; max-height: 160px; margin-top: 0.4rem; }
.schein-aktionen { display: flex; gap: 0.5rem; margin-top: 1.2rem; }
.schein-aktionen .btn { flex: 1; margin-top: 0; }

/* ---------- Login ---------- */
.login-view {
  display: flex; justify-content: center; padding-top: 11vh; min-height: 100vh;
}
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-logo { width: min(230px, 72%); height: auto; }
.login-app {
  margin-top: 0.55rem;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--tinte-2);
}
.login-card { text-align: left; margin-top: 1.4rem; padding: 1.2rem; }
.login-card label:first-child { margin-top: 0; }
.error { color: var(--signal); margin-top: 0.6rem; font-size: 0.9rem; text-align: center; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 5.2rem; left: 50%; transform: translateX(-50%);
  z-index: var(--z-toast);
  background: var(--tinte); color: #fff;
  padding: 0.7rem 1.2rem; border-radius: var(--radius);
  box-shadow: var(--schatten);
  font-size: 0.95rem; font-weight: 600; max-width: 90vw; text-align: center;
  animation: toast-rein 200ms cubic-bezier(0.23, 1, 0.32, 1);
}
#toast.ok { background: var(--loewe); }
#toast.fehler { background: var(--signal); }
@keyframes toast-rein {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

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

/* ---------- Druck: Etiketten (A4, 3x8 je 70x37mm) + Ausgabeschein ---------- */
#print-sheet { display: none; }
@media print {
  body > *:not(#print-sheet) { display: none !important; }
  body { background: #fff; }
  #print-sheet.etiketten { display: grid; grid-template-columns: repeat(3, 70mm); }
  @page { size: A4 portrait; margin: 0; }

  #print-sheet.schein { display: block; padding: 16mm 18mm; color: #000; }
  .schein-logo { height: 12mm; width: auto; }
  .schein-print h1 { font-size: 16pt; margin-top: 8mm; }
  .schein-info { font-size: 10pt; color: #333; margin-top: 2mm; }
  .schein-tabelle { width: 100%; border-collapse: collapse; margin-top: 8mm; font-size: 10.5pt; }
  .schein-tabelle th {
    text-align: left; font-size: 8.5pt; text-transform: uppercase;
    letter-spacing: 0.06em; color: #444;
  }
  .schein-tabelle th, .schein-tabelle td { border-bottom: 0.3mm solid #bbb; padding: 2.2mm 1mm; }
  .schein-tabelle th:last-child, .schein-tabelle td:last-child { text-align: right; }
  .schein-unterschrift { margin-top: 18mm; }
  .unterschrift-bild-print { height: 22mm; display: block; }
  .unterschrift-linie {
    border-top: 0.35mm solid #000; width: 80mm;
    padding-top: 2mm; font-size: 9pt; margin-top: 2mm;
  }
  .etikett {
    width: 70mm; height: 37mm; padding: 2.5mm 3mm;
    overflow: hidden; text-align: center; color: #000;
    display: flex; flex-direction: column; justify-content: center;
    break-inside: avoid;
  }
  .etikett .e-name {
    font-size: 10pt; font-weight: 600; line-height: 1.15;
    max-height: 9mm; overflow: hidden;
  }
  .etikett svg { max-width: 62mm; height: 16mm; margin: 1mm auto 0; }
}
