:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e5eaf1;
  --text: #172033;
  --text-soft: #63708a;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --success: #0f9d6e;
  --success-soft: #e6f7f0;
  --warn: #c2740a;
  --warn-soft: #fff4e0;
  --danger: #d33a3a;
  --danger-soft: #ffeaea;
  --shadow: 0 6px 24px rgba(28, 45, 84, 0.07);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------------- 登录 ---------------- */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: radial-gradient(900px 500px at 15% 0%, #dfeaff 0%, transparent 65%),
              radial-gradient(700px 500px at 90% 100%, #e8f4ff 0%, transparent 60%), var(--bg);
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 30px 26px 24px;
}
.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand-icon {
  width: 50px; height: 50px; flex: none;
  border-radius: 15px;
  background: linear-gradient(145deg, #3b82f6, #1d4ed8);
  color: #fff; font-size: 26px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.28);
}
.brand h1 { margin: 0; font-size: 21px; letter-spacing: -0.3px; }
.brand p { margin: 2px 0 0; color: var(--text-soft); font-size: 13px; }
.role-switch {
  display: flex; gap: 4px; padding: 4px; margin-bottom: 20px;
  background: var(--surface-soft); border: 1px solid var(--border); border-radius: 12px;
}
.role-btn {
  flex: 1; border: 0; background: transparent; color: var(--text-soft);
  padding: 10px 4px; border-radius: 9px; font-weight: 600; font-size: 14px;
}
.role-btn.active { background: var(--surface); color: var(--primary); box-shadow: 0 2px 8px rgba(28,45,84,.09); }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--text-soft); margin-bottom: 7px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 13px; border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface); 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,.11);
}
.field textarea { resize: vertical; min-height: 84px; }
.form-error { color: var(--danger); font-size: 13px; min-height: 20px; margin: -4px 0 8px; }
.login-hint { text-align: center; color: var(--text-soft); font-size: 12px; margin: 16px 0 0; }

