/* DeepStock 策略管理 Tab 样式
   v1.2 2026-05-02 */

/* ── 容器 ── */
.st-container {
    padding: var(--space-4);
    max-width: 1600px;
    margin: 0 auto;
}

/* ── 顶部导航 ── */
.st-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border);
}

.st-sub-tabs {
    display: flex;
    gap: 2px;
    background: var(--color-bg-alt, #eef2f7);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.st-sub-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-text-2, #5a6a7f);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.st-sub-tab:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--color-text-1, #1a1a2e);
}

.st-sub-tab.active {
    background: #FFFFFF;
    color: var(--color-primary);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.st-tab-icon {
    font-size: 14px;
}

.st-sync-hint {
    font-size: 12px;
    color: var(--color-text-2);
}

/* ── 子Tab内容区 ── */
.st-tab-content {
    display: none;
}

.st-tab-content.active {
    display: block;
}

/* ══════════════════════════════════════
   策略生成子Tab
   ══════════════════════════════════════ */

.st-gen-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    flex-wrap: wrap;
}

.st-gen-search,
.st-gen-strategy {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.st-gen-toolbar label {
    font-size: 12px;
    color: var(--color-text-2);
    white-space: nowrap;
}

.st-gen-toolbar input[type="text"],
.st-gen-toolbar select {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--color-bg);
}

.stg-sync-tag {
    font-size: 11px;
    color: var(--color-primary);
    background: rgba(59,130,246,0.1);
    padding: 2px 8px;
    border-radius: 10px;
    display: none;
}

.stg-sync-tag.visible {
    display: inline-block;
}

/* ── 策略管理-自选股下拉 ── */
.stg-symbol-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.stg-wl-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    width: 260px;
    max-height: 360px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    z-index: 900;
    overflow: hidden;
}

.stg-wl-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}

.stg-wl-close-btn {
    background: none;
    border: none;
    font-size: 16px;
    color: var(--color-text-2);
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}
.stg-wl-close-btn:hover {
    color: var(--color-text);
}

.stg-wl-list {
    overflow-y: auto;
    max-height: 310px;
}

.stg-wl-empty {
    padding: 20px 12px;
    text-align: center;
    color: var(--color-text-light);
    font-size: 12px;
}

.stg-wl-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--color-border);
}
.stg-wl-item:last-child {
    border-bottom: none;
}
.stg-wl-item:hover {
    background: rgba(59,130,246,0.08);
}
.stg-wl-item.active {
    background: rgba(59,130,246,0.12);
}

.stg-wl-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.stg-wl-item-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
}

.stg-wl-item-code {
    font-size: 11px;
    color: var(--color-text-light);
}

.stg-wl-item-price {
    font-size: 12px;
    text-align: right;
}

