<div class="alpha-homepage-panel"
     data-alpha-scope="{{ alpha_scope|default:'portfolio' }}"
     data-alpha-refresh-status="{{ alpha_meta.refresh_status|default:'' }}"
     data-alpha-refresh-triggered="{% if alpha_meta.refresh_triggered %}true{% else %}false{% endif %}"
     data-alpha-poll-after-ms="{{ alpha_meta.poll_after_ms|default:5000 }}">
    <div class="investment-disclaimer compact">
        <div class="disclaimer-icon">⚠️</div>
        <div class="disclaimer-text">
            <strong>免责声明：</strong>当前展示的是候选/排名与执行前评估，<span class="highlight">不构成投资建议</span>。
        </div>
    </div>

    {% if alpha_scope == "general" %}
    <div class="alpha-banner alpha-banner-info">
        <strong>通用 Alpha 仅供研究排名</strong>
        <span>当前结果不绑定账户、组合、scope hash 或仓位约束，不会生成可执行建议。</span>
    </div>
    {% endif %}

    <div class="alpha-pool-summary">
        <div>
            <strong>{% if alpha_scope == "general" %}{{ alpha_pool.label|default:"通用 Alpha 研究池" }}{% else %}{{ alpha_pool.label|default:"账户驱动 Alpha 池" }}{% endif %}</strong>
            <div class="alpha-pool-meta">
                <span>池子规模 {{ alpha_pool.pool_size|default:0 }}</span>
                <span>市场 {{ alpha_pool.market|default:"CN" }}</span>
                {% if alpha_scope == "general" %}
                <span>用途 研究排名</span>
                {% else %}
                <span>组合 {{ alpha_pool.portfolio_name|default:"默认组合" }}</span>
                <span>模式 {{ alpha_pool.pool_mode|default:selected_alpha_pool_mode|default:"strict_valuation" }}</span>
                {% if alpha_pool.scope_hash %}<span>scope {{ alpha_pool.scope_hash }}</span>{% endif %}
                {% endif %}
            </div>
        </div>
        <div>
            <div class="alpha-pool-reason">{{ alpha_pool.selection_reason|default:"按当前激活组合所属市场生成候选池。" }}</div>
            {% if alpha_scope != "general" %}
            <div class="alpha-pool-controls" style="margin-top: 10px;">
                <label for="alphaPoolModeSelect"><strong>股票池模式</strong></label>
                <select id="alphaPoolModeSelect"
                        class="form-control form-control-sm"
                        onchange="reloadAlphaStocksTable(10)"
                        style="max-width: 220px; display: inline-block; margin-left: 8px;">
                    {% for choice in alpha_pool_mode_choices %}
                    <option value="{{ choice.value }}" {% if choice.value == selected_alpha_pool_mode %}selected{% endif %}>{{ choice.label }}</option>
                    {% endfor %}
                </select>
            </div>
            {% endif %}
        </div>
    </div>

    {% if alpha_meta.warning_message %}
    <div class="alpha-banner alpha-banner-{{ alpha_meta.warning_level|default:'warning' }}">
        <strong>{{ alpha_meta.warning_title|default:"Alpha 当前为降级结果" }}</strong>
        <span>{{ alpha_meta.warning_message }}</span>
        {% if alpha_meta.auto_refresh_message %}
        <span>{{ alpha_meta.auto_refresh_message }}</span>
        {% endif %}
        {% if alpha_meta.async_task_id %}
        <span>任务 {{ alpha_meta.async_task_id }}</span>
        {% endif %}
        {% if alpha_meta.refresh_status == "recently_queued" %}
        <span>后台任务已在队列中，页面会稍后自动刷新。</span>
        {% endif %}
        {% if alpha_meta.auto_refresh_error %}
        <span>自动触发失败：{{ alpha_meta.auto_refresh_error }}</span>
        {% endif %}
    </div>
    {% endif %}

    {% if alpha_meta.uses_cached_data %}
    <div class="alpha-cache-summary">
        <strong>当前展示缓存/回退结果</strong>
        <span>请求日期 {{ alpha_meta.requested_trade_date|default:"-" }}</span>
        <span>
            评分日期
            {% if alpha_meta.effective_asof_date %}
                {{ alpha_meta.effective_asof_date }}
            {% elif alpha_meta.cache_date %}
                {{ alpha_meta.cache_date }}
            {% else %}
                -
            {% endif %}
        </span>
        {% if alpha_meta.cache_created_at %}<span>缓存写入 {{ alpha_meta.cache_created_at }}</span>{% endif %}
        {% if alpha_meta.cache_reason %}<span>调用缓存原因：{{ alpha_meta.cache_reason }}</span>{% endif %}
        {% if alpha_meta.refresh_triggered %}<span>系统已自动触发实时刷新任务。</span>{% endif %}
        <button type="button" class="btn btn-primary btn-sm" style="margin-left: 12px;" onclick="triggerAlphaRealtimeRefresh({{ top_n|default:10 }}, this)">⚡ 立即推理刷新</button>
    </div>
    {% else %}
    {% if alpha_meta.no_recommendation_reason %}
    <div class="alpha-cache-summary alpha-cache-summary-pending">
        <strong>正在等待账户池 Alpha 推理</strong>
        <span>请求日期 {{ alpha_meta.requested_trade_date|default:"-" }}</span>
        {% if alpha_meta.refresh_status == "queued" %}
        <span>后台任务已触发</span>
        {% elif alpha_meta.refresh_status == "recently_queued" %}
        <span>后台任务已在队列中</span>
        {% elif alpha_meta.refresh_status == "failed" %}
        <span>自动触发失败，请手动重试</span>
        {% else %}
        <span>尚无可用 cache</span>
        {% endif %}
    </div>
    <div style="margin-top: 12px;">
        <button type="button" class="btn btn-primary btn-sm" onclick="triggerAlphaRealtimeRefresh({{ top_n|default:10 }}, this)">
            ⚡ 立即推理刷新
        </button>
    </div>
    {% else %}
    <div class="alpha-cache-summary alpha-cache-summary-live">
        <strong>当前优先展示实时结果</strong>
        <span>请求日期 {{ alpha_meta.requested_trade_date|default:"-" }}</span>
        <span>实际评分日 {{ alpha_meta.effective_asof_date|default:"-" }}</span>
    </div>
    {% endif %}
    {% endif %}

    <section class="alpha-section-block">
        <div class="alpha-section-header">
            <div>
                <h4>Alpha Top 候选/排名</h4>
                <p>{% if alpha_scope == "general" %}通用研究层排序，不生成可执行建议。{% else %}账户专属排序，只有 readiness 通过才可进入可行动候选。{% endif %}</p>
            </div>
            <div class="alpha-section-actions">
                <button type="button"
                        class="btn btn-outline-primary btn-sm"
                        onclick="triggerAlphaRealtimeRefresh({{ top_n|default:10 }}, this)">
                    🔄 刷新首页推荐
                </button>
                <a href="{% url 'dashboard:alpha_ranking' %}?alpha_scope={{ alpha_scope|default:'portfolio' }}{% if selected_portfolio_id and alpha_scope != 'general' %}&portfolio_id={{ selected_portfolio_id }}{% endif %}{% if selected_alpha_pool_mode and alpha_scope != 'general' %}&pool_mode={{ selected_alpha_pool_mode|urlencode }}{% endif %}&top_n=200" class="alpha-history-link">
                    查看完整排名
                </a>
                <a href="{% url 'dashboard:alpha_history' %}{% if selected_portfolio_id %}?portfolio_id={{ selected_portfolio_id }}{% endif %}" class="alpha-history-link">
                    查看历史记录
                </a>
            </div>
        </div>
        {% if alpha_stocks %}
        <div class="alpha-top-grid">
            {% for stock in alpha_stocks %}
            <article class="alpha-stock-card alpha-stage-{{ stock.stage|default:'top_ranked' }}"
                hx-get="{% url 'api_dashboard:alpha_factor_panel' %}?code={{ stock.code|urlencode }}&source={{ stock.source|urlencode }}&top_n={{ top_n|default:10 }}&alpha_scope={{ alpha_scope|default:'portfolio'|urlencode }}{% if selected_portfolio_id and alpha_scope != 'general' %}&portfolio_id={{ selected_portfolio_id }}{% endif %}{% if selected_alpha_pool_mode and alpha_scope != 'general' %}&pool_mode={{ selected_alpha_pool_mode|urlencode }}{% endif %}"
                hx-trigger="click"
                hx-target="#alphaFactorPanel"
                hx-swap="innerHTML">
                <div class="alpha-stock-card-header">
                    <div>
                        <span class="alpha-rank">#{{ stock.rank }}</span>
                        <a href="{% url 'equity:detail' stock.code %}" class="alpha-stock-link" onclick="event.stopPropagation();">
                            {{ stock.code }}
                        </a>
                        <div class="alpha-stock-name">{{ stock.name|default:"-" }}</div>
                    </div>
                    <span class="alpha-stage-badge alpha-stage-badge-{{ stock.stage|default:'top_ranked' }}">
                        {{ stock.stage_label|default:"Alpha Top 候选/排名" }}
                    </span>
                </div>

                <div class="alpha-stock-score-row">
                    <span>评分 {{ stock.alpha_score|floatformat:3 }}</span>
                    <span>置信度 {{ stock.confidence|floatformat:2 }}</span>
                    <span>来源 {{ stock.source }}</span>
                </div>
                <div class="alpha-stock-score-row alpha-stock-score-muted">
                    <span>评分日 {{ stock.asof_date|default:"-" }}</span>
                    <span>风控 {{ stock.gate_status|default:"blocked" }}</span>
                    <span>建议仓位 {{ stock.suggested_position_pct|default:0|floatformat:1 }}%</span>
                </div>

                <div class="alpha-reason-block">
                    <strong>推荐依据</strong>
                    <ul>
                        {% if stock.recommendation_basis.provider_source %}
                        <li>模型/数据源：{{ stock.recommendation_basis.provider_source }}，评分日 {% if stock.recommendation_basis.asof_date %}{{ stock.recommendation_basis.asof_date }}{% elif stock.recommendation_basis.effective_asof_date %}{{ stock.recommendation_basis.effective_asof_date }}{% else %}-{% endif %}</li>
                        {% endif %}
                        {% if stock.recommendation_basis.scope_hash %}
                        <li>账户池：{{ stock.recommendation_basis.scope_label|default:"账户驱动 Alpha 池" }} / {{ stock.recommendation_basis.scope_hash }}</li>
                        {% endif %}
                        {% for basis in stock.recommendation_basis.factor_basis|slice:":3" %}
                        <li>{{ basis }}</li>
                        {% endfor %}
                        {% for reason in stock.buy_reasons|slice:":3" %}
                        <li>{{ reason.text }}</li>
                        {% empty %}
                            {% if not stock.recommendation_basis.factor_basis %}
                            <li>暂无可展示的模型依据。</li>
                            {% endif %}
                        {% endfor %}
                    </ul>
                </div>

                <div class="alpha-reason-block alpha-reason-block-muted">
                    <strong>不买理由</strong>
                    <ul>
                        {% for reason in stock.no_buy_reasons|slice:":3" %}
                        <li>{{ reason.text }}</li>
                        {% empty %}
                        <li>当前无明显阻断项。</li>
                        {% endfor %}
                    </ul>
                </div>

                <div class="alpha-reason-block alpha-reason-block-invalidation">
                    <strong>证伪条件</strong>
                    <p>{{ stock.invalidation_summary|default:"暂无证伪条件。" }}</p>
                </div>

                {% if stock.stage == "pending" and stock.request_id %}
                <div class="alpha-card-actions-row">
                    <button type="button"
                            class="alpha-discard-btn"
                            onclick="event.stopPropagation(); discardAlphaPendingRequest('{{ stock.request_id|escapejs }}');">
                        丢弃待执行
                    </button>
                    <span>保留取消记录，可回溯。</span>
                </div>
                {% endif %}
            </article>
            {% endfor %}
        </div>
        {% else %}
        <div class="empty-state alpha-empty">
            <div class="empty-icon">📊</div>
            <p>暂无可信 Alpha 候选数据</p>
            <p>
                {% if alpha_scope == "general" %}
                    通用 Alpha 暂无可展示研究排名；不会用静态名单冒充结果。
                {% else %}
                    {{ alpha_meta.no_recommendation_reason|default:"账户池尚无真实推理或缓存结果；系统不会用硬编码股票池、静态名单或默认 ETF 冒充推荐。" }}
                {% endif %}
            </p>
            <button type="button" class="btn btn-primary btn-sm" onclick="triggerAlphaRealtimeRefresh({{ top_n|default:10 }}, this)">
                ⚡ 立即推理刷新
            </button>
        </div>
        {% endif %}
    </section>

    {% if alpha_scope == "general" %}
    <section class="alpha-section-block alpha-research-only-block">
        <div class="alpha-section-header">
            <div>
                <h4>通用 Alpha 不生成行动建议</h4>
                <p>{{ alpha_meta.blocked_reason|default:"通用 Alpha 仅用于研究排名；请切换到账户专属 Alpha 并完成 scoped 推理后再评估可行动候选。" }}</p>
            </div>
        </div>
    </section>
    {% else %}
    <div class="alpha-secondary-grid">
        <section class="alpha-section-block alpha-exit-monitor-block">
            <div class="alpha-section-header">
                <div>
                    <h4>持仓退出监控</h4>
                    <p>已持仓证券统一展示 HOLD / REDUCE / SELL、证伪摘要和退出契约，便于持续跟踪卖出时点。</p>
                </div>
                <span class="alpha-pill">{{ alpha_exit_watchlist|length }}</span>
            </div>
            {% if alpha_exit_watch_summary.total %}
            <div class="alpha-exit-summary-row">
                <span class="alpha-summary-pill alpha-summary-pill-urgent">立即处理 {{ alpha_exit_watch_summary.urgent_count|default:0 }}</span>
                <span class="alpha-summary-pill alpha-summary-pill-sell">SELL {{ alpha_exit_watch_summary.sell_count|default:0 }}</span>
                <span class="alpha-summary-pill alpha-summary-pill-reduce">REDUCE {{ alpha_exit_watch_summary.reduce_count|default:0 }}</span>
                <span class="alpha-summary-pill">HOLD {{ alpha_exit_watch_summary.hold_count|default:0 }}</span>
            </div>
            {% endif %}
            {% if alpha_exit_watchlist %}
            <div class="alpha-exit-panel-sync"
                 hx-get="{% url 'api_dashboard:alpha_exit_panel' %}?asset_code={% if alpha_exit_selected_asset_code %}{{ alpha_exit_selected_asset_code|urlencode }}{% else %}{{ alpha_exit_watchlist.0.asset_code|urlencode }}{% endif %}{% if alpha_exit_selected_account_id %}&account_id={{ alpha_exit_selected_account_id }}{% elif alpha_exit_watchlist.0.account_id %}&account_id={{ alpha_exit_watchlist.0.account_id }}{% endif %}&top_n={{ top_n|default:10 }}&alpha_scope={{ alpha_scope|default:'portfolio'|urlencode }}{% if selected_portfolio_id and alpha_scope != 'general' %}&portfolio_id={{ selected_portfolio_id }}{% endif %}{% if selected_alpha_pool_mode and alpha_scope != 'general' %}&pool_mode={{ selected_alpha_pool_mode|urlencode }}{% endif %}"
                 hx-trigger="load"
                 hx-target="#alphaExitDetailPanel"
                 hx-swap="innerHTML"
                 aria-hidden="true"></div>
            <div class="alpha-list">
                {% for item in alpha_exit_watchlist %}
                <div class="alpha-list-item alpha-list-item-exit alpha-list-item-exit-{{ item.exit_action|lower }}{% if item.is_selected %} is-selected{% endif %}"
                     data-exit-asset-code="{{ item.asset_code }}"
                     {% if item.account_id %}data-exit-account-id="{{ item.account_id }}"{% endif %}
                     hx-get="{% url 'api_dashboard:alpha_exit_panel' %}?asset_code={{ item.asset_code|urlencode }}{% if item.account_id %}&account_id={{ item.account_id }}{% endif %}&top_n={{ top_n|default:10 }}&alpha_scope={{ alpha_scope|default:'portfolio'|urlencode }}{% if selected_portfolio_id and alpha_scope != 'general' %}&portfolio_id={{ selected_portfolio_id }}{% endif %}{% if selected_alpha_pool_mode and alpha_scope != 'general' %}&pool_mode={{ selected_alpha_pool_mode|urlencode }}{% endif %}"
                     hx-trigger="click"
                     hx-target="#alphaExitDetailPanel"
                     hx-swap="innerHTML"
                     onclick="this.closest('.alpha-list').querySelectorAll('.alpha-list-item-exit').forEach(function(el){el.classList.remove('is-selected');}); this.classList.add('is-selected');">
                    <div class="alpha-list-main">
                        <strong>{{ item.asset_code }}</strong>
                        <span>{{ item.asset_name }}</span>
                        <span class="alpha-exit-badge alpha-exit-badge-{{ item.exit_action|lower }}">{{ item.exit_action_label }}</span>
                        <span class="alpha-priority-text">{{ item.priority_label }}</span>
                        {% if item.user_action_label %}
                        <span class="alpha-priority-text">处理状态 {{ item.user_action_label }}</span>
                        {% endif %}
                    </div>
                    <div class="alpha-list-meta">
                        <span>账户 {{ item.account_name }}</span>
                        <span>持仓 {{ item.shares|floatformat:0 }}</span>
                        <span>市值 {{ item.market_value|floatformat:0 }}</span>
                        <span>决策侧 {{ item.decision_side_label }}</span>
                    </div>
                    <div class="alpha-list-meta">
                        {% if item.stop_loss_price %}<span>止损 {{ item.stop_loss_price }}</span>{% endif %}
                        {% if item.target_price_low or item.target_price_high %}
                        <span>目标带 {{ item.target_price_low|default:"-" }} - {{ item.target_price_high|default:"-" }}</span>
                        {% endif %}
                        <span>{{ item.contract_status_label }}</span>
                        {% if item.reduce_quantity %}<span>建议减仓 {{ item.reduce_quantity }}</span>{% endif %}
                    </div>
                    <div class="alpha-list-text">退出来源：{{ item.exit_source }}{% if item.exit_reason_text %}；{{ item.exit_reason_text }}{% endif %}</div>
                    <div class="alpha-list-text">证伪/跟踪：{{ item.invalidation_summary }}</div>
                    {% if item.source_signal_ids %}
                    <div class="alpha-list-text">来源信号：{{ item.source_signal_ids|join:", " }}</div>
                    {% endif %}
                    <div class="alpha-list-actions">
                        {% if item.account_detail_url %}
                        <a href="{{ item.account_detail_url }}" class="alpha-inline-link" onclick="event.stopPropagation();">
                            查看账户持仓
                        </a>
                        {% endif %}
                        {% if item.recommendation_detail_url %}
                        <a href="{{ item.recommendation_detail_url }}" class="alpha-inline-link" target="_blank" rel="noopener" onclick="event.stopPropagation();">
                            推荐明细 API
                        </a>
                        {% endif %}
                        {% if item.transition_plan_detail_url %}
                        <a href="{{ item.transition_plan_detail_url }}" class="alpha-inline-link" target="_blank" rel="noopener" onclick="event.stopPropagation();">
                            调仓计划 API
                        </a>
                        {% endif %}
                        <a href="{{ item.decision_workspace_url|default:'/decision/workspace/' }}" class="alpha-inline-link" onclick="event.stopPropagation();">
                            进入决策工作台
                        </a>
                    </div>
                </div>
                {% endfor %}
            </div>
            {% else %}
            <div class="alpha-exit-panel-sync"
                 hx-get="{% url 'api_dashboard:alpha_exit_panel' %}?top_n={{ top_n|default:10 }}&alpha_scope={{ alpha_scope|default:'portfolio'|urlencode }}{% if selected_portfolio_id and alpha_scope != 'general' %}&portfolio_id={{ selected_portfolio_id }}{% endif %}{% if selected_alpha_pool_mode and alpha_scope != 'general' %}&pool_mode={{ selected_alpha_pool_mode|urlencode }}{% endif %}"
                 hx-trigger="load"
                 hx-target="#alphaExitDetailPanel"
                 hx-swap="innerHTML"
                 aria-hidden="true"></div>
            <p class="alpha-empty-inline">当前没有可展示的持仓退出监控项。</p>
            {% endif %}
        </section>

        <section class="alpha-section-block">
            <div class="alpha-section-header">
                <div>
                    <h4>可行动候选</h4>
                    <p>通过执行前风控且给出建议仓位的标的。</p>
                </div>
                <span class="alpha-pill">{{ alpha_actionable_candidates|length }}</span>
            </div>
            {% if alpha_actionable_candidates %}
            <div class="alpha-list">
                {% for item in alpha_actionable_candidates %}
                <div class="alpha-list-item">
                    <div class="alpha-list-main">
                        <strong>{{ item.code }}</strong>
                        <span>{{ item.name }}</span>
                    </div>
                    <div class="alpha-list-meta">
                        <span>建议仓位 {{ item.suggested_position_pct|floatformat:1 }}%</span>
                        <span>建议数量 {{ item.suggested_quantity }}</span>
                    </div>
                    <div class="alpha-list-text">{{ item.buy_reason_summary }}</div>
                </div>
                {% endfor %}
            </div>
            {% else %}
            <p class="alpha-empty-inline">当前没有通过账户级风控的可行动候选。</p>
            {% endif %}
        </section>

        <section class="alpha-section-block">
            <div class="alpha-section-header">
                <div>
                    <h4>待执行队列</h4>
                    <p>历史审批/执行请求，不代表当前 Alpha 推荐。</p>
                </div>
                <span class="alpha-pill">{{ alpha_pending_requests|length }}</span>
            </div>
            {% if alpha_pending_requests %}
            <div class="alpha-list">
                {% for item in alpha_pending_requests %}
                <div class="alpha-list-item alpha-list-item-pending">
                    <div class="alpha-list-main">
                        <strong>{{ item.code }}</strong>
                        <span>{{ item.name }}</span>
                    </div>
                    <div class="alpha-list-meta">
                        <span>数量 {{ item.suggested_quantity|floatformat:0 }}</span>
                        <span>金额 {{ item.suggested_notional|floatformat:0 }}</span>
                        {% if item.risk_snapshot.execution_status %}
                        <span>状态 {{ item.risk_snapshot.execution_status }}</span>
                        {% endif %}
                    </div>
                    {% if item.reason_summary %}
                    <div class="alpha-list-text">来源原因：{{ item.reason_summary }}</div>
                    {% endif %}
                    <div class="alpha-list-text">{{ item.no_buy_reasons.0.text|default:"已进入待执行队列。" }}</div>
                    {% if item.request_id %}
                    <div class="alpha-list-actions">
                        <button type="button"
                                class="alpha-discard-btn"
                                onclick="discardAlphaPendingRequest('{{ item.request_id|escapejs }}');">
                            丢弃待执行
                        </button>
                        <span>状态会改为已取消，记录仍保留。</span>
                    </div>
                    {% endif %}
                </div>
                {% endfor %}
            </div>
            {% else %}
            <p class="alpha-empty-inline">当前待执行队列为空。</p>
            {% endif %}
        </section>
    </div>
    {% endif %}

    <section class="alpha-section-block">
        <div class="alpha-section-header">
            <div>
                <h4>最近推荐记录</h4>
                <p>系统已落库，可回溯历史候选与理由。</p>
            </div>
            {% if alpha_history_run_id %}
            <a href="{% url 'dashboard:alpha_history' %}{% if selected_portfolio_id %}?portfolio_id={{ selected_portfolio_id }}{% endif %}" class="alpha-history-link">
                打开完整时间线
            </a>
            {% endif %}
        </div>
        {% if alpha_recent_runs %}
        <div class="alpha-history-list">
            {% for run in alpha_recent_runs %}
            <div class="alpha-history-item">
                <div class="alpha-history-main">
                    <strong>{{ run.trade_date }}</strong>
                    <span>{{ run.scope_label }}</span>
                </div>
                <div class="alpha-history-meta">
                    <span>来源 {{ run.source }}</span>
                    <span>{% if run.uses_cached_data %}缓存{% else %}实时优先{% endif %}</span>
                    {% if run.effective_asof_date %}<span>评分日 {{ run.effective_asof_date }}</span>{% endif %}
                    {% if run.legacy_hardcoded_fallback %}<span>旧版回退记录</span>{% endif %}
                </div>
                {% if run.reliability_note %}
                <div class="alpha-history-text alpha-history-text-warning">{{ run.reliability_note }}</div>
                {% elif run.cache_reason %}
                <div class="alpha-history-text">{{ run.cache_reason }}</div>
                {% endif %}
            </div>
            {% endfor %}
        </div>
        {% else %}
        <p class="alpha-empty-inline">暂无历史记录。</p>
        {% endif %}
    </section>
