/* 團隊數據儀表板 — 色票（淺色為主，深色跟隨系統） */
:root {
  color-scheme: light;
  --page: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #f9f9f7;
  --surface-3: #f0efec;
  --border: #e4e3de;
  --border-strong: #d3d2cc;
  --ink: #111110;
  --ink-2: #52514e;
  --muted: #84827c;
  --grid: #ecebe6;
  --axis: #c3c2b7;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: #eaf2fc;
  --up: #006300;
  --down: #c22f2f;
  --good: #0ca30c;
  --warning: #c98500;
  --warning-wash: #fdf5e3;
  --critical: #d03b3b;
  --critical-wash: #fcecec;
  --good-wash: #e8f5e8;
  --shadow: 0 1px 2px rgba(17, 17, 16, .04);
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6; --series-8: #e34948;
  /* 平台色標 */
  --p-line: #008300; --p-fb: #2a78d6; --p-ig: #e87ba4; --p-th: #52514e; --p-yt: #e34948; --p-oc: #1baf7a; --p-cv: #eda100; --p-site: #6250d6;
  --radius: 8px;
  --font: "Inter", "Noto Sans TC", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface: #1a1a19; --surface-2: #20201f; --surface-3: #2a2a28;
    --border: #2e2e2c; --border-strong: #3d3d3a;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8f8d86; --grid: #2a2a28; --axis: #3d3d3a;
    --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: #16263a;
    --up: #2fbf4a; --down: #f07272;
    --warning: #fab219; --warning-wash: #2c2412; --critical: #e66767; --critical-wash: #2e1717; --good-wash: #132613;
    --shadow: none;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --p-line: #2a9d2a; --p-fb: #3987e5; --p-ig: #d55181; --p-th: #c3c2b7; --p-yt: #e66767; --p-oc: #199e70; --p-cv: #c98500; --p-site: #9085e9;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface: #1a1a19; --surface-2: #20201f; --surface-3: #2a2a28;
  --border: #2e2e2c; --border-strong: #3d3d3a;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8f8d86; --grid: #2a2a28; --axis: #3d3d3a;
  --accent: #3987e5; --accent-ink: #86b6ef; --accent-wash: #16263a;
  --up: #2fbf4a; --down: #f07272;
  --warning: #fab219; --warning-wash: #2c2412; --critical: #e66767; --critical-wash: #2e1717; --good-wash: #132613;
  --shadow: none;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --p-line: #2a9d2a; --p-fb: #3987e5; --p-ig: #d55181; --p-th: #c3c2b7; --p-yt: #e66767; --p-oc: #199e70; --p-cv: #c98500; --p-site: #9085e9;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: 0; }
.num, td.n, th.n, .tabnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.hidden { display: none !important; }
svg.ic { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 啟動畫面 ---------- */
.boot { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; color: var(--muted); }
.boot-mark { width: 32px; height: 32px; border-radius: 8px; border: 3px solid var(--border); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 登入 ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 32px 28px; box-shadow: var(--shadow); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-weight: 700; font-size: 15px; }
.login h1 { font-size: 20px; margin: 24px 0 4px; }
.login p.sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px; padding: 8px 10px; min-height: 36px; max-width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, tr:focus-visible, .mcard:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink); cursor: pointer; font-weight: 500; white-space: nowrap; text-decoration: none !important; }
.btn:hover { background: var(--surface-2); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.pri:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.sm { min-height: 28px; padding: 0 10px; font-size: 13px; }
.btn.danger { color: var(--critical); }
.btn[disabled] { opacity: .6; cursor: default; }
.btn.block { width: 100%; }
.form-msg { min-height: 20px; font-size: 13px; margin-top: 8px; }
.form-msg.err { color: var(--critical); }
.form-msg.ok { color: var(--up); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .8s linear infinite; }

/* ---------- 外框 ---------- */
.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--surface) 223px, var(--border) 223px, var(--border) 224px, transparent 224px); }
.side { position: sticky; top: 0; height: 100vh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 16px 12px; overflow-y: auto; }
.side .brand { padding: 4px 8px 20px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; color: var(--ink-2); font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--surface-3); color: var(--ink); }
.nav a.on { background: var(--accent-wash); color: var(--accent-ink); }
.nav .sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 26px; padding-left: 8px; border-left: 1px solid var(--border); }
.nav .sub a { padding: 4px 10px; font-size: 13px; font-weight: 400; }
.nav-sep { height: 1px; background: var(--border); margin: 10px 8px; }
.side-foot { margin-top: auto; padding: 12px 8px 0; font-size: 12px; color: var(--muted); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 12px; padding: 0 32px; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 13px; }
.crumbs a { color: var(--muted); }
.crumbs b { color: var(--ink); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--surface-3); color: var(--ink-2); display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; }
.topbar .mbrand { display: none; }
.content { width: 100%; max-width: 1280px; margin: 0 auto; padding: 24px 32px 64px; }
.tabbar { display: none; }

