:root {
  --purple: #572978;
  --purple-dark: #3d1c56;
  --purple-tint: #f2ecf7;
  --orange: #f05426;
  --orange-dark: #d1421a;
  --yellow: #ffc22e;
  --yellow-dark: #e0a300;
  --teal: #75cbc7;
  --teal-dark: #3d8f8a;
  --bg: #f6f3fa;
  --card: #ffffff;
  --border: #e5deed;
  --text: #2a1f3d;
  --text-muted: #7d7290;
  --danger: #d6394a;
  --success: #2f9d72;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(87, 41, 120, 0.09);
  --tap-min: 48px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Exo 2', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--purple);
  color: #fff;
  flex: 0 0 auto;
}

.brand-logo {
  height: 34px;
  width: auto;
  display: block;
}

.topbar-actions { display: flex; gap: 10px; align-items: center; }

.register-badge {
  font-weight: 700;
  gap: 6px;
}
.register-badge span {
  font-weight: 600;
  opacity: 0.75;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  min-height: var(--tap-min);
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.05s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:active { transform: scale(0.97); }
.btn-ghost {
  background: rgba(255,255,255,0.14);
  color: #fff;
  text-decoration: none;
}
.btn-ghost:hover { background: rgba(255,255,255,0.22); }
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); }
.btn-primary:disabled { background: #ded6e8; color: #a49bb8; cursor: not-allowed; }
.btn-text { background: transparent; color: var(--text-muted); }
.btn-text:hover { color: var(--danger); }
.btn-block { width: 100%; margin-top: 8px; padding: 16px; font-size: 16px; min-height: 54px; }

/* Main layout */
.main {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

.menu-pane {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 14px 16px;
}

.cart-pane {
  flex: 0 0 380px;
  background: var(--card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Category tabs */
.category-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  flex: 0 0 auto;
}

.cat-tab {
  flex: 0 0 auto;
  border: 2px solid var(--purple);
  background: #fff;
  color: var(--purple);
  border-radius: 999px;
  padding: 13px 24px;
  min-height: var(--tap-min);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.cat-tab.active {
  background: var(--purple);
  color: #fff;
}

/* Toolbar */
.menu-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex: 0 0 auto;
}

#searchBox {
  flex: 1 1 auto;
  padding: 12px 14px;
  min-height: var(--tap-min);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
}
#searchBox:focus { outline: 2px solid var(--teal); }

.sort-toggle {
  display: flex;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  flex: 0 0 auto;
}
.sort-btn {
  border: none;
  background: transparent;
  padding: 12px 16px;
  min-height: var(--tap-min);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  border-left: 1px solid var(--border);
}
.sort-btn:first-child { border-left: none; }
.sort-btn.active { background: var(--teal); color: #fff; }

/* Product grid */
.product-grid {
  flex: 1 1 auto;
  overflow-y: auto;
  padding-right: 4px;
  padding-bottom: 20px;
}

.producer-heading {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--teal-dark);
  margin: 18px 4px 8px;
}
.producer-heading:first-child { margin-top: 4px; }

.grid-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 4px;
}

.product-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  box-shadow: var(--shadow);
  min-height: 86px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
}

.product-card .p-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
}
.product-card .p-note {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.variant-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.variant-btn {
  border: 1.5px solid var(--purple);
  background: #fff;
  color: var(--purple);
  border-radius: 9px;
  padding: 10px 12px;
  min-height: 52px;
  min-width: 92px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}
.variant-btn:active { background: var(--purple); color: #fff; }
.variant-btn .v-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.75;
}

.no-results {
  padding: 40px 10px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}

/* Cart */
.cart-header {
  padding: 16px 18px 8px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex: 0 0 auto;
}
.cart-header h2 { margin: 0; font-size: 18px; }
.cart-count { font-size: 13px; color: var(--text-muted); font-weight: 600; }

.cart-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 4px 12px;
}

.cart-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 40px 16px;
  font-size: 14px;
}

