:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --sidebar: #1f2733;
  --sidebar-hover: #2b3644;
  --sidebar-active: #2f6bff;
  --border: #e4e7ed;
  --border-strong: #d3d7e0;
  --text: #1c2333;
  --text-2: #5a6377;
  --text-3: #8b93a7;
  --brand: #2f6bff;
  --brand-soft: #eaf1ff;
  --green: #12a15a;
  --green-soft: #e6f6ee;
  --amber: #e08a13;
  --amber-soft: #fdf3e2;
  --red: #d93f3f;
  --red-soft: #fdecec;
  --purple: #7048c4;
  --purple-soft: #f1ecfb;
  --cyan: #0f9ab5;
  --cyan-soft: #e4f5f8;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20, 28, 45, .06);
  --shadow: 0 2px 10px rgba(20, 28, 45, .08);
  --shadow-lg: 0 12px 40px rgba(20, 28, 45, .16);
  --sidebar-w: 208px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--brand); text-decoration: none; }

/* ============ 布局 ============ */
.app { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  flex-shrink: 0;
}
.brand-logo {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, #2f6bff, #6a4bff);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px; font-weight: 600;
  flex-shrink: 0;
}
.brand-name { color: #fff; font-size: 14.5px; font-weight: 600; letter-spacing: .2px; }
.brand-sub { color: #7d879b; font-size: 11px; margin-top: -2px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 8px 16px; }
.nav::-webkit-scrollbar { width: 4px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 2px; }

.nav-group-label {
  color: #6b7689; font-size: 11px; font-weight: 500;
  padding: 14px 10px 6px; letter-spacing: .4px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: 8px;
  color: #c3cad8; font-size: 13.5px;
  cursor: pointer; width: 100%; text-align: left;
  transition: background .13s, color .13s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; font-weight: 500; }
.nav-item .ico { width: 17px; text-align: center; flex-shrink: 0; opacity: .95; }
.nav-badge {
  margin-left: auto;
  background: var(--red); color: #fff;
  font-size: 10.5px; padding: 0 5px;
  border-radius: 9px; min-width: 17px; text-align: center;
  line-height: 17px; font-weight: 500;
}
.nav-item.active .nav-badge { background: rgba(255,255,255,.28); }

.sidebar-foot {
  padding: 10px 12px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex; align-items: center; gap: 9px;
  flex-shrink: 0;
}
.avatar-sm {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11.5px; font-weight: 500; flex-shrink: 0;
}
.sidebar-foot .who { color: #fff; font-size: 12.5px; line-height: 1.3; }
.sidebar-foot .role { color: #7d879b; font-size: 11px; }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 56px; flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 22px; gap: 14px;
}
.topbar h1 { font-size: 16px; font-weight: 600; letter-spacing: .2px; }
.topbar .crumb { color: var(--text-3); font-size: 13px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { flex: 1; overflow-y: auto; padding: 20px 22px 40px; }
.content::-webkit-scrollbar { width: 7px; }
.content::-webkit-scrollbar-thumb { background: #cdd2dc; border-radius: 4px; }
.content::-webkit-scrollbar-thumb:hover { background: #b6bcc9; }

/* ============ 通用组件 ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-head h3 { font-size: 14.5px; font-weight: 600; }
.card-head .sub { color: var(--text-3); font-size: 12.5px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 14px; height: 34px;
  border-radius: 8px;
  font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  transition: all .13s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #2559d8; border-color: #2559d8; color: #fff; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #c23232; border-color: #c23232; color: #fff; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--bg); border-color: transparent; color: var(--text); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 13px; color: var(--text-2);
  margin-bottom: 6px; font-weight: 500;
}
.field label .req { color: var(--red); margin-left: 3px; }
.input, .select, .textarea {
  width: 100%; height: 36px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  outline: none; transition: border-color .13s, box-shadow .13s;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 76px; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 107, 255, .1);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%238b93a7' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center;
  padding-right: 28px; cursor: pointer;
}
.field-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }

/* 标签 */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 21px; padding: 0 8px;
  border-radius: 5px;
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.tag-blue { background: var(--brand-soft); color: var(--brand); }
.tag-green { background: var(--green-soft); color: var(--green); }
.tag-amber { background: var(--amber-soft); color: var(--amber); }
.tag-red { background: var(--red-soft); color: var(--red); }
.tag-gray { background: #eef0f4; color: var(--text-2); }
.tag-purple { background: var(--purple-soft); color: var(--purple); }
.tag-cyan { background: var(--cyan-soft); color: var(--cyan); }
.tag-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
table.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f2f5;
  font-size: 13.5px;
  vertical-align: middle;
}
table.tbl tbody tr { transition: background .1s; }
table.tbl tbody tr:hover { background: #f7f9fc; }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl td.num { font-variant-numeric: tabular-nums; }
.emp-cell { display: flex; align-items: center; gap: 9px; }
.emp-name { font-weight: 500; }
.emp-id { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }

/* 空状态 */
.empty {
  padding: 56px 20px; text-align: center; color: var(--text-3);
}
.empty .ico { font-size: 34px; opacity: .35; margin-bottom: 10px; }
.empty .t { font-size: 14px; color: var(--text-2); margin-bottom: 4px; }

/* 抽屉 */
.mask {
  position: fixed; inset: 0;
  background: rgba(20, 28, 45, .38);
  z-index: 90;
  animation: fade .18s;
}
@keyframes fade { from { opacity: 0 } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 520px; max-width: 92vw;
  background: var(--surface);
  z-index: 91;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideIn .22s cubic-bezier(.32, .72, 0, 1);
}
@keyframes slideIn { from { transform: translateX(30px); opacity: .4 } }
.drawer-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
  flex-shrink: 0;
}
.drawer-head h3 { font-size: 16px; font-weight: 600; }
.drawer-head .sub { color: var(--text-3); font-size: 12.5px; margin-top: 2px; }
.drawer-close {
  margin-left: auto; width: 28px; height: 28px;
  border-radius: 7px; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.drawer-close:hover { background: var(--bg); color: var(--text); }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot {
  padding: 13px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 9px; justify-content: flex-end;
  flex-shrink: 0;
}

/* 模态 */
.modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 620px; max-width: 94vw; max-height: 88vh;
  background: var(--surface);
  border-radius: var(--radius-lg);
  z-index: 91;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: pop .2s cubic-bezier(.32, .72, 0, 1);
}
@keyframes pop { from { transform: translate(-50%, -46%) scale(.97); opacity: 0 } }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; flex-shrink: 0;
}
.modal-head h3 { font-size: 15.5px; font-weight: 600; }
.modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 9px; justify-content: flex-end; flex-shrink: 0;
}

/* Toast */
.toast-wrap {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  background: rgba(24, 32, 48, .94);
  color: #fff; padding: 9px 16px;
  border-radius: 8px; font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  animation: toastIn .22s;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px) } }

/* 分段控件 */
.segmented {
  display: inline-flex; background: #eef0f4;
  border-radius: 8px; padding: 3px; gap: 2px;
}
.segmented button {
  padding: 0 13px; height: 27px; border-radius: 6px;
  font-size: 13px; color: var(--text-2);
  transition: all .13s;
}
.segmented button.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow-sm); }

