/* ============================================================
   生态业务经营辅导智能体后台管理 —— 共享视觉系统
   主色：生态青绿；产品表面：记录管理型工作台
   ============================================================ */

:root {
  /* 色彩系统 */
  --brand-800: #0B5D57;
  --brand-700: #0F766E;
  --brand-600: #0D9488;
  --brand-500: #14B8A6;
  --brand-100: #CCF3EE;
  --brand-50: #EFFAF8;

  --bg: #F4F7F6;
  --surface: #FFFFFF;
  --surface-2: #FAFCFB;
  --border: #E3E9E7;
  --border-strong: #CBD8D4;

  --text-1: #16302B;
  --text-2: #5F6F6B;
  --text-3: #8CA09B;

  --danger: #B91C1C;
  --danger-bg: #FDECEC;
  --warning: #B45309;
  --warning-bg: #FDF3DF;
  --info: #1D4ED8;
  --info-bg: #E8F0FE;
  --success: #15803D;
  --success-bg: #E4F6EA;

  /* 字体 */
  --font-sans: "Segoe UI", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;

  /* 尺寸节奏 */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(22, 48, 43, 0.06);
  --shadow-md: 0 4px 16px rgba(22, 48, 43, 0.10);
  --shadow-lg: 0 12px 40px rgba(22, 48, 43, 0.16);
  --control-h: 36px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  color: var(--text-1);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand-700); text-decoration: none; }

/* ---------------- 控件 ---------------- */
button {
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  height: var(--control-h);
  padding: 0 16px;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.btn-primary {
  background: var(--brand-700);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--brand-800); }
.btn-primary:disabled { background: var(--text-3); cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--text-1);
  border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--brand-600); color: var(--brand-700); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}
.btn-danger:hover { background: #991B1B; }

.btn-link {
  background: none;
  border: none;
  color: var(--brand-700);
  height: auto;
  padding: 2px 6px;
}
.btn-link:hover { color: var(--brand-600); text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

input[type="text"], input[type="password"], input[type="number"],
select, textarea {
  font-family: inherit;
  font-size: 14px;
  color: var(--text-1);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  height: var(--control-h);
  padding: 0 10px;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
textarea { height: auto; padding: 8px 10px; line-height: 1.6; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}
input:disabled, select:disabled { background: var(--surface-2); color: var(--text-3); }

label.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
label.field-label .required::before { content: "*"; color: var(--danger); margin-left: 2px; }

/* ---------------- 徽章 ---------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 1px 10px;
  border-radius: 999px;
  line-height: 20px;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-status-pending { color: #5B6B68; background: #EDF1F0; }
.badge-status-building { color: var(--warning); background: var(--warning-bg); }
.badge-status-published { color: var(--success); background: var(--success-bg); }
.badge-status-iterating { color: var(--info); background: var(--info-bg); }

.data-table .col-check { width: 36px; text-align: center; }
.data-table .col-check input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--brand-600); cursor: pointer; }
.data-table td.cell-desc { max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table .mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; color: var(--text-2); }
.selection-info { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border: 1px solid var(--brand-100); border-radius: 999px; background: var(--brand-50); color: var(--brand-700); font-size: 12px; }
.selection-info b { font-weight: 600; }
.badge-role-admin { color: var(--brand-700); background: var(--brand-50); }
.badge-role-operator { color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); }
.badge-user-disabled { color: var(--danger); background: var(--danger-bg); }

.code-chip {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--brand-800);
  background: var(--brand-50);
  border: 1px solid var(--brand-100);
  border-radius: var(--radius-sm);
  padding: 1px 7px;
  white-space: nowrap;
}

/* ---------------- 表格 ---------------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}
.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-strong);
  background: var(--surface-2);
  white-space: nowrap;
}
.data-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tbody tr:hover { background: var(--brand-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.cell-actions { white-space: nowrap; text-align: right; }

.table-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  /* 列过多导致表格超宽时改为横向滚动，保证右侧操作列可见（圆角裁剪保持） */
  overflow-x: auto;
  overflow-y: hidden;
}

.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--text-2);
}
.empty-state .empty-icon {
  width: 44px; height: 44px;
  margin: 0 auto 12px;
  border-radius: var(--radius-md);
  background: var(--brand-50);
  color: var(--brand-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.empty-state .empty-title { font-weight: 600; color: var(--text-1); margin-bottom: 4px; }
.empty-state .empty-hint { font-size: 13px; }

.loading-state { padding: 40px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------------- 分页 ---------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13px;
  color: var(--text-2);
  flex-wrap: wrap;
  gap: 8px;
}
.pagination .pager { display: flex; align-items: center; gap: 6px; }
.pagination button {
  height: 30px;
  min-width: 30px;
  padding: 0 10px;
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text-1);
}
.pagination button:hover:not(:disabled) { border-color: var(--brand-600); color: var(--brand-700); }
.pagination button:disabled { opacity: 0.45; cursor: not-allowed; }
.pagination .page-current {
  height: 30px; min-width: 30px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-700); color: #fff; border-radius: var(--radius-sm); font-weight: 600;
}

