* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 登录对话框样式 */
.modal {
    display: block; /* 默认显示 */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 0;
    border: 1px solid #888;
    width: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    overflow: hidden;
}

.modal-header {
    padding: 20px 25px;
    background-color: #2c3e50;
    color: white;
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.modal-body {
    padding: 25px;
}

.modal-body p {
    margin-bottom: 15px;
    color: #666;
}

.modal-footer {
    padding: 15px 25px;
    background-color: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    border-top: 1px solid #e9ecef;
}

.modal-footer button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s;
}

#login-btn {
    background-color: #2196f3;
    color: white;
}

#login-btn:hover {
    background-color: #1976d2;
}

#cancel-login-btn {
    background-color: #6c757d;
    color: white;
}

#cancel-login-btn:hover {
    background-color: #545b62;
}

#token {
    border: 1px solid #ced4da;
    border-radius: 4px;
    resize: vertical;
    font-size: 14px;
    min-height: 80px;
    margin-bottom: 0;
}

.form-group {
    margin-bottom: 0;
}

#login-error {
    display: none;
    margin: 5px 0;
    color: #dc3545;
    font-size: 14px;
}

#token:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.25);
}

.error-message {
    color: #dc3545;
    margin-top: 10px;
    font-size: 14px;
    min-height: 20px;
}

/* 加载遮罩样式 */
.loading-overlay {
    display: none; /* 默认隐藏 */
    position: fixed;
    z-index: 1100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255,255,255,0.8);
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.loading-spinner {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #2196f3;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-message {
    color: #666;
    font-size: 16px;
}

/* 主内容样式 */
.container {
    display: none; /* 初始隐藏 */
    margin: 0 auto;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

header {
    background-color: #2c3e50;
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    position: relative;
}

/* 让标题在整个 header 宽度中居中 */
header h1 {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

.site-logo {
    height: 32px;
    width: auto;
    display: block;
}

main {
    display: flex;
    gap: 20px;
    width: 100%;
    height: auto; /* 修改为自适应高度 */
    /* 移除flex-wrap: wrap，确保容器始终并排显示 */
}

/* 容器布局样式 */
.stock-list-container {
    flex: 1 2 20%; /* 增加收缩因子，确保能更小 */
    display: flex;
    flex-direction: column;
    height: auto; /* 修改为自适应高度 */
    min-width: 120px; /* 进一步减小最小宽度 */
    max-width: 25%; /* 最多占25%空间 */
    background-color: white;
    border-radius: 8px;
    padding: 10px; /* 进一步减小内边距 */
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.stock-details-container {
    flex: 4 1 80%; /* 保持4/5比例 */
    display: flex;
    flex-direction: column;
    height: auto; /* 修改为自适应高度 */
    min-width: 280px; /* 适当调整最小宽度 */
    max-width: 80%; /* 确保最大宽度为80% */
}

.section-header {
    margin-bottom: 10px;
}

.section-header h2 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #2c3e50;
}

.search-bar input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 5px; /* 减小与股票列表之间的间距 */
}

/* 交易总览样式 */
.overview-section {
    margin-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
}

.overview-item {
    padding: 12px 15px;
    background-color: #e3f2fd;
    color: #2196f3;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s;
}

.overview-item:hover {
    background-color: #bbdefb;
}

.overview-item.active {
    background-color: #2196f3;
    color: white;
}

/* 操作按钮组样式 */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.action-buttons .overview-item {
    flex: 1; /* 让按钮等分空间 */
}

.action-buttons .overview-item:hover {
    background-color: #bbdefb;
}

/* 输入与发送行样式 */
.action-input {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.action-input input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.action-input #action-send.overview-item {
    flex: 0 0 auto;
    min-width: 80px;
}

/* 输入框与下拉按钮组合容器 */
.input-dropdown-wrapper {
    position: relative;
    width: 100%;
    display: flex;
    align-items: stretch;
}

/* 下拉按钮样式 */
.dropdown-btn {
    width: 40px;
    padding: 0;
    border: 1px solid #ddd;
    border-left: none;
    background-color: #f8f9fa;
    color: #666;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 6px 6px 0;
    transition: all 0.2s ease;
    font-size: 12px;
}

.dropdown-btn:hover {
    background-color: #e9ecef;
    color: #495057;
}

.dropdown-btn:active {
    background-color: #dee2e6;
}

/* 下拉菜单样式 */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    width: 100%;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: none;
    overflow: hidden;
}

/* 下拉菜单项样式 */
.dropdown-item {
    padding: 12px 15px;
    color: #495057;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14px;
}

.dropdown-item:hover {
    background-color: #e3f2fd;
    color: #1976d2;
}

/* 输入框样式调整 */
.input-dropdown-wrapper input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px 0 0 6px;
    font-size: 14px;
    border-right: none;
}

.input-dropdown-wrapper input:focus {
    outline: none;
    border-color: #2196f3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.25);
}

/* 聚焦时下拉按钮边框颜色同步 */
.input-dropdown-wrapper input:focus + .dropdown-btn {
    border-color: #2196f3;
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.25);
}

