/* AI 会员管家 · 总部后台 — 桌面端优先，移动端兼容 */
/* 注：与门店管家独立运行，数据存浏览器 localStorage（ab_hq），不依赖后端。 */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --card: #ffffff;
  --line: #f0e6df;
  --line2: #e7d8cd;
  --ink: #0f172a;
  --ink2: #475569;
  --mut: #94a3b8;
  --blue: #f97316;
  --blue-d: #ea580c;
  --blue-soft: #ffedd5;
  --green: #16a34a;
  --orange: #f59e0b;
  --red: #ef4444;
  --shadow: 0 6px 24px rgba(15, 23, 42, .08);
}
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #faf6f3; color: var(--ink); -webkit-font-smoothing: antialiased; line-height: 1.5;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; }

/* ===== 登录 ===== */
/* 总部门登录页：手机尺寸满屏 + 大字号，方便手机端管理员直接登录 */
.hq-login {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: stretch;
  padding: 0;
  background: linear-gradient(135deg, #f97316 0%, #c2410c 100%);
}
.hq-login-card {
  background: #fff; border-radius: 24px;
  padding: 40px 28px 36px;
  width: 100%;
  max-width: 480px;
  margin: auto;
  align-self: center;
  box-shadow: 0 20px 60px rgba(15,23,42,.35);
}
.hq-login-card h1 {
  margin: 0 0 4px; font-size: 20px; font-weight: 800; color: var(--ink);
}
.hq-login-card .brand-title {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 8px; font-size: 36px;
  color: #ea580c;
  letter-spacing: .02em; line-height: 1;
  font-family: 'Source Han Serif SC', 'Source Han Serif CN', 'Noto Serif SC', 'Noto Serif CJK SC', 'Songti SC', 'STSong', 'SimSun', 'Songti TC', serif;
  font-weight: 900;
}
.hq-login-card .brand-title .brand-icon {
  width: 36px; height: 36px; flex-shrink: 0; color: #ea580c;
  filter: drop-shadow(0 2px 4px rgba(234,88,12,.25));
}
.hq-login-card .brand-sub { margin: 0 0 28px; color: var(--ink2); font-size: 15px; }
.hq-login-card label { display: block; font-size: 14px; color: var(--ink2); font-weight: 600; margin-bottom: 8px; }
.hq-login-card input {
  width: 100%; height: 56px; border-radius: 14px; border: 1.5px solid var(--line);
  background: #fff; padding: 0 16px; font-size: 18px; outline: none; margin-bottom: 18px;
  letter-spacing: .04em;
}
.hq-login-card input:focus { border-color: var(--blue); }
.hq-login-card button {
  width: 100%; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, #ea580c 0%, #c2410c 100%);
  color: #fff;
  font-size: 18px; font-weight: 700;
  box-shadow: 0 8px 18px rgba(234,88,12,.35);
  transition: transform .15s ease, box-shadow .15s ease, background .2s ease;
  letter-spacing: .05em;
}
.hq-login-card button:hover {
  background: linear-gradient(135deg, #fb923c 0%, #ea580c 100%);
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(234,88,12,.45);
}
.hq-login-card button:active { transform: translateY(0); }
.hq-login-card .hint { font-size: 12px; color: var(--mut); margin-top: 14px; text-align: center; }
.hq-login-card .hint b { color: var(--blue-d); }
.hq-login-card .login-policy {
  font-size: 12.5px; color: var(--mut); margin-top: 20px; line-height: 1.7;
  text-align: center;
}
.hq-login-card .login-policy a { color: var(--blue-d); text-decoration: none; }
.hq-login-card .login-policy a:hover { text-decoration: underline; }

/* ===== 主体布局 ===== */
.hq {
  min-height: 100vh; display: grid; grid-template-rows: auto 1fr;
}
.hq-top {
  background: linear-gradient(135deg, #ea580c, #c2410c);
  color: #fff; padding: 14px 22px; display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 4px 16px rgba(15,23,42,.2);
}
.hq-top .brand { display: flex; align-items: center; gap: 12px; }
.hq-top .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #fb923c, #f97316);
  display: grid; place-items: center; font-size: 20px;
  box-shadow: 0 4px 12px rgba(249,115,22,.4);
}
.hq-top .brand h1 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: .04em; }
.hq-top .brand p { margin: 0; font-size: 11.5px; opacity: .8; letter-spacing: .02em; }
.hq-top .actions { display: flex; gap: 8px; }
.hq-top .actions button {
  font-size: 13px; color: #fff; background: rgba(255,255,255,.15);
  padding: 8px 14px; border-radius: 9px; border: 1px solid rgba(255,255,255,.22);
}

.hq-main { padding: 22px 22px 60px; max-width: 1180px; margin: 0 auto; width: 100%; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card {
  background: #fff; border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow); border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.stat-card .k { font-size: 13px; color: var(--ink2); }
.stat-card .n { font-size: 30px; font-weight: 800; margin-top: 8px; line-height: 1; letter-spacing: -.01em; }
.stat-card .s { font-size: 11.5px; color: var(--mut); margin-top: 6px; }
.stat-card.blue .n { color: var(--blue); }
.stat-card.green .n { color: var(--green); }
.stat-card.orange .n { color: var(--orange); }
.stat-card.purple .n { color: #7c3aed; }
.stat-card.teal .n { color: #0d9488; }

.card {
  background: #fff; border-radius: 14px; padding: 18px 20px; box-shadow: var(--shadow);
  margin-bottom: 18px; border: 1px solid var(--line);
}
.card-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; flex-wrap: wrap; }
.card-h h2 { margin: 0; font-size: 15.5px; font-weight: 800; }
.card-h .sub { font-size: 12px; color: var(--mut); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 14px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: var(--blue); color: #fff; box-shadow: 0 4px 12px rgba(249,115,22,.25);
}
.btn.ghost { background: #fff; color: var(--blue); border: 1.5px solid var(--line); box-shadow: none; }
.btn.block { background: #fee2e2; color: var(--red); box-shadow: none; }
.btn.sm { height: 32px; font-size: 12.5px; padding: 0 10px; border-radius: 8px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 12px; text-align: left; font-size: 13.5px; border-bottom: 1px solid var(--line); }
th { font-weight: 700; color: var(--ink2); background: #faf5f1; font-size: 12.5px; }
tr:last-child td { border-bottom: none; }
td .badge {
  display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 6px; font-weight: 600;
}
td .badge.green { background: #dcfce7; color: #166534; }
td .badge.gray { background: #faf6f3; color: var(--ink2); }

/* ===== AI 大模型统一接入 ===== */
.mine-row { display:flex; justify-content:space-between; align-items:center; padding:10px 0; border-bottom:1px dashed var(--line); font-size:13.5px; }
.mine-row:last-child { border-bottom:none; }
.mine-row .mk { color:var(--ink2); font-weight:600; }
.mine-row .mv { color:var(--ink); font-weight:500; text-align:right; }
td .badge.red { background: #fee2e2; color: #b91c1c; }
td .mono { font-family: 'SF Mono', Menlo, Consolas, monospace; color: var(--blue-d); font-weight: 700; }

.ad-preview {
  border-radius: 14px;
  background: linear-gradient(135deg, #9a3412, #f97316);
  color: #fff; padding: 22px 18px; text-align: center;
  box-shadow: 0 12px 28px rgba(234,88,12,.32);
  position: relative; overflow: hidden;
}
.ad-preview.has-image { padding: 36px 18px; min-height: 120px; }
.ad-preview .ad-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.15) 0%, rgba(0,0,0,.55) 100%); }
.ad-preview .ad-t { font-size: 13px; opacity: .85; }
.ad-preview .ad-c { font-size: 22px; font-weight: 800; margin-top: 6px; line-height: 1.4; }
.ad-preview .ad-s { font-size: 12px; opacity: .75; margin-top: 10px; }
.ad-preview .ad-btn {
  display: inline-block; margin-top: 14px; padding: 8px 18px; border-radius: 20px;
  background: rgba(255,255,255,.95); color: var(--blue-d); font-weight: 700; font-size: 13.5px;
}

/* 开屏编辑器 */
.ad-editor-dialog .ad-editor-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.ad-editor-dialog .ad-editor-row:last-child { margin-bottom: 0; }
.ad-editor-dialog .ad-editor-row label { font-size: 13px; color: var(--ink2); font-weight: 600; }
.ad-editor-dialog input[type="text"],
.ad-editor-dialog textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; font-size: 13.5px; font-family: inherit; margin-bottom: 0; }
.ad-editor-dialog textarea { min-height: 78px; resize: vertical; }

/* 全屏开屏弹窗 */
/* 开屏改为「居中手机预览」：像一台手机，不再铺满整屏 */
.splash-mask { padding: 20px; }
.splash-card {
  width: min(390px, 100%);
  aspect-ratio: 9 / 19.5;          /* 标准手机竖屏比例 */
  max-height: 88vh;
  background: linear-gradient(135deg,#9a3412 0%, #f97316 100%); color: #fff;
  display: flex; flex-direction: column; justify-content: space-between;
  text-align: center; padding: 56px 26px 36px;
  position: relative; overflow: hidden;
  border-radius: 30px;
  box-shadow: 0 30px 80px rgba(0,0,0,.45);
  animation: splash-in .35s cubic-bezier(.2,.8,.2,1);
}
.splash-card.has-image { padding: 70px 26px 40px; }
/* 图片模式：把背景图抽到独立层，方便单独控制亮度 / 滤镜不影响文案 */
.splash-bg {
  position: absolute; inset: 0; z-index: 0;
  background-size: cover; background-position: center; background-repeat: no-repeat;
  /* 原生亮度呈现，按用户要求去除 .8 调暗滤镜；保持图片原始色彩 */
  filter: none;
}
/* 透明度关闭：去除渐变暗罩，让海报原色直接呈现 */
.splash-card .ad-shade { display: none; }
/* 文案/按钮层叠在图上（.splash-close-x 自身已是 absolute+z-index:10，无须再覆盖） */
.splash-inner, .splash-foot { position: relative; z-index: 2; }
/* 有图模式：隐藏 demo 标签（开屏广告 + 全部门店共用），让图片本身成为纯净的海报画面 */
.splash-card.has-image .splash-tag,
.splash-card.has-image .splash-sub { display: none; }
.splash-inner { display: flex; flex-direction: column; gap: 16px; align-items: center; justify-content: center; flex: 1; }
.splash-tag { display: inline-block; padding: 5px 14px; border-radius: 100px; background: rgba(255,255,255,.18); font-size: 12px; letter-spacing: .04em; }
.splash-title { font-size: 28px; font-weight: 900; line-height: 1.3; text-shadow: 0 2px 16px rgba(0,0,0,.45), 0 1px 2px rgba(0,0,0,.3); }
.splash-content { font-size: 17px; line-height: 1.7; max-width: 340px; opacity: .96; }
.splash-btn { display: inline-block; margin-top: 14px; padding: 12px 36px; border-radius: 100px; background: #fff; color: var(--blue-d); font-weight: 800; font-size: 15px; box-shadow: 0 12px 30px rgba(0,0,0,.18); }
.splash-sub { font-size: 12.5px; opacity: .7; margin-top: 18px; }
.splash-foot { display: flex; align-items: center; justify-content: center; gap: 18px; position: relative; }
.splash-close { padding: 11px 28px; border-radius: 100px; background: rgba(255,255,255,.95); color: var(--blue-d); font-weight: 800; font-size: 14px; border: none; cursor: pointer; }
.splash-link { background: none; border: none; color: rgba(255,255,255,.7); font-size: 12.5px; cursor: pointer; text-decoration: underline; }
.splash-close-x {
  position: absolute; top: max(18px, env(safe-area-inset-top, 18px)); right: 18px;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; line-height: 1; border: none; cursor: pointer;
  z-index: 10; backdrop-filter: blur(4px);
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
  transition: transform .15s, background .15s;
  padding: 0;
}
.splash-close-x:hover { background: rgba(0,0,0,.7); transform: scale(1.05); }
.splash-close-x:active { transform: scale(.95); }
@keyframes splash-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }

/* 开屏手机端适配：HQ 预览在桌面是"居中手机"造型，在手机端则自适应不溢出 */
@media (max-width: 640px) {
  .splash-mask { padding: 8px; }
  .splash-card {
    width: 100%;
    max-width: 360px;
    max-height: 86vh;
    border-radius: 22px;
    padding: 44px 22px 30px;
  }
  .splash-card.has-image { padding: 56px 22px 34px; }
  .splash-title { font-size: 22px; }
  .splash-content { font-size: 14.5px; max-width: 280px; }
  .splash-btn { padding: 11px 30px; font-size: 14px; }
  .splash-close { padding: 10px 26px; font-size: 13.5px; }
  .splash-close-x { width: 36px; height: 36px; font-size: 19px; top: max(12px, env(safe-area-inset-top, 12px)); right: 12px; }
}
/* 极窄屏（≤360px，老款小屏手机） */
@media (max-width: 360px) {
  .splash-card { max-width: 100%; border-radius: 16px; padding: 40px 18px 26px; }
  .splash-title { font-size: 20px; }
  .splash-content { font-size: 13.5px; }
}

/* ===== 知识库管理（AI 大脑） ===== */
.kb-tabs { display: flex; gap: 8px; background: #faf6f3; padding: 5px; border-radius: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.kb-tab { flex: 1; min-width: 80px; text-align: center; padding: 9px 6px; border-radius: 9px; font-size: 13px; font-weight: 650; color: var(--ink2); cursor: pointer; }
.kb-tab.on { background: #fff; color: var(--blue); box-shadow: 0 2px 8px rgba(15,23,42,.1); }
.kb-badge { display: inline-block; min-width: 18px; padding: 0 5px; font-size: 11px; font-weight: 800; color: #fff; background: #b45309; border-radius: 9px; margin-left: 4px; }
.kb-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.kb-toolbar input { flex: 1; min-width: 160px; border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 13px; background: #fff; }
.kb-toolbar select { border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 13px; background: #fff; }
.kb-table th, .kb-table td { font-size: 13px; padding: 10px 11px; }
.kb-cat-pill { display: inline-block; font-size: 11px; font-weight: 700; color: #fff; background: var(--blue); padding: 2px 8px; border-radius: 7px; }
.kb-tag-learned { font-size: 10.5px; color: #0d9488; background: #ccfbf1; padding: 1px 6px; border-radius: 6px; font-weight: 700; margin-left: 6px; }
.kb-pending { border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; margin-bottom: 12px; background: #fff; }
.kb-p-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.kb-p-head b { font-size: 14px; }
.kb-by { font-size: 11.5px; color: var(--mut); margin-left: auto; }
.kb-p-content { font-size: 13px; color: var(--ink2); line-height: 1.65; white-space: normal; max-height: 220px; overflow-y: auto; }
.kb-p-content + .kb-tags { margin-top: 8px; }
.kb-p-act { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.kb-tags { font-size: 11.5px; color: #f97316; }
.kb-stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kb-stat-box { background: #faf5f1; border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.kb-stat-box .n { font-size: 28px; font-weight: 800; color: var(--blue); }
.kb-stat-box .k { font-size: 12px; color: var(--mut); margin-top: 6px; }
.kb-sub-h { font-size: 13.5px; font-weight: 700; color: var(--ink); margin: 6px 0 10px; }
.kb-cat-dist { display: flex; flex-direction: column; gap: 6px; }
.kb-stat-row { display: flex; justify-content: space-between; padding: 9px 13px; background: #faf5f1; border-radius: 9px; font-size: 13px; border: 1px solid var(--line); }
.kb-stat-row b { color: var(--blue); }

/* ===== 弹窗 ===== */
/* 透明度关闭：背景遮罩改为几乎不透，避免背后页面"透过来"干扰当前弹窗；splash 全屏弹窗另设专属样式 */
.mask {
  position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .88);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
/* 全屏开屏弹窗：保留略深遮罩以聚焦，但 splash-card 本身已满屏，实际看不见背景 */
.splash-mask { background: rgba(15, 23, 42, .55); padding: 16px; }
.dialog {
  background: #fff; border-radius: 16px; padding: 22px;
  width: 100%; max-width: 460px; box-shadow: 0 24px 60px rgba(15,23,42,.3);
  animation: pop .22s ease;
  /* 长字段弹窗：flex 三段布局（head / 滚动 body / 底部按钮）· 短字段自然不出现滚动条 */
  max-height: 92vh;
  display: flex; flex-direction: column; overflow: hidden;
}
@keyframes pop { from { opacity: 0; transform: translateY(20px) scale(.96);} to { opacity: 1; transform: none; } }
.dialog h3 { margin: 0 0 4px; font-size: 17px; font-weight: 800; }
.dialog .dsub { font-size: 12.5px; color: var(--mut); margin-bottom: 16px; }
.dialog .body {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  /* 内容超出时给右侧一个喘息空间，避免 input 紧贴滚动条 */
  padding-right: 2px;
  -webkit-overflow-scrolling: touch;
}
.dialog .body::-webkit-scrollbar { width: 6px; }
.dialog .body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.dialog .body::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.dialog .body::-webkit-scrollbar-track { background: transparent; }
.dialog .body .section-hint {
  font-size: 12px; color: var(--blue); font-weight: 700;
  background: #fff7ed; border: 1px dashed #fdba74; border-radius: 8px;
  padding: 6px 10px; margin: 4px 0 10px; display: flex; align-items: center; gap: 4px;
}
.dialog label { display: block; font-size: 12.5px; color: var(--ink2); margin-bottom: 5px; font-weight: 600; }
.dialog input, .dialog textarea, .dialog select {
  width: 100%; height: 42px; border-radius: 10px; border: 1.5px solid var(--line);
  background: #fff; padding: 0 12px; font-size: 14px; outline: none; margin-bottom: 12px;
}
.dialog textarea { height: 92px; padding: 10px 12px; resize: none; line-height: 1.5; }
.dialog input:focus, .dialog textarea:focus, .dialog select:focus { border-color: var(--blue); }
.dialog .foot {
  display: flex; gap: 10px;
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--line);
  background: #fff;
  flex: 0 0 auto;
}
.dialog .foot .btn { flex: 1; }
@media (max-width: 640px) {
  .mask { padding: 8px; }
  .dialog { max-height: 96vh; padding: 18px; }
}

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 9999;
  background: rgba(15,23,42,.92); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

@media (max-width: 640px) {
  .hq-top { padding: 12px 14px; }
  .hq-main { padding: 14px 12px 60px; }
  th, td { padding: 9px 8px; font-size: 12.5px; }
}

/* ===== 自动预约机制 · 进化数据 ===== */
.mech-card .evo-cell {
  background: #fff; border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 10px; text-align: center;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.mech-card .evo-cell .ec-n { font-size: 24px; font-weight: 800; color: var(--ink); line-height: 1.2; }
.mech-card .evo-cell .ec-k { font-size: 12px; color: var(--ink2); margin-top: 2px; }
.mech-card .mech-run { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 14px; }
.mech-card code { background: #faf6f3; padding: 1px 6px; border-radius: 4px; font-size: 12px; color: #475569; }
@media (max-width: 640px) {
  .mech-card .evo-cell .ec-n { font-size: 18px; }
  .mech-card .evo-cell .ec-k { font-size: 11px; }
  /* 6 原则行的内容太挤：移动端允许自适应换行 */
  .mech-card .mech-rule-row { font-size: 11.5px; flex-wrap: wrap; }
}

/* 大品牌质感：主标题用思源宋体 */
.bt-top .t-name, .card-h .ttl, .hero .h-sys, .home-topbar .ht-store,
.hq-top .brand h1, .card-h h2, .dialog h3, .ad-preview .ad-c {
  font-family: 'Source Han Serif SC','Source Han Serif CN','Noto Serif SC','Noto Serif CJK SC','Songti SC','STSong','SimSun',serif;
}
