:root {
  --bg: #0b0f1a;
  --bg-card: #161d2e;
  --bg-input: #1f293d;
  --bg-hover: #24304678;
  --border: #2c3850;
  --text: #eef1f6;
  --text-dim: #9aa4b7;
  --green: #3ecf8e;
  --red: #f16565;
  --yellow: #e8c547;
  --accent: #5b8cff;
  --accent-dim: rgba(91,140,255,0.15);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(0,0,0,0.25);

  /* AI 科技感強調色：cyan → purple 漸層，只用在 AI 相關的少數元件上
     （Score 環、AI 分析按鈕、全域底層光暈），不是取代整體配色。 */
  --ai-cyan: #22d3ee;
  --ai-purple: #a78bfa;
  --ai-gradient: linear-gradient(90deg, var(--ai-cyan), var(--ai-purple));
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

/* ============================================================
   全域底層背景：跟首頁同一張合成背景圖（globe / data wave / 星空 / grid
   都已經畫在圖裡），由 common.js 在每一頁的 <body> 最前面插入 .ai-bg 這個
   容器（只需要寫一次邏輯，8 個工作頁面自動套用），這裡只負責它的樣式。
   整層 fixed + 負 z-index + pointer-events:none，純視覺、不擋任何操作、
   不吃版面空間、不影響捲動。

   這裡刻意不做任何動畫：實測發現在內容本身已經很吃效能的頁面（例如籌碼雷達
   的資金流向粒子動畫）上，背景只要一動就會讓人感覺到卡頓。這些工作頁面
   使用者會長時間盯著看，穩定不卡比多一點動態更重要，所以固定用一張靜態圖
   （單一 HTTP 請求、瀏覽器跨頁快取，不會每頁重複下載）；overlay 也比首頁
   深一些，因為這裡的內容（表格、卡片、長文字）比首頁的 hero 密集很多，
   需要更高的對比才不會被背景圖干擾閱讀。首頁自己的版本見 css/home.css。
   ============================================================ */
.ai-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.ai-bg-image {
  position: absolute;
  inset: 0;
  background-image: url("/images/novascan-home-bg.webp");
  background-size: cover;
  background-position: center top;
  background-repeat: no-repeat;
}
.ai-bg-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    rgba(2, 8, 20, 0.55),
    rgba(2, 8, 20, 0.68) 35%,
    rgba(2, 8, 20, 0.78)
  );
}
@media (max-width: 640px) {
  .ai-bg-image { background-position: 60% top; opacity: 0.82; }
}

header.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 20px 40px;
  border-bottom: 1px solid var(--border);
  background: rgba(22,29,46,0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  /* position:sticky + z-index 讓 topbar 自己形成一個 stacking context——
     裡面的 nav（手機版抽屜，z-index:20）跟 nav-toggle（21）都只是在這個
     context「內部」排順序，對外實際上整個 topbar 只算 10 那一層。
     .nav-backdrop 是直接掛在 <body> 下面、z-index:19，比 10 高，
     結果變成蓋在 nav 抽屜「上面」，導致點連結點到 backdrop、選單只是
     關起來、沒有真的跳轉。topbar 的 z-index 拉高到 25（比 backdrop 19
     高，但還是低過 tooltip/modal/toast 的 30/100/500），抽屜才會真的
     蓋在最上層、點得到連結。 */
  z-index: 25;
}

header.topbar h1, header.topbar .brand {
  font-size: 20px;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}
header.topbar h1 a, header.topbar .brand a {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.15s ease;
}
header.topbar h1 a:hover, header.topbar .brand a:hover { opacity: 0.82; }
header.topbar h1 .brand-text, header.topbar .brand .brand-text {
  background: var(--ai-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.02em;
}

header.topbar nav { display: flex; gap: 6px; }

header.topbar nav a {
  color: var(--text-dim);
  text-decoration: none;
  padding: 9px 18px;
  border-radius: 100px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

header.topbar nav a.active {
  color: white;
  background: var(--accent);
}

header.topbar nav a:not(.active):hover {
  color: var(--text);
  background: var(--bg-input);
}

/* 手機版導覽：漢堡按鈕 + 側邊抽屜（common.js 動態插入 .nav-toggle / .nav-backdrop）。
   平常（桌機）完全不會出現，只有窄螢幕才切換成這個模式，取代原本「8 個分頁
   擠在頂端、每個字都直式換行」的糟糕版面。 */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  position: relative;
  /* 開啟時抽屜本身（見 header.topbar nav 的 z-index:20）會蓋住整個頂部
     這一條，包含漢堡鈕原本的位置——沒有更高的 z-index，抽屜開著的時候
     再點一次漢堡鈕會點到抽屜的背景（沒有作用），而不是點到這顆按鈕本身。 */
  z-index: 21;
}
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 19;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.nav-backdrop.show { display: block; opacity: 1; }

/* 登入者資訊 + 登出：固定貼在 topbar 最右邊（common.js 動態插入），
   只有正式站（Railway，真的有登入機制）才會出現，本機開發不會看到這塊。 */
.auth-badge {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}
.auth-badge-email {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-badge-owner {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ai-cyan);
  border: 1px solid color-mix(in srgb, var(--ai-cyan) 40%, transparent);
  border-radius: 999px;
  padding: 2px 8px;
}
.auth-badge-logout {
  color: var(--text-dim);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 100px;
  border: 1px solid var(--border);
  font-weight: 600;
  transition: background 0.15s, color 0.15s;
}
.auth-badge-logout:hover {
  color: var(--text);
  background: var(--bg-input);
}
.auth-login-btn {
  margin-left: auto;
  color: white;
  background: var(--accent);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 18px;
  border-radius: 100px;
  white-space: nowrap;
  transition: filter 0.15s;
}
.auth-login-btn:hover { filter: brightness(1.1); }
@media (max-width: 720px) {
  .auth-badge-email { display: none; }
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 36px 40px 64px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  margin-bottom: 24px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.32);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
.stat-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0,0,0,0.3);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

