/* ============ 考勤打卡系统 样式 ============ */
:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --green: #16a34a;
  --green-d: #15803d;
  --blue: #0284c7;
  --blue-d: #0369a1;
  --orange: #d97706;
  --orange-d: #b45309;
  --red: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 10px 26px -14px rgba(15, 23, 42, .18);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶栏 ---------- */
.topbar {
  background: linear-gradient(120deg, #1d4ed8, #2563eb 55%, #3b82f6);
  color: #fff;
  box-shadow: 0 2px 10px rgba(29, 78, 216, .25);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
.brand { font-size: 18px; font-weight: 700; color: #fff; text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  color: rgba(255, 255, 255, .92);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
}
.nav a:hover { background: rgba(255, 255, 255, .15); }
.topbar-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-link { color: rgba(255, 255, 255, .85); text-decoration: none; font-size: 13px; }
.topbar-link:hover { text-decoration: underline; }

/* ---------- 布局与卡片 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }
.container.narrow { max-width: 760px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}
.hero { text-align: center; }
.title { margin: 0 0 6px; font-size: 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head-main h1 { margin: 0 0 4px; }
h2.card-title { margin: 0 0 12px; font-size: 17px; }
.muted { color: var(--muted); margin: 4px 0; }
.small { font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 22px 0; }

/* ---------- 首页 ---------- */
.index-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 760px) { .index-grid { grid-template-columns: 1fr; } }
.user-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.user-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .06s;
}
.user-item:hover { border-color: var(--primary); background: #eff6ff; }
.user-item:active { transform: scale(.99); }
.user-meta { display: flex; flex-direction: column; flex: 1; }
.user-meta small { color: var(--muted); }
.user-go { color: var(--primary); font-size: 13px; white-space: nowrap; }
.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
  flex: none;
}
.avatar.sm { width: 22px; height: 22px; font-size: 11px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255, 255, 255, .18);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  color: #fff;
  white-space: nowrap;
}
.chip.gray { background: var(--line); color: var(--muted); }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.field input, .field select {
  font: inherit;
  font-weight: 400;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fff;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.inline-form { display: flex; gap: 8px; align-items: end; }
.filters { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.filters .field { margin-bottom: 0; }
.btn {
  font: inherit;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #e2e8f0;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  white-space: nowrap;
  transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-block { width: 100%; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.msg { color: var(--red); font-size: 14px; margin: 8px 0 0; min-height: 20px; }

/* ---------- 打卡按钮 ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid-3 { grid-template-columns: 1fr; } }
.punch {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius);
  padding: 22px 12px;
  color: #fff;
  font: inherit;
  cursor: pointer;
  min-height: 128px;
  box-shadow: var(--shadow);
  transition: transform .06s, filter .15s;
}
.punch:active { transform: scale(.97); }
.punch:disabled { opacity: .5; cursor: not-allowed; filter: saturate(.4); }
.punch-icon { font-size: 30px; line-height: 1; }
.punch-label { font-size: 17px; font-weight: 700; }
.punch-time { font-size: 13px; opacity: .95; }
.punch-in  { background: linear-gradient(135deg, #22c55e, #15803d); }
.punch-out { background: linear-gradient(135deg, #38bdf8, #0369a1); }
.punch-ot  { background: linear-gradient(135deg, #fbbf24, #d97706); }

/* ---------- 时间线 ---------- */
.tl { margin-top: 6px; }
.tl-item { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.tl-item:last-child { border-bottom: none; }
.tl-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex: none;
}
.tl-in  .tl-icon { background: #dcfce7; }
.tl-out .tl-icon { background: #e0f2fe; }
.tl-ot  .tl-icon { background: #fef3c7; }
.tl-body { flex: 1; min-width: 0; }
.tl-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-loc { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

/* ---------- 日卡片（记录页） ---------- */
.day-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.day-head h2 { margin: 0; font-size: 16px; }
.day-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.meta-item {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  white-space: nowrap;
}
.badge.ok   { background: #dcfce7; color: #15803d; }
.badge.warn { background: #fef3c7; color: #b45309; }
.badge.bad  { background: #fee2e2; color: #b91c1c; }
.badge.blue { background: #e0f2fe; color: #0369a1; }
.badge.gray { background: #e2e8f0; color: #64748b; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f8fafc; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.loc-cell .small { margin-top: 2px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: #fff;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 90vw;
  z-index: 99;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #b91c1c; }
.empty-card p { text-align: center; color: var(--muted); padding: 10px 0; }
/* ---------- 通用密码/确认弹窗 ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}
.modal-mask[hidden] { display: none; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(15, 23, 42, .3);
  padding: 20px;
  width: min(92vw, 360px);
}
.modal-title { margin: 0 0 4px; font-size: 18px; }
.modal .muted { margin-bottom: 10px; }
#m-input {
  width: 100%;
  font: inherit;
  font-size: 18px;
  letter-spacing: .12em;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #fff;
}
#m-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.modal .msg { min-height: 0; margin: 8px 0 0; }

/* ---------- 小按钮 ---------- */
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }

/* ---------- 锁定按钮 ---------- */
.btn-lock {
  background: none;
  border: none;
  color: rgba(255, 255, 255, .92);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 5px 8px;
  border-radius: 8px;
  white-space: nowrap;
}
.btn-lock:hover { background: rgba(255, 255, 255, .18); }
