        /* ── Design Tokens ─────────────────────────────────── */
        :root {
            --font-sans: 'Outfit', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', sans-serif;
            --color-bg: #f0f3f8;
            --color-surface: #ffffff;
            --color-surface-alt: #e2e8f0;
            --color-border: #e2e8f0;
            --color-border-light: #edf2f7;
            --color-primary: #3b82f6;
            --color-primary-dark: #2563eb;
            --color-primary-soft: #eff6ff;
            --color-teal: #0d9488;
            --color-teal-soft: #f0fdfa;
            --color-text: #1e293b;
            --color-text-muted: #64748b;
            --color-text-subtle: #94a3b8;
            --color-up: #dc2626;
            --color-down: #16a34a;
            --radius-sm: 8px;
            --radius-md: 12px;
            --radius-lg: 16px;
            --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
            --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
            --shadow-lg: 0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.05);
            --color-financial-divider-bg: #edf2f7;
            --color-financial-divider-text: #4a5568;
            --color-financial-year-bg: #f7fafc;
            --color-financial-year-text: #1e293b;
            --color-financial-year-label: #2b6cb0;
            --color-financial-estimate-bg: #fefce8;
            --color-financial-estimate-text: #854d0e;
            --color-financial-estimate-label: #b45309;
            /* light 主題 --color-border 跟 --color-surface-alt 剛好同色（#e2e8f0），
               疊在 surface-alt 背景上的邊框（如 chip）會被吃掉，故另立一階更深的灰 */
            --color-chip-border: #cbd5e1;
        }

        body.dark-theme {
            --color-bg: #0f172a;
            --color-surface: #1e293b;
            --color-surface-alt: #0f172a;
            --color-border: #334155;
            --color-border-light: #1e293b;
            --color-primary: #3b82f6;
            --color-primary-dark: #60a5fa;
            --color-primary-soft: rgba(59, 130, 246, 0.15);
            --color-teal-soft: rgba(13, 148, 136, 0.15);
            --color-text: #f8fafc;
            --color-text-muted: #94a3b8;
            --color-text-subtle: #64748b;
            --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
            --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
            --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);
            --color-financial-divider-bg: #334155;
            --color-financial-divider-text: #cbd5e1;
            --color-financial-year-bg: #0f172a;
            --color-financial-year-text: #f8fafc;
            --color-financial-year-label: #60a5fa;
            --color-financial-estimate-bg: #422006;
            --color-financial-estimate-text: #fde68a;
            --color-financial-estimate-label: #fbbf24;
            --color-chip-border: var(--color-border);   /* dark 主題本來就與 surface-alt 有足夠對比 */
        }
        
        body.dark-theme .controls {
            background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
        }
        body.dark-theme .strategy-desc-box ol {
            color: #fca5a5;
        }
        body.dark-theme .strategy-desc-box ol li strong {
            color: #fecaca;
        }
        body.dark-theme .strategy-param-badge.modified {
            color: #fca5a5;
            border-color: rgba(252, 165, 165, 0.3);
            background: rgba(220, 38, 38, 0.12);
        }
        body.dark-theme .data-table tbody tr:hover {
            background: #2d3748;
        }
        body.dark-theme #cardHistockLink,
        body.dark-theme #cardYahooLink,
        body.dark-theme #cardGoogleNewsLink {
            background: var(--color-surface) !important;
        }

        body.dark-theme .login-overlay {
            background: rgba(15, 23, 42, 0.8);
        }
        body.dark-theme .login-card {
            background: var(--color-surface);
            border-color: var(--color-border);
            color: var(--color-text);
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
        }
        body.dark-theme .login-card .feature-item {
            color: var(--color-text) !important;
        }
        body.dark-theme .login-card .btn-google {
            background: #1e293b;
            color: #f8fafc;
            border-color: #334155;
        }
        body.dark-theme .login-card .btn-google:hover {
            background: #334155;
            border-color: #475569;
        }

        .btn-theme-toggle {
            background: none;
            border: none;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            width: 32px;
            height: 32px;
            border-radius: 50%;
            color: var(--color-text);
            transition: all 0.2s ease;
        }
        .btn-theme-toggle:hover {
            background: var(--color-border-light);
            transform: scale(1.08);
        }

        /* ── Base ──────────────────────────────────────────── */
        *, *::before, *::after { box-sizing: border-box; }
        html { scrollbar-gutter: stable; }
        body {
            font-family: var(--font-sans);
            background: var(--color-bg);
            margin: 0;
            padding: 20px;
            -webkit-text-size-adjust: 100%;
            text-size-adjust: 100%;
            display: flex;
            flex-direction: column;
            align-items: center;
            min-height: 100vh;
            color: var(--color-text);
        }

        /* ── Layout ────────────────────────────────────────── */
        .main-wrapper {
            width: 98%;
            max-width: 1240px;
            background: var(--color-surface);
            padding: 10px 24px 24px;
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-lg);
            transition: min-height 0.5s cubic-bezier(0.25, 0.8, 0.25, 1), padding 0.5s ease;
        }
        .main-wrapper.discussion-mode {
            padding-bottom: 8px;
        }

        /* ── Controls Bar ──────────────────────────────────── */
        .controls {
            width: 100%;
            box-sizing: border-box;
            margin-bottom: 20px;
            display: flex;
            gap: 10px;
            justify-content: center;
            align-items: center;
            padding: 14px 20px;
            background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
            border-radius: var(--radius-md);
            border: 1px solid var(--color-border);
            flex-wrap: wrap;
            transition: all 0.4s ease;
            box-shadow: var(--shadow-sm);
        }

        /* ── Form Controls ─────────────────────────────────── */
        input:not([type="checkbox"]):not([type="radio"]), select {
            padding: 9px 13px;
            border-radius: var(--radius-sm);
            border: 1.5px solid var(--color-border);
            font-size: 13.5px;
            font-family: var(--font-sans);
            outline: none;
            background: var(--color-surface);
            color: var(--color-text);
            transition: border-color 0.2s, box-shadow 0.2s;
        }
        input:not([type="checkbox"]):not([type="radio"]):focus, select:focus {
            border-color: var(--color-primary);
            box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
        }
        button {
            padding: 9px 16px;
            border-radius: var(--radius-sm);
            border: none;
            font-size: 13.5px;
            font-family: var(--font-sans);
            font-weight: 600;
            cursor: pointer;
            outline: none;
            background: var(--color-primary);
            color: white;
            transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
            box-shadow: 0 2px 6px rgba(59,130,246,0.3);
        }
        button:hover {
            background: var(--color-primary-dark);
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(59,130,246,0.35);
        }
        button:active { transform: translateY(0); }
        .btn-anomaly-chart { background: #6366f1; box-shadow: 0 2px 6px rgba(99,102,241,0.35); }
        .btn-anomaly-chart:hover { background: #4f46e5; box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
        /* ── Toolbar Buttons (Layer 2) ── */
        /* 查詢個股：繼承全域 button（主色藍）*/
        /* 多策略交集：teal（由 inline style 設定）*/
        .btn-settings {
            background: #475569;
            box-shadow: 0 2px 6px rgba(71,85,105,0.25);
        }
        .btn-settings:hover {
            background: #334155;
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(71,85,105,0.35);
        }

        /* ── Loading ───────────────────────────────────────── */
        .loading {
            display: none;
            align-items: center;
            gap: 5px;
            white-space: nowrap;
        }
        .spinner {
            width: 16px;
            height: 16px;
            border: 2px solid rgba(220, 38, 38, 0.2);
            border-top: 2px solid #dc2626;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        /* ── Icon ──────────────────────────────────────────── */
        .icon {
            display: inline-block;
            width: 1.05em;
            height: 1.05em;
            stroke-width: 2;
            vertical-align: -0.15em;
            fill: none;
            stroke: currentColor;
            flex-shrink: 0;
        }
        .title-icon {
            margin-right: 5px;
            color: var(--color-teal);
        }

        /* ── Charts ────────────────────────────────────────── */
        .charts-row {
            display: flex;
            flex-direction: row;
            gap: 12px;
            width: 100%;
            justify-content: space-between;
        }
        .chart-box {
            flex: 1;
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            padding: 10px 8px 6px;
            background: var(--color-surface);
            min-width: 0;
            box-shadow: var(--shadow-sm);
        }
        h3 {
            font-size: 0.85em;
            font-weight: 600;
            margin: 0 0 8px 0;
            color: var(--color-text-muted);
            background: var(--color-surface-alt);
            padding: 6px 10px;
            border-radius: 6px;
            letter-spacing: 0.3px;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
            gap: 4px;
        }

        /* ── Summary Panel Cards ───────────────────────────── */
        .summary-panel {
            margin-top: 20px;
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 14px;
            width: 100%;
        }
        .summary-card {
            background: var(--color-surface-alt);
            padding: 14px;
            border-radius: var(--radius-md);
            text-align: center;
            border: 1px solid var(--color-border);
            box-shadow: var(--shadow-sm);
        }
        .summary-card .label {
            font-size: 0.78em;
            font-weight: 500;
            color: var(--color-text-subtle);
            margin-bottom: 4px;
        }
        .summary-card .value {
            font-size: 1.15em;
            font-weight: 700;
            color: var(--color-text);
        }

        /* ── Data Cards (info panels) ──────────────────────── */
        .data-card {
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            padding: 14px 18px;
            box-shadow: var(--shadow-sm);
            overflow-x: auto;
            box-sizing: border-box;
        }
        .data-card h4 {
            margin: 0 0 10px 0;
            font-size: 0.88em;
            font-weight: 600;
            color: var(--color-text);
            border-bottom: 1.5px solid var(--color-border-light);
            padding-bottom: 7px;
            display: flex;
            align-items: center;
            gap: 5px;
        }

        /* ── Table Shared ──────────────────────────────────── */
        .data-table {
            width: 100%;
            border-collapse: collapse;
            text-align: center;
            font-size: 0.84em;
        }
        .data-table thead tr {
            background: var(--color-surface-alt);
            color: var(--color-text-muted);
            border-bottom: 2px solid var(--color-border);
            font-weight: 600;
        }
        .data-table th { padding: 7px 10px; white-space: nowrap; }
        .data-table tbody tr {
            transition: background 0.15s ease;
        }
        .data-table tbody tr:hover { background: #f8faff; }
        .data-table td { padding: 5px 10px; color: var(--color-text); border-bottom: 1px solid var(--color-border-light); }

        /* 全站「代號／名稱」欄統一樣式（基準：概念股明細）：代號＝主色粗體錨點、名稱＝一般文字色 semibold。
           新增顯示代號/名稱的表格一律掛這兩個 class，不要各自寫 inline 字型/顏色；
           可點擊與否由各處自行加 cursor/onclick/tooltip */
        /* 帶 .data-table td 的變體是為了壓過上面 .data-table td 的 color（specificity 0,1,1 > 0,1,0），
           否則掛在 td 上的代號會變回一般文字色、跟掛在 span 上的（popover）不一致 */
        .stock-code-cell, .data-table td.stock-code-cell { color: var(--color-primary); font-weight: 700; white-space: nowrap; }
        .stock-name-cell { font-weight: 600; }

        /* 強度榜產業分佈 chips：點擊篩選該產業、再點取消 */
        .sb-industry-chip { display: inline-flex; align-items: center; gap: 3px; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--color-chip-border); background: var(--color-surface-alt); font-size: 0.76em; color: var(--color-text); cursor: pointer; user-select: none; white-space: nowrap; }
        .sb-industry-chip:hover { border-color: var(--color-primary); }
        .sb-industry-chip.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; font-weight: 600; }
        .sb-industry-chip b { font-weight: 700; }

        /* 盤中即時線圖捷徑（Yahoo）：只在台股盤中渲染（見 main.js 的 yahooRtIconHtml），掛在名稱旁 */
        .yahoo-rt-icon { display: inline-flex; align-items: center; margin-left: 5px; cursor: pointer; color: var(--color-text-muted); vertical-align: -2px; }
        .yahoo-rt-icon:hover { color: var(--color-primary); }
        .yahoo-rt-icon svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

        /* ── Multi Strategy Intersection Box ────────────────── */
        .multi-strategy-box {
            display: none;
            margin-top: 20px;
            margin-bottom: 20px;
            padding: 16px 20px;
            background: linear-gradient(135deg, #eff6ff 0%, #f0fdfa 100%);
            border-radius: var(--radius-md);
            border: 1px solid #bfdbfe;
            width: 100%;
            box-sizing: border-box;
        }
        body.dark-theme .multi-strategy-box {
            background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(13, 148, 136, 0.1) 100%);
            border: 1px solid var(--color-border);
        }
        .multi-strategy-box h4 {
            margin: 0 0 10px 0;
            color: #1d4ed8;
            font-size: 0.92em;
            font-weight: 700;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        body.dark-theme .multi-strategy-box h4 {
            color: #60a5fa;
        }
        .multi-category-title {
            font-weight: bold;
            color: #2b6cb0;
            font-size: 0.9em;
            border-bottom: 1.5px solid #bee3f8;
            padding-bottom: 4px;
            margin-top: 10px;
            display: flex;
            align-items: center;
        }
        body.dark-theme .multi-category-title {
            color: #60a5fa;
            border-bottom: 1.5px solid #334155;
        }
        .multi-category-icon {
            color: #2b6cb0;
            margin-right: 6px;
            flex-shrink: 0;
        }
        body.dark-theme .multi-category-icon {
            color: #60a5fa;
        }
        .strategy-vip-label {
            color: #b45309;
            font-weight: 600;
        }
        .strategy-vip-tag {
            display: inline-block;
            font-size: 0.72em;
            font-weight: 700;
            color: #b45309;
            background: rgba(180,83,9,0.10);
            border: 1px solid rgba(180,83,9,0.30);
            border-radius: 999px;
            padding: 1px 7px;
            margin-left: 6px;
            vertical-align: middle;
        }
        body.dark-theme .strategy-vip-label { color: #fbbf24; }
        body.dark-theme .strategy-vip-tag {
            color: #fbbf24;
            background: rgba(245,158,11,0.18);
            border-color: rgba(245,158,11,0.35);
        }

        /* 排行榜「樣本不足」徽章：比照 .strategy-vip-tag 的琥珀色膠囊樣式 */
        .lb-low-sample-tag {
            display: inline-block;
            font-size: 0.72em;
            font-weight: 700;
            color: #b45309;
            background: rgba(180,83,9,0.10);
            border: 1px solid rgba(180,83,9,0.30);
            border-radius: 999px;
            padding: 1px 7px;
            margin-left: 6px;
            vertical-align: middle;
            white-space: nowrap;
        }
        body.dark-theme .lb-low-sample-tag {
            color: #fbbf24;
            background: rgba(245,158,11,0.18);
            border-color: rgba(245,158,11,0.35);
        }

        /* 建議持有週期標籤（短/中/長），膠囊樣式比照 .strategy-vip-tag */
        .strategy-hold-tag {
            display: inline-block;
            font-size: 0.72em;
            font-weight: 700;
            border-radius: 999px;
            padding: 1px 7px;
            margin-left: 6px;
            vertical-align: middle;
        }
        .strategy-hold-tag.hold-short {
            color: #be123c;
            background: rgba(190,18,60,0.08);
            border: 1px solid rgba(190,18,60,0.28);
        }
        .strategy-hold-tag.hold-mid {
            color: #1d4ed8;
            background: rgba(29,78,216,0.08);
            border: 1px solid rgba(29,78,216,0.28);
        }
        .strategy-hold-tag.hold-long {
            color: #15803d;
            background: rgba(21,128,61,0.08);
            border: 1px solid rgba(21,128,61,0.28);
        }
        body.dark-theme .strategy-hold-tag.hold-short {
            color: #fda4af;
            background: rgba(244,63,94,0.16);
            border-color: rgba(244,63,94,0.35);
        }
        body.dark-theme .strategy-hold-tag.hold-mid {
            color: #93c5fd;
            background: rgba(59,130,246,0.16);
            border-color: rgba(59,130,246,0.35);
        }
        body.dark-theme .strategy-hold-tag.hold-long {
            color: #86efac;
            background: rgba(34,197,94,0.16);
            border-color: rgba(34,197,94,0.35);
        }

        /* ── Financial Details Table Rows ── */
        .financial-divider-row {
            background: var(--color-financial-divider-bg) !important;
            font-weight: bold;
        }
        .data-table tr.financial-divider-row td {
            color: var(--color-financial-divider-text) !important;
        }
        
        .financial-year-row {
            background: var(--color-financial-year-bg) !important;
            border-bottom: 1px solid var(--color-border);
            font-weight: bold;
        }
        .data-table tr.financial-year-row td {
            color: var(--color-financial-year-text) !important;
        }
        
        .financial-year-label {
            color: var(--color-financial-year-label) !important;
            white-space: nowrap; /* 防止旁邊的展開 chevron 被斷行擠到下一行 */
        }

        /* 全年列 chevron 展開的單季/單月明細子列
           color 不用 !important：specificity 已壓過 .data-table td，
           且營收子列的 MoM/YoY 漲跌 inline 紅綠色必須能蓋回來 */
        .financial-year-detail-row {
            border-bottom: 1px solid var(--color-border);
        }
        .data-table tr.financial-year-detail-row td {
            color: var(--color-text-muted);
            font-size: 0.92em;
        }

        /* 用月營收推估的估算列（財報未公布），見 src/revenue_eps_estimate.py */
        .financial-estimate-row {
            background: var(--color-financial-estimate-bg) !important;
            border-bottom: 1px solid var(--color-border);
            font-style: italic;
        }
        .data-table tr.financial-estimate-row td {
            color: var(--color-financial-estimate-text) !important;
        }
        .financial-estimate-label {
            color: var(--color-financial-estimate-label) !important;
            font-style: normal;
            font-size: 0.78em;
            font-weight: 600;
        }

        .financial-note-row {
            background: #fffaf0;
        }
        .data-table tr.financial-note-row td {
            color: #dd6b20 !important;
        }
        body.dark-theme .financial-note-row {
            background: rgba(221, 107, 32, 0.15);
        }
        body.dark-theme .data-table tr.financial-note-row td {
            color: #f6ad55 !important;
        }
        
        /* ── Dividend Table border ── */
        .dividend-row {
            border-bottom: 1px solid #edf2f7;
        }
        body.dark-theme .dividend-row {
            border-bottom: 1px solid #334155;
        }
        
        /* 台股紅漲綠跌慣例：50~100% 健康區間用紅、>100%（配發超過盈餘）用綠。
           選擇器帶 td 是為了壓過 .data-table td 的 color（單一 class 會被蓋掉、只剩粗體） */
        td.ratio-high, .ratio-high {
            color: #38a169;
            font-weight: bold;
        }
        body.dark-theme td.ratio-high {
            color: #48bb78;
        }

        td.ratio-medium, .ratio-medium {
            color: var(--color-up);
            font-weight: bold;
        }
        body.dark-theme td.ratio-medium {
            color: #f87171;
        }

        /* 公司基本資料卡：年化股息殖利率 ≥5% 紅色標示，其餘用主文字色（暗色主題即亮白） */
        #val_yield {
            color: var(--color-text);
        }
        #val_yield.yield-high {
            color: var(--color-up);
        }
        body.dark-theme #val_yield.yield-high {
            color: #f87171;
        }

        /* ── Strategy Desc Box ─────────────────────────────── */
        .strategy-desc-box {
            margin-top: 20px;
            margin-bottom: 20px;
            background: linear-gradient(135deg, var(--color-primary-soft) 0%, var(--color-teal-soft) 100%);
            border: 1px solid var(--color-border);
            border-left: 4px solid #475569;
            border-radius: var(--radius-sm);
            box-shadow: -3px 0 10px rgba(71,85,105,0.2), var(--shadow-sm);
            font-size: 0.9em;
            line-height: 1.65;
            color: var(--color-text);
            width: 100%;
            overflow: hidden;
        }
        .strategy-desc-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
            padding: 11px 16px;
            border-bottom: 1px solid var(--color-border);
        }
        .strategy-desc-body {
            padding: 13px 16px 14px;
        }
        .strategy-desc-box h4 {
            margin: 0;
            font-size: 1em;
            font-weight: 700;
            color: #334155;
            display: flex;
            align-items: center;
            gap: 6px;
        }
        body.dark-theme .strategy-desc-box h4 { color: #94a3b8; }
        .strategy-settings-btn {
            flex-shrink: 0;
            font-weight: 600;
            padding: 9px 12px;
            background: #475569;
            border: none;
            border-radius: var(--radius-sm);
            cursor: pointer;
            color: white;
            display: inline-flex;
            align-items: center;
            gap: 5px;
            white-space: nowrap;
            box-shadow: 0 2px 6px rgba(71,85,105,0.25);
            transition: background 0.15s, transform 0.15s, box-shadow 0.2s;
        }
        .strategy-settings-btn:hover {
            background: #334155;
            color: white;
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(71,85,105,0.35);
        }
        .strategy-settings-btn:active {
            transform: translateY(0);
        }
        .strategy-desc-box p {
            margin: 0;
            font-size: 1em;
            color: var(--color-text);
            line-height: 1.65;
        }
        .observation-focus {
            margin-top: 12px;
            padding-top: 10px;
            border-top: 1px dashed var(--color-border);
            font-size: 1em;
            font-weight: 700;
            color: var(--color-text-muted);
            letter-spacing: 0.02em;
        }
        /* 拉伸 bar（rangeslider）統一作法：只留把手與選取框，不畫迷你圖
           （Plotly 沒有「slider 不畫內容」的正式選項，用 CSS 隱藏內部圖層） */
        #largeKLineChartDiv .rangeslider-rangeplot { display: none; }

        /* K線放大圖標題列的縮放按鈕 */
        .lc-zoom-btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            padding: 4px 7px;
            border: 1.5px solid var(--color-border);
            border-radius: var(--radius-sm);
            background: var(--color-surface);
            color: var(--color-text-muted);
            cursor: pointer;
            line-height: 1;
            box-shadow: none;
            outline: none;
        }
        .lc-zoom-btn:hover { color: var(--color-primary); border-color: var(--color-primary); background: var(--color-surface); }
        .lc-zoom-btn.active { color: white; background: var(--color-primary); border-color: var(--color-primary); }

        /* 摺疊卡片 chevron 共用樣式：展開=▼(SVG 原向)、收合=▶。
           兩種掛法皆可：collapsed class 切在 chevron 自己身上（健診/ETF/重大訊息/策略說明），
           或切在容器上（.data-card / .bulletin-card / .anomaly-category-group）。
           新增摺疊卡片時 chevron SVG 掛上 chevron-toggle 即可，不要再寫 per-id 規則 */
        .chevron-toggle { transition: transform 0.2s; flex-shrink: 0; }
        .chevron-toggle.collapsed,
        .collapsed .chevron-toggle { transform: rotate(-90deg); }
        .forward-return-badge {
            margin-top: 10px;
            padding-top: 8px;
            border-top: 1px dashed var(--color-border);
            font-size: 0.82em;
            color: var(--color-text-muted);
            line-height: 1.6;
        }
        .strategy-desc-box ol {
            margin: 6px 0 0 0;
            padding-left: 1.5em;
            font-size: 1em;
            font-weight: 400;
            color: #991b1b;
            line-height: 1.6;
        }
        .strategy-desc-box ol li {
            margin-bottom: 5px;
        }
        .strategy-desc-box ol li strong {
            font-weight: 700;
            color: #7f1d1d;
        }
        .strategy-params-row {
            margin-top: 10px;
            padding-top: 8px;
            border-top: 1px dashed var(--color-border);
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
            align-items: center;
        }
        .strategy-params-label {
            font-size: 1em;
            font-weight: 600;
            color: var(--color-text-muted);
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }
        .strategy-param-badge {
            background: var(--color-surface);
            color: var(--color-primary);
            padding: 2px 9px;
            border-radius: 10px;
            border: 1px solid var(--color-border);
            font-weight: 500;
        }
        .strategy-param-badge.modified {
            color: #dc2626;
            border-color: rgba(220, 38, 38, 0.35);
            background: rgba(220, 38, 38, 0.07);
        }
        .strategy-param-badge strong {
            font-weight: 700;
        }

        .stock-search-item {
            padding: 8px 12px;
            cursor: pointer;
            font-size: 0.88em;
            border-bottom: 1px solid var(--color-border);
            color: var(--color-text);
        }
        .stock-search-item:last-child { border-bottom: none; }
        .stock-search-item:hover { background: var(--color-surface-alt); }

        /* ── Quick Tool Bar ────────────────────────────────── */
        .quick-tool-btn {
            font-size: 0.84em;
            padding: 8px 10px;
            flex: 0 0 auto;
            width: max-content;
            min-width: 148px;
            background: white;
            border: 1.5px solid currentColor;
            border-radius: var(--radius-sm);
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
            cursor: pointer;
            transition: 0.2s;
            box-shadow: none;
            font-family: var(--font-sans);
            text-align: center;
            box-sizing: border-box;
        }
        .quick-tool-btn:hover {
            background: var(--color-surface-alt, #f8fafc);
            transform: none;
            box-shadow: none;
        }
        #btnCardWatchlistGroupPicker:hover {
            background: #fffbeb;
        }
        body.dark-theme .quick-tool-btn {
            background: #1e293b;
        }
        /* ── 資料卡片收合 ────────────────────────────────────── */
        .data-card.collapsed { align-self: flex-start; }
        .data-card.collapsed h4 { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
        .data-card.collapsed .card-body { display: none !important; }
        #klineSectionCard h4 { border-bottom: none !important; padding-bottom: 0; margin-bottom: 0; }
        /* ── 個股健診卡片 ─────────────────────────────────────── */
        #stockHealthHeader:hover { background: rgba(13,148,136,0.06) !important; }
        .health-title-icon { color: #64748b; }
        .health-badges {
            display: flex;
            flex-wrap: wrap;
            gap: 7px;
            margin-top: 8px;
            margin-bottom: 8px;
        }
        .health-badge {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            font-size: 0.82em;
            font-weight: 600;
            padding: 4px 10px;
            border-radius: 999px;
            background: rgba(71,85,105,0.08);
            color: #334155;
            border: 1px solid rgba(71,85,105,0.25);
            white-space: nowrap;
            cursor: pointer;
        }
        .health-badge.custom {
            background: rgba(124,58,237,0.10);
            color: #6d28d9;
            border-color: rgba(124,58,237,0.30);
        }
        .health-badge.vip {
            background: rgba(180,83,9,0.10);
            color: #b45309;
            border-color: rgba(180,83,9,0.30);
        }
        .health-badge.anomaly {
            background: rgba(37,99,235,0.08);
            color: #2563eb;
            border-color: rgba(37,99,235,0.28);
        }
        /* VIP 異動篩選（合約負債年增/資本支出/研發費用異常）比照策略VIP，顏色要蓋掉上面的
           .anomaly 藍色——用三個class的組合選擇器提高優先度，不依賴宣告順序 */
        .health-badge.anomaly.vip {
            background: rgba(180,83,9,0.10);
            color: #b45309;
            border-color: rgba(180,83,9,0.30);
        }
        .health-section-label {
            font-size: 0.78em;
            font-weight: 700;
            color: var(--color-text-muted);
            margin: 10px 0 4px;
        }
        .badge-spark { width: 11px; height: 11px; flex: 0 0 auto; vertical-align: -1px; }
        .health-spark-legend { display: inline-flex; align-items: center; gap: 3px; color: #6d28d9; }
        body.dark-theme .health-spark-legend { color: #c4b5fd; }
        body.dark-theme .health-badge.vip { background: rgba(245,158,11,0.18); color: #fbbf24; border-color: rgba(245,158,11,0.35); }
        body.dark-theme .health-badge.anomaly { background: rgba(59,130,246,0.18); color: #93c5fd; border-color: rgba(59,130,246,0.35); }
        body.dark-theme .health-badge.anomaly.vip { background: rgba(245,158,11,0.18); color: #fbbf24; border-color: rgba(245,158,11,0.35); }
        .health-meta {
            font-size: 0.76em;
            color: var(--color-text-muted);
            display: flex;
            flex-wrap: wrap;
            gap: 4px 12px;
            align-items: center;
        }
        .health-empty {
            font-size: 0.84em;
            color: var(--color-text-muted);
            padding: 4px 0;
        }
        body.dark-theme .health-badge { background: rgba(148,163,184,0.12); color: #94a3b8; border-color: rgba(148,163,184,0.25); }
        body.dark-theme .health-badge.custom { background: rgba(124,58,237,0.20); color: #c4b5fd; }
        /* ── 近期重大訊息卡片 ─────────────────────────────────── */
        #stockNewsHeader:hover { background: rgba(13,148,136,0.06) !important; }
        .news-list {
            list-style: none;
            margin: 6px 0 8px;
            padding: 0;
            max-height: 260px;
            overflow-y: auto;
        }
        .news-item {
            display: flex;
            gap: 10px;
            align-items: baseline;
            padding: 5px 0;
            border-bottom: 1px dashed var(--color-border);
            font-size: 0.85em;
            line-height: 1.45;
        }
        .news-item:last-child { border-bottom: none; }
        .news-date {
            flex: 0 0 auto;
            font-variant-numeric: tabular-nums;
            color: var(--color-text-muted);
            font-weight: 600;
        }
        .news-subject { color: var(--color-text); }
        .news-flag {
            flex: 0 0 auto;
            padding: 1px 7px;
            border-radius: 4px;
            font-size: 0.8em;
            font-weight: 700;
            white-space: nowrap;
        }
        /* 紅漲綠跌慣例：偏多(pos)=紅、風險(risk)=綠，跟自選清單/填息明細等處的漲跌配色方向一致 */
        .news-flag.risk { background: rgba(13,148,136,0.10); color: #0d9488; border: 1px solid rgba(13,148,136,0.35); }
        .news-flag.pos { background: rgba(220,38,38,0.10); color: #dc2626; border: 1px solid rgba(220,38,38,0.35); }
        .news-flag.neu { background: rgba(100,116,139,0.10); color: #64748b; border: 1px solid rgba(100,116,139,0.35); }
        body.dark-theme .news-flag.risk { background: rgba(13,148,136,0.18); color: #5eead4; }
        body.dark-theme .news-flag.pos { background: rgba(220,38,38,0.18); color: #f87171; }
        body.dark-theme .news-flag.neu { background: rgba(100,116,139,0.20); color: #cbd5e1; }

        /* 強度榜表頭：字級與表身一致、不加粗放大、不斷行（2026-07-15 James 指定） */
        #strengthBoardTable thead th {
            font-size: 1em;
            font-weight: 500;
            white-space: nowrap;
        }

        /* 強度榜「命中組合」徽章：形制比照 .news-flag，每個黃金組合一色（class 為 combo-<id>），
           點擊可篩選該組合，故加 cursor:pointer */
        .combo-badge {
            display: inline-block;
            padding: 1px 7px;
            margin-right: 4px;
            border-radius: 4px;
            font-size: 0.8em;
            font-weight: 700;
            white-space: nowrap;
            cursor: pointer;
        }
        .combo-badge:last-child { margin-right: 0; }
        .combo-badge[data-tier="至尊"] { background: rgba(79,70,229,0.10); color: #4f46e5; border: 1px solid rgba(79,70,229,0.35); }
        .combo-badge[data-tier="鑽石"] { background: rgba(234,88,12,0.10); color: #ea580c; border: 1px solid rgba(234,88,12,0.35); }
        .combo-badge[data-tier="黃金"] { background: rgba(8,145,178,0.10); color: #0891b2; border: 1px solid rgba(8,145,178,0.35); }
        .combo-badge[data-tier="強勢"] { background: rgba(220,38,38,0.10); color: #dc2626; border: 1px solid rgba(220,38,38,0.35); }
        .combo-badge[data-tier="穩健"] { background: rgba(190,24,93,0.10); color: #be185d; border: 1px solid rgba(190,24,93,0.35); }
        .combo-badge[data-tier="飆速"] { background: rgba(202,138,4,0.10); color: #ca8a04; border: 1px solid rgba(202,138,4,0.35); }
        body.dark-theme .combo-badge[data-tier="至尊"] { background: rgba(79,70,229,0.22); color: #a5b4fc; }
        body.dark-theme .combo-badge[data-tier="鑽石"] { background: rgba(234,88,12,0.22); color: #fdba74; }
        body.dark-theme .combo-badge[data-tier="黃金"] { background: rgba(8,145,178,0.20); color: #67e8f9; }
        body.dark-theme .combo-badge[data-tier="強勢"] { background: rgba(220,38,38,0.20); color: #f87171; }
        body.dark-theme .combo-badge[data-tier="穩健"] { background: rgba(190,24,93,0.22); color: #f9a8d4; }
        body.dark-theme .combo-badge[data-tier="飆速"] { background: rgba(202,138,4,0.22); color: #fde047; }
        a.news-subject { text-decoration: none; cursor: pointer; }
        a.news-subject:hover { color: var(--color-primary); text-decoration: underline; }
        /* 連結獨立一列，字級同 .news-item 主旨（0.85em），不吃 .health-meta 的 0.76em */
        .news-all-row { font-size: 0.85em; margin-top: 6px; }
        .news-all-link {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            color: var(--color-primary);
            font-weight: 600;
            text-decoration: none;
        }
        .news-all-link:hover { text-decoration: underline; }
        .news-all-link .icon { stroke: currentColor; }
        /* ── Discussion Panel ───────────────────────────────── */
        #discussionPanel {
            display: flex;
            flex-direction: row;
            gap: 20px;
            width: 100%;
            height: 800px;
            align-items: stretch;
        }
        .discussion-left {
            flex: 1 1 0;
            min-width: 0;
            display: flex;
            flex-direction: column;
        }
        .discussion-feed {
            flex: 1;
            overflow-y: auto;
            padding: 16px 0;
            display: flex;
            flex-direction: column;
            gap: 16px;
        }
        .discussion-composer {
            padding: 12px 0 4px;
            border-top: 1px solid var(--color-border);
        }
        .bulletin-panel {
            width: 350px;
            flex-shrink: 0;
            display: flex;
            flex-direction: column;
            border-left: 1px solid var(--color-border);
            padding-left: 18px;
            overflow: hidden;
        }
        .bulletin-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            font-weight: 700;
            font-size: 0.9em;
            color: var(--color-text);
            margin-bottom: 12px;
            padding-bottom: 8px;
            border-bottom: 1px solid var(--color-border);
            flex-shrink: 0;
        }
        .bulletin-card {
            background: var(--color-surface-alt);
            border: 1px solid var(--color-border);
            border-left: 3px solid var(--color-primary);
            border-radius: 8px;
            padding: 10px 12px;
            font-size: 0.84em;
            line-height: 1.55;
        }
        .bulletin-card-header {
            display: flex;
            align-items: center;
            gap: 8px;
            cursor: pointer;
        }
        .bulletin-card.collapsed .bulletin-card-body { display: none; }
        .bulletin-card-date {
            margin-left: auto;
            flex-shrink: 0;
            font-size: 0.8em;
            color: var(--color-text-muted);
        }
        .bulletin-card-body {
            margin-top: 8px;
        }
        .bulletin-card-title {
            font-weight: 700;
            color: var(--color-text);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .bulletin-card-content {
            color: var(--color-text);
            white-space: pre-wrap;
            word-break: break-word;
        }
        .bulletin-card-meta {
            margin-top: 6px;
            font-size: 0.8em;
            color: var(--color-text-muted);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        body.dark-theme .bulletin-card {
            background: #1e293b;
        }
        body.dark-theme #quoteBanner {
            background: linear-gradient(135deg,rgba(245,158,11,0.1) 0%,rgba(245,158,11,0.04) 100%);
            border-color: rgba(245,158,11,0.35);
        }
        body.dark-theme #quoteAuthor,
        body.dark-theme #quoteBanner button {
            color: #fbbf24;
        }
        @media (max-width: 640px) {
            #discussionPanel { flex-direction: column; height: auto; }
            .bulletin-panel { width: 100%; border-left: none; border-top: 1px solid var(--color-border); padding-left: 0; padding-top: 16px; }
            #bulletinList { max-height: 200px; }
        }
        .msg-bubble {
            display: flex;
            gap: 10px;
            align-items: flex-start;
        }
        .msg-bubble.msg-self {
            flex-direction: row-reverse;
        }
        .msg-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            object-fit: cover;
            flex-shrink: 0;
        }
        .msg-avatar-fallback {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            background: var(--color-teal);
            color: white;
            font-size: 0.85em;
            font-weight: 700;
            display: flex;
            align-items: center;
            justify-content: center;
            flex-shrink: 0;
        }
        .msg-body { flex: 1; min-width: 0; }
        .msg-bubble.msg-self > .msg-body {
            display: flex;
            flex-direction: column;
            align-items: flex-end;
        }
        .msg-meta {
            font-size: 0.78em;
            color: var(--color-text-muted);
            margin-bottom: 3px;
            display: flex;
            align-items: baseline;
            gap: 6px;
        }
        .msg-name { font-weight: 700; color: var(--color-text); font-size: 0.88em; }
        .msg-content-wrap {
            display: flex;
            flex-direction: column;
            max-width: 75%;
        }
        .msg-text {
            background: var(--color-surface-alt);
            border: 1px solid var(--color-border);
            border-radius: 4px 14px 14px 14px;
            padding: 9px 13px;
            font-size: 0.9em;
            line-height: 1.6;
            word-break: break-word;
            color: var(--color-text);
        }
        .msg-bubble.msg-self > .msg-body > .msg-content-wrap > .msg-text {
            background: #dbeafe;
            border-color: #bfdbfe;
            border-radius: 14px 4px 14px 14px;
            color: #1e3a5f;
        }
        .msg-actions {
            margin-top: 5px;
            display: flex;
            gap: 10px;
        }
        .msg-bubble.msg-self > .msg-body > .msg-actions {
            justify-content: flex-end;
        }
        .msg-action-btn {
            font-size: 0.76em;
            color: var(--color-text-muted);
            background: none;
            border: none;
            cursor: pointer;
            padding: 0;
            display: inline-flex;
            align-items: center;
            gap: 3px;
        }
        .msg-action-btn:hover { color: var(--color-primary); }
        .msg-action-btn.delete:hover { color: #ef4444; }
        .msg-replies {
            margin-top: 10px;
            display: flex;
            flex-direction: column;
            gap: 10px;
            align-self: stretch;
            width: 100%;
            box-sizing: border-box;
        }
        .msg-quote {
            display: flex;
            flex-direction: column;
            gap: 2px;
            padding: 5px 10px;
            border-left: 3px solid var(--color-primary);
            background: var(--color-surface-alt);
            border-radius: 0 6px 6px 0;
            margin-bottom: 5px;
            max-width: 100%;
        }
        .msg-quote-name {
            font-size: 0.75em;
            font-weight: 700;
            color: var(--color-primary);
        }
        .msg-quote-text {
            font-size: 0.78em;
            color: var(--color-text-muted);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        body.dark-theme .msg-quote {
            background: #1e293b;
        }
        .msg-reply .msg-text {
            background: var(--color-surface);
            font-size: 0.86em;
        }
        .msg-reply.msg-self .msg-text {
            background: #dbeafe;
            border-color: #bfdbfe;
            color: #1e3a5f;
        }
        .msg-reply .msg-avatar,
        .msg-reply .msg-avatar-fallback {
            width: 28px;
            height: 28px;
            font-size: 0.75em;
        }
        body.dark-theme .msg-text {
            background: #1e293b;
        }
        body.dark-theme .msg-reply .msg-text {
            background: #0f172a;
        }
        body.dark-theme .msg-self .msg-content-wrap .msg-text,
        body.dark-theme .msg-reply.msg-self .msg-content-wrap .msg-text {
            background: #1e3a5f;
            border-color: #2563eb44;
            color: #bfdbfe;
        }

        #cardHistockLink:hover { background: #dd6b20 !important; color: white !important; }
        #cardYahooLink:hover   { background: var(--color-primary) !important; color: white !important; }
        #cardGoogleNewsLink:hover { background: #1a73e8 !important; color: white !important; }
        #cardBtnGemini:hover,
        #btnAskGeminiBasic:hover,
        #btnAskGeminiInstitutional:hover,
        #btnAskGeminiDividend:hover,
        #btnAskGeminiFinance:hover,
        #btnAskGeminiDispersion:hover,
        #btnAskGeminiRevenue:hover,
        #btnAskGeminiInsider:hover { background: #7c3aed !important; color: white !important; }

        /* ── Modal ─────────────────────────────────────────── */
        .modal-overlay {
            display: none;
            position: fixed;
            top: 0; left: 0;
            width: 100%; height: 100%;
            background: rgba(15,23,42,0.55);
            z-index: 1000;
            align-items: center;
            justify-content: center;
            backdrop-filter: blur(6px);
        }
        .modal-content {
            background: var(--color-surface);
            width: 90%;
            max-width: 650px;
            padding: 26px;
            border-radius: var(--radius-lg);
            box-shadow: var(--shadow-lg);
            max-height: 85vh;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
        }
        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 2px solid var(--color-border-light);
            padding-bottom: 12px;
            margin-bottom: 16px;
        }
        .modal-header h2 {
            margin: 0;
            font-size: 1.2em;
            font-weight: 700;
            color: var(--color-text);
        }
        .modal-body { flex: 1; overflow-y: auto; margin-bottom: 20px; }
        .modal-footer {
            display: flex;
            gap: 10px;
            justify-content: flex-end;
            border-top: 1px solid var(--color-border-light);
            padding-top: 15px;
        }
        .param-group { margin-bottom: 14px; }
        .param-group label {
            display: block;
            font-weight: 600;
            font-size: 0.83em;
            color: var(--color-text-muted);
            margin-bottom: 5px;
        }
        .param-group input { width: 100%; }

        /* ── Initial State ─────────────────────────────────── */
        .main-wrapper.initial-state {
            min-height: auto;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            align-items: stretch;
        }
        .main-wrapper.initial-state .controls {
            margin-bottom: 0;
            box-shadow: var(--shadow-md);
            background: var(--color-surface);
            border-color: var(--color-border);
            padding: 22px 28px;
        }
        .main-wrapper.initial-state #chartsRow,
        .main-wrapper.initial-state #summaryPanel,
        .main-wrapper.initial-state #revenuePanel,
        .main-wrapper.initial-state #insiderPanel {
            display: none !important;
        }
        .main-wrapper.initial-state .strategy-desc-box {
            margin-top: 20px;
        }

        /* ── Toast Notification ────────────────────────────── */
        #toastNotification {
            position: fixed;
            bottom: 28px;
            right: 28px;
            background: #1e293b;
            color: white;
            padding: 12px 20px;
            border-radius: var(--radius-md);
            font-size: 0.88em;
            font-weight: 500;
            z-index: 20000;
            opacity: 0;
            transform: translateY(10px);
            transition: opacity 0.35s, transform 0.35s;
            box-shadow: var(--shadow-lg);
            max-width: 320px;
        }
        #toastNotification.show {
            opacity: 1;
            transform: translateY(0);
        }

        /* ── Animations ────────────────────────────────────── */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(20px); }
            to   { opacity: 1; transform: translateY(0); }
        }
        @keyframes pulse {
            0%   { transform: scale(1); }
            50%  { transform: scale(1.05); }
            100% { transform: scale(1); }
        }

        /* ── User Bar Styles ── */
        .user-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            width: 100%;
            margin-bottom: 10px;
            padding: 0 0 4px;
            background: transparent;
            border: none;
            box-shadow: none;
            box-sizing: border-box;
            gap: 16px;
            flex-wrap: wrap;
        }
        .brand-title {
            font-size: 20px;
            font-weight: 800;
            background: linear-gradient(135deg, #f87171 0%, #dc2626 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            letter-spacing: 0.5px;
            display: flex;
            align-items: center;
            gap: 8px;
            animation: pulse 2s infinite;
        }
        .user-info {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .user-avatar {
            width: 28px;
            height: 28px;
            border-radius: 50%;
            border: 1.5px solid var(--color-primary);
            object-fit: cover;
        }
        .user-name {
            font-weight: 600;
            color: var(--color-text);
            font-size: 14px;
        }
        /* ── Navbar Ghost Buttons (Layer 1) ─────────────────── */
        .btn-nav-ghost {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            height: 32px;
            padding: 0 12px;
            background: transparent;
            border-radius: var(--radius-sm);
            font-weight: 600;
            font-size: 13px;
            text-decoration: none;
            cursor: pointer;
            transition: all 0.2s;
            border: 1.5px solid currentColor;
            white-space: nowrap;
            /* 因為文字 nowrap，視窗較窄、按鍵數較多時（例如管理員多一顆「管理後台」）
               若被 flex 預設的收縮擠壓，文字會被裁切重疊而不是換行；固定不收縮，
               改由 .user-actions 自己換行來容納 */
            flex-shrink: 0;
        }
        .btn-nav-ghost:hover {
            transform: translateY(-1px);
        }
        .btn-logout {
            color: #ef4444;
        }
        .btn-logout:hover {
            background: #fee2e2;
            box-shadow: 0 4px 10px rgba(239,68,68,0.15);
        }
        body.dark-theme .btn-logout:hover {
            background: rgba(239,68,68,0.15);
        }
        .btn-trade-portal:hover {
            background: rgba(245,158,11,0.1);
            box-shadow: 0 4px 10px rgba(245,158,11,0.2);
        }
        body.dark-theme .btn-trade-portal:hover {
            background: rgba(245,158,11,0.15);
        }
        .btn-watchlist:hover {
            background: rgba(217,119,6,0.1);
            box-shadow: 0 4px 10px rgba(217,119,6,0.2);
        }
        body.dark-theme .btn-watchlist:hover {
            background: rgba(217,119,6,0.15);
        }

        /* ── Simulated Trading Modal & Tab Styles ── */
        .trade-modal-overlay {
            position: fixed;
            top: 0; left: 0;
            width: 100%; height: 100%;
            background: rgba(15, 23, 42, 0.65);
            z-index: 10001;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 20px;
            box-sizing: border-box;
        }
        .trade-modal-card {
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            width: 100%;
            max-width: 780px;
            box-shadow: var(--shadow-lg);
            display: flex;
            flex-direction: column;
            max-height: 85vh;
            animation: modalFadeIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
            color: var(--color-text);
            overflow: hidden;
        }
        #tradeAccountModal .trade-modal-card {
            height: 680px;
            max-height: 85vh;
        }
        /* 強度榜不垂直置中：貼齊頂部、固定高度往下延伸——切換組合/門檻後列數驟減時，
           視窗不會縮小又跳回畫面中央 */
        #strengthBoardModal {
            align-items: flex-start;
        }
        #strengthBoardModal .trade-modal-card {
            height: calc(100vh - 40px);   /* overlay 上下 padding 各 20px，貼齊頂部往下佔滿 */
            max-height: none;
        }
        #watchlistModal .trade-modal-card {
            height: 620px;
            max-height: 85vh;
            animation: modalSlideIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
        }
        @keyframes modalSlideIn {
            from { opacity: 0; transform: translateY(10px); }
            to   { opacity: 1; transform: translateY(0); }
        }
        .trade-modal-card.order-card {
            max-width: 420px;
        }
        .order-card .trade-modal-body {
            padding: 14px 20px;
        }
        @keyframes modalFadeIn {
            from { opacity: 0; transform: scale(0.98) translateY(6px); }
            to { opacity: 1; transform: scale(1) translateY(0); }
        }
        .trade-modal-header {
            padding: 16px 20px;
            border-bottom: 1px solid var(--color-border-light);
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: var(--color-surface-alt);
        }
        .trade-modal-header h3 {
            margin: 0;
            font-size: 1.1em;
            font-weight: 700;
            display: flex;
            flex-direction: row;
            flex-wrap: nowrap;
            align-items: center;
            gap: 8px;
        }
        .trade-modal-header h3 svg {
            display: inline-block;
            vertical-align: middle;
            flex-shrink: 0;
        }
        .trade-modal-close {
            background: none;
            border: none;
            color: var(--color-text-muted);
            cursor: pointer;
            font-size: 1.5em;
            padding: 0;
            line-height: 1;
            transition: 0.2s;
        }
        .trade-modal-close:hover {
            color: var(--color-text);
        }
        .trade-modal-body {
            padding: 20px;
            overflow-y: auto;
            flex-grow: 1;
            position: relative;
        }
        
        /* ── Loading Spinner Styles ── */
        .trade-loading-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(255, 255, 255, 0.7);
            z-index: 100;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.2s ease;
        }
        body.dark-theme .trade-loading-overlay {
            background: rgba(30, 41, 59, 0.7);
        }
        .trade-loading-overlay.show {
            opacity: 1;
            pointer-events: auto;
        }
        .trade-spinner {
            width: 32px;
            height: 32px;
            border: 3px solid var(--color-border);
            border-top: 3px solid var(--color-primary);
            border-radius: 50%;
            animation: tradeSpin 0.8s linear infinite;
        }
        @keyframes tradeSpin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        
        /* Tabs within Trade Modal */
        .trade-tabs {
            display: flex;
            gap: 0;
            border-bottom: 1px solid var(--color-border);
            background: var(--color-surface-alt);
            padding: 8px 16px 0 16px;
            box-sizing: border-box;
        }
        .trade-tab {
            padding: 8px 16px;
            font-size: 0.88em;
            font-weight: 600;
            background: var(--color-surface-alt);
            color: var(--color-text-muted);
            cursor: pointer;
            border: 1px solid var(--color-border);
            border-bottom: 1px solid var(--color-border);
            border-radius: 6px 6px 0 0;
            margin-right: -1px;
            margin-bottom: -1px;
            transition: all 0.25s ease;
            position: relative;
            z-index: 1;
            outline: none;
            box-shadow: none !important;
            transform: none !important;
        }
        .trade-tab:hover {
            background: var(--color-surface);
            color: var(--color-text);
            box-shadow: none !important;
            transform: none !important;
        }
        .trade-tab:active {
            transform: none !important;
            box-shadow: none !important;
        }
        .trade-tab.active {
            background: var(--color-surface);
            color: var(--color-primary);
            font-weight: 700;
            border-bottom: 1px solid var(--color-surface);
            z-index: 2;
            box-shadow: none !important;
            transform: none !important;
        }
        
        /* Stats summary widgets */
        .trade-stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
            gap: 12px;
            margin-bottom: 20px;
        }
        .trade-stat-card {
            background: var(--color-surface-alt);
            border: 1px solid var(--color-border-light);
            padding: 12px;
            border-radius: var(--radius-sm);
            text-align: center;
        }
        .trade-stat-label {
            font-size: 0.78em;
            color: var(--color-text-muted);
            margin-bottom: 4px;
            font-weight: 500;
        }
        .trade-stat-val {
            font-size: 1.15em;
            font-weight: 700;
        }
        
        /* Form elements for order */
        .trade-form-group {
            margin-bottom: 11px;
        }
        .trade-form-group label {
            display: block;
            font-size: 0.85em;
            font-weight: 600;
            margin-bottom: 4px;
            color: var(--color-text-muted);
        }
        .trade-btn-group {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 10px;
            margin-bottom: 11px;
        }
        .trade-action-btn {
            padding: 7px;
            border-radius: var(--radius-sm);
            font-weight: 700;
            font-size: 0.92em;
            border: 1.5px solid transparent;
            cursor: pointer;
            text-align: center;
            transition: 0.2s;
        }
        .trade-action-btn.btn-buy {
            background: rgba(220, 38, 38, 0.1);
            color: #dc2626;
            border-color: rgba(220, 38, 38, 0.2);
        }
        .trade-action-btn.btn-buy.active {
            background: #dc2626;
            color: white;
            border-color: #dc2626;
            box-shadow: 0 4px 10px rgba(220, 38, 38, 0.2);
        }
        .trade-action-btn.btn-sell {
            background: rgba(22, 163, 74, 0.1);
            color: #16a34a;
            border-color: rgba(22, 163, 74, 0.2);
        }
        .trade-action-btn.btn-sell.active {
            background: #16a34a;
            color: white;
            border-color: #16a34a;
            box-shadow: 0 4px 10px rgba(22, 163, 74, 0.2);
        }
        .trade-input {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid var(--color-border);
            background: var(--color-surface-alt);
            color: var(--color-text);
            border-radius: var(--radius-sm);
            font-size: 0.95em;
            box-sizing: border-box;
            outline: none;
            transition: 0.2s;
        }
        .trade-input:focus {
            border-color: var(--color-primary);
        }
        .trade-input:disabled {
            opacity: 0.6;
            cursor: not-allowed;
        }

        /* Tabs styles */
        .tabs-bar {
            display: flex;
            gap: 0;
            margin-bottom: 20px;
            border-bottom: 1px solid var(--color-border);
            padding-bottom: 0;
            padding-left: 8px;
            width: 100%;
            box-sizing: border-box;
        }
        .tab-btn {
            font-size: 0.95em;
            font-weight: 600;
            background: #f8fafc;
            color: var(--color-text-muted);
            cursor: pointer;
            padding: 10px 24px;
            border: 1px solid var(--color-border);
            border-bottom: 1px solid var(--color-border);
            border-radius: 6px 6px 0 0;
            margin-right: -1px;
            margin-bottom: -1px;
            transition: all 0.25s ease;
            position: relative;
            z-index: 1;
            outline: none;
            box-shadow: none !important;
            transform: none !important;
        }
        .tab-btn:hover {
            background: #f8fafc;
            color: var(--color-text);
            box-shadow: none !important;
            transform: none !important;
        }
        .tab-btn:active {
            transform: none !important;
            box-shadow: none !important;
        }
        .tab-btn.active {
            background: #ffffff;
            color: var(--color-text);
            font-weight: 700;
            border-bottom: 1px solid #ffffff;
            margin-bottom: -1px;
            z-index: 2;
            box-shadow: none !important;
            transform: none !important;
        }

        /* Dark Theme overrides for Tabs */
        body.dark-theme .tab-btn {
            background: #0f172a;
            color: var(--color-text-muted);
            border-color: var(--color-border);
            box-shadow: none !important;
            transform: none !important;
        }
        body.dark-theme .tab-btn:hover {
            background: #1e293b;
            color: var(--color-text);
            box-shadow: none !important;
            transform: none !important;
        }
        body.dark-theme .tab-btn.active {
            background: #1e293b;
            color: var(--color-text);
            border-color: var(--color-border) var(--color-border) #1e293b var(--color-border);
            margin-bottom: -1px;
            box-shadow: none !important;
            transform: none !important;
        }

        /* ── 回測 ──────────────────────────────────────────── */
        /* 回測出場條件 chip */
        .backtest-exit-chip {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 0.836em;
            color: var(--color-text-muted);
            padding: 4px 8px;
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
            background: var(--color-surface);
            cursor: pointer;
            user-select: none;
        }
        .backtest-exit-chip:hover { border-color: var(--color-primary); color: var(--color-text); }
        .backtest-exit-chip.active {
            border-color: #e85a5a;
            background: rgba(232,90,90,0.08);
            color: #e85a5a;
            font-weight: 600;
        }
        /* 回測彙總卡片 */
        .bt-summary-card {
            flex: 1 1 110px;
            min-width: 100px;
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
            padding: 10px 14px;
            text-align: center;
        }
        .bt-summary-card .bt-card-label {
            font-size: 0.75em;
            color: var(--color-text-muted);
            font-weight: 600;
            margin-bottom: 4px;
        }
        .bt-summary-card .bt-card-value {
            font-size: 1.25em;
            font-weight: 700;
            color: var(--color-text);
        }
        .bt-card-value.positive { color: #e85a5a; }
        .bt-card-value.negative { color: #22c55e; }

        /* ── 異動篩選 ─────────────────────────────────────── */
        .anomaly-filter-section {
            padding: 16px 20px;
            background: var(--color-surface-alt);
            border-radius: var(--radius-md);
            border: 1px solid var(--color-border);
            margin-bottom: 16px;
        }
        .anomaly-filters {
            display: flex;
            flex-direction: column;
            gap: 0;
        }
        .anomaly-category-group {
            width: 100%;
        }
        .anomaly-category-label {
            width: 100%;
            font-size: 14px;
            font-weight: 700;
            letter-spacing: 0.04em;
            color: var(--color-text-muted);
            padding: 8px 2px 6px;
            border-bottom: 1px solid var(--color-border);
            margin-bottom: 0;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 5px;
            cursor: pointer;
            user-select: none;
            box-sizing: border-box;
        }
        .anomaly-category-label:hover {
            color: var(--color-text);
        }
        .anomaly-category-items {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            padding: 10px 0 14px;
        }
        .anomaly-category-group.collapsed .anomaly-category-items {
            display: none;
        }
        .anomaly-filter-item {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            font-size: 0.836em;
            color: var(--color-text-muted);
            padding: 4px 8px;
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
            background: var(--color-surface);
            cursor: pointer;
            user-select: none;
        }
        .anomaly-filter-item:hover {
            border-color: var(--color-primary);
            color: var(--color-text);
        }
        .anomaly-filter-item.active {
            border-color: var(--color-primary);
            background: rgba(59,130,246,0.1);
            color: var(--color-primary);
            font-weight: 600;
        }
        .anomaly-filter-item select {
            padding: 2px 5px;
            font-size: 0.92em;
            min-width: unset;
            width: auto;
        }
        .anomaly-logic-toggle {
            display: inline-flex;
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
            overflow: hidden;
        }
        .anomaly-logic-opt {
            display: flex;
            align-items: center;
            cursor: pointer;
        }
        .anomaly-logic-opt input[type="radio"] {
            display: none;
        }
        .anomaly-logic-opt span {
            display: block;
            padding: 5px 14px;
            font-size: 0.83em;
            font-weight: 500;
            color: var(--color-text-muted);
            background: var(--color-surface);
            border-right: 1px solid var(--color-border);
            transition: background 0.15s, color 0.15s;
            white-space: nowrap;
        }
        .anomaly-logic-opt:last-child span {
            border-right: none;
        }
        .anomaly-logic-opt input[type="radio"]:checked + span {
            background: var(--color-primary);
            color: #fff;
            font-weight: 600;
        }
        .anomaly-trigger-label {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 4px;
            background: rgba(59,130,246,0.1);
            color: var(--color-primary);
        }
        body.dark-theme .anomaly-trigger-label {
            background: rgba(59,130,246,0.18);
        }
        /* 強度榜策略清單 popover 的「今日板機」小徽章——字級比照 .combo-badge（0.8em），
           不共用 .anomaly-trigger-label 以免縮到異動篩選結果表的標籤 */
        .strength-trigger-badge {
            display: inline-block;
            padding: 1px 6px;
            margin-left: 5px;
            border-radius: 4px;
            font-size: 0.8em;
            white-space: nowrap;
            background: rgba(59,130,246,0.1);
            color: var(--color-primary);
        }
        body.dark-theme .strength-trigger-badge {
            background: rgba(59,130,246,0.18);
        }
        /* 異動徽章強度分級（配對實驗加值）：強 >=3pp 實心、弱 <1pp 灰淡、中間值維持預設淡藍。
           健診卡與強度榜 popover 共用（main.js triggerTierClass） */
        .strength-trigger-badge.tier-strong {
            background: var(--color-primary);
            color: #fff;
            font-weight: 600;
        }
        body.dark-theme .strength-trigger-badge.tier-strong {
            background: #3b82f6;
            color: #fff;
        }
        .strength-trigger-badge.tier-weak {
            background: rgba(148,163,184,0.15);
            color: var(--color-text-muted);
        }
        body.dark-theme .strength-trigger-badge.tier-weak {
            background: rgba(148,163,184,0.2);
        }
        /* 診斷發動點的「異動強度順序」條（#anomalyTriggerRank）：每個異動是可點選開關，
           勾選狀態與下方 .anomaly-filter-item.active 雙向同步（anomaly.js syncTriggerRankChips） */
        .trigger-rank-chip {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            margin: 2px 8px 2px 0;
            padding: 2px 9px 2px 5px;
            border-radius: 999px;
            border: 1px solid var(--color-primary);
            background: var(--color-primary-soft);
            white-space: nowrap;
            cursor: pointer;
            user-select: none;
            transition: opacity 0.15s, border-color 0.15s, background 0.15s;
        }
        .trigger-rank-chip .trigger-rank-num {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: var(--color-primary);
            color: #fff;
            font-weight: 700;
            font-size: 0.82em;
        }
        .trigger-rank-chip .trigger-rank-check {
            width: 13px;
            height: 13px;
            color: var(--color-primary);
        }
        .trigger-rank-chip .trigger-rank-label { color: var(--color-text); }
        .trigger-rank-chip .trigger-rank-lift {
            font-weight: 700;
            color: var(--color-primary);
        }
        .trigger-rank-chip.off {
            opacity: 0.5;
            border-color: var(--color-border);
            background: transparent;
        }
        .trigger-rank-chip.off .trigger-rank-num { background: var(--color-text-muted); }
        .trigger-rank-chip.off .trigger-rank-check { visibility: hidden; }
        .trigger-rank-chip:hover { opacity: 1; border-color: var(--color-primary); }
        .anomaly-strategy-tag {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 4px;
            background: rgba(22,163,74,0.1);
            color: #16a34a;
            margin: 1px 0;
        }
        body.dark-theme .anomaly-strategy-tag {
            background: rgba(22,163,74,0.18);
            color: #4ade80;
        }

        /* ── Gemini Brand Styles ────────────────────────── */
        .btn-gemini {
            background: linear-gradient(135deg, #1a73e8 0%, #7c4dff 50%, #e040fb 100%) !important;
            border: none !important;
            color: white !important;
            font-weight: 700 !important;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 5px;
            padding: 4px 12px !important;
            border-radius: var(--radius-sm) !important;
            cursor: pointer;
            box-shadow: 0 3px 12px rgba(124, 77, 255, 0.25);
            transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
            position: relative;
            overflow: hidden;
            font-size: 0.84em;
            height: 28px;
            box-sizing: border-box;
            line-height: 1;
            text-shadow: 0 1px 2px rgba(0,0,0,0.1);
        }

        .btn-gemini::before {
            content: '';
            position: absolute;
            top: 0; left: -100%;
            width: 100%; height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
            transition: all 0.5s ease;
        }

        .btn-gemini:hover {
            transform: translateY(-1.5px);
            box-shadow: 0 5px 16px rgba(124, 77, 255, 0.45), 0 2px 6px rgba(224, 64, 251, 0.25);
        }

        .btn-gemini:hover::before {
            left: 100%;
        }

        .btn-gemini svg.icon {
            fill: white !important;
            stroke: none !important;
            filter: drop-shadow(0 0 1.5px rgba(255,255,255,0.6));
            width: 13px;
            height: 13px;
            margin: 0;
        }

        .gemini-style-box {
            display: inline-flex;
            align-items: center;
            gap: 6px;
            background: linear-gradient(135deg, #1a73e8 0%, #7c4dff 50%, #e040fb 100%) !important;
            border: none !important;
            border-radius: var(--radius-sm);
            padding: 4px 10px 4px 12px;
            height: 36px;
            box-sizing: border-box;
            cursor: pointer;
            position: relative;
            box-shadow: 0 3px 12px rgba(124, 77, 255, 0.25);
            transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
            overflow: visible;
            user-select: none;
        }

        .gemini-style-box:hover {
            transform: translateY(-1.5px);
            box-shadow: 0 5px 16px rgba(124, 77, 255, 0.45), 0 2px 6px rgba(224, 64, 251, 0.25);
        }

        .gemini-style-box > svg.icon {
            fill: white !important;
            stroke: none !important;
            filter: drop-shadow(0 0 1.5px rgba(255,255,255,0.6));
            width: 13px;
            height: 13px;
            flex-shrink: 0;
        }

        .gemini-style-box span {
            font-size: 0.84em;
            font-weight: 700;
            color: white !important;
            display: inline-flex;
            align-items: center;
            gap: 3px;
            white-space: nowrap;
        }

        .gemini-dropdown-arrow {
            width: 12px;
            height: 12px;
            stroke: white !important;
            flex-shrink: 0;
            transition: transform 0.2s ease;
        }

        .gemini-style-box.open .gemini-dropdown-arrow {
            transform: rotate(180deg);
        }

        /* Custom dropdown 選單 */
        .gemini-dropdown-menu {
            display: none;
            position: absolute;
            top: calc(100% + 6px);
            right: 0;
            min-width: 110px;
            margin: 0;
            padding: 4px 0;
            list-style: none;
            background: var(--color-surface);
            border: 1.5px solid transparent;
            background-image: linear-gradient(var(--color-surface), var(--color-surface)),
                              linear-gradient(135deg, #1a73e8, #7c4dff, #e040fb);
            background-origin: border-box;
            background-clip: padding-box, border-box;
            border-radius: var(--radius-sm);
            box-shadow: 0 8px 24px rgba(124, 77, 255, 0.25);
            z-index: 9999;
            overflow: hidden;
            animation: geminiDropIn 0.15s ease;
        }

        .gemini-style-box.open .gemini-dropdown-menu {
            display: block;
        }

        @keyframes geminiDropIn {
            from { opacity: 0; transform: translateY(-6px); }
            to   { opacity: 1; transform: translateY(0); }
        }

        .gemini-dropdown-item {
            padding: 7px 14px;
            font-size: 0.84em;
            font-weight: 600;
            color: #7c4dff !important;
            cursor: pointer;
            transition: background 0.15s ease;
            white-space: nowrap;
        }

        .gemini-dropdown-item:hover {
            background: rgba(124, 77, 255, 0.1);
        }

        .gemini-dropdown-item.active {
            background: linear-gradient(135deg, rgba(26,115,232,0.12), rgba(224,64,251,0.12));
            color: #7c4dff !important;
        }

                /* 調整 quickToolsBar 裡的 Gemini 按鈕高度 */
        #quickToolsBar #cardBtnGemini.btn-gemini {
            height: 36px;
            padding: 0 16px !important;
            font-size: 0.88em;
        }

        /* 策略回測工具提示框 */
        .bt-strategy-tooltip {
            position: absolute;
            z-index: 10000;
            background: rgba(255, 255, 255, 0.98);
            backdrop-filter: blur(8px);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-sm);
            padding: 10px 12px;
            color: var(--color-text);
            font-size: 0.78em;
            max-width: 280px;
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
            pointer-events: none;
            transition: opacity 0.15s ease;
            opacity: 0;
            line-height: 1.4;
            display: none;
        }

        body.dark-theme .bt-strategy-tooltip {
            background: rgba(15, 23, 42, 0.95);
            color: #f1f5f9;
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.35), 0 8px 10px -6px rgba(0, 0, 0, 0.35);
        }

        .bt-strategy-tooltip .tip-title {
            font-weight: 700;
            color: var(--color-primary);
            margin-bottom: 4px;
            font-size: 1.05em;
        }

        .bt-strategy-tooltip .tip-desc {
            margin-bottom: 6px;
            color: #334155;
            font-size: 0.95em;
        }

        body.dark-theme .bt-strategy-tooltip .tip-desc {
            color: #cbd5e1;
        }

        .bt-strategy-tooltip .tip-footer {
            font-size: 0.9em;
            color: var(--color-text-muted);
            border-top: 1px solid rgba(0, 0, 0, 0.08);
            padding-top: 4px;
        }

        body.dark-theme .bt-strategy-tooltip .tip-footer {
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        .bt-strategy-tooltip .tip-rules {
            color: #1e293b;
        }

        body.dark-theme .bt-strategy-tooltip .tip-rules {
            color: #f1f5f9;
        }

        .bt-strategy-tooltip .tip-forward-return {
            font-size: 0.9em;
            color: var(--color-text-muted);
            border-top: 1px solid rgba(0, 0, 0, 0.08);
            margin-top: 6px;
            padding-top: 6px;
        }

        body.dark-theme .bt-strategy-tooltip .tip-forward-return {
            border-top: 1px solid rgba(255, 255, 255, 0.1);
        }

        /* 隱藏 rangeslider 中的重複圖表線條，只保留範圍選取框與拉柄 */
        .rangeslider-container .plot .rangeplot {
            display: none !important;
        }

        /* ── Mobile Responsive Overrides ──────────────────────────────── */
        @media (max-width: 768px) {
            /* General page spacing */
            body {
                padding: 10px !important;
            }
            .main-wrapper {
                width: 100% !important;
                padding: 12px !important;
            }
            
            /* Tabs bar scrollable on mobile */
            .tabs-bar {
                overflow-x: auto !important;
                white-space: nowrap !important;
                display: flex !important;
                scrollbar-width: none; /* Firefox */
            }
            .tabs-bar::-webkit-scrollbar {
                display: none; /* Safari and Chrome */
            }
            .tab-btn {
                padding: 8px 16px !important;
                flex-shrink: 0 !important;
            }
            
            /* Controls Bar */
            .controls {
                padding: 10px !important;
                flex-direction: column !important;
                align-items: stretch !important;
            }
            .controls > div {
                flex-direction: column !important;
                align-items: stretch !important;
                width: 100% !important;
            }
            .controls select, .controls input, .controls button {
                width: 100% !important;
            }
            #stockInputWrap {
                width: 100% !important;
            }
            /* #btnWatchlistPopover is absolutely-positioned over the input's right edge;
               the blanket button rule above stretches it to full width, which silently
               covers the whole #stockCode input and blocks typing on mobile. */
            #btnWatchlistPopover {
                width: auto !important;
            }
            /* #cardWatchlistSplit ("加入清單" + 分類 chevron) is a row-direction inline-flex
               pair; the blanket button rule above stretches BOTH children to full width,
               so they sit side-by-side at ~2x the row width instead of sharing it — pushing
               the chevron button (and the category dropdown anchored to it) off-screen and
               overflowing the whole page horizontally on mobile. */
            #cardWatchlistSplit {
                width: 100% !important;
            }
            #cardBtnWatchlist {
                width: auto !important;
                flex: 1 1 auto !important;
            }
            #btnCardWatchlistGroupPicker {
                width: 28px !important;
                flex: 0 0 auto !important;
            }
            #quickToolsBar {
                flex-direction: column !important;
                align-items: stretch !important;
            }
            #quickToolsBar > *, #quickToolsBar .gemini-style-box {
                width: 100% !important;
                box-sizing: border-box;
            }
            
            /* Stack KLine daily/weekly/monthly charts vertically */
            .charts-row {
                flex-direction: column !important;
                gap: 16px !important;
            }
            .chart-box {
                width: 100% !important;
            }
            
            /* Summary Panel Grid */
            .summary-panel {
                grid-template-columns: repeat(2, 1fr) !important;
                gap: 10px !important;
            }
            
            /* Override inline min-widths for data cards */
            #dividendCard, #corpFinanceCard, #dispersionPanel, #institutionalPanel, #companyInfoCard {
                min-width: 0 !important;
                width: 100% !important;
            }

            /* Financial details, ETF, News panels */
            #stockEtfCard, #stockNewsCard, #revenuePanel, #insiderPanel {
                width: 100% !important;
            }
            
            /* Large K-line chart modal */
            #largeKLineModal > div {
                width: 100vw !important;
                height: 100vh !important;
                max-height: 100vh !important;
                border-radius: 0 !important;
                padding: 10px !important;
            }
            /* Stack header elements of KLine modal */
            #largeKLineModal > div > div:first-child {
                flex-direction: column !important;
                align-items: flex-start !important;
                gap: 10px !important;
            }
            #largeKLineModal > div > div:first-child > span {
                flex-wrap: wrap !important;
                gap: 6px !important;
            }
            #largeKLineModal > div > div:nth-child(2) {
                flex-direction: column !important;
                align-items: stretch !important;
            }
            #largeKLineModal > div > div:nth-child(2) > div {
                flex-direction: column !important;
                align-items: stretch !important;
            }
            #divStrategyDropdownWrap, #largeChartIndicatorControls {
                margin-left: 0 !important;
                border-left: none !important;
                padding-left: 0 !important;
                margin-top: 8px !important;
                width: 100% !important;
                box-sizing: border-box;
            }
            #divStrategyDropdownWrap select, #largeChartIndicatorControls select {
                width: 100% !important;
            }
            #largeKLineChartDiv {
                height: 55vh !important;
            }

            /* User bar / Header styles on mobile */
            .user-bar {
                flex-direction: column !important;
                align-items: center !important;
                gap: 12px !important;
                padding: 10px 0 !important;
            }
            .brand-container {
                flex-direction: column !important;
                align-items: center !important;
                gap: 6px !important;
            }
            .user-bar > div:last-child {
                margin-left: 0 !important;
                flex-direction: column !important;
                align-items: center !important;
                width: 100% !important;
                gap: 10px !important;
            }
            .user-actions {
                flex-wrap: wrap !important;
                justify-content: center !important;
                width: 100% !important;
                gap: 8px !important;
            }
            .user-actions a, .user-actions button {
                flex: 1 1 calc(50% - 8px) !important;
                min-width: 110px !important;
                text-align: center !important;
                justify-content: center !important;
                font-size: 0.82em !important;
                padding: 6px 10px !important;
            }
            
            /* Strength Board Modal Responsive Styles */
            #strengthBoardIndustryBar {
                flex-wrap: nowrap !important;
                overflow-x: auto !important;
                padding-bottom: 6px !important;
                -webkit-overflow-scrolling: touch !important;
            }
            #strengthBoardIndustryBar::-webkit-scrollbar {
                height: 4px !important;
            }
            #strengthBoardIndustryBar::-webkit-scrollbar-thumb {
                background: var(--color-border) !important;
                border-radius: 2px !important;
            }
            #strengthBoardIndustryBar .sb-industry-chip {
                flex-shrink: 0 !important;
            }
            #strengthBoardFooterDesc {
                display: none !important;
            }
        }

        @media (max-width: 480px) {
            .summary-panel {
                grid-template-columns: 1fr !important;
            }
        }

        /* ── Controls Module Styles (Extracted from inline styles) ── */
        .tab-btn svg {
            width: 13px;
            height: 13px;
        }

        #stockControls {
            display: flex;
            flex-direction: column;
            gap: 12px;
            align-items: stretch;
            padding: 14px 20px;
        }

        .controls-group {
            display: flex;
            gap: 10px;
            align-items: center;
            justify-content: center;
            flex-wrap: wrap;
        }

        #btnMultiSelect {
            background: #475569;
            box-shadow: 0 2px 6px rgba(71,85,105,0.3);
        }

        #btnMultiSelect:hover {
            background: #334155;
        }

        #stockSelect {
            width: 240px;
        }

        #btnDiagnoseStrategy {
            display: none;
            background: #e85a5a;
            box-shadow: 0 2px 6px rgba(220,80,80,0.25);
        }

        #btnDiagnoseStrategy:hover {
            background: #dc2626;
        }

        .controls-divider-group {
            display: flex;
            gap: 10px;
            align-items: center;
            justify-content: center;
            flex-wrap: wrap;
            border-top: 1px dashed var(--color-border);
            padding-top: 12px;
            margin-top: 2px;
        }

        #stockInputWrap {
            position: relative;
            flex: 0 0 auto;
            width: 180px;
            transition: width 0.2s ease;
        }

        #stockCode {
            width: 100%;
            box-sizing: border-box;
            padding-right: 30px;
        }

        #mainStockDropdown {
            display: none;
            position: fixed;
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: 8px;
            box-shadow: 0 4px 16px rgba(0,0,0,0.15);
            z-index: 5000;
            max-height: 220px;
            overflow-y: auto;
        }

        #btnWatchlistPopover {
            position: absolute;
            right: 4px;
            top: 50%;
            transform: translateY(-50%);
            background: transparent;
            border: none;
            cursor: pointer;
            padding: 2px 3px;
            line-height: 1;
            color: #d97706;
        }

        #watchlistPopover {
            display: none;
            position: absolute;
            top: calc(100% + 6px);
            left: 0;
            z-index: 1000;
            background: var(--color-surface, #fff);
            border: 1px solid var(--color-border, #e2e8f0);
            border-radius: 8px;
            box-shadow: 0 8px 24px rgba(0,0,0,0.12);
            min-width: 300px;
            max-width: 380px;
        }

        #watchlistPopoverList {
            max-height: 260px;
            overflow-y: auto;
            padding: 6px 0;
        }

        .watchlist-popover-footer {
            border-top: 1px solid var(--color-border, #e2e8f0);
            padding: 8px 10px;
            display: flex;
            gap: 6px;
        }

        .watchlist-popover-footer button {
            flex: 1;
            font-size: 0.78em;
            padding: 5px 8px;
            background: var(--color-surface-alt, #f8fafc);
            border: 1px solid var(--color-border, #e2e8f0);
            border-radius: 5px;
            cursor: pointer;
            color: var(--color-text, #1e293b);
            font-weight: 600;
            box-shadow: none;
        }

        .watchlist-popover-footer button:hover {
            background: var(--color-border, #e2e8f0);
            transform: none;
            box-shadow: none;
        }

        #cardWatchlistSplit {
            display: none;
            position: relative;
        }

        #cardBtnWatchlist {
            color: #92400e;
            border-color: #d97706;
            font-weight: 600;
            border-top-right-radius: 0;
            border-bottom-right-radius: 0;
            border-right: none;
        }

        #btnCardWatchlistGroupPicker {
            color: #92400e;
            border-color: #d97706;
            padding: 6px 6px;
            min-width: 0;
            width: 28px;
            border-top-left-radius: 0;
            border-bottom-left-radius: 0;
        }

        #cardWatchlistGroupPicker {
            display: none;
            position: absolute;
            top: calc(100% + 6px);
            left: 0;
            z-index: 2000;
            background: var(--color-surface, #fff);
            border: 1px solid var(--color-border, #e2e8f0);
            border-radius: 8px;
            box-shadow: 0 8px 24px rgba(0,0,0,0.12);
            min-width: 170px;
            max-height: 260px;
            overflow-y: auto;
        }
        /* 分類選單列表項：蓋掉全站 button 預設的彩色陰影跟 hover 上浮動畫，
           不然看起來會像一顆顆浮起來的按鈕，而不是乾淨的下拉選單 */
        .wl-group-picker-item {
            display: flex;
            align-items: center;
            gap: 8px;
            width: 100%;
            box-sizing: border-box;
            text-align: left;
            padding: 8px 12px;
            border: none;
            border-radius: 0;
            background: transparent;
            box-shadow: none;
            cursor: pointer;
            font-size: 0.85em;
            font-weight: 400;
            color: var(--color-text);
            transition: background 0.15s;
        }
        .wl-group-picker-item:hover {
            background: var(--color-surface-alt);
            box-shadow: none;
            transform: none;
        }
        .wl-group-picker-item:active {
            transform: none;
        }

        #quickToolsBar {
            display: none;
            justify-content: center;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
            margin-top: 10px;
            padding: 10px;
            border-radius: var(--radius-sm);
            background: var(--color-surface-alt);
            width: 100%;
            box-sizing: border-box;
        }

        #geminiStyleSelect {
            display: none;
        }

        #cardHistockLink {
            color: #c2410c;
            border-color: #c2410c;
            font-weight: 600;
            text-decoration: none;
        }

        #cardYahooLink {
            color: var(--color-primary);
            border-color: var(--color-primary);
            font-weight: 600;
            text-decoration: none;
        }

        #cardGoogleNewsLink {
            color: #1a73e8;
            border-color: #1a73e8;
            font-weight: 600;
            text-decoration: none;
        }

        #exdivNoticeBar {
            display: none;
            width: 100%;
            margin-top: 8px;
            padding: 9px 14px;
            border-radius: var(--radius-sm);
            background: rgba(217,119,6,0.08);
            border: 1px solid rgba(217,119,6,0.3);
            color: var(--color-text);
            font-size: 0.88em;
            align-items: center;
            gap: 10px;
            flex-wrap: wrap;
            box-sizing: border-box;
        }

        #exdivNoticeBar svg {
            width: 15px;
            height: 15px;
            flex-shrink: 0;
            stroke: #d97706;
            fill: none;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        #exdivNoticeText {
            flex: 1;
        }

        #stockHealthCard {
            display: none;
            width: 100%;
            margin-top: 10px;
            border-radius: var(--radius-sm);
            background: var(--color-surface-alt);
            border: 1px solid var(--color-border);
            overflow: hidden;
        }

        #stockSafetyCard {
            margin-top: 10px;
            border-radius: var(--radius-sm);
            background: var(--color-surface-alt);
            border: 1px solid var(--color-border);
            overflow: hidden;
        }

        #stockSafetyHeader,
        #stockHealthHeader {
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: flex-start;
            gap: 8px;
            padding: 10px 14px;
            background: transparent;
            border: none;
            cursor: pointer;
            color: var(--color-text);
            font-weight: 600;
            font-size: 0.9em;
        }

        #stockSafetyHeader:hover,
        #stockHealthHeader:hover {
            background: rgba(13,148,136,0.06) !important;
        }

        .header-inner-span {
            display: inline-flex;
            align-items: center;
            gap: 7px;
        }

        #stockSafetyBody,
        #stockHealthBody {
            padding: 0 14px 12px;
        }

        #strategyCheckboxes {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .controls-footer-right {
            margin-top: 15px;
            text-align: right;
        }

        #btnApplyIntersection {
            background: #1d4ed8;
            padding: 8px 18px;
        }

        #btnApplyIntersection:hover {
            background: #1e40af;
        }

        /* ── Navbar Module Styles (Extracted from inline styles) ── */
        .brand-container {
            display: flex;
            flex-direction: column;
            align-items: flex-start;
            gap: 2px;
        }

        .brand-row {
            display: flex;
            align-items: center;
            gap: 6px;
        }

        .brand-title svg {
            width: 22px;
            height: 22px;
            color: #ef4444;
        }

        .brand-title span {
            font-size: 24px;
            font-weight: 800;
        }

        .sync-date-container {
            display: flex;
            align-items: center;
            margin-left: 30px;
        }

        .sync-date-text {
            font-size: 12px;
            color: #718096;
            padding: 1px 6px;
            white-space: nowrap;
        }

        #status {
            display: none;
            padding: 2px 10px;
        }

        .user-bar-right {
            display: flex;
            align-items: center;
            gap: 16px;
            margin-left: auto;
        }

        .user-avatar-fallback {
            display: flex;
            align-items: center;
            justify-content: center;
            background: var(--color-primary-soft);
            color: var(--color-primary);
        }

        .user-badge-admin {
            background: var(--color-primary);
            color: white;
            font-size: 11px;
            padding: 2px 6px;
            border-radius: 4px;
            font-weight: bold;
            margin-left: 6px;
            text-decoration: none;
            cursor: pointer;
            display: inline-block;
            transition: transform 0.15s, box-shadow 0.15s;
        }
        .user-badge-admin:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 10px rgba(59,130,246,0.35);
        }

        .user-actions {
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            justify-content: flex-end;
            gap: 8px;
        }

        .btn-trade-portal {
            color: #f59e0b;
            border-color: #f59e0b;
        }

        .btn-trade-portal:hover {
            background: rgba(245, 158, 11, 0.1);
        }

        body.dark-theme .btn-trade-portal:hover {
            background: rgba(245, 158, 11, 0.18);
        }

        .btn-watchlist {
            color: #d97706;
            border-color: #d97706;
        }

        .btn-watchlist:hover {
            background: rgba(217, 119, 6, 0.1);
        }

        body.dark-theme .btn-watchlist:hover {
            background: rgba(217, 119, 6, 0.18);
        }

        .btn-telegram-link {
            color: #0088cc;
            border-color: #0088cc;
        }

        .btn-telegram-link:hover {
            background: rgba(0, 136, 204, 0.1);
        }

        body.dark-theme .btn-telegram-link:hover {
            background: rgba(0, 136, 204, 0.18);
        }

        .btn-tour-replay {
            color: var(--color-text-muted);
            border-color: var(--color-border);
        }

        .btn-tour-replay:hover {
            background: var(--color-surface-alt);
        }

        .btn-nav-ghost svg {
            width: 14px;
            height: 14px;
        }

        .btn-theme-toggle svg {
            width: 20px;
            height: 20px;
        }

        /* ── 拖曳排序樣式 ── */
        .sortable-ghost {
            opacity: 0.4;
            background: var(--color-surface-alt);
        }
        .bulletin-card {
            cursor: grab;
        }
        .bulletin-card:active {
            cursor: grabbing;
        }
        .wl-group-drag-handle {
            display: inline-flex;
            align-items: center;
            color: var(--color-text-muted);
            cursor: grab;
        }
        .wl-group-drag-handle:active {
            cursor: grabbing;
        }

        /* ── 新手引導 Tour ── */
        .tour-blocker {
            position: fixed;
            z-index: 10050;
            background: transparent;
        }
        .tour-spotlight {
            position: fixed;
            z-index: 10051;
            background: transparent;
            border-radius: var(--radius-sm);
            box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.65), 0 0 0 3px var(--color-primary);
            pointer-events: none;
            transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
        }
        .tour-tooltip {
            position: fixed;
            z-index: 10052;
            width: 300px;
            max-width: calc(100vw - 32px);
            background: var(--color-surface);
            border: 1px solid var(--color-border);
            border-radius: var(--radius-md);
            box-shadow: var(--shadow-lg);
            padding: 16px 18px;
            color: var(--color-text);
            transition: top 0.25s ease, left 0.25s ease;
        }
        .tour-tooltip-title {
            font-weight: 700;
            font-size: 0.98em;
            margin-bottom: 6px;
            display: flex;
            align-items: center;
            gap: 8px;
            color: var(--color-primary);
        }
        .tour-tooltip-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            object-fit: cover;
            border: 1.5px solid var(--color-primary);
            flex-shrink: 0;
        }
        .tour-tooltip-text {
            font-size: 0.88em;
            line-height: 1.6;
            color: var(--color-text-muted);
            margin-bottom: 14px;
        }
        .tour-tooltip-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 8px;
        }
        .tour-tooltip-progress {
            font-size: 0.78em;
            color: var(--color-text-subtle);
        }
        .tour-tooltip-actions {
            display: flex;
            gap: 8px;
        }
        .tour-btn {
            border: 1px solid var(--color-border);
            background: var(--color-surface-alt);
            color: var(--color-text);
            border-radius: var(--radius-sm);
            padding: 6px 12px;
            font-size: 0.82em;
            font-weight: 600;
            cursor: pointer;
        }
        .tour-btn-primary {
            border-color: var(--color-primary);
            background: var(--color-primary);
            color: #fff;
        }
        .tour-btn-skip {
            background: transparent;
            border-color: transparent;
            color: var(--color-text-subtle);
        }