.card h2 {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

/* --- 頂部總覽數字卡 --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 26px;
}
.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.stat-card .stat-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.stat-card .stat-sub { font-size: 14px; margin-top: 6px; color: var(--text-dim); }

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--text-dim); font-weight: 500; }

input, select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  min-width: 110px;
  transition: border-color 0.15s;
}

input:focus, select:focus { outline: none; border-color: var(--accent); }

button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s, transform 0.12s ease, box-shadow 0.2s ease;
}
button:hover { filter: brightness(1.1); box-shadow: 0 0 0 4px var(--accent-dim); }
button:active { transform: translateY(1px) scale(0.98); box-shadow: none; }

button.secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
button.secondary.active { background: var(--accent); color: white; border-color: var(--accent); }
button.secondary:hover { box-shadow: 0 0 0 4px rgba(255,255,255,0.06); }
button.danger { background: transparent; color: var(--red); border: 1px solid var(--red); padding: 7px 14px; font-size: 13px; }
button.danger:hover { box-shadow: 0 0 0 4px rgba(241,101,101,0.15); }
button:disabled { opacity: 0.5; cursor: not-allowed; filter: none; box-shadow: none; }

/* --- AI 分析 CTA 按鈕：漸層邊框（雙背景疊圖技巧），loading 時邊框流動 --- */
.ai-cta-btn {
  background-color: var(--bg-input);
  background-image: linear-gradient(var(--bg-input), var(--bg-input)), var(--ai-gradient);
  background-origin: border-box;
  background-clip: padding-box, border-box;
  color: var(--text);
  border: 1px solid transparent;
  transition: box-shadow 0.25s ease, filter 0.2s ease;
}
.ai-cta-btn:hover:not(:disabled) {
  filter: brightness(1.08);
  box-shadow: 0 0 20px color-mix(in srgb, var(--ai-cyan) 40%, transparent),
              0 0 20px color-mix(in srgb, var(--ai-purple) 25%, transparent);
}
.ai-cta-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.ai-cta-btn.is-loading:disabled { opacity: 1; } /* loading 中雖然 disabled，但要維持全亮的動畫，不要跟著變暗 */
.ai-cta-btn.is-loading {
  color: white;
  cursor: progress;
  background-image: linear-gradient(var(--bg-input), var(--bg-input)),
    linear-gradient(90deg, var(--ai-cyan), var(--ai-purple), var(--ai-cyan));
  background-size: 100% 100%, 220% 100%;
  animation: ai-cta-flow 2.2s linear infinite;
}
@keyframes ai-cta-flow {
  to { background-position: 0 0, -220% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ai-cta-btn.is-loading { animation: none; }
}

/* 表格內容常常比卡片寬（欄位多、文字長），這裡讓「裝表格的容器」自己捲，
   不要讓表格把整個頁面撐寬。凡是會塞 <table> 進去的容器都掛這個 id。 */
#holdings-table, #screen-results, #trades-table, #monthly-table,
#transactions-table, #top-tickers-table, .table-scroll {
  overflow-x: auto;
  /* 細一點、跟卡片同色調的捲軸，取代預設的系統捲軸樣式（跟 .ai-card-back 同一套） */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#holdings-table::-webkit-scrollbar, #screen-results::-webkit-scrollbar,
#trades-table::-webkit-scrollbar, #monthly-table::-webkit-scrollbar,
#transactions-table::-webkit-scrollbar, #top-tickers-table::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar {
  height: 6px; width: 6px;
}
#holdings-table::-webkit-scrollbar-track, #screen-results::-webkit-scrollbar-track,
#trades-table::-webkit-scrollbar-track, #monthly-table::-webkit-scrollbar-track,
#transactions-table::-webkit-scrollbar-track, #top-tickers-table::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track {
  background: transparent;
}
#holdings-table::-webkit-scrollbar-thumb, #screen-results::-webkit-scrollbar-thumb,
#trades-table::-webkit-scrollbar-thumb, #monthly-table::-webkit-scrollbar-thumb,
#transactions-table::-webkit-scrollbar-thumb, #top-tickers-table::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}
#holdings-table::-webkit-scrollbar-thumb:hover, #screen-results::-webkit-scrollbar-thumb:hover,
#trades-table::-webkit-scrollbar-thumb:hover, #monthly-table::-webkit-scrollbar-thumb:hover,
#transactions-table::-webkit-scrollbar-thumb:hover, #top-tickers-table::-webkit-scrollbar-thumb:hover,
.table-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

.member-list { white-space: normal; max-width: 360px; }

/* --- 頁內分頁 tab（例如 買超/賣超）--- */
.tab-link {
  text-decoration: none;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 14px;
  padding: 8px 18px;
  border-radius: 100px;
  background: var(--bg-input);
  transition: background 0.15s, color 0.15s;
}
.tab-link.active { color: white; background: var(--accent); }
.tab-link:not(.active):hover { color: var(--text); }
.tab-nav { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }

/* --- 投資工具箱：停損／風險報酬比量表 --- */
.stoploss-gauge-wrap { margin-top: 20px; }
.stoploss-gauge-wrap svg { width: 100%; height: auto; overflow: visible; }

/* --- 投資工具箱：相關性與對沖建議 --- */
.hedge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.hedge-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  text-align: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hedge-card:hover { transform: translateY(-2px); }
.hedge-card.hedge-good { border-color: var(--green); box-shadow: 0 0 14px rgba(62,207,142,0.25); }
.hedge-ticker { font-weight: 800; font-size: 16px; }
.hedge-name { font-size: 11.5px; margin-top: 2px; min-height: 28px; }
.hedge-corr { font-size: 20px; font-weight: 800; margin-top: 8px; }
.hedge-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(62,207,142,0.15);
  color: var(--green);
}

