:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7684;
  --line: #e3e6ea;
  --brand: #d9480f;
  --brand-soft: #fff0e8;
  --ok: #2b8a3e;
  --warn: #b35c00;
  --err: #c92a2a;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Noto Sans TC", "Microsoft JhengHei", "PingFang TC", system-ui, sans-serif;
  font-size: 15px; line-height: 1.6;
}
h1, h2, h3 { margin: 0 0 12px; line-height: 1.3; }
h1 { font-size: 22px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
a { color: var(--brand); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* 按鈕與表單 */
button, .btn {
  font: inherit; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  padding: 8px 16px; border-radius: 8px; cursor: pointer;
}
button:disabled { opacity: .55; cursor: not-allowed; }
a.btn { display: inline-block; text-decoration: none; }
.btn.secondary { background: #fff; color: var(--brand); }
button.secondary { background: #fff; color: var(--brand); }
button.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
label { display: block; font-weight: 600; margin: 14px 0 6px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.msg { margin-top: 12px; padding: 10px 12px; border-radius: 8px; font-size: 14px; }
.msg.ok { background: #ebfbee; color: var(--ok); }
.msg.err { background: #fff5f5; color: var(--err); }
.msg.warn { background: #fff4e6; color: var(--warn); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }

/* 登入頁 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-box { width: 100%; max-width: 380px; }
.login-box .logo { font-size: 24px; font-weight: 700; color: var(--brand); margin-bottom: 4px; }

/* 後台版面 */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #fff; border-right: 1px solid var(--line); padding: 20px 12px; }
.sidebar .logo { font-weight: 700; color: var(--brand); font-size: 18px; padding: 0 8px; }
.sidebar .store { color: var(--muted); font-size: 13px; padding: 0 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.nav button {
  display: flex; justify-content: space-between; align-items: center; width: 100%; text-align: left;
  background: transparent; border: 0; color: var(--ink); padding: 9px 10px; border-radius: 8px; margin-bottom: 2px;
}
.nav button:hover { background: var(--bg); }
.nav button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav button.soon { color: var(--muted); cursor: default; }
.nav .tag { font-size: 11px; background: var(--bg); color: var(--muted); padding: 1px 6px; border-radius: 10px; }
#nav-pending { background: #fff4e6; color: var(--warn); }
.nav .group { font-size: 12px; color: var(--muted); padding: 12px 10px 4px; }
.sidebar .logout { margin-top: 20px; width: 100%; }
.main { padding: 28px 32px; max-width: 980px; }
.topbar { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }

/* 報表數字 */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.stat .num { font-size: 28px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 13px; }
.bar { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--brand); width: 0; }

/* 文案結果 */
.variants { display: grid; gap: 12px; margin-top: 16px; }
.variant { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; background: #fff; }
.variant .style { display: inline-block; font-size: 12px; background: var(--brand-soft); color: var(--brand); padding: 2px 8px; border-radius: 10px; margin-bottom: 8px; }
.variant .title { font-weight: 700; margin-bottom: 6px; }
.variant .body { white-space: pre-wrap; }
.variant .actions { margin-top: 10px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg); font-weight: 600; white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--bg); white-space: nowrap; }
.badge.ok { background: #ebfbee; color: var(--ok); }
.badge.err { background: #fff5f5; color: var(--err); }
.badge.warn { background: #fff4e6; color: var(--warn); }

.history-item { border-bottom: 1px solid var(--line); padding: 10px 0; }
.history-item:last-child { border-bottom: 0; }
.history-item summary { cursor: pointer; }

/* 核取方塊 */
.checks { display: flex; gap: 16px; flex-wrap: wrap; padding-top: 8px; }
.checks label, .check-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 400; margin: 0; }
.check-inline { margin-top: 14px; }
.checks input, .check-inline input { width: auto; }
textarea.tall { min-height: 160px; }

/* 本月用量 */
.quota-row { margin-top: 8px; }
.quota-row .quota-head { display: flex; justify-content: space-between; font-size: 13px; }

/* 貼文 */
.hashtags { color: #1864ab; margin-top: 8px; font-size: 14px; }

/* 合規檢查 */
.overall { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.overall .level { font-size: 20px; font-weight: 700; }
.level-高 { color: var(--err); } .level-中 { color: var(--warn); } .level-低 { color: #5c7cfa; } .level-none { color: var(--ok); }
.marked { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 12px; line-height: 1.9; }
mark { padding: 1px 2px; border-radius: 3px; }
mark.m-高 { background: #ffc9c9; } mark.m-中 { background: #ffe8cc; } mark.m-低 { background: #dbe4ff; }
.badge.lv-高 { background: #fff5f5; color: var(--err); }
.badge.lv-中 { background: #fff4e6; color: var(--warn); }
.badge.lv-低 { background: #edf2ff; color: #4263eb; }
.compliance-hint { margin-top: 12px; }

/* 分頁 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; color: var(--muted); border-radius: 0; padding: 8px 12px; }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* 常見問答 */
.faq { display: grid; grid-template-columns: 1fr 1.6fr auto; gap: 8px; margin-bottom: 8px; align-items: start; }
.faq textarea { min-height: 42px; }

/* 測試對話 */
.chat { background: var(--bg); border-radius: var(--radius); padding: 12px; min-height: 220px; max-height: 420px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 75%; padding: 8px 12px; border-radius: 14px; white-space: pre-wrap; }
.bubble.me { align-self: flex-end; background: #06c755; color: #fff; }
.bubble.bot { align-self: flex-start; background: #fff; border: 1px solid var(--line); }
.bubble .meta { display: block; font-size: 11px; opacity: .75; margin-top: 4px; }
.chat-input { display: flex; gap: 8px; margin-top: 10px; }
.copy-row { display: flex; gap: 8px; }
.list-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.list-line:last-child { border-bottom: 0; }

/* AI 圖片 */
.ref-preview { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.ref-preview img { max-height: 90px; border-radius: 8px; border: 1px solid var(--line); }
.image-result img { width: 100%; max-width: 520px; border-radius: var(--radius); border: 1px solid var(--line); display: block; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gallery figure { margin: 0; }
.gallery img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.gallery figcaption { font-size: 12px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* SEO 文章 */
.article h2 { font-size: 20px; margin-bottom: 6px; }
.article h3 { margin-top: 18px; }
.article .meta { background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.article .content { white-space: pre-wrap; }
.article .tags { color: #1864ab; font-size: 14px; margin-top: 12px; }

.divider { border: 0; border-top: 1px solid var(--line); margin: 24px 0 16px; }
.bind-code { background: var(--brand-soft); border-radius: 8px; padding: 12px 16px; margin: 8px 0; }
.bind-code strong { font-size: 20px; letter-spacing: 1px; color: var(--brand); }
.bind-code ol { margin: 6px 0; padding-left: 20px; }

.export-list { margin: 0 0 12px; padding-left: 20px; }
.export-list li { margin: 4px 0; }

.demo-banner { background: #fff4e6; color: var(--warn); padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }

/* 管理者檢視店家後台 */
.viewer-banner { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  background: #e7f5ff; border: 1px solid #74c0fc; color: #1864ab; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.viewer-banner button { background: #1971c2; border-color: #1971c2; padding: 6px 12px; font-size: 14px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--err); text-decoration: underline; cursor: pointer; font: inherit; }
.er-summary { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
#nav-errors { background: #fff5f5; color: var(--err); }

/* 產業、標語 */
select.small-select { width: auto; font-size: 12px; padding: 2px 6px; margin-top: 4px; }
.sidebar .tagline { font-size: 12px; color: var(--muted); padding: 2px 8px 8px; }
.industry-tag { display: inline-block; margin-left: 6px; font-size: 11px; background: var(--brand-soft); color: var(--brand); padding: 1px 6px; border-radius: 10px; }
.industry-tag:empty { display: none; }

/* 測試對話：快速回覆按鈕 */
.quick-replies { display: flex; gap: 6px; flex-wrap: wrap; align-self: flex-start; }
.quick-replies button { padding: 4px 12px; border-radius: 16px; font-size: 13px; }

/* LINE 接單 */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.filters select, .filters input[type="month"] { width: auto; }
.filters .check-inline { margin-top: 0; }
.order-list { display: grid; gap: 12px; margin-top: 12px; }
.order-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: #fff; }
.order-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.order-body { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.order-total { font-weight: 700; margin-top: 4px; }
.order-card .actions { margin-top: 10px; }
.order-card .actions button { padding: 5px 12px; font-size: 14px; }

@media (max-width: 760px) {
  .order-body { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .main { padding: 20px 16px; }
  .row, .stats { grid-template-columns: 1fr; }
}
