/* 倒班记录 - 移动端优先样式 */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --primary: #0f4c81;
  --primary-light: #2563eb;
  --bg: #f6f8fb;
  --card: #ffffff;
  --line: #d7dee8;
  --text: #1f2937;
  --muted: #64748b;
  --today-ring: #f59e0b;
}

html { font-size: 16px; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

.hidden { display: none !important; }

/* ---------- 顶部栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 6px;
  gap: 8px;
}
.month-nav { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.month-nav h1 { font-size: 18px; font-weight: 600; min-width: 128px; text-align: center; white-space: nowrap; }
.nav-btn {
  width: 44px; height: 44px;
  font-size: 22px; line-height: 1;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--primary);
  cursor: pointer;
}
.nav-btn:active { background: #eef2f7; }
.topbar-right { display: flex; gap: 6px; align-items: center; flex: 0 0 auto; }
.chip {
  font-size: 13px; color: var(--muted);
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; white-space: nowrap;
}
.chip-action {
  color: var(--primary); font-weight: 600; cursor: pointer; border-color: var(--primary-light);
}
.chip-select {
  color: var(--primary); font-weight: 600; cursor: pointer;
  border-color: var(--line); max-width: 104px; height: 32px;
}
.d-watch {
  margin-top: 2px; font-size: 9px; line-height: 1.3;
  color: #b45309; background: #fef3c7;
  border-radius: 4px; padding: 1px 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.dt-watch { margin-top: 6px; font-size: 12px; color: #b45309; font-weight: 600; }
.field.check { display: flex; align-items: center; gap: 8px; }
.field.check input { width: auto; flex: none; }
.resync-row { margin-bottom: 10px; }
.resync-row .btn-mini { color: var(--primary); border-color: var(--primary-light); background: #eff6ff; }

/* ---------- 今日一览 ---------- */
.overview {
  margin: 8px 14px 0;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  color: #1e3a5f;
  line-height: 1.6;
}
.overview .ov-label { font-weight: 600; margin-right: 6px; }

/* ---------- 图例 ---------- */
.legend {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin: 10px 14px 4px;
  font-size: 12px; color: var(--muted);
}
.legend .lg-item { display: flex; align-items: center; gap: 4px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- 星期与日历 ---------- */
.weekdays {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  padding: 6px 8px 2px;
  font-size: 13px; color: var(--muted); text-align: center;
}
.calendar {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr));
  grid-auto-rows: 58px;
  gap: 3px; padding: 4px 8px 8px;
}
.day {
  position: relative;
  min-height: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 6px 4px;
  display: flex; flex-direction: column;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
}
.day:active { background: #eef2f7; }
.day .d-num { font-size: 13px; color: var(--text); line-height: 1.2; }
.day.out { opacity: 0.35; }
.day.today { outline: 2px solid var(--today-ring); outline-offset: -2px; }
.day.selected { background: #eef4fb; border-color: var(--primary-light); }
.day .d-shift {
  margin-top: auto;
  font-size: 11px; text-align: center;
  border-radius: 4px; padding: 2px 0;
  color: #fff; font-weight: 600;
}
.day .d-shift.off-like { color: #334155; }
.day .d-note-mark {
  position: absolute; top: 4px; right: 6px;
  font-size: 10px; color: #f59e0b; font-weight: 700;
}

/* ---------- 日期详情 ---------- */
.detail {
  margin: 6px 14px 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}
.detail .dt-title { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.detail .dt-sub { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.shift-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.shift-btn {
  min-height: 44px; min-width: 72px;
  border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-weight: 600; color: var(--text);
  background: #f8fafc; cursor: pointer; padding: 6px 12px;
}
.shift-btn.active { color: #fff; border-color: transparent; }
.shift-btn .sb-time { display: block; font-size: 11px; font-weight: 400; }
.detail textarea {
  width: 100%; min-height: 64px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px; font-size: 14px; font-family: inherit;
  resize: vertical; color: var(--text);
}
.detail .note-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.btn-mini {
  min-height: 40px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #f8fafc; color: var(--text);
  font-size: 14px; cursor: pointer;
}
.btn-mini.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.detail .dt-hint { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- 班组页 ---------- */
.page-head { padding: 16px 14px 6px; }
.page-head h2 { font-size: 20px; }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 2px; }
.team-list { display: flex; flex-direction: column; gap: 8px; padding: 10px 14px; }
.team-card {
  min-height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; font-size: 15px; cursor: pointer;
}
.team-card.active { border-color: var(--primary-light); background: #eef4fb; }
.team-card .tag { font-size: 12px; color: var(--primary); font-weight: 600; }
.hint { font-size: 12px; color: var(--muted); padding: 8px 14px; line-height: 1.6; }

/* ---------- 设置页 ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; margin: 10px 14px; padding: 12px;
}
.card h3 { font-size: 15px; margin-bottom: 10px; color: var(--primary); }
.radio-row {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 0; font-size: 15px; cursor: pointer;
  min-height: 44px; align-items: center;
}
.radio-row input { width: 18px; height: 18px; flex: none; }
.radio-row small { display: block; font-size: 12px; color: var(--muted); }
.field { display: block; font-size: 13px; color: var(--muted); margin: 8px 0; }
.field input[type="number"], .field input[type="date"], .field select {
  display: block; width: 100%; margin-top: 4px;
  min-height: 44px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; font-size: 15px; color: var(--text); background: #fff;
}
.seq-editor { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.seq-editor select {
  min-height: 44px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px; color: var(--text); background: #fff; padding: 0 6px;
  flex: 1 1 84px;
}
.names-editor { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.names-editor label { font-size: 13px; color: var(--muted); }
.names-editor input {
  display: block; width: 100%; margin-top: 4px;
  min-height: 44px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; font-size: 15px; color: var(--text);
}
.shift-defs { display: flex; flex-direction: column; gap: 10px; }
.shift-def { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.shift-def .sd-head { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.shift-def .sd-head input[type="color"] { width: 40px; height: 32px; border: none; background: none; cursor: pointer; }
.shift-def .sd-row { display: flex; gap: 6px; }
.shift-def .sd-row input {
  flex: 1; min-height: 40px; border: 1px solid var(--line); border-radius: 8px;
  padding: 0 8px; font-size: 14px; color: var(--text);
}
.actions { display: flex; gap: 10px; padding: 4px 14px 24px; }
.btn-primary {
  flex: 1; min-height: 48px; border: none; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-danger {
  flex: 1; min-height: 48px; border: 1px solid #dc2626; border-radius: 10px;
  background: #fff; color: #dc2626; font-size: 15px; cursor: pointer;
}

/* ---------- 底部导航 ---------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px; margin: 0 auto;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.tab {
  flex: 1; min-height: 56px;
  border: none; background: none;
  font-size: 14px; color: var(--muted); cursor: pointer;
}
.tab.active { color: var(--primary); font-weight: 600; }
