/* ==========================================================================
   數據平台前台 — 設計系統
   配色參考 decreto：淺灰底、白卡片、橘 / 薄荷綠 / 墨黑色塊
   主題：data-theme="light" | "dark"；未設定時跟隨系統
   ========================================================================== */

:root {
    color-scheme: light;
    --bg: #f1f2f0;
    --surface: #ffffff;
    --surface-2: #f7f8f6;
    --surface-3: #eceeeb;
    --line: #e2e5e1;
    --line-strong: #cfd4cf;
    --text: #1d2521;
    --text-2: #4f5a54;
    --text-3: #7d8781;

    --orange: #e8692f;
    --orange-strong: #c4521c;      /* 按鈕底色，白字對比 ≥ 4.5 */
    --orange-soft: #fde9df;
    --mint: #a8d8cf;
    --mint-strong: #1f7f70;
    --mint-soft: #e3f3ef;
    --ink: #2b332f;
    --ink-2: #3a4540;
    --slate: #5e6a65;

    --on-orange: #ffffff;
    --on-mint: #16302b;
    --on-ink: #f3f5f3;

    --good-text: #0a7a36;
    --bad-text: #c0362c;
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-serious: #ec835a;
    --status-critical: #d03b3b;

    /* 圖表分類色（已通過色覺辨識驗證：淺色 CVD ΔE ≥ 11.9、一般視覺 ≥ 19.5） */
    --c1: #e8692f;
    --c2: #1f9e8a;
    --c3: #2f6fd0;
    --c4: #d99a00;
    --c5: #8c5bc8;
    --c6: #c9425a;
    --c-muted: #b7bdb8;
    --grid: #eceeeb;
    /* 熱度圖序列色（薄荷綠單色，由淺到深） */
    --seq-low: #e6f4f0;
    --seq-high: #135e53;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(20, 30, 25, .04), 0 4px 16px rgba(20, 30, 25, .04);
    --sidebar-w: 248px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) {
        color-scheme: dark;
        --bg: #111513;
        --surface: #1a1f1c;
        --surface-2: #202622;
        --surface-3: #272e2a;
        --line: #2c3430;
        --line-strong: #3b4540;
        --text: #e9edea;
        --text-2: #b5beb9;
        --text-3: #8a948f;
        --orange: #e06a33;
        --orange-strong: #e06a33;
        --orange-soft: #3a2519;
        --mint: #2f6e63;
        --mint-strong: #7fc8bb;
        --mint-soft: #1d302b;
        --ink: #2a322e;
        --ink-2: #333d38;
        --slate: #3f4a45;
        --on-orange: #ffffff;
        --on-mint: #eaf7f3;
        --on-ink: #eef2ef;
        --good-text: #5fd08a;
        --bad-text: #f08075;
        --c1: #e06a33;
        --c2: #1f9c88;
        --c3: #4d8ae6;
        --c4: #b88300;
        --c5: #a07ee0;
        --c6: #e0667d;
        --c-muted: #56605b;
        --grid: #262d29;
        --seq-low: #1f2b27;
        --seq-high: #8fd6c5;
        --shadow: none;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #111513;
    --surface: #1a1f1c;
    --surface-2: #202622;
    --surface-3: #272e2a;
    --line: #2c3430;
    --line-strong: #3b4540;
    --text: #e9edea;
    --text-2: #b5beb9;
    --text-3: #8a948f;
    --orange: #e06a33;
    --orange-strong: #e06a33;
    --orange-soft: #3a2519;
    --mint: #2f6e63;
    --mint-strong: #7fc8bb;
    --mint-soft: #1d302b;
    --ink: #2a322e;
    --ink-2: #333d38;
    --slate: #3f4a45;
    --on-orange: #ffffff;
    --on-mint: #eaf7f3;
    --on-ink: #eef2ef;
    --good-text: #5fd08a;
    --bad-text: #f08075;
    --c1: #e06a33;
    --c2: #1f9c88;
    --c3: #4d8ae6;
    --c4: #b88300;
    --c5: #a07ee0;
    --c6: #e0667d;
    --c-muted: #56605b;
    --grid: #262d29;
    --seq-low: #1f2b27;
    --seq-high: #8fd6c5;
    --shadow: none;
}

/* ── 基本 ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
a.link { color: var(--mint-strong); text-decoration: underline; text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* ── 版面 ─────────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex; flex-direction: column;
    padding: 22px 16px;
    gap: 22px;
    overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
/* 平台標誌：橘底，白色斜向圓角長條與小圓點（半透明為次要元素）；線條是 SVG，底色跟著主題的橘色 */
.brand-mark {
    width: 38px; height: 38px; border-radius: 10px; flex: none;
    display: block; position: relative; overflow: hidden;
    background: var(--orange) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cg transform='translate(20 20) scale(1.1) rotate(-45) translate(-20 -20)' stroke='%23fff' stroke-width='3' stroke-linecap='round' fill='%23fff'%3E%3Cline x1='15.7' y1='8.4' x2='19.3' y2='8.4' stroke-opacity='.55'/%3E%3Ccircle fill-opacity='.55' stroke='none' cx='26.8' cy='8.4' r='1.5'/%3E%3Ccircle fill-opacity='.55' stroke='none' cx='8.3' cy='14.2' r='1.5'/%3E%3Cline x1='15.7' y1='14.2' x2='30.9' y2='14.2'/%3E%3Cline x1='8.3' y1='20.0' x2='11.9' y2='20.0' stroke-opacity='.55'/%3E%3Cline x1='20.7' y1='20.0' x2='31.7' y2='20.0'/%3E%3Cline x1='9.6' y1='25.8' x2='29.3' y2='25.8'/%3E%3Ccircle fill-opacity='.55' stroke='none' cx='13.4' cy='31.6' r='1.5'/%3E%3Cline x1='22.0' y1='31.6' x2='23.2' y2='31.6' stroke-opacity='.55'/%3E%3C/g%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: .5px; }
.brand-sub { display: block; font-size: 11px; color: var(--text-3); font-weight: 500; letter-spacing: 1.5px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
/* 分組標題：點擊開啟／收起，右側箭頭朝下為展開、朝右為收起 */
.nav-label {
    width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px;
    border: 0; background: none; cursor: pointer; text-align: left; font: inherit; border-radius: var(--radius-sm);
    font-size: 11px; font-weight: 600; letter-spacing: 1px; color: var(--text-3); padding: 10px 12px 6px;
}
.nav-label:hover { color: var(--text); }
.nav-label:focus-visible { outline: 2px solid var(--orange); outline-offset: -2px; }
.nav-caret { width: 15px; height: 15px; flex: none; transition: transform .2s ease; }
.nav-group.closed .nav-caret { transform: rotate(-90deg); }
.nav-group[hidden] { display: none; }
.nav-items { display: grid; grid-template-rows: 1fr; transition: grid-template-rows .22s ease; }
.nav-items > div { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.nav-group.closed .nav-items { grid-template-rows: 0fr; }
.nav-group.closed .nav-items > div { visibility: hidden; transition: visibility 0s .22s; }   /* 收起後不能用 Tab 移到裡面的連結 */
.nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 600;
}
.nav a:hover { background: var(--surface-3); color: var(--text); }
.nav a.active { background: var(--slate); color: #fff; }

.side-panel {
    margin-top: auto;
    background: var(--mint-soft);
    border-radius: var(--radius);
    padding: 14px;
    font-size: 12px; color: var(--text-2);
}
.side-panel strong { display: block; color: var(--text); font-size: 13px; margin-bottom: 4px; }

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px;
    padding: 14px 28px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
}
.icon-btn.menu-btn { display: none; }
.site-switch { position: relative; }
.site-switch button {
    display: flex; align-items: center; gap: 10px;
    background: none; border: 0; cursor: pointer; text-align: left; padding: 4px 6px; border-radius: var(--radius-sm);
}
.site-switch button:hover { background: var(--surface-3); }
.site-switch .site-name { font-weight: 700; font-size: 15px; display: block; }
.site-switch .site-hint { font-size: 12px; color: var(--text-3); display: block; }
.dropdown {
    position: absolute; top: calc(100% + 6px); left: 0; min-width: 280px; max-height: 60vh; overflow: auto;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(0, 0, 0, .14); padding: 6px; display: none;
}
.dropdown.open { display: block; }
.dropdown a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px; border-radius: var(--radius-sm); }
.dropdown a:hover, .dropdown a.current { background: var(--surface-3); }
.dropdown a + a { margin-top: 3px; }   /* 項目之間留一點距離，滑鼠移過的底色才不會黏在一起 */
.topbar-spacer { flex: 1; }

