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

body {
    font-family: 'Microsoft YaHei', sans-serif;
    background: #f5f5f5;
}

.container {
    display: flex;
    height: 100vh;
    padding-bottom: 35px;
}

/* 左侧股票列表 */
.stock-list {
    width: 400px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    transition: width 0.3s;
    position: relative;
    flex-shrink: 0;
}

.stock-list.collapsed {
    width: 0;
    overflow: hidden;
    border-right: none;
}

.stock-list.collapsed .search-box,
.stock-list.collapsed .list-header,
.stock-list.collapsed .list-container,
.stock-list.collapsed .pagination {
    display: none;
}

/* 收缩按钮 */
.toggle-btn {
    position: fixed;
    left: 400px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 60px;
    background: #1890ff;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    color: #fff;
    font-size: 12px;
    transition: left 0.3s;
}

.toggle-btn:hover {
    background: #40a9ff;
}

.stock-list.collapsed~.kline-area .toggle-btn,
.collapsed+.kline-area~.toggle-btn {
    left: 0;
}

.toggle-btn::after {
    content: '◀';
}

.toggle-btn.collapsed::after {
    content: '▶';
}

.search-box {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.search-box input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: #1890ff;
}

.search-box select {
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    min-width: 120px;
    cursor: pointer;
}

.search-box select:focus {
    outline: none;
    border-color: #1890ff;
}

.list-header {
    display: grid;
    grid-template-columns: 100px 80px 1fr 80px;
    padding: 10px 15px;
    background: #fafafa;
    font-weight: bold;
    font-size: 13px;
    color: #666;
    border-bottom: 1px solid #e0e0e0;
}

.list-container {
    flex: 1;
    overflow-y: auto;
}

