:root {
  --bg: #f4f4f6;
  --card: #ffffff;
  --text: #17171a;
  --muted: #6b6b75;
  --border: #e3e3e8;
  --primary: #1d6ff2;
  --ok: #1a9b4b;
  --warn: #d8891a;
  --danger: #d3362b;
  --chain: #ffbc0d;
  --chain-accent: #da291c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111113;
    --card: #1c1c20;
    --text: #f2f2f5;
    --muted: #9a9aa6;
    --border: #2c2c33;
    --primary: #4a8bff;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.4; -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.5rem; margin: .4rem 0; }
p { margin: .5rem 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.error { color: var(--danger); }
.hero { font-size: 3.5rem; margin-top: 2rem; }
.page { padding: 1rem; max-width: 1100px; margin: 0 auto; }
.page.narrow { max-width: 520px; }
.page.wide { max-width: 1300px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .9rem 1rem; margin-bottom: .9rem; border: 1px solid var(--border);
}
.section-title { font-weight: 700; font-size: 1.02rem; margin-bottom: .5rem; display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.section-title .count { background: var(--chain-accent); color: #fff; border-radius: 999px; padding: 0 .55rem; font-size: .8rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: .6rem; }
.inline { display: inline; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: .55rem .7rem; min-height: 2.6rem;
}
input[type=checkbox] { width: 1.3rem; height: 1.3rem; min-height: 0; accent-color: var(--chain-accent); }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--border); background: var(--card);
  color: var(--text); border-radius: 12px; padding: .6rem 1rem; min-height: 2.7rem; display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  transition: transform .05s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--chain-accent); border-color: var(--chain-accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: .35rem .7rem; min-height: 2.1rem; font-size: .85rem; border-radius: 9px; }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.x { border: none; background: transparent; cursor: pointer; font: inherit; padding: .2rem .35rem; border-radius: 8px; color: var(--muted); }
.x:hover { background: var(--bg); color: var(--text); }
.x.danger:hover { color: var(--danger); }
.badge { display: inline-block; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 0 .5rem; font-size: .75rem; font-weight: 600; color: var(--muted); vertical-align: middle; }
.badge.alt { background: #ffe9c7; color: #8a5300; border-color: transparent; }
.badge.done { background: #d9f5e3; color: #146b36; border-color: transparent; }
.badge.error { background: #ffd9d6; color: #8e1f17; border-color: transparent; }
.badge.running { background: #dbe8ff; color: #1d4d9c; border-color: transparent; }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; background: var(--muted); margin-right: .2rem; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--muted); }
.chips { display: flex; gap: .45rem; flex-wrap: wrap; margin: .3rem 0 .6rem; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .3rem; scrollbar-width: thin; }
.chip {
  border: 1px solid var(--border); background: var(--card); color: var(--text); border-radius: 999px;
  padding: .4rem .8rem; font: inherit; font-size: .92rem; cursor: pointer; white-space: nowrap; min-height: 2.3rem; display: inline-flex; align-items: center; gap: .3rem;
}
.chip.active { background: var(--chain-accent); border-color: var(--chain-accent); color: #fff; }
.chip.static { cursor: default; }
.chip.inactive { opacity: .5; }
.chip-add { font-size: .85rem; font-weight: 500; }
.toggle-inline { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; white-space: nowrap; }
.search { width: 100%; margin-bottom: .5rem; }
.inline-search { width: auto; margin: 0 0 0 auto; min-height: 2.2rem; padding: .3rem .6rem; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.table tr.offline td, .table tr.inactive td { opacity: .6; }
.table tr.saved td { animation: savedflash 1.2s ease-out; }
.table tr.save-error td { background: rgba(211,54,43,.15); }
@keyframes savedflash { 0% { background: rgba(26,155,75,.35); } 100% { background: transparent; } }
.field-inline { display: flex; flex-direction: column; gap: .2rem; font-size: .78rem; color: var(--muted); font-weight: 600; }
.field-inline input, .field-inline select { font-size: 1rem; font-weight: 400; color: var(--text); }
.table.products input[data-field] { min-height: 2rem; padding: .3rem .5rem; }
.table.products input[data-field=name] { width: 14rem; font-weight: 600; }
.table.products input[data-field=description] { width: 14rem; }
.img-cell { width: 5.5rem; white-space: nowrap; }
.img-cell img { width: 3.2rem; height: 3.2rem; object-fit: contain; border-radius: 8px; background: #fff; vertical-align: middle; }
.noimg { display: inline-block; width: 3.2rem; height: 3.2rem; line-height: 3.2rem; text-align: center; background: var(--bg); border-radius: 8px; color: var(--muted); }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-item { display: flex; gap: .5rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.plain-item:last-child { border-bottom: none; }
.plain-item .qty { font-weight: 700; min-width: 2rem; }
.plain-item.ok .name { text-decoration: line-through; color: var(--muted); }
.result { margin-top: .6rem; padding: .7rem; border-radius: 10px; background: var(--bg); border: 1px dashed var(--border); word-break: break-all; }
.result .qr { width: 160px; height: 160px; background: #fff; padding: 6px; border-radius: 8px; }
.tile { display: flex; gap: .5rem; align-items: center; padding: .8rem 1rem; border-radius: 12px; border: 1px solid var(--border); background: var(--card); color: var(--text); min-width: 16rem; border-left: 6px solid var(--chain-accent); position: relative; }
.tile-link { display: flex; gap: .8rem; align-items: center; color: var(--text); flex: 1; }
.tile-emoji { font-size: 1.8rem; }
.job-status { margin: .6rem 0; min-height: 1.2rem; font-size: .9rem; }
.job-status .bar { height: 4px; background: var(--bg); border-radius: 2px; overflow: hidden; margin-top: .3rem; }
.job-status .bar i { display: block; height: 100%; width: 40%; background: var(--chain-accent); animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.toast { position: fixed; left: 50%; bottom: 5.2rem; transform: translateX(-50%); background: #222; color: #fff; padding: .6rem 1rem; border-radius: 999px; font-size: .9rem; z-index: 50; box-shadow: var(--shadow); max-width: 92vw; }
.toast.err { background: var(--danger); }

/* Admin header */
.admin-header { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .7rem 1rem; background: var(--card); border-bottom: 1px solid var(--border); flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
.admin-header nav { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.brand { font-weight: 800; color: var(--text); font-size: 1.05rem; }
.navlink { color: var(--text); padding: .3rem .6rem; border-radius: 8px; }
.navlink:hover { background: var(--bg); }
.chain-badge { display: inline-flex; align-items: center; gap: .3rem; background: var(--chain); color: #111; border-radius: 999px; padding: .2rem .7rem; font-weight: 700; font-size: .9rem; }
.p-emoji, .p-name { padding: 0 .15rem; border-radius: 4px; }
.p-emoji:focus, .p-name:focus { outline: 1px solid var(--primary); }

/* Bestellseite */
.order-page { background: var(--bg); }
.app { max-width: 720px; margin: 0 auto; padding-bottom: 6.5rem; }
.loading { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.header { position: sticky; top: 0; z-index: 10; background: var(--card); border-bottom: 3px solid var(--chain-accent); padding: .6rem .9rem .5rem; box-shadow: var(--shadow); }
.header-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.expiry { font-size: .78rem; color: var(--muted); white-space: nowrap; }
.expiry.warn { color: var(--warn); font-weight: 600; }
.header .title { font-size: 1.1rem; margin: .3rem 0 .4rem; display: flex; align-items: center; gap: .4rem; }
.header .title .x { font-size: .85rem; }
.stepper { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; }
.step { border: none; background: var(--bg); border-radius: 10px; padding: .35rem .2rem; font: inherit; font-size: .72rem; color: var(--muted); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: .05rem; line-height: 1.2; }
.step .ico { font-size: 1.05rem; }
.step.done { color: var(--ok); }
.step.active { background: var(--chain-accent); color: #fff; font-weight: 700; }
.main { padding: .8rem .8rem 0; }
.list-item { display: flex; align-items: center; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: none; }
.thumb { width: 3rem; height: 3rem; border-radius: 10px; object-fit: contain; background: #fff; flex-shrink: 0; border: 1px solid var(--border); }
.thumb.ph { display: flex; align-items: center; justify-content: center; font-size: 1.4rem; background: var(--bg); }
.item-body { flex: 1; min-width: 0; cursor: pointer; }
.item-name { font-weight: 600; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.item-sub { font-size: .8rem; color: var(--muted); }
.person-badge { font-size: 1rem; }
.qty-ctl { display: flex; align-items: center; gap: .15rem; }
.qty-ctl button { width: 2.3rem; height: 2.3rem; border-radius: 50%; border: 1px solid var(--border); background: var(--card); font-size: 1.2rem; font-weight: 700; cursor: pointer; color: var(--text); }
.qty-ctl span { min-width: 1.6rem; text-align: center; font-weight: 700; }
.custom-add { display: grid; grid-template-columns: 1fr auto; gap: .45rem; margin-top: .7rem; align-items: center; }
.custom-add .toggle-inline { grid-column: 1 / -1; font-size: .88rem; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .55rem; }
.prod { border: 1px solid var(--border); background: var(--card); border-radius: 12px; padding: .5rem; text-align: left; cursor: pointer; font: inherit; color: var(--text); display: flex; flex-direction: column; gap: .3rem; min-height: 9rem; position: relative; }
.prod:active { transform: scale(.98); }
.prod img, .prod .ph { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; border-radius: 8px; background: #fff; }
.prod .ph { display: flex; align-items: center; justify-content: center; font-size: 2rem; background: var(--bg); }
.prod .p-name { font-weight: 600; font-size: .9rem; line-height: 1.25; padding: 0; }
.prod .p-price { font-size: .8rem; color: var(--muted); }
.prod .p-count { position: absolute; top: .35rem; right: .35rem; background: var(--chain-accent); color: #fff; border-radius: 999px; min-width: 1.5rem; height: 1.5rem; display: flex; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; }
.cat-title { font-weight: 700; margin: .9rem 0 .4rem; font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.progress { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-bottom: .6rem; }
.progress .bar { height: 100%; background: var(--ok); transition: width .2s ease; }
.check-row { display: flex; align-items: center; gap: .7rem; padding: .6rem .2rem; border-bottom: 1px solid var(--border); cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent; }
.check-row:last-child { border-bottom: none; }
.check-row .box { width: 2rem; height: 2rem; border-radius: 8px; border: 2px solid var(--muted); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; color: #fff; }
.check-row.checked .box { background: var(--ok); border-color: var(--ok); }
.check-row.checked .item-name { text-decoration: line-through; color: var(--muted); }
.check-row .qty-big { font-size: 1.2rem; font-weight: 800; min-width: 2.2rem; text-align: right; }
.check-row.sub { padding-left: 3.2rem; font-size: .9rem; }
.check-row.sub .box { width: 1.6rem; height: 1.6rem; font-size: .95rem; }
.check-row.info { cursor: default; opacity: .75; }
.footer { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--border); padding: .6rem .9rem calc(.6rem + env(safe-area-inset-bottom)); z-index: 20; }
.footer-inner { max-width: 720px; margin: 0 auto; display: flex; gap: .5rem; align-items: center; }
.footer .btn { flex: 1; min-height: 3rem; font-size: 1rem; }
.footer .btn.icon { flex: 0 0 3rem; padding: 0; }
.summary-big { font-size: 2.4rem; text-align: center; margin: .5rem 0; }
.missing { border-left: 4px solid var(--danger); padding-left: .6rem; margin: .4rem 0; }
/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--card); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto; }
@media (min-width: 600px) { .modal-bg { align-items: center; } .modal { border-radius: 18px; } }
.modal h2 { margin: 0 0 .6rem; font-size: 1.15rem; display: flex; align-items: center; gap: .5rem; }
.field { margin-bottom: .8rem; }
.field label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .25rem; font-weight: 600; }
.field input[type=text] { width: 100%; }
.comp-row { display: flex; gap: .4rem; align-items: center; margin-bottom: .35rem; }
.comp-row input { flex: 1; }
.modal-actions { display: flex; gap: .5rem; margin-top: .6rem; }
.modal-actions .btn { flex: 1; }
.emoji-grid { display: flex; flex-wrap: wrap; gap: .3rem; }
.emoji-grid button { font-size: 1.3rem; border: 1px solid var(--border); background: var(--bg); border-radius: 8px; width: 2.4rem; height: 2.4rem; cursor: pointer; }
.emoji-grid button.active { border-color: var(--chain-accent); background: var(--chain); }
.share-link { word-break: break-all; font-size: .85rem; }
.qr-wrap { text-align: center; }
.qr-wrap img { width: 220px; height: 220px; background: #fff; padding: 8px; border-radius: 12px; }
