:root {
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --sidebar: #0f172a;
  --sidebar-w: 232px;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Microsoft YaHei', -apple-system, 'Segoe UI', 'PingFang SC', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px; color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  width: 100%; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 60%, #2563eb 100%);
  padding: 20px;
}
.login-card {
  width: 400px; max-width: 100%; background: #fff; border-radius: 16px;
  padding: 40px 36px; box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-logo { text-align: center; margin-bottom: 26px; }
.login-logo .mark {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  color: #fff; font-size: 24px; font-weight: 700; line-height: 52px; text-align: center;
}
.login-logo h1 { font-size: 22px; color: var(--text); }
.login-logo p { color: var(--muted); font-size: 13px; margin-top: 4px; }
.login-card .field { margin-bottom: 16px; }
.login-err { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 10px; }
.btn-block { width: 100%; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 500;
  background: var(--primary); color: #fff; transition: .15s;
}
.btn:hover { background: var(--primary-d); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--bg); border-color: #cbd5e1; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b91c1c; }
.btn.success { background: var(--green); }
.btn.warn { background: var(--amber); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn.link { background: transparent; color: var(--primary); padding: 4px 8px; }
.btn.link:hover { background: rgba(37,99,235,.08); }
.btn.link.danger { color: var(--red); }
.btn.link.danger:hover { background: rgba(220,38,38,.08); }
.btn.loading { pointer-events: none; opacity: .7; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--sidebar);
  color: #cbd5e1; position: fixed; top: 0; bottom: 0; left: 0; overflow-y: auto;
  z-index: 50;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 18px;
  color: #fff; font-size: 16px; font-weight: 600; border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .mark {
  width: 36px; height: 36px; background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.nav-group { padding: 10px 12px; }
.nav-group-title { font-size: 12px; color: #64748b; padding: 8px 10px 6px; text-transform: uppercase; letter-spacing: .05em; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  color: #cbd5e1; border-radius: 8px; margin-bottom: 2px; font-size: 14px;
}
.nav a svg { flex: 0 0 auto; }
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 58px; background: #fff; border-bottom: 1px solid var(--border); z-index: 40;
}
.topbar h2 { font-size: 17px; }
.topbar .user-box { display: flex; align-items: center; gap: 12px; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 8px; background: var(--bg); padding: 6px 12px; border-radius: 20px; font-size: 13px;
}
.topbar .user-chip .role { font-size: 12px; color: var(--muted); }
.content { padding: 22px 24px 40px; max-width: 1300px; }

/* ---------- 卡片 / 面板 ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card + .card { margin-top: 0; }
.section { margin-bottom: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h3 { font-size: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.toolbar input, .toolbar select { width: auto; min-width: 130px; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-card .icon {
  width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 20px;
}
.stat-card .num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-card .label { color: var(--muted); font-size: 13px; margin-top: 3px; }
.bg-blue { background: #2563eb; } .bg-green { background: #16a34a; } .bg-purple { background: #7c3aed; }
.bg-amber { background: #d97706; } .bg-red { background: #dc2626; } .bg-sky { background: #0891b2; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- 表格 ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.tbl th { color: var(--muted); font-weight: 600; font-size: 13px; background: #f8fafc; white-space: nowrap; }
.tbl tbody tr:hover { background: #f8fafc; }
.tbl .empty td { text-align: center; color: var(--muted); padding: 30px 0; }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge.b-blue { background: #dbeafe; color: #1d4ed8; }
.badge.b-green { background: #dcfce7; color: #15803d; }
.badge.b-red { background: #fee2e2; color: #b91c1c; }
.badge.b-amber { background: #fef3c7; color: #b45309; }
.badge.b-gray { background: #f1f5f9; color: #475569; }
.badge.b-purple { background: #ede9fe; color: #6d28d9; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fadeIn .15s;
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.3);
  max-height: 88vh; display: flex; flex-direction: column; animation: popIn .18s;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-x { border: none; background: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.confirm-text { font-size: 14px; line-height: 1.7; }
.modal-open { overflow: hidden; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { transform: scale(.95); opacity: 0; } }

/* ---------- Toast ---------- */
#toast-box { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 18px; border-radius: 10px; color: #fff; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25); opacity: 0; transform: translateY(-8px);
  transition: .25s;
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: #16a34a; }
.toast.err { background: #dc2626; }
.toast.info { background: #2563eb; }

/* ---------- 树形 ---------- */
.tree-row { display: flex; align-items: center; padding: 8px 10px; border-radius: 8px; transition: .12s; }
.tree-row:hover { background: #f8fafc; }
.tree-row .tw { width: 20px; flex: 0 0 20px; }
.tree-row .t-node { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.tree-row .counts { margin-left: auto; color: var(--muted); font-size: 12px; display: flex; gap: 12px; align-items: center; }
.folder-icon { color: #f59e0b; }
.tree-actions { display: none; gap: 2px; }
.tree-row:hover .tree-actions { display: flex; }

/* ---------- 考勤/排班 ---------- */
.checkin-panel { text-align: center; padding: 26px; }
.checkin-panel .clock { font-size: 42px; font-weight: 700; letter-spacing: 1px; }
.checkin-panel .date { color: var(--muted); margin: 6px 0 18px; }
.checkin-panel .actions { display: flex; gap: 14px; justify-content: center; }
.punch-btn { min-width: 140px; }
.punch-btn.done { background: #d1fae5 !important; color: #065f46 !important; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: #fff; cursor: pointer; font-size: 13px; color: var(--muted); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 排班周视图 */
.sched-grid { display: grid; grid-template-columns: 130px repeat(7, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.sched-grid .grid-head { background: #f8fafc; padding: 10px; text-align: center; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--border); }
.sched-grid .grid-head.emp { text-align: left; }
.sched-grid .g-cell { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 6px; min-height: 44px; }
.sched-grid .g-cell.emp { display: flex; align-items: center; font-size: 13px; }
.sched-grid .g-cell.today { background: #eff6ff; }
.shift-tag { display: block; text-align: center; padding: 4px 4px; border-radius: 6px; color: #fff; font-size: 12px; cursor: pointer; }
.empty-tag { display: block; text-align: center; color: #cbd5e1; font-size: 12px; }

/* ---------- 首页 ---------- */
.welcome { font-size: 18px; margin-bottom: 4px; }
.subtle { color: var(--muted); font-size: 13px; }
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 160px; padding: 10px 6px 0; }
.chart-bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.chart-bars .bar { width: 70%; max-width: 42px; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 6px 6px 0 0; min-height: 2px; }
.chart-bars .bar:hover { filter: brightness(1.1); }
.chart-bars .lab { font-size: 11px; color: var(--muted); }
.list-mini { margin: 0; padding: 0; list-style: none; }
.list-mini li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.list-mini li:last-child { border-bottom: none; }

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

/* 滚动条 */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
}