.stg-wl-item-pct {
    font-size: 11px;
}
.stg-wl-item-pct.up { color: #e74c3c; }
.stg-wl-item-pct.down { color: #27ae60; }

/* 回测Tab的自选按钮 */
.stb-watchlist-btn {
    white-space: nowrap;
}

/* 下拉框 — 通用默认值（夜间模式会覆盖） */
.stg-wl-dropdown {
    background: #FFFFFF;
    border-color: #E2E8F0;
}
.stg-wl-dropdown-header {
    background: #F4F6FA;
    border-color: #E2E8F0;
    color: #00194C;
}
.stg-wl-item {
    border-color: #E2E8F0;
}

/* 夜间模式 */
[data-theme="night"] .stg-wl-dropdown {
    background: #1A1C24;
    border-color: #2d2f3a;
}
[data-theme="night"] .stg-wl-dropdown-header {
    background: #14151a;
    border-color: #2d2f3a;
    color: #e0e0e0;
}
[data-theme="night"] .stg-wl-item {
    border-color: #2d2f3a;
}
[data-theme="night"] .stg-wl-item:hover {
    background: rgba(2,235,253,0.08);
}
[data-theme="night"] .stg-wl-item.active {
    background: rgba(2,235,253,0.12);
}
[data-theme="night"] .stg-wl-item-name {
    color: #e0e0e0;
}
[data-theme="night"] .stg-wl-item-code {
    color: #888;
}
[data-theme="night"] .stg-wl-close-btn {
    color: #888;
}
[data-theme="night"] .stg-wl-close-btn:hover {
    color: #e0e0e0;
}
[data-theme="night"] .stg-wl-item-pct.up { color: #e74c3c; }
[data-theme="night"] .stg-wl-item-pct.down { color: #27ae60; }

.st-gen-regime-status {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.st-regime-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.st-regime-badge.bull { background: rgba(239,68,68,0.15); color: var(--color-up); }
.st-regime-badge.bear { background: rgba(34,197,94,0.15); color: var(--color-down); }
.st-regime-badge.neutral { background: rgba(245,158,11,0.15); color: #F59E0B; }
.st-regime-badge.risk { background: rgba(239,68,68,0.15); color: #EF4444; }

.st-regime-alpha {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

/* ── 主内容布局 ── */
.st-gen-main {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: var(--space-4);
    align-items: start;
}

/* ── 决策链路流程图 ── */
.stg-flow-diagram {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stg-flow-title {
    font-size: 12px;
    color: var(--color-text-2);
    margin-bottom: var(--space-2);
}

.stg-flow-steps {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.stg-flow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
    min-width: 44px;
}

.stg-flow-step:hover {
    border-color: var(--color-primary);
    background: rgba(59,130,246,0.05);
}

.stg-flow-step.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.stg-flow-step.stg-flow-signal {
    background: rgba(59,130,246,0.15);
    border-color: var(--color-primary);
}

.stg-step-num {
    font-size: 10px;
    color: var(--color-text-2);
    font-weight: 600;
}

.stg-flow-step.active .stg-step-num {
    color: rgba(255,255,255,0.7);
}

.stg-step-name {
    font-size: 11px;
    font-weight: 600;
}

.stg-flow-arrow {
    color: var(--color-text-2);
    font-size: 12px;
    flex-shrink: 0;
}

/* ── 层级详情折叠面板 ── */
.stg-layers-detail {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.stg-layer-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stg-layer-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-3);
    cursor: pointer;
    transition: background 0.2s;
}

.stg-layer-header:hover {
    background: var(--color-bg);
}

.stg-layer-tag {
    background: var(--color-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.stg-layer-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

.stg-layer-score {
    font-size: 12px;
    color: var(--color-primary);
    font-weight: 600;
}

.stg-layer-filters {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.stg-factor-filter {
    padding: 2px 8px;
    font-size: 11px;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    background: transparent;
    cursor: pointer;
    color: var(--color-text-2);
    transition: all 0.2s;
}

.stg-factor-filter:hover,
.stg-factor-filter.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.stg-layer-toggle {
    background: none;
    border: none;
    color: var(--color-text-2);
    cursor: pointer;
    font-size: 12px;
    padding: 4px;
    transition: transform 0.2s;
}

.stg-layer-card.open .stg-layer-toggle {
    transform: rotate(180deg);
}

.stg-layer-body {
    display: none;
    padding: 0 var(--space-3) var(--space-3);
}

.stg-layer-card.open .stg-layer-body {
    display: block;
}

/* L1 数据层 */
.stg-l1-health-bar {
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    margin-bottom: var(--space-2);
    overflow: hidden;
}

.stg-l1-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #3b82f6);
    border-radius: 3px;
    transition: width 0.5s;
}

.stg-l1-sources {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    align-items: start;
}

.stg-l1-source {
    display: flex;
    flex-direction: column;
    padding: var(--space-2);
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-size: 11px;
}

.stg-l1-source-name {
    color: var(--color-text-2);
    margin-bottom: 2px;
}

.stg-l1-source-status {
    font-weight: 600;
    font-size: 12px;
}

.stg-l1-source-status.ok { color: var(--color-up); }
.stg-l1-source-status.warn { color: #F59E0B; }
.stg-l1-source-status.error { color: var(--color-down); }

/* L1 数据层 — 按类别分组 */
.stg-l1-category {
    min-width: 0;
}
.stg-l1-category-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-1);
    margin-bottom: var(--space-1);
    padding-left: 2px;
}
.stg-l1-category-items {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
}
.stg-l1-item {
    display: flex;
    flex-direction: column;
    padding: 4px 6px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-size: 11px;
    border-left: 3px solid transparent;
}
.stg-l1-item.ok { border-left-color: var(--color-up); }
.stg-l1-item.warn { border-left-color: #F59E0B; }
.stg-l1-item.unknown { border-left-color: var(--color-text-3); }
.stg-l1-item-name {
    color: var(--color-text-2);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stg-l1-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.stg-l1-item-status {
    font-weight: 600;
    font-size: 11px;
    line-height: 1;
}
.stg-l1-item-status.ok { color: var(--color-up); }
.stg-l1-item-status.warn { color: #F59E0B; }
.stg-l1-item-status.unknown { color: var(--color-text-3); }
.stg-l1-item-count {
    font-size: 10px;
    color: var(--color-text-3);
    line-height: 1;
}

.stg-loading {
    text-align: center;
    color: var(--color-text-2);
    padding: var(--space-4);
    font-size: 13px;
}

/* L2 因子表 */
.stg-factor-table-wrap {
    overflow-x: auto;
}

.stg-factor-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.stg-factor-table th {
    background: var(--color-bg);
    padding: 8px;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-2);
    border-bottom: 1px solid var(--color-border);
}

.stg-factor-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border);
}

.stg-factor-table tr:hover td {
    background: var(--color-bg);
}

.stg-factor-table .up { color: var(--color-up); font-weight: 600; }
.stg-factor-table .down { color: var(--color-down); font-weight: 600; }
.stg-factor-table .neutral { color: var(--color-text-2); }

.stg-factor-star {
    color: #F59E0B;
    font-weight: 700;
}

/* 因子数据状态指示器 */
.stg-factor-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    white-space: nowrap;
}
.stg-factor-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}
.stg-factor-status.ok { color: #22c55e; }
.stg-factor-status.ok .dot { background: #22c55e; }
.stg-factor-status.estimated { color: #f97316; }
.stg-factor-status.estimated .dot { background: #f97316; }
.stg-factor-status.empty { color: #eab308; }
.stg-factor-status.empty .dot { background: #eab308; }
.stg-factor-status.missing { color: #ef4444; }
.stg-factor-status.missing .dot { background: #ef4444; }

.stg-empty-cell {
    text-align: center;
    color: var(--color-text-2);
    padding: var(--space-4) !important;
}

/* 因子分组标题行 */
.stg-factor-group-header td {
    background: var(--color-bg);
    padding: 10px 8px 6px 8px;
    border-bottom: 2px solid var(--color-border);
    font-weight: 600;
    font-size: 12px;
    color: var(--color-text-1);
}
.stg-factor-group-header .stg-factor-group-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
}
.stg-factor-group-header .stg-factor-group-name {
    vertical-align: middle;
}
.stg-factor-group-header .stg-factor-group-count {
    margin-left: 6px;
    font-size: 11px;
    font-weight: 400;
    color: var(--color-text-2);
    background: var(--color-surface);
    padding: 1px 6px;
    border-radius: 8px;
}
/* 分组颜色 */
:root {
    --group-technical: #3b82f6;
    --group-flow: #10b981;
    --group-fundamental: #f59e0b;
    --group-altdata: #8b5cf6;
    --group-policy: #ef4444;
}

/* L3 四维压缩 */
.stg-dim-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-2);
}

.stg-dim-card {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    text-align: center;
}

.stg-dimName {
    font-size: 11px;
    color: var(--color-text-2);
    margin-bottom: 4px;
}

.stg-dim-score {
    font-size: 24px;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: 6px;
}

.stg-dim-bar-wrap {
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    margin-bottom: 6px;
    overflow: hidden;
}

.stg-dim-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 2px;
    transition: width 0.5s;
}

.stg-dim-label {
    font-size: 11px;
    color: var(--color-text-2);
    margin-bottom: 4px;
}

.stg-dim-weight {
    font-size: 10px;
    color: var(--color-primary);
}

/* L4 Alpha */
.stg-alpha-hero {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-3);
}

.stg-alpha-final {
    text-align: center;
    padding: var(--space-3);
    background: linear-gradient(135deg, rgba(59,130,246,0.1), rgba(59,130,246,0.05));
    border-radius: var(--radius-md);
    border: 1px solid rgba(59,130,246,0.2);
    min-width: 200px;
}

.stg-alpha-num {
    font-size: 42px;
    font-weight: 900;
    color: var(--color-text);
    line-height: 1;
}

.stg-alpha-signal {
    font-size: 14px;
    font-weight: 600;
    margin-top: 4px;
}

.stg-alpha-signal.buy { color: var(--color-up); }
.stg-alpha-signal.sell { color: var(--color-down); }
.stg-alpha-signal.hold { color: #F59E0B; }
.stg-alpha-signal.neutral { color: var(--color-text-2); }

.stg-alpha-breakdown {
    margin-bottom: var(--space-2);
}

.stg-alpha-breakdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: 6px;
}

.stg-alpha-breakdown-label {
    font-size: 11px;
    color: var(--color-text-2);
    width: 80px;
    flex-shrink: 0;
}

.stg-alpha-breakdown-bar-wrap {
    flex: 1;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}

.stg-alpha-breakdown-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    transition: width 0.5s;
}

.stg-alpha-breakdown-val {
    font-size: 11px;
    font-weight: 600;
    width: 36px;
    text-align: right;
}

.stg-alpha-remark {
    font-size: 12px;
    color: var(--color-text-2);
    line-height: 1.5;
    padding: var(--space-2);
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

/* L5-6 结构+信息 */
.stg-l5-l6-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
}

.stg-struct-card {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: var(--space-3);
    text-align: center;
}

.stg-struct-title {
    font-size: 11px;
    color: var(--color-text-2);
    margin-bottom: 4px;
}

.stg-struct-score {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: 4px;
}

.stg-struct-desc {
    font-size: 11px;
    color: var(--color-text-2);
}

/* L7 Regime */
.stg-regime-rules {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: var(--space-3);
}

.stg-regime-rule {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    padding: 4px 8px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

.stg-regime-rule-ok { color: var(--color-up); }
.stg-regime-rule-fail { color: var(--color-down); }

.stg-regime-current {
    margin-left: auto;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 8px;
    background: rgba(59,130,246,0.15);
    color: var(--color-primary);
}

.stg-regime-weights {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
}

.stg-regime-w-title {
    font-size: 11px;
    color: var(--color-text-2);
    margin-bottom: var(--space-2);
}

.stg-regime-w-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

.stg-regime-w-table th,
.stg-regime-w-table td {
    padding: 4px 8px;
    text-align: center;
    border-bottom: 1px solid var(--color-border);
}

.stg-regime-w-table th {
    color: var(--color-text-2);
    font-weight: 600;
}

.stg-regime-w-table td.current {
    background: rgba(59,130,246,0.1);
    font-weight: 700;
    color: var(--color-primary);
}

/* ── 决策信号汇总 ── */
.stg-signal-summary {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-top: var(--space-3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stg-signal-card {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.stg-signal-item {
    flex: 1;
    text-align: center;
    padding: var(--space-2);
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

.stg-sig-label {
    font-size: 11px;
    color: var(--color-text-2);
    margin-bottom: 4px;
}

.stg-sig-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-text);
}

.stg-sig-action.buy { color: var(--color-up); }
.stg-sig-action.sell { color: var(--color-down); }
.stg-sig-action.hold { color: #F59E0B; }

.stg-signal-actions {
    display: flex;
    gap: var(--space-2);
}

.stg-signal-actions .btn {
    flex: 1;
}

/* ══════════════════════════════════════
   策略编辑器
   ══════════════════════════════════════ */

.st-gen-editor {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    position: sticky;
    top: var(--space-4);
}

.stg-editor-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--color-primary);
}

.stg-editor-form {
    margin-bottom: var(--space-3);
}

.stg-editor-field {
    margin-bottom: var(--space-2);
}

.stg-editor-field label {
    display: block;
    font-size: 11px;
    color: var(--color-text-2);
    margin-bottom: 4px;
}

.stg-editor-field input,
.stg-editor-field textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    background: var(--color-bg);
    resize: vertical;
}

.stg-editor-field input[readonly] {
    background: var(--color-border);
    color: var(--color-text-2);
}

.stg-editor-section-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-2);
    margin-top: var(--space-3);
}

/* 权重滑块 */
.stg-editor-weights {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
    margin-bottom: var(--space-2);
}

.stg-w-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-1);
}

.stg-w-row label {
    font-size: 11px;
    color: var(--color-text-2);
    width: 80px;
    flex-shrink: 0;
}

.stg-w-row input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    background: var(--color-border);
    border-radius: 2px;
    outline: none;
}

.stg-w-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--color-primary);
    cursor: pointer;
}

.stg-w-val {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-primary);
    width: 32px;
    text-align: right;
}

.stg-w-total {
    font-size: 11px;
    color: var(--color-text-2);
    text-align: right;
    margin-top: 4px;
}

/* 阈值 */
.stg-editor-thresholds {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2);
}

.stg-t-row {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.stg-t-row label {
    font-size: 11px;
    color: var(--color-text-2);
    white-space: nowrap;
}

.stg-t-row input {
    width: 60px;
    padding: 4px 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    text-align: center;
    background: var(--color-bg);
}

/* 仓位映射 */
.stg-editor-positions {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
}

.stg-pos-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: 4px;
    font-size: 11px;
}

.stg-pos-row span {
    color: var(--color-text-2);
    flex: 1;
}

.stg-pos-row input {
    width: 50px;
    padding: 2px 4px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 11px;
    text-align: center;
    background: var(--color-surface);
}

.stg-editor-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.stg-editor-actions .btn {
    flex: 1;
}

.stg-editor-tips {
    margin-top: var(--space-3);
    padding: var(--space-2);
    background: rgba(59,130,246,0.05);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(59,130,246,0.15);
}

.stg-tip-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 4px;
}