.segmented {
    display: inline-flex; background: var(--surface); border: 1px solid var(--line);
    border-radius: 999px; padding: 3px; gap: 2px;
}
.segmented button {
    border: 0; background: none; cursor: pointer; border-radius: 999px;
    padding: 5px 12px; font-weight: 600; font-size: 13px; color: var(--text-2);
    display: inline-flex; align-items: center; gap: 6px;
}
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--slate); color: #fff; }
.segmented.icons button { padding: 5px 8px; }
.segmented[hidden] { display: none; }   /* 不需要期間的頁面（帳號）隱藏切換鈕，不留下空殼 */

.icon-btn {
    width: 38px; height: 38px; border-radius: 50%;
    display: inline-grid; place-items: center; cursor: pointer;
    background: var(--surface); border: 1px solid var(--line); color: var(--text-2);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }
.avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: inline-grid; place-items: center;
    background: var(--surface-3); color: var(--text-2); font-weight: 700; font-size: 13px;
    border: 0; cursor: pointer;
}
.user-menu { position: relative; }
.user-menu .dropdown { left: auto; right: 0; min-width: 220px; }
.user-menu .who { padding: 10px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.user-menu .who small { display: block; color: var(--text-3); }

.content { padding: 26px 28px 60px; width: 100%; min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 26px; font-weight: 800; letter-spacing: .3px; }
.page-head p { margin: 4px 0 0; color: var(--text-3); }
.breadcrumb { font-size: 13px; color: var(--text-3); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; }
.breadcrumb a:hover { color: var(--text); }

/* ── 網格 ─────────────────────────────────────────────────────────────── */
.grid { display: grid; gap: 18px; }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.mt { margin-top: 18px; }

/* ── 卡片 ─────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 20px 22px; min-width: 0;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; min-height: 28px; }   /* 與右上角的切換按鈕同高，並排的卡片標題才對齊 */
.card-head h2 { font-size: 17px; font-weight: 700; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }
.card-tools { display: flex; gap: 6px; align-items: center; flex: none; }
.chip-btn {
    border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
    border-radius: 999px; height: 28px; padding: 0 10px; font-size: 12px; font-weight: 600; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 4px; vertical-align: middle;   /* 圖示與文字垂直置中 */
}
.chip-btn svg.icon { width: 14px; height: 14px; }
/* 卡片右上角與區塊標題上的切換鈕：與 chip-btn 同為 28px 高，並排時對齊 */
.card-tools .segmented, .segmented.mini { height: 28px; padding: 2px; vertical-align: middle; }
.card-tools .segmented button, .segmented.mini button { height: 22px; padding: 0 10px; font-size: 12px; }
.chip-btn:hover, .chip-btn.on { background: var(--surface-3); color: var(--text); }

/* ── 主色 KPI 色塊（decreto 風格） ────────────────────────────────────── */
.hero-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.hero {
    border-radius: var(--radius); padding: 20px 22px; min-height: 150px;
    display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
    position: relative; overflow: hidden;
}
.hero.orange { background: var(--orange); color: var(--on-orange); }
.hero.mint { background: var(--mint); color: var(--on-mint); }
.hero.ink { background: var(--ink); color: var(--on-ink); border: 1px solid var(--ink-2); }
.hero-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; white-space: nowrap; }
.hero-title svg.icon { width: 26px; height: 26px; stroke-width: 1.6; }
.hero-top { display: flex; justify-content: space-between; align-items: center; gap: 8px 10px; flex-wrap: wrap; }
.hero-values { display: flex; gap: 12px 28px; align-items: flex-end; flex-wrap: wrap; }
.hero-value strong { display: block; font-size: clamp(26px, 2.6vw, 36px); font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero-value > span { font-size: 12.5px; opacity: .85; }   /* 只套用說明文字，不影響數字裡的 span（數字滾動） */
.hero-delta { white-space: nowrap; flex: none; font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: rgba(255, 255, 255, .22); }
.hero.mint .hero-delta { background: color-mix(in srgb, var(--on-mint) 12%, transparent); }


/* ── 小型 KPI ──────────────────────────────────────────────────────────── */
.stat { display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 13px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }

/* 數字滾動（UI.roll）：每一位數是一條 0～9 的直條，用位移切到目標數字 */
.roll { --roll-h: 1.15em; display: inline-flex; vertical-align: top; }
.hero-value .roll { --roll-h: 1.1em; }
.roll > span { display: inline-block; height: var(--roll-h); line-height: var(--roll-h); white-space: pre; }
.roll-d { overflow: hidden; }
.roll-strip { display: flex; flex-direction: column; transition: transform .8s cubic-bezier(.22, 1, .36, 1); will-change: transform; }
.roll-strip span { display: block; height: var(--roll-h); line-height: var(--roll-h); text-align: center; }
.stat-foot { font-size: 12px; color: var(--text-3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 700; font-size: 12.5px; }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--bad-text); }
.delta.flat { color: var(--text-3); }
.delta svg.icon { width: 14px; height: 14px; stroke-width: 2.4; }

/* ── 白話結論 ─────────────────────────────────────────────────────────── */
.insights { display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 0; list-style: none; }
.insights li { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; line-height: 1.65; }
.insights .tone {
    width: 26px; height: 26px; border-radius: 50%; flex: none;
    display: grid; place-items: center; margin-top: 1px;
}
.insights .tone svg.icon { width: 15px; height: 15px; stroke-width: 2.4; }
.tone.good { background: var(--mint-soft); color: var(--mint-strong); }
.tone.warn { background: var(--orange-soft); color: var(--orange-strong); }
.tone.info { background: var(--surface-3); color: var(--text-2); }
.card.summary { background: var(--surface); border-left: 4px solid var(--orange); }

/* ── 列表 / 表格 ──────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
    text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3);
    padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .r { text-align: right; font-variant-numeric: tabular-nums; }
table.data .title-cell { max-width: 460px; }
table.data .title-cell a { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data .title-cell a:hover { color: var(--orange-strong); }
table.data .path { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
tr.clickable { cursor: pointer; }

.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank-list li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rank-list li:last-child { border-bottom: 0; }
.rank-no { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.rank-list li:first-child .rank-no { background: var(--orange); color: var(--on-orange); }
.rank-list.plain li:first-child .rank-no { background: var(--surface-3); color: var(--text-2); }
.rank-no svg.icon { width: 14px; height: 14px; stroke-width: 2.4; }
.rank-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-title:hover { color: var(--orange-strong); }
.rank-sub { font-size: 12px; color: var(--text-3); }
.rank-val { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

.meter { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.meter > span { display: block; height: 100%; border-radius: 3px; background: var(--mint-strong); }
.meter-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.meter-cell .meter { width: 60px; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.orange { background: var(--orange-soft); color: var(--orange-strong); }
.badge.mint { background: var(--mint-soft); color: var(--mint-strong); }

/* ── 訪客組成 ─────────────────────────────────────────────────────────── */
.audience-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 26px 36px; }
/* 標題列固定高度（等於切換按鈕的高度），有沒有按鈕都對齊 */
.audience-block .stat-label { margin-bottom: 8px; min-height: 28px; }
.audience-block .hbars { gap: 8px; }
.audience-block .hbar-row { grid-template-columns: minmax(56px, 96px) minmax(0, 1fr) auto; }
.audience-note { font-size: 11.5px; color: var(--text-3); margin: -4px 0 8px; }
@media (max-width: 760px) { .audience-grid { grid-template-columns: minmax(0, 1fr); } }

