:root {
  --paper: #eef2f8;
  --card: #ffffff;
  --ink: #111c2e;
  --soft: #55617a;
  --line: #d3dbe8;
  --blue: #1450a3;
  --blue-deep: #0b3473;
  --blue-soft: #e3edfb;
  --red: #c8102e;
  --red-deep: #960b22;
  --red-soft: #fde7ea;
  --tab-h: 66px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.3 system-ui, -apple-system, Roboto, "Segoe UI", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
[hidden] { display: none !important; }
.boot { text-align: center; padding: 64px 16px; color: var(--soft); }
.num { font-variant-numeric: tabular-nums; }

#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; background: var(--paper); }

/* Shop sign */
.sign {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 10px 16px;
  background: var(--blue); color: #fff;
  border-bottom: 4px solid var(--red);
}
.sign h1 {
  flex: 1; min-width: 0; margin: 0;
  font-size: 19px; font-weight: 800; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sign h1 small { display: block; font-size: 13px; font-weight: 600; opacity: .9; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 99px;
  background: rgba(255,255,255,.18); color: #fff;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.pill i { width: 9px; height: 9px; border-radius: 50%; background: #fff; }
.pill.off { background: var(--red); color: #fff; }
.menu-btn {
  width: 44px; height: 44px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 10px; background: rgba(255,255,255,.18); color: #fff;
  font-size: 22px; line-height: 1; text-decoration: none;
}

.lang-btn {
  flex: none; min-height: 44px; padding: 0 12px; border: 2px solid rgba(255,255,255,.6); border-radius: 10px;
  background: none; color: #fff; font-size: 14px; font-weight: 800;
}

/* Shona words can be longer than the English ones */
html[lang="sn"] .tabs button { font-size: 10.5px; }
html[lang="sn"] .row .meta { white-space: normal; }
html[lang="sn"] .card > .line:first-child b { flex: 1; min-width: 0; }
html[lang="sn"] .mode.three button { font-size: 14px; line-height: 1.15; }
html[lang="sn"] .mode button { font-size: 16px; line-height: 1.15; padding: 0 4px; }

main { padding: 12px 12px calc(var(--tab-h) + 96px); }

/* Bottom tabs */
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  z-index: 6; width: 100%; max-width: 560px;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  position: relative; flex: 1; min-width: 0; height: var(--tab-h); border: 0; background: none; padding: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 700; color: var(--soft);
  border-top: 4px solid transparent;
}
.tabs button span { font-size: 21px; line-height: 1; }
.tabs button.on { color: var(--blue-deep); border-top-color: var(--red); background: var(--blue-soft); }
.tabs button em {
  position: absolute; top: 3px; left: 50%; margin-left: 6px;
  min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px;
  background: var(--red); color: #fff; font: 800 12px/19px system-ui, sans-serif; text-align: center;
}

/* Two-way switch: cash or credit, tractor or motorbike */
.mode { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.mode button {
  height: 54px; border-radius: 12px; font-weight: 800; font-size: 18px;
  background: var(--card); border: 2px solid var(--line); color: var(--soft);
}
.mode button.on-cash { background: var(--blue); border-color: var(--blue); color: #fff; }
.mode button.on-credit { background: var(--red); border-color: var(--red); color: #fff; }

.mode.three { grid-template-columns: 1fr 1fr 1fr; }
.mode.three button { height: auto; min-height: 54px; font-size: 16px; padding: 4px 2px; }

.credit-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 10px; border-radius: 12px;
  background: var(--red-soft); border: 2px solid var(--red);
}
.credit-bar div { flex: 1; min-width: 0; }
.credit-bar b { display: block; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.credit-bar small { color: var(--red); font-weight: 700; font-size: 14px; }
.credit-bar.eco { background: var(--blue-soft); border-color: var(--blue-deep); }
.credit-bar.eco small { color: var(--blue-deep); }

.search {
  width: 100%; height: 48px; padding: 0 14px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--card);
}
.search:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 3px solid var(--blue); outline-offset: 0; border-color: var(--blue); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 99px;
  border: 2px solid var(--line); background: var(--card);
  font-weight: 700; font-size: 15px; color: var(--soft);
}
.chip.on { background: var(--blue-deep); border-color: var(--blue-deep); color: #fff; }

/* A row in a list */
.row {
  display: flex; align-items: center; gap: 10px;
  min-height: 76px; padding: 8px 8px 8px 10px; margin-bottom: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
}
.row.tap { width: 100%; text-align: left; font: inherit; }
.row .pic { flex: none; width: 40px; text-align: center; font-size: 30px; line-height: 1; }
.band {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 54px; padding: 8px 14px; margin-bottom: 8px; text-align: left;
  border: 2px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font-weight: 700;
}
.band b { flex: none; color: var(--blue-deep); font-size: 18px; }
.band.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.band.on b { color: #fff; }
.count-input { flex: none; width: 86px; height: 52px; padding: 0 10px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-size: 20px; font-weight: 800; text-align: center; }
.count-input:focus { outline: 3px solid var(--blue); border-color: var(--blue); }
.row .pic img { display: block; width: 44px; height: 44px; margin-left: -2px; border-radius: 10px; object-fit: cover; background: #fff; }
.item-photo { display: block; width: 120px; height: 120px; margin-bottom: 10px; border-radius: 12px; object-fit: cover; border: 1px solid var(--line); background: #fff; }
.row .pic.letter {
  height: 40px; line-height: 40px; border-radius: 10px;
  background: var(--blue-soft); color: var(--blue-deep); font-weight: 800; font-size: 20px;
}
.row .main { flex: 1; min-width: 0; }
.row .name { font-weight: 800; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .meta { font-size: 15px; color: var(--soft); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .right { flex: none; text-align: right; font-weight: 800; font-size: 19px; }
.row .right small { display: block; font-size: 13px; font-weight: 600; color: var(--soft); }
.left-ok { color: var(--ink); font-weight: 700; }
.left-low { color: var(--red-deep); font-weight: 800; }
.left-none { color: var(--red); font-weight: 800; }
.owes { color: var(--red); }

.plus {
  flex: none; width: 62px; height: 60px; border: 0; border-radius: 12px;
  background: var(--blue); color: #fff;
  font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.plus.two { background: var(--blue-deep); }
.credit-on .plus { background: var(--red); }
.credit-on .plus.two { background: var(--red-deep); }
.eco-on .plus { background: var(--ink); }
.eco-on .plus.two { background: #060b14; }
.plus:active { transform: scale(.93); filter: brightness(1.25); }
.row.flash { animation: flash .45s ease-out; }
@keyframes flash { from { background: #bcd5f7; } to { background: var(--card); } }
.credit-on .row.flash { animation-name: flashc; }
@keyframes flashc { from { background: #f8b9c3; } to { background: var(--card); } }

/* Buttons and forms */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 54px; padding: 8px 14px;
  border: 0; border-radius: 12px; background: var(--blue); color: #fff;
  font-weight: 800; font-size: 17px; text-align: center; text-decoration: none;
}
.btn.second { background: var(--card); color: var(--blue-deep); border: 2px solid var(--blue); }
.btn.credit { background: var(--red); }
.btn.danger { background: var(--card); color: var(--red); border: 2px solid var(--red); }
.btn.wa { background: var(--blue-deep); }
.btn.small { width: auto; min-height: 44px; padding: 4px 14px; font-size: 15px; }
.btn:disabled { opacity: .5; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stack > * + * { margin-top: 10px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.field small { display: block; color: var(--soft); font-size: 14px; margin-top: 4px; }
.field input, .field select, .field textarea {
  width: 100%; height: 52px; padding: 0 12px;
  border: 2px solid var(--line); border-radius: 12px; background: #fff;
}
.field textarea { height: 92px; padding: 10px 12px; resize: vertical; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trap { position: absolute; left: -9999px; height: 1px; width: 1px; overflow: hidden; }

.emoji-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-grid button {
  width: 44px; height: 44px; font-size: 24px; line-height: 1; padding: 0;
  border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
.emoji-grid button.on { border-color: var(--blue); background: var(--blue-soft); }

/* Sections and cards */
h2 { margin: 18px 2px 8px; font-size: 17px; font-weight: 800; }
h2:first-child { margin-top: 2px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 18px 2px 8px; }
.head-row h2 { margin: 0; }
.empty { padding: 28px 16px; text-align: center; color: var(--soft); background: var(--card); border: 2px dashed var(--line); border-radius: 14px; }
.empty b { display: block; color: var(--ink); font-size: 18px; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }
.note { padding: 10px 12px; border-radius: 12px; font-size: 15px; background: var(--blue-soft); color: var(--blue-deep); margin-bottom: 10px; }
.note.bad { background: var(--red-soft); color: var(--red); font-weight: 700; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 8px; }
.card.fresh { border: 2px solid var(--red); }
.line { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.line:last-child { border-bottom: 0; }
.line span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line b, .line .num { flex: none; }
.wrap-text { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 16px; overflow-wrap: anywhere; white-space: pre-line; }
.wrap-text small { display: block; color: var(--soft); font-size: 13px; font-weight: 700; }
.tag { flex: none; padding: 2px 10px; border-radius: 99px; font-size: 13px; font-weight: 800; background: var(--blue-soft); color: var(--blue-deep); }
.tag.new { background: var(--red); color: #fff; }
.tag.declined { background: var(--red-soft); color: var(--red); }

/* Money screen */
.takings { background: var(--blue-deep); color: #fff; border-radius: 16px; padding: 16px; margin-bottom: 10px; border-bottom: 5px solid var(--red); }
.takings small { display: block; font-size: 15px; font-weight: 700; opacity: .9; }
.takings b { display: block; font-size: 44px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.takings em { font-style: normal; font-size: 14px; color: #cfe0fb; font-weight: 700; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; }
.tile small { display: block; font-size: 14px; color: var(--soft); font-weight: 600; }
.tile b { font-size: 22px; font-variant-numeric: tabular-nums; }
.tile.wide { grid-column: 1 / -1; background: var(--blue-soft); border-color: var(--blue); }
.tile.wide small { color: var(--blue-deep); }

/* Quantity stepper */
.stepper { flex: none; display: flex; align-items: center; gap: 2px; }
.stepper button {
  width: 46px; height: 50px; border: 0; border-radius: 10px;
  background: var(--blue); color: #fff; font-size: 24px; font-weight: 800;
}
.stepper button.minus { background: var(--line); color: var(--ink); }
.stepper b { min-width: 30px; text-align: center; font-size: 19px; font-variant-numeric: tabular-nums; }
.row.picked { border: 2px solid var(--blue); background: var(--blue-soft); }
.row.gone { opacity: .6; }
.send-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  z-index: 4; width: 100%; max-width: 560px; padding: 10px 12px;
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-top: 2px solid var(--blue);
}
.send-bar div { flex: none; }
.send-bar small { display: block; font-size: 13px; color: var(--soft); }
.send-bar b { font-size: 19px; font-variant-numeric: tabular-nums; }

/* Pop-up sheet */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(10,20,40,.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--paper); border-radius: 18px 18px 0 0;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
}
.sheet-head { position: sticky; top: -8px; z-index: 1; display: flex; align-items: center; gap: 8px; background: var(--paper); padding: 10px 0; }
.sheet-head h3 { flex: 1; min-width: 0; margin: 0; font-size: 20px; font-weight: 800; }
.sheet-close { width: 44px; height: 44px; flex: none; border: 0; border-radius: 10px; background: var(--line); font-size: 20px; }
.preview { display: block; width: 100%; max-height: 44dvh; object-fit: contain; object-position: top; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 12px; }

/* Toast */
#toast {
  position: fixed; left: 12px; right: 12px; z-index: 30;
  bottom: calc(var(--tab-h) + 12px + env(safe-area-inset-bottom));
  max-width: 536px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; min-height: 54px; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 16px;
}
#toast span { flex: 1; min-width: 0; }
#toast button { flex: none; min-height: 40px; padding: 0 14px; border: 0; border-radius: 8px; background: var(--red); color: #fff; font-weight: 800; }
#toast.bad { background: var(--red); }

/* PIN and first-time screens */
.gate { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px 20px; max-width: 420px; margin: 0 auto; }
.gate h1 { margin: 0 0 4px; font-size: 26px; font-weight: 800; text-align: center; color: var(--blue-deep); }
.gate p { margin: 0 0 18px; color: var(--soft); text-align: center; }
.dots { display: flex; justify-content: center; gap: 12px; height: 22px; margin-bottom: 18px; }
.dots i { width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--blue); }
.dots i.on { background: var(--blue); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad button { height: 68px; border: 0; border-radius: 14px; background: var(--card); box-shadow: inset 0 0 0 2px var(--line); font-size: 28px; font-weight: 800; }
.pad button:active { background: var(--blue-soft); }
.pad .go { background: var(--blue); color: #fff; box-shadow: none; font-size: 20px; }
.err { min-height: 22px; margin: 12px 0 0; text-align: center; color: var(--red); font-weight: 700; }
.staff-link { display: block; text-align: center; padding: 18px 0 0; color: var(--soft); font-size: 14px; }

/* Guide pages: one language shows at a time */
html:not([lang="sn"]) .guide-page .sn { display: none; }
html[lang="sn"] .guide-page .en { display: none; }
.guide-page main { padding-bottom: 40px; line-height: 1.5; }
.guide-chips { position: sticky; top: 72px; z-index: 3; background: var(--paper); margin: -12px -12px 0; padding: 10px 12px; }
.guide-title { font-size: 24px; color: var(--blue-deep); margin: 10px 2px 4px; }
.guide-page .lead { font-size: 17px; margin: 0 2px 10px; }
.guide-page h3 { margin: 22px 2px 8px; font-size: 18px; color: var(--blue-deep); border-bottom: 3px solid var(--red); padding-bottom: 4px; }
.guide-page ol, .guide-page ul { margin: 0; padding: 12px 12px 12px 34px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.guide-page li { margin: 4px 0; }
.guide-page p { margin: 8px 2px; }
.guide-page .small { font-size: 14px; color: var(--soft); }
.guide-table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.guide-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.guide-table tr:last-child td { border-bottom: 0; }
.guide-table td:last-child { font-weight: 700; }
.guide-foot { margin-top: 24px !important; text-align: center; }
.link-box { margin: 4px 0 6px; padding: 12px 14px; border-radius: 14px; background: var(--blue-soft); border: 2px solid var(--blue); font-weight: 800; overflow-wrap: anywhere; }
.guide-page a { color: var(--blue-deep); }
.guide-link { display: block; text-align: center; padding: 10px 0 0; color: var(--blue-deep); font-weight: 700; }
@media print {
  body.guide-page, .guide-page #app { background: #fff; max-width: none; }
  .guide-page .sign { position: static; }
  .guide-chips, .lang-btn { display: none !important; }
  .guide-page li, .guide-table tr, .note { break-inside: avoid; }
  .guide-page h3 { break-after: avoid; }
}

@media (prefers-reduced-motion: reduce) {
  .row.flash { animation: none; }
  .plus:active { transform: none; }
}
