/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
}

/* ========== 头部 ========== */
.header {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    height: 60px;
    display: flex;
    align-items: center;
}

.header-content {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.header-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.header-btn {
    padding: 8px 20px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.header-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

/* ========== 主容器（三栏等宽） ========== */
.main-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    max-width: 1080px;
    margin: 20px auto;
    gap: 20px;
    padding-bottom: 40px;
}

/* ========== 栏目基础样式 ========== */
.column {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.column-scroll {
    padding: 20px;
}

.column-input .column-scroll {
    padding-right: 15px;
}

.column-scroll::-webkit-scrollbar {
    width: 6px;
}

.column-scroll::-webkit-scrollbar-track {
    background: #f5f5f5;
}

.column-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.column-scroll::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ========== 左栏：输入区 ========== */
.section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #4285f4;
}

.form-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
}

.form-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-item.full-width {
    grid-column: 1 / -1;
}

.form-item label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.form-item input {
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.2s;
    width: 100%;
    max-width: 100%;
}

.form-item input:focus {
    outline: none;
    border-color: #4285f4;
}

/* ========== 中右栏：结果区 ========== */
.stage-header {
    margin-bottom: 20px;
}

.stage-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    padding-bottom: 10px;
    border-bottom: 2px solid #4285f4;
}

/* 主要结果框 */
.result-box {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    margin-bottom: 20px;
}

.result-box.primary-box {
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border-color: #4285f4;
}

.box-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.box-value {
    font-size: 28px;
    font-weight: 700;
    color: #333;
}

/* 计算流程 */
.calc-flow {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.flow-step {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    background: #fff;
    border-radius: 4px;
}

.flow-step:last-child {
    margin-bottom: 0;
}

.flow-step span:first-child {
    font-size: 13px;
    color: #666;
}

.flow-step span:last-child {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

/* 结果表格 */
.result-table {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}

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

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

.table-row span:first-child {
    font-size: 13px;
    color: #666;
}

.table-row span:last-child {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.table-row.highlight {
    background: #e3f2fd;
}

.table-row.highlight span:last-child {
    color: #1976d2;
}

.table-row.success {
    background: #e8f5e9;
}

.table-row.success span:last-child {
    color: #388e3c;
}

.table-row.total {
    background: #fff3e0;
    font-weight: 600;
}

.table-row.total span:last-child {
    color: #f57c00;
}

/* 利润分析框 */
.profit-box {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
}

.profit-box h3 {
    font-size: 13px;
    font-weight: 600;
    color: #666;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.profit-item:last-child {
    margin-bottom: 0;
}

.profit-item.profit-clickable {
    cursor: pointer;
    transition: background-color 0.2s;
}

.profit-item.profit-clickable:hover {
    background: #f0f0f0;
}

.profit-item.profit-clickable.active {
    background: #e3f2fd;
    border-color: #4285f4;
}

.profit-item span:first-child {
    font-size: 13px;
    color: #666;
}

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

/* 利润颜色 */
.profit-positive {
    color: #2e7d32 !important;
}

.profit-negative {
    color: #c62828 !important;
}

.profit-zero {
    color: #757575 !important;
}

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

.modal-content {
    background-color: #fff;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

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

.close-btn {
    font-size: 28px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.history-item {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: #e3f2fd;
    border-color: #4285f4;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-item-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.history-item-time {
    font-size: 12px;
    color: #999;
}

.history-item-details {
    display: flex;
    gap: 20px;
    font-size: 14px;
    color: #666;
}

.history-item-actions {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

.history-item-btn {
    padding: 4px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item-btn:hover {
    background: #f5f5f5;
}

.history-item-btn.delete {
    color: #c62828;
    border-color: #c62828;
}

.history-item-btn.delete:hover {
    background: #ffebee;
}

.empty-history {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* 确认对话框 */
.confirm-dialog {
    max-width: 500px;
}

.confirm-buttons {
    display: flex;
    gap: 10px;
    padding: 0 20px 20px;
    justify-content: center;
}

.confirm-btn {
    padding: 10px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.confirm-btn.save-and-reset {
    background: #4285f4;
    color: #fff;
}

.confirm-btn.save-and-reset:hover {
    background: #3367d6;
}

.confirm-btn.reset-only {
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
}

.confirm-btn.reset-only:hover {
    background: #f5f5f5;
}

.confirm-btn.cancel {
    background: #fff;
    color: #666;
    border: 1px solid #ddd;
}

.confirm-btn.cancel:hover {
    background: #f5f5f5;
}

/* ========== 响应式 ========== */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }

    .column {
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        height: auto;
    }

    .column-scroll {
        overflow-y: visible;
        height: auto;
    }
}
