:root {
  --bg: #0f1720;
  --panel: #17212b;
  --panel-2: #1e2a37;
  --text: #e8eef4;
  --muted: #93a3b3;
  --brand: #3ba7ff;
  --ok: #35c17a;
  --warn: #f2b705;
  --danger: #e5484d;
  --border: #2a3947;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

header.topbar h1 {
  font-size: 18px;
  margin: 0;
}

header.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 16px;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 6px;
  transition: all 0.2s;
}

header.topbar nav a:hover {
  color: var(--text);
  background: var(--panel-2);
}

header.topbar nav a[href="/kiosk"] {
  background: var(--brand);
  color: #04121f;
  font-weight: 700;
}

main {
  width: 100%;
  margin: 0;
  padding: 20px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}

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

.stat {
  background: var(--panel-2);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat .value { font-size: 28px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; margin-top: 4px; }

.ok { color: var(--ok); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

th { color: var(--muted); font-weight: 600; }

button, .btn {
  background: var(--brand);
  color: #04121f;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.danger { background: var(--danger); color: white; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

input, select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  background: var(--panel-2);
  padding: 8px;
  border-radius: var(--radius);
}

.tabs button {
  background: transparent;
  color: var(--muted);
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
}

.tabs button.active {
  background: var(--brand);
  color: #04121f;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  max-width: 320px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.4);
  z-index: 999;
}

.door-status.closed { color: var(--ok); }
.door-status.open { color: var(--warn); }
.stat.warn-glow { border: 2px solid var(--warn); box-shadow: 0 0 15px rgba(242, 183, 5, 0.3); }
.stat.danger-glow { border: 2px solid var(--danger); opacity: 0.8; }

.kiosk-nav-button {
  background: var(--brand) !important;
  color: #04121f !important;
  font-weight: 800 !important;
  border: 2px solid white !important;
}

/* ===================================================
   Kiosk state screens
   =================================================== */

.banner {
  position: sticky;
  top: 0;
  z-index: 500;
  padding: 12px 20px;
  text-align: center;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.banner.danger { background: var(--danger); color: white; }
.banner.warn { background: var(--warn); color: #201800; }

.kiosk-screen {
  display: none;
  width: 100%;
  margin: 0;
  padding: 32px;
  min-height: 100vh;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.kiosk-screen.active { display: block; }
/* Per ID gesetztes display wuerde .kiosk-screen { display: none } schlagen -
   diese Screens daher nur im aktiven Zustand als Flexbox. */
#screen-idle.active, #screen-pin.active, #screen-message.active { display: flex; }

#screen-idle {
  text-align: center;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.idle-clock {
  font-size: clamp(80px, 20vw, 160px);
  font-weight: 800;
  margin: 20px 0 0;
  color: var(--brand);
  text-shadow: 0 0 30px rgba(59, 167, 255, 0.2);
}

.idle-hint {
  color: var(--muted);
  font-size: 28px;
  margin-bottom: 50px;
  font-weight: 500;
  letter-spacing: 1px;
}

.kiosk-screen .card {
  width: 100%;
  max-width: 900px;
  background: var(--panel-2);
  border: 2px solid var(--border);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.select-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  background: var(--panel);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.select-header h2 { margin: 0 0 10px 0; font-size: 32px; }
.select-header .badge { margin-right: 12px; font-size: 18px; padding: 10px 20px; font-weight: 700; }

.drink-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.drink-tile {
  background: var(--panel-2);
  border: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 30px 15px;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.drink-tile:active { transform: scale(0.92); background-color: var(--panel); }
.drink-tile:not(.disabled):hover { border-color: var(--brand); transform: translateY(-5px); box-shadow: 0 5px 15px rgba(59, 167, 255, 0.2); }

.drink-tile.disabled {
  opacity: 0.2;
  filter: grayscale(1);
  cursor: not-allowed;
}

.drink-name { font-size: 24px; font-weight: 800; line-height: 1.1; margin-bottom: 4px; }
.drink-price { font-size: 20px; color: var(--brand); font-weight: 700; }
.drink-stock { color: var(--muted); font-size: 14px; font-weight: 600; }
.drink-qty { font-size: 32px; font-weight: 900; color: var(--ok); min-height: 38px; }

.select-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel);
  padding: 24px 40px;
  display: flex;
  align-items: center;
  gap: 20px;
  justify-content: flex-end;
  border-top: 2px solid var(--border);
  box-shadow: 0 -10px 30px rgba(0,0,0,0.5);
  z-index: 100;
}

.cart-total {
  margin-right: auto;
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
}

.select-footer button { font-size: 22px; padding: 18px 36px; border-radius: 12px; }
.select-footer button#confirm-btn { background: var(--ok); color: white; }

#screen-pin {
  text-align: center;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

#screen-pin h2 { font-size: 36px; margin-bottom: 10px; }

.pin-display {
  font-size: 60px;
  letter-spacing: 15px;
  min-height: 80px;
  margin: 20px 0 40px;
  color: var(--brand);
  background: var(--panel);
  padding: 10px 40px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: inline-block;
}

.keypad {
  display: block !important;
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

.keypad button {
  display: inline-block !important;
  width: 30% !important;
  margin: 5px !important;
  font-size: 36px;
  padding: 30px 0;
  border-radius: 20px;
  background: var(--panel-2);
  color: var(--text);
  border: 3px solid var(--border);
  font-weight: 800;
  transition: all 0.1s;
}

.keypad button:active { background: var(--brand); color: #04121f; border-color: var(--brand); transform: scale(0.95); }
.keypad button.ok { background: var(--ok); color: white; border-color: var(--ok); }
.keypad button.secondary { background: var(--panel); border-color: var(--border); }

#screen-message {
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  text-align: center;
  padding: 40px;
}

#message-text {
  font-size: 64px;
  font-weight: 900;
  padding: 60px;
  border-radius: 30px;
  background: var(--panel);
  border: 4px solid var(--border);
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  max-width: 800px;
}

#message-text.ok { color: var(--ok); }
#message-text.danger { color: var(--danger); }

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f7fa;
    --panel: #ffffff;
    --panel-2: #f0f3f6;
    --text: #16222d;
    --muted: #5b6b7a;
    --border: #dfe6ec;
  }
}

/* ===================================================
   Tabellen: horizontal scrollbar statt Seiten-Overflow
   =================================================== */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-wrap table {
  min-width: 480px;
}

/* ===================================================
   Mobile (Handy-Bildschirm)
   =================================================== */

@media (max-width: 720px) {

  main {
    padding: 12px;
  }

  header.topbar {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 6px;
  }

  header.topbar nav a {
    margin-left: 0;
    margin-right: 14px;
  }

  .tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }

  .tabs button {
    flex: 0 0 auto;
  }

  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .row input,
  .row select,
  .row button {
    width: 100%;
  }

  .grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .select-footer {
    flex-wrap: wrap;
  }

  .drink-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

/* Kiosk: Restzeit-Balken und Minus-Button im Warenkorb */
.select-timer { height: 6px; background: rgba(127,127,127,0.25); border-radius: 3px; overflow: hidden; margin: 8px 0 12px; }
#select-timer-bar { height: 100%; width: 100%; background: var(--brand); }
.drink-tile { position: relative; }
.drink-minus { position: absolute; top: 6px; left: 6px; width: 44px; height: 44px; padding: 0; border-radius: 50%; font-size: 1.6rem; line-height: 1; }