</div>

<style>
.alpha-homepage-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.alpha-pool-summary,
.alpha-cache-summary,
.alpha-banner,
.alpha-section-block {
    border: 1px solid #dbe4f0;
    border-radius: 14px;
    background: #fff;
    padding: 14px 16px;
}

.alpha-pool-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    background: linear-gradient(135deg, #f7fbff, #eef5ff);
}

.alpha-pool-meta,
.alpha-cache-summary,
.alpha-history-meta,
.alpha-stock-score-row,
.alpha-exit-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 14px;
    font-size: 12px;
    color: #556274;
}

.alpha-exit-summary-row {
    margin-bottom: 10px;
}

.alpha-pool-reason,
.alpha-list-text,
.alpha-history-text,
.alpha-empty-inline {
    font-size: 13px;
    color: #556274;
}

.alpha-history-text-warning {
    color: #9a5b10;
}

.alpha-cache-summary-live {
    background: #f6fff8;
    border-color: #dcefdc;
}

.alpha-cache-summary-pending {
    background: #f7fbff;
    border-color: #b9d5f4;
}

.alpha-banner {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fff8e8;
    border-color: #f2d08a;
    color: #7a5418;
}

.alpha-banner-error {
    background: #fff0f0;
    border-color: #efb5b5;
    color: #933030;
}