/* ---------- 頁首 ---------- */
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.ph h1 { font-size: 22px; line-height: 1.3; }
.ph .lead { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.ph .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.sec { margin-top: 32px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-h h2 { font-size: 16px; }
.sec-h .hint { font-size: 12px; color: var(--muted); }

/* ---------- 卡片 ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-h h3 { font-size: 14px; }
.card-h .sub { font-size: 12px; color: var(--muted); font-weight: 400; }

/* KPI 數字卡 */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 16px 12px; display: flex; flex-direction: column; min-width: 0; }
.kpi .lbl { font-size: 13px; color: var(--ink-2); font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 26px; font-weight: 600; line-height: 1.2; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi .dl { margin-top: 4px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; color: var(--muted); min-height: 18px; }
.kpi .spark { margin-top: 12px; height: 36px; }
.kpi .spark svg { width: 100%; height: 36px; display: block; overflow: visible; }
.kpi .foot { font-size: 11px; color: var(--muted); margin-top: 4px; }
.kpi .split { display: flex; gap: 16px; margin-top: 8px; }
.kpi .split > div { min-width: 0; }
.kpi .split .val { margin-top: 0; font-size: 22px; }
.kpi .split .mini { font-size: 12px; color: var(--muted); }

/* 增減標示 */
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--muted); }
.delta svg { width: 10px; height: 10px; fill: currentColor; stroke: none; }
.nodata { font-size: 12px; color: var(--muted); }

