:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --bg: #f1f5f9;
  --side: #0f172a;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* 登录页 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%); }
.login-box { background: #fff; padding: 40px; border-radius: 12px; width: 360px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-box h1 { font-size: 22px; margin-bottom: 6px; color: #0f172a; }
.login-box .sub { color: var(--muted); margin-bottom: 24px; }
.field { margin-bottom: 14px; }
.field input, .form-row input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
.field input:focus, .form-row input:focus { border-color: var(--primary); }
.msg { color: var(--danger); min-height: 20px; margin-bottom: 10px; font-size: 13px; }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.side { width: 220px; background: var(--side); color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { padding: 20px 18px; font-size: 17px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-user { padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,.08); font-size: 13px; line-height: 1.7; }
.side-user b { color: #fff; }
.side nav { flex: 1; padding-top: 10px; }
.nav-item { display: block; padding: 12px 18px; color: #cbd5e1; text-decoration: none; cursor: pointer; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(37,99,235,.2); color: #fff; border-left-color: var(--primary); }
.side-foot { padding: 14px; }

.main { flex: 1; padding: 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; background: #fff; padding: 14px 20px; border-radius: 10px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.topbar .stats { display: flex; gap: 28px; }
.topbar .stat b { font-size: 20px; color: var(--primary); display: block; }
.topbar .stat span { color: var(--muted); font-size: 12px; }

.panel { background: #fff; border-radius: 10px; padding: 20px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.hidden { display: none; }
h2 { font-size: 16px; margin-bottom: 14px; }

/* 卡片 */
.cards { display: flex; gap: 16px; margin-bottom: 14px; }
.card { flex: 1; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 18px; text-align: center; }
.card-num { font-size: 26px; font-weight: 700; color: var(--primary); }
.card-label { color: var(--muted); margin-top: 6px; font-size: 13px; }

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.tbl th { color: var(--muted); font-weight: 600; background: #f8fafc; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; }
.badge.active { background: #dcfce7; color: #15803d; }
.badge.disabled { background: #fee2e2; color: #b91c1c; }
.badge.role { background: #e0e7ff; color: #4338ca; }

/* 按钮 */
.btn { padding: 8px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; color: #cbd5e1; border: 1px solid rgba(255,255,255,.2); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn.danger { background: var(--danger); color: #fff; }
.block { width: 100%; }
.form-row { display: flex; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.form-row label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.form-row input { width: 200px; }
.tip { color: var(--muted); font-size: 12px; margin-top: 10px; }

/* 树 */
.tree-node { margin: 6px 0; }
.tree-row { display: flex; align-items: center; gap: 10px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; flex-wrap: wrap; }
.tree-row .uname { font-weight: 600; }
.tree-row .meta { color: var(--muted); font-size: 12px; }
.tree-children { margin-left: 26px; padding-left: 14px; border-left: 2px solid var(--border); }
.ops { margin-left: auto; display: flex; gap: 6px; }
.tree-empty { color: var(--muted); padding: 20px; text-align: center; }
.badge.warn { background: #fef9c3; color: #a16207; }

/* 自绘弹窗 */
.m-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.m-box { background: #fff; border-radius: 12px; width: 460px; max-width: 92vw; max-height: 86vh; overflow: auto; box-shadow: 0 24px 64px rgba(0,0,0,.3); animation: mpop .16s ease; }
.m-box.wide { width: 760px; }
@keyframes mpop { from { transform: scale(.96); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.m-title { padding: 16px 20px 0; font-size: 16px; font-weight: 700; color: #0f172a; }
.m-body { padding: 14px 20px; }
.m-actions { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }
.m-field { margin-bottom: 12px; }
.m-field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.m-field .req { color: var(--danger); font-style: normal; margin-left: 2px; }
.m-field input, .m-field select { width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
.m-field input:focus, .m-field select:focus { border-color: var(--primary); }
.m-text { line-height: 1.8; }
.m-text b { color: var(--primary); }

/* 激活码展示 */
.code-box { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: #0f172a; color: #7dd3fc; font-family: Consolas, monospace; font-size: 20px; letter-spacing: 2px; padding: 14px 18px; border-radius: 10px; margin: 12px 0; user-select: all; }
.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 7px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv td:first-child { color: var(--muted); width: 90px; }

/* toast */
#toastRoot { position: fixed; top: 18px; right: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 11px 18px; border-radius: 8px; font-size: 14px; color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.18); animation: mpop .18s ease; max-width: 360px; }
.toast.ok { background: #059669; }
.toast.err { background: #dc2626; }

/* 分隔线 */
.sep { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.btn.danger:hover { opacity: .9; }

/* 文章全文 */
.article-body { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; max-height: 420px; overflow: auto; line-height: 1.9; white-space: normal; }

/* 菜单红点 */
.nav-item { position: relative; }
.dot { position: absolute; right: 10px; top: 10px; background: #ef4444; color: #fff; font-size: 11px; line-height: 1; padding: 3px 6px; border-radius: 10px; min-width: 16px; text-align: center; }

/* 发布任务分组（正方形缩略框·多列网格） */
#pubFolders { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.pub-folder { position: relative; aspect-ratio: 1 / 1; background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .1s; display: flex; align-items: center; justify-content: center; }
.pub-folder:hover { border-color: var(--primary); box-shadow: 0 4px 14px rgba(37,99,235,.15); transform: translateY(-1px); }
.pub-folder .dot { position: absolute; right: 10px; top: 10px; }
.pf-inner { text-align: center; padding: 12px; }
.pf-icon { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 10px; background: #e0e7ff; color: #4338ca; display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700; }
.pf-name { font-size: 15px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-meta { color: var(--muted); font-size: 12px; margin-top: 6px; line-height: 1.6; }
.img-err { color: var(--muted); font-size: 12px; text-align: center; }
#pubBack { margin-bottom: 12px; }
.btn.ghost2 { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }

/* 文章展示（详情弹窗） */
.art-box { border: 1px solid var(--border); border-radius: 8px; margin-top: 12px; overflow: hidden; }
.art-title { text-align: center; font-size: 17px; padding: 14px 16px 10px; margin: 0; flex: none; }
.art-content { border: none; border-radius: 0; border-top: 1px dashed var(--border); max-height: 460px; }

/* 详情弹窗：外框不滚动，仅内容区内部滚动，底部按钮并排 */
.m-box.detail { display: flex; flex-direction: column; overflow: hidden; max-height: 92vh; width: 860px; }
.m-box.detail .m-title { flex: none; }
.m-box.detail .m-body { overflow: hidden; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.m-box.detail .kv { flex: none; }
.m-box.detail .art-flex { flex: 1; min-height: 0; margin-top: 10px; display: flex; flex-direction: column; }
.m-box.detail .art-content { flex: 1; min-height: 0; overflow-y: auto; max-height: none; }
.m-box.detail .m-actions { flex: none; }
.art-content p { margin: 0 0 10px; }
.art-img { text-align: center; margin: 10px 0; }
.art-img img { max-width: 100%; border-radius: 6px; }

/* AI 密钥配置区 */
.ai-sec { background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.ai-sec h3 { font-size: 14px; margin-bottom: 10px; }
.ai-sec .tip { margin-top: 0; margin-bottom: 10px; }
.kstate { font-size: 12px; font-weight: normal; color: var(--muted); margin-left: 6px; }
.kstate.ok { color: #15803d; }
#tab-aikeys .form-row label { min-width: 300px; }

/* 我的点数池条 */
.my-pool { display: flex; align-items: center; gap: 12px; background: #fefce8; border: 1px solid #fde68a; border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; font-size: 14px; }
.my-pool .pool-val b { color: var(--primary); font-size: 16px; }
.my-pool .pool-hint { color: var(--muted); font-size: 12px; }
.my-pool .btn { margin-left: auto; flex: none; }

/* 树节点展开/收起倒三角 */
.tgl { display: inline-flex; align-items: center; justify-content: center; width: 16px; height: 16px; flex: none; cursor: pointer; font-size: 11px; color: var(--muted); transform: rotate(-90deg); transition: transform .12s; user-select: none; border-radius: 3px; }
.tgl:hover { color: var(--primary); background: #e0e7ff; }
.tgl.open { transform: rotate(0deg); color: var(--primary); }
.tgl.ph { visibility: hidden; cursor: default; }
