:root {
  --brand: #4a7c6f;
  --brand-dark: #3a6359;
  --brand-light: #eaf2ef;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1f2d29;
  --muted: #7b8b86;
  --line: #e3eae7;
  --pending: #e0952f;
  --approved: #3f8f6b;
  --rejected: #cf5b52;
  --appeal: #7a63c9;
  --leave: #d9a400;          /* 休假：黄色 */
  --leave-light: #fff7df;     /* 休假浅黄底 */
  --radius: 12px;
  --shadow: 0 1px 3px rgba(31, 45, 41, .08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ---------- 通用 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { color: var(--muted); text-align: center; padding: 24px 12px; font-size: 13px; }

/* ---------- 底部「装成 App」帮助 ---------- */
.help { max-width: 420px; margin: 16px auto 28px; padding: 14px 16px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); font-size: 13px; line-height: 1.7; }
.help summary { font-weight: 700; cursor: pointer; color: var(--brand); list-style: none; padding: 2px 0; }
.help summary::-webkit-details-marker { display: none; }
.help summary::before { content: "\1F4F1  "; white-space: pre; }
.help h4 { margin: 12px 0 4px; font-size: 13px; }
.help ol { margin: 4px 0; padding-left: 20px; }
.help .note { color: var(--muted); margin-top: 8px; }

.input, .select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 15px;
  background: #fff;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
}
.select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path d='M1 1l5 5 5-5' fill='none' stroke='%237b8b86' stroke-width='2' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}
.input:focus, .select:focus { outline: none; border-color: var(--brand); }
textarea.input { min-height: 76px; resize: vertical; font-family: inherit; }

