/* public/css/app.css —— 浅色管理后台风格；全部样式集中于此（CSP 禁止内联样式） */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #dde3ec;
  --border-strong: #c4ccd8;
  --text: #1f2937;
  --text-muted: #6b7280;
  --primary: #1e5aa8;
  --primary-hover: #174a8a;
  --primary-soft: #e8f0fb;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #b7791f;
  --warn-soft: #fff7e0;
  --ok: #1e7d4a;
  --ok-soft: #e8f6ee;
  --info-soft: #eef4fb;
  --yellow: #fcf1cc;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body { background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h2 { font-size: 20px; }
h3 { font-size: 15px; margin-bottom: 10px; }
h4 { font-size: 13px; margin: 12px 0 6px; color: var(--text-muted); }
p { margin: 0 0 10px; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; letter-spacing: 0.5px; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px;
  min-height: 52px; padding: 6px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text); white-space: nowrap; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--primary); color: #fff; font-size: 14px; font-weight: 700;
}
.nav { display: flex; gap: 4px; flex: 1 1 auto; flex-wrap: wrap; }
.nav-link { padding: 6px 12px; border-radius: var(--radius); color: var(--text-muted); font-weight: 500; white-space: nowrap; }
.nav-link:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.nav-link.active { background: var(--primary-soft); color: var(--primary); }
.user { display: flex; align-items: center; gap: 10px; flex: 0 1 auto; flex-wrap: wrap; margin-left: auto; }
.user-name { color: var(--text); font-weight: 500; white-space: nowrap; }
.badge, .pill { white-space: nowrap; }
.main { max-width: 1600px; margin: 0 auto; padding: 20px 20px 60px; }

/* ---------- 页面结构 ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; max-width: 900px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back-link {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 2px 0 12px; padding: 7px 16px 7px 10px;
  font-size: 14px; font-weight: 600; color: #fff;
  background: var(--primary); border-radius: 8px;
  box-shadow: 0 2px 8px rgba(30, 90, 168, 0.28);
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
}
.back-link:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(30, 90, 168, 0.34); transform: translateY(-1px); }
.back-link:active { transform: translateY(0); box-shadow: 0 2px 6px rgba(30, 90, 168, 0.3); }
.back-link-arrow {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.22); font-size: 12px; line-height: 1;
}
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 264px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } }
.main-col, .side-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.meta-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 8px 12px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px;
}
.meta-inline { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr; } }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.step b { color: var(--primary); font-size: 13px; }
.step span { color: var(--text-muted); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.stat-num { font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-num.stat-warn { color: var(--warn); }
.stat-label { color: var(--text-muted); font-size: 12px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.filter { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }

/* ---------- 卡片与面板 ---------- */
.card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.panel { padding: 0; overflow: hidden auto; }
.panel-foot { padding: 12px 16px; border-top: 1px solid var(--border); background: #fafbfd; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h3 { margin: 0; display: flex; align-items: center; gap: 10px; }
.card-muted { background: #fafbfd; }
.card-body { margin-top: 8px; }
.collapse { border-top: 1px solid var(--border); padding: 8px 0; }
.collapse summary { cursor: pointer; color: var(--text-muted); font-weight: 500; }
.dl { display: grid; grid-template-columns: 140px minmax(0, 1fr) 140px minmax(0, 1fr); gap: 6px 12px; margin: 0; }
@media (max-width: 900px) { .dl { grid-template-columns: 120px minmax(0, 1fr); } }
.dl dt { color: var(--text-muted); }
.dl dd { margin: 0; font-weight: 500; word-break: break-all; }

/* ---------- 选项卡 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); background: var(--surface); border-radius: var(--radius) var(--radius) 0 0; padding: 0 8px; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; font-weight: 500; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; gap: 8px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { background: var(--bg); border-radius: 10px; padding: 0 8px; font-size: 12px; color: var(--text-muted); }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 13.5px; }
.table th, .table td { border: 1px solid var(--border); padding: 7px 9px; vertical-align: top; text-align: left; }
.table th { background: #f0f3f8; font-weight: 600; color: var(--text); white-space: nowrap; }
.table thead th { border-top: none; }
.table tbody tr:first-child td { border-top: none; }
.table tbody td:first-child, .table thead th:first-child { border-left: none; }
.table tbody td:last-child, .table thead th:last-child { border-right: none; }
.table.hover tbody tr:hover { background: #f7f9fc; }
.table.edit-tight td { padding: 4px 6px; }
.actions-cell { display: flex; flex-direction: row; }
.table td.actions-cell > * { margin-right: 4px; margin-bottom: 2px; }
.cell-warn { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.row-submitted td { background: var(--ok-soft); }
.row-yellow td { background: var(--yellow); }
.row-yellow.row-submitted td { background: #dff2e6; }
.row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.row-unassigned td:nth-child(1) { box-shadow: inset 3px 0 0 var(--text-muted); }
.row-disabled td { color: var(--text-muted); }
.row-note { color: var(--warn); font-size: 12px; margin-top: 2px; }
.link-strong { font-weight: 600; color: var(--text); }
.sum-ok { color: var(--ok); font-weight: 600; }
.sum-bad { color: var(--danger); font-weight: 600; }
.overview-table td { font-size: 13px; }
.audit-table td:nth-child(5) { min-width: 320px; }

/* ---------- 项目区块（预填编辑） ---------- */
.project { border-bottom: 1px solid var(--border); padding: 12px 16px 16px; }
.project:last-child { border-bottom: none; }
.project-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.project-tag { background: var(--primary-soft); color: var(--primary); border-radius: 4px; padding: 2px 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.project-name { flex: 1; min-width: 260px; font-weight: 600; }
.project-actions { display: flex; gap: 4px; }
.table-edit td { padding: 5px 5px; }
.table-edit .input-sm { width: 100%; min-width: 0; }
.table-prefill { table-layout: fixed; }
/* 固定布局下列宽取自表头单元格，故 th 与 td 同写 */
.table-prefill th:nth-child(1), .table-prefill td:nth-child(1) { width: 38px; }
.table-prefill th:nth-child(2), .table-prefill td:nth-child(2) { width: 210px; }
.table-prefill th:nth-child(3), .table-prefill td:nth-child(3), .table-prefill th:nth-child(4), .table-prefill td:nth-child(4) { width: 76px; }
.table-prefill th:nth-child(5), .table-prefill td:nth-child(5) { width: 72px; }
.table-prefill th:nth-child(6), .table-prefill td:nth-child(6) { width: 130px; }
.table-prefill th:nth-child(8), .table-prefill td:nth-child(8) { width: 42px; }
.table-prefill th:nth-child(9), .table-prefill td:nth-child(9) { width: 80px; }
.table-prefill th:nth-child(10), .table-prefill td:nth-child(10) { width: 92px; }
.table-prefill .member-meta { display: none; }   /* 窄栏里不显示成员填写情况，避免撑宽（“状态”列已有汇总） */
.table-prefill .member-actions { white-space: nowrap; }
.table-prefill td:nth-child(7) { min-width: 170px; }
.member-row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.member-row .input-sm { flex: 1; min-width: 60px; }
.member-actions { display: flex; gap: 12px; margin-top: 4px; }
.alloc-table td:nth-child(3) { width: 140px; }
.alloc-table td .input-sm { width: 100%; max-width: 220px; }
.alloc-table td:nth-child(4) { width: 150px; }
.alloc-table .net-cell { width: 96px; text-align: right; font-variant-numeric: tabular-nums; }
.net-same { color: var(--text-muted); }
.net-cut { color: var(--warn); font-weight: 600; }
.sum-net b { color: var(--primary); }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--text); }
.req { color: var(--danger); }
.hint { font-size: 12px; color: var(--text-muted); }
.input {
  width: 100%; padding: 7px 10px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 90, 168, 0.15); }