/* --- 表格分頁控制列（例如國會議員熱門標的） --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 18px;
  font-size: 14px;
}
.pagination button { padding: 8px 16px; font-size: 13.5px; }

/* --- 議員操盤績效榜：前三名頒獎台 --- */
.member-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  margin: 28px 0 20px;
}
.podium-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  padding: 30px 20px 20px;
  border-radius: var(--radius);
  background: var(--bg-input);
  border: 1px solid var(--border);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  width: 180px;
}
.podium-slot:hover { transform: translateY(-4px); }
.podium-slot[data-rank="1"] { order: 2; padding-top: 44px; width: 210px; z-index: 2; background: linear-gradient(180deg, rgba(255,213,74,0.12), var(--bg-input) 65%); border-color: rgba(255,213,74,0.4); }
.podium-slot[data-rank="2"] { order: 1; background: linear-gradient(180deg, rgba(201,211,224,0.10), var(--bg-input) 65%); border-color: rgba(201,211,224,0.35); }
.podium-slot[data-rank="3"] { order: 3; background: linear-gradient(180deg, rgba(217,155,95,0.10), var(--bg-input) 65%); border-color: rgba(217,155,95,0.35); }

.podium-rank-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px; color: #1a1200;
}
.podium-slot[data-rank="1"] .podium-rank-badge { background: linear-gradient(135deg, #ffe37a, #f0b429); }
.podium-slot[data-rank="2"] .podium-rank-badge { background: linear-gradient(135deg, #eef2f7, #b9c4d1); }
.podium-slot[data-rank="3"] .podium-rank-badge { background: linear-gradient(135deg, #e6b17e, #b6753c); }

.podium-crown {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 36px;
  filter: drop-shadow(0 3px 8px rgba(255,213,74,0.65));
  animation: podium-crown-bounce 1.6s ease-in-out infinite;
}
@keyframes podium-crown-bounce {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(-4deg); }
  50% { transform: translateX(-50%) translateY(-7px) rotate(4deg); }
}

.podium-avatar-wrap { position: relative; margin-bottom: 14px; }
.podium-avatar {
  border-radius: 50%;
  background: var(--bg-card);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}
.podium-slot[data-rank="1"] .podium-avatar { width: 116px; height: 116px; border: 4px solid #f0b429; }
.podium-slot[data-rank="2"] .podium-avatar { width: 92px; height: 92px; border: 4px solid #c9d3e0; }
.podium-slot[data-rank="3"] .podium-avatar { width: 88px; height: 88px; border: 4px solid #b6753c; }
.podium-avatar .member-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.podium-avatar.member-avatar-fallback { color: white; font-weight: 800; }
.podium-slot[data-rank="1"] .podium-avatar.member-avatar-fallback { font-size: 34px; }
.podium-slot[data-rank="2"] .podium-avatar.member-avatar-fallback,
.podium-slot[data-rank="3"] .podium-avatar.member-avatar-fallback { font-size: 26px; }

@keyframes podium-glow-gold {
  0%, 100% { box-shadow: 0 0 18px 4px rgba(255,213,74,0.5), 0 0 36px 10px rgba(255,213,74,0.22); }
  50% { box-shadow: 0 0 30px 9px rgba(255,213,74,0.85), 0 0 56px 16px rgba(255,213,74,0.38); }
}
@keyframes podium-glow-silver {
  0%, 100% { box-shadow: 0 0 12px 3px rgba(201,211,224,0.4); }
  50% { box-shadow: 0 0 20px 5px rgba(201,211,224,0.65); }
}
.podium-slot[data-rank="1"] .podium-avatar-wrap { border-radius: 50%; animation: podium-glow-gold 1.8s ease-in-out infinite; }
.podium-slot[data-rank="2"] .podium-avatar-wrap { border-radius: 50%; animation: podium-glow-silver 2.3s ease-in-out infinite; }
.podium-slot[data-rank="3"] .podium-avatar-wrap { border-radius: 50%; box-shadow: 0 0 12px 3px rgba(217,155,95,0.4); }

.podium-medal {
  position: absolute;
  bottom: -2px;
  right: -2px;
  font-size: 24px;
  z-index: 2;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}
.podium-slot[data-rank="1"] .podium-medal { font-size: 30px; }

.podium-name { font-weight: 800; font-size: 15px; line-height: 1.3; }
.podium-slot[data-rank="1"] .podium-name { font-size: 17px; }
.podium-return { font-weight: 800; font-size: 21px; margin-top: 6px; }
.podium-slot[data-rank="1"] .podium-return { font-size: 28px; }
.podium-sub { font-size: 11.5px; margin-top: 3px; }

/* --- 排名 4 以後：普通格狀清單，沒有頒獎台特效 --- */
.member-rest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.member-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  padding: 14px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease, transform 0.15s ease;
}
.member-card:hover { background: var(--bg-input); transform: translateY(-2px); }
.member-rank { position: absolute; top: 6px; left: 10px; font-size: 11px; color: var(--text-dim); font-weight: 700; }
.member-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin-bottom: 8px;
  background: var(--bg-input);
  border: 2px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.member-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.member-avatar.member-avatar-fallback {
  color: white;
  font-size: 18px;
  font-weight: 700;
  border-color: transparent;
}
.member-name { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.member-stats { font-size: 12px; font-weight: 700; margin-top: 3px; }

/* --- 名詞解釋小圖示（滑鼠移過去顯示說明） --- */
.info-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  border: 1px solid var(--text-dim);
  border-radius: 50%;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  margin-left: 5px;
  cursor: help;
  vertical-align: middle;
}
.info-tip .tip-box {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 130%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  width: 240px;
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  box-shadow: var(--shadow);
  z-index: 30;
  transition: opacity 0.15s;
  pointer-events: none;
}
.info-tip:hover .tip-box { visibility: visible; opacity: 1; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-dim); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--bg-hover); }
tr:last-child td { border-bottom: none; }
tfoot td { border-top: 2px solid var(--border); border-bottom: none; padding-top: 16px; }

.pos { color: var(--green); }
.neg { color: var(--red); }
.muted { color: var(--text-dim); }

.badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
}
.badge.buy { background: rgba(62,207,142,0.15); color: var(--green); }
.badge.hold { background: rgba(232,197,71,0.15); color: var(--yellow); }
.badge.trim, .badge.sell { background: rgba(241,101,101,0.15); color: var(--red); }

.report-block {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-top: 14px;
}
.report-block strong { font-size: 16px; }

.holding-detail { font-size: 15px; color: var(--text-dim); margin-top: 10px; line-height: 1.75; }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 8px;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.disclaimer {
  font-size: 13.5px;
  color: var(--text-dim);
  border-left: 3px solid var(--accent);
  padding: 12px 18px;
  background: var(--accent-dim);
  border-radius: 8px;
  margin-bottom: 24px;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}
/* 有些欄位的 label 文字比較長，換行後會變成兩行，把同一列的 input 往下擠，
   跟旁邊還是一行 label 的欄位對不齊。讓每個 .field 貼齊格子底部，這樣不管
   label 是一行還是兩行，下面的 input 永遠對齊同一條線。 */
.filters-grid .field { justify-content: flex-end; }

.candidate-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 16px;
  background: var(--bg-input);
}
.candidate-card h3 { margin: 0 0 8px; font-size: 18px; }
.candidate-card p { margin: 8px 0; }
.conviction-badge-高 { background: rgba(62,207,142,0.15); color: var(--green); }
.conviction-badge-中 { background: rgba(232,197,71,0.15); color: var(--yellow); }
.conviction-badge-低 { background: var(--bg-input); color: var(--text-dim); }

.allocation-wrap {
  display: flex;
  gap: 56px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
}
.allocation-wrap svg { max-width: 100%; height: auto; overflow: visible; }
.allocation-wrap .pie-label {
  font-size: 14px;
  font-weight: 700;
  fill: var(--text);
}
.allocation-wrap .pie-label-sub {
  font-size: 12px;
  fill: var(--text-dim);
}
/* 圓餅圖每一格：滑過會往外彈出一點並加上發光效果，吸引注意力 */
.pie-slice {
  transition: transform 0.22s ease, filter 0.22s ease, opacity 0.22s ease;
  transform-box: fill-box;
  cursor: pointer;
}
.pie-slice:hover,
.pie-slice.legend-hover {
  transform: translate(var(--tx, 0), var(--ty, 0)) scale(1.035);
  filter: drop-shadow(0 0 16px var(--glow, transparent)) brightness(1.15);
}
.allocation-wrap:has(.pie-slice:hover, .pie-slice.legend-hover) .pie-slice:not(:hover):not(.legend-hover) {
  opacity: 0.55;
}
/* 拉線標籤（線、點、文字）：跟對應的格子一起發光，不是只有格子本身亮 */
.pie-label-group {
  cursor: pointer;
  transition: opacity 0.22s ease;
}
.pie-label-group .pie-label,
.pie-label-group .pie-label-sub {
  transition: filter 0.22s ease, fill 0.22s ease;
}
.pie-label-group polyline { transition: stroke-width 0.22s ease, opacity 0.22s ease, filter 0.22s ease; }
.pie-label-group circle { transition: transform 0.22s ease, filter 0.22s ease; transform-box: fill-box; transform-origin: center; }
.pie-label-group.is-glow .pie-label {
  filter: drop-shadow(0 0 6px var(--glow, transparent));
  fill: #fff;
}
.pie-label-group.is-glow .pie-label-sub {
  filter: drop-shadow(0 0 5px var(--glow, transparent));
}
.pie-label-group.is-glow polyline {
  stroke-width: 3;
  opacity: 1;
  filter: drop-shadow(0 0 4px var(--glow, transparent));
}
.pie-label-group.is-glow circle {
  transform: scale(1.6);
  filter: drop-shadow(0 0 6px var(--glow, transparent));
}
.allocation-wrap:has(.pie-slice:hover, .pie-slice.legend-hover) .pie-label-group:not(.is-glow) {
  opacity: 0.45;
}
.allocation-toggle { display: flex; gap: 8px; margin-bottom: 16px; }
.allocation-toggle button { padding: 7px 16px; font-size: 13px; }

/* --- 市場雷達：VIX 儀表板 --- */
.vix-gauge-wrap { padding: 8px 0; }
@keyframes vix-panic-pulse {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(241,101,101,0.35)); }
  50% { filter: drop-shadow(0 0 24px rgba(241,101,101,0.75)); }
}
.vix-gauge-wrap.vix-panic svg { animation: vix-panic-pulse 1.6s ease-in-out infinite; }

/* --- 市場雷達：殖利率利差 --- */
.yield-curve-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* --- 籌碼雷達：機構持倉 (13F) --- */
.institution-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.institution-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--inst-color, var(--accent));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.institution-name { font-weight: 800; font-size: 16px; margin-bottom: 4px; }
.inst-holding-row { margin-bottom: 10px; }
.inst-holding-bar-wrap { background: var(--bg-input); border-radius: 100px; height: 8px; overflow: hidden; margin-bottom: 4px; }
.inst-holding-bar { height: 100%; border-radius: 100px; transition: width 0.4s ease; }
.inst-holding-label { display: flex; justify-content: space-between; font-size: 12.5px; }
.inst-holding-name { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.inst-holding-pct { color: var(--text-dim); flex-shrink: 0; margin-left: 8px; }

/* --- 籌碼雷達：內部人動向 (Form 4) --- */
.insider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.insider-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s ease;
}
.insider-card:hover { transform: translateY(-3px); }
.insider-ticker { font-weight: 800; font-size: 18px; margin-top: 6px; }
.insider-counts { display: flex; justify-content: center; gap: 12px; margin-top: 8px; font-size: 13px; font-weight: 700; }
@keyframes insider-cluster-glow {
  0%, 100% { box-shadow: 0 0 12px 2px rgba(62,207,142,0.35); }
  50% { box-shadow: 0 0 22px 6px rgba(62,207,142,0.65); }
}
.insider-card.insider-cluster { border-color: var(--green); animation: insider-cluster-glow 1.8s ease-in-out infinite; }
.insider-cluster-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green);
  color: #06301d;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 100px;
  white-space: nowrap;
}

