/* ==========================================================
   國泰洋酒 智慧通路管理系統 · 共用樣式(三端共用)
   色票單一真相 = 本檔 :root(ADR 003)。各端只寫版面,不另定色。
   順序:tokens → reset → 文字 → 按鈕 → 表單 → 徽章 → 卡片 → 商品列 → 步進器 → modal/toast → 工具
   ========================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Sans+TC:wght@400;500;700&family=Noto+Serif+TC:wght@500;600;700&display=swap');

:root {
  /* 色彩 */
  --bg: #F6F1E7;          /* 頁面底(暖米白,禁純白) */
  --surface: #FBF8F2;     /* 卡片 / 面板 */
  --surface-2: #EFE8DB;   /* 次要面板 / 選中底 */
  --line: #E6DFD3;        /* 框線 */
  --line-2: #D6CBB9;      /* 較深框線 / hover */
  --primary: #6B1E2B;     /* 酒紅 */
  --primary-dark: #4F121C;
  --primary-soft: #F2E6E3;
  --ink: #2B2622;
  --sub: #6E645D;
  --mute: #9A9088;
  --ok: #3E6A4B;   --ok-soft: #E4EBDF;
  --warn: #8F6219; --warn-soft: #F3E8D2;
  --warn-tint: #FBF3E3; --warn-line: #E6CF9F;  /* 待出貨卡片底 / 框 */
  --danger: #A2382B; --danger-soft: #F5E1DC; --danger-dark: #8A2C21;
  --line-green: #06C755;
  --invert-bg: #2B2622; --invert-ink: #F2EDE4; --invert-sub: #C9BFB2;
  /* 節奏 */
  --radius: 2px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --shadow: 0 1px 2px rgba(43, 38, 34, .06), 0 4px 16px rgba(43, 38, 34, .06);
  --ease: cubic-bezier(.22, .61, .36, 1);
  /* 字 */
  --f-serif: 'Noto Serif TC', 'Songti TC', Georgia, serif;
  --f-sans: 'Noto Sans TC', 'Microsoft JhengHei', 'PingFang TC', sans-serif;
  --f-num: 'Inter', 'Noto Sans TC', sans-serif;
}

