body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    overflow-x: hidden;
}
.editable {
    cursor: pointer;
}
.editable:hover {
    background-color: #f0f8ff;
}
input[type="number"], input[type="date"] {
    width: 95%;
    padding: 2px;
}
.positive {
    color: #e74c3c;
}
.negative {
    color: #2ecc71;
}
.neutral {
    color: #666;
}
.sort-active {
    color: #e74c3c !important;
    font-weight: bold;
}
tfoot td {
    background-color: #f8f9fa;
    font-weight: bold;
}
#average-return-rate.positive {
    color: #e74c3c;
}
#average-return-rate.negative {
    color: #2ecc71;
}
#annualized-return-rate.positive {
    color: #9b59b6;
}
#annualized-return-rate.negative {
    color: #3498db;
}

.period-selector {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}
.period-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}
.period-btn {
    padding: 8px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    background: white;
    transition: all 0.3s ease;
}
.period-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}
.index-selector {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}
.chart-container {
    margin-top: 40px;
    height: 500px;
    width: 100%;
    position: relative;
    overflow: hidden;
}
#error-toast {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #ff4444;
    color: white;
    padding: 15px;
    border-radius: 5px;
}

/* 表格容器样式 */
.trade-list-container {
    display: flex;
    flex-direction: column;
    margin: 20px 0;
    width: 100%;
    max-width: 100%;
    overflow: visible !important;
    position: static; /* 确保定位基准正确 */
    isolation: isolate;
}

.table-header {
    display: flex;
    background: #f8f9fa;
    padding: 12px 8px;
    border-bottom: 2px solid #dee2e6;
    min-width: fit-content; /* 自动适应最小宽度 */
}

.table-row {
    display: flex;
    padding: 12px 8px;
    border-bottom: 1px solid #dee2e6;
    min-width: fit-content;
    position: relative;
    z-index: 1;
}

