:root {
  --bg: #eef2f7;
  --bg2: #f7f9fc;
  --card: #ffffff;
  --primary: #0f9d8f;
  --primary-d: #0c7e73;
  --primary-soft: #e6f7f4;
  --accent: #3b6fe0;
  --text: #1c2b3a;
  --muted: #74879b;
  --line: #e6ecf3;
  --ok: #15a866;
  --warn: #e08a1e;
  --danger: #e0533d;
  --shadow-sm: 0 1px 3px rgba(28,43,58,.06);
  --shadow: 0 6px 22px rgba(28,43,58,.08);
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(15,157,143,.12), rgba(15,157,143,0) 62%),
    radial-gradient(900px 480px at 100% 0%, rgba(59,111,224,.07), rgba(59,111,224,0) 60%),
    linear-gradient(180deg, #eaf2f3 0%, #eef2f7 220px, #f4f7fa 100%);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
}
body::after {
  content: "";
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: 52vh;
  background: url("../images/bg.jpg") center bottom / contain no-repeat;
  filter: blur(9px) brightness(1.04);
  opacity: .35;
  pointer-events: none;
  z-index: 0;
  transform: translateZ(0);
}
.wrap, .topbar, .admin-wrap { position: relative; z-index: 1; }
.topbar {
  background: linear-gradient(120deg, var(--primary), var(--primary-d));
  color: #fff;
  padding: 15px 24px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 14px rgba(15,157,143,.25);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; letter-spacing: .3px; }
.topbar .sub { font-size: 12px; opacity: .85; margin-top: 2px; font-weight: 400; }
.topbar a {
  color: #eafff9; text-decoration: none; font-size: 13px;
  border: 1px solid rgba(255,255,255,.45); padding: 6px 14px; border-radius: 8px; transition: .15s;
}
.topbar a:hover { background: rgba(255,255,255,.15); }

