/* 聰明投 信任與驗證中心 v2 — 稽核報告風格（紙本報告＋朱印「驗」章），分頁＋白話模式 */
:root {
  color-scheme: light;
  --paper: #f6f4ee; --surface: #ffffff; --surface-2: #fbfaf6; --sunken: #efece3;
  --ink: #142036; --ink-2: #435069; --muted: #6b7486; --rule: #e2ddd0; --rule-strong: #cdc6b4;
  --accent: #23407a; --accent-soft: #e6ecf7; --seal: #b5402c; --seal-soft: #f6e4dd;
  --pass: #0d7a68; --pass-soft: #dcf1ec; --warn: #8f5d00; --warn-soft: #fbefd6; --fail: #b3261e; --fail-soft: #fbe3e0; --info: #4a5a78; --info-soft: #e9edf4;
  --up: #d12f2f; --down: #138a43;
  --series-1: #2a78d6; --series-2: #eb6834; --series-muted: #9aa3b2; --pos-bar: #2a78d6; --neg-bar: #eb6834;
  --zone-bottom: rgba(42, 120, 214, 0.10); --zone-deep: rgba(42, 120, 214, 0.20); --zone-hot: rgba(235, 104, 52, 0.12);
  --shadow: 0 1px 2px rgba(20, 32, 54, 0.06), 0 6px 24px rgba(20, 32, 54, 0.05);
  --radius: 14px; --radius-sm: 9px;
  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --paper: #10141c; --surface: #171c27; --surface-2: #1b2130; --sunken: #0c1017;
    --ink: #e9ecf3; --ink-2: #b9c0cf; --muted: #8b94a7; --rule: #2a3243; --rule-strong: #3a4459;
    --accent: #8fb0f0; --accent-soft: #1e2a44; --seal: #e0735d; --seal-soft: #3a211c;
    --pass: #4cc3a9; --pass-soft: #14322d; --warn: #e8b44f; --warn-soft: #3a2d14; --fail: #f07a70; --fail-soft: #3d1c1a; --info: #a9b6d0; --info-soft: #222b3d;
    --up: #f0625f; --down: #3fbf72; --series-1: #3987e5; --series-2: #d95926; --series-muted: #6b7489; --pos-bar: #3987e5; --neg-bar: #d95926;
    --zone-bottom: rgba(57, 135, 229, 0.14); --zone-deep: rgba(57, 135, 229, 0.26); --zone-hot: rgba(217, 89, 38, 0.18);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #10141c; --surface: #171c27; --surface-2: #1b2130; --sunken: #0c1017;
  --ink: #e9ecf3; --ink-2: #b9c0cf; --muted: #8b94a7; --rule: #2a3243; --rule-strong: #3a4459;
  --accent: #8fb0f0; --accent-soft: #1e2a44; --seal: #e0735d; --seal-soft: #3a211c;
  --pass: #4cc3a9; --pass-soft: #14322d; --warn: #e8b44f; --warn-soft: #3a2d14; --fail: #f07a70; --fail-soft: #3d1c1a; --info: #a9b6d0; --info-soft: #222b3d;
  --up: #f0625f; --down: #3fbf72; --series-1: #3987e5; --series-2: #d95926; --series-muted: #6b7489; --pos-bar: #3987e5; --neg-bar: #d95926;
  --zone-bottom: rgba(57, 135, 229, 0.14); --zone-deep: rgba(57, 135, 229, 0.26); --zone-hot: rgba(217, 89, 38, 0.18);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--font-sans); font-size: 15px; line-height: 1.65; letter-spacing: 0.01em; overflow-x: hidden; }
a { color: var(--accent); text-underline-offset: 3px; }
button, input, select { font: inherit; color: inherit; }
code, .mono { font-family: var(--font-mono); font-size: 0.92em; }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: 0; }
h1, h2, h3 { font-family: var(--font-serif); line-height: 1.3; margin: 0; font-weight: 700; letter-spacing: 0.02em; }
p { margin: 0 0 0.6em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ---------- 頂列 ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: saturate(140%) blur(10px); -webkit-backdrop-filter: saturate(140%) blur(10px); border-bottom: 1px solid var(--rule); }
.topbar-inner { max-width: 1360px; margin: 0 auto; padding: 9px 20px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }
.brand-seal { width: 32px; height: 32px; flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-title { font-family: var(--font-serif); font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-tools { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--rule); background: var(--surface); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; max-width: 100%; min-width: 0; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); flex: none; }
.chip .dot.ok { background: var(--pass); } .chip .dot.warn { background: var(--warn); } .chip .dot.bad { background: var(--fail); }
.chip-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.icon-btn { border: 1px solid var(--rule); background: var(--surface); border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: 12.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; min-height: 30px; }
.icon-btn:hover { border-color: var(--rule-strong); color: var(--ink); }