/* 訪客組成並排比較（A 橘、B 綠） */
.cmp-row { display: grid; grid-template-columns: minmax(56px, 96px) minmax(0, 1fr) 36px; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); }
.cmp-row:last-child { border-bottom: 0; }
.cmp-label { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-bars { display: flex; flex-direction: column; gap: 3px; }
.cmp-bars > div { display: flex; align-items: center; gap: 6px; height: 12px; }
.cmp-bars span { display: block; height: 10px; border-radius: 0 4px 4px 0; min-width: 2px; }
.cmp-bars em { font-style: normal; font-size: 11.5px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cmp-diff { font-size: 12px; font-weight: 700; color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }

/* ── 受眾標籤 ─────────────────────────────────────────────────────────── */
.tag-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px 1px 6px; margin: 2px 4px 0 0;
    border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6;
    background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); white-space: nowrap;
}
.tag-chip i { width: 8px; height: 8px; border-radius: 50%; flex: none; }
a.tag-chip:hover { border-color: var(--line-strong); color: var(--text); }
.tag-toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-toggle { cursor: pointer; margin: 0; padding: 3px 10px 3px 8px; font-size: 12.5px; }
.tag-toggle:hover { border-color: var(--line-strong); color: var(--text); }
.tag-toggle.on { background: var(--mint-soft); border-color: var(--mint-strong); color: var(--text); box-shadow: inset 0 0 0 1px var(--mint-strong); }
.tag-toggle .muted { margin-right: -2px; }
.tag-options { display: flex; flex-direction: column; gap: 2px; max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; }
.tag-option { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.tag-option:hover { background: var(--surface-2); }
.tag-option.child { padding-left: 34px; }
.tag-option small { margin-left: auto; }
.tag-create { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.tag-create .input { flex: 1; min-width: 140px; }
.bulk-bar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 14px; margin-bottom: 12px; border-radius: var(--radius-sm);
    background: var(--mint-soft); color: var(--text);
}
.bulk-bar[hidden] { display: none; }
table.data td.pick, table.data th.pick { width: 32px; padding-right: 0; }
table.data input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--mint-strong); }
.tag-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.compare-bars { display: flex; flex-direction: column; gap: 4px; min-width: 120px; }
.compare-bars span { display: block; height: 8px; border-radius: 0 4px 4px 0; min-width: 2px; }