.wrap { max-width: 760px; margin: 26px auto 24px; padding: 22px; background: rgba(255,255,255,0.95); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.admin-wrap { max-width: 1200px; background: rgba(255,255,255,0.92); min-height: calc(100vh - 52px); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 22px 8px; }

/* 卡片 */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 22px; margin-bottom: 18px; box-shadow: var(--shadow-sm);
}
.section { margin-bottom: 18px; }
.section:last-child { margin-bottom: 0; }
.section-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 1px dashed var(--line);
}
.section-head .badge {
  width: 24px; height: 24px; border-radius: 7px; background: var(--primary-soft); color: var(--primary-d);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: none;
}
.section-head h3 { font-size: 15px; margin: 0; font-weight: 600; }
.section-head .desc { font-size: 12px; color: var(--muted); margin-left: auto; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.field .hint-sm { font-size: 11.5px; color: #9aa9ba; }
.field input, .field textarea, .field select {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 14px; color: var(--text); background: #fbfdff; font-family: inherit; transition: .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-soft);
}
.field textarea { resize: vertical; min-height: 140px; line-height: 1.6; }
.full { grid-column: 1 / -1; }

/* 数字步进器 */
.stepper-wrap { display: flex; align-items: stretch; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; background: #fbfdff; transition: .15s; }
.stepper-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); background: #fff; }
.stepper-input { border: none !important; box-shadow: none !important; text-align: center; padding: 10px 4px; -moz-appearance: textfield; flex: 1; background: transparent !important; font-weight: 600; font-size: 15px; }
.stepper-input::-webkit-outer-spin-button, .stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.step-btn { width: 40px; border: none; background: #f1f5f9; color: var(--primary-d); font-size: 20px; cursor: pointer; flex: none; transition: .12s; font-weight: 600; }
.step-btn:hover { background: var(--primary-soft); }
.step-btn:active { transform: scale(.94); }

/* 按钮 */
.btn {
  background: var(--primary); color: #fff; border: none; border-radius: 10px;
  padding: 11px 22px; font-size: 14px; cursor: pointer; font-family: inherit; font-weight: 600;
  transition: .15s; box-shadow: 0 2px 8px rgba(15,157,143,.25);
}
.btn:hover { background: var(--primary-d); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--primary-d); border: 1.5px solid var(--primary); box-shadow: none; }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.sm { padding: 6px 13px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { background: var(--danger); box-shadow: 0 2px 8px rgba(224,83,61,.25); }
.btn.danger:hover { background: #c4422f; }
.btn.warn { background: var(--warn); box-shadow: 0 2px 8px rgba(224,138,30,.25); }
.btn.warn:hover { background: #c77518; }

/* 底部固定操作栏 */
.actionbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: rgba(255,255,255,.92); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 12px 16px;
  display: flex; align-items: center; gap: 14px; justify-content: center;
  box-shadow: 0 -4px 18px rgba(28,43,58,.06);
}
.actionbar .inner { max-width: 760px; width: 100%; display: flex; align-items: center; gap: 14px; }
.actionbar .savehint { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.actionbar .savehint .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.actionbar .spacer { flex: 1; }

/* Toast */
.toast {
  position: fixed; left: 50%; top: 22px; transform: translateX(-50%) translateY(-20px);
  background: #1c2b3a; color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 60; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #127a4f; }
.toast.err { background: #c4422f; }

/* 图片预览 */
.preview { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.preview .thumb { position: relative; }
.preview img { width: 78px; height: 78px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.preview .del { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; background: var(--danger); color: #fff; border: none; cursor: pointer; font-size: 13px; line-height: 1; display: grid; place-items: center; }
.dropzone { border: 1.5px dashed var(--line); border-radius: 12px; padding: 26px; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; background: var(--bg2); }
.dropzone:hover { border-color: var(--primary); color: var(--primary-d); background: var(--primary-soft); }
.dropzone b { color: var(--primary-d); }

/* 管理端 */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); }
.toolbar .field { min-width: 135px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: #fff; color: var(--muted); border-radius: 20px; padding: 6px 14px; font-size: 12.5px; cursor: pointer; transition: .15s; }
.chip:hover { border-color: var(--primary); color: var(--primary-d); }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.summary { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--primary); opacity: .85; }
.stat .n { font-size: 23px; font-weight: 700; color: var(--text); }
.stat .t { font-size: 12px; color: var(--muted); margin-top: 2px; }

.summary-title { font-size: 13px; font-weight: 600; color: var(--text); margin: 4px 2px 10px; display: flex; align-items: baseline; gap: 8px; }
.summary-title .sub { font-size: 12px; font-weight: 400; color: var(--muted); }
.summary.avg { margin-bottom: 20px; }
.summary.avg .stat { background: linear-gradient(180deg, #f4fbfa, #ffffff); border-color: #d9eeeb; }
.summary.avg .stat::before { background: var(--accent); }
.summary.row-orange .stat::before { background: var(--warn); }
.summary.row-orange .stat:last-child { background: #fff7e6; }
#groupTbl thead th:last-child { background: #fff0d6; color: #b86e00; }
.summary.avg .stat .n { font-size: 21px; color: var(--primary-d); }

.tablecard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow-x: auto; }
table { width: 100%; min-width: 1020px; border-collapse: collapse; font-size: 13px; }
th.pub, td.pub { background: #f3f9fb; }
th.pub { background: #e7f3f7; color: var(--primary-d); }

/* 客服端比率显示 */
.rate-box { display: flex; flex-direction: column; justify-content: center; background: #f3f9fb; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 13px; min-height: 42px; }
.rate { font-size: 19px; font-weight: 700; color: var(--primary-d); line-height: 1.2; }
.rate-formula { font-size: 11px; color: #9aa9ba; margin-top: 2px; }
th, td { padding: 11px 12px; text-align: center; border-bottom: 1px solid var(--line); }
th { background: #f3f6fa; color: var(--muted); font-weight: 600; position: sticky; top: 0; font-size: 12.5px; }
tbody tr:hover { background: #f7fbfa; }
td.l, th.l { text-align: left; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.pill.yes { background: #e6f7ef; color: var(--ok); }
.pill.no { background: #f1f4f7; color: #9aa9ba; }
.rowthumb { width: 34px; height: 34px; object-fit: cover; border-radius: 7px; border: 1px solid var(--line); vertical-align: middle; cursor: zoom-in; }
td.below { color: var(--danger); font-weight: 600; }

.modal-bg { position: fixed; inset: 0; background: rgba(15,30,45,.55); display: none; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow: auto; z-index: 50; }
.modal-bg.show { display: flex; }
.modal { background: #fff; border-radius: 14px; max-width: 780px; width: 100%; padding: 24px; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .close { float: right; cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; }
.modal .close:hover { color: var(--text); }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; margin-bottom: 16px; }
.detail-item { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.detail-item .k { font-size: 12px; color: var(--muted); }
.detail-item .v { font-size: 16px; font-weight: 700; margin-top: 2px; }
.chatbox { background: #f6f8fb; border: 1px solid var(--line); border-radius: 10px; padding: 14px; white-space: pre-wrap; font-size: 13px; max-height: 320px; overflow: auto; line-height: 1.7; }
.imgs { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.imgs img { max-width: 210px; max-height: 210px; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

.login-note { font-size: 12px; color: var(--muted); margin-top: 8px; }
@media (max-width: 880px) {
  .summary { grid-template-columns: repeat(3, 1fr); }
  .grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
