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

:root {
  --primary: #1677ff;
  --primary-light: #e6f4ff;
  --success: #52c41a;
  --warning: #faad14;
  --danger: #ff4d4f;
  --text: #333;
  --text-secondary: #666;
  --text-light: #999;
  --bg: #f5f7fa;
  --card-bg: #fff;
  --border: #e8e8e8;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.page {
  display: none;
  min-height: 100vh;
  padding-bottom: 80px;
}

.page.active {
  display: block;
}

/* ========== 登录页 ========== */
.login-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 40px 24px;
  background: linear-gradient(135deg, #1677ff 0%, #0958d9 100%);
}

.login-header {
  text-align: center;
  margin-bottom: 48px;
  color: #fff;
}

.login-logo {
  font-size: 56px;
  margin-bottom: 16px;
}

.login-header h1 {
  font-size: 28px;
  font-weight: 600;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 15px;
  opacity: 0.85;
}

.login-form {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px 24px;
  box-shadow: var(--shadow);
}

.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.input-group input {
  width: 100%;
  height: 48px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0 16px;
  font-size: 16px;
  transition: border-color 0.2s;
  outline: none;
}

.input-group input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 119, 255, 0.1);
}

.btn-primary {
  width: 100%;
  height: 48px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #0958d9;
}

.btn-primary:active {
  transform: scale(0.98);
}

/* ========== 顶部状态栏 ========== */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.user-name {
  font-size: 15px;
  font-weight: 500;
}

.date-display {
  font-size: 13px;
  color: var(--text-secondary);
}

.device-info-bar {
  padding: 8px 20px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 12px;
  text-align: center;
}

/* ========== 时间卡片 ========== */
.time-card {
  margin: 20px;
  padding: 32px 20px;
  background: linear-gradient(135deg, #1677ff 0%, #4096ff 100%);
  border-radius: var(--radius);
  text-align: center;
  color: #fff;
  box-shadow: 0 4px 16px rgba(22, 119, 255, 0.3);
}

.current-time {
  font-size: 48px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2px;
  margin-bottom: 8px;
}

.time-status {
  font-size: 15px;
  opacity: 0.9;
}

/* ========== 定位卡片 ========== */
.location-card {
  margin: 0 20px 20px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.location-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.location-icon {
  font-size: 20px;
}

.location-title {
  font-size: 15px;
  font-weight: 600;
  flex: 1;
}

.location-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--warning);
  color: #fff;
  font-weight: 500;
}

.location-badge.success {
  background: var(--success);
}

.location-badge.danger {
  background: var(--danger);
}

.location-detail {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.location-distance {
  font-size: 13px;
  color: var(--text-light);
  margin-top: 6px;
}

/* ========== 签到按钮 ========== */
.checkin-section {
  margin: 0 20px 20px;
  text-align: center;
}

.btn-checkin {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #1677ff 0%, #4096ff 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  box-shadow: 0 8px 24px rgba(22, 119, 255, 0.4);
  transition: all 0.2s;
}

.btn-checkin:disabled {
  background: linear-gradient(135deg, #bbb 0%, #ddd 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  cursor: not-allowed;
}

.btn-checkin:not(:disabled):hover {
  transform: scale(1.05);
  box-shadow: 0 12px 32px rgba(22, 119, 255, 0.5);
}

.btn-checkin:not(:disabled):active {
  transform: scale(0.95);
}

.checkin-text {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.checkin-sub {
  font-size: 12px;
  opacity: 0.85;
}

.checkin-status {
  margin-top: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}

.checkin-status.success {
  color: var(--success);
}

.checkin-status.late {
  color: var(--warning);
}

/* ========== 规则卡片 ========== */
.rules-card {
  margin: 0 20px 20px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.rules-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.rule-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rule-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.rule-label {
  color: var(--text-secondary);
}

.rule-value {
  color: var(--text);
  font-weight: 500;
}

/* ========== 签到记录 ========== */
.record-card {
  margin: 0 20px 20px;
  padding: 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.record-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.record-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 8px;
}

.record-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.record-icon.in {
  background: #e6f4ff;
}

.record-icon.out {
  background: #f6ffed;
}

.record-info {
  flex: 1;
}

.record-type {
  font-size: 14px;
  font-weight: 500;
}

.record-time {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 2px;
}

.record-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.record-tag.normal {
  background: #f6ffed;
  color: var(--success);
}

.record-tag.late {
  background: #fff7e6;
  color: var(--warning);
}

.record-tag.early {
  background: #fff1f0;
  color: var(--danger);
}

.record-empty {
  text-align: center;
  color: var(--text-light);
  font-size: 14px;
  padding: 20px 0;
}

/* ========== 历史记录 ========== */
.history-section {
  margin: 0 20px;
}

.btn-secondary {
  width: 100%;
  height: 44px;
  background: var(--card-bg);
  color: var(--primary);
  border: 1.5px solid var(--primary);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--primary-light);
}

.history-header, .admin-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
}

.history-header h2, .admin-header h2 {
  font-size: 17px;
  font-weight: 600;
}

.btn-back {
  background: none;
  border: none;
  font-size: 16px;
  color: var(--primary);
  cursor: pointer;
  padding: 4px 8px;
}

.history-list {
  padding: 20px;
}

.history-date-group {
  margin-bottom: 24px;
}

.history-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  padding-left: 4px;
}

/* ========== 管理设置 ========== */
.admin-content {
  padding: 20px;
}

.setting-group {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.setting-group h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ========== 管理员按钮 ========== */
.btn-admin {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.btn-admin:hover {
  opacity: 1;
}

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 320px;
  width: 90%;
  text-align: center;
}

.modal-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
  line-height: 1.6;
}

.modal-btn {
  width: 100%;
  height: 44px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

/* ========== 响应式 ========== */
@media (min-width: 768px) {
  .page {
    max-width: 480px;
    margin: 0 auto;
  }
}