.cart-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 4px 10px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--border);
}

.cart-item .reorder {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.reorder button {
  border: none;
  background: var(--purple-tint);
  color: var(--purple);
  width: 44px;
  height: 42px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1;
}
.reorder button:disabled { opacity: 0.3; }

.cart-item .ci-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}
.cart-item .ci-price {
  font-size: 12px;
  color: var(--text-muted);
  grid-column: 2;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 2;
  margin-top: 6px;
}
.qty-controls button {
  border: 1px solid var(--border);
  background: #fff;
  width: 44px;
  height: 44px;
  border-radius: 9px;
  font-size: 18px;
  font-weight: 700;
  color: var(--purple);
}
.qty-controls .qty-val { min-width: 26px; text-align: center; font-weight: 700; font-size: 15px; }

.ci-line-total {
  font-weight: 800;
  font-size: 14px;
  grid-row: 1 / span 2;
  text-align: right;
}
.ci-remove {
  grid-row: 1 / span 2;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
}
.ci-remove:active { background: rgba(214, 57, 74, 0.12); color: var(--danger); }

.cart-item-row2 {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cart-footer {
  flex: 0 0 auto;
  padding: 14px 18px 18px;
  border-top: 1px solid var(--border);
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 15px;
  margin-bottom: 12px;
}
.cart-total-row strong { font-size: 26px; color: var(--purple); }

.payment-select {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}
.pay-btn {
  flex: 1 1 0;
  border: 2px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 13px 8px;
  min-height: var(--tap-min);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.pay-btn.active {
  border-color: var(--teal);
  background: rgba(117, 203, 199, 0.16);
  color: var(--teal-dark);
}

/* Overlay / receipt */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(42, 31, 61, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.overlay.hidden { display: none; }

.receipt-card {
  background: #fff;
  border-radius: var(--radius);
  width: min(380px, 92vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#receiptBody {
  padding: 24px 22px;
  overflow-y: auto;
  font-size: 14px;
}
#receiptBody h3 { margin: 0 0 2px; color: var(--purple); }
#receiptBody .r-meta { color: var(--text-muted); font-size: 12.5px; margin-bottom: 14px; }
#receiptBody .r-line {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border);
}
#receiptBody .r-total {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  font-size: 17px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 2px solid var(--text);
}

.receipt-actions {
  display: flex;
  gap: 10px;
  padding: 14px 22px 20px;
  border-top: 1px solid var(--border);
}
.receipt-actions .btn { flex: 1 1 0; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--purple-dark);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 60;
}
.toast.hidden { display: none; }
.toast.error { background: var(--danger); }

/* Kassza (register) picker */
.register-picker {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 40px 24px;
  background: linear-gradient(160deg, var(--purple) 0%, #6b3a97 55%, var(--teal) 130%);
  text-align: center;
}
.register-logo { height: 46px; margin-bottom: 18px; }
.register-picker h1 { color: #fff; font-size: 26px; margin: 0 0 6px; }
.register-picker p { color: rgba(255,255,255,0.8); font-size: 15px; margin: 0 0 30px; max-width: 420px; }
.register-grid {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}
.register-btn {
  border: none;
  background: #fff;
  color: var(--purple);
  border-radius: 20px;
  padding: 36px 44px;
  min-width: 200px;
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transition: transform 0.08s ease;
}
.register-btn:active { transform: scale(0.96); }
.register-btn.is-current {
  background: var(--yellow);
  color: var(--purple-dark);
}

/* Responsive: stack cart under menu on narrow / portrait screens */
@media (max-width: 900px) {
  .main { flex-direction: column; }
  .cart-pane {
    flex: 0 0 auto;
    max-height: 46vh;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .menu-pane { flex: 1 1 auto; min-height: 0; }
}

@media print {
  .app, .toast { display: none !important; }
  .overlay { position: static; background: none; }
  .receipt-actions { display: none; }
  .receipt-card { box-shadow: none; width: 100%; }
}
