/* ============================================================
   QQ Bot 管理后台 · 现代深色主题（2026-10-08 美化版）
   基调：深空蓝黑 + 靛蓝/青渐变点缀；卡片化、状态色一眼可辨
   ============================================================ */
:root {
  --bg: #0a0f1c;
  --bg-soft: #0d1424;
  --panel: #111a2e;
  --panel-2: #16223c;
  --line: rgba(148, 163, 184, .14);
  --line-strong: rgba(148, 163, 184, .26);
  --txt: #e6edf7;
  --muted: #8b98b0;
  --accent: #5b8cff;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --err: #f87171;
  --warn: #fbbf24;
  --violet: #a78bfa;
  --grad: linear-gradient(135deg, #5b8cff, #22d3ee);
  --shadow: 0 10px 30px rgba(2, 8, 23, .45);
  --radius: 14px;
  --sidebar-w: 218px;
  --topbar-h: 54px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(91, 140, 255, .10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(34, 211, 238, .07), transparent 55%),
    var(--bg);
  color: var(--txt);
  -webkit-text-size-adjust: 100%;
  font-variant-numeric: tabular-nums;
}
.hidden { display: none !important; }
::selection { background: rgba(91, 140, 255, .35); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .22); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, .38); border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 按钮 ---------- */
button {
  background: var(--grad); color: #fff; border: 0;
  padding: 8px 16px; border-radius: 9px; cursor: pointer;
  font-weight: 600; font-size: 13px; min-height: 36px;
  box-shadow: 0 4px 14px rgba(91, 140, 255, .25);
  transition: transform .12s ease, filter .15s ease, box-shadow .15s ease;
}
button:hover { filter: brightness(1.1); box-shadow: 0 6px 18px rgba(91, 140, 255, .35); }
button:active { transform: scale(.97); }
.btn-ghost {
  background: rgba(148, 163, 184, .08); color: var(--muted);
  border: 1px solid var(--line-strong); box-shadow: none;
}
.btn-ghost:hover { color: var(--txt); background: rgba(148, 163, 184, .14); box-shadow: none; }
.icon-btn { background: transparent; color: var(--txt); font-size: 20px; padding: 4px 10px; min-height: auto; line-height: 1; box-shadow: none; border-radius: 8px; }
.icon-btn:hover { background: rgba(148, 163, 184, .12); box-shadow: none; }

input, textarea, select {
  background: var(--bg-soft); color: var(--txt);
  border: 1px solid var(--line-strong); border-radius: 9px;
  padding: 10px 12px; width: 100%; font-size: 15px; font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 140, 255, .18);
}
textarea { min-height: 74px; resize: vertical; line-height: 1.6; }
label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
label input[type=checkbox] { width: auto; accent-color: var(--accent); }
.msg { color: var(--err); margin-top: 8px; font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; line-height: 1.5; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.t-dim { color: var(--muted); }

/* ---------- 登录 ---------- */
.login-wrap { height: 100vh; height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box {
  background: linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, .01)), var(--panel);
  padding: 34px 30px; border-radius: 18px; width: min(92vw, 360px);
  display: flex; flex-direction: column; gap: 13px;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.login-box h2 { margin: 0 0 10px; text-align: center; font-size: 20px; letter-spacing: .5px; }
.login-box button { padding: 12px; font-size: 15px; }

/* ---------- 布局 ---------- */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, rgba(255, 255, 255, .02), transparent 30%), var(--bg-soft);
  padding: 18px 14px; display: flex; flex-direction: column;
  border-right: 1px solid var(--line);
}
.logo {
  font-weight: 800; font-size: 16px; letter-spacing: .5px;
  margin: 2px 6px 18px; display: flex; align-items: center; gap: 9px;
}
.logo::before {
  content: ""; width: 10px; height: 10px; border-radius: 50%;
  background: var(--grad); box-shadow: 0 0 12px rgba(91, 140, 255, .8);
}
.sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow: auto; padding: 2px; }
.sidebar nav a {
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  color: var(--muted); font-size: 14px; position: relative;
  transition: background .15s ease, color .15s ease, transform .12s ease;
}
.sidebar nav a:hover { background: rgba(148, 163, 184, .09); color: var(--txt); }
.sidebar nav a.active { background: rgba(91, 140, 255, .14); color: #fff; font-weight: 600; }
.sidebar nav a.active::before {
  content: ""; position: absolute; left: -2px; top: 22%; bottom: 22%;
  width: 3px; border-radius: 3px; background: var(--grad);
}
.side-foot { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); margin-top: 8px; }
.side-foot button { width: 100%; }
.badge { background: var(--grad); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 999px; width: fit-content; font-weight: 700; }

