/* ============================================================
   團購平台｜元件
   ============================================================ */

/* ---------- 頂列 ---------- */
.top { background: var(--c-surface); border-bottom: 1px solid var(--c-line); position: sticky; top: 0; z-index: 20; }
.top-in { max-width: var(--content-max); margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: var(--s-3); }
.wide .top-in { max-width: var(--wide-max); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-weight: 700; font-size: var(--f-md); white-space: nowrap; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center;
  border: 2px solid var(--c-duo); color: var(--c-duo); font-size: 15px; font-weight: 800; line-height: 1;
}
.brand-role { font-size: var(--f-xs); font-weight: 600; color: var(--c-ink-2); background: var(--c-primary-050); border-radius: var(--r-pill); padding: 2px 8px; }
.top-nav { margin-left: auto; display: flex; gap: 2px; overflow-x: auto; }
.top-nav a { text-decoration: none; font-size: var(--f-sm); color: var(--c-ink-2); padding: 6px 10px; border-radius: var(--r-pill); white-space: nowrap; }
.top-nav a:hover { background: var(--c-primary-050); }
.top-nav a[aria-current="page"] { background: var(--c-primary); color: #fff; }

/* ---------- 版面 ---------- */
.wrap { max-width: var(--content-max); margin: 0 auto; padding: 16px 16px 96px; }
.wrap-wide { max-width: var(--wide-max); margin: 0 auto; padding: 24px 16px 96px; }
.page-head { margin: 8px 0 16px; }
.page-head h1 { font-size: var(--f-xl); line-height: 1.3; }
.lead { color: var(--c-ink-soft); font-size: var(--f-sm); margin-top: 4px; }
.section { margin-top: 24px; }
.section-title { font-size: var(--f-md); font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.section-title .muted { font-weight: 400; }
.stack { display: grid; gap: 12px; }
.stack-sm { display: grid; gap: 6px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--c-ink-soft); }
.small { font-size: var(--f-sm); }
.xs { font-size: var(--f-xs); }
.strong { font-weight: 700; }
.num { font-variant-numeric: tabular-nums; }
.duo { color: var(--c-duo); }
.ok { color: var(--c-success); }
.divider { height: 1px; background: var(--c-line); margin: 12px 0; border: 0; }

/* ---------- 卡片 ---------- */
.card { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-pad { padding: 16px; }
.card + .card { margin-top: 12px; }
.note {
  background: var(--c-surface-2); border: 1px dashed var(--c-fill-600); border-radius: var(--r-md);
  padding: 10px 12px; font-size: var(--f-sm); color: var(--c-ink-2);
}
.note-duo { background: var(--c-duo-050); border: 0; color: var(--c-duo-600); }
.note-ok { background: var(--c-success-050); border: 0; color: var(--c-success); }
.note-info { background: var(--c-info-050); border: 0; color: var(--c-info); }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r-pill);
  border: 1px solid var(--c-line); background: var(--c-surface); color: var(--c-ink);
  font-size: var(--f-sm); font-weight: 600; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--c-primary-050); }
.btn-primary { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-600); }
.btn-duo { background: var(--c-duo); border-color: var(--c-duo); color: #fff; }
.btn-duo:hover { background: var(--c-duo-600); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: var(--f-xs); }
.btn-lg { min-height: 48px; font-size: var(--f-md); }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; pointer-events: none; }

/* ---------- 標籤 ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--c-line); background: var(--c-surface); color: var(--c-ink-2);
  border-radius: var(--r-pill); padding: 5px 12px; font-size: var(--f-sm); white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }
.tag { display: inline-block; font-size: var(--f-xs); padding: 1px 8px; border-radius: var(--r-pill); background: var(--c-primary-050); color: var(--c-ink-2); white-space: nowrap; }
.tag-duo { background: var(--c-duo-050); color: var(--c-duo-600); }
.tag-soon { background: var(--c-warn-050); color: var(--c-warn); }
.tag-later { background: var(--c-primary-050); color: var(--c-ink-soft); border: 1px dashed var(--c-fill-600); }

/* 狀態：圖示＋文字，不只靠顏色 */
.st { display: inline-flex; align-items: center; gap: 4px; font-size: var(--f-xs); font-weight: 600; padding: 2px 8px; border-radius: var(--r-pill); white-space: nowrap; }
.st::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-open { background: var(--c-duo-050); color: var(--c-duo-600); }
.st-closed { background: var(--c-warn-050); color: var(--c-warn); }
.st-making { background: var(--c-info-050); color: var(--c-info); }
.st-shipped { background: var(--c-info-050); color: var(--c-info); }
.st-done { background: var(--c-success-050); color: var(--c-success); }
.st-cancelled, .st-refunded { background: var(--c-primary-050); color: var(--c-ink-soft); }

