:root {
  --gelb: #F7E94B;
  --schwarz: #231f20;
  --blau: #38C2FA;
  --grau: #6b6b6b;
  --grau-hell: #ebebeb;
  --rot: #d62828;
  --gruen: #2a9d3f;
  --radius: 4px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: "News Cycle", "Helvetica Neue", Arial, sans-serif;
  background: #f7f7f7;
  color: var(--schwarz);
  font-size: 16px;
  line-height: 1.4;
}

a { color: var(--schwarz); }

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

/* Brand header */
.brand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--schwarz);
  padding: 8px 16px;
  color: var(--gelb);
}
.brand-logo svg { display: block; max-height: 48px; }
.jaku-logo { height: 48px; width: auto; }
.user-chip {
  color: var(--gelb);
  display: flex; gap: 8px; align-items: center;
}
.user-name { font-weight: 700; }
.user-rolle { font-size: 12px; opacity: 0.8; }
.btn-link {
  background: transparent; border: 1px solid var(--gelb);
  color: var(--gelb); padding: 6px 12px; border-radius: var(--radius); cursor: pointer;
  min-height: 44px;
}

/* Footer */
.legal-footer {
  margin-top: 32px;
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--grau);
  border-top: 1px solid var(--grau-hell);
  background: #fff;
}