.stg-tip-list {
    margin: 0;
    padding-left: 16px;
    font-size: 11px;
    color: var(--color-text-2);
    line-height: 1.6;
}

/* ══════════════════════════════════════
   策略回测子Tab
   ══════════════════════════════════════ */

.st-bt-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: var(--space-4);
}

.st-bt-config {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    height: fit-content;
}

.st-bt-progress {
    margin-bottom: var(--space-2);
    padding: 8px 12px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

.st-bt-config-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-3);
}

.st-bt-field {
    margin-bottom: var(--space-2);
}

.st-bt-field label {
    display: block;
    font-size: 11px;
    color: var(--color-text-2);
    margin-bottom: 4px;
}

.st-bt-field input,
.st-bt-field select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    background: var(--color-bg);
}

.stb-checkboxes {
    display: flex;
    gap: var(--space-2);
    font-size: 12px;
}

.stb-checkboxes input {
    width: auto !important;
}

.st-bt-results {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.st-bt-results-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--space-3);
    letter-spacing: 0.5px;
}

.st-bt-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

@media (min-width: 768px) {
    .st-bt-metrics {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (min-width: 1200px) {
    .st-bt-metrics {
        grid-template-columns: repeat(9, 1fr);
    }
}

.stb-metric {
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-2);
    text-align: center;
    border: 1px solid rgba(0,0,0,0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stb-metric:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stb-m-label {
    display: block;
    font-size: 11px;
    color: var(--color-text-2);
    margin-bottom: 6px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.stb-m-val {
    font-size: 18px;
    font-weight: 800;
    color: var(--color-text);
}

.stb-m-val.up { color: var(--color-up); }
.stb-m-val.down { color: var(--color-down); }

.stb-chart {
    height: 260px;
    margin-bottom: var(--space-3);
}

.stb-trades-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--space-2);
}

.stb-trades-table-wrap {
    overflow-x: auto;
}

.stb-trades-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.stb-trades-table th {
    background: var(--color-bg);
    padding: 8px;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-2);
    border-bottom: 1px solid var(--color-border);
}

.stb-trades-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border);
}

