/* ============================================================================
 * theme.css — 視覺單一事實源（附錄 E：AntD 5.x token 移植 + momo magenta）
 * 主品牌色 magenta #eb2f96；白底 sidebar；後台高密度；KPI 卡頂彩條。
 * ========================================================================== */

/* ---- E.1 / E.2 色板 + 語意 token ---- */
:root {
  /* Magenta（momo 主色）10 階 */
  --magenta-1: #fff0f6; --magenta-2: #ffd6e7; --magenta-3: #ffadd2;
  --magenta-4: #ff85c0; --magenta-5: #f759ab; --magenta-6: #d62872;
  --magenta-7: #c41d7f; --magenta-8: #9e1068; --magenta-9: #780650; --magenta-10: #520339;
  /* 其他主色錨點 */
  --blue-6: #1677ff; --green-6: #52c41a; --gold-6: #faad14; --red-5: #ff4d4f;
  --purple-6: #722ed1; --cyan-6: #13c2c2; --orange-6: #fa8c16;
  /* Neutral */
  --gray-1: #ffffff; --gray-2: #fafafa; --gray-3: #f5f5f5; --gray-4: #f0f0f0;
  --gray-5: #d9d9d9; --gray-6: #bfbfbf; --gray-7: #8c8c8c; --gray-8: #595959;
  --gray-9: #434343; --gray-10: #262626; --gray-11: #1f1f1f; --gray-12: #141414;

  /* 語意 token */
  --color-primary: var(--magenta-6);
  --color-primary-hover: var(--magenta-5);
  --color-primary-active: var(--magenta-7);
  --color-primary-bg: var(--magenta-1);
  /* Mixpanel 風中性色（冷調、近黑文字、極淡邊框）*/
  --color-text: #1b1b2b;
  --color-text-secondary: #5c5c70;
  --color-text-tertiary: #8c8ca0;
  --color-bg-container: #fff;
  --color-bg-layout: #f7f7fb;
  --color-bg-mask: rgba(24, 24, 40, .45);
  --color-border: #ececf2;
  --color-border-secondary: #f3f3f8;
  --color-split: rgba(24, 24, 60, .06);
  --color-success: var(--green-6);
  --color-warning: var(--gold-6);
  --color-error: var(--red-5);
  --color-info: var(--blue-6);
  /* 語意底色（兩皮共用：antd 與 momo 的綠/金/紅/藍同階）— 修正成功態誤用 primary-bg */
  --color-success-bg: #f6ffed;
  --color-warning-bg: #fffbe6;
  --color-error-bg: #fff1f0;
  --color-info-bg: #e6f4ff;
  --color-processing: var(--blue-6);
  --gold-1: #fffbe6; --gold-7: #ad6800;
  --purple-1: #f9f0ff;

  /* Mixpanel 風：更大圓角 */
  --border-radius: 8px; --border-radius-lg: 12px; --border-radius-sm: 6px; --border-radius-xs: 4px;
  --font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Roboto, sans-serif;
  --font-size: 14px; --font-size-sm: 12px; --font-size-lg: 16px; --font-size-xl: 20px;
  --line-height: 1.55;
  --motion-fast: .1s; --motion: .18s; --motion-slow: .28s;
  --sidebar-w: 236px; --topbar-h: 56px; --fs-kpi: 30px;

  /* Mixpanel 風：極輕、冷調陰影（更靠邊框驅動）*/
  --box-shadow-tertiary: 0 1px 2px rgba(24,24,60,.04), 0 1px 3px rgba(24,24,60,.03);
  --box-shadow: 0 6px 24px rgba(24,24,60,.10), 0 2px 8px rgba(24,24,60,.06);
  --box-shadow-drawer-right: -8px 0 28px rgba(24,24,60,.12), -2px 0 8px rgba(24,24,60,.06);

  /* 別名 */
  --momo: var(--magenta-6); --bg: var(--gray-3); --card: #fff;

  /* 品牌識別漸層（洋紅→紫→藍紫）— 用於 hero / CTA / 標題 / 強調表面 */
  --brand-gradient: linear-gradient(135deg, #e0277e 0%, #a23ba8 50%, #6b4dd8 100%);
  --brand-gradient-h: linear-gradient(90deg, #e0277e 0%, #a23ba8 50%, #6b4dd8 100%);
  --brand-gradient-soft: linear-gradient(135deg, #fff0f6 0%, #f6effc 50%, #eef0fd 100%);
}

/* 品牌漸層工具：標題漸層字 / 頂部 4px 強調條 / 漸層底色塊 */
.grad-text { background: var(--brand-gradient-h); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.grad-bar { position: relative; }
.grad-bar::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--brand-gradient-h); border-radius: 4px 4px 0 0; }
.grad-fill { background: var(--brand-gradient); color: #fff; }

/* 功能編號標籤：預設隱藏，僅在「功能編號」開啟（body.fn-show）時以磁紅標籤顯示 */
.fn-tag { display: none; }
body.fn-show .fn-tag { display: inline-block; background: var(--magenta-7); color: #fff; font-size: 10px; font-weight: 800; padding: 1px 7px; border-radius: 8px; letter-spacing: .3px; vertical-align: middle; margin-left: 4px; }
/* 已含顯式 .fn-tag 的元素不再額外渲染 annotate 角落 pill（避免重複） */
body.fn-show [data-fn]:has(.fn-tag)::after { content: none; }

/* 上傳名單區塊（Lookalike 種子名單上傳）*/
.upload-zone { display: flex; align-items: center; gap: 16px; border: 2px dashed var(--magenta-3); border-radius: 12px; padding: 16px 20px; background: var(--brand-gradient-soft); margin-bottom: 16px; }
.upload-zone .uz-ico { width: 46px; height: 46px; border-radius: 12px; background: #fff; display: flex; align-items: center; justify-content: center; color: var(--magenta-6); flex: 0 0 auto; box-shadow: var(--box-shadow-tertiary); }
.upload-zone .uz-main { flex: 1; min-width: 0; }
.upload-zone .uz-t { font-weight: 700; font-size: 14px; }
.upload-zone .uz-d { font-size: 12px; color: var(--color-text-secondary); margin-top: 2px; }
.upload-zone .uz-bar { height: 8px; border-radius: 8px; background: rgba(255,255,255,.7); margin-top: 8px; overflow: hidden; }
.upload-zone .uz-bar > i { display: block; height: 100%; width: 0; background: var(--brand-gradient-h); transition: width .8s ease; }
.upload-zone .uz-btn { color: var(--magenta-7); font-weight: 700; cursor: pointer; white-space: nowrap; font-size: 13px; }
.upload-zone .uz-btn:hover { text-decoration: underline; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }
body {
  font-family: var(--font-family);
  font-size: var(--font-size);
  line-height: var(--line-height);
  color: var(--color-text);
  background: var(--color-bg-layout);
  -webkit-font-smoothing: antialiased;
}

/* ---- E.3 App Shell ---- */
#app { display: flex; height: 100vh; overflow: hidden; }

#sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: #fff; border-right: 1px solid var(--color-border);
  height: 100vh; overflow-y: auto;   /* 獨立捲動窗格 */
}
.brand {
  height: var(--topbar-h); box-sizing: border-box;   /* 與右側 topbar 同高，底線對齊 */
  padding: 0 20px; font-size: 17px; font-weight: 700; letter-spacing: -.01em;
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 10px;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--magenta-5), var(--magenta-7));
  color: #fff; display: flex; align-items: center; justify-content: center;
}
.brand .brand-logo { width: 30px; height: 30px; border-radius: 8px; display: block; flex: 0 0 auto; }
.nav-group { padding: 6px 0; }
.nav-group-title {
  padding: 10px 20px 4px; font-size: 11px; color: var(--color-text-tertiary);
  font-weight: 600; letter-spacing: .4px; text-transform: none;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px; margin: 1px 8px; border-radius: var(--border-radius);
  color: var(--color-text-secondary); cursor: pointer;
  font-size: 13.5px; font-weight: 500; transition: all var(--motion);
}
.nav-item:hover { background: var(--gray-2); color: var(--color-text); }
.nav-item.active { background: var(--color-primary-bg); color: var(--color-primary); font-weight: 600; }
.nav-item.active::before {
  content: ""; position: absolute; left: -8px; top: 7px; bottom: 7px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--color-primary);
}
.nav-item .ico { display: flex; opacity: .9; }
.tag-new {
  margin-left: auto; font-size: 9.5px; background: var(--magenta-1); color: var(--magenta-7); border: 1px solid var(--magenta-2);
  padding: 0 6px; border-radius: 10px; font-weight: 700; line-height: 16px; letter-spacing: .3px;
}

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
#topbar {
  height: var(--topbar-h); background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  flex: 0 0 auto; z-index: 50;   /* 固定列，不隨內容捲動 */
}
.crumb { font-size: 14.5px; font-weight: 600; letter-spacing: -.01em; }
.crumb .sub { color: var(--color-text-tertiary); font-weight: 400; }
.spacer { flex: 1; }
.btn-tour {
  background: var(--brand-gradient-h); color: #fff; border: none;
  height: 32px; padding: 0 14px; border-radius: var(--border-radius);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: filter var(--motion);
}
.btn-tour:hover { filter: brightness(1.08); }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--color-text-secondary); }
.user-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
#page-root { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px 60px; animation: pageIn var(--motion-slow) ease; }   /* 獨立捲動窗格 */
@keyframes pageIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- 共用元件 ---- */
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 23px; margin: 0 0 4px; font-weight: 700; letter-spacing: -.02em; }
.page-head h1 { background: var(--brand-gradient-h); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; display: inline-block; }
.page-head h1 .badge { -webkit-text-fill-color: initial; }
.page-head .desc { color: var(--color-text-secondary); font-size: 13.5px; }