.alpha-banner-info,
.alpha-research-only-block {
    background: #eef7ff;
    border-color: #b8d7f4;
    color: #244c77;
}

.alpha-section-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 12px;
}

.alpha-section-header h4 {
    margin: 0;
}

.alpha-section-header p {
    margin: 4px 0 0;
    font-size: 12px;
    color: #556274;
}

.alpha-history-link,
.alpha-stock-link,
.alpha-inline-link {
    color: #164ca1;
    text-decoration: none;
}

.alpha-history-link:hover,
.alpha-stock-link:hover,
.alpha-inline-link:hover {
    text-decoration: underline;
}

.alpha-pill,
.alpha-stage-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.alpha-pill,
.alpha-stage-badge-top_ranked {
    background: #eef3ff;
    color: #3756a4;
}

.alpha-summary-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #eef3ff;
    color: #3756a4;
}

.alpha-summary-pill-urgent {
    background: #ffe5e5;
    color: #a33434;
}

.alpha-summary-pill-sell {
    background: #fff0f0;
    color: #a33434;
}

.alpha-summary-pill-reduce {
    background: #fff3df;
    color: #9a6220;
}

.alpha-stage-badge-actionable {
    background: #e8f8ec;
    color: #1f7a3f;
}

.alpha-stage-badge-pending {
    background: #fff4df;
    color: #a4651d;
}

