/* ========== 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.stock-flat { color: #8c8c8c; }

:root {
    --primary: #1890ff;
    --primary-dark: #096dd9;
    --success: #52c41a;
    --warning: #faad14;
    --danger: #ff4d4f;
    
    /* 中国股市颜色约定：红涨绿跌 */
    --stock-up: #f5222d;
    --stock-down: #52c41a;
    --stock-flat: #8c8c8c;
    
    --bg-primary: #f0f2f5;
    --bg-card: #ffffff;
    --text-primary: #262626;
    --text-secondary: #8c8c8c;
    --border-color: #e8e8e8;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
}

/* ========== 布局 ========== */
.app-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========== 头部 ========== */
.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 36px;
}

.logo-text h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 0;
}

.logo-text .subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 14px;
}

.divider {
    opacity: 0.5;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #52c41a;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========== 主内容区 ========== */
.main-content {
    flex: 1;
    max-width: 1400px;
    width: 100%;
    margin: 24px auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.main-content::-webkit-scrollbar {
    display: none;
}

/* ========== 卡片样式 ========== */
.section-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    min-width: 0;
}

.section-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ========== 输入区样式 ========== */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.input-group textarea,
.input-group input,
.input-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
}

.input-group textarea:focus,
.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.input-group textarea {
    resize: vertical;
    min-height: 100px;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.flex-1 {
    flex: 1;
}

/* ========== 按钮样式 ========== */
.btn-primary {
    width: 100%;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
    margin-bottom: 16px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-icon {
    font-size: 20px;
}

/* ========== 快速指令 ========== */
.quick-commands {
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.quick-commands p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.quick-commands {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-quick {
    padding: 6px 12px;
    background: #f0f5ff;
    color: var(--primary);
    border: 1px solid #d6e4ff;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-quick:hover {
    background: #e6f7ff;
    border-color: var(--primary);
}

/* ========== 信息卡片 ========== */
.info-card ul {
    list-style: none;
    padding: 0;
}

.info-card li {
    padding: 8px 0;
    font-size: 14px;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.info-card li:last-child {
    border-bottom: none;
}

/* ========== 步骤展示 ========== */
.steps-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #fafafa;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s;
}

.step-item.active {
    background: #e6f7ff;
    border-left: 3px solid var(--primary);
}

.step-item.completed {
    background: #f6ffed;
    border-left: 3px solid var(--success);
}

.step-icon {
    font-size: 18px;
}

/* ========== Tab 切换 ========== */
.tab-container {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.tab-header {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background: #fafafa;
}

.tab-btn {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--primary);
    background: #f0f5ff;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: white;
}

.tab-content {
    display: none;
    padding: 24px;
}

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

/* ========== 结果展示区 ========== */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.result-meta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.result-actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    padding: 6px 12px;
    background: #fafafa;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action:hover {
    background: #f0f5ff;
    border-color: var(--primary);
    color: var(--primary);
}

/* ========== 汇总卡片 ========== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.summary-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

.summary-card:nth-child(2) {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.summary-card:nth-child(3) {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.summary-card .card-value {
    font-size: 28px;
    font-weight: 700;
    margin: 8px 0;
}

.summary-card .card-label {
    font-size: 13px;
    opacity: 0.9;
}

/* ========== 股票表格 ========== */
.stocks-table-container {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.stocks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    table-layout: auto;
}

.stocks-table thead {
    background: #fafafa;
    border-bottom: 2px solid var(--border-color);
}

.stocks-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: normal;
}

.stocks-table td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border-color);
    word-break: break-word;
}

.stocks-table tbody tr:hover {
    background: #fafafa;
}

.stocks-table tbody tr:last-child td {
    border-bottom: none;
}

.empty-row td {
    text-align: center;
    color: var(--text-secondary);
    padding: 48px 16px;
    font-size: 16px;
}

.empty-hint {
    text-align: center;
    color: var(--text-secondary);
    padding: 48px 16px;
    font-size: 16px;
}

/* 股票涨跌颜色 */
.stock-up {
    color: var(--stock-up);
    font-weight: 600;
}

.stock-down {
    color: var(--stock-down);
    font-weight: 600;
}

.stock-flat {
    color: var(--stock-flat);
}

/* 排名徽章 */
.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-weight: 700;
    font-size: 13px;
}

.rank-1 { background: #ffd700; color: #fff; }
.rank-2 { background: #c0c0c0; color: #fff; }
.rank-3 { background: #cd7f32; color: #fff; }
.rank-other { background: #f0f0f0; color: #666; }

/* 活跃度标签 */
.activity-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.activity-high {
    background: #fff1f0;
    color: #f5222d;
}

.activity-medium {
    background: #fff7e6;
    color: #fa8c16;
}

.activity-low {
    background: #f6ffed;
    color: #52c41a;
}

/* 操作按钮 */
.btn-detail {
    padding: 4px 8px;
    background: #f0f5ff;
    color: var(--primary);
    border: 1px solid #d6e4ff;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-detail:hover {
    background: var(--primary);
    color: white;
}

/* ========== 图表容器 ========== */
.chart-container {
    margin-top: 16px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #fafbfc;
    padding: 12px;
    box-sizing: border-box;
}

.chart-container > div {
    width: 100% !important;
    min-height: 360px;
}

.chart-container h3 {
    margin-bottom: 8px;
    font-size: 16px;
    color: var(--text-primary);
}

/* 移除图表 Tab 横向滚动条，图表自适应容器 */
#tab-charts.tab-content {
    overflow-x: hidden;
}

#tab-charts .chart-container {
    min-width: 0;
}

/* ========== 加载动画 ========== */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ========== 弹窗样式 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

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

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

.modal-body {
    padding: 24px;
}

/* 股票详情样式 */
.stock-detail-section {
    margin-bottom: 24px;
}

.stock-detail-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
}

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

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: #fafafa;
    border-radius: 6px;
}

.detail-item .label {
    color: var(--text-secondary);
    font-size: 14px;
}

.detail-item .value {
    font-weight: 600;
    font-size: 14px;
}

/* 个股深度分析报告 */
.analysis-report {
    background: #fafafa;
    border-radius: 10px;
    padding: 16px;
    border-left: 4px solid var(--primary);
}

.analysis-report h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 16px 0 10px 0;
    color: var(--text-primary);
}

.analysis-report h4:first-child {
    margin-top: 0;
}

.analysis-report p {
    font-size: 14px;
    line-height: 1.8;
    color: #434343;
    margin-bottom: 8px;
}

.analysis-report .signal-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 6px;
}

.signal-bullish { background: #fff1f0; color: #cf1322; }
.signal-bearish { background: #f6ffed; color: #389e0d; }
.signal-neutral { background: #f5f5f5; color: #595959; }

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

.metric-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.metric-card .metric-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.metric-card .metric-value {
    font-size: 18px;
    font-weight: 700;
}

.metric-card .metric-unit {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========== 底部 ========== */
.app-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 13px;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.disclaimer {
    color: var(--warning);
    margin-top: 4px;
}

/* ========== 响应式设计 ========== */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .summary-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
    }
    
    .input-row {
        grid-template-columns: 1fr;
    }
    
    .tab-header {
        flex-direction: column;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }

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

    .stocks-table {
        font-size: 12px;
    }

    .stocks-table th,
    .stocks-table td {
        padding: 6px 4px;
    }
}