/* 列通用样式 */
.table-header > div,
.table-row > div {
    flex: 1;
    min-width: 100px;
    padding: 0 8px;
    /* 复合布局保证严格居中 */
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-header > div,
.table-row > div {
    flex: 1;
}

/* 响应式调整 */
@media (max-width: 1200px) {
    .table-header > div,
    .table-row > div {
        min-width: 80px;
        padding: 0 4px;
        font-size: 14px;
    }
}

@media (max-width: 992px) {
    .table-header > div,
    .table-row > div {
        min-width: 60px;
        padding: 0 5px;
    }
}

@media (max-width: 768px) {
    .table-header > div,
    .table-row > div {
        min-width: 70px;
        font-size: 13px;
        padding: 0 2px;
    }
    .status-indicator {
        padding: 1px 4px;
        font-size: 0.8em;
    }
    .filter-options {
        left: auto;
        right: -10px;
        transform: none;
    }
}

/* 保留原有可编辑样式 */
.editable {
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.editable:hover {
    background-color: #f0f8ff;
}

.sort-filter-header {
    position: relative !important;
    cursor: pointer;
    padding-right: 25px !important;
    z-index: 1000;
    overflow: visible !important; /* 允许子元素溢出 */
    transition: all 0.2s ease;
}
.filter-arrow {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #666;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.sort-filter-header.active .filter-arrow {
    transform: translateY(-50%) rotate(180deg);
}
.filter-options {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    box-shadow: 0 3px 6px -4px rgba(0,0,0,0.12),
                0 6px 16px 0 rgba(0,0,0,0.08),
                0 9px 28px 8px rgba(0,0,0,0.05);
    z-index: 9999;
    min-width: 120px;
    padding: 4px 0;
    opacity: 0;
    transition: all 0.2s ease;
}
.filter-option {
    padding: 8px 16px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    color: #333;
}
.filter-option:hover {
    background: #f5f5f5;
    color: #1890ff;
}
.sort-filter-header.active .filter-options {
    display: block;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.status-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    min-width: 60px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.持有中 { background: #e6f7ff; color: #f4adf4; border: 1px solid #91d5ff;}
.已止盈 { background: #fff2f0; color: #f5222d; border: 1px solid #ffccc7;}
.已止损 { background: #f6ffed; color: #52c41a; border: 1px solid #b7eb8f;}
.已平出 { background: #fafafa; color: #8c8c8c; border: 1px solid #d9d9d9;}

/* 悬停效果 */
.status-indicator:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.sort-header {
    position: relative;
    padding-right: 20px !important;
}
.sort-header:hover {
    text-decoration: underline;
}
.sort-active {
    color: #e74c3c !important;
    font-weight: bold;
}


/* 修改排序箭头样式 */
.sort-header::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    opacity: 0;
    transition: opacity 0.2s;
}

/* 激活状态显示箭头 */
.sort-header.asc::after,
.sort-header.desc::after {
    opacity: 1 !important;
}

/* 升序状态 */
.sort-header.asc::after {
    border-bottom-color: #e74c3c;
    border-top-color: transparent;
    margin-top: -2px;
}

/* 降序状态 */
.sort-header.desc::after {
    border-top-color: #e74c3c !important;
    border-bottom-color: transparent !important;
    margin-top: 2px; /* 调整箭头位置 */
}

/* 悬停时只对非激活状态显示灰色箭头 */
.sort-header:not(.sort-active):hover::after {
    opacity: 1;
    border-top-color: #999;
}

/* 移除原来的悬停样式 */
.sort-header.asc:hover::after,
.sort-header.desc:hover::after {
    border-top-color: transparent; /* 保持激活状态样式不变 */
}

/* 日期和数值字段优化 */
.table-header > div:nth-child(4), /* 买入日期 */
.table-header > div:nth-child(6), /* 卖出日期 */
.table-header > div:nth-child(7), /* 持股天数 */
.table-header > div:nth-child(9), /* 收益率 */
.table-row > div:nth-child(4),    /* 买入日期 */
.table-row > div:nth-child(6),    /* 卖出日期 */
.table-row > div:nth-child(7),    /* 持股天数 */
.table-row > div:nth-child(9) {   /* 收益率 */
    color: #333; /* 深灰色字体 */
    text-decoration: none !important; /* 去除下划线 */
    font-family: 'Segoe UI', Arial, sans-serif; /* 更专业的字体 */
    font-weight: normal; /* 常规字重 */
}

/* 特别优化收益率显示 */
.table-row > div:nth-child(9) {
    font-family: 'Arial Narrow', Arial, sans-serif; /* 等宽字体便于数字对齐 */
    letter-spacing: 0.5px; /* 轻微字距调整 */
}

/* 去除链接默认样式 */
.sort-header {
    color: inherit !important; /* 继承父元素颜色 */
    text-decoration: none !important; /* 去除下划线 */
    cursor: pointer; /* 保持可点击状态 */
    transition: color 0.2s; /* 添加颜色过渡效果 */
}

/* 排序激活状态样式调整 */
.sort-header.sort-active {
    color: #f5222d !important; /* 深灰色激活状态 */
    font-weight: 600; /* 稍微加粗 */
}

/* 日期字段特殊优化 */
.table-row > div:nth-child(4), /* 买入日期 */
.table-row > div:nth-child(6) { /* 卖出日期 */
    font-family: 'Consolas', 'Monaco', monospace; /* 等宽字体更好对齐 */
    color: #555; /* 稍浅的灰色 */
}

.chart-controls {
    position: absolute;
    top: 10px;
    right: 15px;
    display: flex;
    gap: 5px;
    z-index: 100;
    background: rgba(255,255,255,0.8);
    padding: 5px;
    border-radius: 4px;
}

.chart-controls button {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.chart-controls button:hover {
    background: #f5f5f5;
}

/* 改进的工具提示样式 */
.tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    pointer-events: none;
    font-size: 12px;
    z-index: 9999;
    display: none;
    max-width: 300px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    /* 新增属性 */
    white-space: normal;
    word-wrap: break-word;
    right: auto !important;
    min-width: 100px; /* 设置最小宽度 */
    white-space: nowrap; /* 禁止自动换行 */
}

/* 全屏模式适配 */
.chart-container:-webkit-full-screen .tooltip,
.chart-container:fullscreen .tooltip {
    font-size: 16px;
    padding: 12px 16px;
    max-width: 400px;
}

/* 新增：拖动选择框样式 */
.zoom-selection {
    position: absolute;
    background: rgba(0, 119, 255, 0.1);
    border: 1px solid rgba(0, 119, 255, 0.3);
    z-index: 10;
    display: none;
    pointer-events: none;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}
.page-size-selector {
    margin-left: auto;
}
.page-size-selector select {
    padding: 5px 10px;
    border-radius: 4px;
    border: 1px solid #ddd;
}
.pagination {
    display: flex;
    gap: 5px;
}
.pagination a {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #007bff;
}
.pagination a.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}
.pagination a:hover:not(.active) {
    background-color: #f0f8ff;
}

#suggestions-list li:hover {
    background-color: #f5f5f5;
}

/* 调整搜索框宽度 */
.search-container {
    width: 300px;
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
    margin-left: 50px;
    margin-right: 20px;
}
#search-input {
    width: 200px;
    padding: 8px;
}

/* 搜索建议样式优化 */
#suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    max-height: 200px;
    overflow-y: auto; /* 只允许垂直滚动 */
    overflow-x: hidden; /* 禁止横向滚动 */
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
    margin: 0;
    padding: 0;
    list-style: none;
}

#suggestions-list li {
    padding: 8px 12px;
    cursor: pointer;
    white-space: nowrap; /* 防止文本换行 */
    overflow: hidden; /* 隐藏溢出内容 */
    text-overflow: ellipsis; /* 显示省略号 */
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s;
}

#suggestions-list li:hover {
    background-color: #f5f5f5;
    transform: translateX(5px);
}

