:root {
  --bg: #f4f2ee;
  --card: #fff;
  --ink: #1f1d1a;
  --muted: #706b63;
  --line: #e2ded6;
  --accent: #2f6b3a;
  --accent-ink: #fff;
  --err: #b3261e;
  --ok: #2f6b3a;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 16px; line-height: 1.4; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
a { color: var(--accent); }
code { font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.center { text-align: center; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }

.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--ink); color: #fff; flex-wrap: wrap; }
.top .brand { color: #fff; font-weight: 700; text-decoration: none; font-size: 1.15em; }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.top nav a { color: #ddd; text-decoration: none; padding: 6px 12px; border-radius: 6px; }
.top nav a.active, .top nav a:hover { background: #ffffff22; color: #fff; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
h1 { font-size: 1.4em; margin: 0 0 12px; }
h2 { font-size: 1.15em; margin: 0 0 12px; }

input, select, textarea, button { font: inherit; }
input, select, textarea { padding: 10px 12px; border: 1px solid #c9c3b8; border-radius: 8px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { width: 100%; }
label { display: block; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > input:not([type=file]) { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 8px; border: 1px solid #c9c3b8; background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #f4f2ee; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.big { padding: 14px 22px; font-size: 1.1em; font-weight: 600; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.msg { min-height: 1.4em; margin: 8px 0 0; }
.msg.ok, .ok { color: var(--ok); }
.msg.err, .err { color: var(--err); font-weight: 600; }
.alert { background: #fdecea; color: var(--err); border: 1px solid #f3c1bc; padding: 10px 14px; border-radius: 8px; }
.notice { background: #e7f3e9; color: var(--ok); border: 1px solid #b9dcc0; padding: 10px 14px; border-radius: 8px; }

/* ---------- Kasse */
.kasse { display: grid; grid-template-columns: minmax(0, 1fr) 360px; grid-template-areas: "scan pay" "cart pay"; gap: 16px; align-items: start; }
.kasse .card { margin: 0; }
.scan { grid-area: scan; }
.cart { grid-area: cart; }
.pay { grid-area: pay; position: sticky; top: 16px; }
#scan { font-size: 1.3em; padding: 14px; letter-spacing: .03em; }
.scan label { margin-bottom: 6px; font-weight: 600; }
.scan label .muted { font-weight: 400; font-size: .85em; }
.suggest { border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; max-height: 320px; overflow: auto; }
.suggest button { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: #fff; cursor: pointer; }
.suggest button:hover { background: #f4f2ee; }
details.free, details.customer { margin-top: 12px; }
details summary { cursor: pointer; color: var(--muted); }
details .row { margin-top: 8px; }
.cam { margin-top: 12px; }
.cam-view { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9; max-height: 340px; width: 100%; }
.cam-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-view video.mirror { transform: scaleX(-1); }
.cam-frame { position: absolute; inset: 22% 18%; border: 3px solid #ffffffcc; border-radius: 10px; box-shadow: 0 0 0 9999px #00000055; pointer-events: none; }
.cam-flash { position: absolute; inset: 0; background: #2f6b3a; opacity: 0; pointer-events: none; transition: opacity .35s; }
.cam-flash.on { opacity: .45; transition: none; }
.cam-bar { margin-top: 8px; }
.cam-bar select { max-width: 260px; }
.cust-fields { display: grid; gap: 8px; margin-top: 8px; }
.cust-fields input, .cust-fields select, .cust-fields textarea { width: 100%; margin-top: 2px; }
.hint { background: #fff6e0; border: 1px solid #f0d9a0; color: #6b4a12; padding: 8px 10px; border-radius: 6px; margin: 0; }
.addr-form { display: grid; gap: 8px; max-width: 520px; margin-top: 10px; }
.addr-form input, .addr-form select, .addr-form textarea { width: 100%; }
.tax-note { margin-top: 6mm; font-weight: 600; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .8em; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.cart .name { font-weight: 600; }
.cart th.qty, .cart td.qty { width: 150px; }
.stepper { display: flex; align-items: stretch; }
.stepper button { width: 40px; border: 1px solid #c9c3b8; background: #f4f2ee; font-size: 1.2em; cursor: pointer; }
.stepper button:first-child { border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-radius: 0 8px 8px 0; }
.stepper input { width: 60px; text-align: center; border-radius: 0; border-left: 0; border-right: 0; padding: 8px 4px; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.del { border: 0; background: none; color: var(--muted); font-size: 1.1em; cursor: pointer; padding: 6px 10px; }
.del:hover { color: var(--err); }

.total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.1em; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.total strong { font-size: 2em; font-variant-numeric: tabular-nums; }
.methods { border: 0; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.methods legend { font-weight: 600; margin-bottom: 6px; }
.methods label { position: relative; }
.methods input { position: absolute; opacity: 0; }
.methods span { display: block; padding: 12px 14px; border: 2px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 600; }
.methods input:checked + span { border-color: var(--accent); background: #e7f3e9; }
.methods input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.cash { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.cash input { width: 100%; font-size: 1.1em; }
.cash strong { display: block; font-size: 1.3em; }
.actions { display: flex; gap: 8px; margin-top: 16px; }
.actions .primary { flex: 1; }

/* ---------- Listen / Abschluss */
.list .grand td { font-weight: 700; border-top: 2px solid var(--ink); }
.list tr.struck td { color: var(--muted); }
.tag { display: inline-block; font-size: .75em; padding: 1px 6px; border-radius: 4px; background: #f4e4c8; color: #6b4a12; margin-left: 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 12px 0 20px; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.stat span { display: block; color: var(--muted); font-size: .85em; }
.stat strong { font-size: 1.4em; font-variant-numeric: tabular-nums; }
.stat small { display: block; color: var(--muted); }
pre.log { background: #f4f2ee; padding: 10px; border-radius: 6px; overflow: auto; font-size: .85em; }

/* ---------- Login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box { width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login-box input { width: 100%; margin-top: 4px; }

/* ---------- Rechnung */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.invoice { background: #fff; color: #000; margin: 0 auto; padding: 18mm 16mm; box-shadow: 0 1px 6px #0002; }
.invoice.a4 { width: 210mm; max-width: 100%; min-height: 200mm; font-size: 10.5pt; }
.invoice.bon { width: 80mm; max-width: 100%; padding: 4mm 3mm; font-size: 9pt; }
.inv-head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 10mm; }
.invoice .firm { font-size: 1.3em; }
.invoice .meta h1 { font-size: 1.6em; margin: 0 0 4px; }
.invoice .meta table td { border: 0; padding: 1px 8px 1px 0; }
.customer-addr { margin-bottom: 8mm; }
.invoice .lines th { color: #000; border-bottom: 1.5px solid #000; }
.invoice .lines td { border-bottom: 1px solid #ddd; }
.invoice .sums { width: auto; margin: 6mm 0 0 auto; min-width: 60%; }
.invoice .sums td { border: 0; padding: 2px 0 2px 16px; }
.invoice .sums .grand td { font-size: 1.25em; font-weight: 700; border-top: 1.5px solid #000; border-bottom: 1.5px solid #000; padding: 4px 0 4px 16px; }
.paypal { display: flex; gap: 16px; align-items: center; margin-top: 8mm; padding: 4mm; border: 1.5px solid #000; border-radius: 6px; page-break-inside: avoid; }
.paypal .qr svg { width: 42mm; height: 42mm; display: block; }
.paypal p { margin: 4px 0; }
.inv-foot { margin-top: 10mm; font-size: .85em; color: #333; text-align: center; }

/* Bon (80 mm): alles untereinander */
.invoice.bon .inv-head { flex-direction: column; text-align: center; margin-bottom: 4mm; gap: 4px; }
.invoice.bon .meta table { margin: 0 auto; }
.invoice.bon .meta h1 { font-size: 1.3em; }
.invoice.bon .lines th:nth-child(4), .invoice.bon .lines td:nth-child(4) { display: none; }
.invoice.bon .lines th, .invoice.bon .lines td { padding: 3px 2px; }
.invoice.bon .sums { width: 100%; }
.invoice.bon .paypal { flex-direction: column; text-align: center; border-width: 1px; }
.invoice.bon .paypal .qr svg { width: 50mm; height: 50mm; }

/* ---------- Mobil / Tablet */
@media (max-width: 900px) {
  .kasse { grid-template-columns: 1fr; grid-template-areas: "scan" "cart" "pay"; }
  .pay { position: static; }
  .cart th.qty, .cart td.qty { width: 130px; }
  .inv-head { flex-direction: column; }
}
@media (max-width: 560px) {
  main { padding: 10px; }
  .cart thead { display: none; }
  .cart tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .cart td { border: 0; padding: 2px 0; }
  .cart td:nth-child(2) { display: none; }
  .cart td.qty { width: auto; }
  .invoice { padding: 6mm 4mm; }
}

/* ---------- Druck */
@media print {
  .no-print, .top { display: none !important; }
  body { background: #fff; }
  main { padding: 0; max-width: none; }
  .card { border: 0; padding: 0; }
  .invoice { box-shadow: none; margin: 0; padding: 0; width: auto !important; }
  a { color: inherit; text-decoration: none; }
}
@page { margin: 14mm; }
.invoice.bon { page: bon; }
@page bon { size: 80mm auto; margin: 2mm; }
