/* Modern Quantitative Trading Terminal Design System */
:root {
    /* Primary Palette - Deep Space */
    --bg-main: #0a0e14;
    --bg-sidebar: #0f141c;
    --bg-card: #141b24;
    --bg-card-header: #1a232e;
    --bg-input: #0a0e14;
    
    /* Accents - Electric & Vibrant */
    --accent: #3b82f6; /* Electric Blue */
    --accent-hover: #60a5fa;
    --accent-soft: rgba(59, 130, 246, 0.15);
    
    /* Semantic Colors */
    --positive: #10b981; /* Emerald */
    --positive-soft: rgba(16, 185, 129, 0.1);
    --negative: #ef4444; /* Ruby */
    --negative-soft: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b; /* Amber */
    
    /* Text & Neutral */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    /* Effects */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
}

/* Page Loader */
.page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 20, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
}

.d-none {
    display: none !important;
}

/* Base Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    overflow: hidden; /* App shell layout */
}

/* Layout - App Shell */
.app-wrapper {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: 64px 1fr;
    height: 100vh;
    width: 100vw;
}

.topbar {
    grid-column: 1 / -1;
    background-color: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    z-index: 100;
    height: 64px;
}

/* Demo 站体验期横幅：固定于顶栏下方，内容区由 body.has-trial-banner 补偿下移 */
.trial-banner {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 6px 16px;
    font-size: 12px;
    line-height: 1.5;
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.14), rgba(59, 130, 246, 0.14));
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    backdrop-filter: blur(6px);
}

.trial-banner a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
}

body.has-trial-banner .sidebar,
body.has-trial-banner .main-content {
    padding-top: calc(var(--space-lg) + 34px);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex: 0 0 280px;
}

/* 顶栏中部：容纳统一导航菜单与「更多」溢出菜单。
   min-width:0 让 flex 子项可收缩，配合 app.js 的溢出测量把放不下的 tab
   依次移入「更多」下拉，从根本上避免裁切/遮挡。 */
.topbar-center {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex: 0 0 auto;
    justify-content: flex-end;
}

.sidebar {
    grid-column: 1;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    transition: padding 0.25s ease, width 0.25s ease;
}

/* 侧栏标题栏：首次进入用户一眼可知此区为回测配置 */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border);
    margin-bottom: calc(var(--space-lg) * -1); /* 抵消 sidebar 的 gap */
}
.sidebar-header__title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    min-width: 0;
}
.sidebar-header__icon {
    font-size: 20px;
    color: var(--accent);
    flex-shrink: 0;
}
.sidebar-header__text {
    min-width: 0;
}
.sidebar-header__name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}
.sidebar-header__desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.3;
    margin-top: 2px;
}
.sidebar-toggle {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}
.sidebar-toggle:hover {
    background: var(--bg-card);
    color: var(--accent);
    border-color: var(--accent);
}

/* 折叠态导轨：侧栏收起时显示，保持回测入口始终可见 */
.sidebar-rail {
    display: none;
}
.sidebar-rail__btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--accent);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.sidebar-rail__btn:hover {
    background: var(--accent);
    color: white;
}

/* 侧栏折叠态：宽度收至 60px（导轨区），隐藏表单内容，主内容区自动扩展 */
.app-wrapper.sidebar-collapsed {
    grid-template-columns: 60px 1fr;
}
.app-wrapper.sidebar-collapsed .sidebar {
    padding: var(--space-md) var(--space-xs);
    overflow: hidden;
}
.app-wrapper.sidebar-collapsed .sidebar-header,
.app-wrapper.sidebar-collapsed #backtest-form {
    display: none;
}
.app-wrapper.sidebar-collapsed .sidebar-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
}

.main-content {
    grid-column: 2;
    overflow-y: auto;
    padding: var(--space-lg);
    background-color: var(--bg-main);
}

/* 无侧栏的独立功能页（市场雷达 / 资金管理 / 数据质量 / 绩效分析等）：
   .app-wrapper 默认是「320px 侧栏 + 1fr 内容」双列，供带回测配置侧栏的主面板使用。
   这些页面没有侧栏，若沿用默认双列，会把内容挤到第 2 列并在左侧留下 320px 的空洞，
   造成左右不对称。加 .app-single-col 后统一改为单列全宽并居中约束最大宽度。 */
