/* ============================================================
   QQ 机器人工作台 · PHP 版主题（v2 重设计）
   设计原则：
   1. 深色侧边栏 + 浅色内容区，层次一眼分明
   2. 关键操作永远只有一个大蓝按钮，不让人纠结点哪里
   3. 空状态必须给「下一步该做什么」的入口，不让人发呆
   ============================================================ */

:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --side: #0f172a;
  --side-2: #1e293b;
  --side-text: #94a3b8;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-bg: #fee2e2;
  --warn: #d97706;
  --warn-bg: #fef3c7;
  --info-bg: #dbeafe;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .10);
  /* 兼容旧模板里的变量名 */
  --panel: var(--card);
  --line: var(--border);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
  background: #f1f5f9; border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px;
  font: 13px/1.5 Consolas, "Courier New", monospace;
  word-break: break-all;
}

/* ---------------------------------------------------------- 布局骨架 */
.shell { display: flex; min-height: 100vh; }

.side {
  width: 220px;
  flex-shrink: 0;
  background: var(--side);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand .n {
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .5px;
}
.brand .s {
  color: var(--side-text);
  font-size: 12px;
  margin-top: 4px;
}
.brand .s b { color: #7dd3fc; font-weight: 600; }

.nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav .sep {
  color: #475569;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 16px 10px 6px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--side-text);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav a.on {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.nav a .label { flex: 1; }

.side-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  color: #475569;
  font-size: 12px;
}
.side-foot form { margin: 0; }
.side-foot button {
  width: 100%;
  background: transparent;
  border: 1px solid #334155;
  color: var(--side-text);
  border-radius: 8px;
  padding: 7px 0;
  cursor: pointer;
  font-size: 13px;
  transition: all .15s;
}
.side-foot button:hover { border-color: var(--danger); color: #fca5a5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .pill {
  background: var(--info-bg);
  color: var(--primary);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
}

.content { padding: 24px 28px 48px; max-width: 1080px; width: 100%; }

/* ---------------------------------------------------------- 面板与卡片 */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 18px;
}
.panel h2 {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel h2::before {
  content: "";
  width: 4px;
  height: 15px;
  background: var(--primary);
  border-radius: 2px;
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card .k { color: var(--muted); font-size: 13px; }
.card .v { font-weight: 700; margin-top: 4px; }
.card .v.big { font-size: 30px; line-height: 1.2; color: var(--text); }

/* ---------------------------------------------------------- 表单 */
label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 12px 0 5px;
  font-weight: 600;
}
label .req { color: var(--danger); }
input[type="text"], input[type="password"], input[type="number"], input[type="url"],
select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { resize: vertical; }

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  text-decoration: none !important;
}
button:hover, .btn:hover { border-color: var(--primary); color: var(--primary); }
button.primary, .btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow);
}
button.primary:hover, .btn.primary:hover { background: var(--primary-hover); color: #fff; }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }

form.inline { display: inline-block; margin: 0; }
.row { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.grid2 > div { min-width: 0; }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

label.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  font-weight: normal;
  color: var(--text);
  cursor: pointer;
}
label.check input { width: auto; }

/* ---------------------------------------------------------- 表格 */
table.list {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.list th {
  text-align: left;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
table.list td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.list tr:hover td { background: #f8fafc; }
table.list tr.sub-row td { background: #f8fafc; border-top: none; }
table.list tr.sub-row:hover td { background: #f1f5f9; }

/* ---------------------------------------------------------- 徽章与提示 */
.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.tag.ok  { background: var(--ok-bg);     color: var(--ok);     border-color: #bbf7d0; }
.tag.bad { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.tag.warn{ background: var(--warn-bg);   color: var(--warn);   border-color: #fde68a; }

.banner {
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 14px;
  border: 1px solid;
}
.banner.ok   { background: var(--ok-bg);     border-color: #bbf7d0; color: #14532d; }
.banner.err  { background: var(--danger-bg); border-color: #fecaca; color: #7f1d1d; }
.banner.info { background: var(--info-bg);   border-color: #bfdbfe; color: #1e3a8a; }
.banner a { color: inherit; text-decoration: underline; }

.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.hint code { font-size: 12px; }

/* ---------------------------------------------------------- 空状态（引导操作） */
.empty {
  text-align: center;
  padding: 44px 20px;
  color: var(--muted);
}
.empty .ico {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 14px;
  background: var(--info-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 22px;
  font-weight: 700;
}
.empty .t { font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 4px; }
.empty .d { font-size: 13px; margin-bottom: 16px; }

/* ---------------------------------------------------------- 新手引导（总览页） */
.guide { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.guide .step {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.guide .no {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guide .step.done .no { background: var(--ok); }
.guide .step .t { font-weight: 700; font-size: 14px; }
.guide .step .d { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.guide .step .go { margin-top: 8px; display: inline-block; font-size: 13px; }
.guide .step.done { opacity: .62; }

/* ---------------------------------------------------------- 登录页 / 安装向导 */
.centered {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh 16px 40px;
  background:
    radial-gradient(1200px 500px at 20% -10%, #dbeafe 0%, transparent 60%),
    radial-gradient(1000px 500px at 90% 0%, #ede9fe 0%, transparent 55%),
    var(--bg);
}
.wizard-card {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 34px 36px 30px;
  border: 1px solid var(--border);
}
.wizard-card h1 { margin: 0 0 6px; font-size: 22px; }
.wizard-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 20px; }
.wizard-card button.primary { width: 100%; margin-top: 18px; padding: 11px 0; font-size: 15px; }
.wizard-card .row { justify-content: space-between; }
.wizard-card .row button { flex: 1; }
.wizard-card .row button + button { margin-left: 10px; }

.stepper { display: flex; align-items: center; margin: 4px 0 22px; }
.stepper .s {
  display: flex; flex-direction: column; align-items: center;
  color: var(--muted); font-size: 11px; gap: 4px;
}
.stepper .s i {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 1px solid var(--border);
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.stepper .s.doing { color: var(--primary); font-weight: 700; }
.stepper .s.doing i { background: var(--primary); border-color: var(--primary); color: #fff; }
.stepper .s.done { color: var(--ok); }
.stepper .s.done i { background: var(--ok-bg); border-color: #bbf7d0; color: var(--ok); }
.stepper .line { flex: 1; height: 1px; background: var(--border); margin: 0 4px 14px; }

.bar {
  height: 6px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--danger);
  border-radius: 999px;
  transition: width .25s, background .25s;
}

/* ---------------------------------------------------------- 状态点 */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.dot.on  { background: var(--ok);     box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.off { background: #94a3b8;       box-shadow: 0 0 0 3px #f1f5f9; }
.dot.err { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }

/* ---------------------------------------------------------- KV 表 */
table.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
table.kv td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.kv td:first-child { color: var(--muted); width: 12rem; }

/* 应用网格卡片（参照门户导航样式：图标 + 名称 + 描述，横向多列） */
.appgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
}
.appitem {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: #fff;
  transition: box-shadow .15s, transform .15s;
}
.appitem:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.appicon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f1f5f9;
}
.appicon.ph {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-weight: 700;
  font-size: 20px;
}
.appmeta { flex: 1; min-width: 0; }
.appname { font-weight: 700; font-size: 14px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* v1.6.4：不再单行截断 —— 标识/版本/获取数分行完整显示 */
.appdesc { color: var(--muted); font-size: 12px; margin-top: 3px; line-height: 1.7; }
.appdesc .meta-row { display: block; }
.appdesc code { font-size: 12px; }
.appact { margin-top: 6px; font-size: 13px; }


/* 应用管理：按分类分组（v1.6.3） */
.cat-group { margin-top: 16px; }
.cat-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--text);
  margin: 0 0 10px; padding-left: 9px; border-left: 3px solid var(--primary);
}
.cat-head .count {
  font-weight: 500; font-size: 12px; color: var(--muted);
  background: #f1f5f9; border-radius: 10px; padding: 1px 8px;
}
/* 卡片内操作行：一行放得下，短链接样式 */
.appact.links { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.appact.links a, .appact.links button.link {
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--primary); font-size: 13px; text-decoration: none;
}
.appact.links a:hover, .appact.links button.link:hover { text-decoration: underline; }
.appact.links button.link.del { color: #dc2626; }
.appact.links .sep { color: #cbd5e1; }
/* 卡片里折叠的「发新版本」 */
.appitem details summary { font-size: 12px; color: var(--muted); cursor: pointer; margin-top: 6px; }

/* 系统设置：分区标题 + 顶部导航（v1.6.3） */
.sect-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.sect-nav .btn.on {
  border-color: var(--text); color: var(--text); font-weight: 700;
  box-shadow: 0 0 0 1px var(--text) inset;
}
.tabpane { display: none; }
.tabpane.on { display: block; }
.sect { scroll-margin-top: 16px; }
.sect .sect-title {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 0 0 12px; padding-left: 9px; border-left: 3px solid var(--primary);
  font-size: 16px; font-weight: 700;
}
.sect .sect-title .sect-desc { font-size: 12px; font-weight: 400; color: var(--muted); }

/* 小屏适配 */
@media (max-width: 640px) {
  .shell { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav a { margin-bottom: 4px; }
  .content { padding: 16px; }
}
