/* ============================================
   家政出勤 · 工资管理 - 响应式样式 v2
   适配:桌面 ≥1024px / 平板 768-1023px / 手机 <768px
   ============================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* hidden 属性必须强于组件的 display 声明 */
[hidden] { display: none !important; }

:root {
  --primary: #5b6cf2;
  --primary-dark: #4453d4;
  --primary-light: #e8ecff;
  --primary-tint: #f5f6ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #6b7280;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #eef0f5;
  --text: #2c3142;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --shadow-sm: 0 1px 3px rgba(91, 108, 242, 0.06);
  --shadow: 0 2px 8px rgba(91, 108, 242, 0.08);
  --shadow-lg: 0 8px 24px rgba(91, 108, 242, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --sidebar-w: 240px;
  --topbar-h: 56px;
  --bottom-tabs-h: 60px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input, textarea, select {
  font-family: inherit;
  font-size: 14px;
  color: var(--text);
}

a { color: inherit; text-decoration: none; }

/* ==================== 登录页 ==================== */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(150deg, #eef1ff 0%, #f7f8fc 55%, #e9f6f2 100%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 32px 28px 26px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}

.login-logo {
  font-size: 40px;
  text-align: center;
  line-height: 1;
  margin-bottom: 10px;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.login-sub {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin: 6px 0 18px;
}

.login-form .form-group { margin-bottom: 14px; }

.login-error {
  background: var(--danger-light);
  color: #b91c1c;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 14px;
  line-height: 1.5;
}

.login-tips {
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-light);
  line-height: 1.6;
  text-align: center;
}

/* ==================== 用户菜单 ==================== */
.user-menu { position: relative; }

.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 999px;
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s;
}
.user-btn:hover { background: var(--primary-light); }

.user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex: none;
}

.user-name { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 100;
  animation: fade-in 0.15s;
}

.ud-header {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.ud-name { font-size: 14px; font-weight: 600; color: var(--text); }
.ud-role { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.ud-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  transition: background 0.15s;
}
.ud-item:hover { background: var(--bg); }
.ud-item.danger { color: var(--danger); }
.ud-item.danger:hover { background: var(--danger-light); }

/* ==================== 布局外壳 ==================== */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-areas: "sidebar main";
}

/* ==================== 侧边栏 ==================== */
.sidebar {
  grid-area: sidebar;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 50;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.brand-icon { font-size: 26px; }

.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-title { font-size: 16px; font-weight: 700; color: var(--text); }
.brand-sub { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  cursor: pointer;
}

.nav-item:hover { background: var(--bg); color: var(--text); }

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
}

.staff-switcher { margin-bottom: 10px; }
.ss-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.ss-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}
.ss-btn:hover { background: var(--primary-light); }
.ss-arrow { color: var(--text-light); }

.conn-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.conn-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warning);
}
.conn-status.online .dot { background: var(--success); }
.conn-status.offline .dot { background: var(--danger); }

/* ==================== 主区域 ==================== */
.main-wrap {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(12px);
}

.topbar h1 { font-size: 16px; font-weight: 600; flex: 1; }

.topbar-actions { display: flex; gap: 8px; align-items: center; }

.menu-toggle {
  display: none;
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  color: var(--text);
}
.menu-toggle:hover { background: var(--bg); }

.page-content {
  flex: 1;
  padding: 20px 24px calc(40px + env(safe-area-inset-bottom));
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

/* ==================== 底部 Tab(移动) ==================== */
.bottom-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-tabs-h);
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 60;
  padding-bottom: env(safe-area-inset-bottom);
}

.bt-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 11px;
}

.bt-item.active { color: var(--primary); }
.bt-icon { font-size: 20px; }
.bt-label { font-weight: 500; }