.app-wrapper.app-single-col {
    grid-template-columns: minmax(0, 1fr);
}
.app-wrapper.app-single-col > .main-content,
.app-wrapper.app-single-col > main {
    grid-column: 1;
    min-width: 0;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    overflow-y: auto; /* 页面内容超出视口时由内容区自身滚动，避免被 body 的 overflow:hidden 裁切 */
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Typography */
h1, h2, h3, h4, h5 {
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.01em;
}

.text-mono {
    font-family: 'Roboto Mono', monospace;
}

.text-muted {
    color: var(--text-muted) !important;
}

/* 主题强调色工具类：此前仅在 report_dashboard / audit 内联定义，主面板与市场雷达等页面大量使用却无定义，
   导致品牌图标、卡片标题图标等回退为默认文字色。此处补齐全局定义，统一设计令牌。 */
.text-accent {
    color: var(--accent) !important;
}

/* 表格内代码(ticker)链接：常态中性色，避免喧宾夺主；hover 时用主题蓝+下划线暗示可点击 */
.ticker-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-family: 'Roboto Mono', monospace;
    transition: color 0.15s ease;
}
.ticker-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Components - Card */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
}

.card-header {
    padding: var(--space-md) var(--space-lg);
    background-color: var(--bg-card-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.card-header h3 {
    font-size: 16px;
    margin: 0;
}

.card-body {
    padding: var(--space-lg);
    flex: 1;
}

/* Components - Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}
.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: transparent;
    border-color: var(--border);
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background-color: var(--border);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* Components - Forms */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.form-control, .form-select {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s ease;
    outline: none;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-control::placeholder {
    color: var(--text-muted);
}

/* KPI Grid */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.kpi-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.kpi-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
}

/* KPI 卡片辅助小字（如指标统计窗口的起止日期） */
.kpi-sub {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Roboto Mono', monospace;
    margin-top: 2px;
}

/* ETF Pills */
.pool-section {
    margin-bottom: var(--space-xl);
}

.pool-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.pool-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}

.pool-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    max-height: 200px;
    overflow-y: auto;
    padding-right: var(--space-xs);
}

.etf-pill label {
    display: block;
    padding: 6px 12px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.etf-pill-name {
    display: inline-block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    vertical-align: middle;
    white-space: nowrap;
}

.etf-pill-meta {
    display: inline-block;
    margin-left: 8px;
    font-size: 12px;
    opacity: 0.75;
    vertical-align: middle;
    white-space: nowrap;
}

.etf-pill input:checked + label {
    background-color: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.etf-pill input:disabled + label {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background-color: var(--bg-card-header);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
}

tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Tabs */
.tabs {
    display: flex;
    gap: var(--space-lg);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-lg);
}

.tab-btn {
    padding: 12px 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    position: relative;
}

.tab-btn.active {
    color: var(--accent);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent);
}

/* Utility */
.positive { color: var(--positive) !important; }
.negative { color: var(--negative) !important; }
.warning { color: var(--warning) !important; }

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

.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }

/* Chart Overrides */
.chart-container {
    height: 400px;
    width: 100%;
}

/* ETF Selection Loading State */
.loading-etfs {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.loading-etfs::after {
    content: "Updating Available ETFs...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--bg-sidebar);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    border: 1px solid var(--accent);
    font-size: 12px;
    color: var(--accent);
    z-index: 10;
}

/* Missing Items List */
.missing-list {
    padding-left: 18px;
    margin: 0;
    list-style-type: square;
    opacity: 0.8;
}

.data-unavailable {
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}

.data-unavailable label {
    text-decoration: line-through;
}

/* Responsive */
@media (max-width: 1024px) {
    .app-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }
    .sidebar {
        grid-row: 2;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .main-content {
        grid-row: 3;
    }
}

/* 集成卡片样式 - 资金管理和绩效分析集成 */
.integration-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.integration-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    height: 180px;
    display: flex;
    flex-direction: column;
}

.integration-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.integration-card .card-header {
    padding: var(--space-md) var(--space-lg);
    background-color: var(--bg-card-header);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
}

.integration-card .card-header h5 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
}

.integration-card .card-body {
    padding: var(--space-md) var(--space-lg);
}

/* 统一导航菜单样式 */
.nav-menu {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    /* 不横向滚动：放不下的项由 app.js 收进「更多」下拉菜单，保持顶栏整齐、入口可达 */
    flex-wrap: nowrap;
    max-width: 100%;
}