/* ── 分頁籤（內容群組） ───────────────────────────────────────────────── */
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
    display: flex; flex-direction: column; gap: 2px; min-width: 132px;
    padding: 12px 16px; border-radius: var(--radius); cursor: pointer; text-align: left;
    background: var(--surface); border: 1px solid var(--line);
}
.tab strong { font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tab span { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.tab:hover { border-color: var(--line-strong); }
.tab.on { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.tab.on span { color: var(--on-ink); opacity: .85; }
.tab-desc { margin: -6px 0 14px; color: var(--text-2); font-size: 13px; }

/* ── 表單 ─────────────────────────────────────────────────────────────── */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.input, .select, textarea.input {
    height: 38px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
    background: var(--surface); padding: 0 12px; min-width: 0;
}
textarea.input { height: auto; padding: 10px 12px; }
.input:focus, .select:focus { outline: 2px solid var(--mint-strong); outline-offset: 0; border-color: transparent; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field small { color: var(--text-3); font-size: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
    font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btn.primary { background: var(--orange-strong); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.secondary { background: var(--mint); color: var(--on-mint); }
.btn.ghost { background: var(--surface); border-color: var(--line-strong); color: var(--text); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }

.pager { display: flex; gap: 6px; justify-content: flex-end; align-items: center; margin-top: 14px; font-size: 13px; color: var(--text-3); }

/* ── 圖表 ─────────────────────────────────────────────────────────────── */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart .axis text, .chart text.axis { fill: var(--text-3); font-size: 11px; font-family: var(--font); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--line-strong); stroke-width: 1; }
.chart .crosshair { stroke: var(--line-strong); stroke-width: 1; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.legend i.dot { width: 10px; height: 10px; border-radius: 3px; }
.legend i.dash { background: repeating-linear-gradient(90deg, var(--c-muted) 0 4px, transparent 4px 7px) !important; }

.tooltip {
    position: absolute; z-index: 30; pointer-events: none;
    background: var(--ink); color: var(--on-ink);
    border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px; line-height: 1.5;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2); white-space: nowrap;
    opacity: 0; transition: opacity .08s;
}
.tooltip.show { opacity: 1; }
.tooltip .tt-title { font-weight: 700; margin-bottom: 2px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row i { width: 8px; height: 8px; border-radius: 2px; }
.tooltip .tt-row b { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: grid; grid-template-columns: minmax(80px, 150px) minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.hbar-label { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-label small { display: block; font-weight: 500; color: var(--text-3); font-size: 11.5px; }
.hbar-track { height: 14px; position: relative; }
.hbar-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hbar-val { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; min-width: 56px; }
.hbar-val small { display: block; font-weight: 500; color: var(--text-3); font-size: 11.5px; }

.sharebar { display: flex; height: 14px; border-radius: 4px; overflow: hidden; gap: 2px; margin: 6px 0 10px; }
.sharebar > span { display: block; height: 100%; }

.heatmap { display: grid; grid-template-columns: 44px repeat(24, minmax(0, 1fr)); gap: 2px; font-size: 11px; color: var(--text-3); }
.heatmap .hm-cell { aspect-ratio: 1.3; border-radius: 3px; min-height: 16px; cursor: default; }
.heatmap .hm-cell.best { outline: 2px solid var(--orange); outline-offset: -2px; }
.heatmap .hm-row-label { display: flex; align-items: center; font-weight: 600; color: var(--text-2); }
.heatmap .hm-col-label { text-align: center; }
.hm-legend { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); margin-top: 12px; }
.hm-legend .ramp { width: 160px; height: 8px; border-radius: 4px; }

.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel-step { display: grid; grid-template-columns: 110px minmax(0, 1fr) 90px; gap: 12px; align-items: center; }
.funnel-step .bar { height: 34px; border-radius: 0 6px 6px 0; display: flex; align-items: center; padding-left: 10px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 2px; }
.funnel-step .label { font-weight: 600; font-size: 13px; }
.funnel-step .rate { font-size: 12px; color: var(--text-3); text-align: right; }
.funnel-step .rate b { color: var(--text); font-size: 13px; display: block; }

/* ── 健檢 ─────────────────────────────────────────────────────────────── */
.score-ring { position: relative; width: 132px; height: 132px; flex: none; }
.score-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.score-ring .score-text { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.score-ring strong { font-size: 34px; font-weight: 800; line-height: 1; display: block; }
.score-ring small { color: var(--text-3); font-size: 12px; }
.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.check-list li:last-child { border-bottom: 0; }
.status-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.status-icon svg.icon { width: 16px; height: 16px; stroke-width: 2.6; }
.status-icon.pass { background: var(--status-good); }
.status-icon.warn { background: var(--status-warning); color: #3b2a00; }
.status-icon.fail { background: var(--status-critical); }
.status-icon.unknown { background: var(--surface-3); color: var(--text-3); }
.check-title { font-weight: 700; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.check-detail { color: var(--text-2); font-size: 13.5px; }
.check-advice { margin-top: 6px; font-size: 13px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; color: var(--text-2); }

/* ── 狀態 ─────────────────────────────────────────────────────────────── */
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.empty { text-align: center; padding: 36px 12px; color: var(--text-3); }
.empty svg.icon { width: 34px; height: 34px; margin-bottom: 6px; }
.notice { border-radius: var(--radius); padding: 14px 18px; background: var(--orange-soft); color: var(--text); display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
    background: var(--ink); color: var(--on-ink); padding: 10px 18px; border-radius: 999px;
    font-weight: 600; opacity: 0; transition: all .2s; z-index: 100; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 15, 12, .38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: none; align-items: flex-start; justify-content: center; z-index: 50; padding: 6vh 16px; overflow-y: auto; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--radius); width: min(720px, 100%); padding: 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

.url-preview { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; color: var(--text-2); }
.copy-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.copy-row code { word-break: break-all; font-size: 13px; background: var(--surface-2); padding: 4px 8px; border-radius: 6px; }

/* ── 內容明細 ─────────────────────────────────────────────────────────── */
.content-hero { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 22px; align-items: center; }
.content-hero .thumb { aspect-ratio: 1.6; border-radius: var(--radius-sm); background: var(--surface-3) center/cover no-repeat; }
.content-hero h1 { font-size: 22px; font-weight: 800; }
.meta-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ── 登入頁 ───────────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: var(--ink); color: var(--on-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art h1 { font-size: 34px; font-weight: 800; max-width: 460px; line-height: 1.35; }
.login-art p { color: var(--on-ink); opacity: .75; max-width: 440px; }
.login-blocks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; max-width: 520px; }
.login-blocks div { border-radius: var(--radius); padding: 16px; min-height: 96px; }
.login-blocks .b1 { background: var(--orange); color: #fff; }
.login-blocks .b2 { background: var(--mint); color: var(--on-mint); }
.login-blocks .b3 { background: var(--ink-2); }
.login-blocks strong { display: block; font-size: 22px; }
/* 左側品牌區：背景的斜向長條與標誌同一個語彙。
   用景深表現前後距離：橘、綠兩條在焦點上（清楚）；後方的越遠越小、越淡、越模糊。
   橘色長條後面有一團模糊的橘色光暈，往左上錯開、露出一部分，並延伸到畫面外；各條緩慢漂移，越近的移動越多，產生視差。 */
.login-art > * { position: relative; z-index: 1; }
.login-art > .login-streaks { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.login-streaks i {
    position: absolute; border-radius: 999px; transform: rotate(-45deg);
    animation: streak-drift var(--t, 12s) ease-in-out infinite alternate;
}
.login-streaks .s-far1 { width: 170px; height: 15px; right: 227px; top: 40px; background: #fff; opacity: .12; --dx: 4px; --dy: -3px; --t: 14s; }
.login-streaks .s-far2 { width: 60px; height: 20px; right: 45px; top: 325px; background: #fff; opacity: .1; filter: blur(6px); --dx: 5px; --dy: -4px; --t: 16s; }
.login-streaks .s-mid { width: 340px; height: 28px; right: -120px; top: 150px; background: var(--mint); opacity: .9; filter: blur(.6px); --dx: 8px; --dy: -6px; --t: 11s; }
.login-streaks .s-glow { width: 560px; height: 110px; right: -212px; top: -14px; background: var(--orange); opacity: .5; filter: blur(16px); --dx: 4px; --dy: -3px; --t: 13s; }
.login-streaks .s-main { width: 519px; height: 35px; right: -150px; top: 107px; background: var(--orange); box-shadow: 0 22px 40px rgba(0, 0, 0, .35); --dx: 12px; --dy: -9px; --t: 10s; }
@keyframes streak-drift { to { translate: var(--dx) var(--dy); } }
@media (prefers-reduced-motion: reduce) { .login-streaks i { animation: none; } }
.login-art .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
.login-art .brand-sub { color: var(--on-ink); opacity: .55; }
.login-blocks div { transition: transform .2s; }
.login-blocks div:hover { transform: translateY(-3px); }

/* 右側：浮起的表單卡片 */
.login-form { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 40px 24px; background: var(--bg); }
.login-card {
    width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
    padding: 38px 36px 32px; box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 24px 60px rgba(0, 0, 0, .08);
}
.login-eyebrow { font-size: 11.5px; font-weight: 700; letter-spacing: 2px; color: var(--orange-strong); margin-bottom: 8px; }
.login-card h2 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.login-card .input { height: 46px; }
.login-foot { margin: 0; font-size: 12px; color: var(--text-3); letter-spacing: .5px; display: flex; align-items: center; gap: 10px; }
.login-foot-logo { height: 12px; width: auto; flex: none; color: var(--text-2); }
.login-foot-logo + span { padding-left: 10px; border-left: 1px solid var(--line); line-height: 12px; }
.pwd-wrap { position: relative; }
.pwd-wrap .input { width: 100%; padding-right: 46px; }
.pwd-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; border: 0; background: none; border-radius: 8px; cursor: pointer; color: var(--text-3); display: grid; place-items: center; }
.pwd-toggle:hover { background: var(--surface-3); color: var(--text); }
.pwd-toggle[aria-pressed="true"] { color: var(--orange-strong); }
.pwd-toggle svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.login-card .stack { gap: 16px; margin-top: 26px; }
.login-card .form-error:empty { display: none; }   /* 沒有錯誤時不佔空間，避免欄位與按鈕之間空一大段 */
.login-hero-m { display: none; }
.form-error { color: var(--bad-text); font-weight: 600; min-height: 22px; }

/* ── 響應式 ───────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
    .g-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .g-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 270px; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0, 0, 0, .2); }
    .sidebar.open { transform: none; }
    .icon-btn.menu-btn { display: inline-grid; }
    .topbar { padding: 10px 16px; flex-wrap: wrap; row-gap: 8px; }
    .topbar-spacer { display: none; }
    .site-switch { flex: 1 1 60%; min-width: 0; }
    .site-switch .site-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .user-menu { order: 1; }
    .segmented.period { order: 2; }
    .segmented.icons { order: 3; margin-left: auto; }
    .content { padding: 18px 16px 48px; }
    .hero-tiles, .g-3, .g-2 { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: auto; }
    .form-grid { grid-template-columns: minmax(0, 1fr); }
    .login-page { grid-template-columns: 1fr; }
    .login-art { display: none; }
    /* 手機版登入：上方深色品牌區，登入表單為浮起的白色卡片 */
    .login-form { display: block; padding: 0 0 32px; }
    .login-hero-m {
        display: block; position: relative; overflow: hidden;
        background: var(--ink); color: var(--on-ink);
        padding: calc(28px + env(safe-area-inset-top)) 24px 92px;
    }
    /* 背景裝飾：與標誌同樣的斜向長條 */
    .login-hero-m::before, .login-hero-m::after {
        content: ""; position: absolute; border-radius: 999px; transform: rotate(-45deg); pointer-events: none;
    }
    .login-hero-m::before { width: 150px; height: 16px; right: -58px; top: 12px; background: var(--orange); box-shadow: 14px 30px 0 var(--mint), 28px 60px 0 var(--ink-2); }
    .login-hero-m::after { width: 56px; height: 8px; right: 70px; top: 6px; background: rgba(255, 255, 255, .16); }
    .login-hero-m .brand { position: relative; z-index: 1; }
    .login-hero-m .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
    .login-hero-m .brand-name { color: var(--on-ink); font-size: 20px; }
    .login-hero-m .brand-sub { color: var(--on-ink); opacity: .6; }
    .login-hero-title { position: relative; z-index: 1; margin: 26px 0 14px; font-size: 22px; font-weight: 800; line-height: 1.45; max-width: 260px; }
    .login-hero-tags { position: relative; z-index: 1; display: flex; gap: 8px; }
    .login-hero-tags span { font-size: 12.5px; font-weight: 700; padding: 5px 12px; border-radius: 999px; }
    .login-hero-tags .t1 { background: var(--orange); color: #fff; }
    .login-hero-tags .t2 { background: var(--mint); color: var(--on-mint); }
    .login-hero-tags .t3 { background: var(--ink-2); color: var(--on-ink); border: 1px solid rgba(255, 255, 255, .15); }
    .login-card {
        position: relative; z-index: 2; width: auto; margin: -64px 16px 0;
        background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
        padding: 26px 22px 24px; box-shadow: 0 18px 40px rgba(0, 0, 0, .12);
    }
    .login-card h2 { font-size: 22px; }
    .login-card .stack { margin-top: 20px; }
    .login-eyebrow { margin-bottom: 6px; }
    .login-foot { text-align: center; margin-top: 18px; }
    .content-hero { grid-template-columns: 1fr; }
    .heatmap { grid-template-columns: 34px repeat(24, minmax(0, 1fr)); font-size: 9px; }
}
@media (max-width: 560px) {
    .g-4 { grid-template-columns: minmax(0, 1fr); }
    .hero-values { gap: 20px; }
    .hero-value strong { font-size: 28px; }
    .topbar .segmented.period button { padding: 5px 9px; }
}

/* ── QR Code ─────────────────────────────────────────────────────────── */
.qr-layout { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: start; }
.qr-preview { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr-paper { background: #fff; border-radius: 10px; padding: 8px; box-shadow: inset 0 0 0 1px var(--line); line-height: 0; }   /* 深色模式也維持白底，呈現實際印刷樣貌 */
.qr-paper svg { width: 220px; height: 220px; display: block; }
.qr-preview code { font-size: 12.5px; background: var(--surface-2); padding: 3px 8px; border-radius: 6px; word-break: break-all; text-align: center; }
.qr-options { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.qr-options .segmented { align-self: flex-start; }
.qr-tips { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 12.5px; line-height: 1.7; }
@media (max-width: 640px) {
    .qr-layout { grid-template-columns: 1fr; }
    .qr-paper svg { width: 200px; height: 200px; }
}

/* ── 矩形樹狀圖 ─────────────────────────────────────────────────────── */
.treemap { position: relative; width: 100%; margin-top: 4px; }
.tm-tile { position: absolute; border-radius: 4px; padding: 6px 8px; overflow: hidden; display: flex; flex-direction: column; gap: 1px; cursor: default; box-sizing: border-box; }
.tm-tile.on-dark { color: #fff; }
.tm-tile.on-light { color: #14201c; }
.tm-tile b { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-tile span { font-size: 12px; font-variant-numeric: tabular-nums; opacity: .85; white-space: nowrap; }
.tm-tile:hover { box-shadow: inset 0 0 0 2px var(--text); }

/* ── 期間月曆 ───────────────────────────────────────────────────────── */
.segmented .range-btn svg.icon { width: 15px; height: 15px; }
.segmented .range-btn span { white-space: nowrap; }
.rp {
    position: fixed; z-index: 70; display: flex; outline: none;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .18); overflow: hidden; max-width: calc(100vw - 16px);
}
.rp-presets { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; border-right: 1px solid var(--line); min-width: 112px; }
.rp-presets button {
    border: 0; background: none; text-align: left; padding: 8px 12px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.rp-presets button:hover { background: var(--surface-3); color: var(--text); }
.rp-presets button.on { background: var(--mint-soft); color: var(--text); }
.rp-main { display: flex; flex-direction: column; min-width: 0; }
.rp-cals { display: flex; }
.rp-month { padding: 14px 18px 8px; width: 300px; }
.rp-month + .rp-month { border-left: 1px solid var(--line); }
.rp-head { display: grid; grid-template-columns: 56px 1fr 56px; align-items: center; margin-bottom: 8px; }
.rp-head strong { text-align: center; font-size: 14.5px; }
.rp-nav { display: flex; gap: 2px; }
.rp-nav:last-child { justify-content: flex-end; }
.rp-nav button {
    width: 26px; height: 26px; border: 0; background: none; border-radius: 6px; cursor: pointer;
    color: var(--text-2); font-size: 16px; line-height: 1;
}
.rp-nav button:hover { background: var(--surface-3); color: var(--text); }
.rp-nav .rp-mobile { display: none; }
.rp-grid { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 4px; }
.rp-wd { text-align: center; font-size: 12px; color: var(--text-3); padding: 4px 0 8px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.rp-day {
    height: 34px; border: 0; background: none; padding: 0; font: inherit; font-size: 13px; color: var(--text);
    display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; cursor: pointer;
}
.rp-day span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.rp-day:not(:disabled):hover span { background: var(--surface-3); }
.rp-day.out { color: var(--text-3); opacity: .55; cursor: default; }
.rp-day:disabled { color: var(--text-3); opacity: .4; cursor: not-allowed; }
.rp-day.nodata { color: var(--text-3); }
.rp-day.today span { box-shadow: inset 0 0 0 1px var(--line-strong); }
/* 區間底色：同一列頭尾圓角，起迄日為實心圓 */
.rp-day.in { background: var(--mint-soft); }
.rp-day.in.row-start, .rp-day.in.start { border-top-left-radius: 17px; border-bottom-left-radius: 17px; }
.rp-day.in.row-end, .rp-day.in.end { border-top-right-radius: 17px; border-bottom-right-radius: 17px; }
.rp-day.start span, .rp-day.end span, .rp-day.start:hover span, .rp-day.end:hover span { background: var(--mint-strong); color: var(--surface); font-weight: 700; }
.rp-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 18px; border-top: 1px solid var(--line); }
.rp-summary strong { display: block; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.rp-summary small { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.rp-summary .rp-error { color: var(--bad-text); }
.rp-actions { display: flex; gap: 8px; flex: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
@media (max-width: 760px) {
    .rp { flex-direction: column; left: 8px !important; right: 8px; }
    .rp-presets { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
    .rp-presets button { padding: 6px 10px; font-size: 12.5px; }
    .rp-month { width: auto; flex: 1; padding: 12px 12px 6px; }
    .rp-month + .rp-month { display: none; }
    .rp-nav .rp-mobile { display: inline-block; }
    .rp-foot { flex-direction: column; align-items: stretch; padding: 10px 12px; }
    .rp-actions { justify-content: flex-end; }
}
@media (max-width: 560px) {
    .segmented .range-btn:not(.on) span { display: none; }
}

/* ── 受眾建議 ───────────────────────────────────────────────────────── */
.ready-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.ready-item { display: flex; gap: 12px; align-items: flex-start; }
.ready-item .status-icon { flex: none; }
.ready-title { font-weight: 700; font-size: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ready-detail { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { font-size: 19px; }
.section-head p { margin: 0; font-size: 13px; }
.audience-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.aud-why { margin: 0 0 8px; font-size: 14px; line-height: 1.7; }
.aud-use { margin: 0 0 14px; font-size: 13px; color: var(--text-2); }
.aud-setup { border-top: 1px solid var(--line); padding-top: 14px; }
.aud-setup-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.aud-tabs { height: 28px; padding: 2px; }
.aud-tabs button { height: 22px; padding: 0 10px; font-size: 12px; }
ol.steps { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.75; }
ol.steps li { padding-left: 2px; word-break: break-word; }
.aud-note { display: flex; gap: 8px; align-items: flex-start; margin: 10px 0 0; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.aud-note svg.icon { width: 15px; height: 15px; margin-top: 2px; }
.notice.warn { background: color-mix(in srgb, var(--status-warning) 18%, var(--surface)); font-size: 13px; padding: 10px 14px; margin-bottom: 14px; }
.notice.warn svg.icon { width: 16px; height: 16px; margin-top: 2px; }
.mb { margin-bottom: 18px; }
.schedule-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.schedule-tile { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px 16px; }
.schedule-window { white-space: nowrap; font-size: clamp(18px, 2vw, 24px); font-weight: 700; margin: 4px 0 6px; font-variant-numeric: tabular-nums; }
/* GA 健檢：Ad Grants、追蹤碼 */
.status-icon.manual { background: var(--surface-3); color: var(--text-2); }
.tracking-list { list-style: none; margin: 0; padding: 0; }
.tracking-list li { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.tracking-list li:last-child { border-bottom: 0; }
.tracking-list li > span:first-child { color: var(--text-2); font-weight: 600; }
@media (max-width: 1180px) { .ready-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .audience-cards { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px) { .ready-grid, .schedule-tiles { grid-template-columns: minmax(0, 1fr); } .tracking-list li { grid-template-columns: 1fr; gap: 2px; } }

/* ── 第四階段：廣告成效、週報、跨站比較 ───────────────────────────── */
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: 0; }
.ads-empty { max-width: 620px; margin: 0 auto; padding: 0 8px 8px; font-size: 14px; }
.ads-empty ol.steps { margin: 10px 0 14px; }
.th-sort { border: 0; background: none; font: inherit; color: inherit; cursor: pointer; padding: 0; font-weight: inherit; }
.th-sort.on { color: var(--text); text-decoration: underline; text-underline-offset: 4px; }
table.data tr.mine td { background: var(--orange-soft); }
.weekly-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; align-items: start; }
.weekly-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 720px; overflow-y: auto; }
.weekly-list button { width: 100%; text-align: left; border: 0; background: none; border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; color: var(--text); font: inherit; }
.weekly-list button:hover { background: var(--surface-3); }
.weekly-list button.on { background: var(--mint-soft); }
.weekly-list strong { display: block; font-size: 14px; font-variant-numeric: tabular-nums; }
.weekly-list small { display: block; font-size: 12px; color: var(--text-3); margin-top: 2px; }
.weekly-list small.err { color: var(--bad-text); }
.weekly-frame { width: 100%; min-height: 600px; border: 0; border-radius: var(--radius-sm); background: #f3f4f1; display: block; }
.sub-list { display: flex; flex-direction: column; }
.sub-item { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.sub-item:last-child { border-bottom: 0; }
.sub-item strong { display: block; font-size: 14px; }
.sub-item small { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.switch { appearance: none; -webkit-appearance: none; width: 42px; height: 24px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .15s; }
.switch:checked { background: var(--mint-strong); border-color: var(--mint-strong); }
.switch:checked::after { transform: translateX(18px); }
.switch:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }
@media (max-width: 900px) { .weekly-layout { grid-template-columns: minmax(0, 1fr); } .weekly-list { max-height: 260px; } }
.nav a[hidden] { display: none; }

/* ── 檢視模式：簡易版 / 進階版 ─────────────────────────────────────── */
.segmented.mode button.on { background: var(--orange-strong); }
.nav-more {
    margin: 10px 4px 0; padding: 10px 12px; border-radius: var(--radius-sm);
    border: 1px dashed var(--line-strong); background: none; cursor: pointer;
    display: flex; align-items: center; gap: 10px; text-align: left;
    color: var(--text-2); font: inherit; font-size: 12.5px; line-height: 1.5;
}
.nav-more strong { display: block; color: var(--orange-strong); }
.nav-more:hover { background: var(--surface-3); color: var(--text); }
.nav-more[hidden] { display: none; }
.mode-badge { vertical-align: middle; font-size: 12.5px; padding: 2px 10px; margin-left: 4px; }

/* 簡易版總覽 */
.simple-summary { border-left: 4px solid var(--orange); }
.simple-summary p { margin: 0; font-size: 17px; line-height: 1.75; font-weight: 600; }

.simple-steps { display: grid; grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1fr) 28px minmax(0, 1fr); align-items: stretch; }
.simple-steps > .skeleton { margin: 0 14px; }
.hero.step { min-height: 170px; justify-content: flex-start; gap: 10px; }
.step-title { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; }
.step-no {
    width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; flex: none;
    font-size: 14px; font-weight: 800; background: rgba(255, 255, 255, .25);
}
.hero.mint .step-no { background: color-mix(in srgb, var(--on-mint) 14%, transparent); }
.step-value strong { display: block; font-size: clamp(30px, 3vw, 42px); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.step-value span { font-size: 14px; opacity: .9; }
.step-arrow { display: grid; place-items: center; color: var(--text-3); }
.step-arrow svg.icon { width: 22px; height: 22px; stroke-width: 2.4; }
.plain-delta {
    align-self: flex-start; margin-top: auto; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
    background: var(--surface-3); color: var(--text-2);
}
.plain-delta.up { color: var(--good-text); }
.plain-delta.down { color: var(--bad-text); }
.hero .plain-delta { background: rgba(255, 255, 255, .22); color: inherit; }
.hero.mint .plain-delta { background: color-mix(in srgb, var(--on-mint) 12%, transparent); }

.simple-card { padding: 22px 24px 24px; }
.simple-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 20px; }
.simple-head h2 { font-size: 20px; font-weight: 800; }
.simple-head p { margin: 2px 0 0; font-size: 13.5px; color: var(--text-3); }
.step-dot { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; flex: none; font-weight: 800; }
.step-dot.orange { background: var(--orange); color: var(--on-orange); }
.step-dot.mint { background: var(--mint); color: var(--on-mint); }
.step-dot.ink { background: var(--ink); color: var(--on-ink); }
.simple-sub { font-size: 14.5px; font-weight: 700; margin: 0 0 12px; color: var(--text-2); }

.visit-grid, .result-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 28px; align-items: start; }
.big-facts { display: grid; gap: 14px; }
.big-fact { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.bf-label { font-size: 14px; font-weight: 700; color: var(--text-2); }
.big-fact strong { font-size: 34px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.big-fact strong small { font-size: 15px; font-weight: 600; margin-left: 4px; color: var(--text-2); }
.bf-note { font-size: 12.5px; color: var(--text-3); margin-bottom: 4px; }
.big-fact .plain-delta { margin-top: 2px; }

.src-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.src-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.src-top b { font-size: 15px; }
.src-top span { font-weight: 800; font-size: 15px; font-variant-numeric: tabular-nums; }
.src-bar { height: 10px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.src-bar i { display: block; height: 100%; border-radius: 999px; background: var(--orange); min-width: 4px; }
.src-list small { display: block; margin-top: 4px; font-size: 12.5px; color: var(--text-3); }
.src-list.goals .src-bar i { background: var(--slate); }

.stay-split { display: flex; gap: 2px; height: 22px; }   /* 2px 間隔讓兩段分得開 */
.stay-split i { display: block; height: 100%; }
.stay-split i:first-child { border-radius: 6px 0 0 6px; }
.stay-split i:last-child { border-radius: 0 6px 6px 0; }
.stay-split .on, .stay-legend .on { background: var(--mint-strong); }
.stay-split .off, .stay-legend .off { background: var(--c-muted); }
.stay-legend { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 10px; font-size: 14px; color: var(--text-2); }
.stay-legend span { display: inline-flex; align-items: center; gap: 6px; }
.stay-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.stay-legend b { color: var(--text); }
.stay-say { font-size: 16px; margin: 16px 0 22px; }
.stay-say b { font-size: 20px; color: var(--mint-strong); }
.criteria { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.criteria > div { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius); background: var(--mint-soft); }
.criteria svg.icon { width: 22px; height: 22px; color: var(--mint-strong); margin-bottom: 6px; }
.criteria b { font-size: 15px; }
.criteria span { font-size: 12.5px; color: var(--text-2); }
.stay-facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 14px; color: var(--text-2); }
.stay-facts b { font-size: 18px; color: var(--text); margin: 0 2px; }
.simple-card .notice { margin-bottom: 0; }
.simple-foot { margin: 22px 0 0; font-size: 13px; text-align: center; }

@media (max-width: 1180px) {
    .visit-grid, .result-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .segmented.mode { order: 2; }
    .segmented.period { order: 3; }
    .segmented.icons { order: 4; }
    .simple-steps { grid-template-columns: minmax(0, 1fr); }
    .simple-steps > .skeleton { margin: 0 0 12px; }
    .hero.step { min-height: 0; }
    .step-arrow { height: 24px; }
    .step-arrow svg.icon { transform: rotate(90deg); }
    .criteria { grid-template-columns: minmax(0, 1fr); }
    .simple-summary p { font-size: 15.5px; }
}
.mode-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.mode-option { display: flex; gap: 10px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.mode-option:hover { border-color: var(--line-strong); }
.mode-option:has(input:checked) { border-color: var(--orange); background: var(--orange-soft); }
.mode-option input { margin-top: 4px; accent-color: var(--orange-strong); }
.mode-option b { display: block; font-size: 15px; }
.mode-option small { display: block; color: var(--text-2); font-size: 12.5px; line-height: 1.6; margin-top: 2px; }
@media (max-width: 900px) { .mode-options { grid-template-columns: minmax(0, 1fr); } }

/* ── 側欄收合：只留圖示（桌機） ─────────────────────────────────────── */
.sidebar-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.sidebar-top .brand { min-width: 0; padding-right: 0; }
.sidebar-top .brand-sub { white-space: nowrap; letter-spacing: 1px; }   /* 旁邊多了收合鈕，英文副標維持一行 */
.sidebar-toggle {
    width: 32px; height: 32px; border-radius: 8px; flex: none; border: 0; background: none; cursor: pointer;
    display: grid; place-items: center; color: var(--text-3);
}
.sidebar-toggle:hover { background: var(--surface-3); color: var(--text); }
.sidebar-toggle svg.icon { width: 18px; height: 18px; }
@media (min-width: 901px) {
    .app { transition: grid-template-columns .2s ease; }
    html[data-sidebar="collapsed"] { --sidebar-w: 76px; }
    html[data-sidebar="collapsed"] .sidebar { padding: 22px 12px; overflow-x: hidden; }
    html[data-sidebar="collapsed"] .sidebar-top { flex-direction: column; gap: 14px; }
    html[data-sidebar="collapsed"] .brand { padding: 0; }
    html[data-sidebar="collapsed"] .brand-text,
    html[data-sidebar="collapsed"] .nav a span,
    html[data-sidebar="collapsed"] .nav-more span,
    html[data-sidebar="collapsed"] .side-panel { display: none; }
    html[data-sidebar="collapsed"] .nav a,
    html[data-sidebar="collapsed"] .nav-more { justify-content: center; padding: 10px 0; }
    html[data-sidebar="collapsed"] .nav-more { margin: 10px 0 0; }
    /* 分組標題改成細分隔線；收合時各組一律展開，所有圖示都看得到 */
    html[data-sidebar="collapsed"] .nav-label { font-size: 0; height: 1px; padding: 0; margin: 10px 6px; background: var(--line); pointer-events: none; }
    html[data-sidebar="collapsed"] .nav-group:first-child .nav-label { display: none; }
    html[data-sidebar="collapsed"] .nav-caret { display: none; }
    html[data-sidebar="collapsed"] .nav-group.closed .nav-items { grid-template-rows: 1fr; }
    html[data-sidebar="collapsed"] .nav-group.closed .nav-items > div { visibility: visible; }
}
/* 收合選單的名稱提示（portal.js navTip）：顯示在圖示右側 */
.nav-tip {
    position: fixed; z-index: 60; pointer-events: none; transform: translate(-4px, -50%);
    background: var(--ink); color: var(--on-ink); border-radius: var(--radius-sm);
    padding: 6px 10px; font-size: 13px; font-weight: 600; line-height: 1.4; white-space: nowrap;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .2); opacity: 0; transition: opacity .12s, transform .12s;
}
.nav-tip::before {   /* 指向圖示的小三角 */
    content: ""; position: absolute; left: -4px; top: 50%; width: 8px; height: 8px;
    background: inherit; transform: translateY(-50%) rotate(45deg); border-radius: 1px;
}
.nav-tip.show { opacity: 1; transform: translate(0, -50%); }
@media print { .nav-tip { display: none !important; } }
@media (max-width: 900px) {
    .sidebar-toggle { display: none; }   /* 手機版選單本來就是滑出式 */
}

/* 內容成效（簡易版） */
.top-list { list-style: none; margin: 0; padding: 0; }
.top-list li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.top-list li:last-child { border-bottom: 0; }
.top-list li:first-child .rank-no { background: var(--orange); color: var(--on-orange); }
.top-main { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.top-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-title .rank-title { min-width: 0; font-size: 15px; }
.top-title .plain-delta { margin: 0; flex: none; font-size: 12px; padding: 1px 8px; }
.top-main .src-bar { height: 6px; }
.top-main small { font-size: 12px; }
.top-val { text-align: right; white-space: nowrap; color: var(--text-2); font-size: 13px; }
.top-val b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { display: flex; flex-direction: column; gap: 3px; padding: 11px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.plain-list li:last-child { border-bottom: 0; }
.plain-list .rank-title { display: block; }
.plain-list span { font-size: 13px; color: var(--text-2); }
.plain-list b { color: var(--text); }
.todo-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.todo-list li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--line); }
.todo-list svg.icon { width: 34px; height: 34px; padding: 8px; border-radius: 50%; background: var(--orange-soft); color: var(--orange-strong); stroke-width: 2.2; }
.todo-list p { margin: 0; font-size: 14px; line-height: 1.7; }
@media (max-width: 640px) {
    /* 標題完整顯示（可換行），比較標籤移到下一行 */
    .top-list li { gap: 10px; }
    .top-title { flex-wrap: wrap; gap: 4px 8px; }
    .top-title .rank-title { white-space: normal; flex-basis: 100%; }
    .todo-list li { grid-template-columns: 34px minmax(0, 1fr); }
    .todo-list .chip-btn { grid-column: 2; justify-self: start; }
}

/* ── 較寬的視窗（說明文件等）─────────────────────────────────────── */
.modal.wide { width: min(1000px, 100%); }

/* UTM 操作說明 */
.uh-tabs { margin-bottom: 14px; gap: 6px; }
.uh-tabs .tab { min-width: 0; padding: 7px 14px; border-radius: 999px; }
.uh-tabs .tab span { font-size: 13.5px; }
.utm-help { font-size: 14.5px; line-height: 1.75; min-height: 360px; }
.utm-help p { margin: 0 0 12px; }
.utm-help h3 { font-size: 15.5px; font-weight: 700; margin: 18px 0 10px; }
.utm-help code { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: .92em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.utm-help table.data td { vertical-align: top; }
.uh-url { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 13px; line-height: 2; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; word-break: break-all; color: var(--text-3); }
.uh-url span { font-weight: 700; border-radius: 4px; padding: 1px 4px; }
.uh-url .s, .uh-field.s .uh-fname code { color: var(--c3); }
.uh-url .m, .uh-field.m .uh-fname code { color: var(--c2); }
.uh-url .c, .uh-field.c .uh-fname code { color: var(--c1); }
.uh-field.t .uh-fname code { color: var(--c5); }
.uh-field.k .uh-fname code { color: var(--c4); }
.uh-url .s { background: color-mix(in srgb, var(--c3) 12%, transparent); }
.uh-url .m { background: color-mix(in srgb, var(--c2) 12%, transparent); }
.uh-url .c { background: color-mix(in srgb, var(--c1) 12%, transparent); }
.uh-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; font-size: 13px; color: var(--text-2); }
.uh-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.uh-legend i.s { background: var(--c3); } .uh-legend i.m { background: var(--c2); } .uh-legend i.c { background: var(--c1); }
.uh-callout { border-radius: 10px; padding: 12px 16px; margin: 14px 0 0; font-size: 14px; }
.uh-callout b { display: block; margin-bottom: 2px; }
.uh-callout.warn { background: var(--orange-soft); }
.uh-callout.info { background: var(--mint-soft); }
.uh-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.uh-grid > div { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); }
.uh-grid b { display: block; }
.uh-grid span { font-size: 13px; color: var(--text-2); }
.uh-field { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 16px; border: 1px solid var(--line); border-left: 4px solid var(--c1); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; }
.uh-field.s { border-left-color: var(--c3); } .uh-field.m { border-left-color: var(--c2); } .uh-field.t { border-left-color: var(--c5); } .uh-field.k { border-left-color: var(--c4); }
.uh-fname b { display: block; font-size: 15.5px; }
.uh-fname code { display: inline-block; font-weight: 700; margin: 2px 6px 4px 0; }
.uh-q { font-weight: 700; }
.uh-how { color: var(--text-2); font-size: 13.5px; margin-bottom: 6px; }
.uh-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.uh-same { color: var(--c1); font-weight: 700; }
.uh-list, .uh-check { margin: 0 0 12px; padding: 0; list-style: none; display: grid; gap: 6px; }
.uh-list li::before { content: "・"; color: var(--orange-strong); font-weight: 900; }
.uh-steps { margin: 0 0 12px; padding: 0; list-style: none; counter-reset: uh-step; display: grid; gap: 8px; }
.uh-steps li { counter-increment: uh-step; display: flex; gap: 10px; align-items: flex-start; }
.uh-steps li::before { content: counter(uh-step); width: 22px; height: 22px; border-radius: 50%; background: var(--mint-soft); color: var(--mint-strong); display: grid; place-items: center; font-size: 12px; font-weight: 800; flex: none; margin-top: 1px; }
.uh-check li { display: flex; gap: 10px; align-items: flex-start; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; }
.uh-check li::before { content: "✓"; width: 20px; height: 20px; border-radius: 6px; background: var(--mint); color: var(--on-mint); display: grid; place-items: center; font-size: 12px; font-weight: 900; flex: none; margin-top: 2px; }
.uh-mistake { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 10px; font-size: 13.5px; }
.uh-mtitle { grid-column: 1 / -1; padding: 10px 14px; font-weight: 700; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: center; }
.uh-mistake .bad, .uh-mistake .good { padding: 10px 14px; display: flex; gap: 8px; }
.uh-mistake .bad { background: color-mix(in srgb, var(--status-critical) 9%, var(--surface)); }
.uh-mistake .good { background: color-mix(in srgb, var(--status-good) 9%, var(--surface)); }
.uh-mistake .bad b { color: var(--bad-text); } .uh-mistake .good b { color: var(--good-text); }
@media (max-width: 760px) {
    .uh-grid, .uh-field, .uh-mistake { grid-template-columns: minmax(0, 1fr); }
    .uh-field { gap: 4px; }
}
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.notice.info-notice { background: var(--mint-soft); font-size: 13.5px; padding: 10px 14px; margin-bottom: 14px; }
.notice.info-notice svg.icon { width: 16px; height: 16px; margin-top: 3px; flex: none; }
/* 短網址列表：網址後的「複製」「QR Code」圖示維持同一行 */
.copy-row.link-actions { flex-wrap: nowrap; gap: 4px; }
.copy-row.link-actions code { white-space: nowrap; }
.copy-row.link-actions .icon-btn { flex: none; }

/* 短網址 A/B 分流：表單的版本設定、分析頁的版本比較 */
.badge svg.icon { width: 13px; height: 13px; }
.split-toggle { padding: 4px 0 8px; border-bottom: 0; }
.split-box { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.split-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) 84px 34px; gap: 8px; align-items: center; }
.split-key { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--mint-soft); color: var(--mint-strong); }
.split-same { font-size: 13px; color: var(--text-2); padding: 0 4px; }
.split-weight { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-2); }
.split-weight .input { width: 64px; text-align: right; padding-left: 6px; padding-right: 6px; }
.split-row .icon-btn { width: 32px; height: 32px; }
.split-rows { display: grid; gap: 8px; }
.split-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.split-add { display: inline-flex; align-items: center; gap: 10px; }
.split-bad { color: var(--orange-strong); font-weight: 600; }
.split-preview + .split-preview { margin-top: 6px; }
.split-preview b { font-family: inherit; color: var(--text); margin-right: 6px; }
.split-targets { display: grid; gap: 6px; }
.split-target { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: start; }
.split-target .badge { margin-top: 8px; }
@media (max-width: 640px) {
    /* 窄螢幕：網址佔一整行，比例與移除按鈕放到下一行 */
    .split-row { grid-template-columns: 26px minmax(0, 1fr) auto 34px; row-gap: 6px; }
    .split-row > .input, .split-row > .split-same { grid-column: 2 / -1; }
    .split-row > .split-weight { grid-column: 3; }
    .split-row > .icon-btn, .split-row > span:last-child { grid-column: 4; }
}

/* 活動結案報告（也可列印或存成 PDF） */
.head-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.report-cover { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-top: 4px solid var(--orange); }
.report-cover-main { min-width: 0; }
.report-cover .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 2px; color: var(--orange-strong); }
.report-cover h1 { font-size: 28px; font-weight: 800; margin: 4px 0 14px; overflow-wrap: anywhere; }
.report-meta { display: grid; gap: 6px; margin: 0; font-size: 14px; }
.report-meta > div { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 10px; }
.report-meta dt { color: var(--text-3); }
.report-meta dd { margin: 0; overflow-wrap: anywhere; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.report-section { font-size: 19px; font-weight: 800; margin: 30px 0 12px; padding-left: 12px; border-left: 4px solid var(--mint-strong); }
.report-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.report-stats > div { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; min-width: 0; }
.report-stats span { display: block; font-size: 12.5px; color: var(--text-3); }
.report-stats strong { display: block; font-size: 20px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.report-note { font-size: 12.5px; color: var(--text-3); margin: 20px 0 0; line-height: 1.7; }
@media (max-width: 1180px) { .report-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 640px) {
    .report-cover { flex-direction: column; }
    .report-actions { justify-content: flex-start; }
    .report-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@page { size: A4; margin: 12mm; }
@media print {
    /* 只印內容：隱藏選單、上方工具列與操作按鈕 */
    .sidebar, .topbar, .no-print, [data-view-toggle], .toast, .tooltip { display: none !important; }
    .app { display: block; }
    body { background: #fff; }
    .content { padding: 0; }
    .card { box-shadow: none; break-inside: avoid; }
    .report-section { break-after: avoid; }
    .grid.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .grid.g-main { grid-template-columns: minmax(0, 1fr); }
    .report-stats { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    a.link { text-decoration: none; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