/* ── 回测日志：可展开详情 ── */
.stb-debug-detail-inner {
    display: flex;
    gap: 20px;
    padding: 10px 14px;
    background: var(--color-bg-alt, rgba(0,0,0,0.02));
    border-bottom: 1px solid var(--color-divider, #eee);
    flex-wrap: wrap;
}

.stb-debug-col {
    flex: 1;
    min-width: 180px;
}

.stb-debug-col-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-3, #888);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.stb-debug-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 0;
    font-size: 12px;
    line-height: 1.5;
}

.stb-debug-label {
    color: var(--color-text-2, #666);
}

.stb-debug-val {
    font-weight: 600;
    color: var(--color-text, #333);
}

/* 夜间模式 */
[data-theme="night"] .stb-debug-detail-inner {
    background: rgba(2, 235, 253, 0.03);
    border-bottom-color: rgba(2, 235, 253, 0.07);
}

/* ── 回测日志行状态指示（左侧边框） ── */
.stb-debug-summary.stb-debug-fail {
    border-left: 3px solid rgba(244, 67, 54, 0.35);
}
.stb-debug-summary.stb-debug-trade {
    border-left: 3px solid rgba(76, 175, 80, 0.35);
}

[data-theme="night"] .stb-debug-summary.stb-debug-fail {
    border-left: 3px solid rgba(255, 107, 129, 0.5);
    background: rgba(244, 67, 54, 0.03);
}
[data-theme="night"] .stb-debug-summary.stb-debug-trade {
    border-left: 3px solid rgba(76, 175, 80, 0.5);
    background: rgba(76, 175, 80, 0.03);
}

/* ── 回测日志表格：Excel 冻结窗格效果 ── */
.stb-debug-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
}

.stb-debug-table th,
.stb-debug-table td {
    border-bottom: 1px solid var(--color-divider, #eee);
}

/* 所有 th 统一表头固定 */
.stb-debug-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--color-bg-alt, #f5f5f5);
}

/* ── Regime 列颜色 ── */
.stb-debug-summary td:nth-child(3) {
    color: #7b1fa2;
}
[data-theme="night"] .stb-debug-summary td:nth-child(3) {
    color: #02EBFD;
}

/* ── 固定列 + 表头交叉点（z-index 最高）── */
.stb-debug-table th:nth-child(1) {
    position: sticky;
    left: 0;
    top: 0;
    width: 50px;
    min-width: 50px;
    z-index: 30;
    background: var(--color-bg-alt, #f5f5f5);
}
.stb-debug-table th:nth-child(2) {
    position: sticky;
    left: 50px;
    top: 0;
    width: 85px;
    min-width: 85px;
    z-index: 30;
    background: var(--color-bg-alt, #f5f5f5);
}
.stb-debug-table th:nth-child(3) {
    position: sticky;
    left: 135px;
    top: 0;
    width: 65px;
    min-width: 65px;
    z-index: 30;
    background: var(--color-bg-alt, #f5f5f5);
}

/* ── 固定列数据行 ── */
.stb-debug-table td:nth-child(1) {
    position: sticky;
    left: 0;
    width: 50px;
    min-width: 50px;
    z-index: 20;
    background: var(--color-bg, #fff);
}
.stb-debug-table td:nth-child(2) {
    position: sticky;
    left: 50px;
    width: 85px;
    min-width: 85px;
    z-index: 20;
    background: var(--color-bg, #fff);
}
.stb-debug-table td:nth-child(3) {
    position: sticky;
    left: 135px;
    width: 65px;
    min-width: 65px;
    z-index: 20;
    background: var(--color-bg, #fff);
}

/* 固定列右侧阴影分隔线 */
.stb-debug-table th:nth-child(3),
.stb-debug-table td:nth-child(3) {
    box-shadow: 2px 0 4px rgba(0,0,0,0.08);
}
[data-theme="night"] .stb-debug-table th:nth-child(3),
[data-theme="night"] .stb-debug-table td:nth-child(3) {
    box-shadow: 2px 0 4px rgba(0,0,0,0.25);
}

/* ── 其余列固定宽度 ── */
.stb-debug-table th:nth-child(4),
.stb-debug-table td:nth-child(4) { width: 95px; min-width: 95px; }
.stb-debug-table th:nth-child(5),
.stb-debug-table td:nth-child(5) { width: 65px; min-width: 65px; }
.stb-debug-table th:nth-child(6),
.stb-debug-table td:nth-child(6) { width: 65px; min-width: 65px; }
.stb-debug-table th:nth-child(7),
.stb-debug-table td:nth-child(7) { width: 65px; min-width: 65px; }
.stb-debug-table th:nth-child(8),
.stb-debug-table td:nth-child(8) { width: 65px; min-width: 65px; }
.stb-debug-table th:nth-child(9),
.stb-debug-table td:nth-child(9) { width: 65px; min-width: 65px; }
.stb-debug-table th:nth-child(10),
.stb-debug-table td:nth-child(10) { width: 140px; min-width: 140px; }
.stb-debug-table th:nth-child(11),
.stb-debug-table td:nth-child(11) { width: 60px; min-width: 60px; }
.stb-debug-table th:nth-child(12),
.stb-debug-table td:nth-child(12) { width: 55px; min-width: 55px; }
.stb-debug-table th:nth-child(13),
.stb-debug-table td:nth-child(13) { width: 80px; min-width: 80px; }
.stb-debug-table th:nth-child(14),
.stb-debug-table td:nth-child(14) { width: 80px; min-width: 80px; }
.stb-debug-table th:nth-child(15),
.stb-debug-table td:nth-child(15) { width: 60px; min-width: 60px; }
.stb-debug-table th:nth-child(16),
.stb-debug-table td:nth-child(16) { width: 60px; min-width: 60px; }
.stb-debug-table th:nth-child(17),
.stb-debug-table td:nth-child(17) { width: 90px; min-width: 90px; }
.stb-debug-table th:nth-child(18),
.stb-debug-table td:nth-child(18) { width: 160px; min-width: 160px; }
.stb-debug-table th:nth-child(19),
.stb-debug-table td:nth-child(19) { width: 75px; min-width: 75px; }
.stb-debug-table th:nth-child(20),
.stb-debug-table td:nth-child(20) { width: 65px; min-width: 65px; }

/* 夜间模式表格边框 */
[data-theme="night"] .stb-debug-table th,
[data-theme="night"] .stb-debug-table td {
    border-bottom-color: rgba(2, 235, 253, 0.1);
}

/* 夜间模式固定列背景 */
[data-theme="night"] .stb-debug-table td:nth-child(1),
[data-theme="night"] .stb-debug-table td:nth-child(2),
[data-theme="night"] .stb-debug-table td:nth-child(3) {
    background: var(--color-bg, #0b1218);
}

/* ══════════════════════════════════════
   交易管理子Tab
   ══════════════════════════════════════ */

.stadm-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 4px;
}

.stadm-tab {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-2);
    background: none;
    border: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    cursor: pointer;
    transition: all 0.2s;
}

.stadm-tab:hover {
    color: var(--color-primary);
    background: var(--color-bg);
}

.stadm-tab.active {
    color: var(--color-primary);
    background: var(--color-bg);
    border-bottom: 2px solid var(--color-primary);
}

.stadm-tab-content {
    display: none;
}

.stadm-tab-content.active {
    display: block;
}

/* 模拟账户 */
.stadm-acct-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
    margin-bottom: var(--space-3);
}

.stadm-acct-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stadm-acct-label {
    font-size: 11px;
    color: var(--color-text-2);
    margin-bottom: 4px;
}

.stadm-acct-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--color-text);
}

.stadm-acct-value.up { color: var(--color-up); }
.stadm-acct-value.down { color: var(--color-down); }

.stadm-acct-chart {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    height: 200px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stadm-acct-hint {
    font-size: 12px;
    color: var(--color-text-2);
    text-align: center;
    padding: var(--space-3);
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

/* 持仓表 */
.stadm-pos-table-wrap,
.stadm-logs-table-wrap {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    overflow-x: auto;
}

.stadm-pos-table,
.stadm-logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.stadm-pos-table th,
.stadm-logs-table th {
    background: var(--color-bg);
    padding: 8px;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-2);
    border-bottom: 1px solid var(--color-border);
}

.stadm-pos-table td,
.stadm-logs-table td {
    padding: 8px;
    border-bottom: 1px solid var(--color-border);
}

.stadm-pos-table .up { color: var(--color-up); }
.stadm-pos-table .down { color: var(--color-down); }

/* 日志过滤 */
.stadm-logs-filter {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
    font-size: 12px;
}

.stadm-logs-filter select {
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    background: var(--color-bg);
}

/* 策略列表 */
.stadm-strat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    font-size: 13px;
    font-weight: 600;
}

.stadm-strat-list {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stadm-strat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2);
    border-bottom: 1px solid var(--color-border);
}

.stadm-strat-item:last-child {
    border-bottom: none;
}

.stadm-strat-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stadm-strat-name {
    font-size: 13px;
    font-weight: 600;
}

.stadm-strat-meta {
    font-size: 11px;
    color: var(--color-text-2);
}

.stadm-strat-badge {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 8px;
    font-weight: 600;
}

.stadm-strat-badge.active {
    background: rgba(34,197,94,0.15);
    color: var(--color-up);
}

.stadm-strat-badge.inactive {
    background: var(--color-bg);
    color: var(--color-text-2);
}

.stadm-strat-empty {
    text-align: center;
    color: var(--color-text-2);
    padding: var(--space-4);
    font-size: 13px;
}

/* 策略删除按钮 */
.stadm-strat-del {
    padding: 2px 8px;
    font-size: 11px;
    background: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
    border-radius: 4px;
    cursor: pointer;
    margin-left: 4px;
}
.stadm-strat-del:hover {
    background: var(--color-accent);
    color: #fff;
}

/* 夜视模式 - 策略管理 */
[data-theme="night"] .stadm-strat-list {
    background: #12141a;
    border-color: #2d2f3a;
}
[data-theme="night"] .stadm-strat-item {
    border-color: #2d2f3a;
}
[data-theme="night"] .stadm-strat-name {
    color: #f0f0f0;
}
[data-theme="night"] .stadm-strat-meta {
    color: #888;
}
[data-theme="night"] .stadm-strat-badge.active {
    background: rgba(2,235,253,0.15);
    color: #02EBFD;
}
[data-theme="night"] .stadm-strat-del {
    color: #ff6b6b;
    border-color: #ff6b6b;
}
[data-theme="night"] .stadm-strat-del:hover {
    background: #ff6b6b;
    color: #0a0a10;
}

/* ── 策略管理内嵌编辑器 ── */
.stadm-editor {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stadm-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-3);
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-1);
}
.stadm-editor-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--color-text-2);
    cursor: pointer;
    line-height: 1;
}
.stadm-editor-close:hover { color: var(--color-accent); }
.stadm-editor-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}
.stadm-editor-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stadm-editor-row label {
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-2);
}
.stadm-editor-row input[type="text"],
.stadm-editor-row input[type="number"] {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text-1);
    font-size: 13px;
}
.stadm-editor-weights {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.stadm-editor-weight {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}
.stadm-editor-weight span:first-child {
    width: 48px;
    color: var(--color-text-2);
}
.stadm-editor-weight input[type="range"] {
    flex: 1;
}
.stadm-editor-weight span:last-child {
    width: 36px;
    text-align: right;
    font-weight: 600;
    color: var(--color-primary);
}
.stadm-editor-thresholds {
    display: flex;
    gap: var(--space-3);
    font-size: 12px;
    color: var(--color-text-2);
}
.stadm-editor-thresholds input {
    width: 60px;
    padding: 4px 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text-1);
    font-size: 12px;
}