/* Buttons */
button, .btn, .btn-primary, .btn-danger {
  font-family: inherit; font-size: 16px;
  min-height: 48px; min-width: 48px;
  padding: 10px 16px; cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--schwarz);
  background: #fff;
}
.btn-primary { background: var(--gelb); border-color: var(--schwarz); font-weight: 700; }
.btn-danger { background: var(--rot); color: #fff; border-color: #a01818; }
/* Bestaetigungs-Button im Modal: weniger massiv als die grossen
   Touch-Buttons der Kassenoberflaeche. */
.btn-confirm {
  font-family: inherit; font-size: 15px; font-weight: 700;
  min-height: 40px; padding: 6px 18px; cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid var(--schwarz);
  background: var(--gelb);
}
.btn:disabled, .btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* Inputs */
input[type="text"], input[type="search"], input[type="number"],
input[type="email"], input[type="date"], select, textarea {
  font-family: inherit; font-size: 16px;
  padding: 10px; min-height: 48px;
  border: 1px solid var(--schwarz); border-radius: var(--radius);
  background: #fff; width: 100%;
}

/* Tiles (Geraet / Mitarbeiter) */
.device-grid, .user-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.device-tile, .user-tile {
  text-align: left;
  background: #fff;
  border: 2px solid var(--schwarz);
  padding: 16px; border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 4px;
  cursor: pointer; min-height: 120px;
}
.device-tile .device-id, .user-tile .user-karten-nr {
  font-size: 24px; font-weight: 700;
}
.user-tile.rolle-admin { border-color: var(--blau); }
.user-tile.rolle-lager { border-color: #555; }
.user-tile .user-rolle {
  display: inline-block;
  background: var(--gelb); padding: 2px 6px;
  font-size: 12px; font-weight: 700;
  border-radius: 2px; align-self: flex-start;
}
.user-tile.rolle-admin .user-rolle { background: var(--blau); color: #fff; }
.user-tile.rolle-lager .user-rolle { background: var(--schwarz); color: var(--gelb); }

/* Kasse */
.kasse-toolbar { position: relative; margin-bottom: 16px; }
#scanner { width: 100%; font-size: 18px; }
.suggest {
  position: absolute; left: 0; right: 0; top: 100%;
  background: #fff; border: 1px solid var(--schwarz); border-top: none;
  list-style: none; margin: 0; padding: 0;
  max-height: 320px; overflow-y: auto; z-index: 5;
}
.suggest li { padding: 12px; border-bottom: 1px solid var(--grau-hell); cursor: pointer; min-height: 48px; }
.suggest li:hover, .suggest li.active { background: var(--gelb); }

.set-tiles {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px; margin-bottom: 16px;
}
.set-tile {
  background: var(--gelb); border: 2px solid var(--schwarz);
  padding: 12px; cursor: pointer; min-height: 80px;
  display: flex; flex-direction: column; justify-content: center;
}
.set-tile .set-name { font-weight: 700; }

.cart { width: 100%; border-collapse: collapse; background: #fff; }
.cart th, .cart td { padding: 12px; border-bottom: 1px solid var(--grau-hell); }
.cart th { background: var(--schwarz); color: var(--gelb); text-align: left; }
.cart .menge-control { display: inline-flex; align-items: center; gap: 4px; }
.cart .menge-control button { min-height: 36px; min-width: 36px; padding: 4px 10px; }

.totals {
  display: flex; gap: 24px; align-items: flex-end; flex-wrap: wrap;
  margin: 16px 0; background: #fff; padding: 16px;
  border: 1px solid var(--grau-hell);
}
.totals label { display: flex; flex-direction: column; min-width: 160px; font-weight: 700; }
.totals input { font-size: 18px; }
.totals-summary { margin-left: auto; font-size: 18px; }

.payment {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
  background: #fff; padding: 16px; border: 1px solid var(--grau-hell);
}
.payment fieldset { border: none; padding: 0; margin: 0; display: flex; gap: 16px; }
.payment label { display: flex; align-items: center; gap: 6px; cursor: pointer; min-height: 48px; }

/* Beleg detail */
.beleg-meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 16px 0; }
.beleg-meta dt { font-weight: 700; }
.beleg-pos { width: 100%; background: #fff; border-collapse: collapse; }
.beleg-pos th, .beleg-pos td { padding: 8px 12px; border-bottom: 1px solid var(--grau-hell); }
.beleg-pos thead th { background: var(--schwarz); color: var(--gelb); text-align: left; }
.beleg-pos tr.storno td { text-decoration: line-through; color: var(--grau); }
.beleg-pos tfoot td { font-weight: 700; padding-top: 16px; }
.beleg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* Kunden-QR-Vollbild-Overlay nach Beleg-Abschluss. */
.kunden-qr-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
  padding: 16px;
}
.kunden-qr-overlay[hidden] { display: none; }
.kunden-qr-card {
  background: #fff; padding: 24px; border-radius: 8px; text-align: center;
  max-width: 560px; box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.kunden-qr-card h2 { margin: 0 0 8px; }
.kunden-qr-card img { width: 100%; max-width: 480px; height: auto; image-rendering: pixelated; }
.kunden-qr-nr { font-family: monospace; color: var(--grau-hell); margin: 8px 0 16px; }

.storno-banner {
  background: var(--rot); color: #fff; padding: 12px 16px; font-weight: 700;
  text-align: center; letter-spacing: 1px; margin-bottom: 16px;
}

/* Lager */
.auftrag-list, .picking { width: 100%; border-collapse: collapse; background: #fff; margin-top: 16px; }
.auftrag-list th, .auftrag-list td, .picking th, .picking td { padding: 12px; border-bottom: 1px solid var(--grau-hell); text-align: left; }
.auftrag-list thead th, .picking thead th { background: var(--schwarz); color: var(--gelb); }
.auftrag-list tr.status-fertig { opacity: 0.6; }
.auftrag-list tr.status-in_bearbeitung { background: #fff7d6; }
.auftrag-list tr.beleg-storniert { background: #ffe6e6; }
.badge-storno { background: var(--rot); color: #fff; padding: 2px 6px; font-size: 11px; }
.picking .lagerplatz { font-weight: 700; font-size: 18px; }
.picking .ok { color: var(--gruen); font-weight: 700; }

/* Admin */
.admin-nav {
  display: flex; gap: 0; background: var(--schwarz); margin-bottom: 16px;
  border-radius: var(--radius); overflow: hidden;
}
.admin-tab {
  flex: 1; text-align: center; padding: 14px; color: var(--gelb);
  text-decoration: none; min-height: 48px;
}
.admin-tab.active { background: var(--gelb); color: var(--schwarz); font-weight: 700; }
.admin-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; align-items: center; }
.admin-toolbar > * { flex: none; }
.admin-toolbar input[type="search"] { flex: 1 1 200px; }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; max-width: 560px; width: 90%;
  padding: 24px; border-radius: var(--radius);
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin-top: 0; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }

/* Toast */
.toast {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--schwarz); color: var(--gelb);
  padding: 12px 24px; z-index: 60; border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.toast.error { background: var(--rot); color: #fff; }

/* Tabellen scrollbar auf kleinen Viewports */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-scroll table { min-width: 560px; }

/* Bar/Karte als direkte Abschluss-Buttons */
.btn-pay {
  flex: 1 1 200px; min-height: 64px; font-size: 20px; font-weight: 700;
  border: 2px solid var(--schwarz); color: var(--schwarz);
  border-radius: var(--radius); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.btn-pay:focus-visible { outline: 3px solid var(--blau); outline-offset: 2px; }
.btn-pay-bar   { background: var(--gelb); }
.btn-pay-karte { background: var(--blau); color: #fff; border-color: var(--blau); }
.btn-pay-bar:hover, .btn-pay-karte:hover { filter: brightness(1.05); }

/* Unlock-Screen */
.unlock-page {
  max-width: 420px; margin: 64px auto; padding: 24px;
  background: #fff; border: 2px solid var(--schwarz); border-radius: var(--radius);
}
.unlock-page h1 { margin-top: 0; }
.unlock-page form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.unlock-page .unlock-error {
  background: var(--rot); color: #fff; padding: 8px 12px; border-radius: var(--radius);
}

/* Tagesabschluss */
.tagesabschluss-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px;
}
.tagesabschluss-card {
  background: #fff; padding: 16px; border: 1px solid var(--grau-hell);
  border-radius: var(--radius);
}
.tagesabschluss-card h3 { margin-top: 0; }
.tagesabschluss-stat { font-size: 24px; font-weight: 700; }
.tagesabschluss-stat.gut { color: var(--gruen); }
.tagesabschluss-stat.fehlbetrag { color: var(--rot); }
.tagesabschluss-status {
  display: inline-block; padding: 4px 10px;
  border-radius: 2px; font-weight: 700; font-size: 12px;
}
.tagesabschluss-status.offen { background: var(--gelb); color: var(--schwarz); }
.tagesabschluss-status.abgeschlossen { background: var(--gruen); color: #fff; }

/* Tablet-Viewport */
@media (max-width: 768px) {
  .container { padding: 8px; }
  .brand-header { padding: 6px 10px; }
  .admin-nav { flex-wrap: wrap; }
  .admin-tab { flex: 1 1 33%; min-width: 33%; padding: 12px 6px; font-size: 14px; }
  .totals { flex-direction: column; gap: 12px; align-items: stretch; padding: 12px; }
  .totals label { min-width: 0; width: 100%; }
  .totals-summary { margin-left: 0; }
  .payment { flex-direction: column; align-items: stretch; gap: 12px; padding: 12px; }
  .set-tiles { grid-template-columns: 1fr 1fr; }
  .device-grid, .user-grid { grid-template-columns: 1fr 1fr; }
  .beleg-actions { flex-direction: column; align-items: stretch; }
  .tagesabschluss-grid { grid-template-columns: 1fr; }
  .admin-toolbar input[type="search"] { flex: 1 1 100%; }
}

/* Smartphone-Viewport */
@media (max-width: 480px) {
  .user-chip .user-rolle { display: none; }
  .brand-logo svg, .jaku-logo { max-height: 36px; height: 36px; }
  .admin-tab { flex: 1 1 50%; min-width: 50%; }
  .set-tiles, .device-grid, .user-grid { grid-template-columns: 1fr; }
  .modal { width: 96%; padding: 16px; max-height: 96vh; }
  button, .btn, .btn-primary, .btn-danger { min-height: 56px; font-size: 17px; }
  /* .btn-confirm bleibt absichtlich kompakt (Modal-Bestaetigung). */
  .btn-confirm { min-height: 40px; font-size: 15px; }
  .payment { flex-direction: column; }
  .btn-pay { width: 100%; }
  .cart .menge-control button { min-height: 44px; min-width: 44px; }
  h1 { font-size: 22px; }
  .unlock-page { margin: 16px auto; }
  /* Admin-Tabellen scrollbar machen (Tabellen werden via JS gerendert, daher CSS-Loesung) */
  .data-table { display: block; overflow-x: auto; white-space: nowrap; }
}