.content { flex: 1; padding: 26px 28px; overflow: auto; -webkit-overflow-scrolling: touch; }
.panel { animation: fadeUp .25s ease; }
.panel h2 { margin: 0 0 16px; font-size: 21px; letter-spacing: .3px; }
.panel h3 { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin: 22px 0 10px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar h2 { flex: 1; margin: 0; min-width: 120px; font-size: 21px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 统计卡片 ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.card {
  position: relative; overflow: hidden;
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .005)), var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.card::after {
  content: ""; position: absolute; top: 0; left: 18px; right: 18px; height: 3px;
  border-radius: 0 0 4px 4px; background: var(--grad); opacity: .85;
}
.cards .card:nth-child(2)::after { background: linear-gradient(135deg, #a78bfa, #5b8cff); }
.cards .card:nth-child(3)::after { background: linear-gradient(135deg, #22d3ee, #34d399); }
.cards .card:nth-child(4)::after { background: linear-gradient(135deg, #fbbf24, #fb923c); }
.cards .card:nth-child(5)::after { background: linear-gradient(135deg, #34d399, #22d3ee); }
.card .n {
  font-size: 30px; font-weight: 800; letter-spacing: .5px;
  background: linear-gradient(135deg, #fff, #b9c8e8);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.card .l { color: var(--muted); font-size: 12px; letter-spacing: 1px; margin-top: 4px; text-transform: uppercase; }

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); margin-top: 6px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 14px; vertical-align: middle; }
th {
  color: var(--muted); font-weight: 600; white-space: nowrap;
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
  background: rgba(148, 163, 184, .05);
  position: sticky; top: 0; backdrop-filter: blur(6px);
}
tbody tr { border-top: 1px solid rgba(148, 163, 184, .08); transition: background .12s ease; }
tbody tr:hover { background: rgba(91, 140, 255, .05); }
td button { padding: 5px 10px; margin: 2px 4px 2px 0; font-size: 12px; min-height: 30px; box-shadow: none; }
.table { width: 100%; }

/* ---------- 状态徽章 ---------- */
.status-ok { color: var(--ok); font-weight: 600; }
.status-err { color: var(--err); font-weight: 600; }
.status-mock { color: var(--muted); }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  border: 1px solid transparent; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-in { color: #7dd3fc; background: rgba(34, 211, 238, .12); border-color: rgba(34, 211, 238, .3); }
.pill-out { color: #c4b5fd; background: rgba(167, 139, 250, .12); border-color: rgba(167, 139, 250, .3); }
.pill-ok { color: #6ee7b7; background: rgba(52, 211, 153, .12); border-color: rgba(52, 211, 153, .3); }
.pill-err { color: #fca5a5; background: rgba(248, 113, 113, .12); border-color: rgba(248, 113, 113, .3); }
.pill-mut { color: var(--muted); background: rgba(148, 163, 184, .1); border-color: rgba(148, 163, 184, .25); }

/* 在线状态圆点（仪表盘） */
.live-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 8px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--ok); box-shadow: 0 0 0 4px rgba(52, 211, 153, .15), 0 0 10px rgba(52, 211, 153, .8); }
.dot-err { background: var(--err); box-shadow: 0 0 0 4px rgba(248, 113, 113, .15); }
.live-row .live-name { font-weight: 600; }
.live-row .spacer { flex: 1; }

/* ---------- 表单 ---------- */
.form {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; max-width: 660px;
}
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 横幅 ---------- */
.banner { margin-bottom: 16px; }
.banner-ok, .banner-warn, .banner-info {
  padding: 11px 14px; border-radius: 12px; font-size: 13px;
  line-height: 1.75; text-align: left;
}
.banner-ok b, .banner-warn b, .banner-info b { font-weight: 700; }
.banner-ok { background: rgba(52, 211, 153, .1); border: 1px solid rgba(52, 211, 153, .35); color: #6ee7b7; }
.banner-warn { background: rgba(251, 191, 36, .1); border: 1px solid rgba(251, 191, 36, .35); color: #fcd34d; }
.banner-info { background: rgba(34, 211, 238, .09); border: 1px solid rgba(34, 211, 238, .3); color: #7dd3fc; }

/* 移动端顶部栏 / 抽屉：默认隐藏（桌面端） */
.topbar { display: none; }
.backdrop { display: none; }

/* ================= 平板（≤1024px） ================= */
@media (max-width: 1024px) {
  :root { --sidebar-w: 178px; }
  .content { padding: 20px; }
  .panel h2 { font-size: 19px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(138px, 1fr)); gap: 12px; }
  .sidebar nav a { font-size: 13px; padding: 9px 10px; }
  .form { max-width: none; }
}

/* ================= 手机（≤768px） ================= */
@media (max-width: 768px) {
  .app { flex-direction: column; }

  .topbar {
    display: flex; align-items: center; gap: 10px;
    height: var(--topbar-h); flex: 0 0 var(--topbar-h);
    padding: 0 12px; padding-top: env(safe-area-inset-top);
    background: rgba(13, 20, 36, .85); backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 30;
  }
  .topbar-title { flex: 1; font-weight: 600; font-size: 16px; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    width: 258px; flex: none; background: var(--bg-soft);
    transform: translateX(-100%); transition: transform .25s ease;
    padding-top: calc(16px + env(safe-area-inset-top));
    box-shadow: 4px 0 24px rgba(0, 0, 0, .5);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar nav a { padding: 13px 12px; font-size: 15px; }
  .side-foot { padding-bottom: env(safe-area-inset-bottom); }
  .side-foot .badge { display: none; }

  .backdrop {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(2, 6, 17, .6); opacity: 0; pointer-events: none; transition: opacity .25s;
    backdrop-filter: blur(2px);
  }
  .backdrop.show { opacity: 1; pointer-events: auto; }

  .content { padding: 16px; padding-bottom: calc(26px + env(safe-area-inset-bottom)); }
  .panel h2 { font-size: 18px; }
  .toolbar { gap: 8px; }
  .toolbar h2 { flex: 1 1 100%; }
  .toolbar button { flex: 1; min-width: 96px; }

  .cards { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 14px; }
  .card .n { font-size: 24px; }

  .form { padding: 14px; }
  .form-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .form-actions button { min-height: 44px; font-size: 15px; }

  /* 表格 → 卡片 */
  .table-wrap { overflow: visible; background: transparent; border: none; }
  table { margin-top: 0; }
  table, thead, tbody, tr, td { display: block; width: 100%; }
  thead { display: none; }
  tbody tr {
    background: var(--panel); border: 1px solid var(--line);
    border-radius: 12px; padding: 10px 14px; margin-bottom: 10px;
  }
  td {
    border: none; padding: 6px 0;
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    font-size: 14px; word-break: break-word;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted); font-size: 12px; flex: 0 0 72px; letter-spacing: .5px;
  }
  td:last-child { flex-wrap: wrap; justify-content: flex-start; gap: 8px; padding-top: 8px; }
  td:last-child::before { flex-basis: 100%; }
  td button { min-height: 38px; padding: 8px 14px; font-size: 13px; margin: 0; flex: 1 1 auto; }
  td[data-label="内容"], td[data-label="外部ID"] { font-size: 13px; color: var(--muted); align-items: flex-start; }
  td .pill { flex: none; }
}

/* 超小屏（≤380px） */
@media (max-width: 380px) {
  .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .card .n { font-size: 21px; }
  td::before { flex-basis: 62px; font-size: 11px; }
}

/* ---------- 扫码登录 Modal ---------- */
.modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal.hidden { display: none; }
.modal-mask { position: absolute; inset: 0; background: rgba(2, 6, 17, .66); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: 16px; padding: 22px; width: min(380px, 94vw);
  box-shadow: 0 28px 80px rgba(0, 0, 0, .6);
  animation: fadeUp .2s ease;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-foot button { min-width: 96px; }
.qr-wrap { text-align: center; margin: 14px 0; }
.qr-wrap img { width: 208px; height: 208px; background: #fff; border-radius: 14px; padding: 8px; box-shadow: 0 8px 30px rgba(0, 0, 0, .35); }

/* 智能回复 / AI 配置等区块卡片 */
.card-block {
  background: linear-gradient(180deg, rgba(255, 255, 255, .03), transparent), var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
}
.card-block h3 { margin: 0 0 14px; font-size: 15px; color: var(--txt); letter-spacing: .3px; }
.switch-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--txt); cursor: pointer; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row label { flex: 1; min-width: 120px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.row input { width: 100%; }

/* 触摸设备：加大点击区 */
@media (hover: none) {
  button { min-height: 40px; }
  .sidebar nav a { padding: 12px 10px; }
}

/* 版本更新提示条 */
.update-tip {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 9999; background: var(--warn, #b45309); color: #fff;
  padding: 10px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35); max-width: 92vw;
}
.update-tip a { color: #fff; text-decoration: underline; font-weight: 600; }
@media (max-width: 768px) { .update-tip { bottom: calc(18px + env(safe-area-inset-bottom)); } }

/* Key/Token 输入 + 显示隐藏按钮 */
.input-group { position: relative; display: flex; align-items: center; width: 100%; }
.input-group input { width: 100%; padding-right: 46px; }
.btn-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; cursor: pointer; font-size: 16px;
  padding: 6px 8px; min-height: auto; line-height: 1; opacity: .65; box-shadow: none;
}
.btn-eye:hover { opacity: 1; box-shadow: none; }
.btn-eye.off { opacity: .35; }

/* 微信服务自检：分层结果展示 */
.diagnose { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: rgba(255, 255, 255, .02); font-size: 13px; }
.diag-summary { padding: 9px 12px; border-radius: 10px; line-height: 1.6; margin-bottom: 8px; }
.diag-summary.diag-ok { background: rgba(52, 211, 153, .1); border: 1px solid rgba(52, 211, 153, .35); color: #6ee7b7; }
.diag-summary.diag-bad { background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .35); color: #fca5a5; }
.diag-meta { color: var(--muted); font-size: 12px; margin-bottom: 8px; word-break: break-all; }
.diag-row { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid rgba(148, 163, 184, .08); align-items: flex-start; }
.diag-row:first-of-type { border-top: none; }
.diag-tag { flex: 0 0 110px; font-weight: 600; }
.diag-detail { flex: 1; color: #cbd5e1; word-break: break-all; line-height: 1.55; }

/* ---------- 统计分析页 ---------- */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.chart-card {
  background: linear-gradient(180deg, rgba(255,255,255,.03), transparent), var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px 10px;
  transition: border-color .15s ease;
}
.chart-card:hover { border-color: var(--line-strong); }
.chart-card.wide { grid-column: 1 / -1; }
.chart-card h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; letter-spacing: .8px; text-transform: uppercase; }
.chart { height: 280px; width: 100%; }
.chart-card.wide .chart { height: 300px; }
.seg { display: inline-flex; background: var(--bg-soft); border: 1px solid var(--line-strong); border-radius: 10px; padding: 3px; gap: 2px; }
.seg-btn {
  background: transparent; border: 0; color: var(--muted); box-shadow: none;
  padding: 7px 14px; border-radius: 8px; font-size: 13px; min-height: 32px; font-weight: 600;
}
.seg-btn:hover { color: var(--txt); background: rgba(148,163,184,.1); box-shadow: none; }
.seg-btn.active { background: var(--grad); color: #fff; }
#analysis-cards { margin-top: 2px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } .chart-card.wide { grid-column: auto; } }

/* 教务系统 */
.jw-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.jw-form .input { min-width: 140px; flex: 0 1 auto; }
.jw-chips-label { color: var(--muted); font-size: 13px; margin-right: 4px; }
.jw-chip { position: relative; cursor: pointer; }
.jw-chip input { position: absolute; opacity: 0; }
.jw-chip span { display: inline-block; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-size: 12px; transition: all .15s; }
.jw-chip input:checked + span { background: rgba(99, 102, 241, .18); border-color: var(--accent, #6366f1); color: #cdd6fe; }
.jw-dim { color: var(--muted); }
