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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: #f5f7f5;
  color: #1a1a1a;
  font-size: 14px;
  line-height: 1.5;
}

button {
  cursor: pointer;
  font-family: inherit;
}

input {
  font-family: inherit;
}

/* 登录页 */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #2E7D32 0%, #4CAF50 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  padding: 40px 32px;
  border-radius: 16px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.logo-img {
  display: block;
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
  border-radius: 16px;
  object-fit: contain;
}

.logo {
  font-size: 32px;
  font-weight: 800;
  color: #2E7D32;
  text-align: center;
}

.subtitle {
  text-align: center;
  color: #999;
  margin-top: 4px;
  margin-bottom: 32px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  color: #666;
  font-size: 13px;
}

.form-group input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
}

.form-group input:focus {
  border-color: #2E7D32;
}

.btn-primary {
  width: 100%;
  height: 44px;
  background: #2E7D32;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  margin-top: 8px;
}

.btn-primary:hover { background: #246627; }
.btn-primary:disabled { background: #ccc; cursor: not-allowed; }

.error {
  margin-top: 12px;
  padding: 10px 14px;
  background: #ffebee;
  color: #c62828;
  border-radius: 8px;
  font-size: 13px;
}

/* 主界面 */
.main {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.header {
  background: #fff;
  border-bottom: 1px solid #e8e8e8;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-size: 18px;
  font-weight: 700;
  color: #2E7D32;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.header-right {
  display: flex;
  gap: 8px;
}

.btn-ghost {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  color: #666;
  font-size: 13px;
}

.btn-ghost:hover { background: #f5f5f5; }

.tabs {
  background: #fff;
  display: flex;
  padding: 0 20px;
  border-bottom: 1px solid #e8e8e8;
}

.tabs button {
  padding: 14px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-size: 14px;
  color: #666;
  position: relative;
}

.tabs button.active {
  color: #2E7D32;
  border-bottom-color: #2E7D32;
  font-weight: 600;
}

.badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  background: #ef5350;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* 数据 */
.range-row, .status-row {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.range-chip {
  padding: 6px 16px;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  color: #666;
  font-size: 13px;
}

.range-chip.active {
  background: #2E7D32;
  color: #fff;
  border-color: #2E7D32;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.stat-label { color: #999; font-size: 13px; }
.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: #2E7D32;
  margin: 6px 0 4px;
}
.stat-sub { color: #aaa; font-size: 12px; }

.section {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.section h3 {
  margin-bottom: 14px;
  font-size: 16px;
  color: #333;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.table th {
  background: #fafafa;
  color: #666;
  font-weight: 600;
}

.table tr:hover { background: #fafafa; }

.empty {
  padding: 32px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

.ellipsis {
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 反馈 */
.feedback-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.feedback-card {
  background: #fff;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.feedback-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.type-tag, .status-tag {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.type-bug { background: #ffebee; color: #c62828; }
.type-suggestion { background: #fff3e0; color: #e65100; }
.type-other { background: #e3f2fd; color: #1565c0; }

.status-open { background: #e8f5e9; color: #2e7d32; }
.status-replied { background: #f3e5f5; color: #6a1b9a; }
.status-closed { background: #eeeeee; color: #757575; }

.time { color: #999; font-size: 12px; }
.spacer { flex: 1; }

.btn-tiny {
  padding: 4px 10px;
  background: #f5f5f5;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  font-size: 12px;
  color: #555;
}

.btn-tiny:hover { background: #ebebeb; }

.btn-danger {
  background: #fff;
  color: #c62828;
  border-color: #ffcdd2;
}

.btn-danger:hover { background: #ffebee; }

.feedback-content {
  font-size: 14px;
  line-height: 1.7;
  color: #333;
  white-space: pre-wrap;
  margin-bottom: 8px;
}

.feedback-meta {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

.feedback-images {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.feedback-images img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid #f0f0f0;
}

/* ===================== LLM 模型配置 ===================== */
.llm-list {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.llm-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  border: 1px solid #e8e8e8;
}

.llm-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f0;
}

.llm-task {
  font-size: 18px;
  font-weight: 700;
  color: #2E7D32;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}

.llm-enabled {
  font-size: 14px;
  color: #666;
  display: flex;
  align-items: center;
  gap: 6px;
}

.form-row {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row-inline {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.form-row-inline label {
  margin: 0;
  white-space: nowrap;
}

.form-row-inline input {
  width: 100px;
}

.form-row label {
  font-size: 13px;
  color: #666;
  font-weight: 600;
}

.form-row input,
.form-row select,
.form-row textarea {
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  font-family: inherit;
  resize: vertical;
}

.form-row textarea {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
  outline: none;
  border-color: #2E7D32;
}

.form-hint {
  font-size: 12px;
  color: #999;
  margin-top: 2px;
}

.btn-test {
  background: #2E7D32;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  align-self: flex-start;
}

.btn-test:disabled {
  background: #999;
  cursor: not-allowed;
}

.test-result {
  background: #1e1e1e;
  color: #e0e0e0;
  border-radius: 8px;
  padding: 12px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  max-height: 240px;
  overflow: auto;
}

.test-result pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===================== 调用日志 ===================== */
.llm-calls {
  padding: 16px 20px;
}

.calls-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  font-size: 13px;
  margin-top: 12px;
}

.calls-table thead {
  background: #f8f9fa;
}

.calls-table th,
.calls-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #f0f0f0;
}

.calls-table th {
  font-size: 12px;
  color: #666;
  font-weight: 600;
}

.calls-table tr.error {
  background: rgba(239, 83, 80, 0.04);
}

.calls-table tr.error .td-error {
  color: #c62828;
  font-size: 12px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calls-table td {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  color: #333;
}

.empty {
  text-align: center;
  color: #999;
  padding: 60px 20px;
  font-size: 14px;
}

.loading {
  text-align: center;
  color: #999;
  padding: 40px 20px;
  font-size: 14px;
}

/* Provider 接入页样式 */
.provider-intro {
  background: #f8f9fa;
  border-left: 4px solid #2E7D32;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  color: #555;
  margin-bottom: 12px;
  line-height: 1.6;
}
.provider-intro code {
  background: #e8f5e9;
  color: #2E7D32;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
}
.key-row { display: flex; gap: 8px; }
.key-row input { flex: 1; }
.task-section { margin-bottom: 24px; }
.task-title {
  font-size: 18px;
  color: #2E7D32;
  margin-bottom: 12px;
  padding: 0 4px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.task-title code {
  background: #f0f0f0;
  color: #666;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: normal;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.llm-slot {
  font-size: 14px;
  font-weight: 700;
  color: #666;
  background: #f5f5f5;
  padding: 4px 12px;
  border-radius: 12px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.btn-add-slot {
  width: 100%;
  background: #fff;
  border: 2px dashed #ccc;
  color: #666;
  padding: 12px;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}
.btn-add-slot:hover {
  border-color: #2E7D32;
  color: #2E7D32;
}
.btn-danger {
  background: #fff !important;
  color: #c62828 !important;
  border-color: #ffcdd2 !important;
}
.btn-danger:hover { background: #ffebee !important; }

/* Provider 内置/自定义标记 */
.badge-system, .badge-custom {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 8px;
  margin-left: 6px;
  font-weight: 500;
  vertical-align: middle;
}
.badge-system { background: #e3f2fd; color: #1565c0; }
.badge-custom { background: #fff3e0; color: #e65100; }

.add-provider-card {
  border: 2px dashed #c0c0c0 !important;
  background: #fafafa !important;
}
.text-center { text-align: center; padding: 12px; }

/* 占位符说明表 */
.placeholder-help {
  background: #fff8e1;
  border-left: 4px solid #ffa726;
  padding: 14px 18px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}
.placeholder-help table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
}
.placeholder-help th,
.placeholder-help td {
  padding: 6px 10px;
  border-bottom: 1px solid #ffe0b2;
  text-align: left;
  vertical-align: top;
}
.placeholder-help th {
  background: rgba(255, 167, 38, 0.15);
  color: #e65100;
  font-size: 12px;
}
.placeholder-help code {
  background: #fff;
  border: 1px solid #ffe0b2;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  color: #6a1b9a;
}

/* Task section 头部 */
.task-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

/* 版本输入框 */
.version-name-input {
  flex: 1;
  font-size: 13px;
  padding: 6px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  margin: 0 8px;
}

/* 修改历史块 */
.history-block {
  background: #fafafa;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  padding: 12px;
  margin-top: 8px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  background: #fff;
  border-radius: 6px;
  overflow: hidden;
}

.history-table th, .history-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0f0f0;
  text-align: left;
}

.history-table th {
  background: #f5f5f5;
  color: #666;
  font-weight: 600;
}

.history-table code {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  background: #fff3e0;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
  color: #e65100;
}

.loading-inline, .empty-inline {
  text-align: center;
  color: #999;
  padding: 16px;
  font-size: 13px;
}

/* ===== Phase 2 Commit B: 三段式版本生命周期 UI ===== */

/* Ensemble 开关栏 */
.ensemble-bar {
  background: #fff8e1;
  border: 1px solid #ffe0b2;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
}
.ensemble-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.ensemble-toggle input[type=checkbox] {
  width: 16px;
  height: 16px;
}
.ensemble-members {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #ffd180;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}
.member-checkbox {
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

/* 三段式 section 标题 */
.version-section {
  margin-bottom: 20px;
}
.section-h {
  font-size: 14px;
  color: #555;
  font-weight: 600;
  margin-bottom: 8px;
  padding: 8px 12px;
  background: #f5f5f5;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-h .btn-tiny {
  margin-left: auto;
}

/* 不同状态的卡片 */
.version-card-active {
  border-left: 4px solid #2E7D32 !important;
  background: linear-gradient(to right, #e8f5e9, #fff 30%) !important;
}
.version-card-draft {
  border-left: 4px solid #ff9800 !important;
  background: linear-gradient(to right, #fff3e0, #fff 30%) !important;
}
.version-card-archived {
  border-left: 4px solid #999 !important;
  background: #fafafa !important;
}

/* 版本名展示 */
.version-name-display {
  font-weight: 600;
  color: #333;
  margin-left: 8px;
}

/* 专家徽章 */
.expert-badge {
  background: #e3f2fd;
  color: #1565c0;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  margin-left: 8px;
}

/* status mini 标签 (ensemble 成员里用) */
.status-tag-mini {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}
.st-active { background: #e8f5e9; color: #2E7D32; }
.st-draft { background: #fff3e0; color: #e65100; }
.st-archived { background: #eee; color: #666; }

/* 只读概要 */
.readonly-summary {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: #555;
  line-height: 1.7;
  margin-bottom: 8px;
}
.readonly-summary strong { color: #333; }

/* 折叠 prompt 预览 */
.prompt-preview {
  margin: 8px 0;
}
.prompt-preview summary {
  cursor: pointer;
  font-size: 13px;
  color: #2E7D32;
  font-weight: 600;
  padding: 6px 0;
}
.prompt-preview pre {
  background: #1e1e1e;
  color: #ddd;
  padding: 12px;
  border-radius: 6px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 300px;
  overflow: auto;
}

/* 保存指示器 */
.save-indicator {
  font-size: 12px;
  color: #999;
  margin-left: auto;
}
.save-indicator.ok {
  color: #2E7D32;
}
