:root {
  --brand: #c8641e;
  --brand-dark: #a44f13;
  --bg: #f6f1ea;
  --card: #ffffff;
  --text: #2a2118;
  --muted: #86786a;
  --line: #e7ddd0;
  --ok: #2e8b57;
  --bad: #c0392b;
  --radius: 14px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

input, button { font: inherit; color: inherit; }
input {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; font-size: 17px; outline: none;
}
input:focus { border-color: var(--brand); }
label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 14px; }
label input { margin-top: 6px; color: var(--text); }

.btn { border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 600; cursor: pointer; }
.btn.big { width: 100%; padding: 16px; font-size: 18px; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-dark); }
.btn.ghost { background: #efe6da; color: var(--text); }
.btn:disabled { opacity: .55; }
.icon-btn { border: 0; background: rgba(255,255,255,.18); color: #fff; width: 42px; height: 42px;
  border-radius: 50%; cursor: pointer; display: grid; place-items: center; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--card); padding: 28px 22px; border-radius: 20px;
  box-shadow: 0 8px 30px rgba(80,50,20,.08); }
.login-card h1 { text-align: center; margin: 6px 0 22px; }
.login-logo { display: block; width: 72px; height: 72px; margin: 0 auto; }
.error { color: var(--bad); min-height: 1.3em; text-align: center; margin: 12px 0 0; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--brand); color: #fff; }
.topbar .cafe { font-weight: 700; font-size: 18px; }
.topbar .sub { font-size: 13px; opacity: .9; }

.tab { padding: 12px 12px calc(var(--tabbar-h) + 90px + var(--safe-b)); max-width: 760px; margin: 0 auto; }

/* ---------- goods grid ---------- */
.search { margin-bottom: 12px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 520px) { .grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(4, 1fr); } }

.card { position: relative; background: var(--card); border-radius: var(--radius); overflow: hidden;
  border: 2px solid transparent; user-select: none; cursor: pointer; display: flex; flex-direction: column;
  box-shadow: 0 1px 3px rgba(80,50,20,.07); transition: transform .08s; }
.card:active { transform: scale(.97); }
.card.in-cart { border-color: var(--brand); }
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #fbf7f2; }
.card .info { padding: 8px 10px 10px; }
.card .t { font-size: 15px; font-weight: 600; line-height: 1.2; min-height: 2.4em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .p { color: var(--brand-dark); font-weight: 700; margin-top: 4px; }
.card .badge { position: absolute; top: 8px; right: 8px; min-width: 34px; height: 34px; padding: 0 8px;
  border-radius: 17px; background: var(--brand); color: #fff; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.stepper { display: flex; align-items: center; gap: 6px; padding: 0 8px 10px; }
.stepper button { flex: 0 0 40px; height: 40px; border: 0; border-radius: 10px; background: #efe6da;
  font-size: 22px; font-weight: 700; cursor: pointer; }
.stepper input { text-align: center; padding: 8px 4px; font-weight: 700; }

/* ---------- cart bar ---------- */
.cart-bar { position: fixed; left: 10px; right: 10px; bottom: calc(var(--tabbar-h) + 10px + var(--safe-b)); z-index: 6;
  display: flex; align-items: center; gap: 10px; padding: 10px; background: #fff; border-radius: 16px;
  box-shadow: 0 6px 24px rgba(60,35,10,.22); max-width: 740px; margin: 0 auto; }
.cart-sum { flex: 1; display: flex; flex-direction: column; }
.cart-sum span { font-size: 13px; color: var(--muted); }
.cart-sum strong { font-size: 19px; }
.cart-bar .btn.primary { padding: 14px 26px; font-size: 17px; }

/* ---------- tab bar ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; display: flex; background: #fff;
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); height: calc(var(--tabbar-h) + var(--safe-b)); }
.tabbar button { flex: 1; border: 0; background: none; font-size: 13px; color: var(--muted); display: flex;
  flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.tabbar button span { font-size: 22px; filter: grayscale(1); opacity: .7; }
.tabbar button.active { color: var(--brand); font-weight: 700; }
.tabbar button.active span { filter: none; opacity: 1; }

/* ---------- panels & lists ---------- */
.panel { background: var(--card); padding: 18px 16px 16px; border-radius: var(--radius); }
.section-title { font-size: 15px; color: var(--muted); margin: 20px 4px 8px; display: flex; justify-content: space-between; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { background: var(--card); border-radius: 12px; padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.item .main { flex: 1; min-width: 0; }
.item .title { font-weight: 600; }
.item .meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.item .amt { font-weight: 700; white-space: nowrap; }
.item.voided { opacity: .5; }
.item.voided .amt { text-decoration: line-through; }
.void-btn { border: 0; background: #f6e3e0; color: var(--bad); border-radius: 10px; padding: 8px 10px; font-size: 13px; cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { background: var(--card); border-radius: var(--radius); padding: 14px; }
.stat .k { color: var(--muted); font-size: 14px; }
.stat .v { font-size: 22px; font-weight: 800; margin: 4px 0 2px; overflow-wrap: anywhere; }
.stat .s { color: var(--muted); font-size: 13px; }

/* ---------- sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(30,20,10,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 560px; background: #fff; border-radius: 20px 20px 0 0; padding: 18px 16px calc(16px + var(--safe-b));
  max-height: 88dvh; overflow: auto; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet h2 { margin: 0 0 12px; }
.sheet-line { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.sheet-line .q { color: var(--muted); }
.sheet-total { display: flex; justify-content: space-between; font-size: 22px; padding: 14px 0 18px; }
.row { display: flex; gap: 10px; }

.toast { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 30; background: var(--text); color: #fff;
  padding: 12px 18px; border-radius: 12px; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