/* 平台徽章 */
.pb { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 7px 0 6px; border-radius: 4px; font-size: 11px; font-weight: 600; color: var(--ink-2); background: var(--surface-3); white-space: nowrap; line-height: 1; flex: none; }
.pb::before { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--pc, var(--muted)); }
.pb.line_oa { --pc: var(--p-line); } .pb.facebook { --pc: var(--p-fb); } .pb.instagram { --pc: var(--p-ig); }
.pb.threads { --pc: var(--p-th); } .pb.youtube { --pc: var(--p-yt); } .pb.line_openchat { --pc: var(--p-oc); } .pb.conversion { --pc: var(--p-cv); } .pb.maddy { --pc: var(--p-site); } .pb.linktree { --pc: #8a9a00; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.achip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border: 1px solid var(--border); background: var(--surface); border-radius: 6px; font-size: 13px; color: var(--ink); max-width: 100%; }
.achip span.t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.achip:hover { border-color: var(--border-strong); text-decoration: none; background: var(--surface-2); }

/* 需要注意 */
.alerts { display: flex; flex-direction: column; }
.alert { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-top: 1px solid var(--border); color: var(--ink); text-decoration: none !important; }
.alert:first-child { border-top: 0; }
.alert:hover { background: var(--surface-2); }
.alert .sev { flex: none; display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px 2px 6px; border-radius: 4px; min-width: 52px; }
.alert .sev svg { width: 14px; height: 14px; }
.sev.critical { color: var(--critical); background: var(--critical-wash); }
.sev.warning { color: var(--warning); background: var(--warning-wash); }
.sev.good { color: var(--up); background: var(--good-wash); }
.alert .msg { flex: 1; min-width: 0; }
.alert .msg b { font-weight: 600; }
.alert .go { color: var(--muted); flex: none; }
.allgood { display: flex; align-items: center; gap: 12px; padding: 16px; }
.allgood .t { font-weight: 600; }
.allgood .d { font-size: 13px; color: var(--muted); }

/* 成員卡 */
.members { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.mcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; color: var(--ink); text-decoration: none !important; display: flex; flex-direction: column; gap: 12px; min-width: 0; transition: border-color .12s; }
.mcard:hover { border-color: var(--border-strong); }
.mcard .who { display: flex; align-items: center; gap: 10px; }
.mcard .who .nm { font-weight: 600; font-size: 15px; }
.mcard .who .rl { font-size: 12px; color: var(--muted); }
.mcard .plats { display: flex; gap: 4px; flex-wrap: wrap; }
.mstats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
.mstats .l { font-size: 11px; color: var(--muted); }
.mstats .v { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mstats .delta { font-size: 11px; }
.best { font-size: 12px; background: var(--surface-2); border-radius: 6px; padding: 8px 10px; min-height: 52px; }
.best .l { color: var(--muted); font-size: 11px; margin-bottom: 2px; }
.best .t { color: var(--ink); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.best .v { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* 表格 */
.tw { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--ink); }
table.t th.on { color: var(--ink); }
table.t th .arr { display: inline-block; width: 10px; font-size: 9px; }
table.t td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t tbody tr.click { cursor: pointer; }
table.t tbody tr.click:hover td { background: var(--surface-2); }
table.t td.n, table.t th.n { text-align: right; white-space: nowrap; }
table.t td .sd { display: block; font-size: 11px; line-height: 1.2; }
.cell-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cell-name .nm { font-weight: 500; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
.cell-txt { max-width: 420px; }
.cell-txt a { color: var(--ink); }
.cell-txt a:hover { color: var(--accent-ink); }
td.sp svg { display: block; width: 96px; height: 24px; overflow: visible; }
.ibar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.ibar .b { width: 56px; height: 6px; border-radius: 0 3px 3px 0; background: var(--surface-3); overflow: hidden; flex: none; }
.ibar .b i { display: block; height: 100%; background: var(--series-1); border-radius: 0 3px 3px 0; }
.tag-partial { font-size: 10px; color: var(--muted); margin-left: 4px; font-weight: 400; }

/* 圖表 */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 6px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 12px; border-radius: 4px; cursor: pointer; color: var(--ink-2); font-size: 13px; font-weight: 500; min-height: 28px; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.chart { position: relative; height: 300px; }
.chart.sm { height: 150px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 12px; font-size: 12px; color: var(--ink-2); }
.legend .it { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.legend .it .k { width: 12px; height: 3px; border-radius: 2px; flex: none; }
.legend .it .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.legend.togs .it { cursor: pointer; padding: 3px 8px; margin: -3px -8px; border-radius: 6px; user-select: none; }
.legend.togs .it:hover { background: var(--grid); }
.legend.togs .it:focus-visible { outline: 2px solid var(--series-1); outline-offset: 1px; }
.legend .it.off { opacity: .45; }
.legend .it.off .k { background: var(--muted) !important; }
.legend .it.off .nm { text-decoration: line-through; }
.legend .lg-all { border: 0; background: none; padding: 0; font: inherit; color: var(--series-1); cursor: pointer; text-decoration: underline; }
.legend .it .v { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.multiples .card { padding: 14px 16px 10px; }
.mm-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.mm-h .nm { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.mm-h .v { font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.note { font-size: 12px; color: var(--muted); margin-top: 12px; }
.tblview { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 6px; }

/* 條狀屬性 */
.demo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.hb { display: grid; grid-template-columns: 92px minmax(0,1fr) 48px; gap: 10px; align-items: center; font-size: 13px; padding: 4px 0; }
.hb .lb { color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hb .tr { height: 10px; }
.hb .tr i { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.hb .vv { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

/* 貼文卡 */
.top5 { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.pcard .rk { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pcard .rk .n { font-size: 12px; color: var(--muted); font-weight: 600; }
.pcard .tx { color: var(--ink); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; min-height: 58px; }
.pcard .tx:hover { color: var(--accent-ink); }
.pcard .by { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .fig { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-top: auto; }
.pcard .fig > div { white-space: nowrap; }
.pcard .fig .v { font-size: 18px; font-weight: 600; }
.pcard .fig .l { font-size: 12px; color: var(--muted); }

/* 篩選列 */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters select { min-width: 140px; }
.filters .count { margin-left: auto; font-size: 12px; color: var(--muted); }

/* 表單 */
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 12px; align-items: end; }
.form-grid > * { min-width: 0; }
.form-grid .field { margin: 0; }
.form-grid input, .form-grid select { width: 100%; }
.form-grid.ev { grid-template-columns: 160px 200px 1fr 1.4fr auto; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

/* 狀態 */
.state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; padding: 40px 16px; color: var(--muted); }
.state .ic-wrap { width: 40px; height: 40px; border-radius: 10px; background: var(--surface-3); display: grid; place-items: center; color: var(--ink-2); margin-bottom: 4px; }
.state .ic-wrap svg { width: 20px; height: 20px; }
.state .t { color: var(--ink); font-weight: 600; font-size: 14px; }
.state .d { font-size: 13px; max-width: 420px; }
.state.err .ic-wrap { background: var(--critical-wash); color: var(--critical); }
.state.compact { padding: 20px 12px; }
.sk { background: linear-gradient(90deg, var(--surface-3) 0%, var(--surface-2) 50%, var(--surface-3) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: 4px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.sk-kpi { height: 132px; border-radius: var(--radius); }
.sk-line { height: 12px; margin: 8px 0; }
.sk-block { height: 240px; border-radius: var(--radius); }
.loadmsg { font-size: 13px; color: var(--muted); margin: 0 0 16px; display: flex; align-items: center; gap: 8px; }
.loadmsg .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 6px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill svg { width: 12px; height: 12px; }
.pill.ok { color: var(--up); background: var(--good-wash); }
.pill.error { color: var(--critical); background: var(--critical-wash); }
.pill.running { color: var(--warning); background: var(--warning-wash); }
.errtxt { color: var(--critical); font-size: 12px; word-break: break-all; }

/* 週報 */
.rep { display: grid; grid-template-columns: 240px minmax(0,1fr); gap: 16px; align-items: start; }
.replist { display: flex; flex-direction: column; gap: 2px; }
.replist button { text-align: left; border: 0; background: transparent; padding: 8px 12px; border-radius: 6px; cursor: pointer; color: var(--ink-2); }
.replist button:hover { background: var(--surface-3); }
.replist button.on { background: var(--accent-wash); color: var(--accent-ink); font-weight: 500; }
.md { font-size: 14px; line-height: 1.75; }
.md h1 { font-size: 20px; margin: 0 0 12px; }
.md h2 { font-size: 16px; margin: 24px 0 8px; }
.md h3 { font-size: 14px; margin: 16px 0 6px; }
.md p { margin: 8px 0; }
.md ul { margin: 8px 0; padding-left: 20px; }
.md table { border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.md td, .md th { border: 1px solid var(--border); padding: 6px 10px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 8px; font-size: 13px; z-index: 100; box-shadow: 0 4px 16px rgba(0,0,0,.15); }

/* 每月目標 */
.g-tool { margin-bottom: 16px; }
.g-note { font-size: 12px; color: var(--muted); }
.goals .goal { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) 128px; grid-template-areas: "name mid stat" "why why why"; gap: 6px 28px; align-items: center; padding: 14px 20px; border-top: 1px solid var(--border); }
.goals .goal:first-child { border-top: 0; }
.g-name { grid-area: name; min-width: 0; }
.g-lbl { font-weight: 600; font-size: 14px; color: var(--ink); }
.g-scope { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; color: var(--ink-2); min-width: 0; flex-wrap: wrap; }
.g-acc { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); min-width: 0; max-width: 100%; }
.g-acc span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-acc:hover { color: var(--accent-ink); }
.g-who { font-weight: 600; color: var(--ink); }
.g-mid { grid-area: mid; min-width: 0; }
.g-fig { display: flex; align-items: baseline; gap: 4px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.g-cur { font-size: 18px; font-weight: 600; color: var(--ink); }
.g-sep { color: var(--muted); }
.g-tgt { font-size: 14px; color: var(--ink-2); font-weight: 500; }
.g-ul { font-size: 11px; color: var(--muted); margin-left: 4px; }
.g-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.g-stat { grid-area: stat; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.g-pct { font-size: 20px; font-weight: 600; line-height: 1.1; color: var(--ink); display: flex; flex-direction: column; align-items: flex-end; }
.g-pct small { font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 2px; }
.g-stat .sev, .mg-b { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 8px 2px 6px; border-radius: 4px; white-space: nowrap; }
.g-stat .sev svg, .mg-b svg { width: 14px; height: 14px; }
.sev.none { color: var(--muted); background: var(--surface-3); }
.g-why { grid-area: why; font-size: 12px; color: var(--muted); line-height: 1.6; min-width: 0; }
/* 進度條：淡底、實際進度填色、預期進度一條細直線 */
.gbar { position: relative; height: 8px; margin-top: 8px; background: var(--surface-3); border-radius: 4px; }
.gbar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; min-width: 2px; background: var(--up); }
.gbar i.warn { background: var(--warning); }
.gbar i.bad, .gbar i.miss { background: var(--critical); }
.gbar i.none { background: var(--axis); }
.gbar .pace { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; border-radius: 1px; background: var(--ink); box-shadow: 0 0 0 2px var(--surface); }
.gbar.sm { height: 6px; margin-top: 6px; border-radius: 3px; }
.gbar.sm i { border-radius: 3px; }
/* 可編輯 */
button.edit { border: 0; background: transparent; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; text-decoration: underline dotted var(--axis); text-underline-offset: 3px; border-radius: 3px; }
button.edit:hover { color: var(--accent-ink); text-decoration-color: currentColor; }
button.g-why-t { color: var(--muted); line-height: 1.6; text-decoration: none; }
button.g-why-t:hover { text-decoration: underline dotted currentColor; }
.g-edit { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.g-edit input { width: 120px; min-height: 30px; padding: 4px 8px; font-variant-numeric: tabular-nums; }
.g-edit.wide { display: flex; flex-direction: column; align-items: stretch; gap: 4px; width: 100%; }
.g-edit textarea { width: 100%; font-size: 13px; resize: vertical; }
.g-hint { font-size: 11px; color: var(--muted); }
.g-hint.err { color: var(--critical); }
a.g-h { color: var(--ink); }
/* 成員卡的目標行 */
.mgoal { padding-top: 12px; border-top: 1px solid var(--border); }
.mg-h { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: var(--muted); }
.mg-avg { color: var(--ink-2); }
.mg-v { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.mg-v b { font-size: 16px; font-weight: 600; color: var(--ink); }
.mg-b { font-size: 11px; padding: 1px 6px 1px 4px; }
.mg-b.warn { color: var(--warning); background: var(--warning-wash); }
.mg-b.bad { color: var(--critical); background: var(--critical-wash); }
/* 週報列表的成員名 */
.replist button { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rp { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; background: var(--surface-3); color: var(--ink-2); font-size: 11px; font-weight: 600; margin-right: 8px; }
.replist button.on .rp { background: var(--surface); }
@media (max-width: 900px) {
  .goals .goal { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name stat" "mid mid" "why why"; gap: 8px 12px; padding: 14px 16px; align-items: start; }
  .g-stat { flex-direction: column-reverse; gap: 4px; }
  .g-pct { font-size: 17px; }
  .g-tool .g-note { width: 100%; }
  .kpis.gk .kpi:first-child { grid-column: auto; }
}
@media (forced-colors: active) {
  .gbar i, .gbar .pace { forced-color-adjust: none; }
}

/* ---------- 響應式 ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .top5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .form-grid.ev { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); background: none; }
  .side { display: none; }
  .topbar { padding: 0 16px; height: 52px; }
  .topbar .mbrand { display: flex; }
  .topbar .crumbs { display: none; }
  .topbar .user .nm { display: none; }
  .content { padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); }
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0 4px; font-size: 11px; color: var(--muted); text-decoration: none; border-radius: 6px; }
  .tabbar a svg.ic { width: 20px; height: 20px; }
  .tabbar a.on { color: var(--accent-ink); }
  .ph h1 { font-size: 19px; }
  .kpis, .kpis.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpis .kpi:first-child { grid-column: 1 / -1; }
  .kpi { padding: 12px; }
  .kpi .val { font-size: 22px; }
  .top5 { grid-template-columns: minmax(0, 1fr); }
  .two, .three { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid.ev { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .form-grid .field.wide, .form-grid .btn { grid-column: 1 / -1; }
  .rep { grid-template-columns: minmax(0, 1fr); }
  .replist { flex-direction: row; overflow-x: auto; }
  .replist button { white-space: nowrap; }
  .chart { height: 240px; }
  .card { padding: 16px; }
  .hide-m { display: none !important; }
  .cell-name .nm { max-width: 150px; }
  .cell-txt { max-width: none; min-width: 160px; }
  .members { grid-template-columns: minmax(0, 1fr); }
  .filters select { flex: 1 1 140px; min-width: 0; }
  .filters .count { margin-left: 0; width: 100%; }
}
@media (max-width: 480px) {
  .hide-s { display: none !important; }
  table.t td, table.t th { padding: 10px 8px; }
  .achip span.t { max-width: 140px; }
  .cell-name { gap: 6px; }
  .cell-name .nm { max-width: 92px; }
  .kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .kpis.k3 .kpi:first-child { grid-column: auto; }
  .kpis.k3 .kpi .val { font-size: 18px; }
}
@media (forced-colors: active) {
  .delta, .pb::before, .ibar .b i, .hb .tr i { forced-color-adjust: none; }
}
.show-m { display: none !important; }
@media (max-width: 900px) { .show-m { display: block !important; } }
.kpis.k3 .kpi:first-child { grid-column: auto; }
@media (max-width: 900px) { .pcard .tx { min-height: 0; } }
@media (max-width: 480px) {
  table.t { font-size: 12px; }
  table.t td, table.t th { padding: 10px 6px; }
  table.t td:first-child, table.t th:first-child { padding-left: 10px; }
  .cell-name .nm { max-width: 78px; }
  .pb { padding: 0 5px 0 4px; gap: 4px; font-size: 10px; }
}

/* ---------- 參考帳號 ---------- */
.reftag { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; flex: none; cursor: help; }
table.t tr.ref td, table.t tr.ref .cell-name .nm { color: var(--muted); }
table.t tr.ref .delta { opacity: .75; }
/* 帳號總表：切換列、平台分段、合計列 */
.tbl-tool { margin-bottom: 12px; }
table.t tr.grp td { background: var(--surface-2); padding: 8px 12px; border-bottom: 1px solid var(--border); }
.grp-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.grp-h b { font-weight: 600; color: var(--ink); font-size: 13px; }
.grp-h .grp-v { margin-left: auto; color: var(--ink-2); }
.grp-h .grp-v b { font-size: 13px; }
table.t tfoot td { border-top: 1px solid var(--border-strong); background: var(--surface-2); font-weight: 600; padding: 10px 12px; }
table.t tfoot td .sd { font-weight: 400; }
/* 期間切換 */
.period-tool { margin-bottom: 0; }
.drange { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.drange input { min-height: 32px; padding: 4px 8px; }
.drange .dn { font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* 成員卡：網站一行 */
.msite { font-size: 12px; color: var(--ink-2); background: var(--surface-2); border-radius: 6px; padding: 8px 10px; }
.msite .ms-h { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.msite .ms-g { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 4px; }
.msite .ms-g > div { min-width: 0; }
.msite .l { display: block; font-size: 11px; color: var(--muted); }
.msite b { color: var(--ink); font-weight: 600; font-size: 14px; white-space: nowrap; }
.msite .u { font-size: 11px; color: var(--muted); margin-left: 1px; }
/* 足球麥迪網站頁 */
.site-tool { margin-bottom: 12px; }
.srange { font-size: 12px; color: var(--muted); }
.site-pair { padding-top: 14px; }
.sp-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.sp-h .nm { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.sp-h .v { font-size: 12px; color: var(--ink-2); }
#sv { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.chart.site-c { height: 170px; }
.site-src { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; align-items: start; }
.src-row { grid-template-columns: 112px minmax(0, 1fr) 96px; }
.src-row .lb { display: flex; align-items: center; gap: 6px; }
.src-row .soc { font-size: 10px; color: var(--muted); background: var(--surface-3); border-radius: 3px; padding: 0 4px; line-height: 16px; font-weight: 600; }
.src-row .vv small { display: inline-block; min-width: 44px; margin-left: 6px; font-size: 11px; color: var(--muted); }
.src-row.zero .lb, .src-row.zero .vv { color: var(--muted); }
.soc-tile .lbl { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.soc-tile .big { font-size: 32px; font-weight: 600; line-height: 1.2; margin-top: 8px; }
.soc-tile .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.soc-tile .foot { font-size: 11px; color: var(--muted); margin-top: 10px; line-height: 1.6; }
.funnel { display: grid; grid-template-columns: minmax(0, 1fr) 96px minmax(0, 1fr) 96px minmax(0, 1fr); align-items: center; gap: 8px; }
.fn-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 14px 16px; min-width: 0; }
.fn-cell .l { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.fn-cell .v { font-size: 24px; font-weight: 600; margin-top: 4px; white-space: nowrap; }
.fn-cell .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.fn-cell .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.fn-conn { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); }
.fn-conn svg { width: 28px; height: 14px; stroke: var(--axis); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.fn-conn .r { font-size: 15px; font-weight: 600; color: var(--ink); }
.fn-conn .l { font-size: 11px; }
/* 轉化頁：網站區塊 */
.sec-h h2 .pb { vertical-align: 2px; margin-right: 4px; }
.sconv .sc-v { display: flex; flex-direction: column; gap: 2px; margin: -4px 0 10px; }
.sconv .val { font-size: 24px; font-weight: 600; line-height: 1.2; }
.sconv .val small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.sconv .dl { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 12px; }
@media (max-width: 900px) {
  .site-src { grid-template-columns: minmax(0, 1fr); }
  .funnel { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .fn-conn { flex-direction: row; justify-content: center; gap: 8px; padding: 2px 0; }
  .fn-conn svg { transform: rotate(90deg); width: 20px; }
  .grp-h .grp-v { margin-left: 0; width: 100%; }
  .chart.site-c { height: 160px; }
}
@media (max-width: 480px) {
  .src-row { grid-template-columns: 88px minmax(0, 1fr) 84px; gap: 8px; }
  .src-row .vv small { min-width: 38px; margin-left: 4px; }
  .drange input { width: 140px; }
}

/* 帳號總表：欄位標題列＋分組標題列兩層黏頂 */
.tbl-tool .tl { font-size: 12px; color: var(--muted); }
.avatar.xs { width: 20px; height: 20px; font-size: 10px; }
.grp-sep { color: var(--muted); margin: 0 2px; }
.card.stick-card { overflow: clip; }
.tw.stick { overflow: visible; }
.tw.stick table.t thead th { position: sticky; top: 56px; z-index: 3; box-shadow: inset 0 -1px 0 var(--border); }
.tw.stick table.t tr.grp td { position: sticky; top: calc(56px + var(--thh, 39px)); z-index: 2; box-shadow: inset 0 -1px 0 var(--border); }
@media (max-width: 1180px) {
  /* 窄螢幕需要左右滑：表格放進自己的捲動框，兩層都黏在框頂 */
  .tw.stick { overflow: auto; max-height: calc(100vh - 52px - 96px - env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .tw.stick table.t thead th { top: 0; }
  .tw.stick table.t tr.grp td { top: var(--thh, 39px); }
}

/* 成員卡：網站 */
.mcard.site .mstats .v small.u { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 1px; }
.msoc { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 12px; background: var(--surface-2); border-radius: 6px; padding: 8px 10px; }
.msoc .l { color: var(--muted); font-size: 11px; }
.msoc b { font-size: 16px; font-weight: 600; color: var(--ink); }
.mgoal b.who { font-size: 13px; }
.mcard.site .mgoal .mg-v b { font-size: 14px; }

.mg-site { font-size: 12px; color: var(--ink-2); margin-top: 2px; line-height: 1.5; }
.mg-site b { color: var(--ink); font-weight: 600; }
.mcard.site .mstats .delta { font-size: 10px; }

/* ---------- 目標：週／月切換、新增表單、刪除、主管訂定 ---------- */
.g-tool .g-note { flex-basis: 100%; }
.g-mgr { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 4px; background: var(--accent-wash); color: var(--accent-ink); font-size: 11px; font-weight: 600; white-space: nowrap; flex: none; }
.g-why { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.g-why-x { flex: 1 1 auto; min-width: 0; }
.g-del { flex: none; border: 1px solid transparent; background: transparent; color: var(--muted); font: inherit; font-size: 12px; line-height: 1.4; padding: 1px 8px; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.g-del:hover { color: var(--critical); border-color: var(--border-strong); }
.g-del.armed { color: #fff; background: var(--critical); border-color: var(--critical); font-weight: 600; }
.gform { margin-bottom: 16px; }
.gf-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.gf-grid > * { min-width: 0; }
.gf-grid .field { margin: 0; }
.gf-grid input, .gf-grid select, .gf-grid textarea { width: 100%; min-width: 0; }
.gf-grid textarea { resize: vertical; font-size: 13px; }
.gf-grid .wide { grid-column: span 2; }
.gf-grid .full { grid-column: 1 / -1; }
.gf-ref { align-self: center; font-size: 12px; color: var(--muted); line-height: 1.5; padding-top: 18px; }
.gf-act { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.gf-act .g-hint { margin-right: auto; font-size: 12px; }
@media (max-width: 900px) {
  .gf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gf-ref { grid-column: 1 / -1; padding-top: 0; }
}
@media (max-width: 480px) {
  .gf-grid { grid-template-columns: minmax(0, 1fr); }
  .gf-grid .wide { grid-column: 1 / -1; }
  .g-tool .seg { flex: 1 1 100%; }
  .g-tool .seg button { flex: 1 1 0; padding: 4px 6px; }
  .g-tool #gadd { flex: 1 1 100%; }
}
