:root {
  --ink: #1b2340;
  --paper: #ffffff;
  --soft: #f3f1ee;
  --line: #d9d5cf;
  --muted: #5b5750;
  --accent: #d42d25;
  --accent-ink: #ffffff;
  --ok: #17803d;
  --warn: #a15c00;
  --radius: 14px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--soft); color: var(--ink);
  font: 19px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  background: var(--ink); color: #fff; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  min-height: 60px;
}
.top h1 { font-size: 21px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { background: none; border: 0; color: #fff; font-size: 30px; line-height: 1; width: 44px; height: 44px; padding: 0; }
.sync { font-size: 14px; padding: 4px 10px; border-radius: 99px; background: #2b2b2b; white-space: nowrap; }
.sync.ok::before { content: "\25CF "; color: #3ddc84; }
.sync.wait::before { content: "\25CF "; color: #ffb020; }
main { padding: 16px; max-width: 640px; margin: 0 auto; }
h2 { font-size: 24px; margin: 8px 0 14px; }
h3 { font-size: 17px; margin: 22px 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 16px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  min-height: 56px; padding: 12px 18px; border-radius: var(--radius); border: 2px solid var(--ink);
  background: var(--paper); color: var(--ink); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
}
.btn.big { min-height: 72px; font-size: 22px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--ink); color: #fff; }
.btn.light { background: #fff; }
.btn.danger { color: #a3001f; border-color: #a3001f; }
.btn:disabled { opacity: .4; }
.stack > * + * { margin-top: 12px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.card {
  display: block; background: var(--paper); border-radius: var(--radius); padding: 14px 16px;
  border: 1px solid var(--line); color: inherit; text-decoration: none; margin-bottom: 10px;
}
.card .t { font-weight: 700; font-size: 20px; }
.card .s { color: var(--muted); font-size: 16px; }
.card.line { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.alert { background: #fff4de; border: 2px solid #f0b54a; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
.alert.bad { background: #ffe8ec; border-color: #e46a83; }
.chip { display: inline-block; font-size: 14px; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--soft); }
.chip.ok { background: #dff3e6; color: var(--ok); }
.chip.warn { background: #fff0d6; color: var(--warn); }
.chip.bad { background: #ffe0e6; color: #a3001f; }
label { display: block; font-weight: 700; margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 14px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 3px solid var(--accent); outline-offset: 1px; border-color: var(--ink); }
.hint { font-size: 15px; color: var(--muted); margin-top: 4px; }
.hint.bad { color: #a3001f; font-weight: 700; }
.hint.ok { color: var(--ok); font-weight: 700; }
.inline { display: flex; gap: 10px; }
.inline > input { flex: 1; }
.inline > .btn { width: auto; flex: none; }
.toggle { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.toggle.two { grid-template-columns: 1fr 1fr; }
.toggle button { min-height: 56px; border-radius: 12px; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 700; color: var(--ink); }
.toggle button.on { border-color: var(--ink); background: var(--ink); color: #fff; }

/* candy picker */
.pick { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px 10px 14px; margin-bottom: 8px; }
.pick.has { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.pick .name { flex: 1; min-width: 0; }
.pick .name b { display: block; font-size: 19px; }
.pick .name span { font-size: 14px; color: var(--muted); }
.pick.off { opacity: .55; }
.step { display: flex; align-items: center; gap: 6px; }
.step button { width: 52px; height: 52px; border-radius: 12px; border: 2px solid var(--ink); background: #fff; font-size: 28px; font-weight: 700; line-height: 1; color: var(--ink); }
.step button.plus { background: var(--ink); color: #fff; }
.step input { width: 58px; height: 52px; padding: 0; text-align: center; font-weight: 800; font-size: 22px; }
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--ink); color: #fff;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 12px;
}
.bar .sum { flex: 1; font-weight: 700; }
.bar .sum small { display: block; font-weight: 400; opacity: .8; font-size: 15px; }
.bar .btn { width: auto; min-width: 140px; }
body.has-bar .tabs { display: none; }
body.has-bar { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { text-align: center; padding: 16px 4px; font-weight: 700; font-size: 16px; color: var(--muted); text-decoration: none; }
.tabs a.on { color: var(--ink); box-shadow: inset 0 3px 0 var(--accent); }

.lines .ln { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.lines .ln .r { text-align: right; font-weight: 700; }
.lines .ln .s { grid-column: 1 / -1; font-size: 15px; color: var(--muted); }
.total { display: flex; justify-content: space-between; font-size: 24px; font-weight: 800; padding: 14px 0; }
.bc { width: 150px; height: 44px; display: block; margin-top: 8px; }
.big-ok { text-align: center; padding: 18px 0 8px; }
.big-ok .n { font-size: 34px; font-weight: 800; }
.scanner { position: fixed; inset: 0; z-index: 20; background: #000; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; gap: 14px; text-align: center; }
.scanner video { width: 100%; max-width: 520px; border-radius: 12px; border: 3px solid var(--accent); }
.scanner .btn { max-width: 520px; }
.login { max-width: 420px; margin: 40px auto; text-align: center; }
.login .logo { font-size: 40px; font-weight: 900; letter-spacing: -.02em; }
.login .logo span { color: var(--accent); }
.login input { text-align: center; font-size: 30px; letter-spacing: .3em; margin: 16px 0; }
