:root {
  --primary: #2f6bff;
  --primary-dark: #1f4fd8;
  --primary-light: #eaf1ff;
  --green: #16a085;
  --green-light: #e6f7f2;
  --red: #e8453c;
  --red-light: #fdecea;
  --orange: #f39c12;
  --orange-light: #fef4e2;
  --purple: #9b59b6;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1f2937;
  --text-2: #6b7280;
  --border: #e5e7eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .14);
  --sidebar-w: 220px;
  --topbar-h: 56px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", "Segoe UI", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 通用组件 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: all .15s; white-space: nowrap; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-danger { background: #fff; border-color: #f5c6c3; color: var(--red); }
.btn-danger:hover { background: var(--red); border-color: var(--red); color: #fff; }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #12806a; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: rgba(47, 107, 255, .08); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 600; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-title .sub { font-size: 12px; color: var(--text-2); font-weight: 400; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; line-height: 1.6; }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-gray { background: #f3f4f6; color: var(--text-2); }
.badge-purple { background: #f3eefb; color: var(--purple); }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.tbl th { background: #fafbfc; color: var(--text-2); font-weight: 600; font-size: 13px; position: sticky; top: 0; }
table.tbl tbody tr:hover { background: #f8faff; }
table.tbl td .op { display: flex; gap: 6px; }
.empty { text-align: center; color: var(--text-2); padding: 36px 0; }
.empty .icon { font-size: 34px; opacity: .4; }

.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 5px; color: var(--text-2); font-size: 13px; }
.field label .req { color: var(--red); margin-left: 2px; }
.field input, .field select, .field textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; outline: none; transition: border .15s; background: #fff; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 107, 255, .12); }
.field textarea { min-height: 84px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-hint { font-size: 12px; color: var(--text-2); margin-top: 4px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.toolbar input[type="text"], .toolbar select, .toolbar input[type="date"] { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; outline: none; background: #fff; }
.toolbar input[type="text"]:focus, .toolbar select:focus { border-color: var(--primary); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.stat-card .ic { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 22px; color: #fff; flex: none; }
.stat-card .num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-card .lbl { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.ic-blue { background: linear-gradient(135deg, #4d8bff, #2f6bff); }
.ic-green { background: linear-gradient(135deg, #2fc0a0, #16a085); }
.ic-orange { background: linear-gradient(135deg, #f7b733, #f39c12); }
.ic-purple { background: linear-gradient(135deg, #b07ce0, #9b59b6); }
.ic-red { background: linear-gradient(135deg, #ff6b62, #e8453c); }

.timetable { display: grid; grid-template-columns: 72px repeat(7, 1fr); gap: 6px; overflow-x: auto; }
.timetable .tt-head, .timetable .tt-cell { border-radius: 8px; padding: 8px; font-size: 12px; }
.timetable .tt-head { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; text-align: center; min-height: 34px; display: flex; align-items: center; justify-content: center; }
.timetable .tt-head.today { background: var(--primary); color: #fff; }
.timetable .tt-hour { display: flex; align-items: center; justify-content: center; color: var(--text-2); font-size: 12px; }
.timetable .tt-cell { background: #f8fafc; min-height: 58px; border: 1px dashed transparent; }
.timetable .tt-slot { background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; box-shadow: var(--shadow); }
.timetable .tt-slot .nm { font-weight: 600; font-size: 12.5px; }
.timetable .tt-slot .tm { color: var(--text-2); font-size: 11.5px; margin-top: 2px; }
.timetable .tt-slot .who { color: var(--text-2); font-size: 11.5px; margin-top: 2px; }

.notice-item { padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; background: #fff; }
.notice-item .t { font-weight: 600; margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.notice-item .c { color: var(--text-2); font-size: 13px; line-height: 1.7; }
.notice-item .m { color: var(--text-2); font-size: 12px; margin-top: 6px; }

.seg { display: inline-flex; background: #eceff3; border-radius: 8px; padding: 3px; }
.seg button { border: none; background: transparent; padding: 5px 14px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-size: 13px; }
.seg button.on { background: #fff; color: var(--primary); box-shadow: var(--shadow); font-weight: 600; }

.switch { position: relative; width: 42px; height: 22px; display: inline-block; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .sl { position: absolute; inset: 0; background: #d1d5db; border-radius: 20px; transition: .2s; cursor: pointer; }
.switch .sl::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .sl { background: var(--primary); }
.switch input:checked + .sl::before { transform: translateX(20px); }

.kv-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.kv-row:last-child { border-bottom: none; }
.kv-row .k { font-size: 13.5px; }
.kv-row .d { color: var(--text-2); font-size: 12px; margin-top: 2px; }
.kv-row .v { flex: none; }

.avatar { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 50%; background: var(--primary-light); color: var(--primary); font-weight: 700; font-size: 13px; }
.avatar-lg { width: 44px; height: 44px; font-size: 18px; }
.color-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 4px; }

/* ---------- 模态框 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.modal-mask[hidden] { display: none !important; }
.modal { background: #fff; border-radius: 14px; width: 520px; max-width: 100%; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .16s ease; }
.modal.wide { width: 680px; }
.modal .m-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal .m-head h3 { font-size: 16px; }
.modal .m-x { border: none; background: none; font-size: 20px; color: var(--text-2); cursor: pointer; line-height: 1; }
.modal .m-body { padding: 18px 20px; overflow-y: auto; }
.modal .m-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; top: 70px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow-lg); animation: slideIn .2s ease; max-width: 320px; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 登录页 ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1e3a8a 0%, #2f6bff 55%, #4d8bff 100%); padding: 20px; }
.login-card { width: 400px; max-width: 100%; background: #fff; border-radius: 16px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); padding: 34px 36px; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .lg { font-size: 26px; font-weight: 800; color: var(--primary); }
.login-logo .sub { color: var(--text-2); font-size: 13px; margin-top: 6px; }
.login-page .field input { padding: 11px 12px; }
.login-err { color: var(--red); font-size: 13px; margin-bottom: 8px; min-height: 18px; }
.login-tip { margin-top: 18px; background: var(--primary-light); border-radius: 10px; padding: 12px 14px; font-size: 12.5px; color: var(--primary-dark); line-height: 1.8; }
.login-foot { margin-top: 16px; text-align: center; font-size: 12px; color: var(--text-2); }

/* ---------- 管理端布局 ---------- */
.admin-body { display: flex; }
.sidebar { width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--border); height: 100vh; position: fixed; left: 0; top: 0; display: flex; flex-direction: column; z-index: 100; transition: transform .2s; }
.sidebar-head { padding: 18px 16px 14px; border-bottom: 1px solid var(--border); }
.sidebar-head .logo { font-size: 19px; font-weight: 800; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.sidebar-head .logo .mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #4d8bff, #2f6bff); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.sidebar-head .sub { font-size: 11.5px; color: var(--text-2); margin-top: 4px; padding-left: 38px; }
.menu { flex: 1; overflow-y: auto; padding: 10px 10px; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--text-2); font-size: 13.5px; cursor: pointer; margin-bottom: 2px; }
.menu-item .ic { width: 18px; text-align: center; font-size: 15px; }
.menu-item:hover { background: #f5f7fb; color: var(--text); }
.menu-item.on { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar { height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 18px; position: sticky; top: 0; z-index: 90; }
.topbar-title { font-size: 15px; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.content { padding: 18px; max-width: 1280px; }
.icon-btn { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--text-2); display: none; padding: 4px; }

/* ---------- 手机端 ---------- */
.mp-body { background: var(--bg); }
.mp-page { max-width: 560px; margin: 0 auto; padding: 14px 14px 86px; }
.mp-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 4px 10px; }
.mp-head .tt { font-size: 20px; font-weight: 800; }
.mp-head .who { font-size: 13px; color: var(--text-2); }
.mp-hero { background: linear-gradient(135deg, #2f6bff, #4d8bff); border-radius: 14px; color: #fff; padding: 18px; margin-bottom: 14px; }
.mp-hero .hi { font-size: 15px; opacity: .9; }
.mp-hero .nm { font-size: 22px; font-weight: 800; margin-top: 2px; }
.mp-hero .info { margin-top: 10px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; opacity: .95; }
.mp-bottombar { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--border); display: flex; z-index: 100; }
.mp-bottombar a { flex: 1; text-align: center; padding: 8px 0 10px; font-size: 11px; color: var(--text-2); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.mp-bottombar a .i { font-size: 19px; }
.mp-bottombar a.on { color: var(--primary); font-weight: 600; }
.mp-section-title { font-size: 14.5px; font-weight: 700; margin: 16px 2px 10px; display: flex; align-items: center; justify-content: space-between; }
.roll-list { display: flex; flex-direction: column; gap: 8px; }
.roll-item { background: #fff; border-radius: 12px; padding: 12px 14px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow); }
.roll-item .nm { font-weight: 600; flex: 1; }
.roll-item .st { display: flex; gap: 6px; }
.roll-item .st button { border: 1px solid var(--border); background: #fff; color: var(--text-2); border-radius: 8px; padding: 5px 9px; font-size: 12px; cursor: pointer; }
.roll-item .st button.on-出勤 { background: var(--green-light); border-color: var(--green); color: var(--green); }
.roll-item .st button.on-迟到 { background: var(--orange-light); border-color: var(--orange); color: var(--orange); }
.roll-item .st button.on-请假 { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.roll-item .st button.on-缺勤 { background: var(--red-light); border-color: var(--red); color: var(--red); }
.mp-card { background: #fff; border-radius: 14px; padding: 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.mp-card .k { color: var(--text-2); font-size: 12px; }
.mp-card .v { font-size: 15px; font-weight: 600; margin-top: 2px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .icon-btn { display: block; }
  .hide-mobile { display: none !important; }
  .content { padding: 12px; }
}
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { gap: 8px; }
  .toolbar .spacer { display: none; }
}
