:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --line: #e2e6ec;
  --text: #1c2430;
  --muted: #6b7684;
  --accent: #1e8e5a;
  --accent-dark: #166b44;
  --danger: #d9534f;
  --warn: #e0a030;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 17px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}
button { font: inherit; cursor: pointer; }
input, select { font: inherit; }

.app {
  display: grid;
  grid-template-columns: 1fr 400px;
  height: 100vh;
}

/* ---------------------------------------------------------------- catalogus */
.catalog { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; margin: 0; white-space: nowrap; }
.search { flex: 1; }
.search input {
  width: 100%; padding: 12px 16px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); outline: none;
}
.search input:focus { border-color: var(--accent); background: #fff; }
.clock { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.breadcrumb { padding: 14px 18px 0; font-size: 22px; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 18px 0; }
.chip {
  padding: 10px 18px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--text);
}
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }

.grid {
  flex: 1; overflow-y: auto;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  align-content: start;
}
.grid.categories { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

.tile {
  background: var(--panel);
  border: none; border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0; text-align: left; overflow: hidden;
  display: flex; flex-direction: column;
  color: var(--text);
  transition: transform .08s;
}
.tile:active { transform: scale(.97); }

.tile.cat {
  min-height: 140px; justify-content: flex-end;
  padding: 16px; color: #fff;
  position: relative;
}
.tile.cat .icon { font-size: 44px; line-height: 1; margin-bottom: 8px; }
.tile.cat .name { font-size: 19px; font-weight: 600; }
.tile.cat .count { position: absolute; top: 12px; right: 14px; font-size: 13px; opacity: .85; }

.tile.prod img { width: 100%; aspect-ratio: 1; display: block; padding: 10px 10px 0; }
.tile.prod .body { padding: 8px 12px 12px; }
.tile.prod .name { font-size: 15px; line-height: 1.25; min-height: 2.5em; }
.tile.prod .price { font-weight: 700; font-size: 17px; margin-top: 4px; }
.tile.prod .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tile.prod .tag {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 2px 6px; border-radius: 6px; margin-right: 4px;
}
.tag.age { background: #fde8e8; color: var(--danger); }
.tag.stg { background: #e8f3ff; color: #2b6cb0; }
.tag.low { background: #fff4e0; color: #b06d00; }

.empty { grid-column: 1 / -1; color: var(--muted); padding: 40px; text-align: center; }

/* ---------------------------------------------------------------- winkelwagen */
.cart {
  display: flex; flex-direction: column;
  background: var(--panel);
  border-left: 1px solid var(--line);
  min-height: 0;
}
.cart-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.cart-head h2 { margin: 0; font-size: 20px; }
.badge { background: var(--bg); border-radius: 999px; padding: 4px 12px; font-size: 14px; color: var(--muted); }

.cart-lines { flex: 1; overflow-y: auto; padding: 8px 12px; }
.cart-empty { color: var(--muted); text-align: center; padding: 40px 10px; }

.line {
  display: grid; grid-template-columns: 1fr auto;
  gap: 4px 10px; padding: 10px 6px;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.line .name { font-weight: 600; font-size: 15px; }
.line .sub { font-size: 13px; color: var(--muted); }
.line .amount { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.line .qty { display: flex; align-items: center; gap: 6px; grid-column: 1 / -1; }
.qty button {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); font-size: 20px;
}
.qty .n { min-width: 34px; text-align: center; font-weight: 600; }
.qty .del { margin-left: auto; color: var(--danger); background: #fff; }

.totals { padding: 10px 18px; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.totals .row { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .row.small { font-size: 13px; color: var(--muted); flex-direction: column; }
.totals .row.small div { display: flex; justify-content: space-between; }
.totals .row.total { font-size: 26px; font-weight: 700; padding-top: 8px; }

.cart-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; padding: 0 18px 14px; }

.btn {
  padding: 12px 18px; border-radius: 12px; border: none;
  background: var(--text); color: #fff; font-weight: 600;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn-ghost { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.btn-primary { background: var(--accent); }
.btn-pay { background: var(--accent); font-size: 20px; padding: 18px; }
.btn-pay:not(:disabled):active { background: var(--accent-dark); }
.btn-small { padding: 8px 14px; }

.scan-sim { border-top: 1px dashed var(--line); padding: 8px 18px 12px; font-size: 14px; background: #fafbfc; }
.scan-sim summary { cursor: pointer; color: var(--muted); }
.scan-sim .hint { color: var(--muted); font-size: 12px; margin: 6px 0; }
.sim-row { display: flex; gap: 8px; }
.sim-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.scan-sim select { width: 100%; margin-top: 8px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }

/* ---------------------------------------------------------------- modals */
.overlay {
  position: fixed; inset: 0; background: rgba(20,26,34,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--panel); border-radius: 20px; padding: 28px;
  width: min(520px, 92vw); max-height: 92vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  text-align: center;
}
.modal h3 { margin: 10px 0 6px; font-size: 24px; }
.modal p { color: var(--muted); margin: 0 0 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.modal-actions .btn { min-width: 160px; padding: 14px 20px; }
.modal-icon {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 800; color: #fff;
}
.modal-icon.warn { background: var(--danger); }
.modal-icon.ok { background: var(--accent); font-size: 40px; }

.terminal { margin: 0 auto; width: 300px; }
.terminal-screen {
  background: #1b2a3a; color: #dfe9f3; border-radius: 16px;
  padding: 26px 20px; min-height: 190px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  font-family: "Consolas", monospace;
}
.term-amount { font-size: 34px; font-weight: 700; color: #fff; }
.term-msg { font-size: 16px; }
.terminal-label { color: var(--muted); font-size: 13px; margin-top: 10px; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.2); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- bon */
.receipt {
  font-family: "Consolas", "Courier New", monospace; font-size: 13px;
  text-align: left; background: #fffdf5; border: 1px solid #eee;
  padding: 16px 18px; margin: 12px auto 0; width: 320px;
  white-space: pre; line-height: 1.45; color: #222;
}
.receipt .c { text-align: center; }

@media print {
  body * { visibility: hidden; }
  .receipt, .receipt * { visibility: visible; }
  .receipt { position: absolute; left: 0; top: 0; border: none; background: #fff; width: 72mm; }
}

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--text); color: #fff; padding: 12px 22px; border-radius: 999px;
  box-shadow: var(--shadow); z-index: 60; font-weight: 600;
}
.toast.error { background: var(--danger); }
