:root {
  --blue: #108AAF;       /* Morgen Kaffee - Dau accent */
  --blue-dark: #0C6A87;
  --kape: #80011F;       /* Kapebaluan accent */
  --kape-dark: #5c0016;
  --crema: #FFDDBC;
  --roast: #684226;
  --honey: #FFC857;
  --paper: #FFFDF9;
  --ink: #20201f;
  --line: #e7e0d6;
  --muted: #7a736a;
  --good: #2e7d4f;
  --warn: #b26a00;
  --bad: #b3261e;
  --accent: var(--blue);
  --accent-dark: var(--blue-dark);
}
body[data-branch="kapebaluan"] { --accent: var(--kape); --accent-dark: var(--kape-dark); }

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--paper); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
a { color: inherit; }

.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ---------------------------------------------------------- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--accent); color: #fff;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.topbar .brand { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.topbar .branch-pill {
  font-size: 12px; background: rgba(255,255,255,.18); padding: 4px 10px; border-radius: 999px;
  cursor: pointer; border: none; color: #fff;
}
.topbar .cart-btn {
  position: relative; background: rgba(255,255,255,.18); border: none; color: #fff;
  padding: 8px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.topbar .cart-btn .count {
  position: absolute; top: -6px; right: -6px; background: var(--honey); color: #4a3600;
  font-size: 11px; font-weight: 800; border-radius: 999px; min-width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* --------------------------------------------------------- branch picker */
.picker-wrap {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 20px; text-align: center; gap: 8px;
}
.picker-wrap .logo { font-size: 15px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.picker-wrap h1 { font-size: 26px; margin: 4px 0 6px; }
.picker-wrap p.sub { color: var(--muted); margin: 0 0 22px; font-size: 15px; }
.branch-cards { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.branch-card {
  border: 2px solid var(--line); border-radius: 16px; padding: 18px 20px; text-align: left;
  background: #fff; cursor: pointer; position: relative; transition: transform .1s, border-color .15s;
}
.branch-card:active { transform: scale(.98); }
.branch-card.morgen { border-color: var(--blue); }
.branch-card.kapebaluan { border-color: var(--kape); }
.branch-card h3 { margin: 0 0 4px; font-size: 18px; }
.branch-card p { margin: 0; color: var(--muted); font-size: 13.5px; }
.branch-card .badge {
  position: absolute; top: -10px; right: 14px; background: var(--honey); color: #4a3600;
  font-size: 11px; font-weight: 800; padding: 3px 10px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: .04em;
}
.branch-card.morgen h3 { color: var(--blue-dark); }
.branch-card.kapebaluan h3 { color: var(--kape-dark); }

/* -------------------------------------------------------- order type ---- */
.type-cards { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 14px; }
.type-card {
  border: 2px solid var(--line); border-radius: 16px; padding: 18px 20px; text-align: left;
  background: #fff; cursor: pointer; display: flex; align-items: center; gap: 14px;
}
.type-card .emoji { font-size: 28px; }
.type-card h3 { margin: 0 0 2px; font-size: 17px; }
.type-card p { margin: 0; color: var(--muted); font-size: 13px; }
.back-link { margin-top: 18px; font-size: 13.5px; color: var(--muted); text-decoration: underline; background: none; border: none; cursor: pointer; }

/* ------------------------------------------------------------- menu ---- */
.cat-nav {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 12px; background: #fff;
  border-bottom: 1px solid var(--line); position: sticky; top: 56px; z-index: 15;
  -webkit-overflow-scrolling: touch;
}
.cat-nav button {
  flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 14px; font-size: 13.5px; font-weight: 600; color: var(--ink); cursor: pointer;
}
.cat-nav button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.menu-body { flex: 1; padding: 6px 14px 100px; }
.cat-section { margin-top: 18px; }
.cat-section h2 { font-size: 16px; margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.product-card {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 13px 14px; margin-bottom: 10px; cursor: pointer;
}
.product-card:active { background: #fbfaf8; }
.product-card .info h4 { margin: 0 0 3px; font-size: 15.5px; }
.product-card .info .price { color: var(--muted); font-size: 13.5px; }
.product-card .add-btn {
  flex: none; width: 36px; height: 36px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-size: 20px; font-weight: 700; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.addon-tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; color: var(--roast);
  background: var(--crema); border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: middle;
}

/* ---------------------------------------------------- variant sheet ---- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(20,18,15,.45); z-index: 40;
  display: none; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.active { display: flex; }
.sheet {
  background: #fff; width: 100%; max-width: 480px; border-radius: 20px 20px 0 0;
  padding: 20px 20px 24px; max-height: 85vh; overflow-y: auto;
}
.sheet h3 { margin: 0 0 4px; font-size: 19px; }
.sheet .desc { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
.variant-row {
  display: flex; align-items: center; justify-content: space-between;
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px; cursor: pointer;
}
.variant-row.selected { border-color: var(--accent); background: #f4fbfd; }
body[data-branch="kapebaluan"] .variant-row.selected { background: #fbf1f3; }
.variant-row .name { font-weight: 600; font-size: 14.5px; }
.variant-row .price { color: var(--muted); font-size: 14px; }
.qty-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 18px 0 6px; }
.qty-row button {
  width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--line); background: #fff;
  font-size: 20px; cursor: pointer;
}
.qty-row .n { font-size: 18px; font-weight: 700; min-width: 24px; text-align: center; }
.sheet .cta {
  width: 100%; padding: 15px; border: none; border-radius: 14px; background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 10px;
}
.sheet .cancel { width: 100%; text-align: center; padding: 10px; background: none; border: none; color: var(--muted); font-size: 14px; cursor: pointer; }

/* ----------------------------------------------------- upsell toast ----
   Non-blocking: no backdrop, background stays interactive. Slides up from
   the bottom and auto-dismisses on its own if the customer ignores it. */
.upsell-toast {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
  display: flex; justify-content: center;
  padding: 0 16px calc(16px + env(safe-area-inset-bottom));
  pointer-events: none;
  transform: translateY(130%);
  transition: transform .28s cubic-bezier(.32,.72,0,1);
}
.upsell-toast.active { transform: translateY(0); }
.upsell-card {
  background: #fff; border: 2px solid var(--honey); border-radius: 18px; padding: 18px;
  max-width: 480px; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  pointer-events: auto;
}
.upsell-card .label { font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--warn); margin-bottom: 6px; }
.upsell-item { display: flex; align-items: center; gap: 12px; margin: 10px 0 16px; }
.upsell-item .emoji-box {
  width: 52px; height: 52px; border-radius: 12px; background: var(--crema);
  display: flex; align-items: center; justify-content: center; font-size: 26px; flex: none;
}
.upsell-item .txt h4 { margin: 0 0 2px; font-size: 15.5px; }
.upsell-item .txt .price { color: var(--muted); font-size: 13.5px; }
.upsell-actions { display: flex; gap: 10px; }
.upsell-actions button { flex: 1; padding: 13px; border-radius: 12px; font-size: 14.5px; font-weight: 700; cursor: pointer; border: none; }
.upsell-actions .yes { background: var(--accent); color: #fff; }
.upsell-actions .no { background: #f1eee8; color: var(--ink); }

/* ------------------------------------------------------------- cart ---- */
.cart-body { flex: 1; padding: 14px; }
.cart-line { display: flex; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-line .l h4 { margin: 0 0 2px; font-size: 14.5px; }
.cart-line .l .meta { color: var(--muted); font-size: 12.5px; }
.cart-line .r { text-align: right; flex: none; }
.cart-line .r .price { font-weight: 700; font-size: 14.5px; }
.cart-line .r .stepper { display: flex; align-items: center; gap: 6px; margin-top: 6px; justify-content: flex-end; }
.cart-line .r .stepper button { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer; }
.cart-line.upsell { background: #fffaf0; margin: 0 -14px; padding: 12px 14px; }
.empty-cart { text-align: center; color: var(--muted); padding: 60px 20px; }

.sticky-footer {
  position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line);
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
}
.sticky-footer .row { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 4px; color: var(--muted); }
.sticky-footer .row.total { font-size: 17px; font-weight: 800; color: var(--ink); margin-top: 6px; }
.primary-btn {
  width: 100%; padding: 15px; border: none; border-radius: 14px; background: var(--accent); color: #fff;
  font-size: 16px; font-weight: 700; cursor: pointer; margin-top: 10px;
}
.primary-btn:disabled { opacity: .5; }

/* --------------------------------------------------------- checkout ---- */
.form-body { flex: 1; padding: 16px; max-width: 480px; width: 100%; margin: 0 auto; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; color: var(--roast); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  font-size: 15px; background: #fff; color: var(--ink);
}
.field textarea { resize: vertical; min-height: 60px; }
.pay-options { display: flex; flex-direction: column; gap: 8px; }
.pay-opt {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex;
  align-items: center; gap: 10px; cursor: pointer; font-size: 14.5px;
}
.pay-opt.selected { border-color: var(--accent); background: #f4fbfd; }
body[data-branch="kapebaluan"] .pay-opt.selected { background: #fbf1f3; }
.note {
  font-size: 12.5px; color: var(--muted); background: #f7f5f0; border-radius: 10px; padding: 10px 12px; margin-top: 4px;
}
.proof-preview { margin-top: 10px; }
.proof-preview .thumb-wrap { position: relative; display: inline-block; }
.proof-preview img { max-width: 140px; max-height: 140px; border-radius: 10px; border: 1.5px solid var(--line); display: block; }
.proof-preview .remove-proof {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--ink); color: #fff; border: none; font-size: 14px; line-height: 1; cursor: pointer;
}
.proof-preview .proof-busy { font-size: 13px; color: var(--muted); }

.qr-wrap { display: flex; flex-direction: column; align-items: center; text-align: center; background: #fff; border: 1.5px solid var(--line); border-radius: 14px; padding: 14px; }
.qr-wrap .qr-code { width: 100%; max-width: 220px; border-radius: 8px; }
.qr-wrap .qr-caption { margin: 10px 0 0; font-size: 13.5px; font-weight: 700; color: var(--roast); line-height: 1.4; }

/* --------------------------------------------------------------- conf --- */
.conf-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 20px; text-align: center; }
.conf-check { font-size: 56px; margin-bottom: 10px; }
.conf-wrap h1 { margin: 0 0 6px; font-size: 22px; }
.conf-wrap .order-no { font-size: 15px; color: var(--muted); margin-bottom: 20px; }
.conf-card { width: 100%; max-width: 420px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px; text-align: left; }
.conf-status { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.conf-status.new { background: #fff1d6; color: var(--warn); }
.conf-status.preparing { background: #dcecff; color: var(--blue-dark); }
.conf-status.ready { background: #ddf1e5; color: var(--good); }
.conf-status.completed { background: #eee; color: var(--muted); }
.order-again { margin-top: 20px; background: none; border: 1.5px solid var(--line); border-radius: 12px; padding: 12px 20px; font-size: 14px; cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13.5px;
  z-index: 60; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.toast.show { opacity: 1; }

.loading-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 5px; }

@media (min-width: 640px) {
  .menu-body, .cart-body { max-width: 560px; margin: 0 auto; width: 100%; }
}