/* 「更多」溢出菜单：空间不足时承接被移出的导航项 */
.nav-more {
    position: relative;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.nav-more[hidden] {
    display: none;
}
.nav-more__caret {
    font-size: 10px;
    margin-left: -2px;
}
/* 「更多」按钮隐藏数量徽标：让用户一眼知道还有几个入口被收起 */
.nav-more__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    margin-left: 2px;
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}
.nav-more__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    max-height: 70vh;
    overflow-y: auto;
    display: none;
    flex-direction: column;
    gap: 2px;
    padding: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
}
.nav-more.is-open .nav-more__menu {
    display: flex;
}
/* 下拉内的导航项：左对齐、等宽铺满 */
.nav-more__menu .nav-btn {
    width: 100%;
    justify-content: flex-start;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0; /* 防止按钮被压缩变形 */
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
}

.nav-btn i {
    font-size: 14px;
}

/* 行情看板 */
.market-ticker {
    display: flex;
    gap: var(--space-md);
    padding-right: var(--space-md);
    border-right: 1px solid var(--border);
}

.index-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 60px;
}

.index-item .label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    line-height: 1;
    margin-bottom: 2px;
}

.index-item .value {
    font-size: 14px;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    line-height: 1.2;
}

/* 风控角标 */
.risk-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    cursor: help;
}

.risk-badge .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.risk-badge span:not(.status-dot) {
    font-size: 12px;
    font-weight: 600;
}

/* 工具组 */
.tool-group {
    display: flex;
    gap: var(--space-xs);
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--bg-card-header);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* 移动端导航适配 */
/* 断点由 1400 上调至 1500：补齐 Bootstrap 工具类后，顶栏右侧的用户名/角色
   （.user-info 的 d-md-block）与 me-*/ms-* 间距恢复生效，右侧宽度增加约 45px，
   1440px 笔记本视口下导航文字已无余量，会顶到 .topbar-center 的裁切边界。
   下调到只显示图标后，1440px 下导航宽度约 340px，余量充足。 */
@media (max-width: 1500px) {
    .nav-btn span {
        display: none;
    }
    .nav-btn {
        padding: 8px;
    }
}

@media (max-width: 1024px) {
    /* 小屏不再直接隐藏导航：交由 app.js 的溢出逻辑把放不下的项收进「更多」，
       保证所有入口仍然可达，避免此前 .nav-menu 直接消失导致无法切页 */
    .topbar-center {
        justify-content: flex-end;
    }
}

.integration-card .card-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-lg);
}

.capital-metrics,
.performance-metrics {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
}

.metric-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.metric-value {
    font-size: 14px;
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
    color: var(--text-primary);
}

.capital-chart-mini,
.performance-chart-mini {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 响应式调整 */
@media (max-width: 992px) {
    .app-wrapper {
        grid-template-columns: 1fr;
        grid-template-rows: 64px auto 1fr;
        overflow: auto;
        height: auto;
    }

    .topbar {
        position: sticky;
        top: 0;
        width: 100%;
    }

    .sidebar {
        grid-column: 1;
        border-right: none;
        border-bottom: 1px solid var(--border);
        height: auto;
        padding: var(--space-md);
    }

    .main-content {
        grid-column: 1;
        padding: var(--space-md);
    }

    /* 小屏不再整块隐藏导航：保持 .topbar-center 有实际宽度，
       由 app.js 的溢出逻辑把放不下的导航项收进「更多」下拉，
       保证所有入口在小屏下依然可达。 */
    .topbar-center {
        justify-content: flex-end;
    }

    .nav-menu {
        flex-wrap: nowrap;
        justify-content: flex-start;
    }
    
    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .kpi-row {
        grid-template-columns: 1fr;
    }
    
    .topbar-left {
        flex: 1;
    }
    
    .market-ticker {
        display: none !important;
    }

    .integration-cards-row {
        grid-template-columns: 1fr;
    }
    
    .weight-allocation-container {
        grid-template-columns: 1fr;
    }

    .strategy-metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* 多策略管理面板样式 */
.strategy-overview-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.strategy-overview-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.strategy-metrics-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.strategy-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-md);
    background-color: var(--bg-card-header);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.strategy-metric .metric-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: var(--space-xs);
}

.strategy-metric .metric-value {
    font-size: 20px;
    font-weight: 700;
    font-family: 'Roboto Mono', monospace;
    color: var(--text-primary);
}