.btn {
  display: block;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 9px;
  background: var(--brand);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:active { background: var(--brand-dark); }
.btn:disabled { background: #b6c4bf; cursor: not-allowed; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.ghost:active { background: var(--brand-light); }
.btn.danger { background: var(--rejected); }
.btn.gray { background: #8b9a95; }
.btn.mini { width: auto; padding: 7px 14px; font-size: 13px; border-radius: 7px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }

.err { color: var(--rejected); font-size: 13px; margin-top: 8px; }

/* ---------- 登录 ---------- */
#login { max-width: 420px; margin: 0 auto; padding: calc(28px + env(safe-area-inset-top, 0px)) 18px 28px; }
.brand { text-align: center; margin-bottom: 22px; }
.brand .logo {
  width: 56px; height: 56px; border-radius: 16px; background: var(--brand);
  color: #fff; font-weight: 800; font-size: 21px; line-height: 56px; margin: 0 auto 10px;
}
.brand h1 { font-size: 19px; margin: 0 0 3px; }
.brand .sub { color: var(--muted); font-size: 12px; }

.seg { display: flex; background: #e8eeec; border-radius: 9px; padding: 3px; margin-bottom: 14px; }
.seg button {
  flex: 1; padding: 9px; border: none; background: transparent; border-radius: 7px;
  font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; font-family: inherit;
}
.seg button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow); }

/* ---------- 顶部栏 ---------- */
.topbar {
  background: var(--brand); color: #fff;
  /* 顶部留出状态栏安全区：装成 App（独立窗口）时内容不会顶到状态栏/刘海下面，
     保证「退出」按钮可见可点。普通浏览器里 env() 为 0，保持原样。 */
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  display: flex; align-items: center; justify-content: space-between;
  position: relative; z-index: 20;
}
.topbar .who { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; }
.topbar .who small { display: block; font-weight: 400; font-size: 11px; opacity: .82; }
.topbar .who small.post { margin-top: 2px; opacity: .95; }
.topbar .who small.post i {
  display: inline-block; font-style: normal; background: rgba(255, 255, 255, .22);
  border-radius: 6px; padding: 1px 7px; margin-right: 6px; font-size: 11px;
}
.topbar .out { background: rgba(255, 255, 255, .18); border: none; color: #fff; padding: 6px 12px; border-radius: 7px; font-size: 13px; cursor: pointer; font-family: inherit; }

/* ---------- 标签栏 ---------- */
.tabbar {
  display: flex; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 15;
}
.tabbar button {
  flex: 1; padding: 13px 4px; border: none; background: transparent; font-size: 14px;
  color: var(--muted); cursor: pointer; position: relative; font-family: inherit;
}
.tabbar button.active { color: var(--brand); font-weight: 700; }
.tabbar button.active::after {
  content: ''; position: absolute; left: 50%; transform: translateX(-50%);
  bottom: 0; width: 30px; height: 3px; background: var(--brand); border-radius: 2px 2px 0 0;
}
.badge {
  display: inline-block; min-width: 17px; height: 17px; line-height: 17px; padding: 0 5px;
  background: var(--rejected); color: #fff; border-radius: 9px; font-size: 11px;
  margin-left: 4px; vertical-align: 1px; font-weight: 700;
}

.wrap { padding: 12px; max-width: 620px; margin: 0 auto; }

/* ---------- 日历 ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head .ym { font-size: 16px; font-weight: 700; }
.cal-head .nav { display: flex; gap: 6px; }
.cal-head .nav button {
  width: 32px; height: 32px; border: 1px solid var(--line); background: #fff;
  border-radius: 8px; cursor: pointer; font-size: 15px; color: var(--text); line-height: 1;
}
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid .wd { text-align: center; font-size: 11px; color: var(--muted); padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1 / 1; border-radius: 9px; border: 1px solid transparent;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 14px; background: #fff; cursor: pointer; position: relative; padding: 2px;
  color: var(--text); font-family: inherit;
}
.cal-cell.blank { background: transparent; cursor: default; border: none; }
.cal-cell.disabled { color: #c7d0cc; cursor: not-allowed; background: #fafbfa; }
.cal-cell.today { border-color: var(--brand); font-weight: 700; }
.cal-cell.selected { background: var(--brand-light); border-color: var(--brand); }
.cal-cell .dots { display: flex; gap: 3px; margin-top: 2px; height: 6px; }
.cal-cell .dot { width: 6px; height: 6px; border-radius: 50%; }
.dot.pending { background: var(--pending); }
.dot.approved { background: var(--approved); }
.dot.rejected { background: var(--rejected); }
.dot.appealing { background: var(--appeal); }
.dot.leave { background: var(--leave); }
.cal-cell .am-pm { font-size: 9px; line-height: 1; color: var(--muted); margin-top: 1px; }
/* 休假全天：白字 + 黄底，日历里一眼可见 */
.cal-cell .am-pm.leave { color: #fff; background: var(--leave); font-weight: 700; border-radius: 4px; padding: 1px 3px; }
/* 统计明细分页（出勤统计 / 业绩流水）：每页最多 30 条，可点选页码 */
.pager-m { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px; margin-top: 12px; }
.pager-m .pg {
  min-width: 34px; padding: 5px 9px; border: 1px solid var(--line); background: #fff; border-radius: 7px;
  font-size: 13px; font-family: inherit; color: var(--text); cursor: pointer; text-align: center;
}
.pager-m .pg.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.pager-m .pg[disabled] { opacity: .45; cursor: default; }
.pager-m .pg.dots { border: 0; background: transparent; cursor: default; min-width: 12px; padding: 5px 0; color: var(--muted); }
/* 忘记打卡：过去的日期若上/下午未打满两次，整格标红 */
.cal-cell.missed { background: #fff1f1; border: 1px dashed var(--rejected); color: var(--text); cursor: pointer; }
.cal-cell.missed .dots { opacity: .55; }
.cal-cell .miss { font-size: 8px; line-height: 1.1; color: var(--rejected); font-weight: 700; margin-top: 1px; }
.legend i.sq { border-radius: 2px; border: 1px solid var(--rejected); background: #fff1f1; }
.legend i.sq.leave { border-color: var(--leave); background: var(--leave-light); }

.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; font-size: 11px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }

/* ---------- 时段选择 ---------- */
.period-pick { display: flex; gap: 10px; }
.period-opt {
  flex: 1; text-align: center; padding: 13px 6px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; cursor: pointer; font-size: 14px; color: var(--text);
}
.period-opt.on { border-color: var(--brand); background: var(--brand-light); color: var(--brand); font-weight: 700; }
.period-opt.done { background: #f2f5f4; color: var(--muted); cursor: not-allowed; border-style: dashed; }

/* ---------- 记录列表 ---------- */
.rec {
  background: #fff; border-radius: 10px; padding: 12px; margin-bottom: 9px;
  box-shadow: var(--shadow); border-left: 3px solid var(--line);
}
.rec.pending { border-left-color: var(--pending); }
.rec.approved { border-left-color: var(--approved); }
.rec.rejected { border-left-color: var(--rejected); }
.rec.appealing { border-left-color: var(--appeal); }
.rec.with-chk { display: flex; gap: 10px; align-items: flex-start; }
.rec.with-chk .rec-body { flex: 1; min-width: 0; }
.chk-wrap { display: flex; align-items: center; padding-top: 2px; }
.chk { width: 18px; height: 18px; accent-color: var(--brand); flex: none; margin: 0; }
.rev-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rev-bar .btn { width: auto; }
.rec-h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.rec-h b { font-size: 15px; }
.rec .line { font-size: 13px; color: var(--muted); }
.rec .line b { color: var(--text); font-weight: 600; }
/* 审核/申诉卡片：姓名后补充员工身份（所属门店 · 岗位性质 · 岗位） */
.rec-h.multi { align-items: flex-start; gap: 8px; }
.rec-h.multi .rec-who { flex: 1 1 auto; }
.rec-h.multi > .tag { flex: 0 0 auto; white-space: nowrap; }
.rec-who { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; min-width: 0; }
.rec-meta { font-size: 12px; color: var(--muted); }
.rec-meta em { font-style: normal; font-weight: 600; color: var(--text); }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 700;
}
.tag.pending { background: #fdf1de; color: var(--pending); }
.tag.approved { background: #e5f4ec; color: var(--approved); }
.tag.rejected { background: #fbe9e7; color: var(--rejected); }
.tag.appealing { background: #efeafb; color: var(--appeal); }
.tag.leave { background: var(--leave-light); color: var(--leave); }
.tag.home { background: #e5f4ec; color: var(--approved); }
.tag.cross { background: #eaf2fb; color: #2f6fdb; }

/* 督导待审分类子页签 */
.subtab { display: flex; gap: 8px; padding: 10px 12px 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.subtab button {
  flex: 0 0 auto; padding: 7px 14px; border: 1px solid var(--line); background: #fff;
  border-radius: 20px; font-size: 13px; color: var(--muted); cursor: pointer; font-family: inherit; white-space: nowrap;
}
.subtab button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.subtab button i { font-style: normal; opacity: .7; margin-left: 4px; font-size: 12px; }
.subtab button.on i { opacity: .9; }

/* ---------- 统计 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat-box { background: #fff; border-radius: 10px; padding: 12px; box-shadow: var(--shadow); text-align: center; }
.stat-box .n { font-size: 22px; font-weight: 800; color: var(--brand); }
.stat-box .l { font-size: 11px; color: var(--muted); }

.bar-row { margin-bottom: 9px; }
.bar-row .bt { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar { height: 8px; background: #eef2f0; border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 5px; }

table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
table.mini th, table.mini td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.mini th { color: var(--muted); font-weight: 600; font-size: 12px; }
table.mini td.num, table.mini th.num { text-align: right; }
/* 业绩统计「备注」：默认折叠显示提示词，点击展开详细说明 */
table.mini th, table.mini td { vertical-align: top; }
.note-toggle { display: inline-block; cursor: pointer; color: var(--brand); font-weight: 600; font-size: 12px; user-select: none; white-space: nowrap; }
.note-toggle.open { color: var(--muted); font-weight: 500; }
.note-detail { margin-top: 6px; padding: 8px 10px; background: #f6f9f8; border: 1px solid var(--line); border-radius: 8px; font-size: 12px; line-height: 1.7; color: #33413c; white-space: normal; word-break: break-word; text-align: left; }
table.mini tr.note-row > td { padding-top: 0; border-bottom: 1px solid var(--line); }
/* 业绩统计表：固定列宽，避免展开备注时挤压「日期 / 用工门店」列 */
table.mini.perf-table { table-layout: fixed; font-size: 12px; }
table.mini.perf-table th:nth-child(1), table.mini.perf-table td:nth-child(1) { width: 25%; }
table.mini.perf-table th:nth-child(2), table.mini.perf-table td:nth-child(2) { width: 27%; }
table.mini.perf-table th:nth-child(3), table.mini.perf-table td:nth-child(3) { width: 18%; }
table.mini.perf-table th:nth-child(4), table.mini.perf-table td:nth-child(4) { width: 30%; }
table.mini.perf-table tr.note-row > td { width: auto; }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(20, 32, 28, .45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: #fff; width: 100%; max-width: 620px; border-radius: 16px 16px 0 0;
  padding: 18px 16px 22px; max-height: 88vh; overflow-y: auto;
}
.sheet h3 { margin: 0 0 14px; font-size: 17px; }
.sheet .close-x {
  float: right; border: none; background: none; font-size: 22px; color: var(--muted);
  cursor: pointer; line-height: 1; margin-top: -4px;
}

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 76px;
  background: rgba(31, 45, 41, .92); color: #fff; padding: 10px 18px; border-radius: 20px;
  font-size: 14px; z-index: 90; opacity: 0; transition: opacity .2s; pointer-events: none;
  max-width: 86vw; text-align: center;
}
#toast.show { opacity: 1; }

/* ---------- 底部安全区 ---------- */
.safe { height: calc(24px + env(safe-area-inset-bottom, 0px)); }

/* ---------- 高峰排队横幅 ---------- */
#busy {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(8px + env(safe-area-inset-top, 0px));
  display: flex; align-items: center; gap: 8px; z-index: 95;
  background: rgba(74, 124, 111, .96); color: #fff; padding: 8px 14px; border-radius: 20px;
  font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.18); max-width: 90vw;
}
#busy.hidden { display: none !important; }
.busy-dot {
  width: 12px; height: 12px; border-radius: 50%; border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff; animation: busy-spin .7s linear infinite; flex: none;
}
@keyframes busy-spin { to { transform: rotate(360deg); } }