.stadm-editor-positions {
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    padding: var(--space-2);
}

.stadm-pos-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: 4px;
    font-size: 11px;
}

.stadm-pos-row span {
    color: var(--color-text-2);
    flex: 1;
}

.stadm-pos-row input {
    width: 50px;
    padding: 4px 6px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    text-align: center;
    background: var(--color-bg);
}

.stadm-editor-actions {
    display: flex;
    gap: var(--space-2);
    justify-content: flex-end;
    margin-top: var(--space-1);
}

/* 夜间模式 - 策略管理编辑器 */
[data-theme="night"] .stadm-editor {
    background: #12141a;
    border-color: #2d2f3a;
}
[data-theme="night"] .stadm-editor-row input {
    background: #0a0a10;
    border-color: #2d2f3a;
    color: #f0f0f0;
}

/* 夜视模式 - 策略选择下拉 */
[data-theme="night"] #stg-strategy-select,
[data-theme="night"] #stb-strategy-select,
[data-theme="night"] #stg-strategy-select option,
[data-theme="night"] #stb-strategy-select option {
    background: #12141a !important;
    border-color: rgba(2,235,253,0.3) !important;
    color: #f0f0f0 !important;
}
[data-theme="night"] #stg-strategy-select option,
[data-theme="night"] #stb-strategy-select option {
    background: #1a1c24 !important;
}