/* ---------------- 模态框 ---------------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 38, 34, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 16px 16px;
  z-index: 100;
  overflow-y: auto;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 640px;
  max-width: 100%;
  display: flex; flex-direction: column;
  max-height: 86vh;
}
.modal.wide { width: 780px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  background: none; border: none; height: 28px; width: 28px;
  color: var(--text-3); font-size: 18px; line-height: 1; padding: 0;
}
.modal-close:hover { color: var(--text-1); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }
.form-error {
  display: none;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #F5C6C6;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.form-error.visible { display: block; }

/* ---------------- 提示条 ---------------- */
.toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--text-1);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 13.5px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--danger); }

/* ---------------- 策略维护页（独立页） ---------------- */
.edit-page { background: var(--bg); min-height: 100vh; }

.edit-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  flex-wrap: wrap;
}
.edit-header .btn-back {
  display: inline-flex; align-items: center; gap: 4px;
  background: none; border: none; color: var(--brand-700);
  font-size: 14px; height: 32px; padding: 0 8px; cursor: pointer;
}
.edit-header .btn-back:hover { background: var(--brand-50); border-radius: var(--radius-sm); }
.edit-title { flex: 1; min-width: 220px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.edit-title .edit-mode { font-size: 18px; font-weight: 600; color: var(--text-1); }
.edit-title .code-chip {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12.5px; font-weight: 600;
  color: var(--brand-700); background: var(--brand-50);
  border: 1px solid #B8E3DC; border-radius: var(--radius-sm);
  padding: 2px 8px;
}
.edit-title .strategy-name { font-size: 14px; color: var(--text-2); }
.edit-header .form-error { margin: 0; flex-basis: 100%; }

.tabs {
  display: flex; gap: 2px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  overflow-x: auto;
}
.tab {
  background: none; border: none; cursor: pointer;
  height: 42px; padding: 0 16px;
  font-size: 14px; color: var(--text-2);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--brand-700); background: var(--brand-50); }
.tab.active { color: var(--brand-700); font-weight: 600; border-bottom-color: var(--brand-700); }
.tab em { font-style: normal; font-size: 12px; color: var(--text-3); margin-left: 4px; }
.tab.active em { color: var(--brand-600); }

.tab-panel { display: none; padding: 20px 24px 48px; max-width: 1080px; }
.tab-panel.active { display: block; }

.sub-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px; gap: 12px; flex-wrap: wrap;
}
.sub-toolbar .sub-hint { font-size: 13px; color: var(--text-3); }

.sub-editor {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-600);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 18px 20px;
}
.sub-editor .editor-title { font-size: 14px; font-weight: 600; margin-bottom: 14px; color: var(--text-1); }
.sub-editor .editor-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: flex-end; }

.form-sec { margin-bottom: 22px; }
.form-sec-title {
  font-size: 13px; font-weight: 600; color: var(--text-3);
  letter-spacing: 0.04em; margin-bottom: 12px;
  padding-bottom: 6px; border-bottom: 1px dashed var(--border);
}

@media (max-width: 720px) {
  .tab-panel { padding: 16px 12px 40px; }
  .edit-header { padding: 10px 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: span 1; }
}
