/* ==================== 全局变量 ==================== */
:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d28;
  --bg-tertiary: #252836;
  --bg-hover: #2d3142;
  --text-primary: #e4e6eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #4f7cff;
  --accent-hover: #3a63d9;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --border: #2d3142;
  --radius: 8px;
  --shadow: 0 4px 12px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* ==================== 导航栏 ==================== */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-brand { display: flex; align-items: center; gap: 8px; }
.nav-logo { font-size: 22px; }
.nav-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.nav-links { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 14px;
  transition: all 0.2s;
}
.nav-link:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-link.active { background: var(--accent); color: #fff; }

/* 演示模式横幅 */
.demo-banner {
  background: var(--warning);
  color: #1a1d28;
  padding: 8px 20px;
  text-align: center;
  font-size: 13px;
  font-weight: 500;
}

/* ==================== 容器 ==================== */
.container { max-width: 960px; margin: 0 auto; padding: 24px 20px; }
.page { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
h2 { font-size: 22px; margin-bottom: 20px; }
h3 { font-size: 16px; margin-bottom: 12px; }

/* ==================== 卡片 ==================== */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.card-header h3 { margin: 0; }

/* ==================== 表单元素 ==================== */
.input, .select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus, .select:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

/* ==================== 按钮 ==================== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); }
.btn-danger { background: var(--error); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-row { display: flex; gap: 8px; margin: 8px 0; }

/* ==================== 步骤 ==================== */
.step { margin-bottom: 20px; }
.step-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ==================== 子表列表 ==================== */
.sheets-list { margin-top: 12px; }
.sheet-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.sheet-item-info { flex: 1; }
.sheet-item-name { font-weight: 500; font-size: 14px; }
.sheet-item-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sheet-preview {
  max-height: 300px;
  overflow: auto;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.sheet-preview table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sheet-preview th, .sheet-preview td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.sheet-preview th { background: var(--bg-tertiary); position: sticky; top: 0; }

/* ==================== 导入结果 ==================== */
.import-result { margin-top: 16px; }
.result-item {
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.result-item.success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); }
.result-item.error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); }
.result-item.skipped { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); }
.result-status { font-size: 13px; font-weight: 500; }
.result-status.success { color: var(--success); }
.result-status.error { color: var(--error); }
.result-status.skipped { color: var(--warning); }
.result-msg { font-size: 12px; color: var(--text-muted); padding: 0 12px 8px; margin-top: -4px; }
.result-msg.error { color: rgba(239,68,68,0.7); }

/* 导入配置概览 */
.import-config-preview {
  margin: 12px 0;
  padding: 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.config-preview-header {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}
.config-preview-item {
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--bg-secondary);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}
.config-preview-item.incomplete {
  border-left-color: var(--warning);
  opacity: 0.7;
}
.config-preview-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
}
.config-preview-mappings {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0;
}
.mapping-chip {
  display: inline-block;
  padding: 2px 8px;
  font-size: 12px;
  background: var(--bg-hover);
  border-radius: 4px;
  color: var(--text-secondary);
}

/* 子表选择列表（复选框） */
.mapping-check-list, .sheet-select-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0;
}
.mapping-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-secondary);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.mapping-check-item:hover { background: var(--bg-hover); }
.mapping-check-item.disabled { opacity: 0.5; cursor: not-allowed; }
.mapping-check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}
.mapping-check-item.disabled input[type="checkbox"] { cursor: not-allowed; }
.sheet-select-list .mapping-check-item {
  background: var(--bg-tertiary);
}
.sheet-radio-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 6px 0;
}
.sheet-radio-list .mapping-check-item {
  background: var(--bg-tertiary);
}
.sheet-radio-list .mapping-check-item input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}
.config-preview-target {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.tag { padding: 1px 6px; font-size: 11px; border-radius: 3px; }
.tag-warn { background: rgba(245,158,11,0.2); color: var(--warning); }
.tag-ok { background: rgba(34,197,94,0.2); color: var(--success); }

/* ==================== 文件上传 ==================== */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--bg-secondary);
}
.file-upload-area:hover {
  border-color: var(--accent);
  background: var(--bg-tertiary);
}
.file-upload-area.dragover {
  border-color: var(--accent);
  background: var(--bg-hover);
}
.file-upload-icon {
  font-size: 36px;
  margin-bottom: 8px;
}
.file-upload-text {
  font-size: 15px;
  color: var(--text-secondary);
}
.file-upload-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.file-info {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
}
.file-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}
.file-parsing {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
}
.error-text {
  color: var(--error);
  font-size: 12px;
}

/* ==================== 配置页 ==================== */
.config-layout { display: flex; gap: 16px; }
.config-left { width: 280px; flex-shrink: 0; }
.config-right { flex: 1; }
.config-detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--text-muted);
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  margin-bottom: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.list-item:hover { background: var(--bg-hover); }
.list-item.active { border-color: var(--accent); background: var(--bg-hover); }
.list-item-name { font-size: 14px; }
.list-item-actions { display: flex; gap: 4px; }

.config-section { margin-bottom: 20px; }
.config-section h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.mapping-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 13px;
}

/* ==================== 授权状态 ==================== */
.auth-status {
  padding: 12px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 14px;
}
.auth-status.ok { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: var(--success); }
.auth-status.fail { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: var(--error); }

/* ==================== 日志表格 ==================== */
.logs-table { margin-top: 12px; overflow-x: auto; }
.logs-table table { width: 100%; border-collapse: collapse; font-size: 13px; }
.logs-table th, .logs-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.logs-table th { color: var(--text-secondary); font-weight: 500; }
.log-status { padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.log-status.success { background: rgba(34,197,94,0.15); color: var(--success); }
.log-status.error { background: rgba(239,68,68,0.15); color: var(--error); }

/* ==================== 弹窗 ==================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-width: 400px;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 16px; }
.modal-form .form-group { margin-bottom: 14px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ==================== 提示 ==================== */
.toast {
  position: fixed;
  top: 70px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 300;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--success); color: #fff; }
.toast.error { background: var(--error); color: #fff; }
.toast.info { background: var(--accent); color: #fff; }

.hint { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.hint a { color: var(--accent); }

.empty { text-align: center; padding: 40px; color: var(--text-muted); font-size: 14px; }
.loading { text-align: center; padding: 20px; color: var(--text-secondary); }

/* ==================== 响应式 ==================== */
@media (max-width: 768px) {
  .config-layout { flex-direction: column; }
  .config-left { width: 100%; }
  .modal { min-width: 90%; }
}