/* 权重分配容器 */
.weight-allocation-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    align-items: start;
}

.weight-chart-section {
    display: flex;
    justify-content: center;
    align-items: center;
}

.weight-control-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.weight-controls {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    max-height: 400px;
    overflow-y: auto;
    padding-right: var(--space-sm);
}

.weight-control-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background-color: var(--bg-card-header);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.weight-control-item .strategy-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
}

.weight-control-item .weight-input {
    width: 80px;
    text-align: center;
}

.weight-control-item .weight-slider {
    flex: 1;
    max-width: 200px;
}

.weight-summary {
    display: flex;
    justify-content: space-between;
    padding: var(--space-md);
    background-color: var(--bg-card-header);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.summary-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.summary-item .label {
    font-size: 13px;
    color: var(--text-muted);
}

.summary-item .value {
    font-size: 16px;
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
}

/* 状态监控网格 */
.status-monitoring-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-md);
}

.status-card {
    background-color: var(--bg-card-header);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.status-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-card-title {
    font-weight: 600;
    color: var(--text-primary);
}

.status-badge {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.running {
    background-color: var(--positive-soft);
    color: var(--positive);
    border: 1px solid var(--positive);
}

.status-badge.stopped {
    background-color: var(--negative-soft);
    color: var(--negative);
    border: 1px solid var(--negative);
}

/* 模态框样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    width: 500px;
    max-width: 90%;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.modal-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.btn-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-md);
    background: var(--bg-main);
}

.d-none {
    display: none !important;
}

/* 按钮样式微调 */
.btn-xs {
    padding: 2px 8px;
    font-size: 13px;
}

.status-badge.warning {
    background-color: var(--warning-soft);
    color: var(--warning);
    border: 1px solid var(--warning);
}

.status-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
}

.status-metric {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.status-metric-label {
    font-size: 12px;
    color: var(--text-muted);
}

.status-metric-value {
    font-size: 13px;
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
    color: var(--text-primary);
}

/* 策略配置表格 */
.strategy-config-table {
    width: 100%;
    overflow-x: auto;
}

.strategy-config-table table {
    width: 100%;
    border-collapse: collapse;
}

.strategy-config-table th {
    background-color: var(--bg-card-header);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.strategy-config-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
}

.strategy-config-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.02);
}

/* 相关性分析摘要 */
.correlation-summary {
    margin-top: var(--space-lg);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
}

.summary-grid .summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background-color: var(--bg-card-header);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.summary-grid .label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.summary-grid .value {
    font-size: 14px;
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
    color: var(--text-primary);
}

/* 响应式调整 */
@media (max-width: 1024px) {
    .weight-allocation-container {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
    }
    
    .strategy-metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .status-monitoring-grid {
        grid-template-columns: 1fr;
    }
    
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .weight-controls {
        max-height: 300px;
    }
    
    .weight-control-item {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
    }
    
    .weight-control-item .weight-slider {
        max-width: none;
    }
    
    .weight-summary {
        flex-direction: column;
        gap: var(--space-md);
    }
    
    .summary-grid {
        grid-template-columns: 1fr;
    }
    
    .status-metrics {
        grid-template-columns: 1fr;
    }
}

/* ===== 实时监控报警中心样式 ===== */

/* 顶部状态指示器 */
.topbar-status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 12px;
    color: var(--text-muted);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-indicator.active {
    background-color: var(--positive);
    box-shadow: 0 0 0 2px var(--positive-soft);
}

.status-indicator.inactive {
    background-color: var(--negative);
}

.notification-badge {
    background-color: var(--negative);
    color: white;
    border-radius: 20px;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    text-align: center;
}

/* 报警统计卡片 */
.metric-badge {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
}

.metric-badge.critical {
    background-color: var(--negative-soft);
    color: var(--negative);
}

.metric-badge.warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.metric-badge.info {
    background-color: var(--positive-soft);
    color: var(--positive);
}

/* 报警列表 */
.alert-list {
    max-height: 400px;
    overflow-y: auto;
}

.alert-item {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.2s ease;
}

.alert-item:hover {
    background-color: var(--bg-card-header);
}

.alert-item.critical {
    border-left: 4px solid var(--negative);
    background-color: var(--negative-soft);
}

