:root {
  --bg: #0f1218;
  --panel: #171b24;
  --panel-2: #1d222d;
  --line: #2a3140;
  --text: #e6e9ef;
  --muted: #98a2b3;
  --accent: #4f8cff;
  --ok: #35c46b;
  --warn: #e8b339;
  --bad: #e5534b;
  --sidebar-w: 200px;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  /* 侧栏固定 + 主区让位：一天要来回跳十几次，竖向列表比横向页签好点 */
  display: flex;
  min-height: 100vh;
}
body.sb-collapsed { --sidebar-w: 60px; }

/* ---- 左侧栏 ---- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 12px 10px;
  overflow-y: auto; overflow-x: hidden;
  z-index: 12;
  transition: width .16s ease;
}
.shell {
  flex: 1; min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  transition: margin-left .16s ease;
}

.sb-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 4px 6px 12px; margin-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.sb-logo {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7aa8ff);
  color: #fff; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.sb-brand-text { min-width: 0; }
.sb-brand-text b { display: block; font-size: 14px; letter-spacing: .02em; }
.sb-brand-text span { font-size: 11px; color: var(--muted); }

/* 分组标题：让人一眼看出"现在在动线的哪一段" */
.sb-group {
  font-size: 11px; color: #6b7488; letter-spacing: .08em;
  padding: 14px 10px 4px;
}
.sb-group:first-of-type { padding-top: 4px; }

.tab {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  background: none; border: none; border-radius: 8px;
  padding: 8px 10px; margin-bottom: 2px;
  color: var(--muted); font-size: 13.5px;
  transition: background .12s ease, color .12s ease;
}
.tab:hover { background: var(--panel-2); color: var(--text); border-color: transparent; }
.tab.active { background: rgba(79, 140, 255, .14); color: #fff; }
/* 选中态左侧竖条：不看颜色也能看出当前在哪 */
.tab.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 2px; border-radius: 2px; background: var(--accent);
}
.tab .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-badge {
  display: none; flex: 0 0 auto; padding: 0 6px; border-radius: 9px;
  background: var(--bad); color: #fff; font-size: 11px; line-height: 18px;
}
.tab-badge.show { display: inline-block; }

.sb-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.sb-toggle {
  width: 100%; background: none; border: none; color: var(--muted);
  padding: 6px 10px; border-radius: 8px; font-size: 14px;
}
.sb-toggle:hover { background: var(--panel-2); border-color: transparent; }

/* 收起态：只留两个字 + 角标（屏幕窄时也能一直看见待办数量） */
body.sb-collapsed .sb-brand-text,
body.sb-collapsed .sb-group { display: none; }
body.sb-collapsed .tab { justify-content: center; padding: 9px 0; }
body.sb-collapsed .tab .t { display: none; }
body.sb-collapsed .tab::after { content: attr(data-short); font-size: 12px; }
body.sb-collapsed .tab-badge { position: absolute; top: 1px; right: 5px; padding: 0 4px; font-size: 10px; line-height: 14px; }