.card {
  background: var(--card); border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg); box-shadow: var(--box-shadow-tertiary);
  margin-bottom: 16px;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-head .title { font-size: 16px; font-weight: 600; }
.card-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1100px) { .grid-4, .grid-6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4, .grid-6 { grid-template-columns: repeat(2, 1fr); } }

/* KPI 卡（Mixpanel 風：乾淨白卡 + 左側細彩條 accent） */
.kpi {
  position: relative; background: #fff; border: 1px solid var(--color-border);
  border-radius: var(--border-radius-lg); padding: 16px 18px 16px 20px; overflow: hidden;
  box-shadow: var(--box-shadow-tertiary); transition: box-shadow var(--motion), border-color var(--motion);
}
.kpi:hover { box-shadow: var(--box-shadow-tertiary), 0 2px 10px rgba(24,24,60,.05); border-color: var(--magenta-2); }
.kpi::before {
  content: ""; position: absolute; top: 14px; bottom: 14px; left: 0; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--bar, var(--color-primary));
}
.kpi .k-label { font-size: 12.5px; color: var(--color-text-secondary); margin-bottom: 6px; font-weight: 500; }
.kpi .k-value { font-size: var(--fs-kpi); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; letter-spacing: -.02em; }
.kpi .k-value .unit { font-size: 14px; font-weight: 500; color: var(--color-text-tertiary); margin-left: 2px; }
.kpi .k-foot { font-size: 12px; margin-top: 6px; color: var(--color-text-tertiary); }
.kpi .k-delta.up { color: var(--green-6); }
.kpi .k-delta.down { color: var(--red-5); }
.kpi .k-target { font-size: 11px; color: var(--color-text-tertiary); }