.alert-item.warning {
    border-left: 4px solid var(--warning);
    background-color: rgba(245, 158, 11, 0.05);
}

.alert-item.info {
    border-left: 4px solid var(--positive);
    background-color: var(--positive-soft);
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--space-sm);
}

.alert-title {
    font-weight: 600;
    font-size: 14px;
}

.alert-time {
    font-size: 13px;
    color: var(--text-muted);
    font-family: 'Roboto Mono', monospace;
}

.alert-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
    line-height: 1.5;
}

.alert-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

.alert-list-empty {
    padding: var(--space-xl);
    text-align: center;
    color: var(--text-muted);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.empty-icon {
    font-size: 48px;
    opacity: 0.5;
}

/* 健康监控指标 */
.health-metric {
    background-color: var(--bg-card);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.health-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
    font-weight: 500;
}

.health-value {
    font-size: 18px;
    font-weight: 600;
    font-family: 'Roboto Mono', monospace;
    margin-bottom: var(--space-sm);
}

.health-progress {
    background-color: var(--bg-input);
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--positive), var(--accent));
    transition: width 0.3s ease;
    border-radius: 3px;
}

.progress-bar.warning {
    background: linear-gradient(90deg, var(--warning), #f97316);
}

.progress-bar.critical {
    background: linear-gradient(90deg, var(--negative), #dc2626);
}

/* 表单控件组 */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.slider-with-value {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 12px;
    color: var(--text-muted);
}

.slider {
    flex: 1;
    height: 4px;
    background-color: var(--bg-input);
    border-radius: 2px;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-main);
}

.slider-value {
    min-width: 30px;
    text-align: right;
    font-family: 'Roboto Mono', monospace;
    font-weight: 600;
}

/* 开关控件 */
.toggle-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

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

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

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

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

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

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

.toggle-label {
    font-size: 14px;
    color: var(--text-primary);
}

/* 状态徽章 */
.status-badge {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 600;
}

.status-badge.healthy {
    background-color: var(--positive-soft);
    color: var(--positive);
}

.status-badge.warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.status-badge.critical {
    background-color: var(--negative-soft);
    color: var(--negative);
}

/* 响应式调整 - 监控中心 */
@media (max-width: 1280px) {
    .alert-item {
        padding: var(--space-sm);
    }
    
    .alert-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .alert-actions .btn {
        width: 100%;
    }
}

@media (max-width: 768px) {
    .topbar-status {
        display: none;
    }
    
    .health-metric {
        padding: var(--space-sm);
    }
    
    .health-value {
        font-size: 16px;
    }
    
    .slider-with-value {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-xs);
    }
}

/* ===== 微信/钉钉集成样式 ===== */
.integration-panel {
    background-color: var(--bg-card-header);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid var(--border);
    margin-top: var(--space-sm);
}

.integration-panel .form-group {
    margin-bottom: var(--space-md);
}

.integration-panel .form-group:last-child {
    margin-bottom: 0;
}

/* 多级报警设置样式 */
.level-setting {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm);
    background-color: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.level-label {
    font-size: 13px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 8px;
}

.level-label.critical {
    background-color: var(--negative-soft);
    color: var(--negative);
}

/* ===== 参数优化进度监控面板样式 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-sm);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Roboto Mono', monospace;
}

.current-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--space-md);
    margin-top: var(--space-sm);
}

.current-metrics-grid .metric-item {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border);
    margin: 0;
}

.current-metrics-grid .metric-label {
    font-size: 12px;
    color: var(--text-muted);
}

.current-metrics-grid .metric-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'Roboto Mono', monospace;
}

/* 实时进度动画 */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.optimizing .stat-value,
.optimizing .metric-value {
    animation: pulse 2s infinite;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .stats-grid,
    .current-metrics-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
    
    .stat-item,
    .current-metrics-grid .metric-item {
        padding: var(--space-xs) var(--space-sm);
    }
}
}

