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

body {
    font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* ── 头部 ── */
.app-header {
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 100%);
    color: #fff;
    padding: 28px 40px;
    text-align: center;
}
.app-header h1 { font-size: 24px; font-weight: 700; }
.app-header .subtitle { font-size: 13px; color: #aab; margin-top: 6px; }

/* ── Tab 导航 ── */
.tab-bar {
    display: flex;
    justify-content: center;
    gap: 4px;
    background: #fff;
    border-bottom: 1px solid #e8e8e8;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.tab-btn {
    padding: 14px 28px;
    border: none;
    background: none;
    font-size: 15px;
    cursor: pointer;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}
.tab-btn:hover { color: #1a1f3a; }
.tab-btn.active {
    color: #1a1f3a;
    font-weight: 600;
    border-bottom-color: #4a90d9;
}

/* ── 主体 ── */
.app-main { max-width: 1100px; margin: 0 auto; padding: 28px 20px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── 面板头 ── */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.panel-header h2 { font-size: 20px; color: #1a1f3a; }

/* ── 步骤 ── */
.step { margin-bottom: 32px; }
.step h3 { font-size: 16px; color: #1a1f3a; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid #4a90d9; }
.hidden { display: none !important; }

/* ── 步骤指示器 ── */
.stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 28px;
    padding: 20px 0;
}
.stepper-step {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: default;
}
.stepper-step.clickable { cursor: pointer; }
.stepper-step.clickable:hover .stepper-num { transform: scale(1.1); }
.stepper-num {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.25s;
    background: #e8e8e8;
    color: #999;
}
.stepper-step.active .stepper-num {
    background: #4a90d9;
    color: #fff;
    box-shadow: 0 2px 8px rgba(74,144,217,0.3);
}
.stepper-step.done .stepper-num {
    background: #52c41a;
    color: #fff;
}
.stepper-label {
    font-size: 14px;
    color: #aaa;
    font-weight: 500;
}
.stepper-step.active .stepper-label {
    color: #1a1f3a;
    font-weight: 600;
}
.stepper-step.done .stepper-label {
    color: #52c41a;
}
.stepper-line {
    width: 60px;
    height: 2px;
    background: #e8e8e8;
    margin: 0 12px;
    transition: background 0.3s;
}
.stepper-line.done { background: #52c41a; }

/* ── 卡片网格 ── */
.card-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    border: 2px solid transparent;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: all 0.2s;
}
.card:hover { border-color: #4a90d9; box-shadow: 0 4px 12px rgba(74,144,217,0.12); }
.card.selected { border-color: #4a90d9; background: #f5f9ff; }
.card.preset .card-badge { display: inline-block; background: #e6f7ff; color: #1890ff; font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-bottom: 8px; }
.card.custom .card-badge { display: inline-block; background: #f6ffed; color: #52c41a; font-size: 11px; padding: 2px 8px; border-radius: 10px; margin-bottom: 8px; }
.card-name { font-size: 16px; font-weight: 600; color: #1a1f3a; margin-bottom: 4px; }
.card-desc { font-size: 13px; color: #888; }
.card-actions { margin-top: 12px; display: flex; gap: 8px; }

/* ── 按钮 ── */
.btn {
    padding: 9px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: #4a90d9; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #3a7bc8; }
.btn-success { background: #52c41a; color: #fff; }
.btn-success:hover { background: #45a818; }
.btn-outline { background: #fff; color: #555; border: 1px solid #d9d9d9; }
.btn-outline:hover { border-color: #4a90d9; color: #4a90d9; }
.btn-outline.active { border-color: #4a90d9; color: #4a90d9; background: #f0f7ff; }
.btn-danger { background: #fff; color: #e74c3c; border: 1px solid #e74c3c; }
.btn-danger:hover { background: #fff1f0; }
.btn-sm { padding: 5px 14px; font-size: 12px; }

/* ── 表单 ── */
.input-mode-bar { display: flex; gap: 12px; margin-bottom: 20px; }

.form-area { margin-bottom: 16px; }
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}
.form-group textarea, .form-group input, .input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s;
}
.form-group textarea:focus, .form-group input:focus, .input:focus {
    border-color: #4a90d9;
    outline: none;
    box-shadow: 0 0 0 2px rgba(74,144,217,0.12);
}
.form-group textarea { min-height: 80px; }

.form-row-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.form-row-inline label { font-size: 14px; font-weight: 600; color: #555; white-space: nowrap; min-width: 80px; }
.form-row-inline .input { width: auto; flex: 1; }

/* ── CSV 上传 ── */
.csv-actions { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.upload-area { display: flex; align-items: center; gap: 10px; }
.upload-area input[type="file"] { display: none; }
#csv-status { font-size: 13px; color: #52c41a; }

/* ── 预览 ── */
.preview-container { background: #fff; border-radius: 10px; padding: 32px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); margin-bottom: 20px; max-height: 60vh; overflow-y: auto; }
.preview-section { margin-bottom: 24px; }
.preview-section h4 { font-size: 16px; color: #1a1f3a; border-bottom: 1px solid #f0f0f0; padding-bottom: 8px; margin-bottom: 12px; }
.preview-section textarea { width: 100%; min-height: 100px; padding: 12px; border: 1px solid #e8e8e8; border-radius: 6px; font-size: 14px; font-family: inherit; line-height: 1.8; resize: vertical; }
.preview-section textarea:focus { border-color: #4a90d9; outline: none; }

.preview-actions { display: flex; gap: 12px; justify-content: center; margin-top: 20px; }

/* ── 历史表格 ── */
.history-table-wrap { overflow-x: auto; }
.history-table { width: 100%; background: #fff; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); border-collapse: collapse; }
.history-table th { background: #fafafa; padding: 12px 14px; text-align: left; font-weight: 600; font-size: 13px; color: #666; border-bottom: 2px solid #f0f0f0; }
.history-table td { padding: 12px 14px; border-bottom: 1px solid #f5f5f5; font-size: 14px; }
.history-table tr:hover td { background: #fafbff; }
.history-table .td-actions { display: flex; gap: 6px; }
.history-table input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }

/* ── 对比栏 ── */
.compare-bar {
    background: #fffbe6;
    border: 1px solid #ffe58f;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
}

/* ── 模态框 ── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.45); }
.modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal-content.modal-wide { max-width: 1100px; }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 1px solid #f0f0f0;
}
.modal-header h3 { font-size: 17px; color: #1a1f3a; }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 24px; border-top: 1px solid #f0f0f0; display: flex; gap: 10px; justify-content: flex-end; }
.btn-close { background: none; border: none; font-size: 20px; cursor: pointer; color: #aaa; padding: 4px 8px; }
.btn-close:hover { color: #333; }

/* ── 模板编辑器 ── */
.tpl-section-block {
    background: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 14px;
}
.tpl-section-block .form-group { margin-bottom: 12px; }
.tpl-section-block .form-group:last-child { margin-bottom: 0; }
.tpl-section-block .form-group textarea { min-height: 160px; }
.form-group label .hint { font-weight: 400; font-size: 12px; color: #aaa; }
.form-group label .hint code { background: #f0f0f0; padding: 1px 5px; border-radius: 3px; font-size: 11px; }

/* ── 模板编辑器模态框更大 ── */
#tpl-editor-modal .modal-content { max-width: 1000px; width: 95%; }

/* ── 对比视图 ── */
.compare-body { display: flex; gap: 20px; }
.compare-col { flex: 1; min-width: 0; }
.compare-col h4 { font-size: 15px; color: #1a1f3a; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid #f0f0f0; }
.compare-section { margin-bottom: 20px; padding: 14px; border-radius: 8px; }
.compare-section.same { background: #f8f9fa; }
.compare-section.modified { background: #fffbe6; border: 1px solid #ffe58f; }
.compare-section.added { background: #f6ffed; border: 1px solid #b7eb8f; }
.compare-section.removed { background: #fff1f0; border: 1px solid #ffa39e; }
.compare-section h5 { font-size: 14px; margin-bottom: 8px; }

.diff-line { padding: 2px 6px; font-size: 13px; font-family: "Consolas", "Courier New", monospace; border-radius: 3px; margin: 1px 0; white-space: pre-wrap; }
.diff-line.same { color: #666; }
.diff-line.removed { color: #e74c3c; background: #fff1f0; text-decoration: line-through; }
.diff-line.added { color: #52c41a; background: #f6ffed; }

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1f3a;
    color: #fff;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 300;
    transition: opacity 0.3s;
}
.toast.success { background: #52c41a; }
.toast.error { background: #e74c3c; }

/* ── 响应式 ── */
@media (max-width: 768px) {
    .tab-bar { flex-direction: column; }
    .tab-btn { padding: 10px; }
    .card-grid { grid-template-columns: 1fr; }
    .compare-body { flex-direction: column; }
}
