:root {
  --bg: #f1f4f8;
  --card: #ffffff;
  --text: #16202c;
  --muted: #5b6878;
  --line: #d9e0e8;
  --brand: #1e3a5f;
  --primary: #2563eb;
  --ok: #15803d;
  --danger: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
body.no-scroll { overflow: hidden; }
a { color: var(--primary); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- Bovenbalk ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--brand); color: #fff;
  padding: .6rem 1rem; padding-top: max(.6rem, env(safe-area-inset-top));
}
.brand { font-weight: 700; font-size: 1.1rem; margin-right: auto; }
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.topbar nav a {
  color: #dbe7f5; text-decoration: none; padding: .45rem .75rem; border-radius: 8px; font-weight: 500;
}
.topbar nav a:hover { background: rgba(255,255,255,.1); }
.topbar nav a.active { background: rgba(255,255,255,.18); color: #fff; }

.flash { margin: .75rem 1rem; padding: .75rem 1rem; border-radius: 10px; background: #dcfce7; color: #14532d; }
.flash.err { background: #fee2e2; color: #7f1d1d; }
.card .flash { margin: 0 0 1rem; }

/* ---------- Knoppen en formulieren ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: .6rem 1rem; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  min-height: 44px; touch-action: manipulation;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.big { padding: .85rem 1.2rem; font-size: 1.1rem; min-height: 54px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok-outline { border-color: var(--ok); color: var(--ok); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { border-color: #f1b4b4; color: var(--danger); }
.btn.small { padding: .3rem .6rem; min-height: 34px; font-size: .9rem; }

.form { display: grid; gap: 1rem; }
.form label { display: grid; gap: .3rem; font-weight: 600; }
.form .hint { font-weight: 400; color: var(--muted); font-size: .9rem; }
input[type=text], input[type=password], input[type=date], select {
  font: inherit; padding: .6rem .7rem; border: 1px solid #b9c4d0; border-radius: 9px;
  background: #fff; color: var(--text); width: 100%; min-height: 44px;
}
input:focus, select:focus, .btn:focus-visible { outline: 3px solid #93c5fd; outline-offset: 1px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.narrow { max-width: 440px; margin: 2rem auto; }
.page { max-width: 1100px; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }

/* ---------- Kassa ---------- */
.kassa {
  display: grid; grid-template-columns: 1fr 340px; gap: 1rem;
  padding: 1rem; align-items: start;
}
.grid {
  display: grid; gap: .75rem;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
@media (min-width: 801px) {
  .tile { min-height: 150px; }
  .tile-name { font-size: 1.35rem; }
  .tile-price { font-size: 1.2rem; }
}
.tile-wrap { position: relative; }
.tile {
  --c: #2563eb;
  width: 100%; min-height: 120px; border: 0; border-radius: var(--radius);
  background: var(--c); color: #fff; cursor: pointer; text-align: left;
  padding: .9rem; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow); touch-action: manipulation; user-select: none;
  -webkit-tap-highlight-color: transparent; transition: transform .06s;
}
.tile:active { transform: scale(.97); }
.tile-name { font-size: 1.15rem; font-weight: 700; line-height: 1.2; padding-right: 2.2rem; word-break: break-word; }
.tile-price { font-size: 1.05rem; opacity: .95; font-weight: 600; }
.tile-qty {
  position: absolute; top: .55rem; right: .55rem; min-width: 2.2rem; height: 2.2rem; padding: 0 .45rem;
  border-radius: 1.1rem; background: #fff; color: var(--text); font-weight: 800; font-size: 1.15rem;
  display: none; align-items: center; justify-content: center;
}
.tile-minus {
  position: absolute; bottom: .5rem; right: .5rem; width: 2.6rem; height: 2.6rem;
  border-radius: 50%; border: 0; background: rgba(255,255,255,.95); color: var(--text);
  font-size: 1.5rem; font-weight: 700; line-height: 1; cursor: pointer; display: none;
  touch-action: manipulation;
}
.tile-wrap.has .tile-qty, .tile-wrap.has .tile-minus { display: flex; align-items: center; justify-content: center; }
.tile-wrap.has .tile { outline: 4px solid rgba(0,0,0,.25); outline-offset: -4px; }
.empty { padding: 1rem; }

.order {
  position: sticky; top: 1rem; background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1rem; display: grid; gap: .75rem;
}
.lines { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; max-height: 45vh; overflow: auto; }
.lines li { display: grid; grid-template-columns: 2.6rem 1fr auto; gap: .5rem; align-items: baseline; }
.lines .l-qty { font-weight: 700; }
.lines .l-sum { font-variant-numeric: tabular-nums; }
.lines:empty::before { content: "Tik op een artikel om te beginnen."; color: var(--muted); }
.lines.small { font-size: .95rem; max-height: 22vh; }
.order-total { display: flex; justify-content: space-between; align-items: baseline; border-top: 2px solid var(--line); padding-top: .6rem; }
.order-total strong { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.order-actions { display: grid; grid-template-columns: auto 1fr; gap: .5rem; }

@media (max-width: 800px) {
  .kassa { grid-template-columns: 1fr; padding: .6rem .6rem 9.5rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .55rem; }
  .tile { min-height: 105px; }
  .order {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; border-radius: 16px 16px 0 0;
    padding: .7rem .8rem; padding-bottom: max(.7rem, env(safe-area-inset-bottom)); gap: .5rem;
    box-shadow: 0 -4px 16px rgba(0,0,0,.12); z-index: 5;
  }
  .order .lines { display: none; }
  .order-total { border: 0; padding: 0; }
  .order-total strong { font-size: 1.5rem; }
}

/* ---------- Betaalscherm ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20; background: rgba(10, 20, 35, .65);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.paybox {
  background: #fff; border-radius: 18px; width: min(980px, 100%); max-height: 100%; overflow: auto;
  display: grid; grid-template-columns: auto 1fr; gap: 1.5rem; padding: 1.5rem;
}
.pay-qr { display: grid; justify-items: center; gap: .6rem; align-content: start; }
.pay-amount { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.qr-wrap {
  /* Groot en puur wit: makkelijk te scannen */
  width: min(46vw, 70vh, 480px); aspect-ratio: 1; padding: 0; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; cursor: zoom-in; overflow: hidden;
}
.qr-wrap svg, .qrfull-code svg { display: block; width: 100%; height: 100%; shape-rendering: crispEdges; }
.qr-msg { background: #fef3c7; color: #78350f; padding: 1rem; border-radius: 10px; max-width: 360px; }
.pay-hint { margin: 0; text-align: center; color: var(--muted); }
.pay-side { display: grid; gap: 1rem; align-content: start; }
.pay-meta { display: grid; gap: .2rem; }
.pay-meta b { word-break: break-all; }
.cash { display: grid; gap: .4rem; background: var(--bg); border-radius: 10px; padding: .75rem; }
.cash label { display: grid; gap: .25rem; font-weight: 600; }
.cash b { font-size: 1.2rem; }
.pay-actions { display: grid; gap: .5rem; }

@media (max-width: 800px) {
  .overlay { padding: 0; align-items: stretch; }
  .paybox { border-radius: 0; grid-template-columns: 1fr; gap: 1rem; padding: 1rem; padding-top: max(1rem, env(safe-area-inset-top)); }
  .qr-wrap { width: min(88vw, 58vh); }
  .pay-amount { font-size: 2.2rem; }
}

/* Schermvullende QR */
.qrfull {
  position: fixed; inset: 0; z-index: 30; background: #fff; color: #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
  padding: 1rem; cursor: zoom-out;
}
.qrfull-amount { font-size: 2.4rem; font-weight: 800; }
.qrfull-code { width: min(96vw, 82vh); aspect-ratio: 1; }
.qrfull-hint { color: #555; }

.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 40;
  background: #14532d; color: #fff; padding: .8rem 1.2rem; border-radius: 10px; font-weight: 600;
  box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: calc(100vw - 2rem);
}
.toast.err { background: #7f1d1d; }
@media (max-width: 800px) { .toast { bottom: 9rem; } }

/* ---------- Beheer en verkopen ---------- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: .5rem .55rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .85rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.art-table input[type=text] { min-width: 7rem; }
.art-table .price { width: 6.5rem; min-width: 0; }
.swatch { display: inline-block; width: 1rem; height: 1rem; border-radius: 4px; vertical-align: middle; }
.row-new td { background: #f8fafc; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.stat .v { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .k { color: var(--muted); font-size: .9rem; }
.filters { display: flex; flex-wrap: wrap; gap: .75rem; align-items: end; }
.filters label { display: grid; gap: .25rem; font-weight: 600; font-size: .9rem; }
.badge { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .85rem; font-weight: 700; }
.badge.paid { background: #dcfce7; color: #14532d; }
.badge.open { background: #fef3c7; color: #78350f; }
.badge.cancelled { background: #e5e7eb; color: #374151; text-decoration: line-through; }
.inline { display: inline; }
.actions { display: flex; gap: .3rem; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }
.preview-qr { width: 220px; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.center-page main { margin-top: 3rem; }