/* 智能交易 */
.stadm-smart-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    font-size: 14px;
    font-weight: 600;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-border);
    border-radius: 24px;
    transition: 0.3s;
}

.toggle-slider::before {
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
    position: absolute;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--color-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.stadm-smart-config {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--space-2);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stadm-smart-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stadm-smart-field label {
    font-size: 11px;
    color: var(--color-text-2);
}

.stadm-smart-field input,
.stadm-smart-field select {
    padding: 6px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    background: var(--color-bg);
}

.stadm-smart-logs {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.stadm-smart-logs-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: var(--space-2);
}

.stadm-smart-logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.stadm-smart-logs-table th {
    background: var(--color-bg);
    padding: 8px;
    text-align: left;
    font-weight: 600;
    color: var(--color-text-2);
    border-bottom: 1px solid var(--color-border);
}

.stadm-smart-logs-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--color-border);
}

/* ── 分析进度条 ── */
.stg-progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    flex: 1;
    min-width: 120px;
}
.stg-progress-track {
    flex: 1;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}
.stg-progress-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.stg-progress-text {
    font-size: 11px;
    color: var(--color-text-2);
    white-space: nowrap;
    min-width: 80px;
}

/* ── 政策调度控制条 ── */
.stg-policy-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--color-bg-2);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.stg-policy-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.stg-policy-select {
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    background: var(--color-bg);
    font-size: 12px;
    color: var(--color-text);
}
.stg-policy-llm-label {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--color-text-2);
    cursor: pointer;
    user-select: none;
}
.stg-policy-llm-label input {
    margin: 0;
}
.stg-policy-msg {
    font-size: 12px;
    color: var(--color-text-2);
    white-space: nowrap;
}