/* ==========================================================================
   產業概念分頁樣式 (8大類 ➔ 26小類)
   ========================================================================== */
.concept-layout {
    display: flex;
    gap: 20px;
    align-items: stretch;
    width: 100%;
    margin-top: 15px;
}

@media (max-width: 900px) {
    .concept-layout {
        flex-direction: column;
    }
    .concept-sidebar {
        flex: 1 1 auto !important;
    }
}

.concept-sidebar {
    flex: 0 0 280px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 15px;
    box-sizing: border-box;
}

.concept-main-content {
    flex: 1;
    min-width: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-sizing: border-box;
}

.concept-section-title {
    margin: 0 0 15px 0;
    font-size: 0.92em;
    font-weight: 700;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 8px;
}

.concept-major-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.concept-major-item {
    width: 100%;
    text-align: left;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
    padding: 12px 15px;
    color: var(--color-text);
    font-size: 0.88em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
    outline: none;
    box-shadow: none;
}

.concept-major-item:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

.concept-major-item.active {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: white !important;
}

.concept-major-item .badge {
    background: var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.75em;
    padding: 2px 6px;
    border-radius: 20px;
    font-weight: normal;
}

.concept-major-item.active .badge {
    background: rgba(255,255,255,0.25);
    color: white;
}

.concept-sub-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.concept-sub-card {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 15px;
    cursor: pointer;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
}

