:root {
  --bg: #f2f5fa;
  --card: #ffffff;
  --text: #16202e;
  --muted: #6b7789;
  --line: #e5eaf2;
  --primary: #2f6fed;
  --primary-dark: #1f57c3;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(22, 32, 46, .04), 0 8px 24px rgba(22, 32, 46, .06);
}

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

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

.app { max-width: 680px; margin: 0 auto; padding: 0 14px 96px; min-height: 100vh; }
.loading { padding: 80px 0; text-align: center; color: var(--muted); }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 2px 10px;
}
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: -.2px; }
.topbar .who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.link-btn {
  border: 0; background: none; color: var(--primary); font-size: 13px;
  padding: 4px 2px; cursor: pointer; font-family: inherit;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px;
}
.hero {
  background: linear-gradient(135deg, #2f6fed, #1749b8);
  color: #fff; border-radius: var(--radius); padding: 22px 20px;
  box-shadow: 0 10px 28px rgba(47, 111, 237, .28); margin-bottom: 14px;
}
.hero .label { font-size: 13px; opacity: .85; }
.hero.neg {
  background: linear-gradient(135deg, #ef4444, #991b1b);
  box-shadow: 0 10px 28px rgba(220, 38, 38, .3);
}
.neg-amt { color: #dc2626; }

/* 超休警告 */
.over-warn {
  background: #fef2f2; border: 2px solid #dc2626; border-radius: 12px;
  padding: 13px 15px; margin: 0 0 14px; color: #991b1b;
  animation: pulse 1.5s ease-in-out infinite;
}
.over-warn b { display: block; font-size: 15.5px; margin-bottom: 5px; }
.over-warn span { font-size: 12.5px; line-height: 1.6; color: #b91c1c; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .28); }
  50% { box-shadow: 0 0 0 7px rgba(220, 38, 38, 0); }
}
form.over { position: relative; }
form.over .field input, form.over .field textarea, form.over .field select {
  border-color: #fca5a5; background: #fffafa;
}
form.over .primary-btn { background: #dc2626; }

.rec-over { border: 1.5px solid #fca5a5; background: #fffafa; }
.over-line {
  margin-top: 9px; font-size: 12.5px; font-weight: 600; color: #b91c1c;
  background: #fef2f2; border-radius: 8px; padding: 7px 10px;
}
.hero .value { font-size: 44px; font-weight: 700; line-height: 1.1; margin: 6px 0 4px; letter-spacing: -1.5px; }
.hero .value span { font-size: 16px; font-weight: 500; opacity: .9; margin-left: 2px; }
.hero .sub { font-size: 12.5px; opacity: .82; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat {
  background: var(--card); border-radius: 14px; padding: 14px 10px; text-align: center;
  box-shadow: var(--shadow);
}
.stat b { display: block; font-size: 21px; letter-spacing: -.5px; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- 按钮 ---------- */
button { font-family: inherit; }
.primary-btn {
  width: 100%; border: 0; border-radius: 13px; background: var(--primary); color: #fff;
  font-size: 15.5px; font-weight: 600; padding: 14px; cursor: pointer;
  transition: transform .06s, background .15s;
}
.primary-btn:active { transform: scale(.985); background: var(--primary-dark); }
.primary-btn:disabled { opacity: .55; }
.ghost-btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 11px; padding: 9px 14px; font-size: 13.5px; cursor: pointer;
}
.ghost-btn.danger { color: #b91c1c; border-color: #f3d3d3; }
.mini-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px;
  padding: 6px 11px; font-size: 12.5px; color: var(--muted); cursor: pointer;
}
.mini-btn.danger { color: #b91c1c; border-color: #f3d3d3; }

/* ---------- 列表 ---------- */
.section-title {
  font-size: 13px; color: var(--muted); font-weight: 600;
  margin: 20px 4px 8px; letter-spacing: .3px;
}
.list { list-style: none; margin: 0; padding: 0; }
.rec {
  background: var(--card); border-radius: 14px; padding: 14px 16px;
  box-shadow: var(--shadow); margin-bottom: 10px;
}
.rec-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-date { font-size: 13.5px; color: var(--muted); margin-top: 7px; }
.rec-reason { font-size: 14px; margin-top: 4px; color: #344052; word-break: break-word; }
.rec-actions { margin-top: 10px; display: flex; gap: 8px; }
.rec-comment {
  margin-top: 8px; font-size: 12.5px; color: var(--muted);
  background: #f7f9fc; border-radius: 8px; padding: 7px 10px;
}
.days { font-weight: 600; font-size: 15px; }
.spacer { flex: 1; }

.badge {
  font-size: 12px; padding: 2.5px 9px; border-radius: 999px; font-weight: 600;
}
.badge.comp { background: #eff6ff; color: #0369a1; }
.badge.personal { background: #f5f3ff; color: #6d28d9; }
.badge.deduct { background: #fef2f2; color: #b91c1c; }
.check {
  display: flex; align-items: center; gap: 8px; margin: 0;
  font-size: 14px; color: var(--text); cursor: pointer;
}
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.st { font-size: 12px; padding: 2.5px 9px; border-radius: 999px; font-weight: 600; }
.st.pending   { background: #fff7e6; color: #b45309; }
.st.approved  { background: #ecfdf3; color: #15803d; }
.st.rejected  { background: #fef2f2; color: #b91c1c; }
.st.cancelled { background: #f3f4f6; color: #6b7280; }

.empty { text-align: center; color: var(--muted); font-size: 13.5px; padding: 28px 0; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 13px; font-size: 15px; font-family: inherit; color: var(--text);
  background: #fbfcfe; outline: none; transition: border .15s, background .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); background: #fff;
}
.field textarea { resize: vertical; min-height: 76px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg input { display: none; }
.seg label {
  display: block; text-align: center; padding: 11px 8px; border-radius: 11px;
  border: 1px solid var(--line); background: #fbfcfe; font-size: 14px;
  cursor: pointer; color: var(--muted); margin: 0;
}
.seg input:checked + label {
  border-color: var(--primary); background: #eef4ff; color: var(--primary-dark);
  font-weight: 600;
}

/* ---------- 底部导航 ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { max-width: 680px; margin: 0 auto; display: flex; }
.nav button {
  flex: 1; border: 0; background: none; padding: 9px 0 11px; cursor: pointer;
  font-size: 11.5px; color: var(--muted); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.nav button .ico { font-size: 18px; line-height: 1; }
.nav button.on { color: var(--primary); font-weight: 600; }
.nav .dot {
  position: absolute; transform: translate(11px, -2px);
  width: 7px; height: 7px; border-radius: 50%; background: #ef4444;
}

/* ---------- 登录 ---------- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 20px; }
.auth-head { text-align: center; margin-bottom: 22px; }
.auth-head .logo {
  width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 12px;
  background: linear-gradient(135deg, #2f6fed, #1749b8); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  box-shadow: 0 10px 24px rgba(47, 111, 237, .3);
}
.auth-head h2 { margin: 0 0 4px; font-size: 20px; }
.auth-head p { margin: 0; color: var(--muted); font-size: 13px; }
.auth-card { background: #fff; border-radius: 18px; padding: 20px; box-shadow: var(--shadow); }
.auth-tip { font-size: 12.5px; color: var(--muted); text-align: center; margin-top: 14px; line-height: 1.7; }

/* ---------- 弹窗 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.sheet {
  background: #fff; width: 100%; max-width: 680px;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  animation: up .2s ease;
}
@keyframes up { from { transform: translateY(24px); opacity: .6 } to { transform: none; opacity: 1 } }
.sheet h3 { margin: 0 0 14px; font-size: 16.5px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 16px);
  background: #16202e; color: #fff; font-size: 13.5px; padding: 10px 18px;
  border-radius: 999px; opacity: 0; pointer-events: none; transition: all .22s;
  z-index: 60; max-width: 86vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #b91c1c; }

.member {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 14px; padding: 13px 15px;
  box-shadow: var(--shadow); margin-bottom: 9px;
}
.member .avatar {
  width: 36px; height: 36px; border-radius: 11px; flex: 0 0 auto;
  background: #eef4ff; color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px;
}
.member .info { flex: 1; min-width: 0; }
.member .nm { font-weight: 600; font-size: 14.5px; display: flex; align-items: center; gap: 6px; }
.member .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.member .amt { font-weight: 700; font-size: 16px; }
.member .amt small { font-weight: 400; font-size: 11px; color: var(--muted); }
.tag-admin { font-size: 10.5px; background: #fef3c7; color: #92400e; padding: 1px 6px; border-radius: 5px; }
.tag-off { font-size: 10.5px; background: #f3f4f6; color: #6b7280; padding: 1px 6px; border-radius: 5px; }

/* ---------- 补录 / 批量导入 ---------- */
.tag-src {
  font-size: 10.5px; padding: 1px 6px; border-radius: 6px; margin-left: 2px;
  background: #fff3e0; color: #b26a00; font-weight: 600; white-space: nowrap;
}
.tag-src.pre { background: #e8f2ff; color: #2f6fed; }

.sheet.wide { max-width: 760px; }
.sheet.wide .sheet-actions { grid-template-columns: 1fr 1fr 1.15fr; }

.imp-tip {
  font-size: 12.5px; line-height: 1.75; color: var(--muted);
  background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; margin-bottom: 12px;
}
.imp-tip b { color: var(--text); }
.imp-tip code {
  background: #eef2f8; padding: 1px 5px; border-radius: 5px;
  font-size: 12px; color: var(--text);
}

#imp-text {
  width: 100%; height: 168px; resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.7;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--text); outline: none;
}
#imp-text:focus { border-color: var(--primary); }

.imp-sum { margin-top: 12px; font-size: 13px; color: var(--muted); }
.imp-sum .okc { color: #1a8f4a; }
.imp-sum .errc { color: #d93a3a; }

.imp-list {
  list-style: none; margin: 8px 0 0; padding: 0;
  max-height: 220px; overflow-y: auto;
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
}
.imp-list li {
  display: flex; gap: 8px; align-items: flex-start;
  font-size: 12.5px; padding: 7px 11px; border-bottom: 1px solid var(--line);
}
.imp-list li:last-child { border-bottom: 0; }
.imp-list li .ln { color: var(--muted); flex: 0 0 34px; font-variant-numeric: tabular-nums; }
.imp-list li.ok em {
  font-style: normal; font-size: 11px; padding: 1px 6px; border-radius: 6px;
  background: #eaf3ff; color: #2f6fed; margin-left: 2px;
}
.imp-list li.bad { background: #fff6f6; }
.imp-list li.bad span { color: #c92a2a; }