.level-label.warning {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.level-label.info {
    background-color: var(--positive-soft);
    color: var(--positive);
}

.level-setting select {
    min-width: 120px;
}

/* 历史报警模态框样式 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: var(--bg-main);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    background-color: var(--bg-card-header);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    background-color: var(--bg-input);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-lg);
    max-height: calc(80vh - 120px);
    overflow-y: auto;
}

.history-filters {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}

.history-filters select {
    min-width: 120px;
}

.history-table-container {
    overflow-x: auto;
    margin-bottom: var(--space-lg);
}

.history-table-container table {
    width: 100%;
    border-collapse: collapse;
}

.history-table-container th {
    background-color: var(--bg-card-header);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.history-table-container td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-secondary);
}

.history-table-container tr:hover td {
    background-color: var(--bg-card-header);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
}

/* 响应式调整 - 集成面板 */
@media (max-width: 1024px) {
    .integration-panel {
        padding: var(--space-sm);
    }
    
    .level-setting {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-sm);
    }
    
    .level-setting select {
        min-width: auto;
        width: 100%;
    }
}

@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-width: none;
        margin: var(--space-md);
        top: var(--space-md);
        left: var(--space-md);
        transform: none;
        max-height: calc(100vh - var(--space-md) * 2);
    }
    
    .history-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .history-filters select {
        width: 100%;
    }
}

/* ==========================================================================
   Bootstrap 工具类补齐
   --------------------------------------------------------------------------
   背景：页面只引入了 bootstrap-icons（纯图标字体，不含任何布局类），
   但 13 个模板共 460 处使用 Bootstrap 工具类（d-flex / align-items-center /
   me-3 / text-center 等）。这些类此前全部没有定义，等于哑火，最典型的故障是
   顶栏 .user-profile 退化成 block，头像与图标按钮竖向堆叠，把 64px 顶栏撑到 128px。

   处理：按 Bootstrap 5 语义在此集中定义，间距刻度映射项目自身的 --space-* 变量
   （1→xs 4px，2→sm 8px，3→md 16px，4→lg 24px，5→xl 32px），保证与既有设计一致。
   不引入整套 Bootstrap，避免与其重定义 .btn / .d-none 等造成全局视觉冲突。

   范围：只补布局、间距、排版、尺寸类。边框、圆角、阴影、position 类
   （border-* / rounded* / shadow-* / position-relative）刻意不补——这些类失效
   仅表现为"少一个装饰"，不影响结构与可用性，补上反而会引入未经回归的视觉变化。
   ========================================================================== */

/* ---------- Display ---------- */
.d-flex {
    display: flex !important;
}

.d-block {
    display: block !important;
}

/* ---------- Flex ---------- */
.flex-column {
    flex-direction: column !important;
}

.flex-wrap {
    flex-wrap: wrap !important;
}

.flex-grow-1 {
    flex-grow: 1 !important;
}

.flex-shrink-0 {
    flex-shrink: 0 !important;
}

/* ---------- 主轴对齐 ---------- */
.align-items-center {
    align-items: center !important;
}

.align-items-end {
    align-items: flex-end !important;
}

/* ---------- 交叉轴分布 ---------- */
.justify-content-center {
    justify-content: center !important;
}

.justify-content-between {
    justify-content: space-between !important;
}

/* ---------- Gap ---------- */
.gap-2 {
    gap: var(--space-sm);
}

.gap-3 {
    gap: var(--space-md);
}

.gap-4 {
    gap: var(--space-lg);
}

/* ---------- Margin ---------- */
.mb-0 {
    margin-bottom: 0 !important;
}

.mb-1 {
    margin-bottom: var(--space-xs) !important;
}

.mb-2 {
    margin-bottom: var(--space-sm) !important;
}

.mb-3 {
    margin-bottom: var(--space-md) !important;
}

.mb-4 {
    margin-bottom: var(--space-lg) !important;
}

.mt-1 {
    margin-top: var(--space-xs) !important;
}

.mt-2 {
    margin-top: var(--space-sm) !important;
}

.mt-3 {
    margin-top: var(--space-md) !important;
}

.mt-4 {
    margin-top: var(--space-lg) !important;
}

.mt-5 {
    margin-top: var(--space-xl) !important;
}

.me-1 {
    margin-right: var(--space-xs) !important;
}

.me-2 {
    margin-right: var(--space-sm) !important;
}

.me-3 {
    margin-right: var(--space-md) !important;
}

.ms-2 {
    margin-left: var(--space-sm) !important;
}

.my-2 {
    margin-top: var(--space-sm) !important;
    margin-bottom: var(--space-sm) !important;
}

.my-3 {
    margin-top: var(--space-md) !important;
    margin-bottom: var(--space-md) !important;
}

/* ---------- Padding ---------- */
.p-0 {
    padding: 0 !important;
}

.p-2 {
    padding: var(--space-sm) !important;
}

