/* 商管通後台：不靠外部框架，CSP 只允許自己的樣式檔 */
:root {
  --bg: #f7f6f3;
  --card: #fff;
  --text: #1f1f1f;
  --muted: #6b6b6b;
  --line: #e6e3dd;
  --accent: #e0531c;
  --accent-soft: #fdeee7;
  --ok: #1f8a4c;
  --ok-soft: #e5f4ea;
  --warn: #b26a00;
  --warn-soft: #fff3dc;
  --bad: #c62828;
  --bad-soft: #fde8e8;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161514;
    --card: #211f1d;
    --text: #ece9e4;
    --muted: #a39e96;
    --line: #34312d;
    --accent: #f06a35;
    --accent-soft: #3a2419;
    --ok: #4cc27a;
    --ok-soft: #173222;
    --warn: #e5a443;
    --warn-soft: #3a2c12;
    --bad: #ef6b6b;
    --bad-soft: #3d1c1c;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- 版面 ---------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 210px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
}
.brand { font-weight: 700; font-size: 18px; padding: 0 10px 4px; }
.brand-sub { color: var(--muted); font-size: 13px; padding: 0 10px 16px; }
.side a {
  display: block; padding: 8px 10px; border-radius: 8px; color: var(--text);
}
.side a:hover { background: var(--bg); text-decoration: none; }
.side a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side .grow { flex: 1; }
.side form button { width: 100%; text-align: left; }
.main { flex: 1; min-width: 0; padding: 24px 28px 48px; max-width: 1200px; }
.topbar { display: none; }