/* ── 夜间模式适配 ── */
[data-theme="night"] .stg-layer-card {
    background: #1A1C24;
    border-color: #2d2f3a;
}
[data-theme="night"] .stg-layer-header {
    background: #252833;
    border-bottom: 1px solid #2d2f3a;
}
[data-theme="night"] .stg-layer-tag {
    background: #02EBFD;
    color: #0a0a10;
}
[data-theme="night"] .stg-layer-title {
    color: #e0e0e0;
}
[data-theme="night"] .st-sub-tabs {
    background: rgba(255, 255, 255, 0.05);
}
[data-theme="night"] .st-sub-tab {
    color: rgba(255, 255, 255, 0.6);
}
[data-theme="night"] .st-sub-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #FFFFFF;
}
[data-theme="night"] .st-sub-tab.active {
    background: rgba(2, 235, 253, 0.15);
    color: #02EBFD;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
[data-theme="night"] .stg-factor-filter.active {
    background: #02EBFD;
    border-color: #02EBFD;
    color: #0a0a10;
}

/* ── 存档下拉列表 ── */
.stg-archive-wrap {
    position: relative;
    margin-left: 8px;
}
.stg-archive-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 280px;
    background: var(--color-surface, #ffffff);
    border: 1px solid var(--color-border, #e0e0e0);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}
.stg-archive-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--color-border);
    gap: 6px;
    font-size: 12px;
}
.stg-archive-item:last-child { border-bottom: none; }
.stg-archive-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text);
}
.stg-archive-time {
    font-size: 10px;
    color: var(--color-text-2);
    white-space: nowrap;
}
.stg-archive-load, .stg-archive-del {
    padding: 2px 8px;
    font-size: 11px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.stg-archive-load {
    background: var(--color-primary-2);
    color: #fff;
}
.stg-archive-del {
    background: transparent;
    color: var(--color-accent);
    border: 1px solid var(--color-accent);
}
.stg-archive-del:hover {
    background: var(--color-accent);
    color: #fff;
}
.stg-archive-empty {
    padding: 12px;
    text-align: center;
    color: var(--color-text-2);
    font-size: 12px;
}
[data-theme="night"] .stg-archive-dropdown {
    background: #12141a;
    border-color: #2d2f3a;
}
[data-theme="night"] .stg-archive-item {
    background: #12141a;
    border-color: #2d2f3a;
}
[data-theme="night"] .stg-archive-item:hover {
    background: #1e2028;
}
[data-theme="night"] .stg-archive-label {
    color: #f0f0f0;
}
[data-theme="night"] .stg-archive-time {
    color: #888;
}
[data-theme="night"] .stg-archive-load {
    background: #02EBFD;
    color: #0a0a10;
}

/* ── 响应式 ── */
@media (max-width: 1200px) {
    .st-gen-main {
        grid-template-columns: 1fr;
    }

    .st-gen-editor {
        position: static;
    }

    .stg-dim-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .st-bt-container {
        grid-template-columns: 1fr;
    }

    .stadm-acct-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .st-gen-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .st-gen-regime-status {
        margin-left: 0;
    }

    .stg-dim-grid {
        grid-template-columns: 1fr 1fr;
    }

    .st-bt-metrics {
        grid-template-columns: repeat(3, 1fr);
    }

    .stadm-acct-grid {
        grid-template-columns: 1fr 1fr;
    }

    .stg-flow-steps {
        flex-wrap: wrap;
    }
}

/* ── 数据预下载样式 ── */
#stb-prefetch-btn {
    width: 100%;
    margin-top: 4px;
}
#stb-data-status {
    font-size: 12px;
    color: var(--color-text-2);
    margin-top: 4px;
    text-align: center;
}
#stb-prefetch-progress {
    margin-top: 6px;
}
#stb-prefetch-progress .stg-progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
#stb-prefetch-progress .stg-progress-track {
    flex: 1;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}
#stb-prefetch-progress .stg-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-2));
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* ══════════════════════════════════════
   权重模式切换
   ══════════════════════════════════════ */
.stg-weight-mode-switch {
    display: flex;
    gap: 4px;
    margin-bottom: var(--space-2);
    padding: 4px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
}

.weight-mode-btn {
    flex: 1;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--color-text-2);
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.weight-mode-btn:hover {
    background: var(--color-border);
}

.weight-mode-btn.active {
    background: var(--color-primary);
    color: #fff;
}

[data-theme="night"] .stg-weight-mode-switch {
    background: #1a1c24;
}
[data-theme="night"] .weight-mode-btn.active {
    background: #02EBFD;
    color: #0a0a10;
}

/* ══════════════════════════════════════
   因子有效性 Tab
   ══════════════════════════════════════ */
.st-fv-container {
    padding: var(--space-4);
    max-width: 1200px;
    margin: 0 auto;
}

.st-fv-header {
    margin-bottom: var(--space-4);
}

.st-fv-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.st-fv-header p {
    font-size: 13px;
    color: var(--color-text-2);
}

.st-fv-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
}

.st-fv-actions select {
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: var(--color-bg);
    color: var(--color-text);
}

.st-fv-progress {
    margin-top: 12px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--color-bg);
}

.st-fv-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}

.st-fv-progress-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.18);
    overflow: hidden;
}

.st-fv-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--color-primary), #22d3ee);
    transition: width 0.25s ease;
}

.st-fv-progress-detail {
    margin-top: 8px;
    color: var(--color-text-2);
    font-size: 12px;
    line-height: 1.45;
}

.st-fv-content {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.st-fv-kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.st-fv-kpi {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 12px;
    background: var(--color-bg);
}

.st-fv-kpi .label {
    color: var(--color-text-2);
    font-size: 12px;
}

.st-fv-kpi .value {
    margin-top: 6px;
    font-size: 22px;
    font-weight: 700;
}

.st-fv-split {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
    gap: 16px;
    margin-bottom: 16px;
}

.st-fv-panel {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: var(--color-bg);
    overflow: hidden;
}

.st-fv-panel-title {
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 700;
}

.st-fv-table-wrap {
    max-height: 430px;
    overflow: auto;
}

.st-fv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.st-fv-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--color-bg);
}

.st-fv-factor-label {
    display: block;
    font-weight: 700;
    color: var(--color-text);
}

.st-fv-factor-code {
    display: block;
    margin-top: 2px;
    color: var(--color-text-2);
    font-size: 12px;
}

.st-fv-table th,
.st-fv-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
    white-space: nowrap;
}

.st-fv-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    background: rgba(148, 163, 184, 0.16);
}

.st-fv-status.effective {
    color: #0f9f6e;
    background: rgba(16, 185, 129, 0.14);
}

.st-fv-status.watch,
.st-fv-status.coverage_low,
.st-fv-status.sample_insufficient {
    color: #b7791f;
    background: rgba(245, 158, 11, 0.16);
}