.alpha-top-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 12px;
}

.alpha-stock-card {
    border: 1px solid #e3ebf4;
    border-radius: 14px;
    padding: 14px;
    background: #fcfdff;
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
}

.alpha-stock-card:hover {
    border-color: #b9caea;
    box-shadow: 0 12px 28px rgba(25, 45, 82, 0.08);
}

.alpha-stage-actionable {
    border-color: #b9e2c2;
}

.alpha-stage-pending {
    border-color: #eed3a6;
}

.alpha-stock-card-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.alpha-rank {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #122c57;
    color: #fff;
    font-weight: 700;
    margin-right: 8px;
}

.alpha-stock-name {
    margin-top: 4px;
    font-size: 13px;
    color: #556274;
}

.alpha-stock-score-muted {
    color: #7b8897;
}

.alpha-reason-block strong {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
}

.alpha-reason-block ul {
    margin: 0;
    padding-left: 18px;
    font-size: 12px;
    color: #425164;
}

.alpha-reason-block p {
    margin: 0;
    font-size: 12px;
    color: #425164;
}

.alpha-secondary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 12px;
}

.alpha-list,
.alpha-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.alpha-list-item,
.alpha-history-item {
    border: 1px solid #e6edf5;
    border-radius: 12px;
    padding: 12px;
    background: #fbfcfe;
}

