:root {
  --bg: #f2f4f8;
  --card: #ffffff;
  --line: #e5e8ef;
  --txt: #1f2937;
  --sub: #6b7280;
  --brand: #2563eb;
  --brand-d: #1d4ed8;
  --ok: #16a34a;
  --ok-bg: #ecfdf3;
  --warn: #d97706;
  --warn-bg: #fff7e6;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--txt); font-size: 14px; line-height: 1.5;
}
a { color: var(--brand); text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font: inherit; color: var(--txt); width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
textarea { resize: vertical; min-height: 60px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--sub); font-weight: 500; font-size: 12px; white-space: nowrap; background: #fafbfd; }
tr:last-child td { border-bottom: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 7px 14px; border-radius: 8px; background: var(--brand); color: #fff; font-size: 13px; white-space: nowrap; transition: opacity .15s; }
.btn:hover { opacity: .88; }
.btn.ghost { background: #fff; color: var(--txt); border: 1px solid var(--line); }
.btn.soft { background: #eef2ff; color: var(--brand-d); }
.btn.ok { background: var(--ok); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.block { width: 100%; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.scheduled { background: #eef2ff; color: var(--brand-d); }
.badge.done { background: var(--ok-bg); color: var(--ok); }
.badge.leave { background: var(--warn-bg); color: var(--warn); }
.badge.cancelled { background: #f3f4f6; color: var(--sub); }
.badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.inactive, .badge.none { background: #f3f4f6; color: var(--sub); }
.badge.draft { background: #f3f4f6; color: var(--sub); }
.badge.confirmed { background: #eef2ff; color: var(--brand-d); }
.badge.paid { background: var(--ok-bg); color: var(--ok); }
.badge.pending { background: #fff7ed; color: #c2410c; }
.badge.approved { background: var(--ok-bg); color: var(--ok); }
.badge.rejected { background: #fee2e2; color: #dc2626; }
.badge.batch { background: #e0f2fe; color: #0369a1; }
.badge.private { background: #fae8ff; color: #a21caf; }
.badge.present { background: var(--ok-bg); color: var(--ok); }
.badge.absent { background: var(--danger-bg); color: var(--danger); }
.badge.leave { background: var(--warn-bg); color: var(--warn); }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; }
.card .card-hd { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); gap: 8px; flex-wrap: wrap; }
.card .card-hd h3 { font-size: 15px; font-weight: 600; }
.card .card-bd { padding: 14px 16px; }
.empty { text-align: center; color: var(--sub); padding: 34px 10px; }
.empty .big { font-size: 34px; margin-bottom: 6px; }

/* 登录 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #eef2ff, #f2f4f8 60%); }
.login-card { width: 100%; max-width: 380px; background: #fff; border-radius: 16px; padding: 28px 24px; box-shadow: var(--shadow); }
.login-card .logo { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
.login-card .logo span { color: var(--brand); }
.login-card .slogan { text-align: center; color: var(--sub); font-size: 12px; margin-bottom: 20px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--sub); margin-bottom: 4px; }
.tabs { display: flex; background: #f3f4f6; border-radius: 10px; padding: 3px; margin-bottom: 16px; }
.tabs button { flex: 1; padding: 7px 0; border-radius: 8px; font-size: 13px; color: var(--sub); }
.tabs button.on { background: #fff; color: var(--brand-d); font-weight: 600; box-shadow: var(--shadow); }

/* 主布局 */
.layout { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); }
.topbar .inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.topbar .brand { font-weight: 700; font-size: 17px; margin-right: 6px; }
.topbar .brand span { color: var(--brand); }
.topbar nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.topbar nav a { padding: 7px 12px; border-radius: 8px; color: var(--sub); font-size: 14px; white-space: nowrap; }
.topbar nav a.on { background: #eef2ff; color: var(--brand-d); font-weight: 600; }
.topbar .me { font-size: 12px; color: var(--sub); display: flex; align-items: center; gap: 8px; }
.main { max-width: 1080px; margin: 0 auto; padding: 14px; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 12px; flex-wrap: wrap; }
.page-head h2 { font-size: 18px; }
.page-head .sub { color: var(--sub); font-size: 12px; }

/* 工作台统计条 */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { color: var(--sub); font-size: 12px; margin-top: 2px; }

/* 周课表 */
.weekbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.wd { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; text-align: center; cursor: pointer; box-shadow: var(--shadow); }
.wd .w { font-size: 11px; color: var(--sub); }
.wd .d { font-size: 17px; font-weight: 600; margin-top: 1px; }
.wd.today { border-color: var(--brand); }
.wd.on { background: var(--brand); color: #fff; }
.wd.on .w { color: rgba(255, 255, 255, .8); }
.day-list { display: flex; flex-direction: column; gap: 8px; }
.sched { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow); border-left: 4px solid var(--brand); cursor: pointer; }
.sched.cancelled { opacity: .55; border-left-color: #9ca3af; }
.sched.done { border-left-color: var(--ok); }
.sched.leave { border-left-color: var(--warn); }
.sched .time { min-width: 92px; font-weight: 700; font-size: 15px; }
.sched .info { flex: 1; min-width: 0; }
.sched .t1 { font-weight: 600; }
.sched .t2 { color: var(--sub); font-size: 12px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 表单弹窗 */
.mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.dialog { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 10px 40px rgba(0,0,0,.15); }
.dialog.h2 { max-width: 680px; }
.dialog .dlg-hd { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dialog .dlg-hd h3 { font-size: 15px; }
.dialog .dlg-bd { padding: 14px 16px; overflow-y: auto; }
.dialog .dlg-ft { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field { margin: 0; }

/* 点名行 */
.roll { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.roll:last-child { border-bottom: none; }
.roll .nm { flex: 1; min-width: 0; }
.roll .rm { font-size: 12px; color: var(--sub); }
.roll .opts { display: flex; gap: 4px; }
.seg { padding: 4px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); color: var(--sub); }
.seg.on.present { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); font-weight: 600; }
.seg.on.absent { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); font-weight: 600; }
.seg.on.leave { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); font-weight: 600; }

.toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 99; background: #1f2937; color: #fff; padding: 9px 18px; border-radius: 10px; font-size: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.2); max-width: 90vw; animation: fadein .2s; }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--ok); }
@keyframes fadein { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.table-wrap { overflow-x: auto; }
.muted { color: var(--sub); font-size: 12px; }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.mb10 { margin-bottom: 10px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.nowrap { white-space: nowrap; }
.section-t { font-size: 13px; font-weight: 600; color: var(--sub); margin: 16px 0 8px; display: flex; align-items: center; justify-content: space-between; }

@media (max-width: 640px) {
  .topbar .me .uname { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .main { padding: 10px; }
  .wd { padding: 6px 2px; }
}