/* ==================== 卡片 ==================== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title strong { color: var(--text); font-size: 15px; font-weight: 700; }

.card-actions { display: flex; gap: 8px; }

/* ==================== 数据网格 ==================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.stat-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.stat-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px 12px;
  text-align: center;
  transition: transform 0.15s;
}
.stat-item:hover { transform: translateY(-2px); }

.stat-item .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-item .value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-item .sub {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

.stat-item.success .value { color: var(--success); }
.stat-item.warning .value { color: var(--warning); }
.stat-item.danger .value { color: var(--danger); }
.stat-item.primary .value { color: var(--primary); }
.stat-item.net .value { color: var(--success); font-size: 26px; }

/* ==================== 按钮 ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }

.btn-ghost {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.92); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.92); }

.btn-light { background: var(--primary-light); color: var(--primary); }
.btn-light:hover { background: #d8defc; }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* ==================== 表单 ==================== */
.form-group { margin-bottom: 14px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

textarea.form-control { resize: vertical; min-height: 60px; }

.form-hint {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 4px;
}

/* ==================== 列表 ==================== */
.list { display: flex; flex-direction: column; gap: 8px; }

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.list-item:hover { border-color: var(--primary); transform: translateX(2px); }

.avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 600;
  flex-shrink: 0;
}
.avatar.tone-1 { background: #5b6cf2; }
.avatar.tone-2 { background: #10b981; }
.avatar.tone-3 { background: #f59e0b; }
.avatar.tone-4 { background: #ef4444; }
.avatar.tone-5 { background: #8b5cf6; }

.list-item-body { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 14px; }
.list-item-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.list-item-actions { display: flex; gap: 6px; }

/* ==================== 员工卡片网格(桌面) ==================== */
.staff-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.staff-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.15s;
}
.staff-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.staff-card-head { display: flex; align-items: center; gap: 12px; }
.staff-card .avatar { width: 48px; height: 48px; font-size: 20px; }
.staff-card-name { font-size: 16px; font-weight: 600; }
.staff-card-meta { font-size: 12px; color: var(--text-muted); }

.staff-card-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}
.staff-card-stat .v { font-size: 16px; font-weight: 700; }
.staff-card-stat .l { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.staff-card-actions { display: flex; gap: 6px; }

/* ==================== 徽章 / 标签 ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg);
  color: var(--text-muted);
}
.badge.primary { background: var(--primary-light); color: var(--primary); }
.badge.success { background: var(--success-light); color: #065f46; }
.badge.warning { background: var(--warning-light); color: #92400e; }
.badge.danger { background: var(--danger-light); color: #991b1b; }
.badge.info { background: #e0f2fe; color: #075985; }

/* ==================== 模态框 ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fade-in 0.2s;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slide-up 0.25s;
}

@keyframes slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body { padding: 20px; overflow-y: auto; }

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ==================== Toast ==================== */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 300;
  animation: toast-in 0.25s;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ==================== Popover(员工选择) ==================== */
.popover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 250;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade-in 0.15s;
}
.popover {
  background: var(--card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: popover-up 0.25s;
}
@keyframes popover-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.popover-header {
  padding: 16px;
  text-align: center;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.popover-body { padding: 12px; overflow-y: auto; }

/* ==================== 日历 ==================== */
.calendar {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.cal-month {
  font-size: 16px;
  font-weight: 600;
}

.cal-nav { display: flex; gap: 6px; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-dow {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  padding: 6px 0;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 13px;
  position: relative;
  cursor: pointer;
  transition: all 0.15s;
}

.cal-day.empty { cursor: default; }
.cal-day:hover:not(.empty) { background: var(--primary-light); }

.cal-day .num { font-weight: 600; line-height: 1; }

.cal-day.today { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-day.weekend { background: #fafbff; color: var(--text-muted); }
.cal-day.holiday { background: var(--warning-light); color: var(--warning); }
.cal-day.work { background: var(--success-light); color: var(--success); }
.cal-day.absent { background: var(--danger-light); color: var(--danger); }
.cal-day.leave { background: #fef9c3; color: #a16207; }

.cal-day .dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: currentColor;
  margin-top: 2px;
}

/* ==================== 工资条 ==================== */
.payroll-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.payroll-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.payroll-head h2 {
  font-size: 22px;
  margin-bottom: 4px;
}

.payroll-meta { color: var(--text-muted); font-size: 13px; }

.payroll-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.payroll-summary .stat-item .value { font-size: 20px; }

.payroll-section {
  padding: 14px 0;
  border-top: 1px dashed var(--border);
}
.payroll-section h4 {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 600;
}

.payroll-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
}

.payroll-row .label { color: var(--text-muted); }
.payroll-row .value { font-weight: 600; font-variant-numeric: tabular-nums; }
.payroll-row.add .value { color: var(--success); }
.payroll-row.minus .value { color: var(--danger); }
.payroll-row.total {
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 12px;
  font-size: 16px;
  font-weight: 700;
}
.payroll-row.net { color: var(--success); font-size: 18px; }

/* ==================== 表格 ==================== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--card);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
}

.table tbody tr:hover { background: var(--bg); }

.table tbody tr:last-child td { border-bottom: none; }

.table-wrap {
  overflow-x: auto;
  margin: 0 -20px;
  padding: 0 20px;
}

/* ==================== 工具类 ==================== */
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-primary { color: var(--primary); }
.text-bold { font-weight: 700; }
.text-lg { font-size: 16px; }
.text-xl { font-size: 18px; }
.text-2xl { font-size: 22px; }

.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }

.layout-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.section-spacer { height: 16px; }

/* ==================== 响应式:平板 ==================== */
@media (max-width: 1023px) {
  .app-shell {
    grid-template-columns: 64px 1fr;
  }
  .sidebar {
    width: 64px;
  }
  .sidebar-brand .brand-text,
  .nav-label,
  .staff-switcher {
    display: none;
  }
  .sidebar-brand { justify-content: center; padding: 18px 8px; }
  .nav-item { justify-content: center; padding: 12px 8px; }
  .sidebar-footer { padding: 12px 8px; }
}

/* ==================== 响应式:手机 ==================== */
@media (max-width: 767px) {
  :root {
    --sidebar-w: 0px;
  }
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-areas: "main";
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s;
    box-shadow: var(--shadow-lg);
    z-index: 100;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-brand .brand-text,
  .nav-label,
  .staff-switcher { display: flex; }
  .sidebar-brand { justify-content: flex-start; padding: 18px 20px; }
  .nav-item { justify-content: flex-start; padding: 10px 14px; }
  .sidebar-footer { padding: 12px 16px 16px; }

  .menu-toggle { display: inline-flex; }

  .page-content {
    padding: 14px 14px calc(70px + env(safe-area-inset-bottom));
  }

  .bottom-tabs { display: flex; }

  .topbar h1 { font-size: 15px; }

  .layout-split { grid-template-columns: 1fr; }

  .stat-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid.cols-3 { grid-template-columns: repeat(2, 1fr); }

  .staff-grid { grid-template-columns: 1fr; }

  .modal { max-width: 100%; }

  .popover { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }

  .payroll-card { padding: 16px; }
  .payroll-head h2 { font-size: 18px; }

  .table th, .table td { padding: 8px 6px; font-size: 12px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
}

/* 移动端:菜单打开时的遮罩 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99;
}
@media (max-width: 767px) {
  .sidebar-overlay.show { display: block; }
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .emoji { font-size: 48px; opacity: 0.4; margin-bottom: 12px; }
.empty-state .title { font-size: 15px; margin-bottom: 4px; }
.empty-state .desc { font-size: 12px; color: var(--text-light); }

/* 详情行(工资条内) */
.detail-list { display: flex; flex-direction: column; gap: 6px; }
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row .d-label { color: var(--text-muted); }
.detail-row .d-value { font-weight: 600; }

/* Switcher 圆点 */
.color-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot-work { background: var(--success); }
.dot-absent { background: var(--danger); }
.dot-leave { background: #facc15; }
.dot-weekend { background: #cbd5e1; }
.dot-holiday { background: var(--warning); }

/* 全屏遮罩(顶部 banner) */
.connection-banner {
  background: var(--warning-light);
  color: #92400e;
  padding: 8px 20px;
  font-size: 13px;
  text-align: center;
  border-bottom: 1px solid #fde68a;
}

/* ============================================
   UI v3 现代化组件扩展
   ============================================ */

/* ---------- Hero 欢迎横幅 ---------- */
.hero {
  background: linear-gradient(135deg, #5b6cf2 0%, #7d8cf8 50%, #9aa8ff 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
}
.hero::after {
  content: '';
  position: absolute;
  bottom: -50px; left: -30px;
  width: 140px; height: 140px;
  background: radial-gradient(circle, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
}
.hero-greet {
  font-size: 13px;
  opacity: 0.85;
  margin-bottom: 4px;
  font-weight: 500;
}
.hero-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 14px;
  position: relative;
  z-index: 1;
}
.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  position: relative;
  z-index: 1;
}
.hero-stat { padding: 4px 0; }
.hero-stat .l { font-size: 11px; opacity: 0.85; }
.hero-stat .v { font-size: 18px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.hero-stat .v small { font-size: 12px; font-weight: 500; opacity: 0.9; margin-left: 2px; }

.hero-mini {
  background: rgba(255,255,255,0.18);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  backdrop-filter: blur(4px);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hero-mini.warn { background: rgba(245, 158, 11, 0.3); }
.hero-mini.danger { background: rgba(239, 68, 68, 0.3); }

/* ---------- Segment Control 分段控件 ---------- */
.segment {
  display: inline-flex;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 4px;
  gap: 2px;
  width: 100%;
}
.segment-item {
  flex: 1;
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  white-space: nowrap;
}
.segment-item:hover { color: var(--text); }
.segment-item.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
}
.segment-item.active.success { color: var(--success); }
.segment-item.active.warning { color: var(--warning); }
.segment-item.active.danger { color: var(--danger); }

/* ---------- Quick Chip 快捷胶囊 ---------- */
.quick-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.quick-chip {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  transition: all 0.15s;
  cursor: pointer;
  border: 1px solid transparent;
}
.quick-chip:hover { background: var(--primary-light); color: var(--primary); }
.quick-chip.active {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ---------- Filter Bar 筛选条 ---------- */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.filter-bar .filter-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  flex-shrink: 0;
}
.filter-bar .filter-search {
  flex: 1;
  min-width: 160px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 13px;
}
.filter-bar .filter-search:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--card);
}
.filter-bar select.filter-search { padding-right: 22px; }

/* ---------- Stat Card 现代化 ---------- */
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.18s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card .stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat-card .stat-value small {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}
.stat-card .stat-delta {
  margin-top: 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.stat-card .stat-delta.up { color: var(--success); }
.stat-card .stat-delta.down { color: var(--danger); }
.stat-card .stat-delta.flat { color: var(--text-light); }

.stat-grid-modern {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

/* ---------- Toast 类型化 ---------- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 300;
  animation: toast-in 0.25s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 86vw;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18);
}
.toast .icon { font-size: 15px; flex: none; }
.toast.success { background: var(--success); }
.toast.warning { background: var(--warning); }
.toast.danger { background: var(--danger); }

/* ---------- Badge 扩展 ---------- */
.badge-sm { padding: 1px 6px; font-size: 10px; }
.badge-dot::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 5px;
  vertical-align: middle;
}

/* ---------- Skeleton 骨架屏 ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--bg) 0%, #eef0f7 50%, var(--bg) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
  border-radius: var(--radius-sm);
}
.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
}
.skeleton-line.lg { height: 22px; width: 60%; }
.skeleton-line.md { width: 80%; }
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ---------- Empty State 增强 ---------- */
.empty-state-hero {
  text-align: center;
  padding: 80px 20px;
}
.empty-state-hero .emoji {
  font-size: 64px;
  margin-bottom: 16px;
  display: inline-block;
  filter: grayscale(0.2);
}
.empty-state-hero .title { font-size: 16px; color: var(--text); margin-bottom: 8px; font-weight: 600; }
.empty-state-hero .desc { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

/* ---------- Compare Card ---------- */
.compare-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--primary-tint), #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
}
.compare-card .compare-block { text-align: center; }
.compare-card .compare-block .l {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.compare-card .compare-block .v {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.compare-card .compare-arrow {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.compare-card .delta {
  margin-top: 4px;
  font-size: 11px;
}
.compare-card .delta.up { color: var(--success); }
.compare-card .delta.down { color: var(--danger); }

/* ---------- Bar 迷你柱状图 ---------- */
.bars {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 60px;
  padding: 8px 0;
}
.bars .bar {
  flex: 1;
  background: var(--primary-light);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  position: relative;
  transition: background 0.15s;
}
.bars .bar:hover { background: var(--primary); }
.bars .bar .tip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.bars .bar:hover .tip { opacity: 1; }

/* ---------- Sticky Action Bar ---------- */
.action-bar {
  position: sticky;
  bottom: 12px;
  margin-top: 16px;
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 30;
}
.action-bar .btn { flex: 1; }
@media (max-width: 767px) {
  .action-bar { bottom: calc(var(--bottom-tabs-h) + 8px); }
}

/* ---------- Tabs (水平) ---------- */
.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow-x: auto;
}
.tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: none;
  flex: none;
}
.tab.active {
  background: var(--card);
  color: var(--primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ---------- Mini Info Row ---------- */
.info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.info-row:last-child { border-bottom: none; }
.info-row .key { color: var(--text-muted); font-size: 13px; }
.info-row .val { font-weight: 600; font-size: 14px; }

/* ---------- Notice Banner ---------- */
.notice {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--primary-dark);
  margin-bottom: 14px;
  line-height: 1.5;
}
.notice .icon { flex: none; font-size: 16px; }
.notice.warning { background: var(--warning-light); color: #92400e; }
.notice.danger { background: var(--danger-light); color: #991b1b; }
.notice.success { background: var(--success-light); color: #065f46; }
.notice.info { background: #e0f2fe; color: #075985; }

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.toolbar .group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar .title { font-size: 15px; font-weight: 700; }
.toolbar .count {
  background: var(--bg);
  color: var(--text-muted);
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  font-weight: 500;
}

/* ---------- Avatar (扩展 small) ---------- */
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 56px; height: 56px; font-size: 22px; }
.avatar.xs { width: 24px; height: 24px; font-size: 11px; }

/* ---------- Modern Card v2 ---------- */
.card-modern {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 14px;
  overflow: hidden;
}
.card-modern .cm-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.card-modern .cm-head h3 {
  font-size: 15px;
  font-weight: 600;
}
.card-modern .cm-head .actions { display: flex; gap: 6px; }
.card-modern .cm-body { padding: 18px; }

/* ---------- Input focus 增强 ---------- */
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ---------- Table hover 增强 ---------- */
.table tbody tr {
  transition: background 0.15s;
}
.table tbody tr:hover { background: var(--primary-tint); }

/* ---------- Mobile-specific input zoom fix ---------- */
@media (max-width: 767px) {
  input, select, textarea {
    font-size: 16px; /* 避免 iOS 自动缩放 */
  }
  .hero { padding: 18px 18px; }
  .hero-title { font-size: 18px; }
  .hero-stats { gap: 8px; }
  .hero-stat .v { font-size: 16px; }
  .compare-card { padding: 12px; }
  .compare-card .compare-block .v { font-size: 16px; }
  .stat-card .stat-value { font-size: 20px; }
}

/* ---------- Dark mode 预留 ---------- */
@media (prefers-color-scheme: dark) {
  /* 暂不启用,留 hook */
}