/* HRBP 管理台 —— 深色、克制、表格优先（多为数字密集的核对场景） */
:root {
  --bg: #0f1218;
  --bg-2: #151a23;
  --bg-3: #1c222d;
  --line: #2a3240;
  --tx: #e6eaf2;
  --tx-2: #9aa7bd;
  --tx-3: #6b7891;
  --acc: #3d8bfd;
  --acc-2: #2f6fd0;
  --ok: #35c98a;
  --warn: #e2b33c;
  --err: #f0605c;
  --info: #6aa6ff;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--tx);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
h1, h2, h3 { margin: 0 0 .5em; font-weight: 600; line-height: 1.3; }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }
a { color: var(--acc); }
.muted { color: var(--tx-2); } .small { font-size: 12px; }
.err { color: var(--err); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.boot { padding: 40px; color: var(--tx-2); }
[hidden] { display: none !important; }

/* 登录 */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.login-card { width: min(420px, 100%); display: grid; gap: 12px; }
.login-card h1 { margin-bottom: 0; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--tx-2); }
input, select, textarea {
  background: var(--bg); color: var(--tx); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--acc); outline-offset: 1px; }
button {
  background: var(--bg-3); color: var(--tx); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; font: inherit; cursor: pointer;
}
button:hover { border-color: #3c4757; }
button.primary { background: var(--acc); border-color: var(--acc); color: #fff; font-weight: 600; }
button.primary:hover { background: var(--acc-2); }
button.ghost { background: transparent; }
button.danger { color: var(--err); }
button.tiny { padding: 2px 8px; font-size: 12px; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* 布局 */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 18px; background: var(--bg-2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 22px; }
.brand div { display: grid; }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.period { display: flex; align-items: center; gap: 6px; }
.period input { width: 140px; }
.who { color: var(--tx-2); font-size: 13px; }
.badge { font-size: 12px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--line); }
.badge.trial { color: var(--warn); border-color: #5a4a1c; background: #241f10; }
.badge.formal { color: var(--ok); border-color: #1f5540; background: #10231c; }

.layout { display: grid; grid-template-columns: 208px 1fr; align-items: start; }
.sidebar { position: sticky; top: 57px; padding: 12px 8px; display: grid; gap: 2px; max-height: calc(100vh - 57px); overflow: auto; }
.sidebar button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: transparent; border: 0; text-align: left; padding: 8px 10px; border-radius: 8px; color: var(--tx-2);
}
.sidebar button:hover { background: var(--bg-2); color: var(--tx); }
.sidebar button.active { background: var(--bg-3); color: var(--tx); font-weight: 600; }
.sidebar .count { font-size: 11px; background: var(--err); color: #fff; border-radius: 999px; padding: 0 6px; }
.sidebar .nav-group { margin-bottom: 2px; }
.sidebar .nav-group-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%;
  background: transparent; border: 0; cursor: pointer; padding: 9px 10px 4px;
  color: var(--tx-3); font-size: 12px; letter-spacing: .4px; text-align: left;
}
.sidebar .nav-group-head:hover { color: var(--tx-2); }
.sidebar .nav-group-body { display: grid; gap: 2px; }
.sidebar .nav-group-head .count { font-size: 11px; background: var(--warn); color: #1a1a1a; }
.nav-mobile { display: none; }
.view { padding: 18px 22px 60px; min-width: 0; }

/* 区块 */
.panel { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head .tools { display: flex; gap: 8px; flex-wrap: wrap; }
.grid { display: grid; gap: 14px; }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi-card { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; gap: 4px; }
.kpi-card .v { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-card .l { color: var(--tx-2); font-size: 12px; }
.kpi-card .s { font-size: 12px; color: var(--tx-3); }
.bar { height: 8px; background: var(--bg-3); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--acc); }
.bar.warn > i { background: var(--warn); } .bar.ok > i { background: var(--ok); } .bar.err > i { background: var(--err); }

/* 表格 */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); }
/* macOS 默认隐藏滚动条 → 宽表格右边的列（尤其"操作"）用户根本滚不到。
   所以：① 横向滚动条始终可见；② 操作列固定在最右侧，横滚时不动。 */
.table-wrap::-webkit-scrollbar { height: 10px; width: 10px; }
.table-wrap::-webkit-scrollbar-track { background: var(--bg); border-radius: 0 0 var(--radius) var(--radius); }
.table-wrap::-webkit-scrollbar-thumb { background: #3c4757; border-radius: 999px; }
.table-wrap::-webkit-scrollbar-thumb:hover { background: #55637a; }
.table-wrap { scrollbar-width: thin; scrollbar-color: #3c4757 var(--bg); }
th.sticky-col, td.sticky-col {
  position: sticky; right: 0; z-index: 2; background: var(--bg-2);
  box-shadow: -10px 0 10px -10px rgba(0, 0, 0, .75);
}
th.sticky-col { background: var(--bg-3); z-index: 3; }
tbody tr:hover td.sticky-col { background: #1a2029; }
tfoot td.sticky-col { background: var(--bg-3); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { background: var(--bg-3); color: var(--tx-2); font-weight: 600; position: sticky; top: 0; z-index: 1; }
tbody tr:hover { background: #1a2029; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { background: var(--bg-3); font-weight: 600; }
td.wrap, th.wrap { white-space: normal; min-width: 220px; }
.tag { font-size: 11px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); color: var(--tx-2); }
.tag.ok { color: var(--ok); border-color: #1f5540; } .tag.warn { color: var(--warn); border-color: #5a4a1c; }
.tag.err { color: var(--err); border-color: #5d2724; } .tag.info { color: var(--info); border-color: #24405e; }
.tag.draft { color: var(--tx-3); } .tag.confirmed, .tag.approved, .tag.verified, .tag.locked { color: var(--ok); border-color: #1f5540; }
.tag.submitted, .tag.first_reviewed, .tag.pending { color: var(--warn); border-color: #5a4a1c; }
.tag.rejected { color: var(--err); border-color: #5d2724; }
.empty { padding: 24px; text-align: center; color: var(--tx-3); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.spacer { flex: 1; }

/* 检核 */
.issue { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; align-items: start; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.issue:last-child { border-bottom: 0; }
.issue .lv { font-size: 11px; text-align: center; border-radius: 6px; padding: 2px 0; border: 1px solid var(--line); }
.issue.error .lv { color: var(--err); border-color: #5d2724; background: #241111; }
.issue.warn .lv { color: var(--warn); border-color: #5a4a1c; background: #241f10; }
.issue.info .lv { color: var(--info); border-color: #24405e; background: #111c28; }
.issue .t { font-weight: 600; }
.issue .d { color: var(--tx-2); font-size: 12px; }

/* 弹窗 */
.modal-back { position: fixed; inset: 0; background: rgba(4, 6, 10, .72); display: grid; place-items: start center; padding: 40px 16px; z-index: 50; overflow: auto; }
.modal { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; width: min(920px, 100%); box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal .body { padding: 18px; display: grid; gap: 14px; max-height: 68vh; overflow: auto; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.hint { color: var(--tx-3); font-size: 12px; }
.callout { border: 1px solid var(--line); border-left: 3px solid var(--info); background: #121821; border-radius: 6px; padding: 10px 12px; font-size: 13px; color: var(--tx-2); }
.callout.warn { border-left-color: var(--warn); }
.callout.err { border-left-color: var(--err); }
.steps { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.steps .st { font-size: 12px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; color: var(--tx-3); }
.steps .st.done { color: var(--ok); border-color: #1f5540; }
.steps .st.now { color: var(--warn); border-color: #5a4a1c; }
details { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
summary { cursor: pointer; color: var(--tx-2); }
hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .sidebar { position: static; max-height: none; grid-auto-flow: column; overflow-x: auto; } .split { grid-template-columns: 1fr; } }

/* 提示 */
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 90; }
.toast { background: var(--bg-3); border: 1px solid var(--line); border-left: 3px solid var(--acc); border-radius: 8px; padding: 10px 14px; max-width: 380px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.err { border-left-color: var(--err); } .toast.ok { border-left-color: var(--ok); } .toast.warn { border-left-color: var(--warn); }

/* 材料库内嵌检索（需求单 / 采购单填单时选料） */
.mp-box { display: grid; gap: 6px; }
.mp-results { max-height: 240px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); }
.mat-hit { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; border-bottom: 1px solid var(--line); font-size: 13px; }
.mat-hit:last-child { border-bottom: 0; }
.mat-hit:hover { background: var(--bg-3); }
.mat-hit .mh-name { flex: 1; min-width: 160px; }
.mat-hit .mono { min-width: 78px; text-align: right; }
.sse-dot { font-size: 11px; padding: 2px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--tx-3); }
.sse-dot.live { color: var(--ok); border-color: #1f5540; }
.sse-dot.down { color: var(--warn); border-color: #5a4a1c; }

/* ─────────── 手机端（现场用：提需求单、派工、报进度） ───────────
   思路：宽表格在小屏改成"一行一张卡片"，字段名由 td[data-label] 提供；
   输入字号锁定 16px 防止 iOS 聚焦缩放；点按目标不小于 38px。 */
@media (max-width: 760px) {
  .topbar { position: static; padding: 8px 10px; gap: 8px; }
  .brand strong { font-size: 14px; }
  .brand .muted { display: none; }
  .topbar-right { gap: 6px; }
  .period input { width: 118px; }
  .who { font-size: 12px; }
  .layout { grid-template-columns: 1fr; }
  /* 手机端不用横向滚动的模块条（24 个模块会有一半藏在屏幕外），改用原生分组下拉 */
  .sidebar { display: none; }
  .nav-mobile {
    display: block; flex: 1 1 100%; order: -1; width: 100%;
    min-height: 42px; margin-bottom: 2px; font-size: 15px;
    background: var(--bg-3); border-color: #3c4757;
  }
  .view { padding: 12px 12px 80px; }
  .panel { padding: 12px; }
  h1 { font-size: 18px; } h2 { font-size: 16px; }

  /* 表格 → 卡片 */
  .table-wrap { border: 0; background: transparent; overflow: visible; }
  /* 手机端表格变成"一行一卡片"，不需要固定列 */
  .table-wrap td.sticky-col, .table-wrap th.sticky-col { position: static; box-shadow: none; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; background: var(--bg-2); padding: 8px 10px; }
  .table-wrap tbody tr:hover { background: var(--bg-2); }
  .table-wrap td {
    border: 0; padding: 5px 0; white-space: normal; text-align: left !important;
    display: grid; grid-template-columns: 92px 1fr; gap: 8px; align-items: start; min-width: 0;
  }
  .table-wrap td::before { content: attr(data-label); color: var(--tx-3); font-size: 12px; line-height: 1.7; }
  .table-wrap td:empty { display: none; }
  .table-wrap tfoot tr { border-color: #3c4757; }
  .table-wrap td button { margin-right: 6px; margin-bottom: 4px; }

  /* 表单与点按 */
  input, select, textarea { font-size: 16px; }
  button { min-height: 38px; }
  button.tiny { min-height: 32px; padding: 4px 10px; }
  .fields { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .grid.k4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .kpi-card { padding: 10px; }
  .kpi-card .v { font-size: 20px; }
  .mp-results { max-height: 180px; }
  .mat-hit { flex-wrap: wrap; }

  /* 弹窗占满屏，底部按钮固定可点 */
  .modal-back { padding: 0; align-items: stretch; }
  .modal { width: 100%; border-radius: 0; min-height: 100vh; display: flex; flex-direction: column; }
  .modal .body { max-height: none; flex: 1; overflow: auto; padding: 12px; }
  .modal header, .modal footer { padding: 10px 12px; }
  .modal footer { position: sticky; bottom: 0; background: var(--bg-2); flex-wrap: wrap; }
  .modal footer button { flex: 1; min-width: 110px; }

  .pipe-mini { font-size: 15px; letter-spacing: 2px; }
  .steps { gap: 4px; }
  .issue { grid-template-columns: 46px 1fr; }
  .toasts { left: 10px; right: 10px; bottom: 10px; }
  .toast { max-width: none; }
}

/* 项目台账 · 业务线分类卡片 */
.biz-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.biz-card {
  display: grid; gap: 2px; text-align: left; padding: 10px 12px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; color: var(--tx-2);
}
.biz-card:hover { border-color: #3c4757; color: var(--tx); }
.biz-card.on { border-color: var(--acc); background: #131e2e; color: var(--tx); box-shadow: inset 0 0 0 1px var(--acc); }
.biz-card .biz-name { font-weight: 600; font-size: 13px; }
.biz-card .biz-num { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.biz-card .biz-amt { font-size: 12px; color: var(--tx-3); }
.biz-card.on .biz-amt { color: var(--tx-2); }
/* 可点文字（如项目名＝编辑入口）：要一眼看出"这里能点" */
.link { color: var(--acc); cursor: pointer; text-decoration: none; border-bottom: 1px dashed rgba(61, 139, 253, .45); }
.link:hover { color: #6aa6ff; border-bottom-style: solid; }

/* 工作台壳：业务流说明 + 本台关键数字 + 页内 tab（一级导航按业务流走，模块收进工作台） */
.wb-head { margin-bottom: 12px; }
.wb-head .hint { margin: 0 0 8px; }
.wb-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.wb-chip {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 6px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px;
  font-size: 12px; color: var(--tx-2);
}
.wb-chip b { font-size: 15px; color: var(--tx); font-variant-numeric: tabular-nums; }
.wb-chip.warn { border-color: #6b5a20; } .wb-chip.warn b { color: var(--warn); }
.wb-chip.err { border-color: #6b2f2e; } .wb-chip.err b { color: var(--err); }
.wb-chip.ok b { color: var(--ok); }
.wb-tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.wb-tabs button {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; color: var(--tx-2); font-size: 13px;
}
.wb-tabs button:hover { color: var(--tx); border-color: #3c4757; }
.wb-tabs button.on { background: #131e2e; border-color: var(--acc); color: var(--tx); font-weight: 600; }
.wb-tabs .count { background: var(--acc); color: #fff; border-radius: 999px; padding: 0 6px; font-size: 11px; }
.wb-shortcuts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 2px 0 10px; }
h2 .crumb { font-size: 13px; font-weight: 400; color: var(--tx-3); margin-left: 8px; }

/* 项目进度管线：一行一个项目，六环节横排小圆点（信息密度优先，一屏能扫几十个项目） */
.pipe-mini { display: inline-flex; gap: 2px; align-items: center; font-size: 16px; line-height: 1; letter-spacing: 1px; white-space: nowrap; }
.pipe-mini i { font-style: normal; color: var(--tx-3); }
.pipe-mini i.ok { color: var(--ok); }
.pipe-mini i.run { color: var(--warn); }
.pipe-mini i.now { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.toolbar button.on { border-color: var(--acc); background: #131e2e; color: var(--tx); }

@media (max-width: 760px) {
  .biz-grid { grid-template-columns: repeat(2, 1fr); }
  .biz-card .biz-num { font-size: 17px; }
}
