/* ===== 学生餐费考勤填报系统 · 通用样式（移动优先） ===== */
:root {
  --brand: #2f6bff;
  --brand-dark: #1f4fd8;
  --brand-soft: #eaf0ff;
  --ok: #10b070;
  --ok-soft: #e6f7f0;
  --warn: #f59f00;
  --warn-soft: #fff6e5;
  --danger: #e5484d;
  --danger-soft: #fdecec;
  --text: #1c2333;
  --text-2: #5b6478;
  --text-3: #97a0b3;
  --line: #e6e9f0;
  --bg: #f4f6fa;
  --card: #fff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .05), 0 8px 24px rgba(20, 30, 60, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { 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", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--brand); text-decoration: none; }
.hide { display: none !important; }

/* ---------- 基础组件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 18px; border-radius: 10px;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 15px;
  transition: filter .15s, opacity .15s;
}
.btn:active { filter: brightness(.92); }
.btn[disabled] { background: #c8cedd; cursor: not-allowed; }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.line { background: #fff; border: 1px solid var(--line); color: var(--text-2); font-weight: 500; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn.danger { background: var(--danger); }

.field {
  width: 100%; height: 46px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none;
}
.field:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

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

.tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px;
  border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap;
}
.tag.g { background: var(--ok-soft); color: var(--ok); }
.tag.b { background: var(--brand-soft); color: var(--brand); }
.tag.y { background: var(--warn-soft); color: #b47500; }
.tag.r { background: var(--danger-soft); color: var(--danger); }
.tag.n { background: #f0f2f7; color: var(--text-3); }

.empty { padding: 48px 20px; text-align: center; color: var(--text-3); font-size: 14px; }
.spin {
  width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite;
}
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- 弹层 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(15, 20, 35, .48);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; animation: fade .18s ease;
}
.mask.center { align-items: center; padding: 24px; }
@keyframes fade { from { opacity: 0; } }

.sheet {
  width: 100%; max-width: 520px; background: #fff;
  border-radius: 18px 18px 0 0; max-height: 88vh; display: flex; flex-direction: column;
  animation: up .24s cubic-bezier(.2, .9, .3, 1);
  padding-bottom: var(--safe-b);
}
@keyframes up { from { transform: translateY(100%); } }
.mask.center .sheet { border-radius: 16px; animation: pop .2s ease; max-width: 400px; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }

.sheet-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--line);
}
.sheet-hd h3 { margin: 0; font-size: 16px; }
.sheet-bd { padding: 16px 18px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-ft { padding: 12px 18px 16px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.sheet-ft .btn { flex: 1; }
.x { font-size: 22px; color: var(--text-3); line-height: 1; padding: 4px 8px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; top: 18%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: 84vw;
}
.toast {
  background: rgba(22, 28, 45, .92); color: #fff; padding: 10px 16px;
  border-radius: 10px; font-size: 14px; animation: fade .2s ease; text-align: center;
}
.toast.err { background: rgba(200, 40, 45, .95); }
.toast.ok { background: rgba(12, 140, 90, .95); }

/* ---------- 日历 ---------- */
.cal-hd {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-bottom: 6px; font-size: 12px; color: var(--text-3); text-align: center;
}
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-d {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 9px; font-size: 15px; font-weight: 500; position: relative;
  background: #f6f7fa; color: #c3c8d4; user-select: none;
}
.cal-d.serve { background: #fff; color: var(--text); border: 1px solid var(--line); cursor: pointer; }
.cal-d.serve:active { transform: scale(.94); }
.cal-d.sel { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }
.cal-d.sel.k2 { background: #7c5cff; border-color: #7c5cff; }
.cal-d.sel.k3 { background: #f2882b; border-color: #f2882b; }
.cal-d .k { font-size: 9px; line-height: 1; margin-top: 2px; opacity: .95; }
.cal-d.today::after {
  content: ''; position: absolute; bottom: 4px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--brand);
}
.cal-d.sel.today::after { background: #fff; }
