<div class="funnel-step-content" style="animation: fadeIn 0.3s ease-in-out;">
    <h3 style="margin-bottom: 20px;">阶段 3: 板块选择与风格映射</h3>
    <div class="attention-card" style="margin-bottom: 20px; border-left: 4px solid #0f766e;">
        <div style="display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;">
            <div>
                <h4 class="attention-card__title" style="margin-bottom: 8px;">当前决策账户</h4>
                <p style="margin: 0 0 6px 0;"><strong data-workspace-account-name>默认账户</strong></p>
                <p style="margin: 0; color: var(--color-text-muted); font-size: 13px;">
                    当前账户会作为后续落地执行的上下文，但本阶段仍展示系统级板块与风格判断。
                </p>
            </div>
            <span class="badge badge-neutral">系统级分析</span>
        </div>
        <p style="margin: 12px 0 0 0; color: var(--color-text-secondary); font-size: 13px;">
            板块偏好来自统一宏观主线与轮动模型，不按账户持仓差异单独重算。
        </p>
        <div class="workspace-freshness-panel">
            {% if recommendation_freshness %}
            <div class="workspace-freshness-card">
                <div class="workspace-freshness-head">
                    <span class="workspace-freshness-title">{{ recommendation_freshness.label }}</span>
                    <span class="workspace-freshness-badge workspace-freshness-badge-{{ recommendation_freshness.badge_class }}">{{ recommendation_freshness.status_label }}</span>
                </div>
                <div class="workspace-freshness-meta">
                    <span>数据日期: {{ recommendation_freshness.observed_at_display }}</span>
                    <span>有效至: {{ recommendation_freshness.expires_at_display }}</span>
                    <span>来源: {{ recommendation_freshness.source_label }}</span>
                    <span>口径: 每晚预计算</span>
                </div>
                <div class="workspace-freshness-note">{{ recommendation_freshness.note }}</div>
            </div>
            {% endif %}
            {% if rotation_freshness %}
            <div class="workspace-freshness-card">
                <div class="workspace-freshness-head">
                    <span class="workspace-freshness-title">{{ rotation_freshness.label }}</span>
                    <span class="workspace-freshness-badge workspace-freshness-badge-{{ rotation_freshness.badge_class }}">{{ rotation_freshness.status_label }}</span>
                </div>
                <div class="workspace-freshness-meta">
                    <span>数据日期: {{ rotation_freshness.observed_at_display }}</span>
                    <span>有效至: {{ rotation_freshness.expires_at_display }}</span>
                    <span>来源: {{ rotation_freshness.source_label }}</span>
                    <span>口径: 每晚预计算</span>
                </div>
                <div class="workspace-freshness-note">{{ rotation_freshness.note }}</div>
            </div>
            {% endif %}
        </div>
    </div>
    
    <div class="attention-card" style="margin-bottom: 20px;">
        <h4 class="attention-card__title">推荐偏好依据</h4>
        <p style="margin-top: 10px;">基于当前所处的宏观主线，结合板块动量引擎输出。</p>
    </div>

    {% if rotation_is_stale or rotation_data_source == 'stored_signal' %}
    <div class="attention-card" style="margin-bottom: 20px; border-left: 4px solid {% if rotation_is_stale %}#f59e0b{% else %}#2563eb{% endif %};">
        <div style="display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap;">
            <div>
                <h4 class="attention-card__title" style="margin-bottom: 8px;">轮动结果状态</h4>
                {% if rotation_is_stale %}
                <p style="margin: 0 0 6px 0; color: var(--color-text-primary);">
                    {{ rotation_warning_message|default:"实时轮动重算失败，当前展示最近一次已落库信号，结果可能滞后。" }}
                </p>
                {% else %}
                <p style="margin: 0 0 6px 0; color: var(--color-text-primary);">
                    当前展示的是已落库的当日轮动结果，避免页面刷新时重复触发外部行情请求。
                </p>
                {% endif %}
                {% if rotation_signal_date %}
                <p style="margin: 0; color: var(--color-text-muted); font-size: 13px;">
                    信号日期: {{ rotation_signal_date }}
                </p>
                {% endif %}
            </div>
            <span class="badge {% if rotation_is_stale %}badge-warning{% else %}badge-primary{% endif %}">
                {% if rotation_is_stale %}已回退{% else %}已复用{% endif %}
            </span>
        </div>
    </div>
    {% endif %}

    <div class="status-grid" style="display: grid; grid-template-columns: 1fr 1fr; gap: 20px;">
        <!-- 板块推荐列表 -->
        <div class="attention-card">
            <h4 class="attention-card__title">Regime + 动量板块</h4>
            <div class="table-responsive" style="margin-top: 15px;">
                <table class="table" style="width: 100%;">
                    <thead>
                        <tr>
                            <th align="left">板块</th>
                            <th align="center">契合度</th>
                            <th align="center">综合评分</th>
                            <th align="center">当前动能</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for sector in sector_recommendations %}
                        <tr>
                            <td><strong>{{ sector.name }}</strong></td>
                            <td align="center">
                                <span class="badge {% if sector.alignment == 'high' %}badge-success{% elif sector.alignment == 'medium' %}badge-warning{% else %}badge-neutral{% endif %}">{{ sector.alignment }}</span>
                            </td>
                            <td align="center">{{ sector.score }}</td>
                            <td align="center">
                                {% if sector.momentum == 'up' %}
                                    <span style="color: #22c55e;">↗</span>
                                {% elif sector.momentum == 'down' %}
                                    <span style="color: #ef4444;">↘</span>
                                {% else %}
                                    <span style="color: #9ca3af;">→</span>
                                {% endif %}
                            </td>
                        </tr>
                        {% endfor %}
                        {% if not sector_recommendations %}
                        <tr>
                            <td colspan="4" align="center" style="color: var(--color-text-muted); padding: 20px;">无明确板块推荐</td>
                        </tr>
                        {% endif %}
                    </tbody>
                </table>
            </div>
        </div>

        <!-- 具体的轮动信号 -->
        <div class="attention-card">
            <h4 class="attention-card__title">风格轮动信号 (Rotation)</h4>
            <ul style="margin-top: 15px; list-style: none; padding: 0;">
                {% for signal in rotation_signals %}
                    <li style="margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid var(--color-border);">
                        <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px;">
                            <strong>{{ signal.sector }}</strong>
                            <span class="badge {% if signal.signal == 'BUY' %}badge-primary{% elif signal.signal == 'SELL' %}badge-danger{% else %}badge-neutral{% endif %}">{{ signal.signal }}</span>
                        </div>
                        <div style="font-size: 13px; color: var(--color-text-secondary);">
                            信号强度: <div class="score-bar" style="display: inline-block; width: 60px; margin-left: 5px; vertical-align: middle;"><div class="score-fill" style="width: {{ signal.strength|floatformat:2 }}%;"></div></div>
                        </div>
                    </li>
                {% endfor %}
                {% if not rotation_signals %}
                    <li style="color: var(--color-text-muted); padding: 20px; text-align: center;">无强烈轮动信号</li>
                {% endif %}
            </ul>
        </div>
    </div>
</div>