.alpha-list-item-pending {
    background: #fffaf2;
}

.alpha-list-item-exit {
    background: #f8fbff;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.alpha-list-item-exit-sell {
    border-color: #f1c5c5;
    background: #fff6f6;
}

.alpha-list-item-exit-reduce {
    border-color: #ecd7a5;
    background: #fffaf0;
}

.alpha-exit-monitor-block {
    grid-column: 1 / -1;
}

.alpha-list-item-exit:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}

.alpha-list-item-exit.is-selected {
    border-color: #3756a4;
    box-shadow: 0 0 0 2px rgba(55, 86, 164, 0.12);
}

.alpha-exit-panel-sync {
    display: none;
}

.alpha-exit-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    background: #edf3ff;
    color: #3756a4;
}

.alpha-exit-badge-sell {
    background: #ffe4e4;
    color: #a33434;
}

.alpha-exit-badge-reduce {
    background: #fff1d8;
    color: #9a6220;
}

.alpha-exit-badge-hold {
    background: #edf6ea;
    color: #2c6f3c;
}

.alpha-priority-text {
    color: #a33434;
    font-size: 12px;
    font-weight: 700;
}

.alpha-list-main,
.alpha-history-main {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 6px;
}

.alpha-list-meta {
    display: flex;
    gap: 10px 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: #556274;
    margin-bottom: 6px;
}

.alpha-card-actions-row,
.alpha-list-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: #556274;
}

.alpha-discard-btn {
    border: 1px solid #d9a441;
    border-radius: 6px;
    background: #fff8e8;
    color: #7a5418;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
    cursor: pointer;
}

.alpha-discard-btn:hover {
    background: #ffecc4;
}

@media (max-width: 768px) {
    .alpha-pool-summary,
    .alpha-section-header,
    .alpha-stock-card-header {
        flex-direction: column;
    }
}
</style>
