:root {
  --bg: #f6f1ec;
  --panel: #ffffff;
  --ink: #2a1c1f;
  --muted: #7b6a6e;
  --line: #e7dcd6;
  --accent: #8c1a2b;
  --accent-ink: #ffffff;
  --cash: #2f7d4a;
  --card: #2457a6;
  --danger: #b3261e;
  --ok: #2f7d4a;
  --warn: #b85c00;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(60 20 25 / .08), 0 4px 14px rgb(60 20 25 / .07);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}
input, textarea { user-select: text; -webkit-user-select: text; }
button { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .6em; line-height: 1.2; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); min-height: 1.2em; margin: .4em 0; font-weight: 600; }
.spacer { flex: 1; }
.boot { display: grid; place-items: center; height: 100vh; font-size: 64px; }
[hidden] { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  border: 0; border-radius: 12px; padding: .7em 1.1em; min-height: 48px;
  background: #efe6e1; color: var(--ink); font-weight: 650; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  transition: transform .06s ease, filter .15s ease;
  touch-action: manipulation;
}
.btn:active:not(:disabled) { transform: scale(.97); filter: brightness(.95); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 38px; padding: .4em .8em; font-size: .9rem; }
.btn.icon { width: 48px; padding: 0; font-size: 1.3rem; }
.btn.wide { flex: 1; }
.btn.chip { min-height: 44px; background: #f3ece8; border: 2px solid transparent; }
.btn.chip.sel { border-color: var(--cash); background: #e4f2e8; }

/* ---------- Kopfzeile ---------- */
.top {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; padding-top: max(6px, env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 1.05rem; margin-right: 8px; white-space: nowrap; }
.status { display: flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); }
.dot.on { background: var(--ok); }
.pending { background: #fff1dc; color: var(--warn); border-radius: 999px; padding: 2px 8px; font-weight: 700; }
.banner {
  width: 100%; border: 0; background: #fff1dc; color: #6b3600; padding: 10px 14px;
  font-weight: 600; text-align: left; cursor: pointer;
}

/* ---------- Login ---------- */
.login-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 50% 0, #f7dcd7, var(--bg) 60%); }
.login { width: min(400px, 100%); background: var(--panel); border-radius: 24px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login .logo { font-size: 56px; }
.login h1 { margin: 0 0 4px; }
.segs { display: flex; gap: 8px; }
.seg { flex: 1; background: #f3ece8; border: 2px solid transparent; }
.seg.sel { border-color: var(--accent); background: #fbe9ea; color: var(--accent); }
input:not([type=checkbox]):not([type=color]):not([type=file]) {
  width: 100%; min-height: 50px; border-radius: 12px; border: 2px solid var(--line);
  padding: 0 14px; font: inherit; font-size: 1.05rem; background: #fff; color: var(--ink);
}
input:focus { outline: none; border-color: var(--accent); }

/* ---------- Kasse ---------- */
.kasse { display: flex; flex-direction: column; height: 100dvh; }
.sell { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr minmax(280px, 32%); }
.grid {
  overflow-y: auto; padding: 10px; display: grid; gap: 10px; align-content: start;
  grid-auto-rows: max-content; /* Kacheln nie stauchen */
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
.empty { grid-column: 1 / -1; padding: 40px; text-align: center; color: var(--muted); }
.tile {
  --c: #8c1a2b;
  position: relative; border: 0; padding: 0; border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow); cursor: pointer; overflow: hidden;
  display: block; width: 100%; text-align: center;
  outline: 3px solid transparent; outline-offset: -3px;
  transition: transform .08s ease, outline-color .15s ease;
  touch-action: manipulation;
}
.tile:active { transform: scale(.96); }
.tile.in { outline-color: var(--c); }
/* Bild füllt die ganze Kachel, Text liegt unten darüber */
.tile .img {
  position: relative; width: 100%; aspect-ratio: 1 / 1.08; display: grid; place-items: start center; padding-top: 5%;
  background: radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--c) 22%, #fff) 0 50%, color-mix(in srgb, var(--c) 9%, #fff) 51%);
}
.tile .img img { width: 80%; height: 70%; object-fit: contain; pointer-events: none; }
.tile .initial, .thumb .initial { font-size: 2.6rem; font-weight: 800; color: var(--c); }
.tile .label {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 6px 7px;
  background: rgb(255 255 255 / .86); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid rgb(0 0 0 / .05);
}
.tile .name {
  font-weight: 750; font-size: .98rem; line-height: 1.15;
  overflow-wrap: break-word; hyphens: manual;
}
.tile .price { font-size: .9rem; color: #5a4a4e; line-height: 1.2; margin-top: 1px; }
.badge {
  position: absolute; top: 6px; right: 6px; min-width: 34px; height: 34px; border-radius: 17px;
  background: var(--c); color: #fff; font-weight: 800; font-size: 1.1rem; display: none;
  place-items: center; padding: 0 8px; box-shadow: 0 2px 6px rgb(0 0 0 / .25);
}
.tile.in .badge { display: grid; }
.minus {
  position: absolute; top: 6px; left: 6px; width: 40px; height: 40px; border-radius: 50%;
  background: rgb(255 255 255 / .92); color: var(--ink); font-size: 1.6rem; font-weight: 700; line-height: 1;
  display: none; place-items: center; box-shadow: 0 1px 4px rgb(0 0 0 / .2);
}
.tile.in .minus { display: grid; }
.tile.special { --c: #5d6b75; background: #fbf8f6; border: 2px dashed #d6c9c2; box-shadow: none; }
.tile.special.return { --c: #2f7d4a; }
.tile.special .img { background: transparent; place-items: center; padding: 0 0 30%; }
.tile.special .label { background: transparent; border: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
.tile .sym { font-size: 3rem; font-weight: 800; color: var(--c); }

.cart {
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
  padding-bottom: env(safe-area-inset-bottom);
}
.cart-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 4px; font-weight: 800; min-height: 52px; }
.lines { flex: 1; overflow-y: auto; padding: 0 10px; }
.hint { color: var(--muted); padding: 24px 6px; text-align: center; }
.line { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.line.meta { color: var(--muted); }
.line.meta .lname { grid-column: 2; }
.line.meta:not(:has(.qtyctl)) .lname { grid-column: 1 / 3; }
.lname { font-weight: 650; }
.lsum { font-variant-numeric: tabular-nums; font-weight: 650; }
.qtyctl { display: flex; align-items: center; gap: 2px; }
.qtyctl .q { min-width: 26px; text-align: center; font-weight: 800; }
.step { width: 38px; height: 38px; border-radius: 10px; border: 0; background: #f1e9e5; font-size: 1.25rem; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.step:active { filter: brightness(.9); }
.total { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; border-top: 2px solid var(--ink); }
.total strong { font-size: 2rem; font-variant-numeric: tabular-nums; }
/* Bezahlknöpfe: immer exakt gleich breit und hoch */
.paybar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 10px 10px; }
.paybar > .btn.wide { grid-column: 1 / -1; }
.btn.pay { min-width: 0; height: 72px; white-space: nowrap; line-height: 1; font-size: 1.25rem; color: #fff; border-radius: 14px; }
.btn.pay-cash { background: var(--cash); }
.btn.pay-card { background: var(--card); }

/* Hochformat: Warenkorb unten */
@media (orientation: portrait) {
  .sell { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .cart { border-left: 0; border-top: 1px solid var(--line); max-height: 42dvh; box-shadow: 0 -4px 16px rgb(0 0 0 / .06); }
  .cart-head { min-height: 40px; padding-top: 6px; }
  .total { padding: 6px 14px; }
  .total strong { font-size: 1.6rem; }
  .btn.pay { height: 60px; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; padding: 8px; }
  .tile .name { font-size: .84rem; }
  .tile .price { font-size: .8rem; }
  .tile .label { padding: 4px 4px 5px; }
  .kasse .brand { display: none; }
  .top { gap: 4px; }
  .top .btn.ghost:not(.icon) { padding: .5em .6em; font-size: .9rem; }
}

/* ---------- Dialoge ---------- */
.backdrop {
  position: fixed; inset: 0; background: rgb(30 15 18 / .45); display: grid; place-items: center;
  padding: 12px; z-index: 50; animation: fade .12s ease;
}
.modal {
  background: var(--panel); border-radius: 20px; box-shadow: 0 20px 60px rgb(0 0 0 / .3);
  width: min(420px, 100%); max-height: calc(100dvh - 24px); overflow: auto; padding: 20px;
  animation: pop .14s ease;
}
.modal.wide { width: min(760px, 100%); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.row { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.row.head { margin: 0 0 12px; justify-content: space-between; flex-wrap: wrap; }
.row.head h2 { margin: 0; }
.confirm p { color: var(--muted); }
.confirm .row .btn { flex: 1; }
.amount { font-size: 2.4rem; font-weight: 800; text-align: center; margin: 8px 0 14px; font-variant-numeric: tabular-nums; }
.amount.small { font-size: 1.5rem; margin: 0; text-align: right; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  min-height: 58px; border: 0; border-radius: 12px; background: #f3ece8; font-size: 1.5rem; font-weight: 700;
  cursor: pointer; touch-action: manipulation;
}
.key:active { filter: brightness(.9); }
.cashdlg .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.due, .given, .change { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.due strong { font-size: 1.8rem; }
.change strong { font-size: 2rem; color: var(--cash); }
.change .warn, .change strong.warn { color: var(--warn); }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.quick .btn { flex: 1 1 30%; }
@media (max-width: 620px) { .cashdlg .cols { grid-template-columns: 1fr; } }

.toast {
  position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #2a1c1f; color: #fff; border-radius: 14px; padding: 10px 12px 10px 18px; z-index: 60;
  display: flex; gap: 14px; align-items: center; box-shadow: 0 10px 30px rgb(0 0 0 / .3); font-weight: 600;
  max-width: calc(100% - 24px); animation: pop .15s ease;
}
.toast.ok { background: #1f4f31; }
.toast.err { background: var(--danger); }
.toast .btn { background: rgb(255 255 255 / .18); color: #fff; }

/* Verlauf */
.histdlg .sums { display: flex; gap: 16px; flex-wrap: wrap; padding: 8px 0 12px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.order { border-bottom: 1px solid var(--line); }
.order summary { display: grid; grid-template-columns: 52px 28px 1fr auto 24px; gap: 8px; align-items: center; padding: 12px 4px; cursor: pointer; list-style: none; }
.order summary::-webkit-details-marker { display: none; }
.order .d { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.order .s { font-weight: 750; font-variant-numeric: tabular-nums; }
.order.storno .s, .order.storno .d { text-decoration: line-through; color: var(--danger); }
.olines { padding: 0 4px 12px 88px; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.oline { display: grid; grid-template-columns: 1fr auto 120px; gap: 8px; align-items: center; }
.oline em { color: var(--danger); font-style: normal; font-size: .85rem; }
.olines > .btn.danger { align-self: flex-start; margin-top: 6px; }
@media (max-width: 620px) { .olines { padding-left: 4px; } }

/* ---------- Verwaltung ---------- */
.admin { min-height: 100dvh; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; padding: 8px 10px 0; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 12px 16px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; }
.tab.sel { color: var(--accent); border-bottom-color: var(--accent); }
.admin-body { padding: 16px; max-width: 1100px; width: 100%; margin: 0 auto; }
.alist { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 10px; }
.acard { --c: #8c1a2b; display: flex; gap: 12px; align-items: center; background: var(--panel); border-radius: var(--radius); padding: 10px; box-shadow: var(--shadow); }
.acard.inactive { opacity: .55; }
.acard .info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.acard .actions { display: flex; gap: 2px; flex: none; }
.acard .info span { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.acard .info .tag { margin-left: 0; }
.thumb { width: 64px; height: 64px; border-radius: 12px; display: grid; place-items: center; flex: none; background: color-mix(in srgb, var(--c) 18%, #fff); overflow: hidden; }
.thumb img { width: 90%; height: 90%; object-fit: contain; }
.thumb.big { width: 160px; height: 160px; border-radius: 20px; }
.tag { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: #e4f2e8; color: var(--ok); font-weight: 700; font-size: .75rem; }
.tag.off { background: #f1e9e5; color: var(--muted); }
.form label { display: flex; flex-direction: column; gap: 4px; font-weight: 650; margin-bottom: 10px; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: 10px; }
label.inline { display: flex; flex-direction: row; align-items: center; gap: 10px; font-weight: 650; }
input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--accent); }
input[type=color] { width: 64px; height: 44px; border: 0; background: none; padding: 0; }
.formgrid { display: grid; grid-template-columns: 180px 1fr; gap: 18px; }
.imgcol { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.imgcol label.btn { cursor: pointer; }
.imgcol input[type=file] { display: none; }
@media (max-width: 560px) { .formgrid { grid-template-columns: 1fr; } }
.card { background: var(--panel); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
.card label { display: flex; flex-direction: column; gap: 6px; font-weight: 650; }
.card .btn { align-self: flex-start; }
.cards2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--panel); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 2px; }
.stat span { color: var(--muted); font-weight: 650; font-size: .9rem; }
.stat strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.stat small { color: var(--muted); }
.tbl { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 12px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.tbl th { font-size: .85rem; color: var(--muted); background: #faf6f3; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.storno td { color: var(--danger); text-decoration: line-through; }
details.orders summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.offline-note { background: var(--panel); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
@media (max-width: 700px) { .tbl { display: block; overflow-x: auto; } }
.btn.pay .ico { display: inline-flex; align-items: center; justify-content: center; width: 1.4em; height: 1.4em; font-size: 1.1em; }
