/* ==========================================================================
   GEO 系统 · 全站样式
   ========================================================================== */

:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #fafbfe;
  --border: #e6e8f0;
  --border-strong: #d4d8e6;
  --text: #1a1d29;
  --text-2: #5b6178;
  --text-3: #9096ab;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef0ff;
  --accent: #7c3aed;
  --green: #0f9d58;
  --green-soft: #e7f7ef;
  --amber: #b45309;
  --amber-soft: #fef4e6;
  --red: #d92d20;
  --red-soft: #fdeceb;
  --blue-soft: #e8f1fe;
  --blue: #1d4ed8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .12);
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- 布局 ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .28);
}

.brand-text { line-height: 1.2; }
.brand-text strong { display: block; font-size: 15px; letter-spacing: .3px; }
.brand-text span { font-size: 11px; color: var(--text-3); letter-spacing: .5px; }

.nav { padding: 6px 10px 20px; flex: 1; }
.nav-group { margin-top: 14px; }
.nav-group-title {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: .8px;
  padding: 6px 10px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: background .14s, color .14s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.nav-item .ico { width: 16px; text-align: center; opacity: .85; font-size: 14px; }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-3);
  background: var(--bg);
  border-radius: 20px;
  padding: 1px 7px;
}
.nav-item.active .count { background: #fff; color: var(--brand); }

.sidebar-foot {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  font-size: 11.5px;
  color: var(--text-3);
  line-height: 1.5;
}
.sidebar-foot strong { color: var(--text-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 16px; font-weight: 600; margin: 0; }
.topbar .crumb { font-size: 12px; color: var(--text-3); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-meta { line-height: 1.25; }
.user-meta strong { display: block; font-size: 13px; font-weight: 600; }
.user-meta span { font-size: 11px; color: var(--text-3); }

.content { padding: 24px 26px 48px; flex: 1; }

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 4px; font-size: 20px; font-weight: 650; letter-spacing: -.2px; }
.page-head p { margin: 0; color: var(--text-2); font-size: 13px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .sub { font-size: 12px; color: var(--text-3); }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* ---------- 统计卡 ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 16px 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute; inset: 0 0 auto auto;
  width: 56px; height: 56px;
  background: radial-gradient(circle at 100% 0, rgba(79,70,229,.10), transparent 70%);
}
.stat .label { font-size: 12px; color: var(--text-3); margin-bottom: 6px; }
.stat .value { font-size: 26px; font-weight: 680; letter-spacing: -.5px; line-height: 1.1; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.stat .hint { font-size: 11.5px; color: var(--text-3); margin-top: 6px; }
.stat.brand .value { color: var(--brand); }
.stat.green .value { color: var(--green); }
.stat.amber .value { color: var(--amber); }

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f1f6;
  vertical-align: middle;
}
table.table tr:last-child td { border-bottom: none; }
table.table tr:hover td { background: #fbfbfe; }
table.table td.title-cell { max-width: 420px; }
table.table td.title-cell a { color: var(--text); font-weight: 500; }
table.table td.title-cell a:hover { color: var(--brand); text-decoration: none; }
table.table .muted { color: var(--text-3); font-size: 12px; }
table.table .num { font-variant-numeric: tabular-nums; }

/* ---------- 徽标 ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--bg);
  color: var(--text-2);
  white-space: nowrap;
}
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--blue-soft); color: var(--blue); }
.badge.brand { background: var(--brand-soft); color: var(--brand-dark); }
.badge.gray { background: #f1f2f7; color: var(--text-3); }

.badge.p-zhihu { background: #e8f1fe; color: #1763c8; }
.badge.p-toutiao { background: #fdeceb; color: #cf2b1f; }
.badge.p-baijiahao { background: #e8f1fe; color: #2563eb; }
.badge.p-wechat { background: #e7f7ef; color: #0f9d58; }
.badge.p-website { background: #f1ebfd; color: #7c3aed; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: all .14s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: #c3c8d8; text-decoration: none; }
.btn-primary {
  background: linear-gradient(135deg, #4f46e5, #6d3fe0);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .25);
}
.btn-primary:hover { background: linear-gradient(135deg, #4338ca, #5f36cc); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { color: var(--red); border-color: #f5c6c2; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 表单 ---------- */

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field label .req { color: var(--red); }
.field .help { font-size: 11.5px; color: var(--text-3); margin-top: 5px; }

input[type=text], input[type=password], input[type=email], input[type=date],
input[type=number], input[type=url], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color .14s, box-shadow .14s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
textarea { resize: vertical; min-height: 110px; line-height: 1.7; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.checkline { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.checkline input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--brand); }

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.filter-bar select, .filter-bar input[type=text] { width: auto; min-width: 130px; padding: 7px 10px; font-size: 12.5px; }

/* ---------- Flash ---------- */

.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.flash.success { background: var(--green-soft); color: #0b6e3f; border-color: #c6ebd8; }
.flash.error { background: var(--red-soft); color: #a5120a; border-color: #f6cdc9; }
.flash.info { background: var(--blue-soft); color: var(--blue); border-color: #cddefb; }

/* ---------- 空状态 ---------- */

.empty { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .5; }
.empty p { margin: 0 0 12px; font-size: 13px; }

/* ---------- 进度条 / 占比 ---------- */

.bar { height: 6px; border-radius: 6px; background: #eef0f6; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #4f46e5, #7c3aed); }

.kv { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed #eef0f6; font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv .k { width: 96px; color: var(--text-3); flex: 0 0 96px; }
.kv .v { flex: 1; min-width: 0; word-break: break-word; }

/* ---------- 正文预览 ---------- */

.article-body {
  font-size: 14.5px;
  line-height: 1.85;
  color: #24272f;
  white-space: pre-wrap;
  word-break: break-word;
}
.article-body.mono-narrow { max-height: 520px; overflow-y: auto; padding-right: 8px; }

/* ---------- 登录页 ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  background: #f5f6fb;
}
.login-left {
  flex: 1;
  background: linear-gradient(150deg, #312e81 0%, #4f46e5 45%, #7c3aed 100%);
  color: #fff;
  padding: 56px 54px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: "";
  position: absolute;
  width: 520px; height: 520px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .07);
  right: -180px; bottom: -180px;
}
.login-left::after {
  content: "";
  position: absolute;
  width: 320px; height: 320px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
  right: 40px; top: -120px;
}
.login-left .brand { padding: 0; position: relative; }
.login-left .brand-mark { background: rgba(255,255,255,.18); box-shadow: none; backdrop-filter: blur(6px); }
.login-left .brand-text strong { color: #fff; }
.login-left .brand-text span { color: rgba(255,255,255,.6); }
.login-hero { position: relative; z-index: 1; }
.login-hero h1 { font-size: 34px; line-height: 1.35; margin: 0 0 16px; font-weight: 650; letter-spacing: -.5px; }
.login-hero p { font-size: 14.5px; color: rgba(255,255,255,.75); max-width: 460px; margin: 0 0 26px; }
.login-points { list-style: none; padding: 0; margin: 0; }
.login-points li {
  font-size: 13.5px;
  color: rgba(255,255,255,.85);
  padding-left: 22px;
  position: relative;
  margin-bottom: 10px;
}
.login-points li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: #a5f3c8;
  font-weight: 700;
}
.login-left .foot { font-size: 12px; color: rgba(255,255,255,.45); position: relative; z-index: 1; }

.login-right {
  width: 460px;
  flex: 0 0 460px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: #fff;
}
.login-box { width: 100%; max-width: 330px; }
.login-box h2 { font-size: 22px; margin: 0 0 6px; font-weight: 650; }
.login-box > p { color: var(--text-3); font-size: 13px; margin: 0 0 26px; }
.login-box .field { margin-bottom: 14px; }
.login-box .btn { margin-top: 6px; padding: 10px; }
.login-hint {
  margin-top: 20px;
  font-size: 12px;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.7;
}
.login-hint code { color: var(--brand); font-size: 12px; }

/* ---------- 工具类 ---------- */

.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.mt-0 { margin-top: 0; } .mt-12 { margin-top: 12px; } .mt-18 { margin-top: 18px; }
.mb-0 { margin-bottom: 0; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.w-100 { width: 100%; }
.text-right { text-align: right; }

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- 权限矩阵 ---------- */

.perm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.perm-table th, .perm-table td { padding: 9px 12px; border-bottom: 1px solid #f0f1f6; text-align: left; }
.perm-table th { font-size: 12px; color: var(--text-3); font-weight: 600; background: var(--surface-2); }
.perm-table td.center, .perm-table th.center { text-align: center; width: 96px; }
.perm-table input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--brand); }
.perm-table tr.group-row td { background: #fafbff; font-weight: 600; font-size: 12.5px; color: var(--brand-dark); }

/* ---------- 规则页 ---------- */

.rule-list { counter-reset: rule; list-style: none; padding: 0; margin: 0; }
.rule-list > li {
  position: relative;
  padding: 14px 16px 14px 52px;
  border-bottom: 1px solid #f0f1f6;
}
.rule-list > li:last-child { border-bottom: none; }
.rule-list > li::before {
  counter-increment: rule;
  content: counter(rule);
  position: absolute;
  left: 16px; top: 15px;
  width: 24px; height: 24px;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.rule-list h4 { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; }
.rule-list p { margin: 0; font-size: 12.5px; color: var(--text-2); line-height: 1.7; }

@media (max-width: 1080px) {
  .login-left { display: none; }
  .login-right { width: 100%; flex: 1; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  :root { --sidebar-w: 64px; }
  .brand-text, .nav-group-title, .nav-item span.txt, .nav-item .count, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 0 14px; }
}

/* ==========================================================================
   AI 文案助手（新增）
   ========================================================================== */

.hidden { display: none !important; }
.spacer { flex: 1; }
.text-red { color: var(--red); }
.text-green { color: var(--green); }

.field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.field-head label { margin: 0; }

.btn-ai {
  background: linear-gradient(135deg, #6d5cf0, #8b5cf6);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(109, 92, 240, .28);
}
.btn-ai:hover { background: linear-gradient(135deg, #5b4ae0, #7c4ef0); color: #fff; border-color: transparent; }

.table.compact td, .table.compact th { padding: 8px 12px; font-size: 12.5px; }

/* 分段控件 */
.seg {
  display: inline-flex;
  padding: 3px;
  background: #f1f2f7;
  border-radius: 10px;
  gap: 2px;
  margin-bottom: 14px;
}
.seg-btn {
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.active {
  background: var(--surface);
  color: var(--brand-dark);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* 抽屉 */
.drawer { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.drawer-mask {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 40, .34);
  opacity: 0;
  transition: opacity .22s ease;
}
.drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 580px;
  max-width: 100%;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  transition: transform .26s cubic-bezier(.4, 0, .2, 1);
}
.drawer.open { pointer-events: auto; }
.drawer.open .drawer-mask { opacity: 1; }
.drawer.open .drawer-panel { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fbfbff, #fff);
}
.drawer-head strong { font-size: 15px; }
.drawer-sub { font-size: 11.5px; color: var(--text-3); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.dot.ok { background: var(--green); }
.dot.warn { background: #e0a112; }

.drawer-body {
  padding: 18px 20px 28px;
  overflow-y: auto;
  flex: 1;
}

/* 变量胶囊 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  cursor: pointer;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--brand-dark);
  line-height: 1.3;
}
.chip:hover { border-color: var(--brand); background: var(--brand-soft); }
.chip-sub { font-family: inherit; font-size: 10.5px; color: var(--text-3); }

code.inline {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  padding: 2px 6px;
  border-radius: 5px;
}

.preview {
  margin: 14px 0 0;
  padding: 14px;
  background: #0f1222;
  color: #d7dbf0;
  border-radius: 10px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 380px;
  overflow: auto;
}

/* 生成结果 */
.ai-result {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.ai-result textarea {
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif;
  font-size: 13px;
  line-height: 1.75;
  margin-bottom: 10px;
}
