/* IAGENS 評論小幫手 — 左側選單版面。與公司網站同一套色票與字體。 */
:root {
  --paper: #f6f7f5;
  --panel: #fcfcfb;
  --ink: #16202b;
  --slate: #55636f;
  --faint: #8a95a0;
  --line: #d5dbe0;
  --line-soft: #e6eaee;
  --accent: #0e6e66;
  --accent-ink: #0a534d;
  --accent-soft: #e3efed;
  --warn: #b42318;
  --warn-soft: #fdecea;
  --ok: #1a7f4b;
  --ok-soft: #e4f4ea;
  --new: #9a5b00;
  --new-soft: #fff1d6;
  --dev: #7a4b00;
  --dev-soft: #fbf1e0;
  --sidebar-w: 224px;
  --radius: 6px;
}

* { box-sizing: border-box; }
html { background: var(--paper); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; transition: color .2s; }
.item, .conn, button, .button, .review-list li a { transition: background-color .2s, color .2s, border-color .2s; }
a:hover { text-decoration: underline; text-underline-offset: 0.15em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* ── 版面骨架 ─────────────────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 18px 12px 16px;
}
.content { flex: 1; min-width: 0; padding-block: 0 48px; padding-inline: clamp(16px, 4vw, 40px); }
main { max-width: 1600px; margin-inline: auto; }
main.narrow { max-width: 960px; }

