:root {
  --bg: #f6f7f9;
  --card: #fff;
  --line: #e3e6ea;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #2563eb;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  height: 56px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; font-size: 15px; }
.spacer { flex: 1; }
.who { color: var(--muted); }
.tag {
  background: #eef2ff;
  color: var(--accent);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 12px;
  font-weight: 600;
}
.link {
  background: none;
  border: 0;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-decoration: none;
}
.link:hover { text-decoration: underline; }

.center { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
}
.login { width: 340px; display: flex; flex-direction: column; gap: 12px; }
.login h1 { margin: 0; font-size: 20px; }
.login .sub { margin: -8px 0 8px; color: var(--muted); font-size: 12px; }
input, select {
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
button.primary, .login button[type=submit] {
  padding: 9px 14px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
button.primary:hover, .login button[type=submit]:hover { background: #1d4ed8; }
button.primary:disabled { opacity: .5; cursor: default; }
.err { color: var(--danger); min-height: 20px; font-size: 13px; }
.ok { color: #16a34a; font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.app {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, transform .15s;
}
.app:hover { border-color: var(--accent); transform: translateY(-1px); }
.app h3 { margin: 0 0 6px; font-size: 15px; }
.app p { margin: 0; color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 24px; }

main#admin { padding: 24px; max-width: 1100px; margin: 0 auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #fafbfc; font-weight: 600; font-size: 13px; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.apps-cell { display: flex; flex-wrap: wrap; gap: 10px; }
.apps-cell label { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }
.row-actions { display: flex; gap: 10px; white-space: nowrap; }
.danger { color: var(--danger); }
.newuser { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.newuser .full { grid-column: 1 / -1; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); font-size: 12px; }

/* ─── 首页：三层报表清单 ───────────────────────────────────────────────── */
.reports-page { padding: 24px; max-width: 1080px; margin: 0 auto; }
.tier { margin-bottom: 34px; }
.tier h2 { font-size: 17px; margin: 0 0 12px; }

table.reports { table-layout: fixed; }
table.reports th:nth-child(1), table.reports td.seq { width: 46px; color: var(--muted); }
table.reports th:nth-child(2) { width: 26%; }
table.reports th:nth-child(3) { width: 32%; }  /* 「给谁」列示到人：5 人一行放得下，7 人折两行 */
table.reports th:nth-child(4) { width: 12%; }
table.reports td { vertical-align: middle; }
table.reports tbody tr:hover { background: #fafbfc; }
table.reports .note { color: var(--muted); font-size: 12px; margin-top: 3px; }

/* 「给谁」列：只列人名，条目之间自动补顿号；岗位挂在 title 上悬停可见 */
table.reports td.who-cell { line-height: 1.8; }
.who-item { font-size: 13px; white-space: nowrap; }
/* 顿号必须挂在前一个名字的 ::after，不能挂下一个的 ::before：
   「、」是收尾类标点，行首不允许出现它，而 .who-item 又是 nowrap 禁止其后断行，
   两条一夹，整串名字就成了不可断的一坨——2026-09-03 表格固定布局下溢出压住了「频率」列。 */
.who-item:not(:last-child)::after { content: "、"; color: var(--muted); }
.who-plain { color: var(--muted); }  /* 映射表里没有的岗位，保持灰字提示「还没指到人」 */

/* 窄屏用的副本：折在报表名下面。
   隐藏是写在元素的 style="display:none" 上的（见 server.js，防旧缓存 CSS 时重复列示），
   这里只管样式；下面媒体查询里用 !important 把它打开。 */
.who-inline { margin-top: 5px; font-size: 12px; color: var(--muted); line-height: 1.7; }
.who-inline .who-item { font-size: 12px; color: var(--text); }

.entry { color: var(--accent); text-decoration: none; font-weight: 500; white-space: nowrap; }
.entry:hover { text-decoration: underline; }
.pending, .noaccess {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
}
.pending  { background: #f3f4f6; color: var(--muted); }
.noaccess { background: #fef2f2; color: var(--danger); }

.notice { max-width: 1080px; margin: 16px auto -8px; padding: 0 24px; font-size: 13px; }

@media (max-width: 720px) {
  /* 「给谁」不是砍掉，是折到报表名下面（.who-inline）——窄屏也要看得见责任人 */
  table.reports th:nth-child(3), table.reports td.who-cell { display: none; }
  /* 第三列收起后腾出的宽度给报表名（它现在还要装「给谁」那行），
     但别全吃掉——最后一列是入口链接，挤没了就点不着了。
     360px 视口实算：34 + 46% + 16% 之后，入口列还剩约 90px。 */
  table.reports th:nth-child(1), table.reports td.seq { width: 34px; }
  table.reports th:nth-child(2) { width: 46%; }
  table.reports th:nth-child(4) { width: 16%; }
  table.reports th, table.reports td { padding: 10px 8px; }
  .entry { white-space: normal; }   /* 列窄了，入口名允许折行，别撑破表格 */
  .who-inline { display: block !important; }   /* 盖掉元素上兜底的 style="display:none" */
  .reports-page { padding: 16px; }
}

/* ─── 管理后台：按三层分组的报表权限勾选 ────────────────────────────────── */
.apps-cell { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }

.cb-tier {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 8px;
  align-items: baseline;
}
.cb-tier-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 2px;
}
.cb-items { display: flex; flex-wrap: wrap; gap: 6px 14px; }

label.cb {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}
label.cb input { cursor: pointer; }
label.pending-cb { color: var(--muted); cursor: default; }
label.pending-cb input { cursor: default; }
.cb-note { color: var(--muted); font-size: 11px; }

/* 新增用户卡片里的勾选区留出上下间距 */
.newuser .apps-cell { margin: 6px 0; }

@media (max-width: 720px) {
  .cb-tier { grid-template-columns: 1fr; gap: 2px; }
}

/* 多 key 报表行（部门资金按 6 个部门分别授权）：整行独占一行，子勾选框缩进一档 */
.cb-multi { flex-basis: 100%; display: flex; flex-direction: column; gap: 3px; }
.cb-multi-title { font-size: 12px; color: var(--muted); }
.cb-multi .cb-items { padding-left: 10px; }