.input::placeholder { color: var(--text-muted); opacity: 1; }
.input:disabled, .input[readonly] { background: #f3f4f6; color: var(--text-muted); }
.input-sm { padding: 4px 8px; font-size: 13px; width: auto; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input-bad { border-color: var(--danger); background: var(--danger-soft); }
textarea.input { resize: vertical; min-height: 60px; }
select.input { appearance: auto; }
.check { display: flex; align-items: center; gap: 8px; }
.form-error { color: var(--danger); background: var(--danger-soft); border: 1px solid #f3c1bb; border-radius: var(--radius); padding: 8px 12px; font-size: 13px; }
.credential { background: var(--bg); border: 1px dashed var(--border-strong); border-radius: var(--radius); padding: 10px 14px; margin: 8px 0; font-size: 16px; }
.confirm-text { white-space: pre-line; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 14px; font: inherit; font-weight: 500; line-height: 1.4;
  color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
  cursor: pointer; white-space: nowrap; transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #f3f5f9; text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-sm { padding: 3px 10px; font-size: 13px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { color: var(--danger); border-color: #e0a9a2; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-block { width: 100%; padding: 10px; font-size: 15px; }
.link-btn { background: none; border: none; padding: 0; font: inherit; font-size: 13px; color: var(--primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.save-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 14px; padding: 10px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 -2px 8px rgba(16, 24, 40, 0.06);
}

/* ---------- 标记 ---------- */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.badge-muted, .badge-dark { background: #e9ecf1; color: #3f4a5a; }
.badge-info { background: var(--info-soft); color: var(--primary); }
.badge-success { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-admin { background: #ece7f8; color: #5b3fa0; }
.badge-leader { background: var(--info-soft); color: var(--primary); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- 提示块 ---------- */
.notice { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; border: 1px solid transparent; }
.notice p:last-child { margin-bottom: 0; }
.notice-info { background: var(--info-soft); border-color: #c9dbf3; }
.notice-warn { background: var(--warn-soft); border-color: #f0dca8; }
.notice-danger { background: var(--danger-soft); border-color: #f3c1bb; }
.empty { text-align: center; color: var(--text-muted); padding: 28px 12px; }
.loading { text-align: center; color: var(--text-muted); padding: 40px; }
.check-block { margin-top: 8px; }
.check-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.check-title.is-error { color: var(--danger); }
.check-title.is-warn { color: var(--warn); }
.check-list { margin: 0; padding-left: 18px; font-size: 12.5px; }
.check-list li { margin-bottom: 2px; }
.help-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text); }
.help-list li { margin-bottom: 6px; }
.sum-line { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin: 10px 0 6px; font-size: 14px; }
.sum-item b { font-variant-numeric: tabular-nums; }
.alloc-summary { min-height: 34px; }

/* ---------- 弹窗 ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(16, 24, 40, 0.45); display: flex; align-items: flex-start; justify-content: center; padding: 116px 16px 16px; overflow: auto; }
.modal { background: var(--surface); border-radius: 8px; width: 100%; max-width: 520px; box-shadow: 0 20px 40px rgba(16, 24, 40, 0.25); }
.modal-overlay.modal-wide .modal { max-width: 820px; }
.modal-title { padding: 14px 20px; font-weight: 600; font-size: 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 20px; max-height: 70vh; overflow: auto; }
.modal-body p:last-child { margin-bottom: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); background: #fafbfd; border-radius: 0 0 8px 8px; flex-wrap: wrap; }

/* ---------- 轻提示 ---------- */
/* 顶部居中显示：既不遮挡右上角的操作按钮，也不遮挡底部的保存/提交栏 */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); top: 62px; z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(520px, calc(100vw - 32px)); }
.toast { position: relative; padding: 10px 34px 10px 14px; border-radius: var(--radius); background: #1f2937; color: #fff; font-size: 13px; box-shadow: var(--shadow); border-left: 4px solid #9ca3af; }
.toast-success { border-left-color: #34d399; }
.toast-warn { border-left-color: #fbbf24; }
.toast-danger { border-left-color: #f87171; }
.toast-info { border-left-color: #60a5fa; }
.toast-close { position: absolute; top: 4px; right: 6px; background: none; border: none; color: #d1d5db; font-size: 16px; cursor: pointer; }

/* ---------- 登录页 ---------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #e9eff8 0%, #f6f8fb 60%); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 10px; padding: 28px 32px 32px; box-shadow: 0 10px 30px rgba(16, 24, 40, 0.10); }
.auth-brand { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 13px; margin-bottom: 18px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.booting { padding: 40px; text-align: center; color: var(--text-muted); }

/* ---------- 负责人搜索选择器（弹窗式，可输入姓氏/姓名筛选） ---------- */
.combo-trigger { width: 100%; text-align: left; cursor: pointer; padding: 4px 8px; font-size: 13px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-trigger:hover { border-color: var(--primary); }
.combo-trigger.is-empty { color: var(--text-muted); }
.picker-list { margin-top: 8px; border: 1px solid var(--border); border-radius: var(--radius); max-height: 320px; overflow: auto; background: var(--surface); }
.picker-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: none; border-bottom: 1px solid var(--border); background: none; font: inherit; font-size: 13.5px; color: var(--text); text-align: left; cursor: pointer; }
.picker-item:last-child { border-bottom: none; }
.picker-item:hover, .picker-item.active { background: var(--primary-soft); }
.picker-item.current { font-weight: 600; }
.picker-name { flex: 1; min-width: 0; }
.picker-user { color: var(--text-muted); font-size: 12px; }
.picker-foot { margin-top: 6px; }
.combo-hit { background: #ffe58f; border-radius: 2px; padding: 0 1px; }
.combo-tag { background: var(--warn-soft); color: var(--warn); border-radius: 4px; padding: 0 5px; font-size: 11px; }

/* ---------- 账号列表批量勾选 ---------- */
.check-cell { width: 34px; text-align: center; }
.check-cell .row-check { width: 15px; height: 15px; cursor: pointer; margin: 0; }
.check-cell .row-check:disabled { cursor: not-allowed; opacity: 0.4; }
.table tr.row-selected > td { background: var(--primary-soft); }

/* ---------- 分配明细：负责人自行新增人员 ---------- */
.alloc-table-box { display: flex; flex-direction: column; gap: 10px; }
.alloc-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.alloc-actions .muted { max-width: 640px; }
.table tr.row-new > td { background: #fbfdff; }
.table tr.row-new > td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.table tr.row-added > td { background: #fafcff; }
.pill-soft { background: var(--primary-soft); color: var(--primary); margin-left: 6px; vertical-align: middle; }

/* ---------- 分配明细：姓名可就地编辑 ---------- */
.alloc-table .name-cell .input-sm { max-width: 160px; }
.alloc-table .name-cell .pill-soft { display: inline-block; vertical-align: middle; white-space: nowrap; }