#suggestions-list li:last-child {
    border-bottom: none;
}

/* 添加搜索图标 */
.search-container::before {
    content: "🔍";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.6;
    z-index: 1;
}
#search-input {
    padding-left: 35px !important;
}

/* 新增控制组样式 */
.control-group {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* 导航栏样式 */
#sidebar {
    position: fixed;
    left: -200px;
    top: 0;
    width: 200px;
    height: 100vh;
    background: var(--nav-bg);
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    z-index: 1000;
    left: -240px; /* 增加宽度 */
    width: 240px;
    backdrop-filter: blur(10px); /* 毛玻璃效果 */
    border-right: 1px solid rgba(0,0,0,0.1);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1); /* 更平滑的动画曲线 */
}

.nav-title {
    color: var(--text-color);
    padding: 20px 15px;
    margin: 0;
    font-size: 1.2rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-item {
    position: relative;
    transition: transform 0.2s;
}

.nav-item:hover {
    transform: translateX(8px);
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.3s ease;
    gap: 15px;
}

.nav-link:hover {
    background: rgba(0,0,0,0.05);
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.nav-text {
    flex-grow: 1;
    font-size: 0.95rem;
}

.new-badge {
    background: #e74c3c;
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
}

#sidebar.active {
    left: 0;
}

.nav-toggle {
    position: fixed;
    left: 10px;
    top: 10px;
    z-index: 1001;
    cursor: pointer;
    background: var(--nav-bg);
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: opacity 0.3s;

}

.nav-content {
    padding: 20px;
}

/* 调整现有内容容器 */
.main-content {
    transition: margin-left 0.3s;
    position: relative;
    z-index: 1;
}

/* 导航栏样式优化 */
#sidebar ul {
    list-style: none;
    padding: 0;
}

#sidebar li a {
    color: var(--text-color);
    padding: 8px 0;
    display: block;
    text-decoration: none;
    transition: color 0.2s;
}

#sidebar li a:hover {
    color: #007bff;
}

/* 移动端适配 */
@media (max-width: 768px) {
    body {
        padding-left: 0;
    }

    #sidebar {
        width: 280px;
        left: -280px;
    }

    #sidebar.active {
        box-shadow: 4px 0 15px rgba(0,0,0,0.2);
    }

    .nav-link {
        padding: 16px 25px;
    }

    .nav-toggle {
        left: 5px;
        top: 5px;
        padding: 8px;
    }

    .search-container {
        margin-left: 40px;
        width: calc(100% - 60px);
    }

    #search-input {
        width: 100%;
    }
}

/* 导航栏激活时隐藏按钮 */
#sidebar.active ~ .nav-toggle {
    opacity: 0;
    pointer-events: none;
}

/* 遮罩层点击关闭 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 999;
    transition: opacity 0.3s;
}
#sidebar.active ~ .sidebar-overlay {
    display: block;
}
#sidebar.active + .sidebar-overlay {
    display: block;
}

/* 导航切换按钮优化 */
.nav-toggle:hover {
    transform: scale(1.1);
    background: var(--bg-color);
}

.nav-item::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(0,0,0,0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.nav-item:active::after {
    width: 200px;
    height: 200px;
    opacity: 0;
}

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 添加到你的style.css中 */
#suggestions-list {
    position: absolute;
    width: calc(100% - 2px); /* 对齐输入框宽度 */
    max-height: 300px;
    overflow-y: auto;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    z-index: 1000;
    display: none;
}

#suggestions-list li {
    padding: 8px 12px;
    cursor: pointer;
}

#suggestions-list li:hover {
    background-color: #f5f5f5;
}

.highlight {
    background-color: #fffde8;
    font-weight: bold;
}

.loading, .no-results, .error {
    color: #888;
    font-style: italic;
}

.error {
    color: #ff4d4f;
}

/* 图表加载状态 */
.chart-container.loading {
    position: relative;
    min-height: 300px;
}

.chart-container.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: #1890ff;
    animation: spin 1s ease-in-out infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}