:root {
  --ink: #2b1a12;
  --muted: #6b574b;
  --bg: #faf5ef;
  --card: #fff;
  --brand: #4a2412;
  --small: #00695c;
  --small-bg: #e0f2ef;
  --big: #b8420b;
  --big-bg: #fdebdf;
  --go: #14803c;
  --danger: #c01f1f;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.3 system-ui, "Noto Sans", sans-serif;
  font-variant-numeric: tabular-nums;
}

button {
  font: inherit;
  font-weight: 700;
  color: inherit;
  border: 0;
  border-radius: 14px;
  min-height: 56px;
  padding: 10px 18px;
  cursor: pointer;
  touch-action: manipulation;
}
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 4px solid #1a73e8; outline-offset: 2px; }
button:active { filter: brightness(.9); }

header {
  background: var(--brand);
  color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header strong { font-size: 22px; }

main {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 14px calc(130px + env(safe-area-inset-bottom));
  display: grid;
  gap: 14px;
}

.money { font-weight: 800; line-height: 1.1; }

.total { text-align: center; background: var(--card); border-radius: 18px; padding: 14px; }
.total h1 { font-size: 20px; }
.total .hero { font-size: clamp(72px, 23vw, 104px); font-weight: 800; line-height: 1; }
.total-money { font-size: 22px; }

.cups { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.cup { border-radius: 18px; padding: 12px 8px; text-align: center; }
.cup.small { color: var(--small); background: var(--small-bg); }
.cup.big { color: var(--big); background: var(--big-bg); }
.cup .pic { width: 76px; height: 76px; display: block; margin: 0 auto; }
.cup.small .pic { width: 50px; height: 50px; margin-top: 26px; }
.cup h2 { font-size: 21px; margin-top: 4px; }
.cup .rate { font-size: 16px; }
.cup .count { font-size: 68px; font-weight: 800; line-height: 1.1; color: var(--ink); }
.cup .unit { color: var(--ink); font-size: 16px; }
.cup .sum { font-size: 21px; font-weight: 700; margin-top: 4px; }

.last {
  background: var(--card);
  border-radius: 18px;
  padding: 10px 10px 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.last small { display: block; color: var(--muted); font-size: 15px; }
.undo { background: #fdeaea; color: var(--danger); white-space: nowrap; flex: none; }

.history { background: var(--card); border-radius: 18px; padding: 0 16px; }
.history summary { padding: 16px 0; font-weight: 700; cursor: pointer; }
.history p { padding-bottom: 16px; color: var(--muted); }
.day { display: grid; grid-template-columns: 1fr auto; padding: 10px 0; border-top: 1px solid #eadfd5; }
.day b:nth-child(2) { font-size: 22px; }
.day span { color: var(--muted); grid-column: 1 / -1; }

.print-link { color: var(--ink); padding: 14px; text-align: center; }

.scan-bar {
  position: fixed;
  inset: auto 0 0;
  padding: 12px 14px calc(14px + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 1px solid #eadfd5;
}
#scan {
  width: 100%;
  max-width: 532px;
  min-height: 84px;
  margin: 0 auto;
  background: var(--go);
  color: #fff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
#scan svg { width: 40px; height: 40px; }

/* ---------- Camera / result ---------- */
dialog { border: 0; padding: 0; color: var(--ink); }
dialog.full { width: 100vw; height: 100dvh; max-width: none; max-height: none; background: #000; }
dialog.full > div { width: 100%; height: 100%; }

#camera-view { position: relative; overflow: hidden; }
#video { width: 100%; height: 100%; object-fit: cover; }
.frame {
  position: absolute;
  top: 50%; left: 50%;
  width: min(70vw, 50dvh);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 6px solid #fff;
  border-radius: 24px;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / .45);
}
.wrong .frame { border-color: #ff5252; }
#scan-msg {
  position: absolute;
  inset: calc(20px + env(safe-area-inset-top)) 14px auto;
  padding: 14px;
  border-radius: 14px;
  background: #fff;
  font-size: 21px;
  font-weight: 700;
  text-align: center;
}
.wrong #scan-msg { background: var(--danger); color: #fff; }
#camera-view .close {
  position: absolute;
  inset: auto 14px calc(20px + env(safe-area-inset-bottom));
  min-height: 68px;
  background: #fff;
  font-size: 22px;
}

#result-view, #error-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 8px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  color: #fff;
  text-align: center;
  overflow-y: auto;
}
#result-view.small { background: var(--small); }
#result-view.big { background: var(--big); }
#error-view { background: var(--danger); }
#error-text { font-size: 24px; font-weight: 700; margin: 12px 0 20px; max-width: 24em; }

.tick {
  flex: none;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #fff;
  color: var(--go);
  font-size: 42px;
  font-weight: 800;
  line-height: 64px;
}
#error-view .tick { color: var(--danger); }
#result-view .pic { width: 130px; height: 130px; flex: none; }
#result-view.small .pic { width: 84px; height: 84px; }
#result-name { font-size: 32px; font-weight: 800; }
#result-price { font-size: 68px; }
.added { font-size: 20px; }
.today { font-size: 28px; margin-bottom: 14px; }

#next, #retry {
  width: 100%;
  max-width: 480px;
  min-height: 80px;
  flex: none;
  background: #fff;
  color: var(--ink);
  font-size: 24px;
}
.row { display: flex; gap: 10px; width: 100%; max-width: 480px; }
.row button { flex: 1; background: rgb(0 0 0 / .3); color: #fff; }

/* ---------- Haan / Nahi ---------- */
dialog::backdrop { background: rgb(0 0 0 / .6); }
.ask { margin: auto; width: min(92vw, 420px); border-radius: 20px; padding: 22px; text-align: center; }
.ask h2 { font-size: 23px; }
.ask p { font-size: 26px; font-weight: 800; margin: 12px 0 18px; }
.ask button { width: 100%; min-height: 66px; font-size: 20px; background: #eee6df; }
.ask .danger { background: var(--danger); color: #fff; margin-bottom: 10px; }