/* --- 籌碼雷達：資金流向（科幻感粒子流動視覺化） --- */
.flow-viz-wrap {
  display: flex;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(91,140,255,0.06) 0%, transparent 70%);
  border-radius: var(--radius);
}
.flow-viz-wrap svg { max-width: 900px; width: 100%; height: auto; overflow: visible; }

@keyframes flow-core-breathe {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 0.9; transform: scale(1.18); }
}
.flow-core-pulse { transform-box: fill-box; transform-origin: center; animation: flow-core-breathe 2.4s ease-in-out infinite; }

.flow-guide { transition: opacity 0.2s ease; }
.flow-guide-in { stroke-dasharray: 5 9; animation: flow-dash-forward 1s linear infinite; }
.flow-guide-out { stroke-dasharray: 5 9; animation: flow-dash-forward 1s linear infinite reverse; }
@keyframes flow-dash-forward { to { stroke-dashoffset: -28; } }

.flow-particle-in { filter: drop-shadow(0 0 6px rgba(62,207,142,0.95)) drop-shadow(0 0 12px rgba(62,207,142,0.5)); }
.flow-particle-out { filter: drop-shadow(0 0 6px rgba(241,101,101,0.95)) drop-shadow(0 0 12px rgba(241,101,101,0.5)); }

