:root {
  --navy: #1a3a6b;
  --navy-dark: #142e55;
  --navy-soft: #e8eef8;
  --orange: #e67e22;
  --orange-dark: #ca6d18;
  --green: #27ae60;
  --red: #c0392b;
  --bg: #f5f7fa;
  --text: #2c3e50;
  --muted: #8a96a8;
  --line: #e3e8ee;
  --card: #ffffff;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --radius: 8px;
  --topbar: 54px;
  --sidebar: 220px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid #d0d7de;
  border-radius: 5px;
  outline: none;
  background: #fff;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26, 58, 107, 0.12);
}
input:disabled, select:disabled, textarea:disabled { background: #f3f5f8; color: #7f8c9b; }
textarea { resize: vertical; min-height: 72px; }
table { border-collapse: collapse; width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #1a3a6b 0%, #2c5aa0 100%);
}
.login-box {
  width: 100%; max-width: 400px; background: #fff; border-radius: 12px;
  padding: 36px; box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}
.brand-mark {
  width: 48px; height: 48px; border-radius: 10px; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; letter-spacing: 1px;
  margin: 0 auto 14px;
}
.login-box h1 { margin: 0 0 6px; text-align: center; color: var(--navy); font-size: 20px; }
.login-sub { margin: 0 0 24px; text-align: center; color: var(--muted); font-size: 12px; }
.login-box label { display: block; font-size: 12px; color: #4a5568; margin: 12px 0 6px; font-weight: 600; }
.login-box .btn { margin-top: 20px; padding: 11px; font-size: 15px; }
.login-error {
  margin-top: 12px; padding: 9px 11px; border-radius: 5px;
  background: #fdecea; color: var(--red); font-size: 12px;
}
.login-foot { margin-top: 22px; text-align: center; color: var(--muted); font-size: 12px; }
.login-foot a { color: var(--navy); }
.login-foot span { margin: 0 6px; }

/* ---------- 顶栏 / 侧栏 ---------- */
.app { min-height: 100vh; }
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar); z-index: 100;
  background: var(--navy); color: #fff; display: flex; align-items: center; gap: 12px;
  padding: 0 18px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}
