:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e5e9f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff5ff;
  --green: #059669;
  --green-soft: #ecfdf5;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --purple: #7c3aed;
  --purple-soft: #f5f3ff;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --slate: #475569;
  --slate-soft: #f1f5f9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(140deg, #eff5ff 0%, #f4f6fa 45%, #f0fdf4 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 14px;
  padding: 34px 30px 30px;
  box-shadow: 0 10px 40px rgba(15, 23, 42, .1);
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.2px; }
.login-card p.sub { margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: #334155; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; background: var(--red-soft); }
.btn.danger:hover { background: #fee2e2; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- 布局 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.brand { font-weight: 650; font-size: 15px; letter-spacing: -.2px; display: flex; align-items: center; gap: 9px; }
.brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.brand small { font-weight: 400; color: var(--muted); font-size: 12px; }
.topbar nav { display: flex; gap: 4px; margin-left: 8px; }
.tab {
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { background: var(--slate-soft); color: var(--text); }
.tab.active { background: var(--primary-soft); color: var(--primary-dark); }
.tab .badge {
  background: var(--red); color: #fff;
  font-size: 11px; line-height: 1;
  padding: 3px 6px; border-radius: 99px;
}
.topbar .spacer { flex: 1; }

.page { max-width: 1440px; margin: 0 auto; padding: 22px 24px 60px; }

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .k { font-size: 12px; color: var(--muted); margin-bottom: 7px; }
.stat .v { font-size: 24px; font-weight: 680; letter-spacing: -.6px; line-height: 1; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; letter-spacing: 0; }
.stat.warn .v { color: var(--amber); }
.stat.danger .v { color: var(--red); }
.stat.ok .v { color: var(--green); }

/* ---------- 工具条 ---------- */
.toolbar {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar input[type=search] {
  flex: 1 1 220px;
  min-width: 180px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}
.toolbar input[type=search]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .1); }
.toolbar select {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
  min-width: 118px;
}
.toolbar .count { color: var(--muted); font-size: 13px; margin-left: auto; }

/* ---------- 表格 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: #fafbfd;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f1f4f9;
  white-space: nowrap;
  vertical-align: middle;
}
tbody tr { transition: background .12s; cursor: pointer; }
tbody tr:hover { background: #f8fbff; }
tbody tr:last-child td { border-bottom: none; }
td.name { font-weight: 550; }
td .sub { color: var(--muted); font-size: 12px; margin-top: 2px; font-weight: 400; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.on { color: var(--green); background: var(--green-soft); }
.pill.leave { color: var(--amber); background: var(--amber-soft); }
.pill.loan { color: var(--purple); background: var(--purple-soft); }
.pill.out { color: var(--slate); background: var(--slate-soft); }
.pill.transfer { color: #0891b2; background: #ecfeff; }
.pill.pending { color: var(--amber); background: var(--amber-soft); }
.pill.approved { color: var(--green); background: var(--green-soft); }
.pill.rejected { color: var(--red); background: var(--red-soft); }

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}
.pager .spacer { flex: 1; }

.empty { padding: 60px 20px; text-align: center; color: var(--muted); }

/* ---------- 抽屉 ---------- */
.drawer-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .38);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(760px, 100%);
  background: var(--card);
  z-index: 100;
  transform: translateX(100%);
  transition: transform .26s cubic-bezier(.4, 0, .2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(15, 23, 42, .14);
}
.drawer.show { transform: translateX(0); }
.drawer-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.drawer-head h2 { margin: 0; font-size: 17px; letter-spacing: -.2px; }
.drawer-head .spacer { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: #fafbfd;
}
.icon-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--slate-soft); color: var(--text); }

.sec-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .4px;
  margin: 4px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.sec-title:not(:first-child) { margin-top: 24px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}
.form-grid .full { grid-column: 1 / -1; }

.issue-box {
  background: var(--amber-soft);
  border: 1px solid #fde68a;
  border-radius: 9px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.issue-box h4 { margin: 0 0 8px; font-size: 13px; color: #92400e; display: flex; align-items: center; gap: 6px; }
.issue-box ul { margin: 0; padding-left: 18px; color: #92400e; font-size: 12.5px; line-height: 1.75; }

.timeline { border-left: 2px solid var(--line); padding-left: 14px; margin: 6px 0 0; }
.timeline li { list-style: none; margin-bottom: 12px; position: relative; font-size: 13px; color: #334155; }
.timeline li::before {
  content: ""; position: absolute; left: -20px; top: 5px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--primary);
}

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .42);
  z-index: 120;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--card);
  border-radius: 12px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
  overflow: hidden;
}
.modal-head { padding: 18px 20px 0; font-weight: 600; font-size: 16px; }
.modal-body { padding: 14px 20px 18px; color: #334155; line-height: 1.7; font-size: 13.5px; }
.modal-foot { padding: 0 20px 18px; display: flex; gap: 10px; justify-content: flex-end; }

.toast {
  position: fixed;
  left: 50%; bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #fff;
  padding: 11px 18px;
  border-radius: 9px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: all .22s;
  z-index: 200;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #b91c1c; }

.hidden { display: none !important; }
.mono { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* ---------- 附件上传 / 缩略图 ---------- */
.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 13px;
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  background: #f8fafc;
  color: #475569;
  font-size: 14px;
  font-weight: 500;
  transition: all .15s;
}
.upload-btn:hover { border-color: var(--primary); color: var(--primary-dark); background: var(--primary-soft); }

.file-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 9px;
  margin-top: 11px;
}
.file-list:empty { display: none; }
.file-item {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: #f1f5f9;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.file-item .pdf {
  font-size: 11px; color: var(--muted); padding: 8px;
  text-align: center; word-break: break-all; line-height: 1.4;
}
.file-item .del {
  position: absolute; top: 4px; right: 4px;
  width: 21px; height: 21px; border-radius: 50%;
  background: rgba(15, 23, 42, .68); color: #fff;
  border: none; font-size: 12px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.file-item .del:hover { background: #b91c1c; }
.file-item .nm {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(15, 23, 42, .6); color: #fff;
  font-size: 10px; padding: 3px 5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.evidence-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }

@media (max-width: 640px) {
  .topbar-inner { padding: 0 12px; gap: 8px; height: auto; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; }
  .brand small { display: none; }
  .page { padding: 14px 12px 40px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { padding: 10px; }
  .toolbar .count { margin-left: 0; width: 100%; }
  thead th, tbody td { padding: 9px 10px; }
}