/* ---------- 版面：側欄分頁 ---------- */
.layout { max-width: 1360px; margin: 0 auto; padding: 0 20px 40px; display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 28px; }
.tabs { position: sticky; top: 64px; align-self: start; padding-top: 22px; display: flex; flex-direction: column; gap: 3px; }
.tabs a { display: grid; grid-template-columns: 10px minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; border: 1px solid transparent; }
.tabs a:hover { background: var(--sunken); color: var(--ink); }
.tabs a.active { background: var(--surface); color: var(--ink); border-color: var(--rule); box-shadow: var(--shadow); }
.tab-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.tab-name { font-weight: 600; font-size: 14.5px; }
.tab-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pip { width: 9px; height: 9px; border-radius: 50%; background: var(--rule-strong); }
.pip.ok { background: var(--pass); } .pip.warn { background: var(--warn); } .pip.bad { background: var(--fail); }
main { min-width: 0; padding-top: 22px; }
.panel { min-width: 0; }
.panel-title { font-size: 24px; margin-bottom: 6px; }
.lede { color: var(--ink-2); max-width: 860px; margin-bottom: 14px; }

/* ---------- 共用元件 ---------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; min-width: 0; margin-top: 14px; }
.grid > .card, .grid-2 > .card { margin-top: 0; }
.card-title { font-family: var(--font-serif); font-size: 17px; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-sub { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.grid { display: grid; gap: 12px; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 14px; }
.align-start { align-items: start; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; min-width: 0; }
.spacer { flex: 1 1 auto; }
.muted { color: var(--muted); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.up { color: var(--up); } .down { color: var(--down); }
.kpi { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; min-width: 0; box-shadow: var(--shadow); }
.kpi-label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi-value { font-family: var(--font-mono); font-size: 24px; font-weight: 500; line-height: 1.25; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-value.sm { font-size: 19px; }
.kpi-foot { font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.7; }
.badge.pass { background: var(--pass-soft); color: var(--pass); } .badge.warn { background: var(--warn-soft); color: var(--warn); } .badge.fail { background: var(--fail-soft); color: var(--fail); }
.badge.info { background: var(--info-soft); color: var(--info); } .badge.seal { background: var(--seal-soft); color: var(--seal); }
.stamp { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; border: 1.5px solid var(--seal); color: var(--seal); font-family: var(--font-serif); font-size: 12px; font-weight: 700; transform: rotate(-6deg); flex: none; }
.stamp-lg { width: 46px; height: 46px; font-size: 23px; border-width: 2px; }
.light { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--rule-strong); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rule-strong) 30%, transparent); }
.light.ok { background: var(--pass); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pass) 22%, transparent); }
.light.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }
.light.bad { background: var(--fail); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fail) 22%, transparent); }
.note { margin-top: 10px; border-left: 3px solid var(--warn); background: var(--warn-soft); border-radius: 0 8px 8px 0; padding: 8px 12px; font-size: 13.5px; color: var(--ink); }
.note.info { border-left-color: var(--info); background: var(--info-soft); } .note.fail { border-left-color: var(--fail); background: var(--fail-soft); } .note.pass { border-left-color: var(--pass); background: var(--pass-soft); }
.note-title { font-weight: 700; margin-bottom: 2px; }
.fix-list { margin: 6px 0 0; padding-left: 18px; }
.banner { border-radius: var(--radius-sm); padding: 9px 14px; margin: 12px 0 0; font-size: 14px; }
.banner.fail { background: var(--fail-soft); color: var(--fail); } .banner.warn { background: var(--warn-soft); color: var(--warn); }
.skeleton { background: linear-gradient(90deg, var(--sunken), var(--surface-2), var(--sunken)); background-size: 200% 100%; animation: sk 1.2s infinite linear; border-radius: 8px; min-height: 18px; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

/* ---------- 總覽（一屏） ---------- */
.ov-hero { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 22px; align-items: center; padding: 22px 26px; border-radius: 18px; border: 1px solid var(--rule); box-shadow: var(--shadow);
  background: radial-gradient(900px 300px at 100% 0%, color-mix(in srgb, var(--seal-soft) 75%, transparent), transparent 60%), linear-gradient(180deg, var(--surface), var(--surface-2)); }