header {
  display: flex; align-items: center; gap: 12px; row-gap: 8px;
  flex-wrap: wrap;
  padding: 12px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
header h1 { font-size: 16px; margin: 0 8px 0 0; font-weight: 600; white-space: nowrap; }
header .spacer { flex: 1; }

main { padding: 18px 22px 40px; overflow-x: auto; }

h3 { font-size: 14px; font-weight: 600; margin: 20px 0 10px; }
main > section > h3:first-child { margin-top: 0; }

/* 深色底上默认链接蓝（#0000EE）几乎看不清——全站统一成亮蓝 */
a { color: #8ab4ff; text-decoration: none; }
a:hover { color: #a9c8ff; text-decoration: underline; }

.link { color: #8ab4ff; cursor: pointer; text-decoration: none; border-bottom: 1px dashed rgba(138, 180, 255, .5); }
.link:hover { color: #a9c8ff; border-bottom-style: solid; text-decoration: none; }

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
}
.badge.ok { color: var(--ok); border-color: #245c39; }
.badge.warn { color: var(--warn); border-color: #5c4a1e; }
.badge.bad { color: var(--bad); border-color: #5c2724; }
.badge.accent { color: var(--accent); border-color: #2b4a80; }

button {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: border-color .12s ease, background .12s ease;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #5d97ff; }
button.danger { color: var(--bad); border-color: #5c2724; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.chips { display: inline-flex; gap: 6px; flex-wrap: wrap; }

.todo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 8px; }
.todo-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; cursor: pointer; text-align: left;
  transition: border-color .12s ease, transform .12s ease;
}
.todo-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.todo-card .n { font-size: 26px; font-weight: 600; line-height: 1.2; }
.todo-card .n.zero { color: var(--muted); }
.todo-card .t { font-size: 13px; margin-top: 2px; }
.todo-card .h { font-size: 12px; color: var(--muted); margin-top: 4px; }
.view.hidden { display: none; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar > * { width: auto; }

table { width: 100%; min-width: 880px; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; }
/* 格子不换行 + 超长省略（hover 看全文，标题由 JS 自动补 title）；
   表有最小宽度、页面可横向滚动 —— 窄屏也不会把操作按钮挤没了 */
th, td { white-space: nowrap; }
td { max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
th { color: var(--muted); font-weight: 500; background: var(--panel-2); font-size: 12px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #1a1f2a; }
/* 需要完整展示的列（正文、证据、理由）显式声明换行 */
td.wrap { white-space: normal; max-width: none; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px;
  max-width: calc(100vw - 24px);
  background: var(--panel); border-left: 1px solid var(--line);
  overflow-y: auto; padding: 18px; z-index: 20;
  transform: translateX(100%); transition: transform .18s ease;
}
.drawer.open { transform: translateX(0); }
.drawer h2 { margin: 0 0 4px; font-size: 16px; }
.drawer h3 { font-size: 13px; color: var(--muted); margin: 18px 0 8px; text-transform: none; }

.section { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 12px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }

.row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 120px; }

.mono { font-family: ui-monospace, Consolas, monospace; }
.note { font-size: 12px; color: var(--muted); }
.err { color: var(--bad); font-size: 12px; }
.ok-text { color: var(--ok); font-size: 12px; }

ul.checks { list-style: none; padding: 0; margin: 0; }
ul.checks li { padding: 4px 0; font-size: 13px; border-bottom: 1px dashed var(--line); }
ul.checks li:last-child { border-bottom: none; }

.mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 15; display: none; }
.mask.open { display: block; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--line);
  padding: 10px 16px; border-radius: 8px; z-index: 40; display: none;
}
.toast.show { display: block; }

.loginbox {
  position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%);
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; width: 340px; z-index: 30;
}
.loginbox h2 { margin: 0 0 8px; font-size: 16px; }

/* ---- 居中弹窗（替掉原生 prompt）---- */
.modal-box {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px)); max-height: 84vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; z-index: 32; display: none;
}
.modal-box.open { display: block; }
/* 表单弹窗（askForm/confirmBox）必须压过全文查看器：复制全文的降级框、
   按意见重出的表单、就地处决的通过/驳回都是在 detailBox 开着时弹出的——
   z-index 低于 .modal-box.wide(34) 会被详情内容盖住按钮，表现为"按钮点不动"。 */
#askMask { z-index: 49; }
#askBox, #confirmBox { z-index: 50; }
.toast { z-index: 60; }
.modal-box h2 { margin: 0; font-size: 16px; }

/* ---- 全文查看器（宽版）：AI 产出的完整内容都在这儿看 ---- */
.modal-box.wide { width: min(1040px, calc(100vw - 40px)); max-height: 88vh; z-index: 34; }
#detailMask { z-index: 33; }
.detail-head { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; }
.detail-head h2 { flex: 1; word-break: break-word; }
.detail-acts { display: flex; gap: 6px; flex-shrink: 0; }
.slot { margin-bottom: 14px; }
.slot-k { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.fulltext {
  white-space: pre-wrap; word-break: break-word; margin: 0;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font: inherit; font-size: 13px; line-height: 1.75;
}
.fulltext.empty { color: var(--muted); font-style: italic; }
.meta-grid { display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12px; color: var(--muted); }
.meta-grid b { color: var(--text); font-weight: 600; }
.modal-box .field { margin-bottom: 12px; }
.modal-box textarea { resize: vertical; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.preset { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.preset button { font-size: 12px; padding: 3px 8px; }

/* ---- 标签多选（驳回原因 / 重写槽位）：固定清单，手打的进不了统计 ---- */
.tagpick { display: flex; flex-wrap: wrap; gap: 6px; }
.tagopt {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  font-size: 12px; line-height: 1.6; padding: 4px 9px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel-2);
}
.tagopt:hover { border-color: var(--accent); }
.tagopt input { margin: 0; }
.tagopt:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #041419; }

/* ---- 滚动条：细一点，别抢内容的注意力 ---- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3140; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3a4457; }

/* ---- 今日产线：纵向时间线，每步一行（机器能做的绿，要人点的黄，缺条件的红） ---- */
.pipe-legend { margin: 0 0 10px; line-height: 2; }
.pipeline { display: flex; flex-direction: column; }
.ps {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 12px 14px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  position: relative;
}
.ps::after {
  content: ''; position: absolute; left: 27px; bottom: -9px;
  width: 1px; height: 9px; background: var(--line);
}
.ps:last-child::after { display: none; }
.ps-no {
  flex: 0 0 26px; width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--muted);
  background: var(--panel-2); border: 1px solid var(--line);
}
.ps.ready .ps-no { border-color: rgba(79, 140, 255, .65); color: #8ab4ff; }
.ps.waiting .ps-no { border-color: rgba(251, 191, 36, .65); color: #fbbf24; }
.ps.blocked .ps-no { border-color: rgba(248, 113, 113, .65); color: #f87171; }
.ps.done .ps-no { border-color: rgba(52, 211, 153, .55); color: #34d399; }
.ps.waiting { border-color: rgba(251, 191, 36, .35); }
.ps.blocked { border-color: rgba(248, 113, 113, .35); }
.ps.done { opacity: .85; }
.ps-body { flex: 1; min-width: 0; }
.ps-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ps-top b { font-size: 13.5px; }
.ps-group { margin-left: auto; font-size: 11px; color: var(--muted); }
.ps-hint { margin-top: 3px; font-size: 12px; color: var(--muted); }
.ps-nums { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.ps-nums b { color: var(--text); }
.ps-stuck { margin-top: 6px; padding: 5px 9px; border-radius: 6px; font-size: 12px; }
.ps-stuck.warn { background: rgba(251, 191, 36, .10); color: #fbbf24; }
.ps-stuck.bad { background: rgba(248, 113, 113, .10); color: #f87171; }
.ps-last { margin-top: 5px; font-size: 11.5px; color: var(--muted); word-break: break-word; }
.ps-side { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }

.sw { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.sw input { margin: 0; }

.runs { margin-top: 14px; }
.runs summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.run-row {
  display: grid; grid-template-columns: 150px 92px 74px 150px 1fr;
  gap: 8px; padding: 5px 0; align-items: baseline;
  border-bottom: 1px solid var(--line); font-size: 12px;
}
.run-row.failed { color: var(--bad); }
.run-row.waiting { color: var(--warn); }
