/* ====== 基础重置 ====== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #3498db;
    --primary-dark: #2980b9;
    --success-color: #27ae60;
    --success-dark: #219653;
    --danger-color: #e74c3c;
    --danger-dark: #c0392b;
    --warning-color: #f39c12;
    --warning-dark: #e67e22;
    --dark-color: #2c3e50;
    --gray-color: #7f8c8d;
    --light-gray: #ecf0f1;
    --border-color: #ddd;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

/* ====== 容器布局 ====== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* ====== 头部样式 ====== */
.header {
    background: linear-gradient(135deg, var(--dark-color), var(--primary-color));
    color: white;
    padding: 30px;
    text-align: center;
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.header .subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* ====== 主内容区 ====== */
.main-content {
    padding: 30px;
}

/* ====== 上传区域 ====== */
.upload-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.upload-box {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: var(--transition);
    background: var(--light-gray);
    position: relative;
}

.upload-box.drag-over {
    border-color: var(--primary-color);
    background: #e8f4fc;
    border-style: solid;
    transform: translateY(-2px);
}

.upload-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    color: var(--dark-color);
}

.upload-header i {
    font-size: 28px;
    color: var(--primary-color);
}

.upload-header h3 {
    font-size: 1.3rem;
    font-weight: 600;
}

/* 拖拽区域样式 */
.drop-zone {
    border: 2px dashed #aaa;
    border-radius: var(--radius);
    padding: 0;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.7);
    margin-bottom: 15px;
    position: relative;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-zone:hover {
    border-color: var(--primary-color);
    background: rgba(52, 152, 219, 0.1);
}

.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(52, 152, 219, 0.2);
    border-style: solid;
}

.drop-content {
    padding: 40px 20px;
}

.drop-content i {
    font-size: 48px;
    color: var(--primary-color);
    margin-bottom: 15px;
    display: block;
}

.drop-content p {
    margin-bottom: 10px;
    font-weight: 500;
    color: var(--dark-color);
    font-size: 16px;
}

.drop-content small {
    color: var(--gray-color);
    font-size: 14px;
}

.file-input {
    display: none;
}

.file-info {
    margin-top: 15px;
    font-size: 14px;
    padding: 10px;
    border-radius: 4px;
    background: #f8f9fa;
    border-left: 3px solid var(--gray-color);
    min-height: 60px;
    display: flex;
    align-items: center;
}

.file-info.loaded {
    border-left-color: var(--success-color);
    background: #f0f9f4;
}

.file-info.loaded strong {
    color: var(--success-color);
}

/* ====== 配置区域 ====== */
.config-section {
    background: #f8fafc;
    padding: 25px;
    border-radius: var(--radius);
    margin-bottom: 30px;
    border-left: 5px solid var(--primary-color);
}

.config-section h3 {
    color: var(--dark-color);
    margin-bottom: 20px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.config-item {
    margin-bottom: 15px;
}

.config-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

.field-select-wrapper {
    position: relative;
    display: flex;
    gap: 5px;
}

.config-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 15px;
    transition: var(--transition);
    flex: 1;
}

.config-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.field-refresh-btn {
    padding: 12px 15px;
    background: var(--light-gray);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.field-refresh-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.tolerance-input {
    position: relative;
}

.tolerance-unit {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-color);
}

.hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--gray-color);
}

/* ====== 操作按钮区域 ====== */
.action-section {
    margin-bottom: 30px;
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex: 1;
    min-width: 150px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), var(--success-dark));
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), var(--danger-dark));
    color: white;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
    min-width: auto;
}

/* ====== 加载状态 ====== */
.loading {
    display: none;
    text-align: center;
    padding: 30px;
    background: #f8f9fa;
    border-radius: var(--radius);
    margin: 20px 0;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    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); }
}