/* 品牌 */
.brand { display: flex; flex-direction: column; padding: 4px 10px 14px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { font-weight: 700; font-size: 1.1rem; letter-spacing: 0.05em; line-height: 1.3; }
.brand-sub { color: var(--slate); font-size: 0.85rem; }

/* 連結狀態列：同時是「連結 Google」頁的入口 */
.conn {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 14px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--slate); font-size: 0.85rem; line-height: 1.4;
}
.conn:hover { text-decoration: none; border-color: var(--accent); color: var(--ink); }
.conn.ok { color: var(--ok); border-color: #cfe7d8; }
.conn.bad { color: var(--warn); border-color: #f2c9c4; }
.conn.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }

/* 群組與項目 */
nav .group { margin-top: 10px; }
nav .group + .group { margin-top: 18px; }
.group-title {
  padding: 0 10px 4px; font-size: 0.78rem; font-weight: 500;
  color: var(--faint); letter-spacing: 0.02em;
}
.group.current .group-title { color: var(--accent-ink); }
.item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 12px; border-radius: var(--radius);
  color: var(--ink); font-weight: 500; line-height: 1.4;
}
.item:hover { background: #eef1f0; text-decoration: none; }
.ic { width: 20px; height: 20px; flex: 0 0 20px; }
.item .ic { color: var(--slate); }
.conn .ic { width: 18px; height: 18px; flex-basis: 18px; }
.item.active { background: var(--accent-soft); color: var(--accent-ink); }
.item.active .ic { color: var(--accent); }
.item.active::before {
  content: ""; position: absolute; left: 0; top: 7px; bottom: 7px; width: 3px;
  background: var(--accent); border-radius: 0 2px 2px 0;
}
/* 測試工具：另一個色調，一眼看出不是產品 */
.group.dev { margin-top: auto; padding-top: 18px; border-top: 1px dashed var(--line); }
.group.dev .group-title { color: var(--dev); }
.group.dev .item { color: var(--dev); }
.group.dev .item .ic { color: var(--dev); }
.group.dev .item.active { background: var(--dev-soft); }
.group.dev .item.active::before { background: var(--dev); }

/* ── 主內容 ───────────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; margin: 28px 0 14px; }
h1 { font-size: 1.35rem; line-height: 1.4; margin: 28px 0 14px; font-weight: 700; }
.page-head h1 { margin: 0; }
h2 { font-size: 1.05rem; margin: 28px 0 10px; font-weight: 700; }
h1 small, h2 small, .count { font-weight: 400; color: var(--slate); font-size: 0.9rem; }
p { margin: 0 0 10px; }
.lead { color: var(--slate); max-width: 44em; }
.muted { color: var(--slate); }
.table-note { font-size: 0.85rem; margin: 8px 2px 0; text-align: right; }
.warn { color: var(--warn); }
.meta { color: var(--slate); font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.back {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 22px; margin-bottom: 14px;
  color: var(--slate); font-size: 0.9rem; white-space: nowrap;
}
.back .ic { width: 18px; height: 18px; }
.back:hover { color: var(--accent); }

/* 表格：分隔線分區，不畫格子 */
table { border-collapse: collapse; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 9px 12px; text-align: left; vertical-align: top; font-size: 0.93rem; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
tr:last-child > td { border-bottom: 0; }
th { font-weight: 500; color: var(--slate); background: #fafbfa; white-space: nowrap; }
table.kv th { width: 9em; }
.table-wrap { overflow-x: auto; }

/* 按鈕與表單 */
button, .button {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  padding: 7px 14px; border-radius: var(--radius); cursor: pointer;
  font: inherit; font-size: 0.93rem; font-weight: 500; line-height: 1.4;
}
button:hover, .button:hover { background: var(--accent-ink); border-color: var(--accent-ink); text-decoration: none; }
button.secondary, .button.secondary { background: transparent; color: var(--ink); border-color: var(--line); }
button.secondary:hover, .button.secondary:hover { background: #eef1f0; border-color: var(--slate); }
textarea, select, input[type="number"], input[type="text"], input[type="search"] {
  font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px;
}
textarea { width: 100%; line-height: 1.6; }
textarea:focus, select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
label.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
label.row:last-of-type { border-bottom: 0; }
label.row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.filter button { white-space: nowrap; }
.filter select { max-width: 100%; min-width: 0; }
.filter { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }

/* 提示 */
.flash { margin: 18px 0 0; padding: 10px 14px; border-radius: var(--radius); border: 1px solid transparent; font-size: 0.93rem; }
.flash.error { background: var(--warn-soft); color: var(--warn); border-color: #f2c9c4; }
.flash.notice { background: var(--ok-soft); color: var(--ok); border-color: #cfe7d8; }

/* 標記 */
.badge { display: inline-block; font-size: 0.75rem; line-height: 1.5; padding: 1px 7px; border-radius: 4px; background: #eceff1; color: var(--slate); margin-left: 4px; vertical-align: middle; }
.badge.new { background: var(--new-soft); color: var(--new); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.pos { background: var(--ok-soft); color: var(--ok); }
.badge.neu { background: #eceff1; color: var(--slate); }
.badge.neg { background: var(--warn-soft); color: var(--warn); }

/* AI 判定與草稿 */
section.ai-box { background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px 20px; margin-top: 18px; }
section.ai-box h2 { margin-top: 0; }
blockquote.draft { border-left-color: var(--new); background: var(--new-soft); }

/* 評論清單 */
.review-list { list-style: none; padding: 0; margin: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.review-list li { border-bottom: 1px solid var(--line-soft); }
.review-list li:last-child { border-bottom: 0; }
.review-list li a { display: block; padding: 12px 16px; color: inherit; }
.review-list li a:hover { background: #fafbfa; text-decoration: none; }
.review-list .head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.review-list .stars { color: var(--new); letter-spacing: 0.05em; font-size: 0.9rem; }
.review-list .who { font-weight: 500; }
.review-list .loc { color: var(--slate); font-size: 0.85rem; }
.review-list .time { margin-left: auto; color: var(--faint); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.review-list .snippet { margin: 4px 0 0; color: var(--slate); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 28px 16px; text-align: center; color: var(--slate); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }

/* 評論詳情 */
article.review { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
article.review h1 { margin: 0 0 6px; font-size: 1.15rem; }
article.review h1 .stars { color: var(--new); letter-spacing: 0.05em; }
blockquote { margin: 10px 0; padding: 10px 14px; background: #fafbfa; border-left: 3px solid var(--line); white-space: pre-wrap; }
blockquote.reply { border-left-color: var(--accent); background: var(--accent-soft); }
.reply-box { margin-top: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.reply-box h2 { margin-top: 0; }

/* 手機版頂欄與抽屜（IA-435）：桌面版不顯示 */
.topbar, .nav-close, .nav-backdrop { display: none; }

/* ── 窄螢幕：側欄收成左側抽屜，頂欄放 ☰ 與頁名 ───────── */
@media (max-width: 768px) {
  .shell { display: block; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 50;
    width: min(280px, 85vw); height: auto;
    transform: translateX(-100%); visibility: hidden; transition: transform .2s, visibility .2s;
    overscroll-behavior: contain;
  }
  body.nav-open { overflow: hidden; }
  /* 打開時立刻可見（焦點才移得進去），關閉時等滑出動畫結束才隱藏 */
  body.nav-open .sidebar { transform: none; visibility: visible; transition: transform .2s; box-shadow: 0 0 24px rgba(0, 0, 0, .18); }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(0, 0, 0, .4); opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .nav-close {
    display: inline-flex; position: absolute; top: 14px; right: 10px;
    padding: 6px; border: 0; border-radius: var(--radius); background: none; color: var(--slate); cursor: pointer;
  }
  .nav-close:hover { background: #eef1f0; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 30; height: 56px;
    margin-inline: -16px; padding: 0 8px;
    background: var(--panel); border-bottom: 1px solid var(--line);
  }
  .nav-toggle {
    display: inline-flex; padding: 8px; border: 0; border-radius: var(--radius);
    background: none; color: var(--ink); cursor: pointer;
  }
  .nav-toggle:hover { background: #eef1f0; }
  .nav-toggle .ic { width: 22px; height: 22px; flex-basis: 22px; }
  .topbar-title { font-weight: 700; font-size: 0.95rem; }
  .topbar-spacer { width: 38px; }
  .content { padding-inline: 16px; }
  h1, .page-head { margin-top: 20px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* 摘要頁 */
.bar { display: inline-block; height: 10px; background: var(--new); border-radius: 3px; vertical-align: middle; margin-right: 6px; min-width: 2px; }
h3 { font-size: 0.98rem; margin: 18px 0 6px; font-weight: 600; }

/* ---- 店家登錄頁（IA-420）：無側欄、手機優先 ---- */
body.onboard { display: block; background: var(--paper); }
.onboard-shell { max-width: 480px; margin: 0 auto; padding: 18px 16px 40px; }
.onboard-brand { display: flex; flex-direction: column; line-height: 1.25; margin-bottom: 14px; }
.onboard-brand .brand-mark { font-weight: 700; letter-spacing: 0.05em; }
.onboard-brand .brand-sub { font-size: 0.82rem; color: var(--slate); }
.onboard h1 { font-size: 1.2rem; margin: 6px 0 4px; }
.onboard .lead { color: var(--slate); font-size: 0.92rem; margin: 0 0 12px; }
.onboard .fine, .loc-picker .fine { font-size: 0.8rem; color: var(--faint); margin: 8px 0 0; }
.steps { list-style: none; padding: 0; margin: 4px 0 14px; display: flex; flex-direction: column; gap: 8px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--panel); font-size: 0.92rem; }
.steps li .n { flex: 0 0 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--faint); color: var(--faint); font-size: 0.76rem; display: grid; place-items: center; }
.steps li.done .n { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.cur { border-color: var(--accent); background: var(--accent-soft); }
.steps li.cur .n { background: var(--accent); border-color: var(--accent); color: #fff; }
.steps li .t small { display: block; color: var(--slate); font-size: 0.8rem; }
.onboard .btn { display: block; width: 100%; box-sizing: border-box; text-align: center; text-decoration: none; font: inherit; font-weight: 500; padding: 11px 16px; margin-top: 8px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
.onboard .btn.line { background: #06c755; border-color: #06c755; }
.onboard .btn.secondary { background: #fff; color: var(--accent); }
.onboard .btn.plain { background: transparent; border-color: var(--line); color: var(--ink); }
.onboard .loc, .loc-picker .loc { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line-soft); border-radius: 6px; background: var(--panel); font-size: 0.92rem; margin-bottom: 8px; }
.onboard .loc input, .loc-picker .loc input { margin-top: 4px; accent-color: var(--accent); }
.onboard .loc .t, .loc-picker .loc .t { flex: 1; }
.onboard .loc .t small { display: block; color: var(--faint); font-size: 0.78rem; }
.onboard .pill, .loc-picker .pill { display: inline-block; font-size: 0.74rem; padding: 0 7px; border-radius: 999px; background: var(--new-soft); color: var(--new); margin-top: 2px; }
.onboard .notice, .loc-picker .notice { font-size: 0.88rem; padding: 10px 12px; border-radius: 6px; background: var(--ok-soft); color: var(--ok); margin: 10px 0; }
.onboard .notice.warn, .loc-picker .notice.warn { background: var(--warn-soft); color: var(--warn); }
.loc-picker { max-width: 640px; }
.loc-picker .loc .rule-link { font-size: 0.85rem; white-space: nowrap; }
.loc-picker .loc .rule-now { display: block; color: var(--slate); font-size: 0.8rem; margin-top: 0.125rem; }
/* IA-533：通知設定頁 */
.rule-form { max-width: 40rem; margin-top: 1rem; }
.rule-form table { width: 100%; margin-bottom: 0.75rem; }
.rule-form table.kv th { width: 6.5rem; vertical-align: top; padding-top: 1rem; }
.rule-form input[type="number"] { width: 4.5rem; margin-right: 0.25rem; }
.rule-form .rule-default { color: var(--slate); font-size: 0.85rem; white-space: nowrap; }
.rule-form .fine { font-size: 0.85rem; color: var(--slate); line-height: 1.7; margin: 0.25rem 0; }
.onboard .field { display: flex; flex-direction: column; gap: 8px; }
.onboard .field label { display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; color: var(--slate); }
.onboard .field input[type=text] { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.onboard .check { width: 56px; height: 56px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 1.6rem; margin: 10px auto; }

/* 評論清單工具列與分頁 */
.filter .check, .filter .per { display: inline-flex; align-items: center; gap: 6px; color: var(--slate); font-size: 0.9rem; }
.filter .search { display: inline-flex; gap: 6px; flex: 1 1 220px; min-width: 0; }
.filter .search input[type="search"] { flex: 1 1 auto; min-width: 0; }
.pager { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 18px 0 0; font-size: 0.93rem; }
.pager a, .pager .cur { min-width: 32px; padding: 4px 10px; text-align: center; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: inherit; }
.pager a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.pager .cur { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 500; }
.pager .gap { color: var(--faint); }

/* IA-451：健檢報告檢視頁（PDF.js 畫在 canvas） */
td.nowrap, span.nowrap { white-space: nowrap; }
/* 可點表頭排序（IA-451，同 IA-477）：目前欄 ↓／↑，其他欄淡色 ↕ */
.th-sort { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.th-sort:hover { color: var(--accent); }
.th-sort .arrow { opacity: 0.35; font-size: 0.85em; }
.th-sort.active .arrow, .th-sort:hover .arrow { opacity: 1; }
.pdf-toolbar { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.pdf-toolbar [data-zoom-level] { min-width: 3.5em; text-align: center; color: var(--slate); }
.pdf-pages { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 12px; background: #e5e7eb; border-radius: var(--radius); overflow-x: auto; }
/* 用 auto margin 置中：放大超出容器時不會像 align-items:center 那樣把左半邊推到捲不到的地方 */
.pdf-page { margin-inline: auto; flex-shrink: 0; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); max-width: none; }
.pdf-page canvas { display: block; }

/* IA-503：完整模式已綁定的「帳號與連結」頁 */
.account-page { max-width: 560px; display: flex; flex-direction: column; gap: 14px; }
.acct-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 18px 16px; }
.acct-card h2 { margin: 14px 0 10px; font-size: 0.95rem; color: var(--slate); }
.acct-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 14px 0 10px; }
.acct-head h2 { margin: 0; }
.acct-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.acct-row .t { font-weight: 500; }
.acct-row .t small, .acct-sub { display: block; font-weight: 400; color: var(--slate); font-size: 0.82rem; margin-top: 2px; }
.acct-row form { margin: 0; }
.acct-status { font-size: 0.85rem; white-space: nowrap; }
.acct-status.ok { color: var(--ok); }
.acct-status.bad { color: var(--warn); }
.acct-error { margin: 10px 0 0; padding: 8px 12px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: 0.88rem; }
.acct-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.acct-row .acct-actions { margin-left: auto; }
.acct-actions form { margin: 0; }
.acct-actions-below { margin-top: 10px; }
