:root {
  --bg: #eef2f6;
  --card: #ffffff;
  --ink: #15202b;
  --muted: #6b7c8d;
  --line: #e4eaf1;
  --brand: #16436e;
  --brand-2: #2f6fa8;
  --gold: #d98324;
  --ok: #1c7f57;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(16, 35, 54, 0.08);
}

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

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-2); text-decoration: none; }
.hidden { display: none !important; }

/* ---------- 登录页 ---------- */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 18px;
  background: radial-gradient(1200px 500px at 20% -10%, #2f6fa8 0%, transparent 60%),
    linear-gradient(150deg, #0f3355 0%, #16436e 45%, #1d5285 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 20px;
  padding: 30px 24px 24px;
  box-shadow: 0 24px 60px rgba(4, 18, 32, 0.35);
}
.brand-mark {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: linear-gradient(140deg, #16436e, #2f6fa8);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.brand-mark svg { width: 30px; height: 30px; }
.login-card h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: 0.5px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 22px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select {
  width: 100%;
  height: 46px;
  border: 1.5px solid var(--line);
  border-radius: 11px;
  padding: 0 12px;
  background: #fbfcfe;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.field input:focus, .field select:focus { border-color: var(--brand-2); background: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  height: 46px;
  padding: 0 18px;
  border: none;
  border-radius: 11px;
  background: #eef2f6;
  color: var(--ink);
  font-weight: 600;
  transition: transform 0.08s, opacity 0.15s;
}
.btn:active { transform: scale(0.985); }
.btn.primary {
  width: 100%;
  background: linear-gradient(135deg, #16436e, #2f6fa8);
  color: #fff;
  box-shadow: 0 8px 18px rgba(22, 67, 110, 0.28);
}
.btn.ghost { background: #fff; border: 1.5px solid var(--line); }
.btn.gold { background: linear-gradient(135deg, #e08a1e, #d9761a); color: #fff; }
.btn.small { height: 32px; padding: 0 12px; border-radius: 9px; font-size: 13px; }
.btn.danger-soft { background: #fdecea; color: var(--danger); }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; }

.form-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
  margin: 4px 0 10px;
}
.form-error.hint { color: var(--ok); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(135deg, #16436e 0%, #2f6fa8 100%);
  color: #fff;
  padding: calc(12px + env(safe-area-inset-top)) 16px 14px;
  box-shadow: 0 4px 16px rgba(14, 41, 68, 0.22);
}
.topbar-inner {
  max-width: 980px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px;
}
.topbar .who { flex: 1; min-width: 0; }
.topbar .who b { font-size: 16px; font-weight: 600; display: block; }
.topbar .who span { font-size: 12px; opacity: 0.75; }
.topbar .brand-mini { display: flex; align-items: center; gap: 8px; font-weight: 600; letter-spacing: 0.4px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: none; background: rgba(255, 255, 255, 0.14); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:active { background: rgba(255, 255, 255, 0.26); }

/* ---------- 布局 ---------- */
.page { max-width: 640px; margin: 0 auto; padding: 16px 14px 120px; }
.page.wide { max-width: 980px; }

.section-title {
  display: flex; align-items: baseline; gap: 8px;
  margin: 22px 4px 10px;
  font-size: 14px; color: var(--muted);
}
.section-title b { color: var(--ink); font-size: 15px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* ---------- 月份切换 ---------- */
.month-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}
.month-select {
  flex: 1;
  height: 44px;
  border-radius: 11px;
  border: 1.5px solid var(--line);
  background: #fff;
  padding: 0 12px;
  font-weight: 600;
  outline: none;
}

/* ---------- 合计卡片 ---------- */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.summary .stat {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.summary .stat::after {
  content: ""; position: absolute; right: -18px; top: -18px;
  width: 62px; height: 62px; border-radius: 50%;
  background: rgba(47, 111, 168, 0.08);
}
.summary .stat.deep::after { background: rgba(217, 131, 36, 0.1); }
.summary .label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.summary .value { font-size: 32px; font-weight: 700; line-height: 1.15; margin-top: 4px; letter-spacing: -0.5px; }
.summary .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-2); display: inline-block; }
.dot.gold { background: var(--gold); }

/* ---------- 记录列表 ---------- */
.record-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.record {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 13px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: transform 0.08s;
}
.record:active { transform: scale(0.99); }
.record .date {
  width: 48px; flex: none; text-align: center;
  border-right: 1px solid var(--line); padding-right: 10px;
}
.record .date b { display: block; font-size: 17px; line-height: 1.2; }
.record .date span { font-size: 11px; color: var(--muted); }
.record .body { flex: 1; min-width: 0; }
.record .line1 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.record .wells { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record .memo { font-size: 12px; color: var(--gold); margin-top: 3px; }
.chev { color: #c3ccd6; font-size: 20px; line-height: 1; }

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 7px;
  font-weight: 600;
  white-space: nowrap;
}
.tag.mid { background: #e7f0f9; color: #1d5c92; }
.tag.deep { background: #fbf0e1; color: #a05c12; }
.tag.admin { background: #eaf5ee; color: var(--ok); }
.tag.off { background: #f1f3f6; color: var(--muted); }

.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}
.empty .big { font-size: 34px; margin-bottom: 6px; }

.fab {
  position: fixed;
  right: 18px;
  bottom: calc(22px + env(safe-area-inset-bottom));
  height: 52px;
  padding: 0 20px;
  border: none;
  border-radius: 26px;
  background: linear-gradient(135deg, #16436e, #2f6fa8);
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 12px 26px rgba(22, 67, 110, 0.35);
  z-index: 40;
  display: inline-flex; align-items: center; gap: 6px;
}
.fab:active { transform: scale(0.97); }

/* ---------- 弹层 ---------- */
.mask {
  /* 不用 inset 简写：部分微信内置浏览器/旧 WebKit 不认，
     会导致弹层缩成 560px 掉到页面底部，手机上只剩一条。 */
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: rgba(9, 20, 32, 0.45);
  z-index: 60;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade 0.18s ease;
}
.mask.center { align-items: center; padding: 20px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  max-height: calc(100% - 8px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
  animation: up 0.22s cubic-bezier(0.22, 0.75, 0.3, 1);
}
@keyframes up { from { transform: translateY(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }

.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head b { font-size: 17px; }
.sheet-close {
  width: 32px; height: 32px; border-radius: 50%;
  border: none; background: #f1f4f8; color: var(--muted); font-size: 18px;
}

.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  margin: -2px 2px 12px;
}

.shift-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfcfe;
  padding: 12px 13px 2px;
  margin-bottom: 12px;
}
.shift-card.off { background: #f7f9fb; }
.shift-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.shift-card.off .shift-head { margin-bottom: 0; padding-bottom: 10px; }
.shift-title { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: 15px; }
.shift-card.off .shift-title { color: var(--muted); }
.yesno {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: #edf1f6;
}
.yesno button {
  min-width: 40px;
  height: 28px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}
.yesno button.on {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 1px 6px rgba(16, 35, 54, 0.12);
}
.shift-body .chips { margin-bottom: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 12px; }
.chip {
  border: 1px solid var(--line);
  background: #fbfcfe;
  color: var(--muted);
  border-radius: 16px;
  padding: 5px 11px;
  font-size: 13px;
}
.chip:active { background: #eef4fb; color: var(--brand); }

.dialog {
  width: 100%;
  max-width: 360px;
  background: var(--card);
  border-radius: 18px;
  padding: 20px;
  animation: up 0.2s ease;
}

/* ---------- 管理端 ---------- */
.tabs {
  display: flex; gap: 4px;
  background: rgba(255, 255, 255, 0.12);
  padding: 4px; border-radius: 11px;
}
.tabs button {
  flex: 1; height: 32px; border: none; border-radius: 8px;
  background: transparent; color: rgba(255, 255, 255, 0.8);
  font-size: 13px; font-weight: 600;
}
.tabs button.on { background: #fff; color: var(--brand); }

.stats3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stats3 .stat {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 13px 12px;
}
.stats3 .label { font-size: 12px; color: var(--muted); }
.stats3 .value { font-size: 24px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.stats3 .value small { font-size: 12px; color: var(--muted); font-weight: 500; }

.board-tools { display: flex; gap: 10px; margin-bottom: 12px; }
.search {
  flex: 1; height: 42px; border-radius: 11px; border: 1.5px solid var(--line);
  background: #fff; padding: 0 12px; outline: none;
}

.member-head, .member-row {
  display: grid;
  grid-template-columns: 40px 1fr 62px 62px 70px;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
}
.member-head {
  font-size: 12px; color: var(--muted);
  padding-bottom: 6px;
}
.member-list { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.member-row { border-top: 1px solid var(--line); font-size: 14px; }
.member-row:active { background: #f7fafd; }
.member-row .num { color: var(--muted); font-size: 12px; }
.member-row .name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.member-row .num-cell { text-align: center; font-weight: 600; }
.member-row .num-cell.zero { color: #c7d0da; font-weight: 400; }
.member-row .time { font-size: 11px; color: var(--muted); text-align: right; }
.member-row .time.done { color: var(--ok); }

.account-row {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-top: 1px solid var(--line);
}
.account-row .who { flex: 1; min-width: 0; }
.account-row .who b { font-size: 14px; }
.account-row .pin { font-family: ui-monospace, Consolas, monospace; font-size: 13px; color: var(--brand); }
.account-row .pin.changed { color: var(--muted); font-family: inherit; font-size: 12px; }

.account-actions { display: flex; gap: 6px; }

.setting-field { margin-bottom: 14px; }
.setting-field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.backup-tip { margin: 0 0 12px; font-size: 13px; color: var(--muted); line-height: 1.6; }

.setting-field input {
  width: 100%; height: 44px; border: 1.5px solid var(--line); border-radius: 10px;
  padding: 0 12px; background: #fbfcfe; outline: none;
}

.login-list { font-size: 13px; color: var(--muted); }
.login-list div { padding: 7px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }

/* ---------- Toast ---------- */
#toastWrap {
  position: fixed; left: 0; right: 0; bottom: calc(84px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 90; pointer-events: none;
}
.toast {
  background: rgba(17, 30, 44, 0.92);
  color: #fff;
  padding: 9px 16px;
  border-radius: 20px;
  font-size: 13.5px;
  max-width: 80%;
  text-align: center;
  animation: fade 0.2s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}
.toast.ok { background: rgba(28, 127, 87, 0.95); }
.toast.err { background: rgba(192, 57, 43, 0.95); }

@media (max-width: 420px) {
  .stats3 .value { font-size: 21px; }
  .member-head, .member-row { grid-template-columns: 32px 1fr 54px 54px 58px; font-size: 13px; }
}