.concept-sub-card:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
    transform: translateY(-2px);
}

.concept-sub-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

.concept-sub-card-title {
    font-size: 0.9em;
    font-weight: 700;
    color: var(--color-text);
    margin: 0;
    line-height: 1.35;
}

.concept-sub-card-count {
    font-size: 0.75em;
    color: var(--color-text-muted);
    background: var(--color-border-light);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

.concept-sub-card-chips {
    border-top: 1px dashed var(--color-border-light);
    padding-top: 8px;
    font-size: 0.78em;
    color: var(--color-text-muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chip-flow-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chip-value {
    font-weight: 700;
    font-family: monospace, sans-serif;
}

.chip-value.positive {
    color: var(--color-up);
}

.chip-value.negative {
    color: var(--color-down);
}

/* 全域紅綠漲跌配色 */
.positive {
    color: var(--color-up) !important;
}

.negative {
    color: var(--color-down) !important;
}


/* ==========================================================================
   樹圖 (Treemap) 專屬樣式
   ========================================================================== */
.concept-treemap {
    position: relative;
    width: 100%;
    height: 380px;
    background: var(--color-surface-alt);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.treemap-node {
    position: absolute;
    box-sizing: border-box;
    border: 1px solid var(--color-surface);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 6px;
    text-align: center;
    color: white !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    user-select: none;
    overflow: hidden;
}

.treemap-node:hover {
    filter: brightness(1.18);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.45);
    z-index: 10;
}

.treemap-node-title {
    font-size: 0.82em;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-all;
}

.treemap-node-value {
    font-size: 0.76em;
    font-weight: 600;
    font-family: monospace, sans-serif;
    opacity: 0.95;
}

/* 熱力圖角標：異常 z-score 閃電 (右上)、風險重訊數 (左上) */
.treemap-node-badge {
    position: absolute;
    top: 3px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 0.68em;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}

.treemap-node-badge.anomaly {
    right: 4px;
    color: #fde047;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.6));
}

.treemap-node-badge.risk {
    left: 4px;
    background: rgba(0, 0, 0, 0.4);
    color: #fecaca;
    border-radius: 8px;
    padding: 2px 5px;
}

/* 日期前後步進鈕 */
.treemap-date-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
}

.treemap-date-step:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.treemap-date-step .icon {
    width: 13px;
    height: 13px;
}

/* 個股層下鑽返回列 */
.treemap-drill-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.treemap-drill-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8em;
    font-weight: 600;
    padding: 4px 10px;
    cursor: pointer;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
}

.treemap-drill-back:hover {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

/* ==========================================================================
   📂 產業概念股明細表格壓縮樣式 (防止出現拉bar)
   ========================================================================== */
.concept-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto !important;
    font-size: 0.83em !important; /* 跟自選清單一致 */
}

.concept-table th, 
.concept-table td {
    padding: 6px 4px !important;
    text-align: right;
    white-space: nowrap !important;
}

.concept-table th:first-child,
.concept-table td:first-child {
    text-align: left !important;
}