/* ── reset ── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.6 var(--f-sans); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-family: var(--f-serif); font-weight: 600; line-height: 1.35; letter-spacing: .02em; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
table { border-collapse: collapse; width: 100%; }

.ic { width: 20px; height: 20px; flex: none; display: inline-block; vertical-align: middle; }
.ic.is-fill { fill: currentColor; }
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 28px; height: 28px; }

/* ── 文字 ── */
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; letter-spacing: 0; }
.serif { font-family: var(--f-serif); }
.sub { color: var(--sub); }
.mute { color: var(--mute); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 700; }
.price { font-family: var(--f-num); font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; }
.eyebrow { font: 600 11px/1 var(--f-num); letter-spacing: .18em; text-transform: uppercase; color: var(--sub); }
.sec-title { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.sec-title h2 { font-size: 18px; }
.sec-title h3 { font-size: 16px; }
.sec-title .more { font-size: 13px; color: var(--primary); display: inline-flex; align-items: center; gap: 2px; }
.sec-title .more .ic { width: 16px; height: 16px; }

/* ── 按鈕 ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.btn:hover { border-color: var(--ink); }
.btn .ic { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #FBF8F2; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--sub); }
.btn-ghost:hover { color: var(--ink); border-color: transparent; background: var(--surface-2); }
.btn-line { background: var(--line-green); border-color: var(--line-green); color: #fff; }
.btn-line:hover { filter: brightness(.95); border-color: var(--line-green); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger.is-solid { background: var(--danger); color: #FBF8F2; font-weight: 600; }
.btn-danger.is-solid:hover { background: var(--danger-dark); border-color: var(--danger-dark); }
.btn-lg { min-height: 48px; font-size: 16px; padding: 0 22px; }
.btn-sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }

.icon-btn { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); position: relative; }
.icon-btn .dot { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--primary); color: #fff; font: 600 11px/18px var(--f-num); text-align: center; }

/* ── 品牌標(三端共用)── */
.brand-mark { width: 36px; height: 36px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--primary); color: #F6F1E7; font: 600 16px/1 var(--f-serif); }

/* ── 表單 ── */
.field { display: block; }
.field > span { display: block; font-size: 13px; color: var(--sub); margin-bottom: 4px; }
.input, .select, .textarea { width: 100%; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); outline: none; transition: border-color .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); }
.textarea { min-height: 72px; resize: vertical; }
.field > span em { font-style: normal; color: var(--danger); }
.field.is-error .input, .field.is-error .select, .field.is-error .textarea { border-color: var(--danger); background: var(--danger-soft); }
.field-err { display: block; margin-top: 4px; font-size: 12px; color: var(--danger); }
.search-box { position: relative; }
.search-box .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--mute); width: 18px; height: 18px; }
.search-box .input { padding-left: 38px; }
/* 搜尋框右側掃碼鈕:分隔線隔開,主色圖示 */
.search-box:has(.search-scan) .input { padding-right: 52px; }
.search-box .search-scan { position: absolute; right: 0; top: 0; bottom: 0; width: 46px; display: flex; align-items: center; justify-content: center; border-left: 1px solid var(--line-2); color: var(--primary); }
.search-box .search-scan .ic { position: static; transform: none; width: 22px; height: 22px; color: inherit; }
.search-box .search-scan:active { background: var(--primary-soft); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { accent-color: var(--primary); width: 16px; height: 16px; }

/* ── 徽章 ── */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: var(--radius); font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--sub); }
.badge.is-ok { background: var(--ok-soft); color: var(--ok); }
.badge.is-wait { background: var(--warn-soft); color: var(--warn); }
.badge.is-mute { background: var(--surface-2); color: var(--mute); }
.badge.is-danger { background: var(--danger-soft); color: var(--danger); }
.badge.is-primary { background: var(--primary-soft); color: var(--primary); }
.badge.is-line { background: #E2F6EA; color: #04883A; }
.badge.is-outline { background: transparent; border: 1px solid var(--line-2); }
/* 訂單狀態標籤:圖示 + 文字;待出貨(要處理)實心最醒目,已出貨柔和,已取消只剩框線 */
.st-badge { height: 24px; padding: 0 9px 0 7px; font-size: 12px; font-weight: 600; }
.st-badge .ic { width: 14px; height: 14px; stroke-width: 2.25; }
.st-badge.is-pending { background: var(--warn); color: #FBF8F2; }
.st-badge.is-shipped { background: var(--ok-soft); color: var(--ok); }
.st-badge.is-cancelled { background: transparent; color: var(--mute); border: 1px solid var(--line-2); }
.st-badge.is-big { height: 28px; padding: 0 11px 0 9px; font-size: 13px; }
.st-badge.is-big .ic { width: 16px; height: 16px; }
.tier { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 5px; border: 1px solid var(--primary); color: var(--primary); font: 600 11px/1 var(--f-num); border-radius: var(--radius); }

/* ── 卡片 / 分隔 ── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: var(--sp-4); }
.divider { height: 1px; background: var(--line); border: 0; margin: var(--sp-3) 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--sub); }
.kv dd { margin: 0; text-align: right; }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); font-size: 13px; color: var(--sub); }
.notice .ic { color: var(--primary); margin-top: 1px; width: 18px; height: 18px; }
.notice.is-warn { background: var(--warn-soft); border-color: #E7D5AE; color: #6E4A10; }
.notice.is-warn .ic { color: var(--warn); }
.notice.is-ok { background: var(--ok-soft); border-color: #CBD9C4; color: #2E5038; }
.notice.is-ok .ic { color: var(--ok); }
.notice.is-err { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.notice.is-err .ic { color: var(--danger); }
/* LINE(LIFF)登入中遮罩(partials/liff-login.php):授權回程時蓋住頁面,免得登入表單先閃一次 */
.liff-busy { position: fixed; inset: 0; z-index: 9999; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: var(--bg); color: var(--sub); font-size: 15px; }
.liff-busy.on { display: flex; }
.liff-busy i { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--primary); animation: liff-spin .8s linear infinite; }
@keyframes liff-spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 48px 16px; color: var(--sub); }
.empty .ic { width: 40px; height: 40px; color: var(--line-2); margin: 0 auto 12px; }

