:root {
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --primary-dark: #1d4ed8;
  --bg: #f8fafc;
  --bg2: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --green: #16a34a;
  --green-light: #dcfce7;
  --orange: #ea580c;
  --orange-light: #fff7ed;
  --red: #dc2626;
  --red-light: #fef2f2;
  --sidebar-w: 220px;
  --bottom-nav-h: 64px;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

.hidden { display: none !important; }

/* Login */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); }
.login-card { background: var(--bg2); border-radius: 16px; padding: 40px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.login-logo { font-size: 48px; text-align: center; margin-bottom: 8px; }
.login-title { font-size: 22px; font-weight: 700; text-align: center; color: var(--text); }
.login-sub { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 28px; }

/* App layout */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-w); background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; }
.sidebar-header { padding: 20px 16px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.sidebar-icon { font-size: 24px; }
.sidebar-title { font-weight: 700; font-size: 15px; color: var(--text); }
.nav-list { list-style: none; padding: 12px 8px; flex: 1; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); cursor: pointer; color: var(--text-muted); font-size: 14px; font-weight: 500; margin-bottom: 2px; transition: background 0.15s, color 0.15s; }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary); color: white; }
.nav-section-divider { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); padding: 14px 12px 4px; opacity: .7; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
#nav-username { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.btn-logout { font-size: 12px; color: var(--text-muted); background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
.btn-logout:hover { color: var(--red); border-color: var(--red); }

/* Main content */
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px; min-height: 100vh; }

/* Mobile header (hidden on desktop) */
.mobile-header { display: none; }

/* Bottom nav (hidden on desktop) */
.bottom-nav { display: none; }

/* Sidebar overlay (mobile) */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 99; }
.sidebar-overlay.open { display: block; }

/* Responsive */
@media (max-width: 768px) {
  .mobile-header {
    display: flex; align-items: center; justify-content: space-between;
    position: fixed; top: 0; left: 0; right: 0; height: 52px;
    background: var(--bg2); border-bottom: 1px solid var(--border);
    padding: 0 16px; z-index: 98;
  }
  .mobile-header-logo { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
  .hamburger-btn {
    width: 40px; height: 40px; border: none; background: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--text);
  }
  .hamburger-btn svg { width: 22px; height: 22px; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 100;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }
  .main-content { margin-left: 0; padding: 16px 12px; padding-top: calc(52px + 16px); padding-bottom: 16px; }
  .bottom-nav { display: none; }
}

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; }

/* Cards */
.card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 16px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius); border: none; cursor: pointer; font-size: 14px; font-weight: 500; min-height: 44px; transition: opacity 0.15s; }
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--red-light); color: var(--red); border: 1px solid #fca5a5; }
.btn-success { background: var(--green-light); color: var(--green); border: 1px solid #86efac; }
.btn-sm { padding: 5px 10px; min-height: 32px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; color: var(--text); background: var(--bg2); min-height: 44px; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 12px; border-bottom: 2px solid var(--border); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* Badges */
.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-ok { background: var(--green-light); color: var(--green); }
.badge-warn { background: var(--orange-light); color: var(--orange); }
.badge-crit { background: var(--red-light); color: var(--red); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-gray { background: #f1f5f9; color: var(--text-muted); }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--bg2); border-radius: 12px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 17px; font-weight: 600; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); padding: 4px; min-height: 0; }
.modal-body { padding: 24px; }

/* Filters */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filter-bar .form-group { margin-bottom: 0; min-width: 140px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 16px; background: none; border: none; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; min-height: 44px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; text-align: center; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Search */
.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; }

/* Error */
.error-msg { color: var(--red); font-size: 13px; padding: 8px 12px; background: var(--red-light); border-radius: var(--radius); margin-bottom: 12px; }
.success-msg { color: var(--green); font-size: 13px; padding: 8px 12px; background: var(--green-light); border-radius: var(--radius); margin-bottom: 12px; }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }

/* Number input */
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }

/* Booking form */
.booking-form { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; align-items: flex-end; }
@media (max-width: 600px) { .booking-form { grid-template-columns: 1fr 1fr; } }

/* Color swatch */
.color-preview { width: 36px; height: 36px; border-radius: 6px; border: 2px solid var(--border); cursor: pointer; }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #cbd5e1; border-radius: 22px; cursor: pointer; transition: 0.2s; }
.slider:before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; top: 3px; background: white; border-radius: 50%; transition: 0.2s; }
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider:before { transform: translateX(18px); }

/* ── Touch / Schnellerfassung ─────────────────────────────────── */
#touch-root { display: flex; flex-direction: column; min-height: calc(100vh - 120px); }

.touch-header { display: flex; align-items: center; gap: 14px; padding-bottom: 16px; border-bottom: 2px solid var(--border); margin-bottom: 18px; flex-shrink: 0; }
.touch-step-label { font-size: 18px; font-weight: 700; color: var(--text); }
.touch-back-btn { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 18px; font-size: 15px; font-weight: 600; cursor: pointer; color: var(--text); white-space: nowrap; }
.touch-back-btn:active { background: var(--border); }

.touch-body { flex: 1; }

.touch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(304px, 1fr)); gap: 21px; }
.touch-grid-sm { grid-template-columns: repeat(auto-fill, minmax(266px, 1fr)); gap: 18px; }