@media (max-width: 800px) {
  .shell { display: block; }
  .side { display: none; width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side.open { display: flex; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
  }
  .main { padding: 16px; }
}

/* ---------- 元件 ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .value.accent { color: var(--accent); }
.stat .sub { color: var(--muted); font-size: 12px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }

.btn, button {
  font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 7px 14px; border-radius: 8px; display: inline-block; line-height: 1.4;
}
.btn:hover, button:hover { border-color: var(--muted); text-decoration: none; }
.btn.primary, button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger, button.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.small, button.small { padding: 3px 10px; font-size: 13px; }
button.link { border: 0; background: none; color: var(--accent); padding: 0; }
.chip { border-radius: 999px; padding: 4px 12px; font-size: 14px; }
.chip.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

input[type=text], input[type=password], input[type=number], input[type=date], input[type=month], input[type=tel], input[type=search], select, textarea {
  font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px;
  max-width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.field input:not([type=checkbox]), label.field select, label.field textarea { width: 100%; }
label.check { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.form-narrow { max-width: 460px; }
.field-error, .validation-summary-errors { color: var(--bad); font-size: 13px; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.input-validation-error { border-color: var(--bad) !important; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 500; }
tbody tr:hover { background: var(--bg); }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.table-wrap table { min-width: 560px; }
tr.void td { color: var(--muted); text-decoration: line-through; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.bad { background: var(--bad-soft); color: var(--bad); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }

.secret { font-family: ui-monospace, Consolas, monospace; font-size: 20px; letter-spacing: 2px; background: var(--bg); padding: 6px 12px; border-radius: 6px; }

/* ---------- 長條圖（SVG） ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar.dim { fill: var(--line); }
.chart .axis { fill: var(--muted); font-size: 10px; }
.chart .val { fill: var(--text); font-size: 10px; }
.hbar { display: grid; grid-template-columns: 9em 1fr 6em; gap: 8px; align-items: center; margin: 4px 0; }
.hbar svg { width: 100%; height: 14px; }
.hbar rect { fill: var(--accent); }

/* ---------- 登入 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 380px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; }
.tabs a { flex: 1; text-align: center; padding: 8px; border-radius: 8px; border: 1px solid var(--line); color: var(--text); }
.tabs a.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* ---------- 商品 ---------- */
.thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--bg); display: block; }
.thumb-lg { width: 160px; height: 160px; border-radius: 10px; object-fit: cover; background: var(--bg); display: block; }
.og { border: 1px dashed var(--line); border-radius: 8px; padding: 10px; margin-bottom: 10px; }
.og-opt { display: grid; grid-template-columns: 1fr 100px auto; gap: 6px; margin-top: 6px; }
.qr { width: 200px; height: 200px; background: #fff; padding: 8px; border-radius: 8px; }
.qr svg { width: 100%; height: 100%; }
.url { font-family: ui-monospace, Consolas, monospace; font-size: 13px; word-break: break-all; background: var(--bg); padding: 4px 8px; border-radius: 6px; }

@media print {
  .side, .topbar, .no-print { display: none !important; }
  .main { padding: 0; }
}
.flash.acting { background: #2a3a5a; color: #cfe0ff; border: 1px solid #4a6aa8; gap: 12px; align-items: center; }
.stat .value.bad, td.bad { color: var(--bad); }
table.heat { border-collapse: separate; border-spacing: 2px; font-size: 12px; }
table.heat th { font-weight: 500; color: var(--muted); padding: 2px 4px; text-align: center; }
table.heat td { width: 32px; height: 26px; text-align: center; border-radius: 4px; padding: 0; background: rgba(127,127,127,.08); }
table.heat td.h1 { background: rgba(255,106,61,.18); }
table.heat td.h2 { background: rgba(255,106,61,.35); }
table.heat td.h3 { background: rgba(255,106,61,.55); }
table.heat td.h4 { background: rgba(255,106,61,.75); color: #fff; }
table.heat td.h5 { background: rgba(255,106,61,.95); color: #fff; }
img.thumb { max-width: 120px; max-height: 120px; border-radius: 8px; vertical-align: middle; }
.banner-row { display: flex; gap: 14px; align-items: flex-start; }
.banner-thumb { width: 180px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; flex: none; }
.banner-row .grow { flex: 1; }
.col-btns { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 720px) { .banner-row { flex-direction: column; } .banner-thumb { width: 100%; } .col-btns { flex-direction: row; } }
table.plans { table-layout: fixed; }
table.plans th, table.plans td { text-align: center; }
table.plans th:first-child, table.plans td:first-child { text-align: left; width: 34%; }
table.plans th.on { color: var(--accent); font-weight: 700; }
.coupon-form { max-width: 760px; }
.choice { display: flex; gap: 10px; margin-bottom: 12px; }
.choice-card { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 12px; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; }
.choice-card input { position: absolute; opacity: 0; }
.choice-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice-card small { color: var(--muted); }
.input-unit { display: flex; align-items: center; gap: 6px; }
.input-unit input { flex: 1; min-width: 0; }
.coupon-form .pct-only { display: none; }
.coupon-form.is-pct .pct-only { display: block; }
.coupon-form.is-pct .amt-only { display: none; }
.pv-ticket { display: flex; align-items: center; gap: 12px; max-width: 420px; border-radius: 12px; overflow: hidden; background: var(--bg); border: 1px solid var(--line); }
.pv-amt { flex: 0 0 90px; align-self: stretch; display: grid; place-items: center; background: #e8962a; color: #fff; font-size: 22px; font-weight: 700; border-right: 2px dashed rgba(255,255,255,.7); padding: 14px 0; }
.pv-body { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 8px 0; }
.pv-body small { color: var(--muted); }
.pv-btn { margin-right: 12px; background: #e8962a; color: #fff; border-radius: 999px; padding: 4px 12px; font-size: 13px; }
ol.steps { padding-left: 22px; line-height: 1.9; }
ol.steps li { margin-bottom: 6px; }
.print-qr svg { width: 220px; height: 220px; }
@media print { body * { visibility: hidden; } .print-qr, .print-qr * { visibility: visible; } .print-qr { position: absolute; inset: 0; margin: auto; box-shadow: none; } .print-qr button { display: none; } }
.manual { max-width: 860px; }
.manual .card { scroll-margin-top: 16px; }
.manual h3 { margin: 18px 0 6px; font-size: 16px; }
.manual ol, .manual ul { padding-left: 22px; line-height: 1.9; }
.manual .toc ol { columns: 2; }
.manual .tip { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; }
.manual .warn-box { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; }
.manual .faq dt { font-weight: 700; margin-top: 12px; }
.manual .faq dd { margin: 4px 0 0; color: var(--muted); }
@media (max-width: 720px) { .manual .toc ol { columns: 1; } }
.manual figure.shot { margin: 12px 0 18px; }
.manual figure.shot img { display: block; width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); box-shadow: 0 4px 16px rgba(0,0,0,.18); }
.manual figure.shot figcaption { font-size: 13px; color: var(--muted); margin-top: 6px; text-align: center; }
.manual .shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin: 12px 0 18px; }
.manual .shots figure.half { grid-column: span 2; }
.manual .shots figure { margin: 0; }
@media (max-width: 720px) { .manual .shots figure.half { grid-column: auto; } }