/* 全撤按钮特殊颜色 */
#btn-cancel-all {
    background-color: #ffebee;
    color: #d32f2f;
}

#btn-cancel-all:hover {
    background-color: #ffcdd2;
}

/* 全平按钮特殊颜色 */
#btn-close-all {
    background-color: #e8f5e8;
    color: #388e3c;
}

#btn-close-all:hover {
    background-color: #c8e6c9;
}

/* 暂停开仓按钮颜色 */
#btn-pause-open {
    background-color: #fff3e0;
    color: #ef6c00;
}
#btn-pause-open:hover {
    background-color: #ffe0b2;
}

/* 暂停交易按钮颜色 */
#btn-pause-trade {
    background-color: #ede7f6;
    color: #5e35b1;
}
#btn-pause-trade:hover {
    background-color: #d1c4e9;
}

/* 暂停态样式（按钮切换时加深提示） */
.overview-item.paused {
    filter: saturate(1.2) brightness(0.95);
}

/* 调整股票列表与搜索框的间距 */
.stock-list {
    flex: none; /* 移除自动填充空间，改为自适应内容 */
    overflow-y: visible; /* 移除滚动条，让内容自然展开 */
    margin-top: 0; /* 保持与搜索框的间距 */
}

.stock-item {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s;
}

.stock-item:hover {
    background-color: #f8f9fa;
}

.stock-item.selected {
    background-color: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.stock-item-info {
    flex: 1;
}

.stock-item-name {
    font-size: 16px;
    font-weight: bold;
    color: #2c3e50;
}

.stock-item-code {
    font-size: 14px;
    color: #666;
}

.stock-item-price {
    text-align: right;
}

.price-value {
    font-size: 16px;
    font-weight: bold;
}

.price-up {
    color: #e74c3c;
}

.price-down {
    color: #2ecc71;
}

.price-change {
    font-size: 14px;
    margin-left: 5px;
}

/* 右侧股票详情样式 */
.stock-details-container {
    flex: 2;
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    height: 100%; /* 继承main的高度 */
}

.stock-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eee;
}

.stock-header h2 {
    font-size: 24px;
    color: #2c3e50;
    margin: 0;
}

.stock-price {
    display: flex;
    align-items: center;
    gap: 10px;
}

#stock-current-price {
    font-size: 28px;
    font-weight: bold;
}

/* 图表容器样式 */
.chart-container {
    position: relative;
    height: 400px;
    margin-bottom: 20px;
}

.chart-controls {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 5px;
    z-index: 10;
}

.chart-type-btn {
    padding: 6px 12px;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-type-btn:hover {
    background-color: #f8f9fa;
}

.chart-type-btn.active {
    background-color: #2196f3;
    color: white;
    border-color: #2196f3;
    box-shadow: 0 2px 5px rgba(33, 150, 243, 0.3);
}

/* 委托下单表单样式 */
.order-form {
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.order-form h3 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.order-type {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.order-type-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    background-color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.order-type-btn.active {
    background-color: #2196f3;
    color: white;
    border-color: #2196f3;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    color: #666;
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.quick-amounts {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.quick-amount-btn {
    flex: 1;
    padding: 8px;
    background-color: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.quick-amount-btn:hover {
    background-color: #f0f0f0;
}

.submit-order-btn {
    width: 100%;
    padding: 12px;
    background-color: #2196f3;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.submit-order-btn:hover {
    background-color: #1976d2;
}

/* 委托和成交列表的并列布局容器 */
.lists-container {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    width: 100%;
}

/* 委托列表样式 - 移除固定高度和滚动条，改为自适应内容 */
.orders-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 0;
}

/* 移除订单项容器的滚动功能 */
.orders-list {
    flex: none;
    overflow-y: visible;
    min-height: auto;
}

.orders-container h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
}

.orders-list {
    flex: none;
    overflow-y: visible;
}

.order-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.order-item-info {
    flex: 1;
}

.order-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 10px;
}

.order-buy {
    background-color: #e3f2fd;
    color: #1976d2;
}

.order-sell {
    background-color: #ffebee;
    color: #d32f2f;
}

.order-price, .order-quantity, .order-status {
    font-size: 14px;
    color: #666;
    margin-right: 15px;
}

.cancel-order-btn {
    padding: 5px 10px;
    background-color: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.cancel-order-btn:hover {
    background-color: #d32f2f;
}

/* 成交列表样式 - 移除固定高度和滚动条，改为自适应内容 */
.trades-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 0;
}

.trades-container h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
}

.trades-list {
    flex: none;
    overflow-y: visible;
    min-height: auto;
}

.trade-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.trade-item-info {
    flex: 1;
}

.trade-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-right: 10px;
}

.trade-buy {
    background-color: #e3f2fd;
    color: #1976d2;
}

.trade-sell {
    background-color: #ffebee;
    color: #d32f2f;
}

.trade-price, .trade-quantity, .trade-time {
    font-size: 14px;
    color: #666;
    margin-right: 15px;
}

/* 交易标记样式 */
.chart-container {
    position: relative;
    height: 400px;
    margin-bottom: 20px;
}