.flow-node text { pointer-events: none; }

.flow-legend {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-dim);
}
.flow-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* ============================================================
   資金建議：AI Portfolio Strategy + AI Opportunities Dashboard
   ============================================================ */

.section-eyebrow {
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin: 28px 0 16px;
}

/* --- AI Portfolio Strategy 區塊 --- */
.ai-strategy-card { margin-bottom: 8px; }
.ai-strategy-header-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.ai-strategy-header-row h2 { margin: 0; }
.ai-strategy-headline {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.6;
  margin: 4px 0 10px;
}
.ai-strategy-expand-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  margin-bottom: 12px;
}
.ai-strategy-expand-btn:hover { text-decoration: underline; }
.ai-strategy-full {
  font-size: 14px;
  line-height: 1.75;
  color: var(--text-dim);
  margin: -4px 0 16px;
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
}
.ai-strategy-stats { margin: 4px 0 18px; }
.ai-strategy-buckets {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bucket-row {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
}
.bucket-row.bucket-buy { color: var(--green); }
.bucket-row.bucket-watch { color: var(--yellow); }
.bucket-row.bucket-avoid { color: var(--text-dim); }

/* --- Stock 卡片 Grid --- */
.ai-stock-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
@media (max-width: 1100px) { .ai-stock-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .ai-stock-grid { grid-template-columns: 1fr; } }

.ai-stock-card {
  background: transparent;
  perspective: 1200px;
  height: 560px;
  cursor: pointer;
  outline: none;
  transition: transform 0.25s ease;
}
/* Hover 上浮效果放在最外層、不參與 3D 翻牌的這個元素上，不要放在
   .ai-card-face（同時有 backface-visibility:hidden 又有 backdrop-filter）
   ——那個組合在部分瀏覽器會讓「應該被翻到背面藏起來」的那一面在 hover
   觸發 transform 重繪時短暫穿幫，看起來就像滑鼠移上去卡片就自己翻過去了。 */
.ai-stock-card:hover { transform: translateY(-4px); }
.ai-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}
.ai-stock-card.is-flipped .ai-card-inner { transform: rotateY(180deg); }
.ai-stock-card:focus-visible .ai-card-inner { box-shadow: 0 0 0 2px var(--accent); border-radius: 14px; }
.ai-card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  /* 這裡刻意不用 backdrop-filter：這個元素本來就要靠 backface-visibility:hidden
     把「背面」完全藏起來做 3D 翻牌，backdrop-filter 會逼瀏覽器另外開一個合成
     層，兩者疊在一起在部分瀏覽器會讓翻牌機制失靈（滑鼠移過去就看得到背面內容，
     不用點擊）。改用不透明底色，一樣有暗色卡片的質感，但不會破壞翻牌。 */
  background: var(--bg-card);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  overflow: hidden;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}
.ai-stock-card.ai-stock-card-first .ai-card-face {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}
.ai-card-back {
  transform: rotateY(180deg);
  overflow-y: auto;
  /* 細一點、跟卡片同色調的捲軸，取代預設的系統捲軸樣式 */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.ai-card-back::-webkit-scrollbar { width: 6px; }
.ai-card-back::-webkit-scrollbar-track { background: transparent; }
.ai-card-back::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}
.ai-card-back::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
.ai-stock-card:hover .ai-card-face {
  border-color: color-mix(in srgb, var(--ai-cyan) 45%, var(--border));
  box-shadow:
    0 0 16px color-mix(in srgb, var(--ai-cyan) 30%, transparent),
    0 0 16px color-mix(in srgb, var(--ai-purple) 20%, transparent),
    0 14px 30px rgba(0, 0, 0, 0.35);
}
.ai-stock-card:hover .ai-score-ring-fg { filter: drop-shadow(0 0 5px color-mix(in srgb, var(--ai-cyan) 60%, transparent)); }
.ai-stock-card:hover .ai-sparkline { transform: scale(1.03); }

/* 正面內容 */
.ai-card-top-row { display: flex; align-items: center; justify-content: space-between; }
.ai-card-rank { font-size: 12px; font-weight: 700; color: var(--text-dim); letter-spacing: 0.04em; }
.ai-card-ticker { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }

.ai-card-price-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-top: 10px;
}
.ai-card-price { font-size: 26px; font-weight: 700; }
.ai-card-trend { font-size: 12.5px; font-weight: 600; }
.ai-card-trend .muted { font-weight: 500; font-size: 11px; }

.ai-score-wrap {
  position: relative;
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 10px 0 4px;
  transition: transform 0.2s ease;
}
.ai-score-ring-bg { stroke: var(--border); }
/* stroke 顏色改由 SVG 自帶的漸層 <linearGradient> 決定（見 cash-advice.js 的
   renderScoreRing），這裡就不再用純色蓋掉它，只留線帽形狀跟 hover 的發光動畫。 */