.stock-item {
    display: grid;
    grid-template-columns: 100px 80px 1fr 80px;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.stock-item:hover {
    background: #e6f7ff;
}

.stock-item.active {
    background: #bae7ff;
}

.stock-item .name {
    color: #333;
    font-weight: 500;
}

.stock-item .code {
    color: #999;
}

.stock-item .industry {
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pagination {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.pagination button {
    padding: 6px 15px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
}

.pagination button:hover:not(:disabled) {
    border-color: #1890ff;
    color: #1890ff;
}

.pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.pagination span {
    color: #666;
    font-size: 13px;
}

.jump-box {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #666;
}

.jump-box input {
    width: 50px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: center;
    font-size: 13px;
    line-height: 1.4;
    -moz-appearance: textfield;
}

.jump-box input::-webkit-outer-spin-button,
.jump-box input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.jump-btn {
    padding: 6px 12px !important;
}

/* 右侧K线图 */
.kline-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.kline-header {
    padding: 15px 20px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kline-header .title-section h2 {
    font-size: 18px;
    color: #333;
}

.kline-header .stock-info {
    margin-top: 5px;
    font-size: 13px;
    color: #999;
}

.time-range {
    display: flex;
    gap: 8px;
}

.time-range button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.time-range button:hover {
    border-color: #1890ff;
    color: #1890ff;
}

.time-range button.active {
    background: #1890ff;
    color: #fff;
    border-color: #1890ff;
}

/* 股票基本信息 */
.stock-detail {
    padding: 15px 20px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
    display: none;
}

.stock-detail.show {
    display: block;
}

.stock-detail .detail-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.stock-detail .detail-item {
    font-size: 13px;
}

.stock-detail .detail-item .label {
    color: #999;
    margin-right: 5px;
}

.stock-detail .detail-item .value {
    color: #333;
}

#kline-chart {
    flex: 1;
    background: #fff;
}

.no-data {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #999;
    font-size: 16px;
    background: #fff;
}

/* 模态框样式 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 8px;
    width: 600px;
    max-width: 90%;
    max-height: 80%;
    overflow: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    color: #333;
    margin: 0;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 20px;
}

.modal-section {
    margin-bottom: 20px;
}

.modal-section:last-child {
    margin-bottom: 0;
}

.modal-section h4 {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.modal-item {
    display: flex;
    font-size: 14px;
}

.modal-item .label {
    color: #999;
    width: 80px;
    flex-shrink: 0;
}

.modal-item .value {
    color: #333;
    font-weight: 500;
}

.modal-item .value.up {
    color: #ef5350;
}

.modal-item .value.down {
    color: #26a69a;
}

/* 详情按钮 */
.detail-btn {
    padding: 6px 12px;
    border: 1px solid #1890ff;
    background: #fff;
    color: #1890ff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    margin-left: 10px;
}

.detail-btn:hover {
    background: #1890ff;
    color: #fff;
}

.detail-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.detail-btn.active {
    background: #1890ff;
    color: #fff;
    border-color: #1890ff;
}

.watchlist-row {
    display: grid;
    grid-template-columns: 130px 100px 1fr 70px 132px;
    gap: 10px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
}

.watchlist-row:last-child {
    border-bottom: none;
}

.watchlist-row .code {
    color: #999;
}

.watchlist-row .name {
    color: #333;
    font-weight: 500;
}

.watchlist-row .industry {
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.watchlist-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.watchlist-row button {
    padding: 5px 10px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.watchlist-row button:hover {
    border-color: #1890ff;
    color: #1890ff;
}

.watchlist-empty {
    padding: 40px 0;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.rank-modal {
    width: 1080px;
    max-width: 96%;
}

.rank-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.rank-tabs {
    display: inline-flex;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.rank-tab {
    padding: 7px 13px;
    border: none;
    border-right: 1px solid #e0e0e0;
    background: #fff;
    color: #666;
    cursor: pointer;
    font-size: 13px;
}

.rank-tab:last-child {
    border-right: none;
}

.rank-tab.active {
    background: #1890ff;
    color: #fff;
}

.rank-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.rank-actions input,
.rank-actions select {
    height: 32px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
}

.rank-actions input:focus,
.rank-actions select:focus {
    border-color: #1890ff;
}

.rank-primary-btn {
    height: 32px;
    padding: 0 12px;
    background: #1890ff;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.rank-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.rank-stat {
    border: 1px solid #f0f0f0;
    border-radius: 6px;
    padding: 10px 12px;
    background: #fafafa;
}

.rank-stat .label {
    color: #999;
    font-size: 12px;
    margin-bottom: 6px;
}

.rank-stat .value {
    color: #333;
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
}

.rank-stat .value.up {
    color: #ef5350;
}

.rank-stat .value.down {
    color: #26a69a;
}

.rank-stat .sub {
    margin-top: 6px;
    color: #999;
    font-size: 12px;
}

.rank-table-wrap {
    max-height: 520px;
    overflow: auto;
    border: 1px solid #f0f0f0;
    border-radius: 6px;
}

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

.rank-table thead {
    position: sticky;
    top: 0;
    background: #fafafa;
    z-index: 1;
}

.rank-table th {
    padding: 10px;
    border-bottom: 2px solid #e0e0e0;
    color: #666;
    font-weight: 600;
    white-space: nowrap;
}

.rank-table th.sortable {
    cursor: pointer;
    user-select: none;
}

.rank-table th.sorted {
    color: #1890ff;
}

.rank-table td {
    padding: 9px 10px;
    border-bottom: 1px solid #f0f0f0;
    white-space: nowrap;
}

.rank-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.rank-table tbody tr:hover {
    background: #f5fbff;
}

.rank-badge {
    display: inline-flex;
    min-width: 42px;
    justify-content: center;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.rank-badge.up {
    color: #ef5350;
    background: #fff1f0;
}

.rank-badge.down {
    color: #26a69a;
    background: #e8f7f2;
}

.rank-empty {
    text-align: center;
    padding: 42px 10px;
    color: #999;
}

@media (max-width: 900px) {
    .rank-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .rank-modal {
        max-height: 88%;
    }
}

/* AI分析按钮 */
.detail-btn.ai-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-color: transparent;
}

.detail-btn.ai-btn:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4192 100%);
}

.detail-btn.ai-btn:disabled {
    background: linear-gradient(135deg, #b0b0b0 0%, #999 100%);
    opacity: 0.6;
}

/* 聊天模态框 */
.chat-modal {
    width: 700px;
    max-width: 94%;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 520px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-message {
    display: flex;
    gap: 10px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-message.assistant {
    align-self: flex-start;
}

.chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-message.user .chat-avatar {
    background: #1890ff;
    color: #fff;
}

.chat-message.assistant .chat-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.7;
    word-break: break-word;
}

.chat-message.user .chat-bubble {
    background: #1890ff;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message.assistant .chat-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chat-bubble p {
    margin: 0 0 8px 0;
}

.chat-bubble p:last-child {
    margin-bottom: 0;
}

.chat-bubble ul, .chat-bubble ol {
    margin: 6px 0;
    padding-left: 18px;
}

.chat-bubble li {
    margin: 3px 0;
}

.chat-bubble strong {
    font-weight: 600;
}

.chat-typing {
    align-self: flex-start;
    padding: 10px 14px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    color: #999;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-typing .dots {
    display: flex;
    gap: 4px;
}

.chat-typing .dots span {
    width: 6px;
    height: 6px;
    background: #bbb;
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.chat-typing .dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing .dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.6); }
    40% { transform: scale(1); }
}

.chat-input-area {
    display: flex;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
    margin-top: 12px;
}

.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
}

.chat-input-area input:focus {
    border-color: #1890ff;
}

.chat-input-area button {
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.chat-input-area button:hover {
    opacity: 0.9;
}

.chat-input-area button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chat-quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 0 0 0;
}

.chat-quick-q {
    padding: 5px 12px;
    background: #f5f5f5;
    border: 1px solid #e8e8e8;
    border-radius: 14px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-quick-q:hover {
    background: #e6f7ff;
    border-color: #1890ff;
    color: #1890ff;
}

.chat-welcome {
    text-align: center;
    color: #999;
    padding: 30px 20px;
    font-size: 13px;
    line-height: 1.8;
}

.ai-insight-panel {
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.ai-insight-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
    margin-bottom: 10px;
    color: #333;
    font-size: 13px;
}

.ai-insight-date {
    color: #999;
    font-size: 12px;
    white-space: nowrap;
}

.ai-insight-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.ai-insight-card {
    min-height: 68px;
    padding: 8px;
    background: #f8fafc;
    border: 1px solid #eef1f5;
    border-radius: 6px;
}

.ai-insight-card .label {
    color: #8a8f98;
    font-size: 12px;
    margin-bottom: 4px;
}

.ai-insight-card .value {
    color: #20242a;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.25;
}

.ai-insight-card .sub {
    color: #8a8f98;
    font-size: 12px;
    margin-top: 3px;
    line-height: 1.35;
}

.ai-insight-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.ai-insight-tag {
    padding: 4px 8px;
    border-radius: 12px;
    background: #f5f7fa;
    border: 1px solid #e7eaf0;
    color: #5c6370;
    font-size: 12px;
}

.ai-insight-tag.risk {
    color: #b54708;
    background: #fff7ed;
    border-color: #fed7aa;
}

.ai-insight-loading {
    color: #999;
    font-size: 13px;
    padding: 12px;
    text-align: center;
}

@media (max-width: 700px) {
    .ai-insight-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ai-insight-header {
        flex-direction: column;
    }
}
