/* ============ 基础变量 ============ */
:root {
  --blue: #2563EB;
  --blue-deep: #1D4ED8;
  --blue-soft: #EFF6FF;
  --pink: #F472B6;
  --pink-soft: #FDF2F8;
  --green: #10B981;
  --green-soft: #ECFDF5;
  --yellow: #F59E0B;
  --yellow-soft: #FFFBEB;
  --purple: #8B5CF6;
  --purple-soft: #F5F3FF;
  --red: #EF4444;
  --red-soft: #FEF2F2;
  --bg: #F4F7FC;
  --card: #FFFFFF;
  --ink: #1E293B;
  --ink-2: #475569;
  --muted: #94A3B8;
  --line: #E8EDF5;
  --shadow: 0 8px 26px rgba(37, 99, 235, .07);
  --shadow-sm: 0 3px 12px rgba(15, 23, 42, .05);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--blue); text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 布局 ============ */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 50;
  width: 248px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.sidebar-mask { display: none; }
.main { margin-left: 248px; min-width: 0; }
.content { padding: 22px 28px 56px; max-width: 1560px; margin: 0 auto; }

/* 品牌 */
.brand { display: flex; align-items: center; gap: 11px; padding: 22px 19px 18px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center;
  font-size: 22px; background: linear-gradient(135deg, var(--blue), #60A5FA);
  box-shadow: 0 6px 14px rgba(37,99,235,.25);
}
.brand-text strong { display: block; font-size: 16px; letter-spacing: .3px; }
.brand-text span { font-size: 11px; color: var(--muted); letter-spacing: .5px; }

/* 导航 */
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 14px; }
.nav-group-title {
  font-size: 11px; color: var(--muted); padding: 14px 10px 6px; font-weight: 700; letter-spacing: 1px;
}
.nav-item {
  width: 100%; display: flex; align-items: center; gap: 11px; border: 0; background: transparent;
  padding: 10px 12px; border-radius: 12px; color: var(--ink-2); font-weight: 600; text-align: left;
  margin-bottom: 3px; transition: .18s;
}
.nav-item:hover { background: var(--blue-soft); color: var(--blue); }
.nav-item.active { background: var(--blue); color: #fff; box-shadow: 0 6px 14px rgba(37,99,235,.22); }
.nav-emoji { font-size: 17px; width: 24px; text-align: center; }
.nav-count {
  margin-left: auto; background: var(--yellow); color: #fff; border-radius: 20px;
  font-size: 11px; padding: 1px 7px; font-weight: 700;
}
.nav-item.active .nav-count { background: rgba(255,255,255,.25); }
.sidebar-foot { padding: 12px 14px 18px; border-top: 1px solid var(--line); }
.teacher-card { display: flex; align-items: center; gap: 10px; padding: 8px 6px; }
.teacher-avatar {
  width: 38px; height: 38px; border-radius: 12px; background: var(--pink-soft); display: grid; place-items: center; font-size: 20px;
}
.teacher-info strong { display: block; font-size: 13px; }
.teacher-info span { font-size: 11px; color: var(--muted); }
.reset-btn {
  width: 100%; margin-top: 8px; border: 1px dashed var(--line); background: #fff; color: var(--muted);
  border-radius: 10px; padding: 7px; font-size: 12px;
}
.reset-btn:hover { color: var(--blue); border-color: var(--blue); }
.local-tip { text-align: center; font-size: 11px; color: var(--muted); margin-top: 9px; }

/* 顶栏 */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  padding: 14px 28px; background: rgba(255,255,255,.92); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.page-heading { min-width: 0; }
.page-heading h1 { font-size: 19px; margin: 0; line-height: 1.3; }
.page-heading p { margin: 1px 0 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.search-box {
  display: flex; align-items: center; gap: 7px; background: var(--bg); border: 1px solid transparent;
  border-radius: 11px; padding: 7px 12px; color: var(--muted); transition: .2s;
}
.search-box:focus-within { border-color: var(--blue); background: #fff; }
.search-box input { border: 0; outline: 0; background: transparent; width: 150px; color: var(--ink); }
.today-chip { background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 700; padding: 7px 12px; border-radius: 11px; white-space: nowrap; }
.icon-btn { border: 0; background: var(--bg); border-radius: 10px; width: 36px; height: 36px; font-size: 18px; color: var(--ink-2); }
.menu-btn { display: none; }

/* ============ 通用组件 ============ */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.panel { padding: 18px 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 15px; flex-wrap: wrap; }
.panel-title { font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; margin: 0; }
.panel-title .emoji { font-size: 18px; }
.panel-sub { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: minmax(0,1.7fr) minmax(0,1fr); }
.g-1-2 { grid-template-columns: minmax(0,1fr) minmax(0,1.7fr); }
.mt16 { margin-top: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.flex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.empty { text-align: center; padding: 38px 16px; color: var(--muted); }
.empty .big { font-size: 34px; display: block; margin-bottom: 8px; }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); border-radius: 10px;
  padding: 8px 13px; font-size: 13px; font-weight: 700; display: inline-flex; align-items: center; gap: 6px;
  transition: .16s; white-space: nowrap;
}
.btn:hover { border-color: var(--blue); color: var(--blue); transform: translateY(-1px); }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); box-shadow: 0 5px 14px rgba(37,99,235,.2); }
.btn-primary:hover { background: var(--blue-deep); color: #fff; }
.btn-green { background: var(--green); color: #fff; border-color: var(--green); }
.btn-green:hover { background: #059669; color: #fff; }
.btn-yellow { background: var(--yellow); color: #fff; border-color: var(--yellow); }
.btn-yellow:hover { background: #D97706; color: #fff; }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); color: var(--red); }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 8px; }
.btn-icon { padding: 5px 8px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: 20px; padding: 3px 9px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.b-blue { background: var(--blue-soft); color: var(--blue); }
.b-green { background: var(--green-soft); color: #059669; }
.b-yellow { background: var(--yellow-soft); color: #B45309; }
.b-pink { background: var(--pink-soft); color: #DB2777; }
.b-purple { background: var(--purple-soft); color: #7C3AED; }
.b-red { background: var(--red-soft); color: #DC2626; }
.b-gray { background: #F1F5F9; color: var(--ink-2); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #DDE5F0; border-radius: 10px; padding: 9px 11px; outline: none;
  background: #fff; color: var(--ink); transition: .16s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.field textarea { resize: vertical; min-height: 78px; }
.field .hint { font-size: 11px; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.span2 { grid-column: 1 / -1; }

.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 15px; }
.toolbar input[type="search"], .toolbar select, .toolbar input[type="date"] {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px; color: var(--ink); outline: none;
}
.toolbar input[type="search"]:focus, .toolbar select:focus { border-color: var(--blue); }
.toolbar select { max-width: 170px; }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; min-width: 640px; }
table.data th {
  text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #FBFCFF;
}
table.data td { padding: 11px 12px; border-bottom: 1px solid #F1F4F9; vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #FAFCFF; }
.avatar {
  width: 31px; height: 31px; border-radius: 10px; display: inline-grid; place-items: center;
  font-weight: 800; font-size: 12px; margin-right: 9px; vertical-align: middle; color: #fff;
}
.row-actions { display: flex; gap: 5px; flex-wrap: wrap; }

/* 统计卡 */
.stat {
  position: relative; padding: 17px 18px; border-radius: var(--radius); background: #fff;
  border: 1px solid var(--line); box-shadow: var(--shadow-sm); overflow: hidden;
}
.stat::after { content: ''; position: absolute; right: -18px; top: -22px; width: 86px; height: 86px; border-radius: 50%; background: var(--tint, var(--blue-soft)); opacity: .75; }
.stat-top { display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.stat-emoji { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; font-size: 18px; background: var(--tint, var(--blue-soft)); }
.stat-label { font-size: 12px; color: var(--ink-2); font-weight: 700; }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.25; margin-top: 7px; position: relative; z-index: 1; }
.stat-value small { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat-foot { font-size: 11px; color: var(--muted); margin-top: 3px; position: relative; z-index: 1; }
.stat.blue { --tint: var(--blue-soft); --accent: var(--blue); }
.stat.pink { --tint: var(--pink-soft); --accent: var(--pink); }
.stat.green { --tint: var(--green-soft); --accent: var(--green); }
.stat.yellow { --tint: var(--yellow-soft); --accent: var(--yellow); }
.stat.purple { --tint: var(--purple-soft); --accent: var(--purple); }
.stat.red { --tint: var(--red-soft); --accent: var(--red); }

/* 首页横幅 */
.hero {
  border-radius: 22px; padding: 22px 26px; color: #fff; margin-bottom: 16px;
  background: linear-gradient(115deg, #2563EB 0%, #3B82F6 55%, #60A5FA 100%);
  position: relative; overflow: hidden; box-shadow: 0 12px 26px rgba(37,99,235,.2);
}
.hero::before { content: '🎓'; position: absolute; right: 28px; top: -24px; font-size: 140px; opacity: .16; transform: rotate(-12deg); }
.hero h2 { margin: 0 0 4px; font-size: 21px; position: relative; z-index: 1; }
.hero p { margin: 0; opacity: .85; font-size: 13px; position: relative; z-index: 1; }
.hero-actions { display: flex; gap: 9px; margin-top: 17px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero-actions button {
  border: 0; background: rgba(255,255,255,.19); color: #fff; border-radius: 11px; padding: 8px 13px;
  font-weight: 700; font-size: 12px; backdrop-filter: blur(4px); transition: .16s;
}
.hero-actions button:hover { background: #fff; color: var(--blue); transform: translateY(-2px); }

/* 图表 */
.chart-box { width: 100%; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 9px 16px; margin-top: 10px; font-size: 12px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-wrap svg { width: 160px; height: 160px; flex: 0 0 auto; }
.donut-legend { flex: 1; min-width: 130px; display: grid; gap: 7px; }

/* 列表项 */
.list-item { display: flex; align-items: flex-start; gap: 11px; padding: 11px 0; border-bottom: 1px dashed var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-emoji { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; flex: 0 0 auto; background: var(--blue-soft); }
.list-body { flex: 1; min-width: 0; }
.list-title { font-weight: 700; font-size: 13px; }
.list-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.list-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* 待办 */
.todo-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 8px; background: #fff; transition: .16s;
}
.todo-item:hover { border-color: #BFDBFE; background: #FBFDFF; }
.todo-item.done { opacity: .62; }
.todo-item.done .todo-title { text-decoration: line-through; color: var(--muted); }
.check {
  width: 21px; height: 21px; border-radius: 7px; border: 2px solid #CBD5E1; background: #fff;
  display: grid; place-items: center; font-size: 12px; color: #fff; flex: 0 0 auto; padding: 0;
}
.check.on { background: var(--green); border-color: var(--green); }
.todo-title { font-weight: 700; font-size: 13px; }
.todo-meta { font-size: 11px; color: var(--muted); }
.overdue { color: var(--red) !important; }
.today-mark { color: var(--blue) !important; }

/* 活动卡 */
.activity-card { padding: 17px; display: flex; flex-direction: column; gap: 9px; transition: .18s; }
.activity-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.activity-icon { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; font-size: 21px; }
.activity-title { font-weight: 800; font-size: 14px; }
.activity-desc { font-size: 12px; color: var(--ink-2); min-height: 36px; }

/* 公告 */
.notice-card { padding: 16px 18px; margin-bottom: 10px; }
.notice-card.pinned { border-left: 4px solid var(--yellow); }
.notice-title { font-weight: 800; font-size: 14px; margin-bottom: 5px; }
.notice-content { font-size: 13px; color: var(--ink-2); white-space: pre-wrap; }

/* 班级胶囊 */
.class-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 12px; background: #fff; font-size: 13px; font-weight: 700;
}
.class-chip:hover { border-color: var(--blue); }
.class-chip .cnt { color: var(--muted); font-weight: 600; font-size: 11px; }

/* 考勤状态按钮 */
.status-group { display: inline-flex; gap: 3px; background: var(--bg); padding: 3px; border-radius: 9px; }
.status-group button {
  border: 0; background: transparent; border-radius: 7px; padding: 4px 8px; font-size: 11px; font-weight: 700; color: var(--muted);
}
.status-group button.on { background: #fff; box-shadow: var(--shadow-sm); }
.status-group button.on[data-s="present"] { color: var(--green); }
.status-group button.on[data-s="late"] { color: var(--yellow); }
.status-group button.on[data-s="leave"] { color: var(--blue); }
.status-group button.on[data-s="absent"] { color: var(--red); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.4); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal {
  background: #fff; border-radius: 20px; width: min(620px, 100%); max-height: min(86vh, 900px);
  display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(15,23,42,.2); animation: pop .18s ease-out;
}
.modal.wide { width: min(820px, 100%); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 21px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; }
.modal-head .close { margin-left: auto; border: 0; background: var(--bg); width: 30px; height: 30px; border-radius: 9px; font-size: 17px; color: var(--muted); }
.modal-body { padding: 20px 21px; overflow-y: auto; }
.modal-foot { padding: 14px 21px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }
.bulk-row { display: grid; grid-template-columns: 1.4fr 1fr; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.bulk-row:last-child { border-bottom: 0; }

/* 提示 */
.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: grid; gap: 9px; }
.toast {
  background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 12px;
  padding: 11px 15px; box-shadow: var(--shadow); font-size: 13px; font-weight: 700; min-width: 210px;
  animation: slidein .2s ease-out;
}
.toast.err { border-left-color: var(--red); }
.toast.info { border-left-color: var(--blue); }
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* ============ 响应式 ============ */
@media (max-width: 1180px) {
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g-2-1, .g-1-2 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; box-shadow: 12px 0 30px rgba(15,23,42,.12); }
  .sidebar.open { transform: none; }
  .sidebar-mask.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 45; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; place-items: center; }
  .topbar { padding: 11px 16px; }
  .content { padding: 16px 15px 60px; }
  .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 13px; }
  .topbar { gap: 9px; }
  .page-heading h1 { font-size: 16px; }
  .page-heading p { display: none; }
  .today-chip { display: none; }
  .search-box input { width: 108px; }
  .content { padding: 13px 12px 70px; }
  .grid, .g2, .g3, .g4 { grid-template-columns: 1fr; gap: 12px; }
  .hero { padding: 18px 17px; }
  .hero h2 { font-size: 18px; }
  .hero::before { font-size: 92px; right: 0; }
  .stat { padding: 14px; }
  .stat-value { font-size: 22px; }
  .panel { padding: 15px 14px; }
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .toolbar > input, .toolbar > select { flex: 1 1 130px; max-width: none; }
  .toolbar .btn { flex: 1 1 auto; justify-content: center; }

  /* 手机端表格转卡片 */
  table.data { min-width: 0; display: block; }
  table.data thead { display: none; }
  table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tbody tr {
    border: 1px solid var(--line); border-radius: 13px; padding: 8px 11px; margin-bottom: 10px; background: #fff;
  }
  table.data td { border: 0; padding: 5px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  table.data td::before {
    content: attr(data-label); flex: 0 0 76px; color: var(--muted); font-size: 11px; font-weight: 700;
  }
  table.data td:last-child { border-top: 1px dashed var(--line); margin-top: 5px; padding-top: 9px; }
  table.data td:last-child::before { display: none; }
  .row-actions { justify-content: flex-end; width: 100%; }
  .bulk-row { grid-template-columns: 1fr; gap: 6px; }
  .modal-body { padding: 15px; }
  .modal-head, .modal-foot { padding: 14px 15px; }
  .toast-root { left: 12px; right: 12px; bottom: 12px; }
}

@media print {
  .sidebar, .topbar, .toolbar, .row-actions, .hero-actions { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  .card, .stat { box-shadow: none; }
}