.logo { font-size: 16px; font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.logo small { font-size: 11px; font-weight: 400; opacity: .72; margin-left: 6px; }
.logo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff; color: var(--navy); border-radius: 5px; font-size: 11px; font-weight: 800;
  padding: 3px 6px; margin-right: 6px; letter-spacing: .5px;
}
.topbar-spacer { flex: 1; }
.project-select {
  width: auto; max-width: 300px; background: #fff; color: var(--text);
  border: none; border-radius: 5px; padding: 6px 9px; font-size: 12px;
}
.user-badge {
  background: var(--orange); color: #fff; border-radius: 12px;
  padding: 4px 10px; font-size: 12px; white-space: nowrap;
}
.menu-toggle {
  display: none; background: none; border: 0; color: #fff; font-size: 22px; padding: 0 4px;
}
.sidebar {
  position: fixed; top: var(--topbar); left: 0; bottom: 0; width: var(--sidebar);
  background: #fff; border-right: 1px solid var(--line); overflow-y: auto; z-index: 90;
}
.menu-group { padding: 8px 0; }
.menu-title {
  font-size: 10px; color: var(--muted); padding: 8px 18px 5px;
  letter-spacing: 1.2px; text-transform: uppercase;
}
.nav-item, .nav-link {
  display: flex; align-items: center; gap: 9px; padding: 10px 18px;
  color: #4a5568; border-left: 3px solid transparent; font-size: 13px;
  cursor: pointer; user-select: none;
}
.nav-item:hover, .nav-link:hover { background: #f0f4fa; color: var(--navy); text-decoration: none; }
.nav-item.active { background: var(--navy-soft); color: var(--navy); border-left-color: var(--orange); font-weight: 700; }
.nav-item .ico, .nav-link span:first-child { width: 18px; text-align: center; }
.nav-disabled {
  display: flex; align-items: center; gap: 9px; padding: 9px 18px;
  color: #aab4c2; font-size: 12.5px; cursor: not-allowed;
}
.nav-disabled em {
  margin-left: auto; font-style: normal; font-size: 10px; color: #b7c0cc;
  border: 1px solid #e3e8ee; border-radius: 8px; padding: 1px 6px;
}
.main {
  margin-left: var(--sidebar); padding: calc(var(--topbar) + 22px) 22px 36px;
  min-height: 100vh;
}

/* ---------- 通用 ---------- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 16px;
}
.page-header h2 { margin: 0; font-size: 20px; color: var(--navy); }
.page-header .desc { margin-top: 4px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; color: var(--navy); }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi {
  background: #fff; border-radius: var(--radius); padding: 16px 18px;
  border-left: 4px solid var(--navy); box-shadow: var(--shadow);
}
.kpi.warn { border-left-color: var(--orange); }
.kpi.ok { border-left-color: var(--green); }
.kpi.red { border-left-color: var(--red); }
.kpi .num { font-size: 26px; font-weight: 800; color: var(--navy); line-height: 1.15; }
.kpi .lbl { margin-top: 5px; font-size: 12px; color: var(--muted); }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-end { margin-left: auto; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.empty {
  text-align: center; color: var(--muted); padding: 36px 16px; font-size: 13px;
}
.alert { padding: 12px 14px; border-radius: 6px; font-size: 12.5px; line-height: 1.65; margin-bottom: 14px; }
.alert-info { background: #e8eef8; color: #24466f; }
.alert-warn { background: #fef3e6; color: #9b5a12; }
.alert-ok { background: #e6f7ed; color: #1e7e45; }
.alert-danger { background: #fdecea; color: #a93226; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 5px; padding: 8px 14px;
  background: var(--navy); color: #fff; font-size: 13px; line-height: 1.2;
  transition: .15s; white-space: nowrap;
}
.btn:hover { background: var(--navy-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--navy); }
.btn-orange { background: var(--orange); }
.btn-orange:hover { background: var(--orange-dark); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--navy); }
.btn-ghost:hover { background: var(--navy-soft); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #a93226; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-link { background: none; border: 0; color: var(--navy); padding: 0; font-size: 12px; }
.btn-link:hover { text-decoration: underline; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
table.data { font-size: 12.5px; min-width: 620px; }
table.data th {
  background: var(--navy); color: #fff; text-align: left; padding: 9px 11px;
  font-weight: 500; white-space: nowrap; position: sticky; top: 0;
}
table.data td { padding: 8px 11px; border-bottom: 1px solid #eef1f5; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #f8fafd; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table-empty { text-align: center; color: var(--muted); padding: 28px 12px !important; }

/* ---------- 标签 ---------- */
.tag { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tag-info { background: #e8eef8; color: var(--navy); }
.tag-ok { background: #e6f7ed; color: #1e7e45; }
.tag-warn { background: #fef3e6; color: #b35f11; }
.tag-danger { background: #fdecea; color: #a93226; }
.tag-gray { background: #eef1f5; color: #7f8c9b; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-item { display: flex; flex-direction: column; gap: 5px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { font-size: 12px; color: #4a5568; font-weight: 600; }
.form-item .req { color: var(--red); }
.form-item .help { font-size: 11px; color: var(--muted); line-height: 1.4; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form input { width: auto; min-width: 180px; }

/* ---------- 项目详情 ---------- */
.project-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.project-meta b { color: var(--text); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 12px; }
.section-title h3 { margin: 0; }

/* ---------- 权限矩阵 ---------- */
.matrix-wrap { overflow-x: auto; }
table.matrix { min-width: 1100px; font-size: 12px; }
table.matrix th, table.matrix td { border: 1px solid #e7ebf0; padding: 6px; text-align: center; }
table.matrix th { background: #f0f4fa; color: var(--navy); font-weight: 600; }
table.matrix td:first-child, table.matrix th:first-child {
  position: sticky; left: 0; background: #fff; text-align: left; min-width: 130px; z-index: 1;
}
table.matrix th:first-child { background: #f0f4fa; }
table.matrix label { display: inline-flex; align-items: center; gap: 2px; margin: 0 3px; font-size: 10px; color: #5b6b7f; }
table.matrix input[type="checkbox"] { width: auto; margin: 0; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 300; background: rgba(10, 20, 35, .5);
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 14px; overflow: auto;
}
.modal {
  width: 100%; max-width: 760px; background: #fff; border-radius: 10px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, .32); overflow: hidden;
}
.modal-head {
  background: var(--navy); color: #fff; padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: 0; color: #fff; font-size: 22px; line-height: 1; padding: 0 2px; }
.modal-body { padding: 18px; max-height: 65vh; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; top: 70px; right: 18px; z-index: 500; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 220px; max-width: 380px; padding: 11px 14px; border-radius: 6px;
  color: #fff; font-size: 12.5px; line-height: 1.5; box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
  animation: toast-in .18s ease-out;
}
.toast-info { background: var(--navy); }
.toast-ok { background: var(--green); }
.toast-warn { background: var(--orange); }
.toast-error { background: var(--red); }
@keyframes toast-in { from { transform: translateY(-6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 状态/空态 ---------- */
.loading { padding: 40px; text-align: center; color: var(--muted); }
.no-perm { padding: 60px 20px; text-align: center; color: var(--red); background: #fff; border-radius: var(--radius); }
.steps { display: flex; gap: 10px; flex-wrap: wrap; }
.step {
  flex: 1; min-width: 180px; background: #fff; border: 1px solid var(--line);
  border-top: 3px solid var(--navy); border-radius: 6px; padding: 12px 14px;
}
.step .seq { color: var(--orange); font-weight: 800; font-size: 12px; }
.step b { display: block; margin: 4px 0; color: var(--navy); }
.step span { font-size: 12px; color: var(--muted); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .project-select { max-width: 180px; }
}
@media (max-width: 720px) {
  .menu-toggle { display: inline-block; }
  .sidebar {
    transform: translateX(-100%); transition: transform .2s ease; width: 240px;
    box-shadow: 4px 0 20px rgba(0, 0, 0, .12);
  }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; padding: calc(var(--topbar) + 16px) 14px 28px; }
  .logo small { display: none; }
  .user-badge { display: none; }
  .project-select { max-width: 150px; }
  .login-box { padding: 26px; }
}

/* ---------- P2 业务页面 ---------- */
.p2-filter { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.p2-filter input { width: auto; }
.p2-filter select { width: auto; }
.table-spec { max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diff-plus { color: var(--green); font-weight: 700; }
.diff-minus { color: var(--red); font-weight: 700; }

/* ---------- 责任矩阵用户标签选择 ---------- */
.tag-select { position: relative; min-width: 190px; }
.tag-select-control {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  min-height: 38px; padding: 4px 8px; border: 1px solid #d0d7de;
  border-radius: 5px; background: #fff; cursor: text;
}
.tag-select-control:focus-within {
  border-color: var(--navy); box-shadow: 0 0 0 3px rgba(26, 58, 107, .12);
}
.tag-select-values { display: flex; flex-wrap: wrap; gap: 4px; }
.tag-select-input {
  border: 0 !important; box-shadow: none !important; background: transparent;
  padding: 2px !important; min-width: 90px; flex: 1; font-size: 12px;
}
.tag-select-input:focus { border: 0; box-shadow: none; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--navy-soft); color: var(--navy);
  border-radius: 10px; padding: 2px 7px; font-size: 11.5px; line-height: 1.5;
}
.tag-chip.readonly { background: #eef1f5; color: #4a5568; }
.tag-chip-remove {
  background: none; border: 0; color: var(--navy); font-size: 14px;
  line-height: 1; padding: 0 1px; cursor: pointer;
}
.tag-chip-remove:hover { color: var(--red); }
.tag-select-menu {
  position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 220px; overflow: auto; background: #fff;
  border: 1px solid #d0d7de; border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .14); padding: 4px;
}
.tag-option {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: 0; border-radius: 4px; padding: 7px 9px;
  text-align: left; font-size: 12.5px; color: var(--text);
}
.tag-option:hover { background: #f0f4fa; }
.tag-option.selected { background: var(--navy-soft); color: var(--navy); font-weight: 600; }
.tag-option small { margin-left: auto; color: var(--muted); font-size: 10.5px; }
.tag-select-empty { padding: 8px; color: var(--muted); font-size: 12px; }
