/* 馬可工作台：酒紅＋金細線＋米白紙感，直角、不用圓角卡片和膠囊標籤 */
:root {
  --wine: #7A2A2A;
  --wine-deep: #561A1E;
  --gold: #B8915A;
  --gold-soft: #C6A068;
  --ink: #3A2E2A;
  --muted: #807064;
  --paper: #F4EDE3;
  --paper-2: #ECE3D5;
  --surface: #FBF8F3;
  --green: #0A423E;
  --line: rgba(184, 145, 90, .38);
  --line-strong: rgba(184, 145, 90, .7);
  --warn: #A33A22;
  --serif: 'Noto Serif TC', 'Songti TC', serif;
  --latin: 'Cormorant', 'Noto Serif TC', serif;
  --top: 56px;
  --navh: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--serif); font-weight: 500; color: var(--ink); font-size: 16px; line-height: 1.6;
  background: linear-gradient(180deg, #F8F3EB 0%, var(--paper) 40%, #EFE6D9 100%) fixed;
  min-height: 100dvh; letter-spacing: .02em;
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
.num { font-family: var(--latin); font-weight: 600; font-variant-numeric: lining-nums tabular-nums; letter-spacing: 0; }
.en { font-family: var(--latin); font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.wine { color: var(--wine); }
.warn { color: var(--warn); }

/* ── 頂列 */
.topbar {
  position: sticky; top: 0; z-index: 30; height: calc(var(--top) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(135deg, #802C2E, var(--wine-deep)); color: #F4EDE3;
  border-bottom: 1px solid var(--gold-soft);
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand-en { font-family: var(--latin); font-weight: 600; letter-spacing: .28em; color: var(--gold-soft); font-size: 17px; }
.brand-zh { font-weight: 600; letter-spacing: .3em; font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; min-width: 0; }
.sync { background: none; border: 0; color: #E9DCCB; padding: 8px 0; font-size: 13px; white-space: nowrap; }
.sync.bad { color: #F2B8A6; }
.who { color: var(--gold-soft); white-space: nowrap; }

/* ── 導覽：手機在底部，大螢幕在左側 */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--navh) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: var(--surface); border-top: 1px solid var(--line-strong);
}
.nav a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--muted); font-size: 15px; letter-spacing: .2em; border-top: 2px solid transparent; margin-top: -1px; }
.nav a.on { color: var(--wine); font-weight: 700; border-top-color: var(--gold); }
.nav a em { font-style: normal; font-family: var(--latin); font-weight: 700; font-size: 14px; line-height: 1; color: var(--gold); min-height: 14px; letter-spacing: 0; }
.nav a.nav-new { background: var(--wine); color: #F4EDE3; font-weight: 600; border-top-color: var(--gold); }
.nav a.nav-new.on { background: var(--wine-deep); color: #fff; }

.view { padding: 18px 16px calc(var(--navh) + var(--safe-b) + 28px); max-width: 1180px; margin: 0 auto; }
.loading { padding: 60px 0; text-align: center; color: var(--muted); }

@media (min-width: 900px) {
  .nav { top: calc(var(--top) + env(safe-area-inset-top, 0px)); right: auto; width: 168px; height: auto; grid-template-columns: 1fr; grid-auto-rows: 64px; align-content: start;
    border-top: 0; border-right: 1px solid var(--line-strong); padding: 18px 0; background: rgba(251, 248, 243, .7); }
  .nav a { flex-direction: row; justify-content: space-between; padding: 0 22px 0 26px; border-top: 0; border-left: 2px solid transparent; margin: 0; font-size: 16px; }
  .nav a.on { border-left-color: var(--gold); background: var(--surface); }
  .nav a.nav-new { margin: 10px 18px; justify-content: center; letter-spacing: .3em; border-left: 0; }
  .view { margin-left: 168px; padding: 28px 36px 60px; }
}

/* ── 標題區 */
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding-bottom: 14px; border-bottom: 1px solid var(--line-strong); margin-bottom: 4px; flex-wrap: wrap; }
.kicker { font-family: var(--latin); color: var(--gold); letter-spacing: .3em; font-size: 13px; font-weight: 600; text-transform: uppercase; }
h1 { margin: 2px 0 0; font-size: 26px; font-weight: 700; color: var(--wine); letter-spacing: .12em; line-height: 1.3; }
h2 { margin: 30px 0 6px; font-size: 17px; font-weight: 600; color: var(--wine); letter-spacing: .14em; display: flex; align-items: baseline; gap: 10px; }
h2 .kicker { font-size: 12px; }
.stat { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.stat b { font-family: var(--latin); font-size: 40px; font-weight: 600; color: var(--wine); line-height: 1; font-variant-numeric: lining-nums; }
.stat span { color: var(--muted); font-size: 14px; }
.stat .unit { color: var(--ink); font-size: 15px; margin-left: 4px; }

/* ── 清單列：細線分隔、不用卡片 */
.list { border-top: 1px solid var(--line); }
.row { border-bottom: 1px solid var(--line); }
.row-main { display: grid; grid-template-columns: 1fr auto; gap: 6px 16px; padding: 16px 2px; align-items: center; }
.row-title { font-size: 17px; font-weight: 600; color: var(--wine); line-height: 1.45; }
.row-sub { color: var(--muted); font-size: 14px; }
.row.done { opacity: .5; }
.row-tap { cursor: pointer; }
.row-tap:hover { background: rgba(255, 255, 255, .35); }
.tag { font-family: var(--latin); font-weight: 700; font-size: 12px; letter-spacing: .14em; color: var(--gold); white-space: nowrap; }
.tag.zh { font-family: var(--serif); font-weight: 600; letter-spacing: .1em; }
.note { color: var(--wine); font-size: 14px; border-left: 2px solid var(--gold); padding-left: 10px; margin-top: 4px; }
.amount { font-family: var(--latin); font-weight: 600; font-size: 30px; color: var(--ink); line-height: 1; text-align: right; font-variant-numeric: lining-nums; }
.amount small { font-family: var(--serif); font-size: 13px; color: var(--muted); margin-left: 3px; font-weight: 500; }

/* ── 按鈕：直角、細框 */
.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 20px; border: 1px solid var(--wine); background: transparent; color: var(--wine); font-weight: 600; letter-spacing: .14em; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn.solid { background: var(--wine); color: #F8F3EB; }
.btn.solid:hover { background: var(--wine-deep); }
.btn.ghost { border-color: var(--line-strong); color: var(--ink); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.link { background: none; border: 0; padding: 6px 0; color: var(--wine); text-decoration: underline; text-underline-offset: 4px; text-decoration-color: var(--gold); font-size: 14px; }

/* ── 勾選框：方形金框、勾起來是酒紅 */
.check { display: inline-flex; align-items: center; gap: 10px; min-height: 46px; cursor: pointer; user-select: none; background: none; border: 0; padding: 0; font-size: 15px; }
.check i { width: 28px; height: 28px; border: 1.5px solid var(--gold); background: var(--surface); display: inline-grid; place-items: center; flex: none; font-style: normal; color: #F8F3EB; font-size: 17px; font-weight: 700; }
.check.on i { background: var(--wine); border-color: var(--wine); }
.check.on i::before { content: '✓'; }
.check.part i { background: linear-gradient(135deg, var(--wine) 50%, var(--surface) 50%); border-color: var(--wine); }
.check small { display: block; font-size: 12px; color: var(--muted); line-height: 1.2; }

/* ── 分頁籤：底線，不用膠囊 */
.tabs { display: flex; gap: 22px; overflow-x: auto; border-bottom: 1px solid var(--line-strong); margin: 0 -16px 0; padding: 0 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px 0 10px; color: var(--muted); white-space: nowrap; font-size: 15px; letter-spacing: .12em; margin-bottom: -1px; }
.tabs button.on { color: var(--wine); border-bottom-color: var(--wine); font-weight: 700; }
.tabs button .num { margin-left: 4px; color: var(--gold); font-size: 16px; }
@media (min-width: 900px) { .tabs { margin: 0; padding: 0; } }

/* ── 表單 */
.field { display: block; margin: 16px 0 0; }
.field > span { display: block; font-size: 13px; color: var(--muted); letter-spacing: .14em; margin-bottom: 6px; }
.input, textarea.input, select.input { width: 100%; min-height: 48px; border: 0; border-bottom: 1px solid var(--line-strong); background: rgba(255, 255, 255, .55); padding: 10px 12px; font-size: 16px; border-radius: 0; outline: none; }
textarea.input { min-height: 72px; resize: vertical; }
.input:focus { border-bottom-color: var(--wine); background: #fff; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); border: 1px solid var(--line-strong); }
.seg button { min-height: 46px; border: 0; border-right: 1px solid var(--line); background: transparent; color: var(--ink); letter-spacing: .08em; padding: 0 6px; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--wine); color: #F8F3EB; font-weight: 600; }
.grid2 { display: grid; grid-template-columns: 1fr; gap: 0 20px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.search { position: relative; margin: 14px 0 4px; }
.search .input { padding-left: 14px; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; z-index: 5; background: var(--surface); border: 1px solid var(--line-strong); border-top: 0; max-height: 280px; overflow: auto; box-shadow: 0 10px 24px rgba(58, 46, 42, .12); }
.suggest button { display: block; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 12px 14px; }
.suggest button:hover { background: var(--paper); }

/* ── 補單：商品格 */
.picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); margin-top: 10px; }
.pick { position: relative; min-height: 86px; background: rgba(255, 255, 255, .4); border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 12px 10px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; gap: 6px; }
.pick:hover { background: #fff; }
.pick b { font-weight: 600; font-size: 15px; line-height: 1.4; color: var(--ink); }
.pick .num { color: var(--muted); font-size: 18px; }
.pick.in { background: #fff; box-shadow: inset 0 0 0 2px var(--wine); }
.pick .qty { position: absolute; top: 0; right: 0; background: var(--wine); color: #F8F3EB; font-family: var(--latin); font-weight: 700; min-width: 28px; height: 28px; display: grid; place-items: center; font-size: 17px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.stepper { display: inline-grid; grid-template-columns: 44px 44px 44px; border: 1px solid var(--line-strong); height: 44px; }
.stepper button { border: 0; background: transparent; font-size: 22px; color: var(--wine); }
.stepper span { display: grid; place-items: center; border-left: 1px solid var(--line); border-right: 1px solid var(--line); font-family: var(--latin); font-weight: 700; font-size: 24px; font-variant-numeric: lining-nums; }
.savebar { position: sticky; bottom: calc(var(--navh) + var(--safe-b)); z-index: 10; margin: 26px -16px 0; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--line-strong); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (min-width: 900px) { .savebar { bottom: 0; margin: 26px 0 0; } }
.savebar .amount { font-size: 32px; }
.alert { border-left: 3px solid var(--warn); background: rgba(163, 58, 34, .07); padding: 10px 14px; color: var(--warn); font-size: 14px; margin-top: 12px; }
.hint { border-left: 2px solid var(--gold); padding: 8px 12px; color: var(--muted); font-size: 14px; margin-top: 12px; background: rgba(255, 255, 255, .35); }

/* ── 烘豆：展開的訂單 */
.orders-in { padding: 0 0 14px 2px; display: grid; gap: 2px; }
.orders-in .check { min-height: 40px; align-items: flex-start; padding: 4px 0; }
.orders-in .check i { width: 24px; height: 24px; font-size: 15px; margin-top: 2px; }
.orders-in .check.on i { background: var(--gold); border-color: var(--gold); }
.roast-actions { display: flex; align-items: center; gap: 10px; }
.chev { font-family: var(--latin); color: var(--gold); font-size: 20px; transition: transform .2s; display: inline-block; }
.open .chev { transform: rotate(90deg); }

/* ── 訂單：步驟 */
.steps { display: flex; gap: 14px; align-items: flex-start; }
.steps .check { flex-direction: column; gap: 2px; min-height: 0; font-size: 12px; color: var(--muted); letter-spacing: .1em; }
.steps .check i { width: 32px; height: 32px; }
.steps .check.locked { cursor: default; }
.order-meta { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }

/* ── 大螢幕：訂單左右兩欄 */
.split { display: block; }
@media (min-width: 1100px) {
  .split.has-detail { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 32px; }
  .split .detail-pane { position: sticky; top: calc(var(--top) + 20px); max-height: calc(100dvh - var(--top) - 40px); overflow: auto; border-left: 1px solid var(--line-strong); padding-left: 28px; }
}

/* ── 底部抽屜（手機）／右側面板（大螢幕） */
.sheet { position: fixed; inset: 0; z-index: 50; background: rgba(42, 30, 28, .42); display: flex; align-items: flex-end; justify-content: center; }
.sheet-body { width: 100%; max-width: 620px; max-height: 92dvh; overflow: auto; background: var(--surface); border-top: 2px solid var(--gold); padding: 22px 20px calc(22px + var(--safe-b)); animation: up .22s ease-out; }
@media (min-width: 900px) { .sheet { align-items: center; } .sheet-body { border: 1px solid var(--line-strong); border-top: 2px solid var(--gold); } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sheet-head h3 { margin: 2px 0 0; color: var(--wine); font-size: 20px; letter-spacing: .1em; line-height: 1.4; }
.x { background: none; border: 0; font-size: 26px; color: var(--muted); line-height: 1; padding: 4px 8px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 22px; }
.unit-input { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; }
.unit-input { grid-template-columns: 1fr 128px; }
.unit-input .input { font-size: 22px; }
.unit-input .num { font-size: 15px; color: var(--muted); padding-bottom: 12px; white-space: nowrap; }

/* ── 表格（庫存） */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; letter-spacing: .12em; padding: 12px 8px; border-bottom: 1px solid var(--line-strong); }
.table td { padding: 14px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table td.r, .table th.r { text-align: right; }
.table tr.tap { cursor: pointer; }
.table tr.tap:hover td { background: rgba(255, 255, 255, .4); }
.table .num { font-size: 20px; }
@media (max-width: 640px) { .table .hide-s { display: none; } .table td, .table th { padding-left: 4px; padding-right: 4px; } }

/* ── 更多 */
.menu-list a, .menu-list button { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 18px 2px; border: 0; border-bottom: 1px solid var(--line); background: none; text-decoration: none; font-size: 17px; letter-spacing: .12em; text-align: left; }
.menu-list .chev { font-size: 22px; }

.empty { padding: 34px 0; color: var(--muted); text-align: center; border-bottom: 1px solid var(--line); }
.empty b { display: block; font-family: var(--latin); color: var(--gold); letter-spacing: .3em; font-size: 13px; margin-bottom: 6px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--navh) + var(--safe-b) + 16px); z-index: 60; background: var(--ink); color: #F4EDE3; padding: 12px 18px; display: flex; gap: 18px; align-items: center; max-width: calc(100% - 32px); box-shadow: 0 10px 24px rgba(0, 0, 0, .18); font-size: 15px; }
.toast { width: max-content; }
.toast button { background: none; border: 0; color: var(--gold-soft); font-weight: 700; letter-spacing: .12em; padding: 4px 0; white-space: nowrap; flex: none; }
@media (min-width: 900px) { .toast { bottom: 28px; margin-left: 84px; } }
.offline { background: var(--warn); color: #fff; text-align: center; font-size: 13px; padding: 4px; }

/* ── 登入 */
body.signed-out .nav, body.signed-out .topbar-right { display: none; }
body.signed-out .view { margin-left: auto; }
.login { max-width: 400px; margin: 4vh auto 0; text-align: center; }
.login-logo { width: 88px; height: 88px; display: block; margin: 0 auto 14px; }
.login h1 { margin-bottom: 18px; }
.login .field, .login .hint, .login .alert { text-align: left; }
.login-google { display: flex; justify-content: center; margin: 22px 0 6px; min-height: 44px; }
.login-or { display: flex; align-items: center; gap: 14px; color: var(--muted); margin: 14px 0 0; font-size: 14px; }
.login-or::before, .login-or::after { content: ''; flex: 1; border-top: 1px solid var(--line-strong); }
.login-code { font-size: 34px; text-align: center; letter-spacing: .3em; min-height: 64px; }
.qr { width: min(260px, 70vw); margin: 18px auto 6px; background: #fff; border: 1px solid var(--line); padding: 6px; }
.qr svg { display: block; width: 100%; height: auto; }
.login-code-show { display: flex; flex-direction: column; align-items: center; margin-top: 14px; }
.login-code-show b { font-size: 40px; letter-spacing: .12em; color: var(--wine); line-height: 1.2; }