/* ---------------- 通用按钮 ---------------- */
.btn {
  border: 1px solid transparent; border-radius: 11px; padding: 10px 16px;
  font-weight: 600; font-size: 14px; background: var(--surface-soft); color: var(--text);
  transition: transform .1s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-block { width: 100%; padding: 13px; font-size: 15px; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 6px 10px; font-size: 12px; border-radius: 8px; }

/* ---------------- 应用框架 ---------------- */
.app-page { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.app-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.94); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: calc(12px + env(safe-area-inset-top)) 18px 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.header-org { font-weight: 700; font-size: 16px; }
.header-sub { color: var(--text-soft); font-size: 12px; margin-top: 1px; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 9px; padding: 6px 12px; font-size: 13px; color: var(--text-soft); }
.view { flex: 1; width: 100%; max-width: 860px; margin: 0 auto; padding: 18px 16px 100px; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  display: flex; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tab {
  flex: 1; border: 0; background: transparent; color: var(--text-soft);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; font-size: 11px; border-radius: 10px;
}
.tab .tab-icon { font-size: 19px; line-height: 1.1; }
.tab.active { color: var(--primary); font-weight: 700; }
.tab.active .tab-icon { transform: translateY(-1px); }

/* ---------------- 卡片与排版 ---------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.card-title { font-weight: 700; font-size: 15px; margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-title small { font-weight: 500; color: var(--text-soft); font-size: 12px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-soft); margin: 22px 2px 10px; text-transform: none; }
.muted { color: var(--text-soft); }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* 打卡页 */
.clock-card { text-align: center; padding: 22px 18px 20px; background: linear-gradient(160deg, #f7faff, #ffffff 65%); }
.clock-date { color: var(--text-soft); font-size: 13px; }
.clock-time { font-size: 42px; font-weight: 700; letter-spacing: 1px; line-height: 1.2; font-variant-numeric: tabular-nums; }
.clock-status { color: var(--text-soft); font-size: 13px; margin-top: 4px; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.status-box { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface-soft); text-align: left; }
.status-box.done { background: var(--success-soft); border-color: #c8eadc; }
.status-box.late { background: var(--warn-soft); border-color: #f3ddb4; }
.status-box .label { font-size: 12px; color: var(--text-soft); }
.status-box .value { font-weight: 700; font-size: 15px; margin-top: 3px; }

.location-line { display: flex; align-items: flex-start; gap: 10px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-soft); }
.location-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--success); margin-top: 6px; flex: none; box-shadow: 0 0 0 4px rgba(15,157,110,.12); }
.location-line.out { background: var(--danger-soft); border-color: #f6d4d4; }
.location-line.out .location-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(211,58,58,.12); }
.location-name { font-weight: 700; }
.location-meta { font-size: 12px; color: var(--text-soft); margin-top: 2px; }
.checkin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.checkin-btn { border: 0; border-radius: 14px; padding: 18px 8px; color: #fff; font-weight: 700; font-size: 16px; box-shadow: 0 8px 18px rgba(37,99,235,.2); }
.checkin-btn.in { background: linear-gradient(145deg, #3b82f6, #1d4ed8); }
.checkin-btn.out { background: linear-gradient(145deg, #475569, #243043); box-shadow: 0 8px 18px rgba(36,48,67,.16); }
.checkin-btn:disabled { opacity: .45; box-shadow: none; }
.checkin-btn small { display: block; font-weight: 500; font-size: 11px; opacity: .85; margin-top: 3px; }

/* 列表 */
.list { display: flex; flex-direction: column; gap: 9px; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.avatar { width: 38px; height: 38px; flex: none; border-radius: 11px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.item-title { font-weight: 600; }
.item-sub { color: var(--text-soft); font-size: 12px; margin-top: 2px; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.normal, .badge.approved, .badge.active { background: var(--success-soft); color: var(--success); }
.badge.late, .badge.pending, .badge.early { background: var(--warn-soft); color: var(--warn); }
.badge.outside, .badge.rejected, .badge.inactive { background: var(--danger-soft); color: var(--danger); }
.badge.neutral { background: var(--surface-soft); color: var(--text-soft); border: 1px solid var(--border); }
.badge.manual { background: #eef2ff; color: #4f46e5; }

/* 统计 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-box { background: var(--surface-soft); border: 1px solid var(--border); border-radius: 13px; padding: 13px; }
.stat-num { font-size: 25px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-soft); font-size: 12px; margin-top: 5px; }
.stat-box.good .stat-num { color: var(--success); }
.stat-box.warn .stat-num { color: var(--warn); }
.stat-box.bad .stat-num { color: var(--danger); }

/* 表格 */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 620px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-soft); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 700px) { .filters { grid-template-columns: 1fr 1fr; } }
.filters .field { margin-bottom: 0; }
.filters input, .filters select { padding: 9px 10px; font-size: 13px; }

/* 表单网格 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 8px; }
.check-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; font-size: 13px; background: var(--surface); }
.check-chip input { accent-color: var(--primary); }
.switch-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.switch-line input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); }

/* 弹窗 */
.modal-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(16,24,40,.42); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
@media (min-width: 640px) { .modal-backdrop { align-items: center; padding: 20px; } }
.modal { width: 100%; max-width: 620px; max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { .modal { border-radius: 18px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-close { border: 0; background: var(--surface-soft); border-radius: 8px; width: 30px; height: 30px; color: var(--text-soft); font-size: 17px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn { flex: 1; }

/* 提示条 */
.notice { background: var(--primary-soft); color: #1e40af; border: 1px solid #d5e4ff; border-radius: 12px; padding: 11px 13px; font-size: 12.5px; line-height: 1.6; }
.notice code { background: rgba(255,255,255,.7); padding: 1px 5px; border-radius: 4px; }
.empty { text-align: center; color: var(--text-soft); padding: 28px 10px; font-size: 13px; }
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 16px); z-index: 100;
  max-width: min(90vw, 460px); background: #172033; color: #fff;
  padding: 11px 16px; border-radius: 11px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.2);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #b83232; }
.toast.success { background: #0d8b63; }

/* 自动签到状态卡 */
.sign-card { text-align: center; padding: 26px 18px; }
.sign-icon {
  width: 62px; height: 62px; margin: 0 auto 12px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center; font-size: 28px; font-weight: 700;
}
.sign-card.done { background: var(--success-soft); border-color: #c8eadc; }
.sign-card.done .sign-icon { background: var(--success); color: #fff; }
.sign-card.late { background: var(--warn-soft); border-color: #f3ddb4; }
.sign-card.late .sign-icon { background: var(--warn); color: #fff; }
.sign-title { font-size: 18px; font-weight: 700; }
.sign-text { color: var(--text-soft); font-size: 13px; margin-top: 5px; }
.neutral-avatar { background: var(--surface-soft); color: var(--text-soft); }
.badge.unsigned { background: var(--surface-soft); color: var(--text-soft); border: 1px solid var(--border); }