.ov-text { min-width: 0; }
.eyebrow { font-size: 12px; letter-spacing: 0.16em; color: var(--seal); font-weight: 700; margin-bottom: 8px; }
.ov-hero h1 { font-size: clamp(26px, 3.2vw, 38px); line-height: 1.22; margin-bottom: 10px; }
.ov-hero h1 em { font-style: normal; color: var(--seal); }
.ov-summary { color: var(--ink-2); font-size: 15.5px; max-width: 760px; margin: 0; }
.ov-points { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 6px; font-size: 15px; color: var(--ink); }
.ov-points li { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 10px; align-items: baseline; }
.ov-points .light { width: 9px; height: 9px; transform: translateY(-1px); }
.hero-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.ov-seal { display: flex; justify-content: center; }
svg.seal { width: 190px; height: 190px; }
.status-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.status-tile { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--rule); background: var(--surface); box-shadow: var(--shadow); text-decoration: none; color: inherit; min-width: 0; transition: transform .15s, border-color .15s; border-top-width: 4px; }
.status-tile:hover { transform: translateY(-1px); border-color: var(--rule-strong); }
.status-tile.ok { border-top-color: var(--pass); } .status-tile.warn { border-top-color: var(--warn); } .status-tile.bad { border-top-color: var(--fail); } .status-tile.info { border-top-color: var(--rule-strong); }
.status-top { display: flex; align-items: center; gap: 9px; }
.status-label { font-weight: 600; font-size: 14px; color: var(--ink-2); }
.status-big { font-family: var(--font-mono); font-size: 40px; font-weight: 500; line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums; }
.status-big small { font-size: 15px; color: var(--muted); font-family: var(--font-sans); margin-left: 4px; }
.status-sub { font-weight: 600; font-size: 14px; overflow-wrap: anywhere; }
.status-foot { font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.ov-mini { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px dashed var(--rule-strong); color: var(--ink-2); text-decoration: none; font-size: 13.5px; }
.ov-mini span:nth-child(2) { flex: 1 1 260px; min-width: 0; }

/* ---------- 白話與專業 ---------- */
.plain-box { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; align-items: start; margin-top: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-size: 15px; }
.plain-tag { font-size: 12px; font-weight: 700; color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 0 8px; line-height: 1.8; white-space: nowrap; }
.quote { margin-top: 12px; padding: 10px 14px; border-left: 3px solid var(--rule-strong); background: var(--surface-2); border-radius: 0 8px 8px 0; font-size: 14px; color: var(--ink-2); }
.quote-tag { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
details.pro { margin-top: 12px; border: 1px solid var(--rule); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
details.pro > summary { cursor: pointer; list-style: none; padding: 12px 18px; font-weight: 600; font-size: 14.5px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
details.pro > summary::-webkit-details-marker { display: none; }
details.pro > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.pro[open] > summary::before { transform: rotate(90deg); }
.pro-body { padding: 0 18px 16px; }
.pro-body > .card:first-child, .pro-body > .grid-2:first-child { margin-top: 0; }
.pro-body .card { box-shadow: none; }

/* ---------- 驗算 ---------- */
.form-card { margin-top: 0; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; margin-top: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-wide { grid-column: span 2; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.input, select.input { width: 100%; border: 1px solid var(--rule-strong); background: var(--surface); border-radius: 10px; padding: 8px 11px; min-height: 40px; min-width: 0; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); border-color: var(--accent); }
.input.invalid { border-color: var(--fail); }
.field-help { font-size: 12px; color: var(--muted); }
.field-error { font-size: 12.5px; color: var(--fail); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 10px; overflow: hidden; max-width: 100%; }
.seg button { border: 0; background: var(--surface); padding: 7px 14px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg-sm button { padding: 3px 11px; font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { border: 1px solid var(--rule-strong); background: var(--surface); border-radius: 999px; padding: 3px 12px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.chip-btn:hover { color: var(--ink); border-color: var(--ink-2); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; padding: 8px 18px; min-height: 40px; cursor: pointer; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); font-weight: 600; }
.btn:hover { filter: brightness(1.1); }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--rule-strong); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn.fix { border-color: var(--fail); background: var(--surface); color: var(--fail); padding: 1px 10px; min-height: 26px; font-size: 12px; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--ink); }
.verdict { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; padding: 14px 18px; border-radius: var(--radius); border: 1px solid var(--rule); background: var(--surface-2); margin-top: 14px; }
.verdict.pass { border-color: color-mix(in srgb, var(--pass) 35%, var(--rule)); background: color-mix(in srgb, var(--pass-soft) 55%, var(--surface)); }
.verdict.warn { border-color: color-mix(in srgb, var(--warn) 35%, var(--rule)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.verdict.fail { border-color: color-mix(in srgb, var(--fail) 35%, var(--rule)); background: color-mix(in srgb, var(--fail-soft) 55%, var(--surface)); }
.verdict-big { font-family: var(--font-mono); font-size: 34px; font-weight: 500; line-height: 1; }
.verdict-text { min-width: 0; flex: 1 1 260px; }
.verdict-title { font-family: var(--font-serif); font-weight: 700; font-size: 17px; }
.assume { margin: 0; padding-left: 20px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface); max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 7px 11px; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12.5px; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; z-index: 1; }
tr:last-child td { border-bottom: none; }
td.r, th.r { text-align: right; } td.nowrap { white-space: nowrap; }
tr.is-bad td { background: color-mix(in srgb, var(--fail-soft) 45%, transparent); }
tr.is-warn td { background: color-mix(in srgb, var(--warn-soft) 45%, transparent); }
.table-scroll { max-height: 380px; overflow: auto; }

/* ---------- 圖表 ---------- */
.chart { width: 100%; height: 300px; min-width: 0; }
.chart.tall { height: 320px; }
.chart-fallback { display: grid; place-items: center; height: 100%; color: var(--muted); font-size: 13px; border: 1px dashed var(--rule-strong); border-radius: 10px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin: 2px 0 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }
.legend i.dot { width: 7px; height: 7px; border-radius: 50%; }

/* ---------- 記分板 ---------- */
.dial { position: relative; margin: 30px 0 12px; }
.dial-track { display: flex; height: 14px; border-radius: 7px; overflow: hidden; gap: 2px; }
.dial-seg { height: 100%; }
.dial-seg.hot { background: color-mix(in srgb, var(--neg-bar) 55%, var(--surface)); } .dial-seg.neutral { background: var(--sunken); }
.dial-seg.bottom { background: color-mix(in srgb, var(--pos-bar) 40%, var(--surface)); } .dial-seg.deep { background: color-mix(in srgb, var(--pos-bar) 75%, var(--surface)); }
.dial-marker { position: absolute; top: -26px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.dial-marker b { font-family: var(--font-mono); font-size: 15px; background: var(--ink); color: var(--paper); border-radius: 6px; padding: 0 7px; line-height: 20px; }
.dial-marker::after { content: ""; width: 2px; height: 22px; background: var(--ink); }
.dial-scale { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); margin-top: 6px; font-family: var(--font-mono); }
.formula { font-family: var(--font-mono); font-size: 13.5px; background: var(--sunken); border-radius: 10px; padding: 9px 13px; overflow-wrap: anywhere; line-height: 1.9; }
.formula .p { color: var(--pos-bar); } .formula .n { color: var(--neg-bar); }
.ptbar { display: inline-block; height: 8px; border-radius: 2px; vertical-align: middle; }
.ptbar.p { background: var(--pos-bar); } .ptbar.n { background: var(--neg-bar); }
.cov { position: relative; height: 8px; background: var(--sunken); border-radius: 4px; min-width: 110px; }
.cov span { position: absolute; top: 0; bottom: 0; border-radius: 4px; background: var(--accent); opacity: 0.75; }

/* ---------- 口徑與追蹤 ---------- */
.track { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.track-item { border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); min-width: 0; }
.track-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 3px; }
.method-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
details.method { border: 1px solid var(--rule); border-radius: var(--radius-sm); padding: 8px 12px; background: var(--surface-2); min-width: 0; }
details.method > summary { cursor: pointer; list-style: none; }
details.method > summary::-webkit-details-marker { display: none; }
details.method p { margin: 8px 0 4px; font-size: 13.5px; color: var(--ink-2); overflow-wrap: anywhere; }

/* ---------- 自我檢測 ---------- */
.tests { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.test { display: grid; grid-template-columns: 74px minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 10px 12px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface); }
.test-name { font-weight: 600; font-size: 14px; }
.test-detail { font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.test-detail code { background: var(--sunken); padding: 0 4px; border-radius: 4px; }
.test-ms { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ---------- 出處條、頁尾 ---------- */
.provenance { margin-top: 16px; border-top: 1px dashed var(--rule-strong); padding-top: 10px; font-size: 12px; color: var(--muted); display: grid; gap: 3px; }
.provenance .src { display: flex; gap: 6px 12px; flex-wrap: wrap; align-items: center; }
.provenance .src-item { overflow-wrap: anywhere; }
.provenance code { color: var(--ink-2); }
.provenance .disc { color: var(--ink-2); }
.site-foot { border-top: 1px solid var(--rule); margin-top: 24px; padding: 18px 20px 30px; color: var(--muted); font-size: 12.5px; }
.site-foot-inner { max-width: 1360px; margin: 0 auto; display: grid; gap: 6px; }
.site-foot strong { color: var(--ink-2); }

/* ---------- 金鑰頁 ---------- */
.gate { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 40px 16px; }
.gate-card { width: min(560px, 100%); background: var(--surface); border: 1px solid var(--rule); border-radius: 20px; padding: 30px; box-shadow: var(--shadow); }
.gate-card h1 { font-size: 26px; margin: 10px 0 8px; }
.gate-card ol { padding-left: 20px; color: var(--ink-2); font-size: 14px; }
.gate-seal { width: 60px; height: 60px; }

/* ---------- 響應式 ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .tabs { position: sticky; top: 52px; z-index: 20; flex-direction: row; gap: 6px; padding: 8px 20px; margin: 0 -20px; overflow-x: auto; background: var(--paper); border-bottom: 1px solid var(--rule); scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { grid-template-columns: 8px auto; padding: 6px 12px; border: 1px solid var(--rule); background: var(--surface); flex: none; }
  .tab-sub { display: none; }
  .tab-name { font-size: 13.5px; white-space: nowrap; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .topbar-inner { padding: 7px 16px; gap: 8px; }
  .brand-sub, .hide-sm { display: none; }
  .brand-title { font-size: 15px; }
  .layout { padding: 0 16px 32px; }
  .tabs { margin: 0 -16px; padding: 8px 16px; top: 48px; }
  .ov-hero { grid-template-columns: minmax(0, 1fr); padding: 18px; gap: 6px; }
  .ov-seal { order: -1; justify-content: flex-start; }
  svg.seal { width: 128px; height: 128px; }
  .status-row { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .status-tile { padding: 12px 14px; }
  .status-big { font-size: 32px; }
  .grid-2, .track, .method-list, .tests { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .kpi-value.sm { font-size: 16px; }
  .card { padding: 14px; }
  .panel-title { font-size: 21px; }
  .test { grid-template-columns: minmax(0, 1fr) auto; }
  .test > div:first-child { grid-column: 1 / -1; }
  .chart { height: 240px; }
  .verdict-big { font-size: 28px; }
  .verdict .stamp-lg { display: none; }
  .form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .form .field-wide, .form #v-symbol, .form .field:has(#v-symbol), .form .field:has(#v-amount) { grid-column: 1 / -1; }
  details.pro > summary { padding: 11px 14px; }
  .pro-body { padding: 0 12px 12px; }
  th, td { padding: 6px 8px; }
}
@media print { .topbar, .tabs, .btn, .icon-btn, .chips, .seg { display: none !important; } .layout { display: block; } .panel[hidden] { display: block !important; } body { background: #fff; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===================== r4：互審後改進 ===================== */
.icon-sq { width: 36px; height: 36px; padding: 0; justify-content: center; font-size: 15px; }
.seg-sm button { min-height: 32px; }
.attr-list { margin: 2px 0 0; padding-left: 18px; }
.key-row { gap: 8px; margin-top: 4px; }
.banner.info { background: var(--info-soft); color: var(--info); }
/* 出處列：可收合 */
details.prov > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 32px; }
details.prov > summary::-webkit-details-marker { display: none; }
details.prov > summary::after { content: "展開"; margin-left: auto; font-size: 11.5px; color: var(--accent); }
details.prov[open] > summary::after { content: "收合"; }
.prov-short { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1 1 auto; }
details.prov[open] > summary .prov-short { white-space: normal; }
details.prov > div { margin-top: 6px; }
/* 總覽狀態卡：連結區＋動作按鈕 */
.status-tile { padding: 0; }
.status-link { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px 10px; text-decoration: none; color: inherit; flex: 1 1 auto; }
.status-tile > .btn { margin: 0 18px 16px; align-self: flex-start; }
a.ov-seal { text-decoration: none; }
/* 全部策略對帳格子 */
.mx-cell { width: 100%; min-height: 40px; border-radius: 8px; border: 1px solid var(--rule); background: var(--surface-2); cursor: pointer; font-family: var(--font-mono); font-size: 13px; text-align: left; padding: 6px 10px; }
.mx-cell.ok { background: var(--pass-soft); color: var(--pass); border-color: color-mix(in srgb, var(--pass) 30%, var(--rule)); }
.mx-cell.bad { background: var(--fail-soft); color: var(--fail); border-color: color-mix(in srgb, var(--fail) 30%, var(--rule)); }
.cost { flex: 1 1 260px; min-width: 0; }
/* 手機分頁列：左右漸層提示還能滑 */
.tabs-wrap { position: sticky; top: 64px; align-self: start; min-width: 0; z-index: 5; }
.tabs-wrap .tabs { position: static; }
@media (max-width: 1080px) {
  .tabs-wrap { top: 52px; z-index: 20; margin: 0 -20px; }
  .tabs-wrap .tabs { margin: 0; }
  .tabs-wrap::after { content: "›"; position: absolute; right: 0; top: 0; bottom: 1px; width: 44px; display: grid; place-items: center; font-size: 22px; color: var(--ink-2); background: linear-gradient(90deg, transparent, var(--paper) 60%); pointer-events: none; transition: opacity .2s; }
  .tabs-wrap.at-end::after { opacity: 0; }
  .tabs a { min-height: 40px; }
}
@media (max-width: 760px) {
  .tabs-wrap { top: 48px; margin: 0 -16px; }
  .seg-sm button { min-height: 40px; padding: 4px 14px; }
  .icon-sq { width: 40px; height: 40px; }
  .icon-btn { min-height: 40px; }
  .chip-btn, .btn.small, .btn.fix { min-height: 40px; }
  details.pro > summary, details.method > summary { min-height: 44px; }
  .status-link { padding: 12px 14px 8px; }
  .status-tile > .btn { margin: 0 14px 12px; }
  details.prov > summary { min-height: 40px; }
}
/* 列印驗證證明（A4） */
#print-cert { display: none; }
@media print {
  body.printing-cert > *:not(#print-cert) { display: none !important; }
  body.printing-cert #print-cert { display: block; color: #000; font-size: 11pt; padding: 0; }
  #print-cert h1 { font-size: 20pt; margin: 6pt 0; }
  #print-cert table { width: 100%; border-collapse: collapse; margin: 8pt 0; font-size: 9.5pt; }
  #print-cert th, #print-cert td { border: 0.5pt solid #999; padding: 3pt 5pt; }
  #print-cert .pc-mark { border: 1.5pt solid #b5402c; color: #b5402c; font-weight: 700; padding: 4pt 8pt; display: inline-block; }
  #print-cert .pc-small { font-size: 8pt; color: #333; word-break: break-all; }
  @page { size: A4; margin: 14mm; }
}
.provenance { grid-template-columns: minmax(0, 1fr); }
details.prov, details.prov > summary { min-width: 0; max-width: 100%; }
details.prov > summary::after { white-space: nowrap; }
@media (max-width: 760px) { .table-wrap td:first-child, .table-wrap th:first-child { min-width: 7em; } }

/* ---------- r6：我的投組、修正追蹤分組 ---------- */
.track-sub { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 16px 0 8px; padding-top: 12px; border-top: 1px dashed var(--rule); }
.seg.seg-wrap { flex-wrap: wrap; min-width: 0; }
@media (max-width: 520px) { .seg.seg-wrap > button { flex: 1 1 auto; } }
details.track-self > summary { cursor: pointer; list-style: none; }
details.track-self > summary::-webkit-details-marker { display: none; }
details.track-self > summary::after { content: '▾'; color: var(--muted); margin-left: auto; }
details.track-self:not([open]) > summary::after { content: '▸'; }
.wrap-any { overflow-wrap: anywhere; word-break: break-all; }
