:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

/* 后台框架 */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 230px; flex: 0 0 230px; background: #111827; color: #d1d5db; display: flex; flex-direction: column; padding: 20px 14px; }
.logo, .auth-logo { display: block; font-size: 20px; font-weight: 700; color: #fff; padding: 4px 10px 24px; letter-spacing: -.5px; }
.logo span, .auth-logo span { color: #818cf8; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { color: #d1d5db; padding: 11px 12px; border-radius: 9px; font-weight: 500; }
.sidebar nav a:hover { background: #1f2937; text-decoration: none; }
.sidebar nav a.active { background: var(--primary); color: #fff; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid #1f2937; padding-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-chip strong, .user-chip small { display: block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { color: #9ca3af; font-size: 11px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: #374151; color: #fff; display: grid; place-items: center; font-weight: 700; }
.logout { width: 100%; background: transparent; border: 1px solid #374151; color: #d1d5db; padding: 8px; border-radius: 8px; cursor: pointer; }
.logout:hover { background: #1f2937; }
.main { 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 28px; }
.topbar h1 { font-size: 18px; }
.content { padding: 26px 28px 48px; max-width: 1420px; margin: 0 auto; }

/* 通用组件 */
.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: 0 2px 12px rgba(15, 23, 42, .03); }
.panel.narrow { max-width: 660px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.panel-actions { display: flex; gap: 10px; margin-bottom: 14px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }
label { display: block; font-weight: 600; font-size: 13px; margin: 14px 0 6px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-top: 18px; }
input[type=text], input[type=email], input[type=password], input[type=number], input:not([type]), textarea, select {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; font: inherit; color: var(--text); background: #fff;
}
input:focus, textarea:focus, select:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
input[type=color] { width: 100%; height: 42px; border: 1px solid #d1d5db; border-radius: 8px; padding: 2px; background: #fff; }
.btn-primary, .btn-ghost, .btn-secondary { display: inline-block; border-radius: 8px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-ghost { background: #fff; border-color: var(--border); color: var(--text); }
.btn-secondary { background: #eef2ff; color: var(--primary-dark); border-color: #e0e7ff; }
.btn-primary.small, .btn-ghost.small, .btn-secondary.small { padding: 7px 13px; font-size: 13px; }
button:disabled { opacity: .55; cursor: not-allowed; }
.color-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.color-grid label { margin: 0; }
.notice { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; padding: 12px 14px; border-radius: 9px; margin-bottom: 18px; font-size: 13px; }
.status-line { margin-bottom: 12px; color: var(--muted); }
.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }
.flash.success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.flash.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.on { background: #ecfdf5; color: #047857; }
.badge.off { background: #f3f4f6; color: #6b7280; }
.empty { text-align: center; padding: 46px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 6px; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-size: 12px; font-weight: 600; }
.table small { display: block; color: var(--muted); margin-top: 3px; }
.table code { background: #f3f4f6; padding: 2px 6px; border-radius: 5px; font-size: 12px; }
.actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }
.inline select { width: auto; }
.link-danger { background: none; border: 0; color: #dc2626; cursor: pointer; font: inherit; padding: 0; }

/* 统计卡片 */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.stat-card span { color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; font-size: 30px; margin-top: 8px; }

/* 登录页 */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: linear-gradient(135deg, #eef2ff, #f5f7fb); }
.auth-card { width: 400px; max-width: calc(100vw - 32px); background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: 0 18px 50px rgba(30, 41, 59, .1); }
.auth-card .auth-logo { color: #111827; padding-bottom: 20px; }
.auth-link { text-align: center; color: var(--muted); margin: 18px 0 0; }

/* 编辑器 */
.editor { display: flex; flex-direction: column; height: calc(100vh - 128px); min-height: 620px; }
.editor-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; padding: 12px 18px; }
.editor-title strong { display: block; }
.editor-title span { color: var(--muted); font-size: 12px; }
.editor-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.save-status { color: var(--muted); font-size: 12px; min-width: 48px; }
.editor-body { flex: 1; display: grid; grid-template-columns: 250px 350px 1fr; min-height: 0; background: #fff; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); overflow: hidden; }
.block-panel, .fields-panel { border-right: 1px solid var(--border); overflow-y: auto; padding: 16px; }
.block-panel h3 { display: flex; justify-content: space-between; margin: 6px 0 10px; }
.block-panel h3 small { color: var(--muted); font-weight: 400; font-size: 11px; }
.add-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 18px; }
.add-btn { display: flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: #f9fafb; border-radius: 8px; padding: 7px; font: inherit; font-size: 12px; cursor: pointer; text-align: left; }
.add-btn:hover { border-color: var(--primary); color: var(--primary); }
.add-icon { color: var(--primary); font-size: 14px; }
.section-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.section-item { display: flex; align-items: center; gap: 8px; padding: 9px 8px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: #fff; }
.section-item.selected { border-color: var(--primary); background: #eef2ff; }
.section-label { flex: 1; display: flex; align-items: center; gap: 7px; font-size: 13px; }
.section-icon { color: var(--primary); }
.drag-handle { color: #9ca3af; cursor: grab; }
.section-tools { display: flex; gap: 2px; }
.icon-btn { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.icon-btn.danger:hover { color: #dc2626; }
.fields-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.field-label { margin-top: 14px; }
.fields-panel label { font-size: 12px; }
.fields-panel textarea { font-size: 13px; }
.list-field, .image-field { display: flex; flex-direction: column; gap: 8px; }
.item-card { border: 1px solid var(--border); border-radius: 9px; padding: 10px; background: #f9fafb; }
.item-card-head { display: flex; justify-content: space-between; align-items: center; }
.item-card label { margin: 8px 0 4px; }
.image-field input[type=file] { font-size: 12px; }
.empty-hint { color: var(--muted); font-size: 13px; padding: 10px 0; }
.preview-panel { display: flex; flex-direction: column; min-width: 0; }
.preview-head { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }
.preview-panel iframe { flex: 1; width: 100%; border: 0; background: #f5f7fb; }

@media (max-width: 1100px) {
  .editor-body { grid-template-columns: 220px 300px 1fr; }
}
@media (max-width: 860px) {
  .sidebar { width: 68px; flex-basis: 68px; padding: 16px 8px; }
  .sidebar nav a { font-size: 0; text-align: center; }
  .sidebar nav a::first-letter { font-size: 18px; }
  .user-chip div, .logout { display: none; }
  .editor-body { grid-template-columns: 1fr; }
  .block-panel, .fields-panel { border-right: 0; border-bottom: 1px solid var(--border); max-height: 320px; }
}

/* 多语言与后台搭建组件 */
.lang-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 8px; }
.lang-grid label { margin: 0; }
.lang-grid code { color: var(--muted); font-size: 11px; }
.site-edit-lang { width: auto; min-width: 116px; padding: 7px 10px !important; }
.widget-preview .content { padding: 18px; max-width: none; }
.widget { margin-bottom: 18px; }
.widget-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.widget-card h2 { font-size: 17px; margin-bottom: 14px; }
.widget-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.widget-stat { background: #f9fafb; border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.widget-stat span { display: block; color: var(--muted); font-size: 12px; }
.widget-stat strong { display: block; font-size: 26px; margin-top: 6px; }
.widget-chart { display: flex; align-items: flex-end; gap: 10px; height: 170px; }
.chart-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.chart-col span { font-size: 11px; color: var(--muted); }
.chart-col i { display: block; width: 72%; min-height: 3px; background: var(--primary); border-radius: 4px 4px 0 0; }
.chart-col small { font-size: 11px; color: var(--muted); margin-top: 6px; }
.widget-muted, .widget-empty { color: var(--muted); }
.widget-notice { padding: 14px 16px; border-radius: 9px; border: 1px solid #bfdbfe; background: #eff6ff; color: #1e40af; }
.widget-notice.success { border-color: #a7f3d0; background: #ecfdf5; color: #047857; }
.widget-notice.warning { border-color: #fde68a; background: #fffbeb; color: #b45309; }
.widget-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 620px; }
.widget-form label { margin: 0; }
.widget-form .btn-primary { grid-column: 1 / -1; justify-self: start; }
.widget-form textarea { grid-column: 1 / -1; }
.widget-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.widget-card .table td, .widget-card .table th { font-size: 12px; }

/* v3：SEO/GEO 面板与 AI 可视化编辑 */
.seo-geo-panel { padding: 18px 20px 30px; border-top: 1px solid var(--border); margin-top: 24px; }
.seo-geo-panel h3 { font-size: 15px; margin: 0 0 14px; }
.seo-geo-panel h3 small { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 8px; }
.seo-geo-panel label small { color: var(--muted); font-weight: 400; }
.ai-visual-panel { border-top: 1px solid var(--border); padding: 18px 24px; background: #f8fafc; }
.ai-visual-panel[hidden] { display: none; }
.ai-visual-panel h3 { margin: 0 0 10px; font-size: 15px; }
.ai-visual-panel h3 small { color: var(--muted); font-weight: 400; margin-left: 8px; }
.ai-visual-panel textarea { max-width: 900px; }
.ai-visual-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.ai-hint { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tabs a { padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 13px; }
.tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.template-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.template-card h3 { margin: 0 0 6px; font-size: 15px; }
.template-card p { color: var(--muted); font-size: 12px; min-height: 34px; }
.template-tag { display: inline-block; font-size: 11px; color: var(--primary); background: #eef2ff; border-radius: 6px; padding: 2px 8px; margin-bottom: 8px; }
.template-card form { margin-top: 12px; }
.domain-status, .badge.on, .badge.off { display: inline-block; font-size: 11px; padding: 3px 8px; border-radius: 6px; }
.domain-status.on, .badge.on { background: #ecfdf5; color: #047857; }
.domain-status.off, .badge.off { background: #f3f4f6; color: #6b7280; }
.code-box { font-family: Consolas, monospace; font-size: 11px; background: #0f172a; color: #e2e8f0; padding: 14px; border-radius: 8px; overflow-x: auto; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; }
.hint a { color: var(--primary); }
input[type=color] { width: 100%; height: 42px; padding: 3px; cursor: pointer; }

/* v5 客服中心 */
.chat-detail { margin-top: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.chat-detail[hidden] { display: none; }
.chat-detail-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-detail-head h3 { margin: 0; font-size: 15px; }
.chat-detail-head small { font-weight: 400; color: var(--muted); font-size: 11px; margin-left: 8px; }
.chat-detail-msgs { max-height: 420px; overflow-y: auto; padding: 16px; background: #f8fafc; }
.chat-msg { display: flex; flex-direction: column; margin-bottom: 12px; }
.chat-msg-role { font-size: 10px; color: var(--muted); margin-bottom: 3px; }
.chat-msg-body { align-self: flex-start; max-width: 80%; padding: 8px 12px; border-radius: 10px; background: #fff; border: 1px solid var(--border); font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.chat-msg-visitor .chat-msg-body { align-self: flex-end; background: #eef2ff; }
.chat-msg-system .chat-msg-body { align-self: center; background: #ecfdf5; color: #047857; font-size: 11px; }
.chat-msg time { font-size: 10px; color: #94a3b8; margin-top: 3px; align-self: flex-end; }
.chat-reply-form { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
.chat-reply-form input[type=text], .chat-reply-form input:not([type]) { flex: 1; }
.faq-item { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; background: #fff; }
.faq-item summary { cursor: pointer; font-size: 13px; font-weight: 500; }
.faq-item summary small { color: var(--muted); font-weight: 400; margin-left: 8px; }
.faq-item form { margin-top: 12px; }
.rating-bars { display: grid; gap: 8px; max-width: 480px; }
.rating-bar { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.rating-bar .bar-track { flex: 1; height: 8px; background: #e5e7eb; border-radius: 4px; overflow: hidden; }
.rating-bar .bar-fill { height: 100%; background: #f59e0b; }
.intent-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-block; padding: 4px 10px; border-radius: 12px; background: #eef2ff; color: #4338ca; font-size: 12px; }

/* v5 数据中心 */
.chart-wrap { background:#fff; border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-bottom:18px; }
.analytics-columns { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; margin-top:18px; }
.analytics-columns h3 { font-size:14px; margin:0 0 10px; }
.dist-list { list-style:none; padding:0; margin:0; }
.dist-list li { display:flex; justify-content:space-between; padding:7px 0; border-bottom:1px dashed var(--border); font-size:13px; }
.dist-list li b { color:var(--primary); }
.code-area { font-family:Consolas,"Courier New",monospace; font-size:12px; line-height:1.5; }
.tabs .btn-ghost { margin-left:auto; }
@media (max-width:900px){ .analytics-columns { grid-template-columns:1fr; } }