/* 进度条 */
.bar { height: 5px; background: #eef0f4; border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .3s; }

/* 信息行 */
.info-row {
  display: flex; gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid #f2f4f7;
  font-size: 13.5px;
}
.info-row:last-child { border-bottom: none; }
.info-row .k { color: var(--text-3); width: 92px; flex-shrink: 0; }
.info-row .v { color: var(--text); flex: 1; word-break: break-all; }

/* 分区标题 */
.sec-title {
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  margin: 22px 0 10px; display: flex; align-items: center; gap: 7px;
}
.sec-title::before {
  content: ''; width: 3px; height: 13px;
  background: var(--brand); border-radius: 2px;
}
.sec-title:first-child { margin-top: 0; }

/* 工具条 */
.toolbar {
  display: flex; gap: 9px; align-items: center;
  margin-bottom: 14px; flex-wrap: wrap;
}
.toolbar .spacer { margin-left: auto; }
.search-box { position: relative; }
.search-box input {
  width: 226px; height: 34px;
  padding: 0 11px 0 32px;
  border: 1px solid var(--border-strong);
  border-radius: 8px; outline: none;
  transition: border-color .13s, box-shadow .13s;
}
.search-box input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,107,255,.1); }
.search-box .ico {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 13px; pointer-events: none;
}
.toolbar .select { width: auto; min-width: 118px; height: 34px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }