:root {
  --red: #BA0C2F;
  --red-soft: #F6E3E6;
  --ink: #231916;
  --cream: #F4EFE6;
  --paper: #FBF8F3;
  --line: #E2D9CB;
  --grey: #7A716A;
  --ok: #2F6B3A;
  --ok-soft: #E3EFE5;
  --warn: #B26A00;
  --warn-soft: #FBEFD9;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: -apple-system, "PingFang TC", "Noto Sans TC", "Noto Sans Thai", "Microsoft JhengHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; -webkit-tap-highlight-color: transparent; }
input { font: inherit; }
.hidden { display: none !important; }
.price { font-variant-numeric: tabular-nums; white-space: nowrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 20px;
  border-radius: 12px; font-weight: 700; font-size: 17px; }
.btn-red { background: var(--red); color: #fff; }
.btn-ink { background: var(--ink); color: #fff; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-line { background: #fff; border: 1.5px solid var(--line); }
.btn:disabled { opacity: .5; cursor: default; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 15px; z-index: 99; max-width: calc(100% - 32px); text-align: center; }

/* 登入卡（店家、總公司共用） */
.login { max-width: 360px; margin: 12vh auto 0; padding: 32px 24px; background: #fff; border: 1px solid var(--line); border-radius: 16px; text-align: center; }
.login img { width: 200px; }
.login h1 { font-family: var(--serif); font-size: 22px; margin: 16px 0 4px; }
.login p { color: var(--grey); margin: 0 0 20px; }
.login input { width: 100%; height: 52px; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 14px; font-size: 20px; text-align: center; letter-spacing: .1em; }
.login .btn { width: 100%; margin-top: 12px; }
.login .err { color: var(--red); min-height: 24px; margin: 8px 0 0; }

/* ===== 客人 ===== */
.lang-screen { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: 40px 16px 24px; }
.lang-screen .logo { width: 108px; margin-bottom: 12px; }
.lang-screen .store { font-family: var(--serif); font-size: 18px; color: var(--grey); margin-bottom: 28px; text-align: center; }
.lang-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 420px; }
.lang-grid button { height: 76px; border-radius: 14px; background: #fff; border: 1.5px solid var(--line); font-size: 20px; font-weight: 700; }
.lang-grid button:active { border-color: var(--red); background: var(--red-soft); }
.lang-grid small { display: block; font-size: 12px; font-weight: 400; color: var(--grey); }

.top { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.top-row .logo-h { height: 30px; }
.top-row .store-name { flex: 1; min-width: 0; font-size: 13px; color: var(--grey); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-row .lang-btn { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 14px; background: #fff; white-space: nowrap; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 10px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { flex: none; padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); font-size: 15px; white-space: nowrap; }
.tabs button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.menu { padding: 4px 16px 120px; max-width: 720px; margin: 0 auto; }
.menu h2 { font-family: var(--serif); font-size: 20px; margin: 22px 0 10px; scroll-margin-top: 110px; }
.item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; }
.item:active { border-color: var(--red); }
.item { padding: 10px 14px 10px 10px; }
.thumb { width: 68px; height: 68px; border-radius: 12px; object-fit: cover; background: var(--cream); flex: none; }
.sheet .hero { display: flex; gap: 14px; align-items: center; margin-right: 32px; }
.sheet .hero .thumb { width: 104px; height: 104px; border-radius: 16px; }
.cart-line .thumb { width: 48px; height: 48px; border-radius: 10px; }
.item .nm { flex: 1; min-width: 0; }
.item .nm b { display: block; font-size: 17px; }
.item .nm small { display: block; color: var(--grey); font-size: 13px; }
.item .pr { font-weight: 700; font-size: 17px; }
.item .plus { width: 34px; height: 34px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-size: 22px; line-height: 1; flex: none; }
.rec { display: inline-block; font-size: 11px; font-weight: 700; color: var(--red); border: 1px solid var(--red); border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: 2px; }

.cartbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--line); }
.cartbar .btn { width: 100%; max-width: 688px; margin: 0 auto; display: flex; justify-content: space-between; }

.sheet-bg { position: fixed; inset: 0; background: rgba(35, 25, 22, .45); z-index: 30; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 31; max-height: 90vh; max-height: 90dvh; overflow-y: auto; background: var(--paper);
  border-radius: 18px 18px 0 0; padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.sheet h3 { margin: 0 32px 2px 0; font-size: 21px; font-family: var(--serif); }
.sheet .sub { color: var(--grey); font-size: 14px; margin: 0 0 6px; }
.sheet .x { position: absolute; right: 12px; top: 12px; width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 1px solid var(--line); font-size: 20px; }
.opt h4 { font-size: 15px; margin: 18px 0 8px; color: var(--grey); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { min-height: 44px; padding: 6px 14px; border-radius: 10px; background: #fff; border: 1.5px solid var(--line); font-size: 15px; text-align: center; }
.chips button small { display: block; font-size: 11px; color: var(--grey); }
.chips button.on { border-color: var(--red); background: var(--red-soft); color: var(--red); font-weight: 700; }
.chips button.on small { color: var(--red); }
.fixed-note { color: var(--grey); font-size: 14px; }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 44px; height: 44px; border-radius: 10px; background: #fff; border: 1.5px solid var(--line); font-size: 22px; }
.stepper span { min-width: 44px; text-align: center; font-size: 20px; font-weight: 700; }
.sheet-foot { margin-top: 22px; }
.sheet-foot .btn { width: 100%; }
.two { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; margin-top: 16px; }
.two .btn { padding: 0 8px; font-size: 16px; line-height: 1.2; }
img.logo, img.logo-h, .login img, .start img, .hq-head img { mix-blend-mode: multiply; }

.cart-line { display: flex; gap: 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.cart-line .nm { flex: 1; min-width: 0; }
.cart-line .nm b { display: block; }
.cart-line .nm small { color: var(--grey); font-size: 13px; }
.cart-line .del { color: var(--grey); font-size: 13px; text-decoration: underline; padding: 4px; }
.cart-line .stepper button { width: 34px; height: 34px; font-size: 18px; }
.cart-line .stepper span { min-width: 30px; font-size: 17px; }
.cart-total { display: flex; justify-content: space-between; font-size: 19px; font-weight: 700; padding: 14px 0 0; }
.empty { text-align: center; color: var(--grey); padding: 30px 0; }

.done-screen { max-width: 480px; margin: 0 auto; padding: 28px 16px 40px; text-align: center; }
.done-screen .logo-h { height: 36px; }
.ticket { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 22px 18px; margin-top: 18px; }
.ticket .lbl { color: var(--grey); font-size: 14px; }
.ticket .no { font-size: 64px; font-weight: 800; letter-spacing: .04em; line-height: 1.1; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.ticket .due { font-size: 20px; }
.ticket .due b { font-size: 26px; color: var(--red); }
.status { margin-top: 16px; padding: 12px; border-radius: 12px; font-weight: 700; font-size: 18px; }
.status.pending { background: var(--warn-soft); color: var(--warn); }
.status.paid { background: var(--red-soft); color: var(--red); }
.status.done { background: var(--ok-soft); color: var(--ok); }
.status.cancelled { background: #eee; color: var(--grey); }
.steps { display: flex; justify-content: space-between; margin: 18px 6px 0; position: relative; }
.steps::before { content: ""; position: absolute; left: 12%; right: 12%; top: 13px; height: 2px; background: var(--line); }
.steps div { position: relative; flex: 1; font-size: 12px; color: var(--grey); }
.steps i { display: block; width: 28px; height: 28px; margin: 0 auto 4px; border-radius: 50%; background: #fff; border: 2px solid var(--line); font-style: normal; line-height: 24px; font-weight: 700; }
.steps .on { color: var(--ink); font-weight: 700; }
.steps .on i { background: var(--red); border-color: var(--red); color: #fff; }
.msg { color: var(--grey); font-size: 14px; margin: 14px 0 0; }
.order-lines { text-align: left; margin-top: 18px; font-size: 14px; }
.order-lines div { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }

/* ===== 店家 ===== */
.shop-head { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 16px; background: var(--ink); color: #fff; }
.shop-head img { height: 28px; }
.shop-head .t { font-weight: 700; font-size: 18px; }
.shop-head .stats { display: flex; gap: 16px; margin-left: auto; font-size: 15px; }
.shop-head .stats b { font-size: 20px; }
.shop-head .conn { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--ok); }
.shop-head .conn.bad { background: var(--red); }
.shop-head .lo { color: #fff; opacity: .7; font-size: 13px; text-decoration: underline; }
.start { text-align: center; padding: 18vh 16px; }
.start .btn { min-height: 72px; font-size: 24px; padding: 0 48px; }
.start p { color: var(--grey); }
.board { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px 12px 96px; align-items: start; }
.shop-head .hbtn { color: #fff; border: 1px solid rgba(255, 255, 255, .45); border-radius: 999px; padding: 3px 12px; font-size: 14px; }
.start .tips { text-align: left; max-width: 440px; margin: 18px auto 0; font-size: 14px; line-height: 1.8; }
.donebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom)); background: var(--ok); color: #fff; font-size: 17px; text-align: left; }
.donebar b { font-size: 20px; }
.donebar span { white-space: nowrap; }
.closed-sheet .sum-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 12px 0 14px; }
.closed-sheet .sum-row div { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; }
.closed-sheet .sum-row small { display: block; color: var(--grey); font-size: 12px; }
.closed-sheet .sum-row b { font-size: 19px; }
.closed-row { border: 1px solid var(--line); padding: 10px 12px; margin-bottom: 8px; }
.closed-row .no { font-size: 20px; }
.closed-row .amt { font-size: 17px; }
.closed-row.cancel { opacity: .6; }
.closed-row.cancel .no { text-decoration: line-through; }
.closed-row .mini { color: var(--grey); font-size: 13px; margin-top: 4px; }
@media (max-width: 600px) { .closed-sheet .sum-row { grid-template-columns: 1fr 1fr; } }
.col { background: var(--cream); border-radius: 14px; padding: 10px; min-height: 60vh; }
.col h2 { margin: 2px 4px 10px; font-size: 18px; display: flex; justify-content: space-between; }
.col h2 .cnt { background: var(--ink); color: #fff; border-radius: 999px; padding: 0 10px; font-size: 15px; }
.col.c-pending h2 .cnt { background: var(--warn); }
.col.c-paid h2 .cnt { background: var(--red); }
.col.c-done h2 .cnt { background: var(--ok); }
.card { background: #fff; border-radius: 12px; padding: 12px; margin-bottom: 10px; border: 2px solid transparent; }
.card.new { animation: flash 1s ease-in-out 6; border-color: var(--warn); }
.card.late { border-color: var(--red); }
@keyframes flash { 50% { background: var(--warn-soft); } }
.card .row1 { display: flex; align-items: baseline; gap: 8px; }
.card .no { font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; }
.card .time { color: var(--grey); font-size: 13px; }
.card .amt { margin-left: auto; font-size: 20px; font-weight: 800; }
.card .late-tag { color: var(--red); font-size: 13px; font-weight: 700; }
.card ul { list-style: none; margin: 8px 0; padding: 0; }
.card li { padding: 4px 0; border-top: 1px dashed var(--line); font-size: 16px; }
.card li b { font-size: 17px; }
.card li .q { float: right; font-weight: 800; font-size: 18px; }
.card li .o { color: var(--red); font-weight: 600; }
.card .acts { display: flex; gap: 8px; margin-top: 8px; }
.card .acts .btn { flex: 1; min-height: 52px; font-size: 18px; }
.card .acts .btn-line { flex: none; padding: 0 14px; font-size: 15px; color: var(--grey); }
.card.closed { opacity: .75; padding: 8px 12px; }
.card.closed .no { font-size: 20px; }
.card.closed.cancel .no { text-decoration: line-through; }
@media (max-width: 700px) { .board { grid-template-columns: 1fr; } .col { min-height: 0; } }

/* ===== 總公司 ===== */
.hq-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); }
.hq-head img { height: 32px; }
.hq-head .t { font-family: var(--serif); font-size: 20px; font-weight: 700; }
.hq-head .lo { margin-left: auto; color: var(--grey); font-size: 14px; text-decoration: underline; }
.hq { max-width: 1180px; margin: 0 auto; padding: 16px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.filters button, .filters select, .filters input { height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-size: 15px; }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.filters .sp { flex: 1; }
.filters .upd { color: var(--grey); font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.kpi .l { color: var(--grey); font-size: 14px; }
.kpi .v { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi .s { color: var(--grey); font-size: 13px; }
.panels { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel h3 { margin: 0 0 10px; font-size: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--grey); font-weight: 600; font-size: 13px; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--cream); }
.bars .b { display: grid; grid-template-columns: 9em 1fr 5em; gap: 8px; align-items: center; padding: 4px 0; font-size: 14px; }
.bars .b .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars .track { height: 14px; background: var(--cream); border-radius: 7px; overflow: hidden; }
.bars .fill { height: 100%; background: var(--red); border-radius: 7px; }
.bars .b .n { text-align: right; font-variant-numeric: tabular-nums; }
.hours { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 10px; }
.hours .h { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; font-size: 11px; color: var(--grey); }
.hours .h .col2 { width: 100%; background: var(--ink); border-radius: 4px 4px 0 0; min-height: 1px; }
.hours .h span { margin-top: 4px; }
.st { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.st.pending { background: var(--warn-soft); color: var(--warn); }
.st.paid { background: var(--red-soft); color: var(--red); }
.st.done { background: var(--ok-soft); color: var(--ok); }
.st.cancelled { background: #eee; color: var(--grey); }
.orders td.sum { font-size: 13px; color: var(--grey); max-width: 420px; }
.scroll { overflow-x: auto; }
@media (max-width: 760px) { .kpis { grid-template-columns: 1fr 1fr; } .panels { grid-template-columns: 1fr; } .kpi .v { font-size: 24px; } }