.p-3 {
    padding: var(--space-md) !important;
}

.p-4 {
    padding: var(--space-lg) !important;
}

.pt-2 {
    padding-top: var(--space-sm) !important;
}

.pb-3 {
    padding-bottom: var(--space-md) !important;
}

.pb-4 {
    padding-bottom: var(--space-lg) !important;
}

.px-3 {
    padding-left: var(--space-md) !important;
    padding-right: var(--space-md) !important;
}

.px-4 {
    padding-left: var(--space-lg) !important;
    padding-right: var(--space-lg) !important;
}

.py-1 {
    padding-top: var(--space-xs) !important;
    padding-bottom: var(--space-xs) !important;
}

.py-2 {
    padding-top: var(--space-sm) !important;
    padding-bottom: var(--space-sm) !important;
}

.py-3 {
    padding-top: var(--space-md) !important;
    padding-bottom: var(--space-md) !important;
}

.py-4 {
    padding-top: var(--space-lg) !important;
    padding-bottom: var(--space-lg) !important;
}

.py-5 {
    padding-top: var(--space-xl) !important;
    padding-bottom: var(--space-xl) !important;
}

/* ---------- 尺寸 ---------- */
.w-100 {
    width: 100% !important;
}

.h-100 {
    height: 100% !important;
}

/* ---------- 排版 ---------- */
.text-center {
    text-align: center !important;
}

.text-start {
    text-align: left !important;
}

.text-end {
    text-align: right !important;
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fw-bold {
    font-weight: 700 !important;
}

.fs-4 {
    font-size: 1.5rem !important;
}

.fs-5 {
    font-size: 1.25rem !important;
}

/* ---------- 响应式显隐 ----------
   必须置于文件中所有 .d-none 定义（第 61、1101 行）之后，
   这样同为 !important 时由书写顺序决定、响应式类胜出，
   才能实现「小屏隐藏、大屏显示」的经典组合（如 d-none d-xl-flex）。 */
@media (min-width: 768px) {
    .d-md-block {
        display: block !important;
    }
}

@media (min-width: 992px) {
    .d-lg-flex {
        display: flex !important;
    }
}

/* .d-xl-flex 刻意不定义：
   index.html 第 190 行的行情条写作 class="market-ticker d-none d-xl-flex"，
   但因 .d-none 一直生效，该行情条从未展示过（属未经线上验证的模块）。
   若此处按 Bootstrap 语义在 ≥1200px 放行，顶栏右侧会多占约 230px，
   在 1200~1500px 的笔记本视口下会把中间导航按钮挤出 .topbar-center 的
   overflow:hidden 边界（按现有尺寸推算：1440px 时导航约需 700px，可用仅约 470px）。
   HTML 中的 d-xl-flex 保留为"意图标记"，待顶栏元素优先级重新规划后再启用。 */

/* ============================================================
   数据源状态条 (Datasource Bar)
   用于明确告知用户：当前主面板展示的是模拟盘实时数据，
   还是某次历史回测的结果。避免用户混淆数据来源。
   ============================================================ */
.datasource-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    transition: background-color 0.2s, border-color 0.2s;
}

.datasource-bar__left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.datasource-bar__dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 8px currentColor;
}

.datasource-bar__text {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.datasource-bar__label {
    font-size: 13px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.datasource-bar__value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.datasource-bar__desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.datasource-bar__right {
    flex-shrink: 0;
}

/* 模拟盘实时视图：青绿色标识 */
.datasource-bar.datasource-live {
    background-color: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.25);
}
.datasource-bar.datasource-live .datasource-bar__dot {
    background-color: #10b981;
    color: #10b981;
}
.datasource-bar.datasource-live .datasource-bar__value {
    color: #34d399;
}

/* 回测视图：靛蓝色标识 */
.datasource-bar.datasource-backtest {
    background-color: rgba(99, 102, 241, 0.10);
    border-color: rgba(99, 102, 241, 0.30);
}
.datasource-bar.datasource-backtest .datasource-bar__dot {
    background-color: #6366f1;
    color: #6366f1;
}
.datasource-bar.datasource-backtest .datasource-bar__value {
    color: #818cf8;
}

/* ============================================================
   模块数据来源提示横幅 (Module Hint)
   用于在"执行质量"、"风控"等始终读取模拟盘数据的标签页中，
   当用户加载了回测视图时提醒：此处数据与回测无关。
   ============================================================ */
.module-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 6px;
    background-color: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    color: #fbbf24;
    font-size: 12.5px;
    margin-bottom: 16px;
}
.module-hint i {
    font-size: 14px;
    flex-shrink: 0;
}
.module-hint span {
    color: #fcd34d;
}