/* ---------- 檔期橫幅 ---------- */
.season {
  display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-radius: var(--r-lg);
  background: var(--c-duo); color: #fff; text-decoration: none;
}
.season-mark { font-size: 26px; font-weight: 800; border: 2px solid rgba(255,255,255,.8); border-radius: 10px; width: 48px; height: 48px; display: grid; place-items: center; flex: none; }
.season-title { font-weight: 700; }
.season-sub { font-size: var(--f-sm); opacity: .9; }

/* ---------- 選品卡 ---------- */
.pgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pcard { display: flex; flex-direction: column; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); overflow: hidden; text-decoration: none; box-shadow: var(--sh-1); }
.pcard:hover { box-shadow: var(--sh-2); }
.pcard-thumb { position: relative; background: var(--c-paper); aspect-ratio: 4 / 3; display: grid; place-items: center; padding: 12px; }
.pcard-thumb .tag { position: absolute; top: 8px; left: 8px; }
.pcard-body { padding: 10px 12px 12px; display: grid; gap: 4px; }
.pcard-name { font-size: var(--f-sm); font-weight: 700; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.8em; }
.pcard-earn { font-size: var(--f-sm); color: var(--c-duo); font-weight: 700; }
.pcard-meta { font-size: var(--f-xs); color: var(--c-ink-soft); }

/* ---------- 印面 ---------- */
.stamp-box { background: var(--c-paper); border-radius: var(--r-md); display: grid; place-items: center; padding: 16px; }
.stamp-svg { width: 100%; height: auto; max-height: 160px; }
.pcard-thumb .stamp-svg { max-height: 96px; }

/* ---------- 價格 ---------- */
.price { font-size: var(--f-xl); font-weight: 800; color: var(--c-duo); font-variant-numeric: tabular-nums; }
.price-unit { font-size: var(--f-sm); color: var(--c-ink-soft); font-weight: 400; }
.price-old { font-size: var(--f-sm); color: var(--c-ink-soft); text-decoration: line-through; }

/* ---------- 進度條（階梯價）：填色為朱紅，底軌為同色系淡色 ---------- */
.meter { height: 8px; border-radius: var(--r-pill); background: var(--c-duo-200); overflow: hidden; }
.meter-fill { height: 100%; border-radius: var(--r-pill); background: var(--c-duo); }
.tiers { display: flex; justify-content: space-between; font-size: var(--f-xs); color: var(--c-ink-soft); margin-top: 6px; gap: 8px; }
.tiers .hit { color: var(--c-ink); font-weight: 700; }

/* ---------- 數字卡 ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.tile { background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-lg); padding: 14px 16px; }
.tile-label { font-size: var(--f-sm); color: var(--c-ink-2); }
.tile-value { font-size: var(--f-xl); font-weight: 600; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile-note { font-size: var(--f-xs); color: var(--c-ink-soft); margin-top: 2px; }
.tile-main { border-color: var(--c-ink); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: var(--f-sm); }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--c-line-2); vertical-align: top; }
.table th { font-size: var(--f-xs); color: var(--c-ink-soft); font-weight: 600; white-space: nowrap; background: var(--c-surface-2); }
.table td.r, .table th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tfoot td { font-weight: 700; border-bottom: 0; }

/* ---------- 表單 ---------- */
.field { display: grid; gap: 6px; }
.field > label, .field-label { font-size: var(--f-sm); font-weight: 600; }
.field .hint { font-size: var(--f-xs); color: var(--c-ink-soft); }
.req { color: var(--c-duo); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: var(--r-md);
  border: 1px solid var(--c-line); background: var(--c-surface); font-size: 16px;
}
.textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-ring); }
.input[aria-invalid="true"] { border-color: var(--c-danger); }
.err { font-size: var(--f-xs); color: var(--c-danger); }
.options { display: grid; gap: 8px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface); cursor: pointer; }
.option input { margin-top: 4px; accent-color: var(--c-primary); }
.option:has(input:checked) { border-color: var(--c-primary); box-shadow: 0 0 0 3px var(--c-primary-ring); }
.option-title { font-weight: 600; font-size: var(--f-sm); }
.option-sub { font-size: var(--f-xs); color: var(--c-ink-soft); }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: var(--f-sm); }
.check input { margin-top: 4px; accent-color: var(--c-primary); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--c-line); border-radius: var(--r-pill); overflow: hidden; }
.qty button { width: 40px; height: 40px; border: 0; background: var(--c-surface); font-size: 18px; }
.qty output { min-width: 36px; text-align: center; font-weight: 700; }

