:root {
  --bg: #f6f4f0; --card: #ffffff; --text: #1d1b18; --muted: #6b665e; --line: #e4dfd6;
  --accent: #1f5f4a; --accent-text: #ffffff; --warn: #a35a00; --warn-bg: #fff3e0;
  --bad: #b3261e; --bad-bg: #fdecea; --ok: #1f7a3a; --ok-bg: #e7f5ec;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --card: #211f1c; --text: #f1ede6; --muted: #a39d93; --line: #35322d;
    --accent: #5fbf9a; --accent-text: #0e1a15; --warn: #ffb74d; --warn-bg: #3a2a12;
    --bad: #f28b82; --bad-bg: #3b1d1a; --ok: #7fd49a; --ok-bg: #16301f;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
header.top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
header.top .shop { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.top .who { color: var(--muted); font-size: 14px; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 8px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
nav.tabs a { padding: 8px 12px; border-radius: 999px; color: var(--text); text-decoration: none; white-space: nowrap; font-size: 15px; }
nav.tabs a.on { background: var(--accent); color: var(--accent-text); }
main { max-width: 960px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 20px 0 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.big { font-size: 28px; font-weight: 700; }
.ticket { font-weight: 800; font-size: 20px; min-width: 44px; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 10px 14px; border-radius: 10px; cursor: pointer; min-height: 44px; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--text); min-height: 44px; width: 100%; }
label { display: block; margin: 10px 0 4px; font-size: 14px; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pick { text-align: left; padding: 14px; }
.pick.on { outline: 3px solid var(--accent); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 13px; background: var(--line); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.flag { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; }
.error { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.notice { background: var(--ok-bg); color: var(--ok); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 13px; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 12px auto; }
.pinpad button { font-size: 24px; min-height: 64px; }
.dots { text-align: center; font-size: 32px; letter-spacing: 8px; min-height: 44px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 700; }
.poster { text-align: center; }
.poster svg, .poster img { width: 260px; max-width: 100%; height: auto; background: #fff; padding: 12px; border-radius: 12px; }
.receipt { max-width: 380px; }
@media print {
  header.top, nav.tabs, .noprint, main > .notice, main > .error, main > .flag { display: none !important; }
  body { background: #fff; color: #000; }
  .receipt { border: none; max-width: 72mm; padding: 0; color: #000; background: #fff; }
  /* Print poster: only the poster copy in #print-only (see printPoster in app.js). */
  body.printing-poster > *:not(#print-only) { display: none !important; }
  #print-only .poster { border: none; box-shadow: none; }
}
@media screen { #print-only { display: none; } }

/* Older iPhones (before iOS 14.1) ignore gap in flexbox: compat.js adds .no-flexgap and these margins stand in. */
.no-flexgap header.top > * + *, .no-flexgap .row > * + * { margin-left: 10px; }
.no-flexgap .row { margin-bottom: -6px; }
.no-flexgap .row > * { margin-bottom: 6px; }
.no-flexgap nav.tabs a + a { margin-left: 4px; }
.no-flexgap .toggle button + button { margin-left: 10px; }
header.top { position: -webkit-sticky; position: sticky; }

a.btn { display: inline-flex; align-items: center; text-decoration: none; }
details.card summary { list-style: revert; }

/* ---------- Staff assistant (assistant.js): a round button at the bottom right and a chat panel ----------
   Layers, bottom to top: the page, the button (60), the panel (70), toasts and notices (90).
   Anything that pops up over the page (a toast, a notice) uses .toast / .toasts or z-index 90 or more,
   and sits clear of the button and panel (see the end of this block). */
/* The button: sparkles (the usual sign for AI) on a slowly drifting brand gradient, a soft glow that
   breathes out every few seconds, a shine that sweeps across now and then, and stars that twinkle in turn. */
.assist-fab { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); z-index: 60; display: flex; align-items: center; gap: 8px;
  border: 0; border-radius: 999px; padding: 10px 18px 10px 12px; color: #fff; font: inherit; font-weight: 600; letter-spacing: .2px; cursor: pointer; margin: 0;
  background: linear-gradient(120deg, #14402f, #1f5f4a 30%, #2a9d8f 60%, #c9a227 100%); background-size: 260% 260%;
  box-shadow: 0 4px 14px rgba(42,157,143,.45), 0 2px 6px rgba(0,0,0,.25);
  animation: assist-flow 9s ease-in-out infinite; transition: transform .2s ease, box-shadow .2s ease; isolation: isolate; overflow: visible; }
.assist-fab::before { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: inherit; z-index: -1; box-shadow: 0 0 0 0 rgba(42,157,143,.55); animation: assist-breathe 3.4s ease-out infinite; }
.assist-fab::after { content: ''; position: absolute; top: 0; right: 0; bottom: 0; left: 0; border-radius: inherit; z-index: -1; pointer-events: none;
  background: linear-gradient(100deg, transparent 35%, rgba(255,255,255,.45) 50%, transparent 65%) no-repeat; background-size: 250% 100%; animation: assist-shine 5s ease-in-out infinite; }
.assist-fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 10px 24px rgba(42,157,143,.55), 0 3px 8px rgba(0,0,0,.25); }
.assist-fab:active { transform: translateY(-1px) scale(.99); }
.assist-fab:focus-visible { outline: 3px solid var(--text); outline-offset: 3px; }
.assist-sparkles { width: 26px; height: 26px; fill: currentColor; overflow: visible; filter: drop-shadow(0 0 3px rgba(255,255,255,.6)); flex: none; }
.assist-sparkles .spark { transform-box: fill-box; transform-origin: center; animation: assist-twinkle 2.6s ease-in-out infinite; }
.assist-sparkles .spark.top { animation-delay: .85s; }
.assist-sparkles .spark.low { animation-delay: 1.7s; }
@keyframes assist-flow { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes assist-breathe { 0% { box-shadow: 0 0 0 0 rgba(42,157,143,.55); } 70%, 100% { box-shadow: 0 0 0 14px rgba(42,157,143,0); } }
@keyframes assist-shine { 0% { background-position: 150% 0; } 30%, 100% { background-position: -50% 0; } }
@keyframes assist-twinkle { 0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; } 50% { transform: scale(.55) rotate(45deg); opacity: .55; } }
body.assist-open .assist-fab { display: none; }

/* The panel. */
.assist-panel { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 70; width: min(400px, calc(100vw - 32px)); height: min(620px, calc(100vh - 32px)); height: min(620px, calc(100dvh - 32px));
  display: flex; flex-direction: column; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 12px 36px rgba(0,0,0,.3); overflow: hidden; }
.assist-panel[hidden] { display: none; }
.assist-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 12px; border-bottom: 1px solid var(--line); }
.assist-head > div { flex: 1; min-width: 0; }
.assist-sub { color: var(--muted); font-size: 13px; }
.assist-badge { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; flex: none;
  background: linear-gradient(120deg, #14402f, #1f5f4a 30%, #2a9d8f 60%, #c9a227 100%); background-size: 260% 260%; animation: assist-flow 9s ease-in-out infinite; }
.assist-badge .assist-sparkles { width: 20px; height: 20px; }
.assist-ghost { background: none; border: 0; padding: 6px 8px; margin: 0; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; border-radius: 8px; }
.assist-ghost:hover { background: var(--bg); color: var(--text); }
.assist-ghost:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.assist-x { font-size: 24px; line-height: 1; padding: 2px 10px; }
.assist-messages { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); }
.assist-msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.assist-msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); border-bottom-right-radius: 4px; }
.assist-msg.assistant { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; white-space: normal; }
.assist-msg.assistant p { margin: 0 0 8px; }
.assist-msg.assistant p:last-child { margin-bottom: 0; }
.assist-msg.assistant ol, .assist-msg.assistant ul { margin: 4px 0 8px; padding-left: 22px; }
.assist-msg.assistant .notice { margin: 6px 0; }
.assist-msg.error { align-self: center; color: var(--bad); background: var(--bad-bg); font-size: 14px; }
.assist-msg.thinking { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.assist-dots { display: inline-flex; gap: 3px; }
.assist-dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: assist-dot 1.2s ease-in-out infinite; }
.assist-dots i:nth-child(2) { animation-delay: .15s; }
.assist-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes assist-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.assist-empty { display: grid; gap: 8px; color: var(--muted); }
.assist-empty p { margin: 0 0 4px; }
.assist-chip { justify-self: start; text-align: left; white-space: normal; border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 999px; padding: 7px 12px; margin: 0; font: inherit; font-size: 14px; cursor: pointer; }
.assist-chip:hover { border-color: var(--accent); }
.assist-form { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px 6px; border-top: 1px solid var(--line); background: var(--card); }
.assist-form textarea { flex: 1; min-width: 0; resize: none; max-height: 120px; min-height: 44px; margin: 0; font: inherit; line-height: 1.35; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.assist-form textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.assist-form button { flex: none; margin: 0; }
.assist-foot { margin: 0; padding: 0 12px 8px; color: var(--muted); font-size: 12px; background: var(--card); }
/* Room under the page so the button never covers the last thing on it. */
body:has(#assist-fab) main { padding-bottom: 88px; }

@media (max-width: 600px) {
  /* Just the round icon. */
  .assist-fab span { display: none; }
  .assist-fab { padding: 13px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
  /* The panel fills the screen, sized by assistFit() to the part the keyboard leaves free, and pinned to the screen width. */
  .assist-panel { top: var(--assist-top, 0); left: var(--assist-left, 0); right: auto; bottom: auto; width: var(--assist-width, 100vw); max-width: 100vw;
    height: var(--assist-height, 100dvh); border: 0; border-radius: 0; box-shadow: none; }
  .assist-head { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .assist-foot { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  /* 16px keeps phones from zooming in when the box is tapped. */
  .assist-form textarea { font-size: 16px; }
  body.assist-open { overflow: hidden; }
}

/* Toasts and notices that float over the page sit above the button and the panel, and clear of them:
   above the button while it shows, left of the open panel on a wide screen, at the top on a phone. */
.toasts, .toast { z-index: 90; }
body:has(#assist-fab):not(.assist-open) .toasts { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
body.assist-open .toasts { right: 432px; }
@media (max-width: 900px) { body.assist-open .toasts { top: 12px; bottom: auto; left: 12px; right: 12px; justify-items: center; } }
@media (max-width: 600px) { body.assist-open .toasts { top: calc(64px + env(safe-area-inset-top, 0px)); } }

/* Reduced motion: everything still. */
@media (prefers-reduced-motion: reduce) {
  .assist-fab, .assist-fab::before, .assist-fab::after, .assist-sparkles .spark, .assist-badge, .assist-dots i { animation: none; }
  .assist-fab { transition: none; }
  .assist-fab:hover, .assist-fab:active { transform: none; }
}
