/* ===== 基础重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body { background: #F5F6FA; color: #1A1A1A; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif; min-height: 100vh; padding-bottom: env(safe-area-inset-bottom); }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select { font-family: inherit; font-size: inherit; outline: none; }
select { appearance: none; -webkit-appearance: none; }

/* ===== 顶部导航 ===== */
.header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center;
  background: #fff; height: 48px;
  padding: 0 12px;
  box-shadow: 0 1px 0 #EBEBEB;
}
.header-back, .header-refresh {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: #333; border-radius: 8px;
  flex-shrink: 0;
}
.header-back:active, .header-refresh:active { background: #F0F0F0; }
.header-title { flex: 1; text-align: center; font-size: 16px; font-weight: 600; color: #1A1A1A; }
.header-refresh.spinning svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.update-time {
  text-align: right; font-size: 11px; color: #999;
  padding: 4px 14px 0;
}

/* ===== 卡片通用 ===== */
.card {
  background: #fff;
  border-radius: 12px;
  margin: 10px 12px 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.card-header {
  display: flex; align-items: center;
  padding: 14px 14px 10px;
  gap: 6px;
}
.section-label {
  font-size: 15px; font-weight: 600; color: #1A1A1A;
  padding-left: 8px;
  border-left: 3px solid #1677FF;
  flex-shrink: 0;
}
.card-sub { font-size: 11px; color: #999; flex: 1; }
.collapse-btn {
  display: flex; align-items: center; gap: 2px;
  font-size: 13px; color: #1677FF; cursor: pointer;
  margin-left: auto; flex-shrink: 0;
}

/* ===== 筛选表单 ===== */
#filterForm { padding: 0 14px 14px; }

.filter-row { margin-bottom: 12px; }

/* 日期+快捷选择行 */
.filter-row-date {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.filter-label { font-size: 12px; color: #666; margin-bottom: 6px; }

.date-range {
  display: flex; align-items: center; gap: 4px;
}
.date-input-wrap {
  position: relative; flex: 1;
  display: flex; align-items: center;
  border: 1px solid #E8E8E8; border-radius: 8px;
  background: #FAFAFA; overflow: hidden;
}
.date-icon { position: absolute; left: 7px; color: #999; flex-shrink: 0; }
.date-icon.right { left: auto; right: 7px; }
.date-input {
  width: 100%; height: 34px;
  border: none; background: transparent;
  padding: 0 8px 0 26px;
  font-size: 12px; color: #333;
}
.date-sep { color: #999; font-size: 13px; flex-shrink: 0; }

.quick-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.quick-btn {
  height: 28px; padding: 0 10px;
  border: 1px solid #E8E8E8; border-radius: 6px;
  font-size: 12px; color: #666; background: #FAFAFA;
  white-space: nowrap;
}
.quick-btn.active {
  background: #1677FF; color: #fff; border-color: #1677FF;
}

/* 三列筛选 */
.filter-row-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.filter-field { min-width: 0; }

.input-wrap, .select-wrap {
  position: relative; display: flex; align-items: center;
  border: 1px solid #E8E8E8; border-radius: 8px;
  background: #FAFAFA; height: 36px; overflow: hidden;
}
.text-input {
  width: 100%; height: 100%;
  border: none; background: transparent;
  padding: 0 28px 0 10px;
  font-size: 12px; color: #333;
}
.text-input::placeholder { color: #BFBFBF; }
.input-icon {
  position: absolute; right: 8px; color: #BFBFBF; pointer-events: none;
}
.select-input {
  width: 100%; height: 100%;
  border: none; background: transparent;
  padding: 0 26px 0 10px;
  font-size: 12px; color: #333;
}
.select-arrow {
  position: absolute; right: 7px; color: #BFBFBF; pointer-events: none;
}

/* 操作按钮 */
.filter-actions {
  display: grid; grid-template-columns: 2fr 1fr;
  gap: 10px; margin-top: 14px;
}
.btn-primary {
  height: 40px; border-radius: 10px;
  background: #1677FF; color: #fff;
  font-size: 15px; font-weight: 500;
  letter-spacing: 1px;
}
.btn-primary:active { opacity: 0.85; }
.btn-default {
  height: 40px; border-radius: 10px;
  background: #F5F5F5; color: #666;
  font-size: 15px;
  border: 1px solid #E8E8E8;
}
.btn-default:active { background: #EBEBEB; }

/* ===== 统计卡片 ===== */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 10px 12px 0;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 14px 12px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.stat-icon-wrap {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon-wrap.blue   { background: #E6F0FF; color: #1677FF; }
.stat-icon-wrap.green  { background: #E8F8E8; color: #52C41A; }
.stat-icon-wrap.purple { background: #F0E8FF; color: #722ED1; }
.stat-icon-wrap.orange { background: #FFF3E8; color: #FA8C16; }

.stat-info { min-width: 0; }
.stat-label { font-size: 11px; color: #888; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: #1A1A1A; line-height: 1.1; }
.stat-value .stat-unit { font-size: 12px; font-weight: 400; color: #888; margin-left: 2px; }

/* ===== 请假列表 ===== */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; }
.data-table th {
  background: #F8F9FB; color: #888;
  font-size: 12px; font-weight: 500;
  padding: 10px 12px;
  border-bottom: 1px solid #F0F0F0;
  text-align: left;
}
.data-table td {
  padding: 10px 12px;
  font-size: 13px; color: #333;
  border-bottom: 1px solid #F6F6F6;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:active td { background: #FAFAFA; }

.status-tag {
  display: inline-block; padding: 2px 8px;
  border-radius: 4px; font-size: 11px; font-weight: 500;
}
.status-approved  { background: #E8F8E8; color: #389E0D; }
.status-pending   { background: #FFF7E6; color: #D46B08; }
.status-rejected  { background: #FFF1F0; color: #CF1322; }
.status-cancelled { background: #F5F5F5; color: #8C8C8C; }

.empty-tip {
  text-align: center; color: #BFBFBF;
  padding: 40px 0; font-size: 13px;
}
.loading-tip { text-align: center; color: #BFBFBF; padding: 20px 0; font-size: 13px; }

.card-header .export-btns { margin-left: auto; display: flex; gap: 8px; }
.export-btn {
  display: flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 10px;
  border-radius: 6px; font-size: 12px;
}
.export-btn.excel { border: 1px solid #52C41A; color: #52C41A; }
.export-btn.pdf   { border: 1px solid #FF4D4F; color: #FF4D4F; }
.export-btn:active { opacity: 0.7; }

.load-more-btn {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  width: 100%; height: 42px;
  color: #1677FF; font-size: 13px;
  border-top: 1px solid #F0F0F0;
}
.load-more-btn:active { background: #F5F5F5; }

/* ===== 调休余额排行 ===== */
.quota-summary-wrap {
  display: flex;
  padding: 4px 14px 14px;
  gap: 14px;
}
.quota-summary-left {
  width: 110px; flex-shrink: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
}
.quota-icon-wrap {
  width: 64px; height: 64px; border-radius: 50%;
  background: #EEF5FF;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.quota-summary-label { font-size: 11px; color: #888; line-height: 1.4; }
.quota-summary-value { font-size: 28px; font-weight: 700; color: #1A1A1A; margin-top: 4px; }
.quota-summary-unit  { font-size: 12px; color: #888; }

.quota-list { flex: 1; min-width: 0; }
.quota-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #F6F6F6;
}
.quota-item:last-child { border-bottom: none; }

.rank-badge {
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.rank-1 { background: linear-gradient(135deg, #FF6B35, #FF9A5C); color: #fff; }
.rank-2 { background: linear-gradient(135deg, #5B8AF0, #8AB4FF); color: #fff; }
.rank-3 { background: linear-gradient(135deg, #FFC107, #FFE082); color: #fff; }
.rank-n { background: #F0F0F0; color: #999; }

.quota-name { font-size: 13px; color: #333; font-weight: 500; flex-shrink: 0; }
.quota-dept { font-size: 11px; color: #999; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quota-days { font-size: 14px; font-weight: 700; color: #1677FF; flex-shrink: 0; white-space: nowrap; }

.more-link {
  display: flex; align-items: center; gap: 2px;
  font-size: 13px; color: #1677FF; margin-left: auto; flex-shrink: 0;
}

/* ===== 全员余额弹窗 ===== */
.modal-mask {
  display: none; position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.45);
}
.modal-mask.show { display: flex; align-items: flex-end; }
.modal-box {
  width: 100%; background: #fff;
  border-radius: 16px 16px 0 0;
  max-height: 80vh; display: flex; flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px;
  font-size: 16px; font-weight: 600;
  border-bottom: 1px solid #F0F0F0;
}
.modal-close {
  font-size: 22px; color: #999; line-height: 1;
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
}
.modal-sort {
  padding: 10px 16px;
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: #888;
  border-bottom: 1px solid #F0F0F0;
}
.sort-btn {
  height: 28px; padding: 0 12px;
  border: 1px solid #E8E8E8; border-radius: 14px;
  font-size: 12px; color: #666;
}
.sort-btn.active { border-color: #1677FF; color: #1677FF; background: #EEF5FF; }
.modal-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 16px; }

.modal-table { width: 100%; border-collapse: collapse; }
.modal-table th {
  font-size: 12px; color: #888; font-weight: 400;
  padding: 10px 0; text-align: left;
  border-bottom: 1px solid #F0F0F0;
  position: sticky; top: 0; background: #fff;
}
.modal-table td { padding: 10px 0; font-size: 13px; border-bottom: 1px solid #F8F8F8; }
.modal-table tr:last-child td { border-bottom: none; }
.modal-total td { font-weight: 700; color: #1677FF; background: #F8FBFF; }

/* ===== 个人查询 ===== */
.personal-search {
  display: flex; gap: 10px; align-items: center;
  padding: 0 14px 4px;
}
.personal-input-wrap {
  flex: 1; position: relative; display: flex; align-items: center;
  border: 1px solid #E8E8E8; border-radius: 10px;
  background: #FAFAFA; height: 40px; overflow: hidden;
}
.personal-input-wrap .text-input { padding: 0 36px 0 12px; font-size: 14px; }
.personal-input-wrap .input-icon { right: 10px; }
.personal-search .btn-primary { width: 72px; height: 40px; flex-shrink: 0; font-size: 14px; }
.personal-hint { font-size: 11px; color: #BFBFBF; padding: 4px 14px 10px; }

#personalResult { padding: 0 14px 14px; }
.personal-card {
  background: #F8FBFF; border-radius: 10px;
  padding: 12px 14px;
}
.personal-name { font-size: 15px; font-weight: 600; color: #1A1A1A; }
.personal-dept { font-size: 12px; color: #999; margin-top: 2px; margin-bottom: 10px; }
.personal-quotas { display: flex; flex-direction: column; gap: 8px; }
.personal-quota-item {
  display: flex; align-items: center; justify-content: space-between;
}
.personal-quota-name { font-size: 13px; color: #555; }
.personal-quota-val { font-size: 16px; font-weight: 700; color: #1677FF; }
.personal-quota-val span { font-size: 12px; font-weight: 400; color: #888; }
.personal-error { text-align: center; color: #FF4D4F; font-size: 13px; padding: 12px 0; }

/* ===== 全局 Loading ===== */
.loading-mask {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(255,255,255,0.6);
  align-items: center; justify-content: center;
}
.loading-mask.show { display: flex; }
.loading-spinner {
  width: 36px; height: 36px; border-radius: 50%;
  border: 3px solid #E8E8E8; border-top-color: #1677FF;
  animation: spin 0.8s linear infinite;
}

/* ===== 打印样式（导出PDF） ===== */
@media print {
  .header, .update-time, #leaveCard, .stats-grid, .quota-summary-wrap,
  .personal-search, .personal-hint, .load-more-btn, .export-btns,
  .loading-mask, .modal-mask { display: none !important; }
  .card { box-shadow: none; margin: 0; border-radius: 0; }
  body { background: #fff; }
}