/* Badge */
.badge {
  display: inline-flex; align-items: center; font-size: 11.5px; line-height: 19px;
  padding: 0 9px; border-radius: 999px; font-weight: 600; white-space: nowrap;
}
.badge.blue { background: #e6f4ff; color: #1677ff; }
.badge.green { background: #f6ffed; color: #389e0d; }
.badge.orange { background: #fff7e6; color: #d46b08; }
.badge.purple { background: #f9f0ff; color: #722ed1; }
.badge.red { background: #fff1f0; color: #cf1322; }
.badge.cyan { background: #e6fffb; color: #08979c; }
.badge.pink { background: var(--magenta-1); color: var(--magenta-7); }
.badge.yellow { background: #fffbe6; color: #d4b106; }
.badge.gray { background: #f5f5f5; color: #595959; }

/* Button（Mixpanel：8px 圓角、medium weight、輕 hover）*/
.btn {
  height: 34px; padding: 0 14px; border-radius: var(--border-radius);
  border: 1px solid var(--color-border); background: #fff; color: var(--color-text);
  font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all var(--motion);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--magenta-3); background: var(--gray-2); color: var(--color-text); }
.btn.primary, .btn.pink { background: var(--brand-gradient-h); border: none; color: #fff; box-shadow: 0 1px 3px rgba(160,59,168,.3); transition: filter var(--motion); }
.btn.primary:hover, .btn.pink:hover { filter: brightness(1.08); color: #fff; }
.btn.sm { height: 28px; padding: 0 11px; font-size: 12.5px; }
.btn.lg { height: 40px; padding: 0 20px; font-size: 14.5px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Table（Mixpanel：無重底、細 hover）*/
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--color-border); }
.tbl th { color: var(--color-text-tertiary); font-weight: 600; background: transparent; font-size: 12px; letter-spacing: .02em; }
.tbl tr:hover td { background: var(--gray-2); }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.best td { background: #f3fbf0; }
.tbl tr.best td:first-child { box-shadow: inset 3px 0 0 var(--green-6); }

/* Tabs（Mixpanel：pill 風 segmented）*/
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--color-border); margin-bottom: 18px; }
.tabs .tab {
  padding: 9px 14px; cursor: pointer; font-size: 13.5px; font-weight: 500; color: var(--color-text-secondary);
  border-bottom: 2px solid transparent; transition: all var(--motion); margin-bottom: -1px;
}
.tabs .tab:hover { color: var(--color-text); }
.tabs .tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: 600; }

/* Drawer 480 / Modal 540 */
.mask {
  position: fixed; inset: 0; background: var(--color-bg-mask); z-index: 900;
  animation: fadeIn var(--motion) ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 480px; max-width: 92vw;
  background: #fff; z-index: 910; box-shadow: var(--box-shadow-drawer-right);
  display: flex; flex-direction: column; animation: slideIn var(--motion-slow) ease;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: 540px; max-width: 92vw; max-height: 86vh; background: #fff;
  z-index: 910; border-radius: var(--border-radius-lg); box-shadow: var(--box-shadow);
  display: flex; flex-direction: column; animation: zoomIn var(--motion) ease;
}
@keyframes zoomIn { from { opacity: 0; transform: translate(-50%, -50%) scale(.95); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.drawer-head, .modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between; font-size: 16px; font-weight: 600;
}
.drawer-body, .modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--color-border); display: flex; justify-content: flex-end; gap: 8px; }
.x-close { cursor: pointer; color: var(--color-text-tertiary); font-size: 18px; line-height: 1; }
.x-close:hover { color: var(--color-text); }

/* Heat cell */
.heat-cell {
  cursor: pointer; transition: transform var(--motion-fast); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 12px; font-variant-numeric: tabular-nums;
  height: 40px; user-select: none;
}
.heat-cell:hover { transform: scale(1.15); z-index: 5; box-shadow: var(--box-shadow); position: relative; }

/* Bar */
.bar-track { background: var(--gray-4); border-radius: 10px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 10px; background: var(--color-primary); transition: width var(--motion-slow) ease; }

.score-pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 38px; padding: 2px 8px; border-radius: 12px; color: #fff;
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
}

/* Phone mockup */
.phone {
  width: 280px; background: #000; border-radius: 32px; padding: 10px;
  box-shadow: var(--box-shadow); position: relative; flex: 0 0 auto;
}
.phone .notch {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  width: 100px; height: 22px; background: #000; border-radius: 0 0 14px 14px; z-index: 3;
}
.phone .screen {
  background: #f5f5f5; border-radius: 24px; height: 520px; overflow-y: auto;
  position: relative;
}

/* misc */
.muted { color: var(--color-text-tertiary); }
.flex { display: flex; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.center { display: flex; align-items: center; justify-content: center; }
.wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%);
  background: var(--gray-11); color: #fff; padding: 10px 20px; border-radius: var(--border-radius);
  z-index: 950; font-size: 14px; box-shadow: var(--box-shadow); animation: fadeIn var(--motion) ease;
}
.chart-box { position: relative; height: 300px; }

/* Tour */
#tour-mask { position: fixed; inset: 0; z-index: 980; pointer-events: auto; }
/* 統一聚光：桃紅光環 + 極淡變暗（對齊 US 演示 .usp-ring） */
.tour-spot {
  position: absolute; border-radius: 10px; border: 2.5px solid var(--color-primary);
  box-shadow: 0 0 0 4px var(--magenta-2), 0 0 0 9999px rgba(24,24,60,.06);
  transition: all var(--motion-slow) ease; pointer-events: none;
}
.tour-box {
  position: absolute; width: 340px; background: #fff; border-radius: var(--border-radius-lg);
  box-shadow: var(--box-shadow); padding: 18px; z-index: 985;
}
.tour-box h4 { margin: 0 0 8px; font-size: 16px; }
.tour-box p { margin: 0 0 14px; color: var(--color-text-secondary); font-size: 13px; }
.tour-box .step-n { color: var(--color-primary); font-weight: 700; }
.tour-foot { display: flex; align-items: center; justify-content: space-between; }
