:root {
  --bg: #f4f6fa; --card: #fff; --border: #e3e8f0; --text: #1f2937; --muted: #6b7280;
  --primary: #2563eb; --primary-dark: #1d4ed8; --green: #16a34a; --red: #dc2626; --amber: #d97706;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.view { display: flex; min-height: 100vh; }
#view-login { align-items: center; justify-content: center; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 32px; width: 360px; box-shadow: 0 8px 30px rgba(0,0,0,.06); }
.login-card h1 { font-size: 20px; margin-bottom: 20px; text-align: center; }
.tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.tab { flex: 1; padding: 8px; border: 1px solid var(--border); background: #fff; border-radius: 8px; cursor: pointer; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.form { display: flex; flex-direction: column; gap: 10px; }
.form input, .form select, .form textarea { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; width: 100%; }
.form textarea { min-height: 80px; font-family: inherit; }
.error { color: var(--red); font-size: 13px; min-height: 18px; }
.btn { padding: 9px 16px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; background: var(--border); }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.danger { background: var(--red); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--border); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.sidebar { width: 200px; background: #111827; color: #e5e7eb; display: flex; flex-direction: column; padding: 16px 0; }
.brand { padding: 0 20px 20px; font-size: 16px; font-weight: 700; }
nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-item { text-align: left; padding: 10px 20px; background: transparent; border: none; color: #d1d5db; cursor: pointer; font-size: 14px; }
.nav-item:hover { background: #1f2937; }
.nav-item.active { background: var(--primary); color: #fff; }
.sidebar-footer { padding: 12px 20px; border-top: 1px solid #1f2937; display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: #9ca3af; }
.content { flex: 1; padding: 24px; overflow: auto; }
.page { max-width: 1200px; margin: 0 auto; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.page-head h2 { font-size: 20px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat .num { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .label { color: var(--muted); font-size: 13px; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
th { background: #f9fafb; font-weight: 600; }
tr:hover td { background: #f9fafb; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.green { background: #dcfce7; color: var(--green); }
.badge.red { background: #fee2e2; color: var(--red); }
.badge.amber { background: #fef3c7; color: var(--amber); }
.badge.blue { background: #dbeafe; color: var(--primary); }
.badge.gray { background: #f3f4f6; color: var(--muted); }
.banner-warn { background: #fef3c7; color: #92400e; border: 1px solid #f59e0b; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }
.task-err { color: var(--red); font-size: 12px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-err.dsh { font-weight: 600; }
.run-time { font-size: 11px; color: var(--muted); margin-top: 2px; }
.run-time.warn { color: var(--amber); font-weight: 600; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-box { background: #fff; border-radius: 12px; width: 640px; max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.modal-body { padding: 18px; overflow: auto; }
.chart { display: flex; align-items: flex-end; gap: 3px; height: 120px; margin-top: 12px; }
.chart .bar { flex: 1; background: var(--primary); min-height: 2px; border-radius: 2px 2px 0 0; position: relative; }
.chart .bar:hover::after { content: attr(data-v); position: absolute; top: -22px; left: 50%; transform: translateX(-50%); background: #111; color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 11px; white-space: nowrap; }
.chart-label { display: flex; gap: 3px; margin-top: 4px; }
.chart-label span { flex: 1; text-align: center; font-size: 10px; color: var(--muted); overflow: hidden; }
.tabs2 { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs2 button { padding: 6px 14px; border: 1px solid var(--border); background: #fff; border-radius: 999px; cursor: pointer; font-size: 13px; max-width: 180px; }
.tabs2 button .tab-label { display: inline-block; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.tabs2 button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.doc-content { white-space: pre-wrap; background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-family: ui-monospace, monospace; font-size: 12px; max-height: 480px; overflow: auto; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag { display: inline-block; background: #eff6ff; border: 1px solid #bfdbfe; color: var(--primary); border-radius: 999px; padding: 2px 10px; font-size: 12px; }
.tag .tag-del { color: var(--muted); text-decoration: none; margin-left: 4px; font-size: 11px; }
.tag .tag-del:hover { color: var(--red); }
.book-list { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
/* 操作列：所有按钮并列同一行，不折行，宽度随内容自适应 */
td.ops, th.ops { white-space: nowrap; }
.ops-row { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.ops-row .btn { flex: none; }
.muted { color: var(--muted); }
.mt { margin-top: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
/* 章节浏览子页面：左目录右正文 */
.chap-browser { display: flex; gap: 12px; min-height: 420px; }
.chap-dir { width: 260px; flex: none; border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 60vh; }
.chap-item { padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.chap-item:hover { background: #f3f4f6; }
.chap-item.active { background: #eff6ff; border-left: 3px solid var(--primary); }
.chap-no { font-weight: 600; color: var(--primary); }
.chap-title { color: #111827; }
.chap-wc { font-size: 11px; }
.chap-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.chap-main h3 { margin: 0; font-size: 15px; }
#chap-body { white-space: pre-wrap; background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 12px; font-size: 14px; line-height: 1.9; max-height: 52vh; overflow: auto; }
/* 指令预览 */
.ins-preview { background: #f9fafb; border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.ins-preview textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 12px; line-height: 1.6; min-height: 180px; border: 1px solid var(--border); border-radius: 6px; padding: 8px; resize: vertical; }
.ins-hint { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
/* 设计卡片修改红点提示 */
.dot-red { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; margin-left: 5px; vertical-align: 1px; }
/* 章节目录「新建章节」入口 */
.chap-new { border-left: 3px solid var(--primary); background: #f8fafc; }
.chap-new:hover { background: #eff6ff; }
.chap-standalone { border-left: 3px solid #d97706; background: #fffbeb; }
.chap-standalone:hover { background: #fef3c7; }
.chap-standalone .chap-no { color: #b45309; font-weight: 600; }
/* 章节目录排序工具条 */
.chap-sort { display: flex; gap: 4px; align-items: center; padding: 6px 8px; border-bottom: 1px solid var(--border); background: #f8fafc; }
.chap-sort span { font-size: 12px; margin-right: 4px; }
.chap-sort .btn { padding: 2px 8px; font-size: 12px; }
#chap-dir-list { overflow: auto; max-height: 52vh; }
#chap-status { min-height: 16px; font-size: 12px; }
.chap-content { white-space: pre-wrap; }
.chap-item { position: relative; }
.chap-actions { display: flex; gap: 4px; margin-top: 4px; }
.chap-actions .btn { padding: 1px 6px; font-size: 11px; }
.st { font-weight: 600; }
.st.pending_update { color: var(--amber); }
.st.published { color: var(--green); }
.st.pending_publish { color: var(--primary); }
