* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background: #fff7e6; color: #2b2250; font-size: 18px;
  min-height: 100vh;
}
a { color: inherit; }
button { font-family: inherit; cursor: pointer; border: 0; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: #7c5cff; color: #fff;
  position: sticky; top: 0; z-index: 5;
}
.top h1 { margin: 0; font-size: 26px; }
.pill {
  background: #fff; color: #7c5cff; text-decoration: none; font-weight: 700;
  padding: 10px 16px; border-radius: 999px; font-size: 17px;
}
main { padding: 16px; max-width: 640px; margin: 0 auto; }

.scan {
  width: 100%; padding: 20px; font-size: 24px; font-weight: 800; color: #fff;
  background: #ff7a45; border-radius: 22px; box-shadow: 0 6px 0 #d95a28; margin-bottom: 22px;
}
.scan:active { transform: translateY(4px); box-shadow: 0 2px 0 #d95a28; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.item {
  display: flex; flex-direction: column; justify-content: space-between; text-align: left;
  min-height: 120px; padding: 14px; border-radius: 22px; color: #fff;
  box-shadow: 0 6px 0 rgba(0,0,0,.18);
}
.item:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.item .nm { font-size: 21px; font-weight: 800; line-height: 1.15; word-break: break-word; }
.item .pr { font-size: 18px; margin-top: 8px; }
.item .pr b { font-size: 26px; }
.item .pr s { opacity: .8; font-size: 15px; }
.c1 { background: #ff5c8a; } .c2 { background: #2bb673; } .c3 { background: #3b82f6; }
.c4 { background: #f5a623; } .c5 { background: #9b5cff; } .c6 { background: #14b8c4; }
.empty { text-align: center; font-size: 20px; margin-top: 40px; }

.overlay {
  position: fixed; inset: 0; background: rgba(43,34,80,.65); z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
}
.overlay[hidden] { display: none; }
.overlay.dark { background: #000; align-items: stretch; }
.card {
  position: relative; width: 100%; max-width: 640px; background: #fff;
  border-radius: 28px 28px 0 0; padding: 26px 20px 28px; max-height: 95vh; overflow: auto;
}
.card.center { text-align: center; }
.card h2 { margin: 0 40px 6px 0; font-size: 28px; }
.card.center h2 { margin: 0 0 6px; }
.close {
  position: absolute; top: 14px; right: 14px; width: 44px; height: 44px;
  border-radius: 50%; background: #eee; font-size: 22px; color: #555;
}
.price { font-size: 20px; margin-bottom: 14px; }
.price b { font-size: 30px; color: #2bb673; }
.price s { color: #999; }

.qtyrow { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 14px 0; }
.round {
  width: 74px; height: 74px; border-radius: 50%; font-size: 44px; font-weight: 800;
  background: #7c5cff; color: #fff; line-height: 1; box-shadow: 0 5px 0 #5a3fd1;
}
.round:active { transform: translateY(3px); box-shadow: 0 2px 0 #5a3fd1; }
#qty {
  width: 120px; height: 74px; font-size: 44px; font-weight: 800; text-align: center;
  border: 4px solid #7c5cff; border-radius: 20px; color: #2b2250; font-family: inherit;
}
.total { text-align: center; font-size: 24px; margin: 6px 0 16px; }
.total b { font-size: 36px; color: #7c5cff; }

.pay { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.big {
  padding: 22px 10px; font-size: 24px; font-weight: 800; color: #fff; border-radius: 22px;
  box-shadow: 0 6px 0 rgba(0,0,0,.22);
}
.big:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(0,0,0,.22); }
.big:disabled { opacity: .6; }
.wide { width: 100%; margin-top: 16px; }
.green { background: #2bb673; } .blue { background: #3b82f6; }
.purple { background: #7c5cff; } .red { background: #ff5c5c; }

.bigtotal { font-size: 56px; font-weight: 800; color: #7c5cff; margin: 6px 0 10px; }
.qr { width: min(80vw, 340px); height: auto; border-radius: 16px; border: 3px solid #eee; margin: 6px auto; display: block; }
.hint { font-size: 18px; color: #6b6490; margin: 10px 0; }
.party { font-size: 80px; }
.link { background: none; color: #8a84a8; font-size: 17px; margin-top: 18px; text-decoration: underline; padding: 10px; }

.scanbox { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; gap: 14px; }
#video { width: 100%; max-height: 60vh; object-fit: cover; border-radius: 20px; background: #111; display: none; }
#reader { width: 100%; display: none; }
#scanMsg { color: #fff; font-size: 20px; text-align: center; margin: 0; }
.frame { display: none; }

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); z-index: 50;
  background: #2b2250; color: #fff; padding: 14px 22px; border-radius: 999px; font-size: 18px;
  max-width: 90vw; text-align: center;
}
.toast[hidden] { display: none; }

/* ---------- reports + admin ---------- */
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 20px; }
.stat { border-radius: 22px; padding: 18px; color: #fff; }
.stat small { display: block; font-size: 16px; opacity: .9; }
.stat b { display: block; font-size: 32px; margin-top: 4px; }
.stat.a { background: #2bb673; } .stat.b { background: #7c5cff; }
.datebar { display: flex; gap: 10px; align-items: center; margin-bottom: 20px; }
.datebar a, .datebar button {
  background: #fff; border-radius: 16px; padding: 14px 18px; font-size: 20px; font-weight: 800;
  text-decoration: none; color: #7c5cff; box-shadow: 0 3px 0 #e4dcc9;
}
.datebar input[type=date] {
  flex: 1; min-width: 0; padding: 12px; font-size: 18px; font-family: inherit;
  border: 3px solid #7c5cff; border-radius: 16px; background: #fff;
}
.panel { background: #fff; border-radius: 22px; padding: 16px; margin-bottom: 20px; box-shadow: 0 3px 0 #e4dcc9; }
.panel h3 { margin: 0 0 10px; font-size: 22px; }
table { width: 100%; border-collapse: collapse; font-size: 18px; }
th { text-align: left; color: #8a84a8; font-size: 15px; padding: 6px 4px; }
td { padding: 10px 4px; border-top: 1px solid #f0ead9; }
td.n, th.n { text-align: right; }
.muted { color: #8a84a8; }

.form label { display: block; font-weight: 700; margin: 12px 0 4px; }
.form input[type=text], .form input[type=number], .form input[type=file] {
  width: 100%; padding: 14px; font-size: 18px; font-family: inherit;
  border: 3px solid #ddd3f5; border-radius: 14px; background: #fff;
}
.btn { display: inline-block; padding: 14px 22px; font-size: 18px; font-weight: 800; color: #fff; background: #7c5cff; border-radius: 16px; text-decoration: none; margin-top: 14px; }
.btn.red { background: #ff5c5c; } .btn.gray { background: #8a84a8; }
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid #f0ead9; }
.row:first-of-type { border-top: 0; }
.row .acts { display: flex; gap: 8px; flex-shrink: 0; }
.row .acts a, .row .acts button { padding: 10px 14px; border-radius: 12px; font-size: 16px; font-weight: 700; text-decoration: none; color: #fff; background: #3b82f6; }
.row .acts button { background: #ff5c5c; }
.ok { background: #e3f7ec; color: #1c7a4a; padding: 12px 14px; border-radius: 14px; margin-bottom: 14px; font-weight: 700; }
.qrprev { max-width: 220px; border-radius: 12px; border: 3px solid #eee; display: block; margin: 8px 0; }