/* ── 分頁籤(segmented / underline)── */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.seg > * { min-height: 38px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; color: var(--sub); border-right: 1px solid var(--line-2); }
.seg > *:last-child { border-right: 0; }
.seg > .is-active { background: var(--primary); color: #FBF8F2; font-weight: 500; }
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs > * { flex: none; padding: 10px 0; font-size: 14px; color: var(--sub); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs > .is-active { color: var(--primary); border-color: var(--primary); font-weight: 500; }
.tabs .cnt { font-family: var(--f-num); font-size: 12px; margin-left: 2px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 14px; display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 16px; font-size: 13px; color: var(--sub); background: var(--surface); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--invert-ink); }
/* 類別列:單行左右滑;哪一側還有內容,那側就淡出並出現箭頭(點一下捲一屏) */
.chips-box { position: relative; --fade-l: 0px; --fade-r: 0px; }
.chips-box .chips { scroll-behavior: smooth; overscroll-behavior-x: contain; cursor: grab;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--fade-l), #000 calc(100% - var(--fade-r)), transparent); }
.chips-box .chips.is-dragging { cursor: grabbing; scroll-behavior: auto; }
.chips-box.can-prev { --fade-l: 40px; }
.chips-box.can-next { --fade-r: 40px; }
/* 箭頭刻意和標籤不同:實心酒紅小圓、無框、白色粗箭頭,一眼看出是「操作」不是「選項」 */
.chips-arrow { position: absolute; top: 4px; z-index: 1; width: 24px; height: 24px; padding: 0; display: none; align-items: center; justify-content: center; border: 0; border-radius: 50%; background: var(--primary); color: var(--invert-ink); box-shadow: 0 2px 6px rgba(107, 30, 43, .3); cursor: pointer; transition: background .15s, transform .15s; }
.chips-arrow .ic { width: 16px; height: 16px; stroke-width: 2.5; }
.chips-arrow:hover { background: var(--primary-dark); }
.chips-arrow:active { transform: scale(.9); }
.chips-arrow.is-prev { left: 0; }
.chips-arrow.is-next { right: 0; }
.chips-box.can-prev .is-prev, .chips-box.can-next .is-next { display: inline-flex; }

/* ── 商品列(店家叫貨 / 業務代下單 共用)── */
.p-row { display: grid; grid-template-columns: 76px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.p-row:last-child { border-bottom: 0; }
.p-thumb { position: relative; width: 76px; height: 92px; background: var(--surface); border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.p-thumb img { max-height: 86px; width: auto; mix-blend-mode: multiply; }
.p-thumb .flag { position: absolute; left: 0; top: 0; font-size: 10px; padding: 2px 5px; background: var(--ink); color: var(--invert-ink); letter-spacing: .05em; }
.p-thumb .flag.is-inq { background: var(--warn); }
.p-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.p-head { display: flex; gap: 6px; align-items: flex-start; }
.p-name { font-size: 15px; font-weight: 500; line-height: 1.4; flex: 1; min-width: 0; }
.p-name a:hover { color: var(--primary); }
.p-meta { font: 12px/1.4 var(--f-num); color: var(--mute); }
.p-note { font-size: 12px; color: var(--sub); }
.p-note b { color: var(--primary); font-weight: 600; }
.p-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: 6px; }
.p-price .lbl { font-size: 11px; color: var(--sub); display: block; line-height: 1.2; }
.p-price .price { font-size: 17px; }
.p-price .tax { font-size: 11px; color: var(--mute); margin-left: 2px; }
.p-stock { font: 12px var(--f-num); color: var(--ok); }
.p-stock.is-low { color: var(--warn); }
.p-row.is-out .p-thumb img, .p-row.is-inquiry .p-thumb img { opacity: .55; }
.p-row.is-out .p-name, .p-row.is-inquiry .p-name { color: var(--sub); }
.fav-btn { color: var(--line-2); padding: 2px; margin: -2px -2px 0 0; }
.fav-btn .ic { width: 20px; height: 20px; }
.fav-btn.is-on { color: var(--primary); }
.fav-btn.is-on .ic { fill: currentColor; }

/* ── 數量步進器 ── */
.stepper { display: inline-grid; grid-template-columns: 34px 44px 34px; height: 34px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface); }
.stepper button { display: flex; align-items: center; justify-content: center; color: var(--ink); }
.stepper button .ic { width: 16px; height: 16px; }
.stepper button:disabled { color: var(--line-2); cursor: default; }
.stepper input { width: 100%; text-align: center; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: transparent; font: 600 15px var(--f-num); outline: none; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper.has-qty { border-color: var(--primary); }
.stepper.has-qty input { color: var(--primary); }
.add-btn { height: 34px; padding: 0 14px; display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--primary); color: var(--primary); border-radius: var(--radius); font-size: 14px; font-weight: 500; background: transparent; }
.add-btn .ic { width: 16px; height: 16px; }
.add-btn:hover { background: var(--primary-soft); }

/* ── modal / sheet / toast ── */
.modal { position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(43, 38, 34, .45); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); }
.modal.is-open { opacity: 1; pointer-events: auto; }
.modal-box { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius); padding: 24px 20px 20px; box-shadow: var(--shadow); transform: translateY(8px); transition: transform .2s var(--ease); }
.modal.is-open .modal-box { transform: none; }
.modal-box h3 { font-size: 18px; margin-bottom: 8px; }
.modal-box .body { color: var(--sub); font-size: 14px; }
.modal-box .actions { display: flex; gap: 8px; margin-top: 20px; }
.modal-box .actions .btn { flex: 1; }
/* 底部滑出(選項多 / 要填原因的設定):手機貼底,桌機仍置中 */
.modal.is-sheet { align-items: flex-end; padding: 0; }
.modal.is-sheet .modal-box { max-width: 480px; max-height: 88vh; overflow-y: auto; padding-bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateY(24px); }
@media (min-width: 720px) { .modal.is-sheet { align-items: center; padding: 16px; } }
.toast { position: fixed; left: 50%; bottom: 96px; z-index: 95; transform: translate(-50%, 12px); background: var(--invert-bg); color: var(--invert-ink); padding: 10px 16px; border-radius: var(--radius); font-size: 14px; display: inline-flex; gap: 8px; align-items: center; opacity: 0; pointer-events: none; transition: all .2s var(--ease); max-width: calc(100% - 32px); }
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast .ic { width: 18px; height: 18px; color: #9FD3AE; }

/* ── 商品規格 / 介紹(前台 + LIFF 共用)── */
.specs { display: grid; grid-template-columns: 88px 1fr; margin: 0; border-top: 1px solid var(--line); font-size: 14px; }
.specs dt, .specs dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); }
.specs dt { color: var(--sub); }
.intro { font-size: 14px; line-height: 1.9; color: #4A423C; }

/* ── 法定警語 ── */
.legal { font-size: 12px; color: var(--mute); text-align: center; letter-spacing: .08em; padding: 16px 0; }

/* ── 工具 ── */
.row { display: flex; align-items: center; gap: var(--sp-2); }
.between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.stack > * + * { margin-top: var(--sp-3); }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); } .mt-5 { margin-top: var(--sp-5); }
.mb-4 { margin-bottom: var(--sp-4); }
.right { text-align: right; }
