* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

.container {
    display: flex;
    height: 100vh;
}

/* 侧边栏样式 */
.sidebar {
    width: 250px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar h1 {
    font-size: 24px;
    margin-bottom: 20px;
    text-align: center;
}

/* 语言切换器 */
.language-switcher {
    display: flex;
    gap: 8px;
    margin-bottom: 25px;
    padding: 0 5px;
}

.lang-btn {
    flex: 1;
    padding: 8px 5px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
    white-space: nowrap;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.lang-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* 货币切换器 */
.currency-selector {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.currency-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.currency-btn {
    flex: 1;
    min-width: 40px;
    padding: 8px 5px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: all 0.3s;
}

.currency-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.currency-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transform: scale(1.1);
}

.sidebar nav ul {
    list-style: none;
}

.sidebar nav li {
    margin-bottom: 10px;
}

.nav-link {
    display: block;
    padding: 12px 15px;
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(5px);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.2);
}

/* 主内容区样式 */
.main-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

.page {
    display: none;
}

.page.active {
    display: block;
}

.page h2 {
    font-size: 28px;
    margin-bottom: 25px;
    color: #333;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.stat-card h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    color: #667eea;
}

.stat-card small {
    color: #888;
    font-size: 12px;
}

/* 表单卡片 */
.form-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 30px;
}

.form-card h3 {
    margin-bottom: 20px;
    color: #333;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* 表单行布局 */
.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

/* 自定义产品输入框动画 */
#customProductGroup,
#customCostProductGroup {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 按钮样式 */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-danger {
    background: #ff4757;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
}

.btn-danger:hover {
    background: #ff3838;
}

/* 表格样式 */
.table-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    overflow-x: auto;
}

.table-card h3 {
    margin-bottom: 15px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: #f8f9fa;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    font-weight: 600;
    color: #555;
}

tbody tr:hover {
    background: #f8f9fa;
}

/* 图表容器 */
.chart-container {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-top: 20px;
}

.chart-container h3 {
    margin-bottom: 15px;
    color: #333;
}

.charts-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

/* 报表筛选 */
.report-filters {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.report-filters label {
    font-weight: 500;
}

.report-filters input {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

/* 成本列表 */
.cost-list {
    margin-top: 20px;
}

.cost-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    margin-bottom: 8px;
}

.cost-item strong {
    color: #667eea;
}

/* 盈亏平衡分析 */
.breakeven-info {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.breakeven-info p {
    margin: 10px 0;
    font-size: 16px;
}

.breakeven-result {
    background: #667eea;
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
    font-size: 18px;
}

.breakeven-result strong {
    font-size: 24px;
    color: #ffd700;
}

/* AI分析选项卡片 */
.ai-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.ai-option-card {
    background: white;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
}

.ai-option-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-option-card:hover h3,
.ai-option-card:hover p {
    color: white;
}

.ai-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.ai-option-card h3 {
    margin: 10px 0;
    color: #333;
}

.ai-option-card p {
    color: #666;
    font-size: 14px;
}

/* AI结果卡片 */
.ai-result-card {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.ai-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.ai-result-header h3 {
    margin: 0;
}

.ai-result-content {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    line-height: 1.8;
}

.ai-result-content h4 {
    color: #667eea;
    margin-top: 20px;
    margin-bottom: 10px;
}

.ai-result-content ul {
    margin-left: 20px;
}

.ai-result-content li {
    margin: 8px 0;
}

.ai-result-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* 加载动画 */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 遮罩层 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        padding: 15px;
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .sidebar h1 {
        font-size: 18px;
        margin-bottom: 10px;
    }
    
    /* 移动端语言切换器 */
    .language-switcher {
        gap: 5px;
        margin-bottom: 10px;
    }
    
    .lang-btn {
        font-size: 11px;
        padding: 6px 4px;
    }
    
    /* 移动端货币切换器 */
    .currency-selector {
        padding: 10px;
        margin-bottom: 15px;
    }
    
    .currency-selector label {
        font-size: 11px !important;
    }
    
    .currency-buttons {
        gap: 4px;
    }
    
    .currency-btn {
        min-width: 35px;
        padding: 6px 3px;
        font-size: 14px;
    }
    
    .sidebar nav ul {
        display: flex;
        overflow-x: auto;
        gap: 10px;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
    }
    
    .sidebar nav li {
        margin-bottom: 0;
        flex-shrink: 0;
    }
    
    .nav-link {
        white-space: nowrap;
        padding: 10px 15px;
        font-size: 14px;
    }
    
    .nav-link:hover {
        transform: none;
    }

    .main-content {
        padding: 15px;
        padding-bottom: 30px;
    }
    
    .page h2 {
        font-size: 24px;
        margin-bottom: 20px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    .stat-value {
        font-size: 28px;
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .ai-options {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .ai-option-card {
        padding: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-card, .table-card {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .form-group input,
    .form-group select {
        font-size: 16px; /* 防止iOS自动缩放 */
    }
    
    .btn {
        width: 100%;
        padding: 12px 20px;
        font-size: 16px;
    }
    
    .btn-danger {
        width: auto;
        padding: 8px 12px;
        font-size: 14px;
    }
    
    /* 表格横向滚动 */
    .table-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        min-width: 600px;
    }
    
    th, td {
        padding: 10px 8px;
        font-size: 14px;
    }
    
    /* AI结果卡片 */
    .ai-result-card {
        width: 95%;
        max-height: 85vh;
    }
    
    .ai-result-header {
        padding: 15px;
    }
    
    .ai-result-content {
        padding: 15px;
        font-size: 15px;
    }
    
    .ai-result-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .ai-result-footer .btn {
        width: 100%;
    }
    
    /* 报表筛选 */
    .report-filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .report-filters input,
    .report-filters button {
        width: 100%;
    }
    
    /* 盈亏平衡分析 */
    .breakeven-info {
        padding: 15px;
    }
    
    .breakeven-info p {
        font-size: 15px;
    }
    
    .breakeven-result {
        font-size: 16px;
        padding: 12px;
    }
    
    .breakeven-result strong {
        font-size: 20px;
    }
    
    /* 成本列表 */
    .cost-item {
        padding: 12px;
        font-size: 15px;
    }
    
    /* Chart容器 */
    .chart-container {
        padding: 15px;
    }
}

/* 小屏手机优化 */
@media (max-width: 480px) {
    .sidebar h1 {
        font-size: 16px;
    }
    
    /* 小屏手机语言按钮 */
    .language-switcher {
        gap: 4px;
        margin-bottom: 8px;
    }
    
    .lang-btn {
        font-size: 10px;
        padding: 5px 3px;
    }
    
    /* 小屏手机货币按钮 */
    .currency-selector {
        padding: 8px;
        margin-bottom: 10px;
    }
    
    .currency-selector label {
        font-size: 10px !important;
    }
    
    .currency-btn {
        min-width: 30px;
        padding: 5px 2px;
        font-size: 13px;
    }
    
    .nav-link {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .stat-card h3 {
        font-size: 13px;
    }
    
    .ai-icon {
        font-size: 36px;
    }
    
    table {
        min-width: 500px;
        font-size: 13px;
    }
}
