/* ==========================================================================
   LiveDesk · 后台管理样式
   ========================================================================== */
body.admin { background: #f2f4fa; }
.admin-shell { display: grid; grid-template-columns: 244px 1fr; min-height: 100vh; }

/* ---------------------------------------------------------------- 侧栏 */
.a-side {
  background: #0b1020; color: #cbd5e1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.a-side::before { content: ""; position: absolute; width: 320px; height: 320px; border-radius: 50%; background: radial-gradient(circle, rgba(99, 102, 241, .35), transparent 65%); top: -140px; left: -100px; pointer-events: none; }
.a-brand { display: flex; align-items: center; gap: 10px; padding: 20px 20px 18px; position: relative; }
.a-brand .brand-logo { width: 32px; height: 32px; border-radius: 9px; }
.a-brand b { color: #fff; font-size: 15px; letter-spacing: -.02em; }
.a-brand small { display: block; font-size: 10px; color: #64748b; letter-spacing: .1em; text-transform: uppercase; }
.a-nav { flex: 1; overflow-y: auto; padding: 6px 12px 20px; position: relative; }
.a-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); }
.a-group { font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: #475569; padding: 16px 12px 8px; font-weight: 700; }
.a-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: #a8b4c8; font-size: 13px; font-weight: 500; cursor: pointer; transition: .16s; margin-bottom: 2px; position: relative; }
.a-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.a-link.on { background: linear-gradient(90deg, rgba(99, 102, 241, .28), rgba(139, 92, 246, .1)); color: #fff; }
.a-link.on::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2.5px; border-radius: 2px; background: #818cf8; }
.a-link svg { flex: none; opacity: .85; }
.a-link .count { margin-left: auto; background: rgba(239, 68, 68, .9); color: #fff; font-size: 10.5px; padding: 1px 7px; border-radius: 99px; font-weight: 700; }
.a-side-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .07); }
.a-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 10px; cursor: pointer; }
.a-user:hover { background: rgba(255, 255, 255, .06); }
.a-user .nm { color: #fff; font-size: 12.5px; font-weight: 600; }
.a-user .rl { font-size: 10.5px; color: #64748b; }

/* ---------------------------------------------------------------- 主区 */
.a-main { min-width: 0; display: flex; flex-direction: column; }
.a-top { height: 62px; background: rgba(255, 255, 255, .86); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 40; }
.a-top h1 { font-size: 16px; letter-spacing: -.02em; }
.a-top .crumb { font-size: 11.5px; color: var(--muted-2); }
.a-search { margin-left: auto; position: relative; }
.a-search input { width: 240px; height: 36px; border-radius: 10px; border: 1px solid var(--line); padding: 0 12px 0 34px; background: #f7f9fd; outline: none; font-size: 12.5px; }
.a-search input:focus { background: #fff; border-color: var(--brand); box-shadow: var(--ring); }
.a-search svg { position: absolute; left: 11px; top: 10px; color: var(--muted-2); }
.a-content { padding: 22px 24px 40px; flex: 1; min-width: 0; }
.a-view { display: none; }
.a-view.on { display: block; animation: viewIn .2s ease; }
@keyframes viewIn { from { opacity: 0; transform: translateY(5px); } }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; position: relative; overflow: hidden; }
.stat .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 27px; font-weight: 800; letter-spacing: -.035em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.stat .ico { position: absolute; right: 14px; top: 14px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--grad-soft); color: var(--brand-600); }
.stat.g .ico { background: rgba(16, 185, 129, .12); color: #059669; }
.stat.a .ico { background: rgba(245, 158, 11, .14); color: #b45309; }
.stat.c .ico { background: rgba(6, 182, 212, .12); color: #0e7490; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel-head { padding: 14px 18px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel-head h3 { font-size: 14px; }
.panel-body { padding: 18px; }
.grid-main { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; align-items: start; }

/* 图表 */
.chart-box { position: relative; height: 250px; }
.chart-legend { display: flex; gap: 16px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.chart-legend i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; margin-right: 5px; }

/* 工具条 */
.toolbar-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar-row .input, .toolbar-row .select { height: 36px; width: auto; min-width: 150px; font-size: 12.5px; }
.toolbar-row .grow { flex: 1; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-2); font-size: 12.5px; color: var(--muted); }
.pager .btns { display: flex; gap: 6px; }

/* ---------------------------------------------------------------- 会话控制台 */
.console { display: grid; grid-template-columns: 300px 1fr 268px; gap: 0; height: calc(100vh - 128px); background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.c-list { border-right: 1px solid var(--line-2); display: flex; flex-direction: column; min-width: 0; }
.c-list-head { padding: 12px; border-bottom: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 8px; }
.c-tabs { display: flex; gap: 4px; background: #f4f6fb; padding: 3px; border-radius: 9px; }
.c-tabs button { flex: 1; height: 28px; border: 0; background: transparent; border-radius: 7px; font-size: 11.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.c-tabs button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }
.c-items { flex: 1; overflow-y: auto; }
.c-item { padding: 12px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; display: flex; gap: 10px; transition: .14s; position: relative; }
.c-item:hover { background: #fafbff; }
.c-item.on { background: rgba(99, 102, 241, .07); }
.c-item.on::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2.5px; background: var(--brand); }
.c-item .info { flex: 1; min-width: 0; }
.c-item .top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.c-item .nm { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-item .tm { font-size: 10.5px; color: var(--muted-2); flex: none; }
.c-item .preview { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 3px; }
.c-item .badges { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
.c-item .unread { background: var(--brand); color: #fff; font-size: 10px; font-weight: 700; border-radius: 99px; padding: 1px 6px; }

.c-main { display: flex; flex-direction: column; min-width: 0; background: #fbfcff; }
.c-main-head { padding: 12px 18px; background: #fff; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; gap: 12px; }
.c-main-head .meta { flex: 1; min-width: 0; }
.c-main-head h3 { font-size: 13.5px; display: flex; align-items: center; gap: 8px; }
.c-main-head .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.c-msgs { flex: 1; overflow-y: auto; padding: 18px; }
.c-info { border-left: 1px solid var(--line-2); background: #fff; overflow-y: auto; }
.c-info-block { padding: 16px; border-bottom: 1px solid var(--line-2); }
.c-info-block h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted-2); margin-bottom: 10px; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; padding: 4px 0; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; color: var(--ink-2); text-align: right; word-break: break-all; }

/* 快捷回复面板 */
.canned-pop { position: absolute; bottom: 100%; left: 14px; right: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto; z-index: 30; display: none; }
.canned-pop.show { display: block; }
.canned-pop .ci { padding: 10px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.canned-pop .ci:hover { background: #f7f9fd; }
.canned-pop .ci b { font-size: 12.5px; display: block; }
.canned-pop .ci small { color: var(--muted); font-size: 11px; }

/* ---------------------------------------------------------------- 角色权限矩阵 */
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
.perm-item { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 9px; border: 1px solid var(--line-2); font-size: 12.5px; cursor: pointer; }
.perm-item:hover { background: #fafbff; }
.perm-item input { accent-color: var(--brand); width: 15px; height: 15px; flex: none; }
.perm-item span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.perm-item code { font-size: 10px; color: var(--muted-2); font-family: var(--mono); white-space: nowrap; flex: none; opacity: .8; }
#v-roles .grid-main { grid-template-columns: 1fr 1.35fr; }

/* 邮件模板编辑器 */
.mail-layout { display: grid; grid-template-columns: 230px 1fr; gap: 16px; align-items: start; }
.tpl-list .ti { padding: 10px 14px; border-radius: 9px; cursor: pointer; font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.tpl-list .ti:hover { background: #f6f8fd; }
.tpl-list .ti.on { background: rgba(99, 102, 241, .1); color: var(--brand-600); font-weight: 600; }

/* 文件网格 */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.file-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; transition: .18s; }
.file-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.file-card .thumb { height: 96px; background: #f5f7fc; display: grid; place-items: center; color: var(--muted-2); font-size: 12px; font-weight: 700; overflow: hidden; }
.file-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-card .meta { padding: 9px 11px; }
.file-card .nm { font-size: 11.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .sz { font-size: 10.5px; color: var(--muted-2); display: flex; justify-content: space-between; margin-top: 3px; }

/* 设置 */
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; align-items: start; }
.set-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.set-item { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.set-item.wide { grid-column: 1 / -1; }
.set-item label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.set-item .hint { font-size: 11.5px; color: var(--muted-2); line-height: 1.5; }
/* 开关单独一格时，用一行说明把高度撑齐，免得看着像「空了一块」 */
.switch-row { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.switch-row .hint { flex: 1; min-width: 0; }
.set-grid textarea.textarea { min-height: 68px; resize: vertical; }

/* 弹窗内表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .wide { grid-column: 1 / -1; }

/* 响应式 */
@media (max-width: 1280px) {
  .console { grid-template-columns: 270px 1fr; }
  .c-info { display: none; }
}
@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-main { grid-template-columns: 1fr; }
  .perm-grid, .set-grid, .set-grid.cols-3, .form-grid { grid-template-columns: 1fr; }
  .mail-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .admin-shell { grid-template-columns: 1fr; }
  .a-side { position: fixed; left: 0; top: 0; z-index: 200; width: 244px; transform: translateX(-100%); transition: .25s; }
  .a-side.open { transform: none; }
  .a-search { display: none; }
  .a-content { padding: 14px; }
  .console { grid-template-columns: 1fr; height: calc(100vh - 110px); }
  .c-list { display: none; }
  .console.list-view .c-list { display: flex; }
  .console.list-view .c-main { display: none; }
}

/* ==========================================================================
   广告 / 公告 / 附件选择器
   ========================================================================== */

/* 多选人群 */
.chk-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chk {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: var(--surface-2); font-size: 12.5px; cursor: pointer; user-select: none;
  transition: .16s;
}
.chk:hover { border-color: var(--brand); }
.chk input { accent-color: var(--brand); margin: 0; }
.chk:has(input:checked) { border-color: var(--brand); background: rgba(99,102,241,.08); color: var(--brand-700); font-weight: 600; }

/* 富文本宿主 */
.rich-host { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: #fff; }
.rich-host .editor { min-height: 120px; }

/* 附件选择器 */
.att-picker { border: 1px dashed var(--line); border-radius: 12px; padding: 12px; background: var(--surface-2); }
.att-chips { display: flex; flex-wrap: wrap; gap: 8px; min-height: 26px; align-items: center; }
.att-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 9px; border-radius: 8px; background: #fff;
  border: 1px solid var(--line); font-size: 12px; max-width: 100%;
}
.att-chip b {
  font-size: 9.5px; font-weight: 800; letter-spacing: .04em; color: var(--brand-600);
  background: rgba(99,102,241,.1); padding: 2px 5px; border-radius: 4px;
}
.att-chip .nm { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip .sz { color: var(--muted-2); font-size: 11px; }
.att-chip i {
  font-style: normal; cursor: pointer; color: var(--muted-2);
  width: 16px; height: 16px; display: grid; place-items: center; border-radius: 4px;
}
.att-chip i:hover { background: rgba(239,68,68,.12); color: var(--red); }
.att-acts { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* 附件库选择态 */
.file-card { cursor: pointer; position: relative; }
.file-card.picked { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(99,102,241,.22); }
.file-card.picked::after {
  content: "✓"; position: absolute; top: 7px; right: 7px;
  width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff;
  font-size: 12px; font-weight: 800; display: grid; place-items: center;
}

/* ==========================================================================
   支付：订单 / 渠道
   ========================================================================== */
.pay-stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.pay-stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: flex; flex-direction: column; gap: 2px;
}
.pay-stat.warn { border-color: rgba(245, 158, 11, .45); background: linear-gradient(180deg, rgba(245,158,11,.07), #fff); }
.pay-stat-k { font-size: 11.5px; color: var(--muted); letter-spacing: .02em; }
.pay-stat-v { font-size: 21px; font-weight: 700; letter-spacing: -.02em; color: var(--ink); line-height: 1.3; }
.pay-stat-s { font-size: 11px; color: var(--muted-2); }

.guide-card {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(99,102,241,.07), rgba(139,92,246,.05));
  border: 1px solid rgba(99,102,241,.22); border-radius: var(--radius);
}
.guide-ico { font-size: 22px; line-height: 1; }
.guide-card b { font-size: 13.5px; }
.guide-steps { margin: 8px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink-2); line-height: 1.85; }
.guide-steps b { color: var(--brand-600); }

.ch-dot {
  width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center;
  color: #fff; font-size: 12.5px; font-weight: 700; flex: 0 0 auto;
}
.qr-thumb { width: 34px; height: 34px; border-radius: 7px; border: 1px solid var(--line); object-fit: contain; background: #fff; }
.miss { color: var(--red); }

/* 收款渠道表格：固定列宽，否则「标识」列会被内容撑宽、操作列被挤到边 */
#channelTable { overflow-x: auto; }
.ch-table { table-layout: fixed; min-width: 820px; }
.ch-table th, .ch-table td { padding: 12px 14px; }
.ch-table th { white-space: nowrap; }
.ch-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.ch-name b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-table code.mono { font-size: 11.5px; color: var(--muted); word-break: break-all; }
.ch-table .num { text-align: center; font-variant-numeric: tabular-nums; }
.ch-table .ctr { text-align: center; }
.ch-info { min-width: 0; }
.ch-info .truncate { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ch-ops { display: flex; justify-content: flex-end; align-items: center; gap: 14px; white-space: nowrap; }

/* 颜色选择：别让 input[type=color] 撑成一整条色块 */
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row .color-input { flex: 0 0 56px; width: 56px; height: 38px; padding: 3px; cursor: pointer; }
.color-row .input { flex: 1 1 auto; min-width: 0; }

/* 多行输入如果挂了 .input 会被 42px 定高压扁，这里还原成多行 */
textarea.input { height: auto; min-height: 84px; padding: 11px 13px; line-height: 1.65; resize: vertical; }

.qr-picker { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.qr-preview {
  width: 104px; height: 104px; border-radius: 12px; border: 1px dashed var(--line); background: var(--surface-2);
  display: grid; place-items: center; overflow: hidden; flex: 0 0 auto;
}
.qr-preview img { width: 100%; height: 100%; object-fit: contain; }
.qr-picker-side { flex: 1 1 240px; min-width: 220px; }

.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.kv-grid .kv { border-bottom: 1px dashed var(--line-2); }
.notice-box {
  margin-top: 12px; padding: 10px 12px; font-size: 12.5px; color: var(--ink-2);
  background: var(--surface-2); border-left: 3px solid var(--brand); border-radius: 8px; line-height: 1.7;
}
.sec-title { margin: 20px 0 10px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }

.timeline { display: flex; flex-direction: column; gap: 0; }
.tl-item { display: flex; gap: 10px; padding: 8px 0 8px 2px; position: relative; }
.tl-item:not(:last-child)::before {
  content: ''; position: absolute; left: 5px; top: 20px; bottom: -2px; width: 1px; background: var(--line);
}
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); margin-top: 6px; flex: 0 0 auto; box-shadow: 0 0 0 3px rgba(99,102,241,.14); }
.tl-item b { font-size: 12.5px; }
.tl-item .tiny { display: block; }

@media (max-width: 700px) {
  .kv-grid { grid-template-columns: 1fr; }
}