/* ============================================================
   Markdown 正文排版（AI 周报 / AI 投研内容）
   背景：周报 AI 正文此前用内联样式 font-size:13px、color:var(--text-main)，
        但 --text-main 从未定义，颜色实际靠继承回退，正文为纯白且刺眼，
        标题层级仅靠加粗区分、扫读困难。
   说明：此处统一收敛为类级样式，供 #weekly-ai-content、
        #weekly-ai-content-full 两处共用，避免内联样式各写一套。
   ============================================================ */
.markdown-body {
    font-size: 14px;                 /* 研报正文 14px，比原 13px 更适合长文阅读 */
    line-height: 1.8;
    color: var(--text-secondary);    /* 灰蓝正文，降低纯白在深色底上的刺眼感 */
    word-break: break-word;
    overflow-wrap: anywhere;
}

/* 标题层级：H1~H3 逐级递减，H2 加分割线、H3 加左侧强调条，便于快速定位章节 */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5,
.markdown-body h6 {
    color: var(--text-primary);
    font-weight: 700;
    line-height: 1.4;
    margin: 1.4em 0 0.6em;
}

.markdown-body h1 {
    font-size: 20px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.markdown-body h2 {
    font-size: 17px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.markdown-body h3 {
    font-size: 16px;
    padding-left: 10px;
    border-left: 3px solid var(--accent);
}

.markdown-body h4 {
    font-size: 15px;
    color: #93c5fd;               /* 次级章节用浅蓝，与 H3 白色区分 */
}

.markdown-body h5,
.markdown-body h6 {
    font-size: 13.5px;
}

/* 首个 / 末个元素不占外边距，避免与容器 padding 叠加出现空洞 */
.markdown-body > :first-child { margin-top: 0; }
.markdown-body > :last-child { margin-bottom: 0; }

.markdown-body p { margin: 0 0 0.9em; }

/* 强调：在灰蓝正文中回到高对比白，突出关键结论 */
.markdown-body strong,
.markdown-body b {
    color: var(--text-primary);
    font-weight: 600;
}

.markdown-body em {
    color: var(--text-primary);
    font-style: italic;
}

/* 列表：统一缩进，标记点用主题强调色 */
.markdown-body ul,
.markdown-body ol {
    margin: 0 0 0.9em;
    padding-left: 1.4em;
}

.markdown-body li { margin: 0.25em 0; }
.markdown-body li::marker { color: var(--accent); }

/* 引用块：左侧强调竖线 + 轻背景，用于风险提示 / 免责声明 */
.markdown-body blockquote {
    margin: 0 0 0.9em;
    padding: 8px 14px;
    border-left: 3px solid var(--accent);
    background: rgba(59, 130, 246, 0.06);
    border-radius: 0 6px 6px 0;
    color: var(--text-secondary);
}

.markdown-body blockquote > :last-child { margin-bottom: 0; }

/* 行内代码 / 代码块（深色主题适配） */
.markdown-body code {
    font-family: "Roboto Mono", Consolas, monospace;
    font-size: 0.92em;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    color: #93c5fd;
}

.markdown-body pre {
    margin: 0 0 0.9em;
    padding: 12px 14px;
    border-radius: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    overflow-x: auto;
}

.markdown-body pre code {
    padding: 0;
    background: none;
    color: var(--text-secondary);
    font-size: 12.5px;
    line-height: 1.6;
}

/* 链接 */
.markdown-body a {
    color: var(--accent-hover);
    text-decoration: none;
}

.markdown-body a:hover { text-decoration: underline; }

/* 表格：细边框 + 表头轻背景 */
.markdown-body table {
    width: 100%;
    margin: 0 0 0.9em;
    border-collapse: collapse;
    font-size: 13px;
}

.markdown-body th,
.markdown-body td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: left;
}

.markdown-body th {
    background: var(--bg-card-header);
    color: var(--text-primary);
    font-weight: 600;
}

/* 分隔线 */
.markdown-body hr {
    margin: 1.2em 0;
    border: 0;
    border-top: 1px solid var(--border);
}
