:root {
  --brand: #1f6feb;
  --brand-dark: #1158c7;
  --ink: #1a2233;
  --muted: #6b7280;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e5e9f0;
  --danger: #e5484d;
  --success: #2f9e6e;
  --warning: #d9822b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Microsoft YaHei", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

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

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; background: #141b2b; color: #cfd6e4;
  flex-shrink: 0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 20px 18px; font-size: 17px; font-weight: 700; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar .brand .logo {
  width: 30px; height: 30px; border-radius: 7px; background: var(--brand);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.sidebar .nav { padding: 12px 0; flex: 1; overflow-y: auto; }
.sidebar .nav .group {
  padding: 10px 20px 4px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 1px; color: #6d7a94;
}
.sidebar .nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 20px;
  color: #cfd6e4; font-size: 14px; border-left: 3px solid transparent;
}
.sidebar .nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar .nav a.active {
  background: rgba(31,111,235,.18); color: #fff; border-left-color: var(--brand);
}
.sidebar .nav a i { font-size: 16px; width: 20px; text-align: center; }
.sidebar .foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 12px; color: #7d8aa3; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 10;
}
.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.topbar .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.content { padding: 26px; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; margin-bottom: 20px;
}
.card h3 { margin: 0 0 16px; font-size: 15px; }
.card h3 .sub { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 8px; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 16px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; display: flex; flex-direction: column; gap: 6px;
}
.stat .label { color: var(--muted); font-size: 13px; }
.stat .value { font-size: 26px; font-weight: 700; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat.highlight { border-color: var(--warning); }
.stat.highlight .value { color: var(--warning); }

/* 表格 */
.table { width: 100%; border-collapse: collapse; background: var(--card); }
.table th, .table td {
  text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table th { background: #fafbfd; color: var(--muted); font-weight: 600; font-size: 12px; }
.table tr:hover td { background: #f8fafd; }

/* 徽章 */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.badge.new { background: #eef4ff; color: var(--brand); }
.badge.following { background: #fff4e5; color: var(--warning); }
.badge.quoted { background: #f0ecff; color: #6b48c7; }
.badge.sampling { background: #e6f7ff; color: #0e8ac4; }
.badge.deal { background: #e6f7ef; color: var(--success); }
.badge.lost { background: #fdecec; color: var(--danger); }
.badge.gray { background: #eef0f4; color: var(--muted); }
.badge.brand { background: #eef4ff; color: var(--brand); }
.badge-sm { padding: 1px 8px; font-size: 11px; margin-left: 4px; }

/* 生成后新记录高亮（历史列表首行） */
@keyframes rowFlash {
  0%   { background: #fff7e0; }
  25%  { background: #ffe9a8; }
  50%  { background: #fff3cc; }
  75%  { background: #ffe9a8; }
  100% { background: transparent; }
}
.table tr.row-flash.flash-on td { animation: rowFlash 1.2s ease 2; }
.table tr.row-new td { box-shadow: inset 3px 0 0 var(--success); }

/* AI 生成提示条 */
.ai-notice {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0 4px; padding: 9px 12px; border-radius: 8px;
  background: #e6f7ef; color: var(--success);
  border: 1px solid #b8e4cf; font-size: 13px; font-weight: 600;
}
.ai-notice i { font-size: 16px; }
.ai-notice-muted { background: #f0f2f5; color: var(--muted); border-color: #dde2ea; }

/* 表单 */
.form-group { margin-bottom: 16px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid #d4dae3; border-radius: 8px;
  font-size: 14px; background: #fff; color: var(--ink);
}
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(31,111,235,.12); }
textarea.form-control { min-height: 90px; resize: vertical; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px;
  border-radius: 8px; border: 1px solid transparent; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline { background: #fff; color: var(--ink); border-color: #d4dae3; }
.btn-outline:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }

/* 复选框行 */
.check-line { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

/* 自定义品类添加 */
.custom-cat { display: flex; gap: 8px; margin-top: 12px; }
.custom-cat .form-control { flex: 1; }
.custom-cat-list { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }
.custom-chip {
  display: inline-flex; align-items: center; gap: 6px; margin: 0;
  background: #eef4ff; border: 1px solid #cfe3ff; border-radius: 20px; padding: 4px 10px;
}
.custom-chip span { font-size: 13px; }
.custom-chip input { margin: 0; }
.chip-del {
  border: none; background: none; color: var(--muted); cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 2px;
}
.chip-del:hover { color: var(--danger); }

/* 空状态 */
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty i { font-size: 40px; display: block; margin-bottom: 12px; opacity: .4; }

/* 提示条 */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #e6f7ef; color: #1d7a50; }
.alert-danger { background: #fdecec; color: #b02a2f; }
.alert-warning { background: #fff4e5; color: #a8621a; }
.alert-info { background: #eef4ff; color: #1a5fbd; }

/* CRM 子页签导航 */
.crm-tabs {
  display: flex; gap: 4px; margin-bottom: 20px;
  border-bottom: 2px solid var(--line);
}
.crm-tabs a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 18px; margin-bottom: -2px; font-weight: 600; font-size: 14px;
  color: var(--muted); border-bottom: 2px solid transparent;
}
.crm-tabs a:hover { color: var(--ink); }
.crm-tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* 生成结果 */
.gen-block { margin-bottom: 20px; }
.gen-block .gen-title {
  font-weight: 700; font-size: 15px; margin-bottom: 8px; color: var(--brand);
  display: flex; align-items: center; gap: 8px;
}
.gen-block .gen-body {
  background: #f8fafd; border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px; white-space: pre-wrap; line-height: 1.8;
}

/* 分镜清单 */
.shot { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.shot .num {
  width: 26px; height: 26px; border-radius: 6px; background: #eef4ff; color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0;
}

/* 登录页 */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #141b2b 0%, #1f6feb 100%); padding: 20px; }
.auth-card { width: 420px; background: #fff; border-radius: 16px; padding: 34px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card .subtitle { color: var(--muted); margin-bottom: 24px; font-size: 13px; }

/* 时间线 */
.timeline { border-left: 2px solid var(--line); padding-left: 18px; }
.timeline .item { position: relative; padding-bottom: 14px; }
.timeline .item::before {
  content: ""; position: absolute; left: -24px; top: 4px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--brand);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ===== AI 脚本创作中心 ===== */
.info-bar {
  background: #eaf3ff; border: 1px solid #cfe3ff; color: #1a5fbd;
  padding: 12px 16px; border-radius: 10px; margin-bottom: 20px;
  display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.6;
}
.info-bar i { font-size: 18px; margin-top: 1px; }

.script-workspace {
  display: grid; grid-template-columns: 38fr 62fr; gap: 20px; align-items: start;
}
.script-form { position: sticky; top: 76px; }
.script-preview { min-height: 480px; }

.preview-empty {
  background: var(--card); border: 2px dashed #d4dae3; border-radius: 12px;
  min-height: 480px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--muted); gap: 14px; text-align: center; padding: 30px;
}
.preview-empty i { font-size: 52px; opacity: .35; }
.preview-empty p { margin: 0; font-size: 14px; }

/* 生成按钮行 */
.btn-row { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

/* 目标平台单选 */
.platform-radio { display: flex; gap: 16px; flex-wrap: wrap; }
.radio-line { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.radio-line input { accent-color: var(--brand); }

/* 折叠面板（预览五件套） */
.accordion {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  margin-bottom: 14px; overflow: hidden;
}
.accordion summary {
  list-style: none; cursor: pointer; padding: 14px 18px; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; gap: 8px; user-select: none;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary:hover { background: #f8fafd; }
.accordion .acc-right { margin-left: auto; display: inline-flex; align-items: center; gap: 10px; }
.accordion .acc-meta { font-weight: 400; font-size: 12px; color: var(--muted); }
.accordion .acc-caret { color: var(--muted); font-size: 13px; transition: transform .2s; }
.accordion:not([open]) .acc-caret { transform: rotate(-90deg); }
.accordion .acc-body { padding: 0 18px 16px; }
.accordion .acc-toolbar { display: flex; justify-content: flex-end; margin-bottom: 8px; }

/* 预览头 / 底部操作 */
.preview-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.preview-head .name { font-size: 16px; font-weight: 700; }
.preview-foot { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 8px; }

/* 标题备选行 */
.title-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px dashed var(--line);
}
.title-row:last-child { border-bottom: none; }
.title-num {
  width: 22px; height: 22px; border-radius: 6px; background: #eef4ff; color: var(--brand);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; font-size: 12px;
}
.title-text { flex: 1; line-height: 1.5; }

/* 复制按钮 */
.copy-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 12px;
  border: 1px solid #d4dae3; border-radius: 7px; background: #fff; color: var(--brand);
  font-size: 12px; font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap;
}
.copy-btn:hover { border-color: var(--brand); background: #eef4ff; }
.copy-btn.copied { color: var(--success); border-color: var(--success); background: #e6f7ef; }

/* 历史脚本筛选 */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.filter-select { width: auto; min-width: 180px; }
.filter-date { width: auto; }
.filter-sep { color: var(--muted); }

/* 历史操作按钮组 */
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row-actions .btn { margin: 0; }
.btn-del:hover { border-color: var(--danger); color: var(--danger); }

/* 加载 spinner */
.spinner {
  display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1100px) {
  .script-workspace { grid-template-columns: 1fr; }
  .script-form { position: static; }
}

@media (max-width: 900px) {
  .sidebar { display: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* 获客渠道回调地址 */
.hook-cell { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hook-url {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px; background: #f1f3f7; color: #3c4a5a;
  padding: 4px 8px; border-radius: 6px; word-break: break-all;
}
.tip {
  font-size: 12px; color: var(--muted); background: #f5f7fa;
  padding: 10px 12px; border-radius: 8px; margin-top: 12px; line-height: 1.6;
}
.tip i { margin-right: 4px; color: var(--brand); }

/* 配置方法折叠说明 */
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.steps li { line-height: 1.7; color: var(--ink); }
.muted { color: var(--muted); }
.code-block {
  background: #f1f3f7; color: #2c3e50;
  padding: 12px 14px; border-radius: 8px; margin: 8px 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px; line-height: 1.7; overflow-x: auto; white-space: pre;
}

/* 各平台发布内容卡片 */
.platform-post {
  border: 1px solid #e6e9f0; border-radius: 10px; padding: 16px; margin-bottom: 14px;
  background: #fff;
}
.platform-post:last-child { margin-bottom: 0; }
.pp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.pp-title { font-size: 16px; font-weight: 700; color: var(--ink); margin-bottom: 8px; }
.pp-content { font-size: 14px; color: var(--ink); line-height: 1.7; white-space: pre-wrap; margin-bottom: 10px; }
.pp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.pp-cover { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.pp-cover img { max-width: 260px; border-radius: 10px; border: 1px solid #e6e9f0; box-shadow: 0 2px 8px rgba(0,0,0,.06); }

/* 核心优势 / FAQ 动态增删条目 */
.entry-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.entry-row { display: flex; gap: 8px; align-items: center; }
.entry-row .form-control { flex: 1; min-width: 0; }
.entry-del {
  width: 30px; height: 30px; flex-shrink: 0; border: 1px solid #d4dae3; border-radius: 7px;
  background: #fff; color: var(--muted); cursor: pointer; line-height: 1; font-size: 16px;
}
.entry-del:hover { border-color: var(--danger); color: var(--danger); background: #fdecec; }
