:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #718096;
  --line: #e4e9ee;
  --canvas: #f3f5f7;
  --panel: #ffffff;
  --nav: #18232d;
  --nav-soft: #263541;
  --accent: #ff6b35;
  --accent-soft: #fff0e9;
  --blue: #2878ff;
  --blue-soft: #eaf2ff;
  --green: #16a268;
  --green-soft: #e7f7ef;
  --amber: #d78500;
  --amber-soft: #fff7df;
  --red: #dc3c3c;
  --shadow: 0 12px 30px rgba(23, 33, 43, .06);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; color: var(--ink); background: var(--canvas); }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w, 246px) minmax(0, 1fr); transition: grid-template-columns .18s ease; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w, 246px); background: var(--nav); color: #dbe5ec; padding: 22px 14px 18px; display: flex; flex-direction: column; z-index: 20; transition: width .18s ease; overflow: hidden; }
/* 側邊 bar 收合（桌面）：縮到只剩圖標，文字隱藏 */
.app-shell.sidebar-collapsed { --sidebar-w: 66px; }
.sidebar-collapsed .sidebar { padding: 22px 8px 18px; }
.sidebar-collapsed .brand strong, .sidebar-collapsed .brand small,
.sidebar-collapsed .nav-label, .sidebar-collapsed .nav-item b,
.sidebar-collapsed .nav-item em, .sidebar-collapsed .nav-item small,
.sidebar-collapsed .sidebar-foot > div { display: none; }
.sidebar-collapsed .brand { justify-content: center; padding: 0 0 22px; }
.sidebar-collapsed .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 0; }
.sidebar-collapsed .sidebar-foot { justify-content: center; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 22px; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: linear-gradient(145deg, #ff814f, #ff5630); color: white; border-radius: 12px 12px 12px 4px; font-weight: 800; letter-spacing: -.08em; }
.brand strong { display: block; color: white; font-size: 17px; letter-spacing: .12em; }
.brand small { display: block; margin-top: 2px; color: #8496a4; font-size: 9px; letter-spacing: .23em; }
.nav { overflow-y: auto; padding-right: 2px; }
.nav-label { margin: 20px 10px 7px; color: #718491; font-size: 10px; font-weight: 700; letter-spacing: .14em; }
.nav-item { border: 0; background: transparent; color: #c9d5dd; width: 100%; height: 42px; border-radius: 9px; padding: 0 11px; display: grid; grid-template-columns: 22px 1fr auto; align-items: center; gap: 8px; text-align: left; cursor: pointer; }
.nav-item > span { color: #93a5b1; text-align: center; }
.nav-item b { font-size: 13px; font-weight: 500; }
.nav-item em { min-width: 23px; padding: 2px 6px; text-align: center; border-radius: 10px; background: #3b4c58; font-size: 10px; font-style: normal; }
.nav-item small { color: #6f828f; font-size: 9px; }
.nav-item:hover:not(.disabled) { background: var(--nav-soft); }
.nav-item.active { color: white; background: linear-gradient(90deg, rgba(255,107,53,.25), rgba(255,107,53,.08)); box-shadow: inset 3px 0 var(--accent); }
.nav-item.active > span { color: #ff8a61; }
.nav-item.disabled { opacity: .55; cursor: default; }
.sidebar-foot { margin-top: auto; padding: 15px 10px 0; border-top: 1px solid #2c3c47; display: flex; align-items: center; gap: 10px; }
.sidebar-foot strong, .sidebar-foot small { display: block; }
.sidebar-foot strong { color: #d9e4ea; font-size: 11px; }
.sidebar-foot small { color: #7f929e; font-size: 9px; margin-top: 2px; }
.status-dot { width: 8px; height: 8px; display: inline-block; flex: 0 0 auto; border-radius: 50%; background: #20c979; box-shadow: 0 0 0 4px rgba(32,201,121,.12); }

.workspace { grid-column: 2; min-width: 0; }
.topbar { height: 64px; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 32px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.94); backdrop-filter: blur(12px); }
.menu-button { display: none; border: 0; background: transparent; font-size: 22px; }
.collapse-button { border: 0; background: transparent; font-size: 18px; cursor: pointer; color: var(--muted, #8b98a6); padding: 6px 9px; border-radius: 8px; line-height: 1; }
.collapse-button:hover { background: var(--nav-soft, #eef2f5); color: var(--ink, #1f2329); }
/* 活動列上線/下架 + 買幾送幾串回 */
.button.small { padding: 5px 12px; font-size: 12px; }
.campaign-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; align-items: center; }
.campaign-row .cstatus { font-style: normal; padding: 2px 8px; border-radius: 10px; background: #eef; font-size: 11px; }
.campaign-row .cstatus.active { background: #e4f6ea; color: #1c7a3d; }
.campaign-row .cstatus.ended, .campaign-row .cstatus.paused { background: #fdecec; color: #b0341f; }
.item-price-input { width: 92px; padding: 5px 7px; border: 1px solid var(--line, #d7dee4); border-radius: 6px; font-size: 13px; }
.bxgy-panel { margin-top: 16px; }
.bxgy-item { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line, #e3e6ea); border-radius: 8px; margin-top: 8px; }
.bxgy-badge { font-size: 10px; padding: 2px 8px; border-radius: 10px; background: #eef; color: #4a5; white-space: nowrap; }
.bxgy-badge.ACTIVE { background: #e4f6ea; color: #1c7a3d; }
.bxgy-badge.EXPIRED, .bxgy-badge.SCHEDULED { background: #fff4e0; color: #8a6d00; }
/* 活動編輯彈出視窗（放大、獨立整理） */
.modal-backdrop { position: fixed; inset: 0; background: rgba(23,33,43,.45); display: flex; align-items: flex-start; justify-content: center; z-index: 80; padding: 32px 16px; overflow-y: auto; }
.modal-box { background: var(--panel, #fff); width: min(960px, 100%); border-radius: 12px; box-shadow: 0 24px 60px rgba(0,0,0,.28); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; border-bottom: 1px solid var(--line, #e3e6ea); }
.modal-head h2 { margin: 0; font-size: 19px; }
.modal-close { border: 0; background: transparent; font-size: 20px; cursor: pointer; color: #66707a; padding: 4px 10px; border-radius: 8px; }
.modal-close:hover { background: #eef2f6; color: #1f2329; }
.campaign-modal-body { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 20px; padding: 22px 24px; }
.campaign-modal-body .campaign-form { display: grid; gap: 15px; align-content: start; }
.modal-preview { min-height: 200px; }
.campaign-modal-body input, .campaign-modal-body select { font-size: 15px; padding: 9px 12px; }
.campaign-modal-body .field > span, .campaign-modal-body .scope-switch b { font-size: 13.5px; }
.campaign-modal-body .selected-items { max-height: 340px; overflow-y: auto; }
.campaign-modal-body .item-price-input { width: 110px; font-size: 15px; }
@media (max-width: 780px) { .campaign-modal-body { grid-template-columns: 1fr; } .modal-backdrop { padding: 10px 6px; } }
.crumb { display: flex; align-items: center; gap: 9px; font-size: 12px; }
.crumb span, .crumb i { color: #8b98a6; font-style: normal; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.store-chip, .time-chip { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 20px; padding: 7px 12px; background: white; color: #556271; font-size: 11px; }

main { padding: 30px 32px 60px; max-width: 1640px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.eyebrow { display: block; margin-bottom: 6px; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: .22em; }
.page-heading h1 { margin: 0; font-size: clamp(25px, 2.5vw, 34px); letter-spacing: -.04em; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }
.button { border: 1px solid var(--line); border-radius: 9px; padding: 10px 15px; background: white; cursor: pointer; font-size: 12px; font-weight: 700; transition: transform .15s, box-shadow .15s; }
.button:hover { transform: translateY(-1px); box-shadow: 0 5px 15px rgba(23,33,43,.08); }
.button.primary { border-color: var(--accent); background: var(--accent); color: white; }
.button.secondary { background: #f7f9fa; color: #42515e; }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.text-button { border: 0; background: none; color: var(--blue); font-size: 11px; cursor: pointer; }

.notice { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; padding: 13px 16px; border: 1px solid #ffd49e; border-radius: 10px; background: var(--amber-soft); }
.notice > span { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; background: #f2a40a; color: white; font-weight: 800; }
.notice strong, .notice p { display: inline; font-size: 11px; }
.notice p { margin-left: 8px; color: #8b6828; }
.notice.success { border-color: #b7e7cd; background: var(--green-soft); }
.notice.success > span { background: var(--green); }
.notice.error { border-color: #ffc6c6; background: #fff0f0; }
.notice.error > span { background: var(--red); }
.notice.privacy { border-color: #cfe1ff; background: var(--blue-soft); }
.notice.privacy > span { background: var(--blue); }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.metric-card, .panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.metric-card { min-height: 144px; padding: 22px; position: relative; overflow: hidden; }
.metric-card.featured::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--blue); }
.metric-label { color: #6d7a87; font-size: 11px; font-weight: 600; }
.metric-card > strong { display: block; margin: 18px 0 8px; font-size: clamp(25px, 3vw, 37px); letter-spacing: -.04em; }
.metric-card > p { margin: 0; color: #8995a0; font-size: 11px; }
.warning-card > strong { color: var(--amber); }
.info { width: 14px; height: 14px; display: inline-grid; place-items: center; border-radius: 50%; background: #edf1f4; font-size: 8px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(250px, 1fr); gap: 16px; }
.panel { padding: 20px; min-width: 0; }
.panel-head { display: flex; align-items: start; justify-content: space-between; gap: 14px; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 15px; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.legend { display: flex; gap: 14px; color: #768492; font-size: 10px; }
.legend i { width: 14px; height: 3px; display: inline-block; vertical-align: middle; margin-right: 5px; border-radius: 3px; }
.sales-line { background: var(--blue); }
.orders-line { background: #36b5d7; }
.chart-summary strong, .chart-summary span { display: block; }
.chart-summary strong { font-size: 27px; }
.chart-summary span { margin-top: 2px; color: var(--muted); font-size: 9px; }
.chart { height: 250px; margin-top: 10px; }
.chart svg, .spark svg { width: 100%; height: 100%; overflow: visible; }
.chart .grid-line { stroke: #edf0f3; stroke-width: 1; }
.chart text { fill: #8a97a3; font-size: 9px; }
.chart .area { fill: url(#salesArea); }
.chart .sales-path { fill: none; stroke: var(--blue); stroke-width: 2.5; }
.chart .orders-path { fill: none; stroke: #36b5d7; stroke-width: 2; }
.chart circle { fill: white; stroke: var(--blue); stroke-width: 2; }
.live-badge, .safe-pill, .draft-pill { border-radius: 20px; padding: 6px 9px; font-size: 8px; font-weight: 800; letter-spacing: .06em; }
.live-badge { color: var(--green); background: var(--green-soft); }
.safe-pill { color: var(--green); background: var(--green-soft); }
.draft-pill { align-self: center; color: #825300; background: var(--amber-soft); border: 1px solid #f3d894; }
.live-stat { display: flex; align-items: end; justify-content: space-between; padding: 15px 0; border-bottom: 1px solid var(--line); }
.live-stat span { color: var(--muted); font-size: 10px; }
.live-stat strong { font-size: 20px; }
.spark { height: 54px; margin: 4px 0; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 2; }
.data-rule { margin-top: 17px; padding: 12px; border-radius: 9px; background: #f7f9fa; }
.data-rule strong { font-size: 10px; }
.data-rule p { margin: 5px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.lower-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); gap: 16px; margin-top: 16px; }
.quick-action { width: 100%; display: grid; grid-template-columns: 38px 1fr 20px; align-items: center; gap: 12px; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); background: white; text-align: left; cursor: pointer; }
.quick-action:last-child { border: 0; }
.quick-action div strong, .quick-action div small { display: block; }
.quick-action div strong { font-size: 11px; }
.quick-action div small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.quick-action > b { color: #abb5bd; }
.quick-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; font-weight: 700; }
.quick-icon.blue { color: var(--blue); background: var(--blue-soft); }
.quick-icon.orange { color: var(--accent); background: var(--accent-soft); }
.quick-icon.green { color: var(--green); background: var(--green-soft); }
.quick-icon.purple { color: #7057d9; background: #f0edff; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 11px 12px; border-bottom: 1px solid var(--line); background: #f8fafb; color: #7b8894; font-size: 9px; font-weight: 700; text-align: left; }
td { padding: 13px 12px; border-bottom: 1px solid #eef1f3; font-size: 10px; vertical-align: top; }
tbody tr:hover { background: #fbfcfd; }
.num { text-align: right; }
.empty-row { padding: 28px; color: var(--muted); text-align: center; }
.counter { padding: 5px 9px; border-radius: 20px; color: var(--blue); background: var(--blue-soft); font-size: 9px; }
.order-row { cursor: pointer; transition: background .15s, box-shadow .15s; }
.order-row:hover, .order-row:focus { background: #f7faff; box-shadow: inset 3px 0 var(--blue); outline: none; }
.order-number { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.order-number span strong, .order-number span small { display: block; }
.order-number span small { margin-top: 3px; color: var(--muted); }
.order-number > b { color: #9aa8b4; font-size: 17px; }

.order-detail { min-width: 0; }
.order-detail-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.back-button { border: 0; padding: 8px 0; background: transparent; color: var(--blue); font-size: 11px; font-weight: 700; cursor: pointer; }
.order-detail-heading { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.order-title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.order-title-line h1 { margin: 0 4px 0 0; font-size: clamp(26px, 2.5vw, 34px); letter-spacing: -.04em; }
.order-detail-heading p { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.status-pill { display: inline-flex; align-items: center; gap: 5px; border-radius: 8px; padding: 6px 9px; font-size: 10px; font-weight: 700; }
.status-pill.paid { color: #59636d; background: #edf0f2; }
.status-pill.fulfillment { color: #625300; background: #ffe66d; }
.order-detail-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, .8fr); gap: 18px; align-items: start; }
.order-detail-main, .order-detail-aside { display: grid; gap: 16px; min-width: 0; }
.order-items-card, .totals-card, .side-card { border-color: #dfe4e8; box-shadow: 0 2px 5px rgba(23,33,43,.05); }
.order-card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.order-card-title small { color: var(--muted); font-size: 10px; }
.shipping-strip { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd; font-size: 12px; }
.shipping-strip span { color: #64727e; }
.line-item-list { overflow: hidden; border: 1px solid var(--line); border-radius: 11px; }
.line-item-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) 110px 95px; align-items: center; gap: 13px; min-height: 82px; padding: 12px; border-bottom: 1px solid var(--line); }
.line-item-row:last-child { border-bottom: 0; }
.line-item-image { width: 54px; height: 54px; display: grid; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: #f5f7f8; color: #a3afb8; }
.line-item-image img { width: 100%; height: 100%; object-fit: cover; }
.line-item-copy { min-width: 0; }
.line-item-copy strong, .line-item-copy span, .line-item-copy small { display: block; }
.line-item-copy strong { font-size: 11px; line-height: 1.45; }
.line-item-copy span { margin-top: 4px; color: #53616d; font-size: 9px; }
.line-item-copy small { margin-top: 4px; color: var(--muted); font-size: 8px; }
.line-item-unit { text-align: right; white-space: nowrap; font-size: 10px; }
.line-item-unit b { margin-left: 5px; padding: 4px 7px; border-radius: 12px; background: #f0f2f4; font-weight: 600; }
.line-item-total { text-align: right; white-space: nowrap; font-size: 11px; }
.read-only-action { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.read-only-action span { color: var(--muted); font-size: 9px; }
.read-only-action button { border: 0; border-radius: 8px; padding: 9px 12px; background: #31383e; color: white; font-size: 10px; opacity: .52; }
.totals-card { padding-top: 17px; }
.totals-row { display: grid; grid-template-columns: 100px minmax(0, 1fr) auto; gap: 12px; padding: 10px 4px; border-bottom: 1px solid #eef1f3; font-size: 10px; }
.totals-row small { color: var(--muted); }
.totals-row strong { text-align: right; }
.totals-row.discount strong { color: var(--green); }
.totals-row.grand { padding-top: 14px; border-bottom: 0; font-size: 12px; font-weight: 700; }
.side-card h2 { margin: 0 0 14px; font-size: 13px; }
.side-card h3 { margin: 17px 0 7px; font-size: 10px; }
.side-card p { margin: 6px 0 0; color: #53616d; font-size: 10px; line-height: 1.7; }
.side-link { color: var(--blue); font-size: 12px; }
.selectable { user-select: text; }
.address-block { overflow-wrap: anywhere; }
.journey-point { display: grid; grid-template-columns: 24px 1fr; align-items: start; gap: 9px; margin: 11px 0; }
.journey-point > span { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: #f0f3f5; color: #56636e; font-size: 9px; font-weight: 800; }
.journey-point p { margin: 2px 0 0; }
.attribution-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 9px; }
.attribution-meta span { color: var(--muted); text-align: right; }
.detail-link { display: block; margin-top: 9px; color: var(--blue); font-size: 9px; }
.risk-track { height: 10px; overflow: hidden; border-radius: 10px; background: #e7eaed; }
.risk-track i { display: block; height: 100%; border-radius: 10px; background: var(--green); }
.risk-labels { display: flex; justify-content: space-between; margin-top: 6px; color: #788691; font-size: 8px; }
.detail-loading { min-height: 360px; display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; }
.detail-loading h2, .detail-loading p { margin: 0; }
.detail-loading h2 { font-size: 15px; }
.detail-loading p { color: var(--muted); font-size: 10px; }
.loading-ring { width: 28px; height: 28px; border: 3px solid #e0e5e9; border-top-color: var(--accent); border-radius: 50%; animation: detail-spin .8s linear infinite; }
@keyframes detail-spin { to { transform: rotate(360deg); } }

.search-panel { margin-bottom: 16px; }
.searchbar, .inline-search { display: flex; gap: 9px; }
input, select { width: 100%; border: 1px solid #dce2e7; border-radius: 8px; padding: 10px 11px; background: white; color: var(--ink); outline: none; font-size: 11px; }
input:focus, select:focus { border-color: #82aefc; box-shadow: 0 0 0 3px rgba(40,120,255,.1); }
.helper { margin: 8px 0 0; color: var(--muted); font-size: 9px; }
.product-layout { display: grid; grid-template-columns: minmax(300px, .9fr) minmax(0, 1.5fr); gap: 16px; }
.result-list { display: grid; gap: 8px; }
.result-item { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: white; text-align: left; cursor: pointer; }
.result-item:hover { border-color: #a9c5fc; background: #f8fbff; }
.result-item strong, .result-item small { display: block; }
.result-item strong { font-size: 11px; }
.result-item small { margin-top: 5px; color: var(--muted); font-size: 9px; }
.empty-state, .preview-empty { min-height: 260px; display: grid; place-items: center; align-content: center; color: var(--muted); text-align: center; }
.empty-state span, .preview-empty span { font-size: 34px; color: #c4ced6; }
.empty-state h3, .preview-empty h3 { margin: 10px 0 4px; color: #687785; font-size: 13px; }
.empty-state p, .preview-empty p { margin: 0; font-size: 10px; }
.product-title { margin-bottom: 16px; }
.product-title h2 { margin: 0; font-size: 18px; }
.product-title p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.variant-list { display: grid; gap: 8px; }
.variant-row { display: grid; grid-template-columns: minmax(120px, 1fr) 110px 90px 70px; gap: 10px; align-items: center; padding: 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 10px; }
.variant-row small { color: var(--muted); }

.campaign-layout { display: grid; grid-template-columns: minmax(360px, .9fr) minmax(0, 1.4fr); gap: 16px; align-items: start; }
.campaign-side { display: grid; gap: 16px; }
.campaign-form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { color: #596875; font-size: 10px; font-weight: 700; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.scope-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.scope-switch label { cursor: pointer; }
.scope-switch input { position: absolute; opacity: 0; pointer-events: none; }
.scope-switch label > span { display: block; min-height: 68px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.scope-switch b, .scope-switch small { display: block; }
.scope-switch b { font-size: 11px; }
.scope-switch small { margin-top: 5px; color: var(--muted); font-size: 8px; line-height: 1.4; }
.scope-switch input:checked + span { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.input-suffix { display: flex; position: relative; }
.input-suffix b { position: absolute; right: 12px; top: 10px; color: var(--muted); font-size: 11px; }
.target-picker { padding: 13px; border: 1px dashed #bfcbd4; border-radius: 10px; background: #fafcfd; }
.hidden { display: none !important; }
.picker-results { margin-top: 8px; display: grid; gap: 6px; }
.picker-product { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px; border-radius: 7px; background: white; border: 1px solid var(--line); }
.picker-product div strong, .picker-product div small { display: block; }
.picker-product div strong { font-size: 10px; }
.picker-product div small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.mini-button { border: 0; border-radius: 6px; padding: 6px 9px; background: var(--blue-soft); color: var(--blue); font-size: 9px; cursor: pointer; }
.selected-items { margin-top: 13px; }
.subhead { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 9px; }
.selected-item { display: grid; grid-template-columns: 1fr 74px 25px; gap: 8px; align-items: center; padding: 8px; margin-top: 5px; border-radius: 7px; background: white; border: 1px solid var(--line); }
.selected-item strong, .selected-item small { display: block; }
.selected-item strong { font-size: 9px; }
.selected-item small { margin-top: 3px; color: var(--muted); font-size: 8px; }
.selected-item button { border: 0; background: none; color: var(--red); cursor: pointer; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.preview-panel { min-height: 330px; }
.preview-summary { padding: 13px; border-radius: 9px; background: var(--green-soft); }
.preview-summary strong, .preview-summary span { display: block; }
.preview-summary strong { font-size: 13px; }
.preview-summary span { margin-top: 5px; color: #4d7861; font-size: 9px; }
.preview-flags { display: flex; gap: 8px; margin: 12px 0; }
.preview-flags span { padding: 6px 9px; border-radius: 15px; background: #f1f4f6; font-size: 9px; }
.preview-errors { padding: 10px; border-radius: 8px; background: #fff0f0; color: var(--red); font-size: 9px; line-height: 1.5; }
.preview-rows { max-height: 190px; overflow-y: auto; }
.campaign-list { display: grid; gap: 8px; }
.campaign-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 11px; border: 1px solid var(--line); border-radius: 8px; }
.campaign-row strong, .campaign-row small { display: block; }
.campaign-row strong { font-size: 10px; }
.campaign-row small { margin-top: 4px; color: var(--muted); font-size: 8px; }
.campaign-row em { align-self: start; padding: 4px 7px; border-radius: 10px; color: #8b5a00; background: var(--amber-soft); font-size: 8px; font-style: normal; }

.social-heading { margin-bottom: 14px; }
.social-switch { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: white; box-shadow: var(--shadow); }
.social-switch button { border: 1px solid var(--line); border-radius: 20px; padding: 8px 13px; background: #f7f9fa; color: #53616e; font-size: 10px; font-weight: 700; cursor: pointer; }
.social-switch button.active { border-color: var(--nav); background: var(--nav); color: white; }
.social-switch a { margin-left: auto; color: var(--blue); font-size: 10px; }
.data-pending { color: var(--muted); font-size: 10px; font-weight: 600; }
.social-panel { padding: 0; overflow: hidden; background: #e9ecf1; }
.social-frame { display: block; width: 100%; height: calc(100vh - 210px); min-height: 760px; border: 0; background: #e9ecf1; }

.architecture-flow { display: grid; grid-template-columns: repeat(7, auto); align-items: center; gap: 12px; margin-bottom: 16px; }
.architecture-flow article { min-height: 125px; padding: 17px; border: 1px solid var(--line); border-radius: 13px; background: white; box-shadow: var(--shadow); }
.architecture-flow article > span { width: 25px; height: 25px; display: grid; place-items: center; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-size: 9px; font-weight: 800; }
.architecture-flow strong { display: block; margin-top: 12px; font-size: 11px; }
.architecture-flow p { margin: 6px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.architecture-flow > i { color: #a5b0b8; font-style: normal; }
.module-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.module-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.module-card > span { float: right; padding: 4px 7px; border-radius: 10px; background: #f0f3f5; color: var(--muted); font-size: 8px; }
.module-card span.ready { background: var(--green-soft); color: var(--green); }
.module-card strong, .module-card small { display: block; }
.module-card strong { font-size: 11px; }
.module-card small { margin-top: 6px; color: var(--muted); font-size: 9px; }
.decision-panel h2 { margin: 0 0 14px; font-size: 15px; }
.decision-rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.decision-rows div { padding: 14px; border-radius: 9px; background: #f7f9fa; }
.decision-rows b { font-size: 10px; }
.decision-rows p { margin: 6px 0 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 50; max-width: 360px; padding: 12px 15px; border-radius: 9px; background: #17212b; color: white; box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 11px; opacity: 0; transform: translateY(15px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: #a52c2c; }

@media (max-width: 1120px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid, .lower-grid, .campaign-layout { grid-template-columns: 1fr; }
  .live-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
  .live-panel .panel-head, .live-panel .data-rule { grid-column: 1 / -1; }
  .architecture-flow { grid-template-columns: 1fr; }
  .architecture-flow > i { transform: rotate(90deg); justify-self: center; }
  .order-detail-grid { grid-template-columns: 1fr; }
  .order-detail-aside { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { transform: translateX(-105%); transition: transform .2s; box-shadow: 15px 0 30px rgba(0,0,0,.16); }
  .sidebar.open { transform: none; }
  .workspace { display: block; }
  .menu-button { display: block; }
  .topbar { padding: 0 17px; }
  .crumb span, .crumb i, .time-chip { display: none; }
  main { padding: 22px 16px 90px; }
  .product-layout { grid-template-columns: 1fr; }
  .module-grid, .decision-rows { grid-template-columns: 1fr 1fr; }
  .order-detail-aside { grid-template-columns: 1fr; }
  .line-item-row { grid-template-columns: 48px minmax(0, 1fr) auto; }
  .line-item-image { width: 48px; height: 48px; }
  .line-item-unit { grid-column: 2; text-align: left; }
  .line-item-total { grid-column: 3; grid-row: 1 / span 2; }
}

@media (max-width: 560px) {
  .page-heading { align-items: start; flex-direction: column; }
  .page-heading .button { width: 100%; }
  .metric-grid, .form-row, .scope-switch, .module-grid, .decision-rows { grid-template-columns: 1fr; }
  .metric-card { min-height: 125px; }
  .dashboard-grid, .lower-grid { gap: 12px; }
  .panel { padding: 16px; border-radius: 12px; }
  .live-panel { display: block; }
  .top-actions .store-chip { max-width: 160px; overflow: hidden; white-space: nowrap; }
  .legend { display: none; }
  .chart { height: 210px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .button { width: 100%; }
  .variant-row { grid-template-columns: 1fr 80px; }
  .variant-row > :nth-child(3), .variant-row > :nth-child(4) { text-align: right; }
  .notice { align-items: start; }
  .notice strong, .notice p { display: block; margin-left: 0; }
  .notice p { margin-top: 4px; }
  .social-switch { align-items: stretch; flex-direction: column; }
  .social-switch button, .social-switch a { width: 100%; text-align: center; }
  .social-switch a { margin-left: 0; padding: 7px; }
  .social-frame { min-height: 680px; }
  .order-detail-toolbar { align-items: stretch; flex-direction: column; }
  .order-detail-toolbar .button { text-align: center; }
  .order-card-title, .read-only-action { align-items: stretch; flex-direction: column; }
  .line-item-row { grid-template-columns: 44px minmax(0, 1fr); gap: 9px; }
  .line-item-image { width: 44px; height: 44px; }
  .line-item-unit { grid-column: 2; }
  .line-item-total { grid-column: 2; grid-row: auto; text-align: left; }
  .totals-row { grid-template-columns: 74px minmax(0, 1fr) auto; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; } }

/* ── 批次出貨 ─────────────────────────────────────────────────────────────── */
.ship-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 16px; }
.ship-check { width: 42px; text-align: center; }
.ship-check input, .ship-row-check { width: 17px; height: 17px; cursor: pointer; }
.ship-tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--canvas); color: var(--muted); border: .5px solid var(--line); }
.ship-tag.hct { background: var(--blue-soft); color: var(--blue); border-color: transparent; }
.ship-upload { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 14px; }
.ship-upload input[type="file"] { flex: 1; min-width: 220px; padding: 9px 12px; border: .5px dashed var(--line); border-radius: 10px; background: var(--canvas); }
.ship-flags { display: flex; flex-wrap: wrap; gap: 10px; margin: 4px 0 12px; }
.ship-flags span { font-size: 13px; font-weight: 600; color: var(--muted); background: var(--canvas); border-radius: 8px; padding: 5px 12px; }
.ship-pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.ship-pill.ok { background: var(--green-soft); color: var(--green); }
.ship-pill.warn { background: var(--amber-soft); color: var(--amber); }
.ship-pill.err { background: #fdeaea; color: var(--red); }
.ship-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 16px; padding: 14px 16px; border: .5px solid var(--amber); background: var(--amber-soft); border-radius: 12px; }
.ship-notify { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink); }
.ship-notify input { width: 16px; height: 16px; }
.ship-hint { color: var(--amber); font-weight: 600; font-size: 13px; }
.ship-confirm .button.primary { margin-left: auto; }
#shipFulfillResult { margin-top: 16px; }

/* ── 商品管理（catalog）───────────────────────────────────────────────────── */
.button.ghost { background: transparent; color: var(--muted); border: .5px solid var(--line); }
.button.ghost:hover { background: var(--canvas); color: var(--ink); }
.catalog-toolbar { display: flex; flex-direction: column; gap: 12px; }
.catalog-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.catalog-filters input, .catalog-filters select, .catalog-actions select { padding: 9px 12px; border: .5px solid var(--line); border-radius: 10px; background: var(--panel); }
.catalog-filters input { flex: 1; min-width: 200px; }
.catalog-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.catalog-selcount { font-weight: 600; color: var(--muted); margin-right: auto; }
.catalog-import input[type="file"] { max-width: 200px; font-size: 13px; }
.catalog-table th, .catalog-table td { vertical-align: middle; }
.cat-img { width: 52px; }
.cat-img img { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; border: .5px solid var(--line); }
.catalog-pager { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 14px 0 4px; }
.catalog-pager span { font-weight: 600; color: var(--muted); }

/* 新增商品抽屜 */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(23, 33, 43, .38); display: flex; justify-content: flex-end; z-index: 60; }
.drawer { width: min(560px, 100%); height: 100%; background: var(--panel); display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(23, 33, 43, .18); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: .5px solid var(--line); }
.drawer-head h2 { margin: 0; }
.drawer-close { border: none; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px; display: flex; flex-direction: column; gap: 12px; }
.drawer-body textarea { width: 100%; padding: 9px 12px; border: .5px solid var(--line); border-radius: 10px; font-family: inherit; resize: vertical; }
.drawer-foot { border-top: .5px solid var(--line); padding: 14px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.drawer-buttons { display: flex; gap: 8px; }
.np-variant { display: grid; grid-template-columns: 1.4fr 1fr .8fr .7fr auto; gap: 8px; margin-bottom: 8px; }
.np-variant input { padding: 8px 10px; border: .5px solid var(--line); border-radius: 8px; min-width: 0; }
.np-v-del { border: .5px solid var(--line); background: var(--canvas); border-radius: 8px; cursor: pointer; color: var(--red); }
@media (max-width: 640px) { .np-variant { grid-template-columns: 1fr 1fr; } }

/* ── 商品編輯頁 ───────────────────────────────────────────────────────────── */
.cat-title { cursor: pointer; }
.cat-title:hover strong { color: var(--blue); text-decoration: underline; }
.mini-button.danger { color: var(--red); border-color: var(--red); }
.link-btn { background: none; border: none; color: var(--blue); cursor: pointer; padding: 0; font: inherit; }
.edit-topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; background: var(--panel); border: .5px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.edit-title-wrap { flex: 1; display: flex; flex-direction: column; }
.edit-title-wrap small { color: var(--amber); font-weight: 600; }
.edit-topbar-actions { display: flex; gap: 8px; }
.edit-layout { display: grid; grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.edit-main, .edit-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.edit-side h2, .edit-main h2 { margin: 0 0 6px; }
.edit-variants th, .edit-variants td { padding: 7px 8px; }
.edit-variants input { width: 100%; padding: 7px 9px; border: .5px solid var(--line); border-radius: 8px; min-width: 60px; }
.edit-badge { margin-top: 8px; }
#editStatus { width: 100%; padding: 9px 12px; border: .5px solid var(--line); border-radius: 10px; }
.collection-picker { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; border: .5px solid var(--line); border-radius: 10px; padding: 10px; }
.col-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.col-check.smart { color: var(--muted); }
.media-drop { border: 1px dashed var(--line); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); margin-bottom: 12px; }
.media-drop.drag { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.media-cell { position: relative; border: .5px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--canvas); }
.media-cell img { width: 100%; height: 120px; object-fit: cover; display: block; }
.media-cell-tools { display: flex; justify-content: center; gap: 4px; padding: 5px; background: var(--panel); }
.modal { width: min(640px, 94vw); max-height: 88vh; margin: auto; background: var(--panel); border-radius: 14px; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(23,33,43,.28); }
.drawer-backdrop { align-items: center; }
.modal .drawer-body { max-height: 60vh; }
@media (max-width: 900px) { .edit-layout { grid-template-columns: 1fr; } }
.catalog-tabs { display: flex; gap: 4px; border-bottom: .5px solid var(--line); margin-bottom: 4px; }
.cat-tab { background: none; border: none; padding: 8px 14px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; }
.cat-tab.active { color: var(--ink); border-bottom-color: var(--blue); }
.cat-tab:hover { color: var(--ink); }
