/* St. Martin Bon Kasse – mobile first, flat, kindgerecht */
:root {
  --navy: #1b2a4e;
  --navy-2: #2a3d70;
  --cream: #fff6e3;
  --ink: #1b2a4e;
  --muted: #64739a;
  --line: #e6e9f3;
  --yellow: #ffc93c;
  --green: #10a46c;
  --green-d: #0b7f52;
  --red: #e5484d;
  --orange: #f08c3a;
  --card: #ffffff;
  --shadow: rgba(0, 0, 0, 0.18);
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  font-family: var(--font);
  color: var(--ink);
  background: var(--cream);
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}
button { font: inherit; color: inherit; }
input { font: inherit; -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }
svg { display: block; }

/* ---------- Kopfzeile ---------- */
.top {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 12px;
  background: var(--navy);
  border-radius: 0 0 26px 26px;
  color: #fff;
  position: relative;
  z-index: 5;
}
.brand { flex: none; display: flex; align-items: center; gap: 12px; background: none; border: 0; padding: 0; color: #fff; text-align: left; cursor: default; }
.logo { width: 44px; height: 44px; border-radius: 14px; background: #fff; display: grid; place-items: center; flex: none; }
.logo svg { width: 32px; height: 32px; }
.title { display: flex; flex-direction: column; font-size: 0.8rem; line-height: 1.05; font-weight: 700; opacity: 0.85; letter-spacing: 0.02em; }
.title b { white-space: nowrap; font-size: 1.35rem; font-weight: 900; opacity: 1; color: var(--yellow); letter-spacing: 0; }
.sync { display: flex; align-items: center; gap: 8px; padding: 8px 14px; min-height: 40px; min-width: 0; flex: 0 1 auto; max-width: 58vw; border: 0; border-radius: 999px; background: rgba(255, 255, 255, 0.14); color: #fff; font-size: 0.9rem; font-weight: 800; white-space: nowrap; cursor: pointer; }
.sync i { width: 10px; height: 10px; border-radius: 50%; background: #3ddc97; flex: none; }
.sync span { overflow: hidden; text-overflow: ellipsis; }
.sync em { font-style: normal; font-weight: 700; opacity: 0.8; font-size: 0.8rem; }
.sync em:empty { display: none; }
.sync.warn i { background: var(--orange); }
.sync.off i { background: var(--red); }

/* ---------- Ansichten ---------- */
.view { flex: 1; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; }

/* ---------- Artikel-Kacheln ---------- */
.grid { padding-bottom: 96px !important; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; padding: 20px 16px 24px; max-width: 1100px; margin: 0 auto; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.empty { padding: 40px 24px; text-align: center; color: var(--muted); font-weight: 700; }

.tile { position: relative; }
.tile-main {
  width: 100%;
  min-height: 176px;
  border: 0;
  border-radius: 28px;
  background: var(--c);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 16px 10px 14px;
  cursor: pointer;
  box-shadow: 0 7px 0 var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.tile-main:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--shadow); }
.tile .ico { width: 78px; height: 78px; border-radius: 50%; background: #fff; display: grid; place-items: center; }
.tile .ico svg { width: 54px; height: 54px; }
.tile .name { font-weight: 900; font-size: 1.15rem; line-height: 1.1; text-align: center; overflow-wrap: anywhere; }
.tile .price { background: #fff; color: var(--c); font-weight: 900; border-radius: 999px; padding: 4px 14px; font-size: 1.05rem; }

.badge {
  position: absolute; top: -10px; right: -6px;
  min-width: 48px; height: 48px; padding: 0 12px;
  border-radius: 24px;
  background: var(--yellow); color: var(--navy);
  font-weight: 900; font-size: 1.6rem;
  display: grid; place-items: center;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  transform: scale(0); transition: transform 0.16s cubic-bezier(0.3, 1.7, 0.6, 1);
  pointer-events: none;
}
.tile.has .badge { transform: scale(1); }
.badge.pop { animation: pop 0.2s ease; }
@keyframes pop { 50% { transform: scale(1.25); } }

.minus {
  position: absolute; top: -10px; left: -6px;
  width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: #fff; color: var(--navy);
  display: none; place-items: center;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.minus svg { width: 26px; height: 26px; }
.tile.has .minus { display: grid; }
.minus:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2); }

/* ---------- Untere Leiste ---------- */
.bar {
  flex: none;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: #fff;
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -6px 22px rgba(27, 42, 78, 0.12);
  position: relative; z-index: 4;
}
.bar[hidden] { display: none; }
.sum { flex: 1; min-width: 0; line-height: 1.1; }
.sum small { display: block; color: var(--muted); font-weight: 800; font-size: 0.85rem; }
.sum b { display: block; font-size: 1.85rem; font-weight: 900; }

/* ---------- Buttons ---------- */
.btn {
  border: 0; border-radius: 18px;
  padding: 12px 22px; min-height: 56px;
  font-weight: 900; font-size: 1.15rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.16);
  transition: transform 0.08s, box-shadow 0.08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.16); }
.btn svg { width: 24px; height: 24px; flex: none; }
.btn.primary { background: var(--green); color: #fff; }
.btn.yellow { background: var(--yellow); color: var(--navy); }
.btn.ghost { background: #e8ecf7; color: var(--navy); }
.btn.danger { background: var(--red); color: #fff; }
.btn.small { min-height: 44px; padding: 8px 14px; font-size: 1rem; border-radius: 14px; box-shadow: 0 3px 0 rgba(0, 0, 0, 0.14); }
.btn.round { width: 56px; padding: 0; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ---------- Sheets & Dialoge ---------- */
.wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.scrim { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.55); animation: fade 0.2s ease; }
.sheet {
  position: relative; width: 100%; max-width: 680px; max-height: 94dvh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: #fff; border-radius: 30px 30px 0 0;
  padding: 22px 16px 0;
  animation: up 0.26s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.chead { position: sticky; top: 0; z-index: 2; background: #fff; padding-bottom: 2px; max-height: 46dvh; overflow-y: auto; }
.dlg-wrap { z-index: 60; align-items: center; padding: 16px; }
.dlg {
  position: relative; width: 100%; max-width: 460px; max-height: 88dvh; overflow-y: auto;
  background: #fff; border-radius: 28px; padding: 22px 18px 18px;
  animation: pop-in 0.2s ease;
}
@media (min-width: 720px) { .wrap { align-items: center; } .sheet { border-radius: 30px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes pop-in { from { transform: scale(0.94); opacity: 0; } }

.sheet h2, .dlg h2 { margin: 0 0 14px; font-size: 1.5rem; font-weight: 900; }
.dlg p { margin: 0 0 16px; font-size: 1.05rem; line-height: 1.35; color: var(--muted); font-weight: 600; }
.dlg .actions, .foot { display: flex; gap: 12px; }
.dlg .actions .btn, .foot .btn { flex: 1; }
.foot { position: sticky; bottom: 0; z-index: 2; margin: 14px -16px 0; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -8px 14px -8px rgba(27, 42, 78, 0.12); }

/* Bestellung */
.lines { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.line { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; border-radius: 20px; background: var(--tint, #f3f5fb); }
.line .li { width: 46px; height: 46px; border-radius: 50%; background: #fff; display: grid; place-items: center; flex: none; }
.line .li svg { width: 32px; height: 32px; }
.line .q { font-size: 1.8rem; font-weight: 900; color: var(--c, var(--navy)); min-width: 2.7rem; }
.line .n { flex: 1; min-width: 0; font-size: 1.1rem; font-weight: 800; line-height: 1.1; overflow-wrap: break-word; hyphens: auto; }
.line .p { font-size: 1rem; font-weight: 800; color: var(--muted); white-space: nowrap; }
.total { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 12px 12px 16px; border-radius: 22px; background: var(--navy); color: #fff; }
.total small { display: block; font-weight: 800; opacity: 0.75; font-size: 0.9rem; }
.total b { font-size: 2.1rem; font-weight: 900; line-height: 1.05; color: var(--yellow); white-space: nowrap; }
.total .btn { padding: 10px 16px; }

/* Rückgeld */
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.pair > div { background: #f3f5fb; border-radius: 20px; padding: 10px 14px; }
.pair small { display: block; color: var(--muted); font-weight: 800; font-size: 0.85rem; }
.pair b { font-size: 1.6rem; font-weight: 900; }
.result { border-radius: 24px; padding: 12px; margin-bottom: 4px; text-align: center; font-weight: 900; }
.result.wait { background: #f3f5fb; color: var(--muted); font-size: 1.05rem; }
.result.miss { background: #fff1e0; color: #b45309; font-size: 1.35rem; }
.result.ok { background: #dcf7ea; color: var(--green-d); font-size: 1.35rem; }
.result.change { background: #dcf7ea; color: var(--green-d); }
.result .big { display: block; font-size: 2.3rem; line-height: 1.1; margin-bottom: 8px; }
.result .cap { display: block; font-size: 0.95rem; opacity: 0.85; }
.out { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 14px 18px; margin-top: 6px; }
.out .o { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 18px; padding: 8px 12px; box-shadow: 0 3px 0 rgba(16, 164, 108, 0.25); }
.out .o .x { font-size: 1.6rem; font-weight: 900; color: var(--navy); }
.picked { display: flex; flex-wrap: wrap; gap: 8px; min-height: 52px; align-items: center; margin-bottom: 12px; padding: 8px; border-radius: 18px; border: 2px dashed var(--line); }
.picked .hint { color: var(--muted); font-weight: 700; padding: 0 6px; }
.chip { display: flex; align-items: center; gap: 6px; background: #f3f5fb; border: 0; border-radius: 16px; padding: 4px 10px 4px 6px; cursor: pointer; }
.chip .x { font-weight: 900; font-size: 1.1rem; }
.chip .money { max-height: 34px; width: auto !important; height: 34px; }
.sec { margin: 14px 0 6px; font-size: 0.9rem; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.mgrid { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.mbtn { border: 0; background: #f3f5fb; border-radius: 18px; min-width: 62px; min-height: 62px; padding: 8px 10px; display: grid; place-items: center; cursor: pointer; transition: transform 0.08s; }
.mbtn:active { transform: scale(0.92); background: #e3e8f6; }
.tools { display: flex; gap: 8px; margin: 10px 0 0; }
.tools .btn { flex: 1; }

/* Icon-Auswahl */
.pick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 8px 0 16px; }
.pick-grid button { border: 0; background: #f3f5fb; border-radius: 18px; padding: 10px 4px 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; font-size: 0.75rem; font-weight: 800; color: var(--muted); }
.pick-grid button.on { outline: 3px solid var(--navy); background: #fff; }
.pick-grid svg { width: 44px; height: 44px; }

/* Text-Eingabe im Dialog */
.dlg input.txt { width: 100%; padding: 12px 14px; font-size: 1.1rem; font-weight: 700; border: 2px solid var(--line); border-radius: 14px; margin-bottom: 16px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 80; display: flex; align-items: center; gap: 12px;
  background: var(--navy); color: #fff; font-weight: 800;
  padding: 10px 12px 10px 18px; border-radius: 999px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  max-width: calc(100vw - 24px); animation: up 0.2s ease;
}
.toast button { border: 0; background: var(--yellow); color: var(--navy); font-weight: 900; border-radius: 999px; padding: 8px 14px; cursor: pointer; display: flex; align-items: center; gap: 6px; }
.toast button svg { width: 18px; height: 18px; }
.toast.err { background: #b42318; }

/* ---------- Verwaltung ---------- */
.admin { background: #f6f7fc; }
.admin-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #f6f7fc; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: #e8ecf7; padding: 4px; border-radius: 16px; flex: 1 1 280px; min-width: 0; }
.tab { flex: 1 1 auto; border: 0; background: none; border-radius: 12px; padding: 10px 8px; white-space: nowrap; font-size: 0.95rem; font-weight: 900; color: var(--muted); cursor: pointer; }
.tab.on { background: #fff; color: var(--navy); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08); }
.admin-body { max-width: 820px; margin: 0 auto; padding: 4px 16px 120px; -webkit-user-select: text; user-select: text; }
.admin h3 { margin: 22px 0 10px; font-size: 1.15rem; font-weight: 900; }
.note { color: var(--muted); font-weight: 600; font-size: 0.95rem; line-height: 1.4; margin: 0 0 12px; }

.edit-row { background: #fff; border-radius: 22px; padding: 14px; margin-bottom: 12px; display: grid; grid-template-columns: auto 1fr; gap: 12px 14px; box-shadow: 0 2px 0 rgba(27, 42, 78, 0.06); }
.edit-row .pick { width: 72px; height: 72px; border-radius: 22px; border: 0; background: var(--c); display: grid; place-items: center; cursor: pointer; position: relative; }
.edit-row .pick span { width: 52px; height: 52px; border-radius: 50%; background: #fff; display: grid; place-items: center; }
.edit-row .pick svg { width: 38px; height: 38px; }
.edit-row .pick em { position: absolute; right: -6px; bottom: -6px; font-style: normal; background: var(--navy); color: #fff; border-radius: 10px; font-size: 0.7rem; font-weight: 800; padding: 2px 6px; }
.fields { display: flex; gap: 8px; align-items: center; min-width: 0; }
.fields input { min-width: 0; border: 2px solid var(--line); border-radius: 14px; padding: 12px; font-size: 1.05rem; font-weight: 800; background: #fff; color: var(--navy); }
.fields .f-name { flex: 1; }
.fields .pricebox { display: flex; align-items: center; gap: 4px; font-weight: 900; }
.fields .f-price { width: 92px; text-align: right; }
.fields input.bad { border-color: var(--red); background: #fff1f1; }
.swatches { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--c); cursor: pointer; display: grid; place-items: center; }
.sw.on { box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--navy); }
.row-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }
.row-actions .btn { min-height: 44px; padding: 6px 14px; border-radius: 14px; box-shadow: none; }
.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -6px 22px rgba(27, 42, 78, 0.12); display: flex; gap: 12px; justify-content: center; }
.savebar .btn { flex: 1; max-width: 340px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: #fff; border-radius: 20px; padding: 14px 16px; }
.stat small { display: block; color: var(--muted); font-weight: 800; }
.stat b { font-size: 1.8rem; font-weight: 900; }
.table { background: #fff; border-radius: 20px; overflow: hidden; }
.trow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.trow:last-child { border-bottom: 0; }
.trow .grow { flex: 1; min-width: 0; }
.trow .t1 { font-weight: 800; }
.trow .t2 { color: var(--muted); font-weight: 600; font-size: 0.9rem; overflow-wrap: anywhere; }
.trow .amt { font-weight: 900; white-space: nowrap; }
.trow.void .t1, .trow.void .amt { text-decoration: line-through; opacity: 0.5; }
.trow.void .t2 { opacity: 0.5; }
.tag { display: inline-block; background: #fde2e2; color: #b42318; border-radius: 8px; font-size: 0.75rem; font-weight: 900; padding: 1px 6px; margin-left: 6px; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; margin: 6px 0 14px; }
.btnrow .btn { flex: 1; min-width: 210px; }
.devbox { background: #fff; border-radius: 22px; padding: 16px; }
.devbox input { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px; font-size: 1.1rem; font-weight: 800; margin: 8px 0 12px; }
.bad-msg { color: var(--red); font-weight: 800; }

@media (min-width: 720px) {
  .stats { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Name-Dialog */
.namebox { display: flex; gap: 10px; align-items: stretch; margin-bottom: 16px; }
.namebox .txt { flex: 1; min-width: 0; margin: 0 !important; font-size: 1.25rem !important; font-weight: 900 !important; color: var(--navy); border-color: var(--yellow) !important; background: #fffbea; }
.namebox .btn { flex: none; }
#reroll.spin svg { animation: spin 0.45s ease; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Einstellungen: Schalter + Vorschau */
.switch { display: flex; align-items: center; gap: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .knob { flex: none; width: 60px; height: 34px; border-radius: 17px; background: #cbd3e6; position: relative; transition: background 0.15s; }
.switch .knob::after { content: ""; position: absolute; top: 4px; left: 4px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18); transition: transform 0.15s; }
.switch input:checked + .knob { background: var(--green); }
.switch input:checked + .knob::after { transform: translateX(26px); }
.switch input:focus-visible + .knob { outline: 3px solid var(--navy); outline-offset: 2px; }
.sw-txt b { display: block; font-size: 1.05rem; }
.sw-txt small { display: block; color: var(--muted); font-weight: 600; line-height: 1.3; margin-top: 2px; }
.preview { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; padding: 10px; background: #f3f5fb; border-radius: 16px; }
.money.real { height: auto; -webkit-user-drag: none; pointer-events: none; }
.chip .money.real { height: 34px; width: auto !important; }
.chip .money.real.bill { height: 30px; }

/* Lautsprecher-Knopf (Kasse, unten rechts) */
.fab { position: fixed; right: 16px; bottom: calc(112px + env(safe-area-inset-bottom)); z-index: 3; width: 56px; height: 56px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer; background: #fff; color: var(--muted); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.16), 0 8px 18px rgba(27, 42, 78, 0.18); transition: transform 0.08s, background 0.15s; }
.fab svg { width: 28px; height: 28px; }
.fab:active { transform: translateY(3px); }
.fab.on { background: var(--yellow); color: var(--navy); }
