:root {
  --bg: #f6f4ef; --card: #fff; --text: #222; --muted: #777; --line: #e5e1d8;
  --brand: #d9602b; --brand-dark: #b54a1b;
  --green: #2e8b57; --red: #c0392b; --orange: #d98a1c; --blue: #2c6fbb; --gray: #888;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; }

.topbar { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; min-height: 56px; flex-wrap: wrap; gap: 8px; }
.brand { font-weight: 700; font-size: 18px; color: var(--brand); }
.topbar nav { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.topbar nav a { color: var(--text); }
.topbar nav a.active { color: var(--brand); font-weight: 600; }
.subnav { background: #fbf8f2; border-top: 1px solid var(--line); }
.subnav .wrap { display: flex; gap: 18px; padding-top: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.subnav a { color: var(--text); }
.subnav a.active { color: var(--brand); font-weight: 600; }
.footer { color: var(--muted); font-size: 13px; padding: 24px 16px; }

main { padding-top: 20px; padding-bottom: 20px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.stat b { display: block; font-size: 26px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.flash.ok { background: #eaf6ef; border-color: #b7dfc6; color: #1f6b40; }
.flash.err { background: #fbeceb; border-color: #efbdb8; color: #962d22; }
.flash.warn { background: #fdf4e4; border-color: #f0d6a6; color: #8a5a0b; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 13px; color: var(--muted); font-weight: 600; background: #fbf9f5; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; color: #fff; white-space: nowrap; }
.badge.green { background: var(--green); } .badge.red { background: var(--red); }
.badge.orange { background: var(--orange); } .badge.blue { background: var(--blue); } .badge.gray { background: var(--gray); }

form.inline { display: inline; margin: 0; }
label { display: block; font-size: 14px; margin-bottom: 4px; color: #444; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfc9bd; border-radius: 6px; font: inherit; background: #fff; }
textarea { min-height: 70px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 160px; }
.form-narrow { max-width: 420px; margin: 0 auto; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }

button, .btn { display: inline-block; padding: 8px 16px; border-radius: 6px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; font: inherit; cursor: pointer; text-decoration: none; }
button:hover, .btn:hover { background: var(--brand-dark); text-decoration: none; }
.btn.secondary, button.secondary { background: #fff; color: var(--brand); }
.btn.secondary:hover, button.secondary:hover { background: #fdf0ea; }
button.danger { background: var(--red); border-color: var(--red); }
button.ok { background: var(--green); border-color: var(--green); }
button.small, .btn.small { padding: 3px 10px; font-size: 13px; }
.linkbtn { background: none; border: 0; color: var(--text); padding: 0; cursor: pointer; }
.linkbtn:hover { background: none; color: var(--brand); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.qty { width: 80px !important; text-align: right; }
.qr-box { text-align: center; }
.qr-box .pay-actions { justify-content: center; margin: 8px 0; }
.qr-box img { width: 260px; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.rank { font-weight: 700; color: var(--brand); width: 36px; }
.total-bar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: 12px 0; display: flex; justify-content: space-between; align-items: center; }
.empty { color: var(--muted); padding: 12px 0; }

/* 點餐頁 */
.order-layout { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
.order-layout .cart { position: sticky; top: 76px; }
@media (max-width: 860px) { .order-layout { grid-template-columns: 1fr; } .order-layout .cart { position: static; } }
.menu-items { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.menu-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left;
  background: #fff; color: var(--text); border: 1px solid var(--line); padding: 12px 14px; }
.menu-item:hover { background: #fdf0ea; border-color: var(--brand); }
.menu-item b { color: var(--brand); white-space: nowrap; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cart-main { cursor: pointer; }
.cart-main:hover b { color: var(--brand); }
.cart-note { font-size: 13px; color: var(--brand-dark); }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper button { padding: 2px 10px; }
.stepper.small button { padding: 0 8px; font-size: 13px; }
dialog { border: 0; border-radius: 12px; padding: 20px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.opt-group { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; }
.opt-group legend { font-weight: 600; padding: 0 4px; }
.opt { display: inline-flex; align-items: center; gap: 4px; margin: 4px 14px 4px 0; cursor: pointer; }
.user-pick { max-height: 360px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.user-pick label { display: flex; gap: 6px; align-items: center; padding: 4px 0; margin: 0; cursor: pointer; }
.user-pick label[hidden] { display: none; }

/* 下拉式勾選清單（品項套用選項群組） */
.multi-select { position: relative; }
.multi-select > summary { list-style: none; cursor: pointer; padding: 8px 28px 8px 10px; border: 1px solid #cfc9bd; border-radius: 6px;
  background: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; min-height: 40px; }
.multi-select > summary::-webkit-details-marker { display: none; }
.multi-select > summary::after { content: '▾'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.multi-select[open] > summary { border-color: var(--brand); }
.ms-panel { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 280px; max-width: 420px; background: #fff;
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); padding: 8px 12px; }
.ms-panel label { display: flex; gap: 6px; align-items: baseline; margin: 4px 0; cursor: pointer; white-space: normal; font-weight: normal; }
.ms-panel label .muted { font-size: 12px; }
.ms-bulk { display: inline-block; margin-left: 6px; }
.ms-bulk > summary { display: inline-block; min-height: 0; padding: 1px 22px 1px 8px; font-size: 12px; font-weight: normal; color: var(--brand); }
.ms-bulk-row { display: flex; gap: 6px; align-items: center; margin: 4px 0; font-weight: normal; color: var(--text); }
.ms-bulk-row span { flex: 1; }
.ms-table { overflow: visible; }
@media (max-width: 860px) { .ms-table { overflow-x: auto; } }