.ai-score-ring-fg { stroke-linecap: round; transition: filter 0.2s ease; }
.ai-score-center {
  position: absolute;
  top: 0; left: 0; width: 92px; height: 92px;
  display: flex; align-items: center; justify-content: center;
}
.ai-score-value { font-size: 26px; font-weight: 700; }
.ai-score-signal {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 10px;
  border-radius: 999px;
}
.ai-score-signal.signal-buy { color: var(--green); background: rgba(62,207,142,0.12); }
.ai-score-signal.signal-watch { color: var(--yellow); background: rgba(232,197,71,0.12); }
.ai-score-signal.signal-avoid { color: var(--text-dim); background: var(--bg-input); }

.ai-sparkline-wrap { margin: 4px 0 8px; }
.ai-sparkline { width: 100%; height: 52px; display: block; transition: transform 0.2s ease; }
.ai-sparkline-empty {
  height: 52px; display: flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-dim);
}

.ai-card-target-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.ai-card-target-cell { flex: 1; }
.ai-card-target-cell .label { font-size: 11px; color: var(--text-dim); margin-bottom: 2px; }
.ai-card-target-cell .value { font-size: 15px; font-weight: 700; }

.ai-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
  min-height: 26px;
}
.ai-tag {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.ai-tag:hover { border-color: var(--accent); }
.ai-tag-warn { color: var(--yellow); border-color: color-mix(in srgb, var(--yellow) 40%, var(--border)); }
.ai-tag-empty { font-size: 12px; }

.ai-card-amount-row {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-top: 8px;
}
.ai-card-amount-row .label { font-size: 12px; color: var(--text-dim); }
.ai-card-amount-row .value { font-size: 19px; font-weight: 700; color: var(--accent); }

.flip-hint {
  margin-top: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  opacity: 0.75;
  text-align: right;
}

/* 標籤詳細解釋：蓋在正面卡片上的浮層，不影響卡片高度 */
.ai-tag-detail {
  position: absolute;
  inset: 0;
  background: var(--bg-card);
  border-radius: 14px;
  padding: 20px;
  flex-direction: column;
  gap: 10px;
  z-index: 2;
}
/* [hidden] 屬性跟這個 class 選擇器的 specificity 相同，用 :not([hidden]) 確保
   沒有 hidden 屬性時才套用 display:flex，避免蓋掉原生的 hidden 隱藏效果。 */
.ai-tag-detail:not([hidden]) { display: flex; }
.ai-tag-detail-close {
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.ai-tag-detail-title { font-size: 16px; font-weight: 700; }
.ai-tag-detail-body p { font-size: 14px; line-height: 1.7; color: var(--text-dim); margin: 0; }

/* 背面內容 */
.ai-card-back h3 { margin: 0 0 8px; font-size: 17px; }
.ai-back-action { font-weight: 600; color: var(--accent); margin: 0 0 8px; }
.ai-back-subtitle {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 14px 0 6px;
}
.ai-back-risk ul { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.7; color: var(--yellow); }

.ai-buy-zone { margin-top: 14px; }
.ai-buy-zone-title {
  font-size: 12px; font-weight: 700; letter-spacing: 0.06em; color: var(--text-dim); margin-bottom: 8px;
}
.buy-zone-row {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  padding: 4px 0;
}
.buy-zone-price { font-weight: 700; text-align: right; }
.buy-zone-bar { position: relative; height: 6px; border-radius: 999px; background: var(--bg-input); overflow: hidden; }
.buy-zone-bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 999px; }
.buy-zone-label { color: var(--text-dim); white-space: nowrap; }
.buy-zone-row.buy-zone-current .buy-zone-price,
.buy-zone-row.buy-zone-current .buy-zone-label { color: var(--text); }
.buy-zone-row.buy-zone-current .buy-zone-bar-fill { background: var(--text); }

@media (prefers-reduced-motion: reduce) {
  .ai-card-inner, .ai-score-ring-fg, .ai-sparkline, .ai-stock-card .ai-card-face, .ai-stock-card {
    transition: none !important;
  }
}
.allocation-legend {
  flex: 0 1 460px;
  min-width: 300px;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.allocation-legend .legend-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 16.5px;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.2s ease, transform 0.2s ease;
}
.allocation-legend .legend-row.is-active {
  background: var(--bg-input);
  transform: translateX(2px);
}
.allocation-legend .swatch {
  width: 15px; height: 15px;
  border-radius: 4px;
  flex-shrink: 0;
}
.allocation-legend .legend-name { flex: 1; font-weight: 600; }
.allocation-legend .legend-value { color: var(--text-dim); }
.allocation-legend .legend-pct { min-width: 60px; text-align: right; font-weight: 700; }

/* --- 賣出彈窗 --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,8,14,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 32px;
  width: 100%;
  max-width: 420px;
}
.modal-box h3 { margin: 0 0 18px; }
.modal-box .form-row { flex-direction: column; align-items: stretch; gap: 14px; }
.modal-box .field { width: 100%; }
.modal-box input { width: 100%; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

.ai-cell { font-size: 13.5px; line-height: 1.5; white-space: normal; max-width: 320px; }

.source-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 11.5px;
  font-weight: 600;
}
.source-badge.existing { background: rgba(91,140,255,0.15); color: var(--accent); }
.source-badge.new { background: rgba(232,197,71,0.15); color: var(--yellow); }
.ai-cell .fair-value { color: var(--text-dim); }
.ai-cell .sell-at { color: var(--yellow); }
.ai-cell .no-analysis { color: var(--text-dim); font-style: italic; }

.empty-state { color: var(--text-dim); text-align: center; padding: 40px 0; font-size: 15px; }
.error-box {
  background: rgba(241,101,101,0.1);
  border: 1px solid var(--red);
  color: var(--red);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
  font-size: 14px;
}

/* --- Toast 提示（取代 alert()） --- */
#toast-host {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
  cursor: pointer;
  opacity: 0;
  transform: translateX(24px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-icon {
  flex-shrink: 0;
  width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
  background: var(--accent-dim); color: var(--accent);
}
.toast-success { border-left-color: var(--green); }
.toast-success .toast-icon { background: rgba(62,207,142,0.15); color: var(--green); }
.toast-error { border-left-color: var(--red); }
.toast-error .toast-icon { background: rgba(241,101,101,0.15); color: var(--red); }
.toast-warning { border-left-color: var(--yellow); }
.toast-warning .toast-icon { background: rgba(232,197,71,0.15); color: var(--yellow); }

/* --- 骨架屏（載入中的灰色閃爍區塊，取代純文字「載入中…」） --- */
@keyframes skel-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skel-line, .skel-card {
  background: linear-gradient(90deg, var(--bg-input) 25%, var(--bg-hover) 50%, var(--bg-input) 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}
.skel-line { height: 16px; margin: 10px 0; }
.skel-card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.skel-card { padding: 18px; border-radius: var(--radius); }
.skel-card .skel-line:first-child { margin-top: 0; }

/* --- 進場動畫：卡片淡入＋輕微上移，吸引目光但不會每次刷新都干擾閱讀 --- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.enter-anim { animation: fadeInUp 0.45s ease both; }

/* --- 個股迷你走勢圖（sparkline） --- */
.sparkline-cell { display: inline-block; vertical-align: middle; }
.sparkline-cell svg { display: block; }

@media (max-width: 720px) {
  header.topbar { padding: 14px 16px; gap: 12px; }
  .nav-toggle { display: flex; }
  /* nav 本身變成從右邊滑出的側邊抽屜，平常關閉、按漢堡鈕才打開，
     不再跟著 topbar 一起把 8 個分頁擠成一排。 */
  header.topbar nav {
    position: fixed;
    top: 0;
    right: 0;
    /* 明確給 100vh，不要只靠 top:0 + bottom:0 讓瀏覽器自己算高度——
     這裡量到某些情況下算出來的高度會被壓縮成只有一小塊（可能是父層
     header.topbar 的 flex align-items:center 影響到了），直接寫死
     100vh 最保險，一定會撐滿整個螢幕高度。 */
    height: 100vh;
    width: 78vw;
    max-width: 300px;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 84px 16px 24px;
    margin: 0;
    /* 底色本來是半透明+模糊（backdrop-filter），但這個組合（position:fixed +
       transform 動畫 + backdrop-filter）在部分手機瀏覽器上會讓裡面的連結
       點擊沒反應（已知的 WebKit 合成/觸控判定問題）。改成幾乎不透明的實色，
       視覺上差異很小，但換掉這個可能的問題來源。 */
    background: #0d1119;
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    /* 故意不加滑動動畫：抽屜滑入的這 0.25 秒之間，連結還沒到定位，
       使用者一快速點擊反而會點到底下的 backdrop（變成選單自己關起來、
       沒有跳轉），這正是這次回報「點了沒反應」的原因。開合直接瞬間
       切換，比較不精緻，但保證點下去連結一定已經在正確位置上。 */
    z-index: 20;
    overflow-y: auto;
  }
  header.topbar nav.nav-open { transform: translateX(0); }
  header.topbar nav a {
    white-space: nowrap;
    padding: 13px 16px;
    font-size: 15px;
    border-radius: 10px;
    text-align: left;
  }
  main { padding: 20px 16px 40px; }
  .card { padding: 18px 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-card { padding: 16px 18px; }
  .stat-card .stat-value { font-size: 24px; }
  .form-row { gap: 10px; }
  .field, input, select { min-width: 0; }
  .form-row .field { flex: 1 1 140px; }
  table { font-size: 13.5px; }
  th, td { padding: 10px 10px; }
  .allocation-wrap { gap: 24px; }
  .allocation-legend { min-width: 0; width: 100%; max-width: 100%; }
  .modal-box { padding: 20px; margin: 16px; }
  #toast-host { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }

  /* 議員操盤績效榜：桌機版用「2-1-3」頒獎台排法（第一名擺中間、墊高），
     靠 order 屬性重排視覺順序。手機版每個 podium-slot 都寬到會各自獨占
     一行，這時候 order 還留著會變成「第2名排最上面」，看起來像排名顛倒。
     窄螢幕改回真正的名次直排（1 在最上面），並取消頒獎台特有的墊高/加寬。 */
  .member-podium { flex-direction: column; align-items: stretch; gap: 12px; }
  .podium-slot,
  .podium-slot[data-rank="1"],
  .podium-slot[data-rank="2"],
  .podium-slot[data-rank="3"] {
    order: 0;
    width: auto;
    padding-top: 20px;
  }

  /* 分頁內的三個切換按鈕（例如籌碼雷達的 資金流向/機構持倉/內部人動向）：
     維持同一排，擠不下就整排橫向捲動，不要換行變成「最後一個自己一行」。 */
  .tab-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }
  .tab-link {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 7px 14px;
    font-size: 13px;
  }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  header.topbar h1, header.topbar .brand { font-size: 17px; }
}

/* ============================================================
   潛力股掃描：Filter Bar / 資料表視覺化 / AI 質化分析卡片
   ============================================================ */

/* --- 可收合的 Filter Bar --- */
.filter-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.filter-bar-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 8px;
  cursor: pointer;
}
.filter-bar-toggle:hover { text-decoration: underline; }
.filter-bar-body {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.3s ease;
}
.filter-bar-body > form { overflow: hidden; min-height: 0; }
.filter-bar-body.is-collapsed { grid-template-rows: 0fr; }
.filter-bar-body.is-collapsed > form { opacity: 0; transition: opacity 0.15s ease; }

/* --- Pill Tags（取代 checkbox）--- */
.pill-tag-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.pill-tag {
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.pill-tag:hover { border-color: var(--accent); }
.pill-tag.pill-tag-active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* --- 資料表分頁 --- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 18px;
}
.pagination-status { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.pagination-btn {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.pagination-btn:hover:not(:disabled) { border-color: var(--accent); }
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- 資料表：RSI 環形量表 / 分析師徽章發光 / 列 hover --- */
.table-scroll { overflow-x: auto; }
.rsi-gauge { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; vertical-align: middle; }
.rsi-gauge-value { position: absolute; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.badge-glow { box-shadow: 0 0 10px color-mix(in srgb, currentColor 35%, transparent); }
tbody tr {
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
tbody tr:hover {
  background: var(--bg-hover);
  box-shadow: inset 3px 0 0 var(--accent);
}

/* --- AI 質化分析：Grid 卡片 --- */
.ai-quant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  /* Grid 預設會把同一列所有格子拉伸到跟最高的一樣高，所以某張卡片展開變高時，
     同一排的其他卡片也會被拉高（即使它們自己還是收合狀態），看起來像整排都
     展開了。改成 start，每張卡片各自維持自己內容決定的高度，互不影響。 */
  align-items: start;
}
@media (min-width: 1100px) { .ai-quant-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 1099px) and (min-width: 700px) { .ai-quant-grid { grid-template-columns: repeat(2, 1fr); } }

.ai-quant-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
}
.ai-quant-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.ai-quant-ticker { font-size: 19px; font-weight: 700; margin-right: 10px; }
.ai-quant-price { font-size: 14px; color: var(--text-dim); font-weight: 600; }
.conviction-badge { font-size: 11.5px; padding: 3px 11px; }

.ai-quant-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.ai-quant-tile {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.ai-quant-tile .label { font-size: 11px; color: var(--text-dim); margin-bottom: 2px; }
.ai-quant-tile .value { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }

.ai-quant-headline {
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.7;
  margin: 0 0 10px;
  min-height: 1.7em;
}
.ai-typewriter-cursor::after {
  content: "▋";
  margin-left: 2px;
  opacity: 0.8;
  animation: ai-blink 0.8s step-start infinite;
}
@keyframes ai-blink { 50% { opacity: 0; } }

.ai-quant-entry-box {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 10px;
}
.ai-quant-body {
  position: relative;
  max-height: 190px;
  overflow: hidden;
  transition: max-height 0.35s ease;
}
.ai-quant-body.is-expanded { max-height: 2000px; }
.ai-quant-body .ai-quant-fade {
  position: absolute;
  left: 0; right: 0; bottom: 0; height: 40px;
  background: linear-gradient(to bottom, transparent, var(--bg-input));
  pointer-events: none;
}
.ai-quant-body.is-expanded .ai-quant-fade { display: none; }
.ai-quant-section { margin-bottom: 10px; }
.ai-quant-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.ai-quant-section ul { margin: 0; padding-left: 18px; font-size: 13.5px; line-height: 1.7; color: var(--text); }
.ai-keyword {
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-weight: 700;
}
.ai-quant-expand-btn {
  align-self: flex-start;
  margin-top: 10px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}
.ai-quant-expand-btn:hover { text-decoration: underline; }

@media (prefers-reduced-motion: reduce) {
  .filter-bar-body, .ai-quant-body, tbody tr { transition: none !important; }
}

/* ===== 方案：升級卡片、header 方案標籤、價格表（2026-10） ===== */
.upgrade-backdrop { position: fixed; inset: 0; background: rgba(5, 8, 20, 0.72); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.upgrade-card { position: relative; max-width: 440px; width: 100%; background: #111a33; color: #e8ecf8; border: 1px solid rgba(255, 196, 77, 0.45); border-radius: 14px; padding: 24px 22px 18px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.upgrade-card h2 { margin: 6px 0 8px; font-size: 1.25rem; }
.upgrade-tag { display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; color: #1a1300; background: #ffc44d; border-radius: 999px; padding: 2px 10px; }
.upgrade-close { position: absolute; top: 8px; right: 12px; background: none; border: 0; color: inherit; font-size: 1.5rem; cursor: pointer; }
.upgrade-msg { opacity: 0.9; }
.upgrade-benefits { margin: 10px 0; padding-left: 1.2em; line-height: 1.7; }
.upgrade-price { font-size: 1.4rem; font-weight: 700; color: #ffc44d; margin: 8px 0 4px; }
.upgrade-note, .upgrade-contact, .upgrade-more { font-size: 0.9rem; opacity: 0.9; margin: 4px 0; }
.upgrade-card a { color: #8ab4ff; }
.auth-badge-plan { font-size: 0.72rem; font-weight: 700; border-radius: 999px; padding: 2px 8px; border: 1px solid rgba(255, 255, 255, 0.3); color: inherit; text-decoration: none; }
.auth-badge-pro { background: #ffc44d; color: #1a1300; border-color: #ffc44d; }
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 12px 0; }
.pricing-card { border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 12px; padding: 16px 18px; }
.pricing-card-pro { border-color: #ffc44d; }
.pricing-price { font-size: 1.6rem; font-weight: 700; margin: 4px 0 8px; }
.pricing-price span { font-size: 0.9rem; font-weight: 400; opacity: 0.8; }
.plan-table td, .plan-table th { padding: 4px 8px; text-align: left; }

/* SEO：首頁描述性 H1（logo 不再用 h1） */
.home-h1 { font-size: clamp(15px, 2.2vw, 19px); font-weight: 600; color: var(--text-dim, #b8c2d9); margin: 4px 0 10px; letter-spacing: 0.02em; line-height: 1.5; }
/* 公開頁固定免責聲明 */
.site-disclaimer { max-width: 960px; margin: 28px auto 24px; padding: 12px 16px 0; border-top: 1px solid rgba(255,255,255,.12); font-size: 12.5px; line-height: 1.7; color: var(--text-dim, #b8c2d9); text-align: center; }

.home-lead { max-width: 760px; margin: 12px auto 0; font-size: 14.5px; line-height: 1.8; color: var(--text-dim, #b8c2d9); }
.home-faq { max-width: 960px; margin: 36px auto 0; padding: 0 16px; }
.home-faq h2 { font-size: 20px; margin-bottom: 8px; }
.home-faq h3 { font-size: 15.5px; margin: 18px 0 6px; }
.home-faq p { font-size: 14px; line-height: 1.75; color: var(--text-dim, #b8c2d9); margin: 0; }

.ai-output-note { font-size: 12px; line-height: 1.6; color: var(--text-dim, #b8c2d9); margin: 10px 0 0; opacity: .9; }
