:root {
  --ink: #2d211c;
  --muted: #786c66;
  --paper: #fffaf4;
  --card: #ffffff;
  --line: #eadfd4;
  --brand: #7c3f25;
  --brand-dark: #5b2c19;
  --soft: #f5e9dc;
  --red: #d44848;
  --blue: #3f72ba;
  --green: #4f8f62;
  --yellow: #d9a923;
  --shadow: 0 12px 35px rgba(74, 46, 31, .08);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 8% 0%, #fff1dc 0, transparent 30%), var(--paper); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.topbar { max-width: 880px; margin: auto; padding: 26px 20px 14px; display: flex; align-items: end; justify-content: space-between; gap: 16px; }
.eyebrow, .step { margin: 0 0 4px; color: var(--brand); font-size: 12px; font-weight: 800; letter-spacing: .12em; }
h1 { margin: 0; font-size: clamp(24px, 5vw, 34px); }
h2, h3 { margin: 0; }
h2 { font-size: 20px; }
h3 { font-size: 18px; }
.date-control { color: var(--muted); font-size: 12px; font-weight: 700; }
.date-control input { display: block; margin-top: 5px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: white; color: var(--ink); }
.tabs { position: sticky; top: 0; z-index: 10; max-width: 880px; margin: 0 auto 18px; padding: 6px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; background: rgba(255,255,255,.94); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.tab { border: 0; border-radius: 9px; padding: 11px 8px; color: var(--muted); background: transparent; font-weight: 800; }
.tab.active { color: white; background: var(--brand); }
main { max-width: 880px; margin: auto; padding: 0 20px 60px; }
.panel { display: none; }
.panel.active { display: block; }
.section-heading { margin: 24px 0 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.section-heading.compact { margin-top: 20px; }
.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.product { min-height: 132px; padding: 17px 12px 12px; border: 2px solid transparent; border-radius: 16px; background: white; color: var(--ink); box-shadow: var(--shadow); text-align: left; }
.product strong, .product span { display: block; }
.product strong { font-size: 18px; }
.product > span { margin-top: 7px; color: var(--brand); font-size: 22px; font-weight: 900; }
.product.active { border-color: var(--brand); background: #fff6ea; }
.item-quantity { margin-top: 12px; display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: white; text-align: center; }
.item-quantity button { height: 36px; border: 0; color: var(--brand); background: var(--soft); font-size: 20px; }
.item-quantity strong { font-size: 16px; }
.coupon-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.coupon { min-height: 78px; padding: 12px; border: 2px solid transparent; border-radius: 13px; background: white; box-shadow: var(--shadow); font-weight: 800; }
.coupon small { display: block; margin-top: 3px; color: var(--muted); font-weight: 600; }
.coupon.active { border-color: var(--brand); }
.coupon[data-color="blue"] { border-bottom: 5px solid var(--blue); }
.coupon[data-color="green"] { border-bottom: 5px solid var(--green); }
.coupon[data-color="yellow"] { border-bottom: 5px solid var(--yellow); }
.coupon-quantity { margin-top: 9px; }
.hint, .muted { color: var(--muted); font-size: 13px; }
.hint { margin: 9px 0 0; line-height: 1.55; }
.checkout-card, .card { margin-top: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.checkout-card > div { display: flex; justify-content: space-between; padding: 7px 0; color: var(--muted); }
.checkout-card > div strong { color: var(--ink); }
.checkout-card .total { margin-top: 7px; padding-top: 14px; border-top: 1px dashed var(--line); color: var(--ink); font-weight: 800; }
.checkout-card .total strong { color: var(--brand); font-size: 30px; }
.primary, .secondary { width: 100%; margin-top: 14px; padding: 14px 18px; border: 0; border-radius: 12px; font-weight: 900; }
.primary { color: white; background: var(--brand); }
.primary:hover { background: var(--brand-dark); }
.primary:disabled { cursor: not-allowed; opacity: .45; }
.secondary { color: var(--brand); background: var(--soft); }
.record-list { display: grid; gap: 8px; }
.record { padding: 13px 14px; display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.record-title { font-weight: 800; }
.record-meta { margin-top: 3px; color: var(--muted); font-size: 12px; }
.record-amount { text-align: right; font-weight: 900; }
.delete { width: 30px; height: 30px; border: 0; border-radius: 9px; background: #f8eaea; color: var(--red); }
.empty { padding: 26px; border: 1px dashed var(--line); border-radius: 13px; color: var(--muted); text-align: center; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 9px; }
.metric { padding: 15px; border-radius: 15px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { display: block; margin-top: 8px; font-size: 22px; }
.table-card h3 { margin-bottom: 12px; }
.summary-row { padding: 10px 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(100px, .55fr) auto auto; gap: 16px; align-items: center; border-bottom: 1px solid var(--line); }
.summary-row:last-child { border-bottom: 0; }
.summary-row .unit-price, .summary-row span:nth-last-child(2) { color: var(--muted); }
.summary-row strong { min-width: 80px; text-align: right; }
.red-card { border-top: 5px solid var(--red); }
.red-text { color: var(--red); }
.redemption-form { margin: 16px 0; display: grid; grid-template-columns: 1.4fr .7fr 1fr; gap: 10px; align-items: end; }
.redemption-form label, .vendor-card label { color: var(--muted); font-size: 12px; font-weight: 700; }
input, select { width: 100%; margin-top: 5px; padding: 11px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--ink); }
.redemption-form .secondary { margin: 0; }
.red-total { margin-top: 15px; padding-top: 15px; display: flex; justify-content: space-between; border-top: 1px dashed var(--line); font-weight: 800; }
.red-total strong { color: var(--red); font-size: 24px; }
.notice { margin-bottom: 14px; padding: 13px 14px; color: #6d4911; background: #fff3d4; border-radius: 12px; font-size: 13px; }
.vendor-settings { display: grid; gap: 12px; }
.vendor-card { padding: 16px; border-radius: 16px; background: white; border: 1px solid var(--line); box-shadow: var(--shadow); }
.vendor-card.blue { border-left: 6px solid var(--blue); }
.vendor-card.green { border-left: 6px solid var(--green); }
.vendor-card.yellow { border-left: 6px solid var(--yellow); }
.vendor-card h3 { margin-bottom: 12px; }
.vendor-fields { display: grid; grid-template-columns: 1fr 1fr .6fr; gap: 10px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; transform: translate(-50%, 120px); opacity: 0; padding: 12px 18px; border-radius: 999px; color: white; background: #2d211c; box-shadow: var(--shadow); transition: .25s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.error { background: var(--red); }

@media (max-width: 640px) {
  .topbar { padding-top: 18px; align-items: center; }
  .tabs { margin-left: 12px; margin-right: 12px; border-radius: 12px; }
  main { padding-left: 14px; padding-right: 14px; }
  .product-grid { grid-template-columns: 1fr 1fr; }
  .product:first-child { grid-column: span 2; }
  .coupon-grid { grid-template-columns: 1fr 1fr; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .redemption-form, .vendor-fields { grid-template-columns: 1fr; }
  .record { grid-template-columns: 1fr auto; }
  .record .delete { grid-column: 2; grid-row: 1 / span 2; }
  .summary-row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; }
  .summary-row .unit-price { grid-column: 1; font-size: 12px; }
  .summary-row > span:nth-last-child(2) { grid-column: 2; grid-row: 1 / span 2; }
  .summary-row > strong { grid-column: 3; grid-row: 1 / span 2; }
}
