* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-sub: #64748b;
  --border: #e2e8f0;
  --sidebar: #0f172a;
  --success: #059669;
  --warning: #d97706;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
.app { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 250px; background: var(--sidebar); color: #cbd5e1;
  display: flex; flex-direction: column; position: fixed; height: 100vh; left: 0; top: 0;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 24px 20px; border-bottom: 1px solid #1e293b; }
.brand-icon { width: 40px; height: 40px; background: linear-gradient(135deg,#3b82f6,#1e40af); border-radius: 10px; display:flex; align-items:center; justify-content:center; font-size:24px; color:#fff; }
.brand-title { font-size: 15px; font-weight: 700; color: #fff; }
.brand-sub { font-size: 9px; color: #64748b; letter-spacing: 1.5px; margin-top: 2px; }
.nav { padding: 20px 12px; flex: 1; }
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: none; border: none; color: #94a3b8; font-size: 14px;
  border-radius: 8px; cursor: pointer; margin-bottom: 4px; text-align: left; transition: .2s;
}
.nav-item:hover { background: #1e293b; color: #e2e8f0; }
.nav-item.active { background: #1e40af; color: #fff; }
.nav-ico { font-size: 16px; width: 20px; text-align: center; }
.sidebar-footer { padding: 20px; border-top: 1px solid #1e293b; font-size: 11px; color: #64748b; display:flex; align-items:center; gap:8px; }
.status-dot { width: 8px; height: 8px; background: #10b981; border-radius: 50%; box-shadow: 0 0 8px #10b981; }

/* 主内容 */
.main { margin-left: 250px; flex: 1; min-width: 0; }
.topbar {
  height: 64px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 32px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; gap: 8px; }
.badge { font-size: 11px; padding: 4px 10px; background: #dbeafe; color: #1e40af; border-radius: 20px; font-weight: 600; }
.badge-green { background: #d1fae5; color: #059669; }

.page { display: none; padding: 28px 32px; max-width: 1200px; }
.page.active { display: block; }

/* 卡片 */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.04); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 10px; }
.card-body { padding: 20px; }
.step-num { width: 24px; height: 24px; background: var(--primary); color: #fff; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.header-hint { font-weight: 400; font-size: 12px; color: var(--text-sub); }

/* 提示框 */
.alert-box { display: flex; gap: 14px; background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 16px 18px; margin-bottom: 20px; }
.alert-icon { color: var(--primary-light); font-size: 20px; flex-shrink: 0; }
.alert-box strong { color: #1e40af; }
.alert-box p { font-size: 12px; color: #475569; margin-top: 4px; }

/* 表单 */
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; color: #334155; }
.input-row { display: flex; gap: 12px; }
.text-input, .select-input, .text-area {
  width: 100%; padding: 11px 14px; border: 1px solid #cbd5e1; border-radius: 8px;
  font-size: 14px; font-family: inherit; outline: none; transition: .2s; background: #fff;
}
.text-input:focus, .select-input:focus, .text-area:focus { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,.1); }
.text-area { resize: vertical; }
.checkbox-line { display: flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 13px; color: #475569; cursor: pointer; }
.checkbox-line input { width: 16px; height: 16px; accent-color: var(--primary); }

/* 按钮 */
.btn {
  padding: 10px 20px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff;
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer; transition: .2s;
  font-family: inherit; white-space: nowrap;
}
.btn:hover { background: #f8fafc; border-color: #94a3b8; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: #1e3a8a; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #047857; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 数据源网格 */
.source-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.source-card {
  border: 2px solid var(--border); border-radius: 10px; padding: 14px; cursor: pointer;
  transition: .2s; background: #fff; display: flex; gap: 12px; align-items: flex-start;
}
.source-card:hover { border-color: #93c5fd; background: #f8fbff; }
.source-card.selected { border-color: var(--primary-light); background: #eff6ff; }
.source-check { width: 18px; height: 18px; border: 2px solid #cbd5e1; border-radius: 4px; flex-shrink: 0; display:flex; align-items:center; justify-content:center; color:#fff; font-size:12px; margin-top:2px; }
.source-card.selected .source-check { background: var(--primary-light); border-color: var(--primary-light); }
.source-info { flex: 1; }
.source-name { font-weight: 700; font-size: 13px; color: #1e293b; }
.source-desc { font-size: 11px; color: var(--text-sub); margin-top: 4px; line-height: 1.5; }
.source-legal { font-size: 10px; color: var(--success); margin-top: 6px; }
.source-actions { margin-top: 14px; display: flex; gap: 8px; }

/* 进度 */
.progress-bar { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg,var(--primary-light),var(--primary)); width: 0%; transition: width .3s; }
.progress-text { font-size: 12px; color: var(--text-sub); margin-top: 10px; }

/* 结果 */
.result-count { color: var(--primary); font-size: 13px; }
.result-list { max-height: 460px; overflow-y: auto; }
.result-item { padding: 14px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; }
.result-title { font-weight: 600; color: #1e40af; font-size: 14px; }
.result-title a { color: inherit; text-decoration: none; }
.result-title a:hover { text-decoration: underline; }
.result-meta { font-size: 11px; color: var(--text-sub); margin: 6px 0; }
.result-snippet { font-size: 12px; color: #475569; line-height: 1.6; }
.result-actions { margin-top: 16px; display: flex; gap: 10px; }

/* 分析类型 */
.analysis-types { display: grid; grid-template-columns: repeat(auto-fill,minmax(220px,1fr)); gap: 12px; }
.analysis-type { display: flex; gap: 10px; padding: 14px; border: 2px solid var(--border); border-radius: 10px; cursor: pointer; transition: .2s; align-items: flex-start; }
.analysis-type.active { border-color: var(--primary-light); background: #eff6ff; }
.analysis-type input { margin-top: 3px; accent-color: var(--primary); }
.at-title { font-weight: 700; font-size: 13px; }
.at-desc { font-size: 11px; color: var(--text-sub); margin-top: 3px; }
.data-source-note { margin-top: 14px; padding: 12px; background: #fef3c7; border: 1px solid #fde68a; border-radius: 8px; font-size: 12px; color: #92400e; }

/* Markdown 结果 */
.markdown-body { line-height: 1.8; font-size: 14px; }
.markdown-body h1,.markdown-body h2,.markdown-body h3 { color: #1e40af; margin: 20px 0 10px; }
.markdown-body h1 { font-size: 22px; }
.markdown-body h2 { font-size: 18px; border-bottom: 2px solid #e2e8f0; padding-bottom: 6px; }
.markdown-body h3 { font-size: 15px; }
.markdown-body p { margin: 10px 0; }
.markdown-body ul,.markdown-body ol { padding-left: 24px; margin: 10px 0; }
.markdown-body li { margin: 5px 0; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 14px 0; }
.markdown-body th,.markdown-body td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-size: 13px; }
.markdown-body th { background: #f1f5f9; }
.markdown-body strong { color: #1e293b; }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.markdown-body blockquote { border-left: 4px solid var(--primary-light); padding: 8px 16px; background: #f8fafc; margin: 12px 0; }

/* 上传 */
.upload-zone { border: 2px dashed #cbd5e1; border-radius: 12px; padding: 48px 20px; text-align: center; cursor: pointer; transition: .2s; }
.upload-zone:hover,.upload-zone.dragover { border-color: var(--primary-light); background: #f8fbff; }
.upload-icon { font-size: 40px; color: var(--primary-light); }
.upload-text { font-size: 15px; font-weight: 600; margin-top: 10px; }
.upload-hint { font-size: 12px; color: var(--text-sub); margin-top: 6px; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; background: #eff6ff; padding: 10px 16px; border-radius: 8px; font-size: 13px; }
.file-size { color: var(--text-sub); font-size: 11px; }
.preview-box { margin-top: 12px; padding: 14px; background: #f8fafc; border-radius: 8px; font-size: 12px; color: #475569; max-height: 150px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; }

/* 文件列表 */
.file-list-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; }
.file-list-item:hover { background: #f8fafc; }
.file-name { font-size: 13px; font-weight: 500; }
.file-meta { font-size: 11px; color: var(--text-sub); margin-top: 2px; }

/* 指南 */
.guide-body h3 { color: #1e40af; margin: 22px 0 10px; font-size: 15px; }
.guide-body h3:first-child { margin-top: 0; }
.guide-body p,.guide-body li { font-size: 13px; color: #475569; }
.guide-body ul,.guide-body ol { padding-left: 22px; margin: 8px 0; }
.guide-body li { margin: 5px 0; }
.limit-box { background: #fef2f2; border: 1px solid #fecaca; border-radius: 10px; padding: 16px; margin: 12px 0; }
.limit-box p { color: #991b1b; }
.limit-box li { color: #7f1d1d; }

/* 遮罩与提示 */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); z-index: 100; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.spinner { width: 48px; height: 48px; border: 4px solid rgba(255,255,255,.2); border-top-color: #fff; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.overlay-text { color: #fff; margin-top: 16px; font-size: 14px; font-weight: 600; }
.toast { position: fixed; bottom: 30px; right: 30px; padding: 14px 20px; background: #1e293b; color: #fff; border-radius: 8px; font-size: 13px; z-index: 200; opacity: 0; transform: translateY(20px); transition: .3s; pointer-events: none; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #dc2626; }
.toast.success { background: #059669; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 900px) {
  .sidebar { width: 70px; }
  .brand-title,.brand-sub,.nav-item span:not(.nav-ico),.sidebar-footer span { display: none; }
  .nav-item { justify-content: center; }
  .main { margin-left: 70px; }
  .page { padding: 20px; }
}