.st-fv-adaptive-empty,
.st-fv-adaptive-card,
.st-fv-signal-list {
    padding: 14px;
    color: var(--color-text-2);
    font-size: 13px;
}

.st-fv-adaptive-card .weight {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-text);
}

.st-fv-signal-row {
    display: grid;
    grid-template-columns: 1fr repeat(3, 120px);
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    font-size: 13px;
}

.st-fv-signal-row.st-fv-two-col {
    grid-template-columns: minmax(0, 1.2fr) repeat(3, minmax(90px, 0.4fr));
}

.st-fv-placeholder {
    text-align: center;
    padding: var(--space-4);
    color: var(--color-text-2);
    font-size: 14px;
}

[data-theme="night"] .st-fv-container {
    background: transparent;
}
[data-theme="night"] .st-fv-content {
    background: #12141a;
    border-color: #2d2f3a;
}

@media (max-width: 900px) {
    .st-fv-kpis,
    .st-fv-split {
        grid-template-columns: 1fr;
    }
    .st-fv-signal-row {
        grid-template-columns: 1fr 1fr;
    }
}

/* ═══════════════════════════════════════════════════════════
   Portfolio Strategy (P0) — 组合策略样式补充
   ═══════════════════════════════════════════════════════════ */

/* ── 组合策略列表 ── */
.stps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.stps-active-bar {
    margin: 12px 0;
    padding: 8px 14px;
    background: var(--panel2);
    border-radius: 8px;
    font-size: 13px;
    color: var(--muted);
}
.stps-active-bar span {
    color: var(--green);
    font-weight: 600;
}
.stps-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── 编辑器视图 ── */
.st-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}
.st-editor-header h3 {
    margin: 0;
    font-size: 17px;
    color: var(--text);
}
.st-editor-actions {
    display: flex;
    gap: 8px;
}

/* ── 表单元素（补充，避免与文档内联样式冲突） ── */
.stps-editor-body .st-form-group {
    margin: 12px 0;
}
.stps-editor-body .st-form-group label {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 6px;
}
.stps-editor-body input[type="text"],
.stps-editor-body input[type="number"],
.stps-editor-body select,
.stps-editor-body textarea {
    width: 100%;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--color-text-1);
    font-size: 14px;
    outline: none;
}

/* 组合策略编辑器：卡片默认全部展开，无需点击 */
#st-portfolio .stg-layer-body {
    display: block !important;
}
#st-portfolio .stg-layer-header {
    cursor: default;
}
#st-portfolio .stg-layer-toggle {
    display: none;
}
.stps-editor-body input:focus,
.stps-editor-body select:focus {
    border-color: var(--accent);
}
.stps-editor-body .st-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}
.stps-editor-body .st-form-hint {
    font-size: 12px;
    color: var(--muted);
    margin-top: 4px;
}

/* ── 标签芯片 ── */
.st-tag-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.st-tag-chip {
    padding: 6px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 13px;
    cursor: pointer;
    transition: all .2s;
    user-select: none;
}
.st-tag-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.st-tag-chip.active {
    background: rgba(91, 157, 255, .15);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── 开关 toggle ── */
.st-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}
.st-toggle input {
    display: none;
}
.st-toggle-track {
    width: 44px;
    height: 24px;
    background: var(--line);
    border-radius: 999px;
    position: relative;
    transition: background .2s;
    flex-shrink: 0;
}
.st-toggle-track::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform .2s;
}
.st-toggle input:checked + .st-toggle-track {
    background: var(--green);
}
.st-toggle input:checked + .st-toggle-track::after {
    transform: translateX(20px);
}

/* ── 策略卡片 ── */
.st-strat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    position: relative;
    transition: all .2s;
}
.st-strat-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(91, 157, 255, .1);
}
.st-strat-card.active {
    border-color: var(--accent);
    background: rgba(91, 157, 255, .06);
}
.st-strat-card .st-strat-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--panel2);
    color: var(--muted);
}
.st-strat-card .st-strat-badge.active {
    background: rgba(62, 207, 142, .2);
    color: var(--green);
}

/* ── 表格增强 ── */
.st-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.st-table th,
.st-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}
.st-table th {
    color: var(--muted);
    font-weight: 600;
    background: var(--panel2);
}
.st-table tr:hover td {
    background: rgba(91, 157, 255, .04);
}
.st-table .st-td-num {
    font-family: var(--mono);
    text-align: right;
    width: 80px;
}

/* ── 空状态 ── */
.st-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
}
.st-empty .st-empty-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: .5;
}

/* ── 预览抽屉 ── */
#stps-preview-drawer {
    width: 420px;
    max-width: 90vw;
}
#stps-preview-drawer .pool-drawer-body {
    padding: 16px;
}

/* ── 响应式 ── */
@media (max-width: 768px) {
    .stps-editor-body .st-form-row {
        grid-template-columns: 1fr;
    }
    .stps-grid {
        grid-template-columns: 1fr;
    }
    #stps-preview-drawer {
        width: 100%;
        max-width: 100vw;
    }
}

/* ═══════════════════════════════════════════════════════════
   P3: 组合回测前端样式补充
   ═══════════════════════════════════════════════════════════ */

/* ── Alpha有效性 内部 Tab ── */
.st-fv-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}
.st-fv-tab {
    padding: 8px 18px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 14px;
    cursor: pointer;
    transition: all .2s;
}
.st-fv-tab:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.st-fv-tab.active {
    background: rgba(91, 157, 255, .15);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── 组合回测配置区 ── */
#stpb-kpi-section {
    margin-top: 16px;
}
#stpb-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

/* ── 图表容器 ── */
#stpb-chart-nav,
#stpb-chart-quantile,
#stpb-chart-ls,
#stpb-chart-turnover {
    width: 100%;
    min-height: 260px;
}

/* ── 进度条 ── */
.st-progress-bar {
    height: 6px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
}
.st-progress-bar .st-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #7eb8ff);
    border-radius: 999px;
    transition: width .3s ease;
}