/* ---------- 底部固定列 ---------- */
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--c-surface); border-top: 1px solid var(--c-line); z-index: 15; }
.bottom-bar-in { max-width: var(--content-max); margin: 0 auto; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: center; gap: 12px; }
.bottom-bar-in .grow { flex: 1; min-width: 0; }

/* ---------- 接龍 ---------- */
.jl { display: grid; gap: 0; grid-template-columns: minmax(0, 1fr); }  /* 欄寬不跟著長文字撐開 */
.jl-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--c-line-2); font-size: var(--f-sm); }
.jl-item:last-child { border-bottom: 0; }
.jl-item .tag { flex: none; }
.jl-no { width: 24px; color: var(--c-ink-soft); font-variant-numeric: tabular-nums; font-size: var(--f-xs); }
.jl-name { font-weight: 600; }
.jl-spec { color: var(--c-ink-soft); font-size: var(--f-xs); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--c-duo-050); color: var(--c-duo-600); display: grid; place-items: center; font-weight: 800; flex: none; }

/* ---------- 收益的清單（手機友善，不用表格） ---------- */
.erow { display: grid; gap: 4px; padding: 12px 16px; border-bottom: 1px solid var(--c-line-2); font-size: var(--f-sm); }
.erow:last-child { border-bottom: 0; }

/* ---------- 分享卡（LINE 訊息的預覽） ---------- */
.share { background: var(--c-chat); border-radius: var(--r-lg); padding: 16px; }
.share-bubble { background: #fff; border-radius: 16px; overflow: hidden; max-width: 300px; }
.share-bubble .stamp-box { border-radius: 0; }
.share-body { padding: 10px 12px; display: grid; gap: 4px; }
.share-title { font-weight: 700; font-size: var(--f-sm); }
.share-link { font-size: var(--f-xs); color: var(--c-info); word-break: break-all; }

/* ---------- 步驟 ---------- */
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; }
.steps li { position: relative; padding: 0 0 14px 26px; font-size: var(--f-sm); color: var(--c-ink-soft); }
.steps li::before { content: ""; position: absolute; left: 5px; top: 6px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--c-fill-600); background: var(--c-surface); }
.steps li::after { content: ""; position: absolute; left: 10px; top: 18px; bottom: 0; width: 2px; background: var(--c-line); }
.steps li:last-child::after { display: none; }
.steps li.done { color: var(--c-ink); }
.steps li.done::before { background: var(--c-success); border-color: var(--c-success); }
.steps li.now { color: var(--c-ink); font-weight: 700; }
.steps li.now::before { border-color: var(--c-duo); background: var(--c-duo); }

/* ---------- 分頁籤 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--c-line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 12px; font-size: var(--f-sm); color: var(--c-ink-soft); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--c-ink); font-weight: 700; border-bottom-color: var(--c-ink); }
.count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: var(--r-pill); background: var(--c-primary-050); font-size: 11px; text-align: center; }

/* ---------- 對話框與提示 ---------- */
.modal { border: 0; border-radius: var(--r-lg); padding: 0; width: min(420px, calc(100vw - 32px)); box-shadow: var(--sh-3); }
.modal::backdrop { background: rgba(20, 22, 28, .45); }
.modal-body { padding: 20px; display: grid; gap: 12px; }
.modal-title { font-size: var(--f-lg); font-weight: 700; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%); z-index: 50;
  background: var(--c-ink); color: #fff; padding: 10px 16px; border-radius: var(--r-pill); font-size: var(--f-sm);
  box-shadow: var(--sh-2); max-width: calc(100vw - 32px);
}

/* ---------- 入口頁 ---------- */
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.role { display: grid; gap: 6px; padding: 18px; text-decoration: none; }
.role:hover { box-shadow: var(--sh-2); }
.role-who { font-size: var(--f-xs); color: var(--c-ink-soft); }
.role-name { font-size: var(--f-lg); font-weight: 700; }
.flow { counter-reset: f; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.flow li { counter-increment: f; display: grid; grid-template-columns: 28px 1fr; gap: 10px; font-size: var(--f-sm); }
.flow li::before { content: counter(f); width: 24px; height: 24px; border-radius: 50%; background: var(--c-primary); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }

/* ---------- 批次（廠商） ---------- */
.batch-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px 16px; font-size: var(--f-sm); margin-top: 10px; }
.kv dt { font-size: var(--f-xs); color: var(--c-ink-soft); }
.kv dd { margin: 0; font-weight: 600; }

@media (min-width: 720px) {
  .pgrid { grid-template-columns: repeat(3, 1fr); }
  .wide .pgrid { grid-template-columns: repeat(4, 1fr); }
}
@media print {
  .top, .bottom-bar, .no-print { display: none !important; }
  body { background: #fff; }
}
