:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --primary: #4f7cff;
  --primary-d: #3a63d8;
  --text: #1f2430;
  --muted: #8a93a6;
  --line: #e7ebf3;
  --danger: #ef4444;
  --ok: #22c55e;
  --tab-h: 58px;
  --top-h: 52px;
}
* { 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", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  padding-top: var(--top-h);
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  font-size: 14px;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* 顶栏 */
.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--top-h); max-width: 560px; margin: 0 auto;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; padding: 0 8px;
  z-index: 30; box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.icon-btn { width: 40px; height: 40px; font-size: 20px; color: #fff; border-radius: 8px; }
.icon-btn:active { background: rgba(255,255,255,.15); }
.topbar-title { flex: 1; text-align: center; font-weight: 600; font-size: 16px; }

/* 主视图 */
#view { padding: 10px; }
.card { background: var(--card); border-radius: 12px; padding: 12px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.section-title { font-weight: 600; margin: 4px 2px 8px; font-size: 15px; }

/* 工具栏 */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.btn {
  background: var(--primary); color: #fff; border-radius: 9px;
  padding: 8px 12px; font-size: 13px; font-weight: 600;
}
.btn:active { background: var(--primary-d); }
.btn.ghost { background: #eef2ff; color: var(--primary); }
.btn.line { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: #fee2e2; color: var(--danger); }
.seg { display: inline-flex; background: #eef2ff; border-radius: 9px; padding: 3px; }
.seg button { padding: 6px 12px; border-radius: 7px; font-size: 13px; color: var(--primary); }
.seg button.on { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.1); font-weight: 600; }

/* 日历 - 月视图 */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0; }
.cal-cell {
  background: #fff; border-radius: 9px; min-height: 60px; padding: 4px;
  border: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px;
}
.cal-cell.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.cal-cell.other { opacity: .4; }
.cal-date { font-size: 12px; font-weight: 600; color: var(--muted); }
.cal-cell.today .cal-date { color: var(--primary); }
.chip {
  font-size: 11px; line-height: 1.3; border-radius: 6px; padding: 2px 5px;
  color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip .more { background: rgba(0,0,0,.15); border-radius: 4px; padding: 0 3px; }

/* 日历 - 周视图 */
.week-col { background: #fff; border-radius: 10px; border: 1px solid var(--line); padding: 6px; display: flex; flex-direction: column; gap: 5px; }
.week-dow { text-align: center; font-size: 12px; color: var(--muted); }
.week-dnum { text-align: center; font-weight: 700; font-size: 15px; }
.week-col.today { border-color: var(--primary); }
.week-slot { border-radius: 7px; padding: 3px 5px; color: #fff; font-size: 11px; }
.week-empty { color: var(--muted); font-size: 11px; text-align: center; padding: 4px; border: 1px dashed var(--line); border-radius: 7px; }

/* 列表项 */
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.avatar { width: 38px; height: 38px; border-radius: 50%; flex: none; object-fit: cover; background: #e8edf7; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 600; }
.row-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.row-actions { display: flex; gap: 6px; }
.mini { padding: 5px 9px; font-size: 12px; border-radius: 7px; border: 1px solid var(--line); }
.mini.danger { color: var(--danger); border-color: #fecaca; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 6px; vertical-align: middle; }

/* 标签徽章 */
.badge { font-size: 11px; padding: 2px 7px; border-radius: 20px; font-weight: 600; }
.badge.pending { background: #fef3c7; color: #b45309; }
.badge.approved { background: #dcfce7; color: #15803d; }
.badge.rejected { background: #fee2e2; color: #b91c1c; }
.badge.leave { background: #ede9fe; color: #6d28d9; }
.badge.swap { background: #cffafe; color: #0e7490; }

/* 底部 Tab */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; max-width: 560px; margin: 0 auto;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff; border-top: 1px solid var(--line);
  display: flex; z-index: 30;
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); font-size: 11px; }
.tab .tab-ico { font-size: 19px; }
.tab.on { color: var(--primary); font-weight: 600; }

/* 抽屉 */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.4); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.drawer-mask.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 78%; max-width: 320px;
  background: #fff; z-index: 50; transform: translateX(-100%); transition: transform .22s ease;
  display: flex; flex-direction: column; box-shadow: 2px 0 12px rgba(0,0,0,.12);
}
.drawer.show { transform: translateX(0); }
.drawer-head { background: var(--primary); color: #fff; padding: 22px 18px 16px; }
.drawer-team { font-size: 18px; font-weight: 700; }
.drawer-code { font-size: 12px; opacity: .9; margin-top: 4px; }
.drawer-section { padding: 12px 14px; border-bottom: 8px solid var(--bg); }
.drawer-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.drawer-item { display: block; width: 100%; text-align: left; padding: 11px 8px; border-radius: 8px; font-size: 14px; }
.drawer-item:active { background: var(--bg); }
.drawer-about { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; width: 100%; max-width: 560px; border-radius: 16px 16px 0 0;
  max-height: 86vh; overflow-y: auto; padding: 16px; transform: translateY(20px); transition: transform .2s; z-index: 61;
}
.modal-mask.show .modal { transform: translateY(0); }
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.modal-close { font-size: 20px; color: var(--muted); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe;
}
.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.modal-actions .btn { flex: 1; }

/* 日排班弹窗 */
.day-slots { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.day-shift { border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.day-shift.sel { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.day-shift-head { display: flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 6px; }
.day-assigned { display: flex; flex-wrap: wrap; gap: 6px; }
.asg { display: inline-flex; align-items: center; gap: 4px; background: #eef2ff; color: var(--primary); border-radius: 20px; padding: 3px 8px; font-size: 12px; }
.asg .x { color: var(--danger); font-weight: 700; }
.roster { display: flex; flex-wrap: wrap; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.roster-chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 20px; padding: 5px 10px; font-size: 13px; background: #fff; }
.roster-chip.sel { border-color: var(--primary); background: #eef2ff; }
.roster-chip:active { transform: scale(.96); }

/* 引导 / 启动屏 */
.boot { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; z-index: 70; }
.boot h1 { font-size: 22px; margin: 0; }
.boot p { color: var(--muted); text-align: center; margin: 0; }
.boot .card { width: 100%; max-width: 360px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px); transform: translateX(-50%) translateY(20px);
  background: rgba(31,36,48,.92); color: #fff; padding: 10px 16px; border-radius: 22px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: all .2s; z-index: 80; max-width: 80%;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.empty { text-align: center; color: var(--muted); padding: 30px 0; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 2px 10px; }
