/* ===== 全局重置 ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f5f6fa;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.6;
}
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ===== 顶部导航栏 ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px; height: 64px;
  background: #fff; border-bottom: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.logo { font-size: 26px; }
.brand-title { font-size: 17px; font-weight: 700; color: #111827; }
.brand-sub { font-size: 11px; color: #9ca3af; margin-top: 1px; }
.topbar-nav { display: flex; gap: 4px; }
.nav-btn {
  padding: 8px 16px; border: none; background: transparent; cursor: pointer;
  color: #6b7280; font-size: 14px; border-radius: 8px; transition: all .2s;
}
.nav-btn:hover { background: #f3f4f6; color: #374151; }
.nav-btn.active { background: #eff6ff; color: #2563eb; font-weight: 600; }
.topbar-right { display: flex; align-items: center; }
.engine-status { display: flex; align-items: center; gap: 7px; font-size: 12px; padding: 5px 12px; border-radius: 20px; }
.engine-status .dot { width: 8px; height: 8px; border-radius: 50%; }
.engine-status.loading { background: #fef3c7; color: #92400e; }
.engine-status.loading .dot { background: #f59e0b; animation: pulse 1.2s infinite; }
.engine-status.ready { background: #d1fae5; color: #065f46; }
.engine-status.ready .dot { background: #10b981; }
.engine-status.error { background: #fee2e2; color: #991b1b; }
.engine-status.error .dot { background: #ef4444; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ===== 主内容区 ===== */
.main { flex: 1; padding: 28px 32px; max-width: 1400px; width: 100%; margin: 0 auto; }
.view { display: none; animation: fadeIn .3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }
.view-header { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid #e5e7eb; }
.view-header h1 { font-size: 22px; font-weight: 700; color: #111827; margin-bottom: 6px; }
.view-header p { font-size: 13px; color: #6b7280; }
.back-btn {
  padding: 6px 14px; border: 1px solid #e5e7eb; background: #fff; border-radius: 8px;
  cursor: pointer; color: #6b7280; font-size: 13px; margin-bottom: 10px; transition: all .2s;
}
.back-btn:hover { background: #f9fafb; color: #374151; }

/* ===== 插件卡片网格 ===== */
.plugin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px; }
.plugin-card {
  background: #fff; border-radius: 14px; padding: 24px; cursor: pointer;
  border: 2px solid transparent; box-shadow: 0 2px 8px rgba(0,0,0,.05);
  transition: all .25s; position: relative; overflow: hidden;
}
.plugin-card:hover { box-shadow: 0 8px 24px rgba(0,0,0,.1); transform: translateY(-3px); border-color: #bfdbfe; }
.plugin-card.placeholder { display: flex; flex-direction: column; align-items: center; gap: 12px; color: #9ca3af; cursor: default; }
.plugin-card.placeholder:hover { transform: none; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.plugin-card::before { content:''; position:absolute; top:0; left:0; right:0; height:4px; background:linear-gradient(90deg,#3b82f6,#60a5fa); }
.plugin-icon { font-size: 38px; margin-bottom: 12px; }
.plugin-name { font-size: 17px; font-weight: 700; color: #111827; margin-bottom: 6px; }
.plugin-version { font-size: 11px; color: #9ca3af; background: #f3f4f6; padding: 2px 8px; border-radius: 10px; display: inline-block; margin-left: 6px; }
.plugin-desc { font-size: 13px; color: #6b7280; line-height: 1.6; margin-bottom: 14px; min-height: 40px; }
.plugin-category { font-size: 11px; color: #2563eb; font-weight: 600; }
.plugin-inputs-count { font-size: 12px; color: #9ca3af; margin-top: 8px; }

/* ===== 表单区 ===== */
.form-container { background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.form-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; margin-bottom: 20px; }
.form-options { margin-bottom: 20px; }
.form-label-input { margin-bottom: 20px; }
.form-label-input label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-label-input input[type="text"] {
  width: 100%; max-width: 400px; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px;
}
.form-label-input input[type="text"]:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,.1); }

.file-slot {
  border: 2px dashed #d1d5db; border-radius: 12px; padding: 18px; transition: all .2s;
  background: #fafbfc;
}
.file-slot.has-file { border-color: #10b981; border-style: solid; background: #f0fdf4; }
.file-slot.drag-over { border-color: #3b82f6; background: #eff6ff; }
.file-slot-label { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 10px; }
.file-slot-label .req { color: #ef4444; }
.file-slot-label .opt { color: #9ca3af; font-weight: 400; font-size: 11px; }
.file-slot-input { position: relative; }
.file-slot-input input[type="file"] { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.file-slot-btn {
  display: inline-block; padding: 7px 16px; background: #fff; border: 1px solid #d1d5db; border-radius: 7px;
  color: #374151; font-size: 13px; cursor: pointer; transition: all .2s;
}
.file-slot-btn:hover { background: #f9fafb; border-color: #9ca3af; }
.file-slot-name { margin-top: 8px; font-size: 12px; color: #10b981; word-break: break-all; display: none; }
.file-slot.has-file .file-slot-name { display: block; }
.file-slot.has-file .file-slot-btn { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }

.option-row { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; }
.option-row input[type="checkbox"] { margin-top: 2px; cursor: pointer; }
.option-row label { font-size: 13px; color: #374151; cursor: pointer; }
.option-row .hint { display: block; font-size: 11px; color: #9ca3af; margin-top: 3px; }

.form-actions { display: flex; align-items: center; gap: 14px; padding-top: 16px; border-top: 1px solid #f0f1f3; }
.btn-primary {
  padding: 11px 28px; background: #3b82f6; color: #fff; border: none; border-radius: 9px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .2s; display: flex; align-items: center; gap: 8px;
}
.btn-primary:hover:not(:disabled) { background: #2563eb; transform: translateY(-1px); }
.btn-primary:disabled { background: #9ca3af; cursor: not-allowed; }
.btn-secondary {
  padding: 8px 18px; background: #fff; border: 1px solid #d1d5db; border-radius: 8px;
  color: #374151; font-size: 13px; cursor: pointer; transition: all .2s;
}
.btn-secondary:hover { background: #f9fafb; border-color: #9ca3af; }
.run-hint { font-size: 12px; color: #9ca3af; }

.run-progress { margin-top: 18px; }
.progress-bar { width: 100%; height: 6px; background: #e5e7eb; border-radius: 3px; overflow: hidden; margin-bottom: 10px; }
.progress-fill { height: 100%; background: linear-gradient(90deg,#3b82f6,#60a5fa); width: 0%; transition: width .3s; border-radius: 3px; }
.run-log {
  background: #1f2937; color: #d1d5db; padding: 14px; border-radius: 8px;
  font-family: "SF Mono", Consolas, Monaco, monospace; font-size: 12px; line-height: 1.6;
  max-height: 240px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}
.run-error {
  margin-top: 16px; background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  padding: 14px 18px; border-radius: 10px; font-size: 13px; white-space: pre-wrap; font-family: monospace;
}

/* ===== 结果预览 ===== */
.result-meta { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.result-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.result-kpi-card {
  background: #fff; border-radius: 10px; padding: 14px 16px; box-shadow: 0 2px 6px rgba(0,0,0,.04);
  border-left: 3px solid #3b82f6;
}
.result-kpi-label { font-size: 11px; color: #9ca3af; margin-bottom: 5px; }
.result-kpi-value { font-size: 22px; font-weight: 700; color: #111827; }
.result-kpi-unit { font-size: 12px; color: #9ca3af; margin-left: 3px; }
.result-actions { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.dashboard-frame-wrapper { background: #fff; border-radius: 12px; overflow: hidden; box-shadow: 0 2px 8px rgba(0,0,0,.05); }
.dashboard-frame { width: 100%; height: calc(100vh - 320px); min-height: 600px; border: none; display: block; }

/* ===== 历史记录 ===== */
.history-toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.history-toolbar select { padding: 7px 12px; border: 1px solid #d1d5db; border-radius: 7px; font-size: 13px; }
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item {
  background: #fff; border-radius: 12px; padding: 18px 20px; box-shadow: 0 2px 6px rgba(0,0,0,.04);
  display: flex; align-items: center; gap: 16px; transition: all .2s;
}
.history-item:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.history-icon { font-size: 28px; }
.history-info { flex: 1; min-width: 0; }
.history-title { font-size: 14px; font-weight: 600; color: #111827; margin-bottom: 3px; }
.history-time { font-size: 12px; color: #9ca3af; }
.history-kpis { display: flex; gap: 14px; flex-wrap: wrap; }
.history-kpi { font-size: 11px; color: #6b7280; }
.history-kpi b { color: #111827; font-size: 13px; }
.history-actions { display: flex; gap: 8px; }
.history-actions button { padding: 6px 12px; font-size: 12px; }
.empty-state { text-align: center; padding: 60px 20px; color: #9ca3af; font-size: 14px; }

/* ===== 遮罩层 ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.overlay.hidden { display: none; }
.overlay-card {
  background: #fff; border-radius: 16px; padding: 40px 48px; text-align: center; max-width: 440px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.overlay-card h3 { font-size: 18px; font-weight: 700; color: #111827; margin: 18px 0 8px; }
.overlay-card p { font-size: 13px; color: #6b7280; margin-bottom: 8px; }
.overlay-hint { font-size: 11px !important; color: #9ca3af !important; margin-top: 12px !important; }
.overlay .progress-bar { margin: 14px 0; }

/* ===== Spinner ===== */
.spinner {
  width: 40px; height: 40px; border: 4px solid #e5e7eb; border-top-color: #3b82f6;
  border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto;
}
.spinner.small { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Footer ===== */
.footer {
  padding: 16px 32px; text-align: center; font-size: 12px; color: #9ca3af;
  border-top: 1px solid #e5e7eb; background: #fff;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .topbar { padding: 0 16px; flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; }
  .brand-sub { display: none; }
  .main { padding: 16px; }
  .plugin-grid { grid-template-columns: 1fr; }
  .form-inputs { grid-template-columns: 1fr; }
  .dashboard-frame { height: calc(100vh - 400px); min-height: 500px; }
}
