/* 示範小店 — shared styles (no external assets) */
:root {
  --bg: #f4f6f8; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --primary: #0f766e; --primary-600: #0d9488; --primary-50: #ecfdf5;
  --warn: #b45309; --warn-bg: #fffbeb; --danger: #b91c1c; --danger-bg: #fef2f2;
  --info: #1d4ed8; --info-bg: #eff6ff; --ok: #15803d; --ok-bg: #f0fdf4;
  --radius: 14px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 4px 16px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); line-height: 1.55; font-size: 15px;
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang HK", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.hidden { display: none !important; }

/* Demo banner */
.demo-banner {
  background: repeating-linear-gradient(45deg, #fde68a, #fde68a 12px, #fcd34d 12px, #fcd34d 24px);
  color: #78350f; text-align: center; font-weight: 700; padding: 8px 12px; font-size: .95rem;
  position: sticky; top: 0; z-index: 50; border-bottom: 1px solid #f59e0b;
}

/* Header */
.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .inner { max-width: 1120px; margin: 0 auto; padding: 12px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.brand .logo { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--primary), #34d399); display: grid; place-items: center; color: #fff; font-size: 1rem; }
.nav { display: flex; gap: 4px; margin-left: auto; flex-wrap: wrap; }
.nav a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; font-weight: 600; font-size: .92rem; }
.nav a:hover { background: var(--bg); color: var(--text); }
.nav a.active { background: var(--primary-50); color: var(--primary); }

.container { max-width: 1120px; margin: 0 auto; padding: 20px 16px 48px; }
.narrow { max-width: 760px; }
.page-title { margin: 4px 0 16px; }
.page-title p { margin: 4px 0 0; color: var(--muted); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; border: 1px solid #eef0f3; }
.card > h2 { display: flex; align-items: center; gap: 8px; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--primary); color: #fff; font-size: .8rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.sticky { position: sticky; top: 56px; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } .sticky { position: static; } }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } h1 { font-size: 1.3rem; } }

/* Forms */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input[type=text], input[type=tel], input[type=email], input[type=date], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 10px; font: inherit; background: #fff; color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(13,148,136,.35); border-color: var(--primary-600); }
textarea { min-height: 76px; resize: vertical; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.req { color: var(--danger); }

.choice-group { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span { display: block; padding: 11px 12px; border: 1.5px solid var(--line); border-radius: 12px; text-align: center; font-weight: 600; cursor: pointer; background: #fff; transition: .15s; }
.choice input:checked + span { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.choice input:focus-visible + span { outline: 2px solid var(--primary-600); }

/* product rows */
.product { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.product:last-child { border-bottom: 0; }
.product .thumb { width: 52px; height: 52px; border-radius: 12px; background: #e6f4f1; display: grid; place-items: center; font-weight: 800; color: var(--primary); flex: none; font-size: .9rem; }
.product .info { flex: 1; min-width: 0; }
.product .name { font-weight: 700; }
.qty { display: flex; align-items: center; border: 1px solid #d1d5db; border-radius: 10px; overflow: hidden; flex: none; }
.qty button { width: 36px; height: 38px; border: 0; background: #f9fafb; font-size: 1.1rem; cursor: pointer; color: var(--text); }
.qty button:disabled { color: #cbd5e1; cursor: not-allowed; }
.qty input { width: 48px; height: 38px; border: 0; border-left: 1px solid #e5e7eb; border-right: 1px solid #e5e7eb; text-align: center; border-radius: 0; padding: 0; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* summary */
.summary-row { display: flex; justify-content: space-between; padding: 5px 0; gap: 10px; }
.summary-row.total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; font-size: 1.2rem; font-weight: 800; }
.summary-items { font-size: .9rem; color: var(--muted); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 700; cursor: pointer; text-decoration: none; background: var(--primary); color: #fff; line-height: 1.2; }
.btn:hover { background: var(--primary-600); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; padding: 13px; font-size: 1.02rem; }
.btn.secondary { background: #fff; color: var(--text); border-color: #d1d5db; }
.btn.secondary:hover { background: #f9fafb; }
.btn.danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.btn.sm { padding: 6px 10px; font-size: .84rem; border-radius: 8px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* alerts */
.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 12px; font-size: .92rem; border: 1px solid; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert.error { background: var(--danger-bg); border-color: #fecaca; color: var(--danger); }
.alert.info { background: var(--info-bg); border-color: #bfdbfe; color: #1e3a8a; }
.alert.warn { background: var(--warn-bg); border-color: #fde68a; color: #78350f; }
.alert.ok { background: var(--ok-bg); border-color: #bbf7d0; color: #14532d; }

.privacy { display: flex; gap: 10px; align-items: flex-start; font-size: .88rem; background: #f9fafb; border: 1px solid var(--line); padding: 12px; border-radius: 12px; margin: 12px 0; }
.privacy input { margin-top: 4px; width: 18px; height: 18px; flex: none; }

/* honeypot: hidden from humans, still in DOM for bots */
.hp { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

/* badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.st-待付款 { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.st-已付款 { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.st-準備中 { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.st-可取貨 { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.st-已寄出 { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.st-已完成 { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.st-已取消 { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: #f3f4f6; font-size: .78rem; color: #374151; font-weight: 600; }
.tag.low { background: var(--danger-bg); color: var(--danger); }
.tag.ok { background: var(--ok-bg); color: var(--ok); }

/* confirmation */
.order-no { font-size: 1.7rem; font-weight: 800; letter-spacing: .5px; color: var(--primary); font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; word-break: break-all; }
.success-icon { width: 54px; height: 54px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; font-size: 1.6rem; margin-bottom: 8px; border: 2px solid #bbf7d0; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: .93rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.pay-box { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 16px; text-align: center; background: #f8fafc; color: var(--muted); }
.pay-box .qr { width: 120px; height: 120px; margin: 8px auto; border-radius: 10px; background:
  repeating-linear-gradient(0deg, #e2e8f0 0 10px, #fff 10px 20px), #fff; display: grid; place-items: center; color: #94a3b8; font-size: .8rem; border: 1px solid #e2e8f0; }
.preview { max-width: 220px; max-height: 320px; border-radius: 10px; border: 1px solid var(--line); display: block; margin-top: 10px; }

table.items { width: 100%; border-collapse: collapse; font-size: .93rem; }
table.items th, table.items td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.items td.r, table.items th.r { text-align: right; }

/* timeline */
.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 34px; }
.timeline li::before { content: ""; position: absolute; left: 11px; top: 22px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2px solid #d1d5db; display: grid; place-items: center; font-size: .7rem; color: #fff; }
.timeline li.done .dot { background: var(--primary); border-color: var(--primary); }
.timeline li.done::before { background: var(--primary); }
.timeline li.current .dot { background: #fff; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(13,148,136,.15); }
.timeline li.cancel .dot { background: var(--danger); border-color: var(--danger); }
.timeline .t-title { font-weight: 700; }
.timeline li.todo .t-title { color: #9ca3af; font-weight: 600; }
.timeline .t-meta { font-size: .82rem; color: var(--muted); }

.site-footer { text-align: center; color: var(--muted); font-size: .82rem; padding: 18px 16px 32px; }

/* ---------- Admin ---------- */
.admin-bar { background: #0f172a; color: #e2e8f0; }
.admin-bar .inner { max-width: 1240px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.admin-bar .brand { color: #fff; }
.admin-bar .clock { font-size: .82rem; color: #94a3b8; margin-left: auto; }
.admin-bar .clock b { color: #fbbf24; }
.tabs { max-width: 1240px; margin: 0 auto; padding: 0 16px; display: flex; gap: 4px; overflow-x: auto; }
.tabs-wrap { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 38px; z-index: 40; }
.tabs button { border: 0; background: none; padding: 12px 14px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { background: #fee2e2; color: var(--danger); border-radius: 999px; padding: 0 7px; font-size: .75rem; margin-left: 4px; }
.admin-main { max-width: 1240px; margin: 0 auto; padding: 18px 16px 48px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid #eef0f3; border-radius: 12px; padding: 10px 12px; box-shadow: var(--shadow); cursor: pointer; text-align: left; font: inherit; color: inherit; }
.stat.active { outline: 2px solid var(--primary); }
.stat .n { font-size: 1.4rem; font-weight: 800; }
.stat .l { font-size: .82rem; color: var(--muted); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar label { font-size: .82rem; font-weight: 600; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.toolbar select, .toolbar input { padding: 8px 10px; min-width: 140px; }
.toolbar .spacer { flex: 1; }

.table-wrap { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid #eef0f3; overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th { background: #f9fafb; text-align: left; font-size: .8rem; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: #f8fafc; }
table.data .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; font-weight: 700; }
table.data td.r, table.data th.r { text-align: right; }
table.data input[type=number] { width: 90px; padding: 6px 8px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

@media (max-width: 760px) {
  table.data.responsive thead { display: none; }
  table.data.responsive tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.data.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 12px; text-align: right; }
  table.data.responsive td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left; }
}

.group-title { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; }
.group-title h3 { margin: 0; }
.slot-title { font-size: .88rem; font-weight: 700; color: var(--primary); margin: 10px 0 6px; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 760px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal header { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; font-size: 1.05rem; }
.modal header .close { margin-left: auto; border: 0; background: #f3f4f6; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 1.1rem; }
.modal .body { padding: 16px 18px; }
.modal .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .modal .cols { grid-template-columns: 1fr; } }
.shot { max-width: 100%; max-height: 360px; border-radius: 10px; border: 1px solid var(--line); }

.login-wrap { min-height: calc(100vh - 40px); display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; }
.demo-creds { background: var(--warn-bg); border: 1px dashed #f59e0b; border-radius: 12px; padding: 10px 12px; font-size: .88rem; color: #78350f; margin-bottom: 14px; }
.demo-creds code { background: #fff; padding: 1px 6px; border-radius: 5px; border: 1px solid #fde68a; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 200; font-size: .9rem; box-shadow: var(--shadow); max-width: 90vw; }
.log-actor { font-weight: 700; }
.toolbar input[type=checkbox] { min-width: 0; width: 16px; height: 16px; padding: 0; }
table.data.fixed { table-layout: fixed; }
table.data.fixed th:nth-child(1) { width: 15%; } table.data.fixed th:nth-child(2) { width: 12%; }
table.data.fixed th:nth-child(3) { width: 13%; } table.data.fixed th:nth-child(4) { width: 12%; }
table.data.fixed th:nth-child(5) { width: 8%; }  table.data.fixed th:nth-child(6) { width: 12%; }
table.data.fixed th:nth-child(7) { width: 28%; }
@media (max-width: 760px) { table.data.fixed { table-layout: auto; } }

/* ---------- order-admin-secure additions (no inline styles => strict CSP style-src 'self') ---------- */
.st-pending_payment { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.st-paid { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.st-preparing { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.st-ready_for_pickup, .st-shipped { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.st-completed { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.st-cancelled { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
.mt-6 { margin-top: 6px; } .mt-10 { margin-top: 10px; } .mt-12 { margin-top: 12px; } .mt-14 { margin-top: 14px; }
.mb-10 { margin-bottom: 10px; } .mb-12 { margin-bottom: 12px; } .m-0 { margin: 0; }
.center { text-align: center; } .left { text-align: left; } .nowrap { white-space: nowrap; }
.mx-auto { margin-left: auto; margin-right: auto; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.order-no.sm { font-size: 1.3rem; }
.uppercase { text-transform: uppercase; }
.brand.mb { margin-bottom: 12px; }
.toolbar label.inline { flex-direction: row; align-items: center; gap: 6px; }
.history { padding-left: 18px; margin: 6px 0; }
.config-missing { max-width: 640px; margin: 40px auto; }
.ts-box { min-height: 70px; margin: 8px 0; }
.qr-img { width: 200px; height: 200px; display: block; margin: 8px auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; background: #f8fafc; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); }
.otp { letter-spacing: .3em; font-size: 1.3rem; text-align: center; }
.security-note { background: var(--info-bg); border: 1px solid #bfdbfe; color: #1e3a8a; border-radius: 12px; padding: 10px 12px; font-size: .86rem; margin-bottom: 14px; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.shot-wrap { min-height: 60px; }
.tabs-wrap.top0 { top: 38px; }