/* ====== 错误提示 ====== */
.error-message {
    display: none;
    background: linear-gradient(135deg, #fadbd8, #f5b7b1);
    color: var(--danger-dark);
    padding: 15px 20px;
    border-radius: var(--radius);
    border-left: 5px solid var(--danger-color);
    margin: 20px 0;
    font-weight: 500;
}

.error-message.success {
    background: linear-gradient(135deg, #d5f4e6, #a3e9cb);
    color: var(--success-dark);
    border-left-color: var(--success-color);
}

/* ====== 结果区域 ====== */
.result-section {
    display: none;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h3 {
    color: var(--dark-color);
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}

.filter-actions {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.filter-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 8px 16px;
    background: var(--light-gray);
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--dark-color);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.filter-btn:hover {
    background: #e9ecef;
}

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

.filter-btn[data-filter="matched"].active {
    background: var(--success-color);
    border-color: var(--success-color);
}

.filter-btn[data-filter="conflict"].active {
    background: var(--warning-color);
    border-color: var(--warning-color);
}

.filter-btn[data-filter="unmatched"].active {
    background: var(--danger-color);
    border-color: var(--danger-color);
}

/* ====== 统计卡片 ====== */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
    border-top: 5px solid;
    cursor: default;
}

.card.clickable {
    cursor: pointer;
}

.card.clickable:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
}

.card-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.card-total {
    border-color: var(--primary-color);
}
.card-total .card-icon {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.card-matched {
    border-color: var(--success-color);
}
.card-matched .card-icon {
    background: linear-gradient(135deg, var(--success-color), var(--success-dark));
}

.card-unmatched {
    border-color: var(--danger-color);
}
.card-unmatched .card-icon {
    background: linear-gradient(135deg, var(--danger-color), var(--danger-dark));
}

.card-conflict {
    border-color: var(--warning-color);
}
.card-conflict .card-icon {
    background: linear-gradient(135deg, var(--warning-color), var(--warning-dark));
}

.card-content {
    flex: 1;
}

.card-number {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.card-label {
    font-size: 14px;
    color: var(--gray-color);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ====== 结果表格 ====== */
.result-table-container {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 30px;
}

.table-header {
    background: var(--dark-color);
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.table-title {
    font-size: 1.2rem;
    font-weight: 600;
}

#currentFilterText {
    color: #ffd700;
    font-weight: bold;
}

.table-stats {
    font-size: 14px;
    opacity: 0.9;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1000px;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    background: var(--dark-color);
    color: white;
    padding: 16px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--primary-color);
    white-space: nowrap;
}

td {
    padding: 14px 12px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
    vertical-align: top;
}

tbody tr:hover {
    background: #f8f9fa;
}

/* 状态标签 */
.status {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    min-width: 80px;
}

.status-matched {
    background: #d5f4e6;
    color: var(--success-color);
    border: 1px solid #a3e9cb;
}

.status-unmatched {
    background: #fadbd8;
    color: var(--danger-color);
    border: 1px solid #f5b7b1;
}

.status-conflict {
    background: #fef5e7;
    color: var(--warning-color);
    border: 1px solid #fad9a1;
}

/* 金额样式 */
.amount {
    text-align: right;
    font-family: 'Consolas', 'Monaco', monospace;
    font-weight: 600;
}

.amount-positive {
    color: var(--success-color);
}

.amount-negative {
    color: var(--danger-color);
}

.amount-zero {
    color: var(--gray-color);
}

/* 行信息样式 */
.row-info {
    font-size: 12px;
    color: var(--gray-color);
    line-height: 1.4;
}

.row-info div {
    margin-bottom: 2px;
}

.row-info .missing {
    color: #ccc;
    font-style: italic;
}

/* 表格页脚 */
.table-footer {
    padding: 15px 20px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.pagination-info {
    font-size: 14px;
    color: var(--gray-color);
}

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

.pagination-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

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

#pageInfo {
    font-size: 14px;
    color: var(--dark-color);
}

/* ====== 分页大小选择器 ====== */
.page-size-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    margin-left: 10px;
}

.page-size-select:hover {
    border-color: var(--primary-color);
}

.page-size-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

/* ====== 空状态 ====== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-color);
}

.empty-icon {
    font-size: 80px;
    color: #ddd;
    margin-bottom: 20px;
}

.empty-state h4 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: var(--dark-color);
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 30px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.empty-tips {
    background: #f8f9fa;
    padding: 20px;
    border-radius: var(--radius);
    max-width: 600px;
    margin: 0 auto;
    text-align: left;
}

.tip {
    display: flex;
    gap: 10px;
}

.tip i {
    color: var(--warning-color);
    margin-top: 3px;
    flex-shrink: 0;
}

.tip ul {
    margin-top: 10px;
    margin-left: 20px;
    color: var(--dark-color);
}

.tip li {
    margin-bottom: 5px;
}

/* ====== 页脚 ====== */
.footer {
    background: var(--dark-color);
    color: white;
    text-align: center;
    padding: 20px;
    font-size: 14px;
    opacity: 0.8;
}

/* ====== 响应式设计 ====== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .header {
        padding: 20px;
    }
    
    .header h1 {
        font-size: 1.8rem;
        flex-direction: column;
        gap: 10px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    .upload-section {
        grid-template-columns: 1fr;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .filter-buttons {
        width: 100%;
        justify-content: center;
    }
    
    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .card {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 20px;
    }
    
    .card-number {
        font-size: 2rem;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .table-footer {
        flex-direction: column;
        text-align: center;
    }
    
    .drop-zone {
        min-height: 150px;
    }
    
    .drop-content {
        padding: 30px 15px;
    }
    
    .drop-content i {
        font-size: 36px;
    }
    
    .drop-content p {
        font-size: 14px;
    }
    
    .drop-content small {
        font-size: 12px;
    }
}