.touch-tile { background: var(--bg2); border: 2px solid var(--border); border-radius: 18px; padding: 43px 27px; min-height: 191px; display: flex; flex-direction: column; align-items: center; justify-content: center; cursor: pointer; font-size: 29px; font-weight: 700; text-align: center; line-height: 1.3; color: var(--text); transition: border-color 0.1s, background 0.1s; user-select: none; -webkit-tap-highlight-color: transparent; }
.touch-tile:hover  { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.touch-tile:active { transform: scale(0.95); border-color: var(--primary); background: var(--primary-light); }
.touch-tile-dim  { color: var(--text-muted); border-style: dashed; }
.touch-tile-art  { min-height: 164px; gap: 8px; }
.touch-tile-warn { border-color: #fca5a5; background: var(--red-light); }
.touch-tile-warn:hover { border-color: var(--red); background: #fee2e2; color: var(--red); }

.touch-art-name    { font-size: 13px; font-weight: 700; line-height: 1.25; }
.touch-art-bestand { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.touch-art-bestand.warn { color: var(--red); }

.touch-empty { padding: 60px 20px; text-align: center; color: var(--text-muted); font-size: 16px; }

/* Numpad overlay */
.touch-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 300; display: flex; align-items: center; justify-content: center; padding: 16px; }
.touch-numpad-card { background: var(--bg2); border-radius: 18px; padding: 24px; width: 100%; max-width: 370px; box-shadow: 0 28px 80px rgba(0,0,0,0.35); }

.touch-art-info { text-align: center; margin-bottom: 16px; }
.touch-art-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.touch-art-sub   { font-size: 13px; color: var(--text-muted); }

.touch-display { font-size: 44px; font-weight: 800; text-align: center; padding: 14px 16px; border: 2px solid var(--border); border-radius: 12px; margin-bottom: 14px; background: var(--bg); letter-spacing: 2px; min-height: 80px; display: flex; align-items: center; justify-content: center; transition: border-color 0.2s; }

.touch-numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.touch-npad { font-size: 26px; font-weight: 700; padding: 16px 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); cursor: pointer; color: var(--text); user-select: none; -webkit-tap-highlight-color: transparent; }
.touch-npad:active  { background: var(--primary-light); border-color: var(--primary); }
.touch-npad-del { font-size: 20px; color: var(--text-muted); }

.touch-confirm-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.touch-btn-ein { padding: 18px 10px; font-size: 17px; font-weight: 800; border-radius: 12px; border: none; cursor: pointer; background: var(--green); color: white; letter-spacing: 0.3px; user-select: none; }
.touch-btn-ein:active { opacity: 0.85; transform: scale(0.97); }
.touch-btn-aus { padding: 18px 10px; font-size: 17px; font-weight: 800; border-radius: 12px; border: none; cursor: pointer; background: var(--red); color: white; letter-spacing: 0.3px; user-select: none; }
.touch-btn-aus:active { opacity: 0.85; transform: scale(0.97); }

.touch-cancel { width: 100%; padding: 10px; background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 14px; }
.touch-cancel:hover { color: var(--text); }

/* ── Café-Bestellungen (Bestellzettel-Layout) ──────────────────── */
.ib-page { display: flex; flex-direction: column; min-height: calc(100vh - 80px); }
.ib-topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.ib-content { flex: 1; }

.bestell-header-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px;
  position: sticky; top: 0; z-index: 50;
}

.bestell-columns {
  column-count: 2;
  column-gap: 16px;
}
@media (max-width: 900px) { .bestell-columns { column-count: 1; } }

.bestell-section {
  break-inside: avoid;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 14px;
  overflow: hidden;
}

.bestell-sec-header {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-muted);
  padding: 8px 14px; background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.bestell-row {
  display: grid; grid-template-columns: 1fr auto auto;
  align-items: center; gap: 8px;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.12s;
  min-height: 48px;
}
.bestell-row:last-child { border-bottom: none; }
.bestell-row:hover { background: var(--primary-light); }
.bestell-row:active { background: var(--primary-light); }
.bestell-row.has-qty { background: #ecfdf5; }
.bestell-row.has-qty .bestell-art-qty { color: var(--green); font-weight: 700; }

.bestell-art-name { font-size: 14px; font-weight: 500; }
.bestell-art-unit { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.bestell-art-qty {
  min-width: 36px; text-align: right;
  font-size: 15px; font-weight: 600; color: var(--text-muted);
}

/* Bottom-sheet numpad */
.ib-numpad {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 500;
  background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-end; justify-content: center;
  pointer-events: all;
}
.ib-numpad.hidden { display: none !important; }

.ib-numpad-inner {
  background: var(--bg2); border-radius: 20px 20px 0 0;
  padding: 20px 20px 32px;
  width: 100%; max-width: 420px;
  box-shadow: 0 -8px 40px rgba(0,0,0,0.18);
}

.ib-npad-top { margin-bottom: 14px; }
.ib-npad-label { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 6px; }
.ib-npad-display {
  font-size: 42px; font-weight: 800; text-align: center;
  padding: 10px 16px; border: 2px solid var(--border);
  border-radius: 12px; background: var(--bg);
  letter-spacing: 2px; min-height: 72px;
  display: flex; align-items: center; justify-content: center;
}

.ib-npad-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 8px; margin-bottom: 10px;
}
.ib-npad-btn {
  font-size: 24px; font-weight: 700;
  padding: 14px 8px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg);
  cursor: pointer; color: var(--text);
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.ib-npad-btn:active { background: var(--primary-light); border-color: var(--primary); }
.ib-npad-dot { font-size: 20px; color: var(--text-muted); }
.ib-npad-del { font-size: 18px; color: var(--text-muted); }

.ib-npad-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ib-npad-cancel {
  padding: 14px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; font-size: 15px; font-weight: 600;
  cursor: pointer; color: var(--text-muted);
}
.ib-npad-cancel:active { background: var(--border); }
.ib-npad-ok {
  padding: 14px; background: var(--green); border: none;
  border-radius: 10px; font-size: 15px; font-weight: 700;
  cursor: pointer; color: white;
}
.ib-npad-ok:active { opacity: 0.85; }
