/* Lagerverwaltung Grill au Bois
   Design: warmes Holz/Grill-Thema, hoher Kontrast, grosse Touch-Flaechen fuer
   die Bedienung mit Handy direkt am Lagerregal. */

:root {
  --kohle: #1f1a17;
  --holz: #5b3a29;
  --holz-hell: #8a5a3f;
  --glut: #c1440e;
  --glut-hell: #e8632a;
  --asche: #f4ede4;
  --papier: #fffaf3;
  --gruen: #4a7c3f;
  --rot: #c1272d;
  --rot-bg: #fbe3e0;
  --gelb-bg: #fff4d6;
  --rand: #e3d6c4;
  --text: #2c2521;
  --text-mute: #71665c;
  --radius: 12px;
  --schatten: 0 2px 8px rgba(31, 26, 23, 0.08);
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--asche);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--kohle);
  margin: 0 0 0.5em;
}

a { color: var(--glut); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

.container-narrow {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* --- Topbar (Admin) --- */
.topbar {
  background: var(--kohle);
  color: var(--papier);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.topbar .brand {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--papier);
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar .brand .dot { color: var(--glut-hell); }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  color: #e6dccf;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 500;
}
.topbar nav a:hover, .topbar nav a.active {
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-decoration: none;
}
.topbar .user {
  font-size: 0.85rem;
  color: #c8bba8;
  display: flex;
  align-items: center;
  gap: 10px;
}
.topbar .user a { color: #e6dccf; }

/* --- Karten / Boxen --- */
.card {
  background: var(--papier);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 22px;
  margin-bottom: 20px;
}

.grid {
  display: grid;
  gap: 16px;
}
.grid-lager {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.lager-kachel {
  display: block;
  background: var(--papier);
  border: 1px solid var(--rand);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--schatten);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}
.lager-kachel:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(31,26,23,0.12);
  text-decoration: none;
}
.lager-kachel h3 {
  margin-bottom: 6px;
  font-size: 1.15rem;
}
.lager-kachel .anzahl-artikel {
  color: var(--text-mute);
  font-size: 0.88rem;
}
.lager-kachel .warnbadge {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--rot);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
}

/* --- Tabellen --- */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.93rem;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--rand);
  vertical-align: middle;
}
th {
  color: var(--text-mute);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fbf6ee;
}
tr.bestand-niedrig td { background: var(--rot-bg); }
tr.bestand-niedrig .bestand-zahl { color: var(--rot); font-weight: 700; }
.bestand-zahl { font-weight: 600; }
.tag-ok { color: var(--gruen); font-weight: 600; font-size: 0.85rem; }
.tag-niedrig {
  color: var(--rot);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table-scroll { overflow-x: auto; }

/* --- Formulare --- */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-mute);
  margin-bottom: 6px;
}
input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--rand);
  border-radius: 9px;
  font-size: 1rem;
  font-family: var(--font-body);
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--glut-hell);
  outline-offset: 1px;
  border-color: var(--glut-hell);
}
.form-row { margin-bottom: 16px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 9px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  text-decoration: none;
  line-height: 1.2;
}
.btn-glut { background: var(--glut); color: #fff; }
.btn-glut:hover { background: #a83a0c; }
.btn-dunkel { background: var(--kohle); color: #fff; }
.btn-dunkel:hover { background: #322a25; }
.btn-outline { background: transparent; border: 1px solid var(--rand); color: var(--text); }
.btn-outline:hover { background: #f4ede4; }
.btn-gruen { background: var(--gruen); color: #fff; }
.btn-gruen:hover { background: #3c6432; }
.btn-rot { background: var(--rot); color: #fff; }
.btn-rot:hover { background: #9e2024; }
.btn-block { width: 100%; }
.btn-lg { padding: 18px 24px; font-size: 1.15rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 0.85rem; }

.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- Badges / Hinweise --- */
.alert {
  padding: 14px 16px;
  border-radius: 9px;
  margin-bottom: 18px;
  font-size: 0.92rem;
}
.alert-error { background: var(--rot-bg); color: #7a1c20; border: 1px solid #e7b9b6; }
.alert-success { background: #e3f0e0; color: #2c5024; border: 1px solid #bcdcb3; }
.alert-success-entnahme { background: #fbe3e0; color: #7a1c20; border: 1px solid #e7b9b6; }
.alert-info { background: var(--gelb-bg); color: #6b5212; border: 1px solid #ecd99a; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: #ece1d2;
  color: var(--holz);
  font-size: 0.78rem;
  font-weight: 600;
}

/* --- Login --- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--kohle), #3a2c24);
  padding: 20px;
}
.login-box {
  background: var(--papier);
  border-radius: 16px;
  padding: 38px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}
.login-box h1 {
  font-size: 1.5rem;
  text-align: center;
  margin-bottom: 4px;
}
.login-box .sub {
  text-align: center;
  color: var(--text-mute);
  font-size: 0.9rem;
  margin-bottom: 26px;
}

/* --- Scan-Seite (mobil, kein Login) --- */
.scan-header {
  background: var(--kohle);
  color: var(--papier);
  padding: 18px 20px;
  text-align: center;
}
.scan-header .lager-name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
}
.scan-header .lager-wechseln {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.85rem;
  color: #d8cbb8;
}

.scan-card {
  background: var(--papier);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 22px;
  margin: 16px;
}

.scan-action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 18px 16px;
}
.scan-action-btn {
  padding: 22px 10px;
  border-radius: var(--radius);
  border: 3px solid transparent;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-display);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  position: relative;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  background: #ece5da;
  color: #9c8f7d;
  transform: scale(0.96);
  box-shadow: none;
}
.scan-action-btn .icon { font-size: 1.8rem; }
.scan-action-btn .check {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 1rem;
  display: none;
}

/* Aktiv gewaehlte Aktion: kraeftig, groesser, mit Haken */
.scan-action-btn.gewaehlt {
  transform: scale(1);
  box-shadow: 0 4px 14px rgba(31,26,23,0.18);
}
.scan-action-btn.gewaehlt .check { display: inline; }
.scan-action-btn.aktiv-ein.gewaehlt {
  background: var(--gruen);
  color: #fff;
  border-color: #2c5024;
}
.scan-action-btn.aktiv-aus.gewaehlt {
  background: var(--rot);
  color: #fff;
  border-color: #7a1c20;
}

.scan-result {
  margin: 0 16px 16px;
}

.artikel-info {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.artikel-info .name { font-weight: 700; font-size: 1.05rem; }
.artikel-info .bestand { font-size: 1.4rem; font-weight: 800; }

.aktion-hinweis {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  margin: 10px 0;
}
.aktion-hinweis .hinweis-ein { color: var(--gruen); }
.aktion-hinweis .hinweis-aus { color: var(--rot); }

.menge-stepper {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  margin: 18px 0;
}
.menge-stepper button {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid var(--rand);
  background: #fff;
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--kohle);
}
.menge-stepper .menge-zahl {
  font-size: 2rem;
  font-weight: 800;
  min-width: 60px;
  text-align: center;
  font-family: var(--font-display);
}

.scan-video-wrap {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  margin: 12px 16px;
}
.scan-video-wrap video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.scan-video-wrap #reader {
  width: 100%;
  height: 100%;
}
.scan-video-wrap #reader video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
}
.scan-video-wrap #reader__scan_region {
  width: 100% !important;
  height: 100% !important;
}
.scan-video-wrap #reader__dashboard {
  display: none !important;
}
.scan-video-wrap .scan-frame {
  position: absolute;
  top: 50%; left: 50%;
  width: 65%; height: 55%;
  transform: translate(-50%, -50%);
  border: 3px solid var(--glut-hell);
  border-radius: 10px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,0.35);
}

.manual-ean-toggle {
  text-align: center;
  margin: 10px 16px 0;
  font-size: 0.88rem;
}

footer.app-footer {
  text-align: center;
  color: var(--text-mute);
  font-size: 0.8rem;
  padding: 30px 16px;
}

/* --- Utility --- */
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-mute { color: var(--text-mute); }
.text-center { text-align: center; }
.hidden { display: none !important; }

@media (max-width: 640px) {
  .container { padding: 16px 12px 50px; }
  .card { padding: 16px; }
  th, td { padding: 8px 8px; font-size: 0.85rem; }
}