:root {
  --bg: #f6f4fb;
  --surface: #ffffff;
  --surface-soft: #fbf9fe;
  --border: #ebe5f4;
  --border-strong: #ded5ee;
  --text: #251d38;
  --text-2: #615877;
  --text-3: #9187a6;
  --primary: #7c4dcb;
  --primary-dark: #6238ab;
  --primary-soft: #f2ebfc;
  --accent: #d24597;
  --accent-soft: #fdeff7;
  --gold: #d99a2b;
  --gold-soft: #fdf4e3;
  --danger: #d4505f;
  --danger-soft: #fdf0f1;
  --success: #2f9c7a;
  --success-soft: #eaf7f2;
  --shadow-sm: 0 1px 2px rgba(45, 25, 80, .03), 0 4px 14px rgba(60, 35, 105, .04);
  --shadow-md: 0 4px 10px rgba(45, 25, 80, .05), 0 14px 36px rgba(60, 35, 105, .08);
  --radius: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
input, select { outline: none; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

/* ---------- Top bar ---------- */
.topbar {
  background: linear-gradient(112deg, #6f3fc0 0%, #8551cd 48%, #a855b8 100%);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.topbar::after {
  content: "";
  position: absolute;
  right: -70px;
  top: -110px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .13);
  box-shadow: 0 0 0 38px rgba(255, 255, 255, .045), 0 0 0 82px rgba(255, 255, 255, .035);
  pointer-events: none;
}
.topbar-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 1;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand-mark {
  width: 52px; height: 52px; flex: none;
  border-radius: 15px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .25);
  display: grid; place-items: center;
  backdrop-filter: blur(4px);
}
.brand-mark svg { width: 34px; height: 34px; }
.brand-copy h1 { font-size: 20px; font-weight: 700; letter-spacing: .3px; line-height: 1.35; }
.brand-sep { opacity: .6; font-weight: 400; margin: 0 2px; }
.brand-copy p { font-size: 12.5px; opacity: .78; letter-spacing: 1.2px; margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex: none; }
.dept-entry {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 13px; border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .3);
  color: #fff; font-size: 13px; font-weight: 600;
  text-decoration: none; white-space: nowrap;
}
.dept-entry:hover { background: rgba(255, 255, 255, .26); }
.today-chip {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; opacity: .9;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .16);
  white-space: nowrap;
}
.today-chip .icon { width: 15px; height: 15px; }
.icon-button {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  transition: background .18s ease, transform .18s ease;
}
.icon-button:hover { background: rgba(255, 255, 255, .24); }
.icon-button:active { transform: translateY(1px); }

/* ---------- Container ---------- */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 24px 24px 40px; flex: 1; }

.demo-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px;
  margin-bottom: 18px;
  background: #fff8e9;
  border: 1px solid #f4e0b6;
  border-radius: 12px;
  color: #8a6420;
  font-size: 13px;
}
.demo-banner .icon { width: 17px; height: 17px; color: #c8932f; }
.demo-banner span { flex: 1; }
.demo-banner strong { font-weight: 700; }
.demo-banner button {
  flex: none;
  border: 1px solid #e6c88b;
  background: #fff;
  color: #8a6420;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 8px;
  transition: background .18s ease;
}
.demo-banner button:hover { background: #fdf1d9; }
.demo-banner .banner-close { padding: 4px; border: none; background: transparent; color: #b19055; display: grid; place-items: center; }
.demo-banner .banner-close:hover { background: transparent; color: #8a6420; }

/* ---------- Stat cards ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.stat-label { font-size: 12.5px; color: var(--text-2); letter-spacing: .2px; }
.stat-value { font-size: 28px; font-weight: 700; line-height: 1.25; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stat-value .unit { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 3px; letter-spacing: 0; }
.stat-note { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.stat-icon {
  width: 38px; height: 38px; flex: none;
  border-radius: 11px;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.stat-icon .icon { width: 19px; height: 19px; }
.stat-icon.pink { background: var(--accent-soft); color: var(--accent); }
.stat-icon.gold { background: var(--gold-soft); color: var(--gold); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }

/* ---------- Month bar ---------- */
.month-bar {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(105deg, #fff 0%, #fbf7ff 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.month-nav { display: flex; align-items: center; gap: 10px; }
.month-arrow {
  width: 32px; height: 32px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--border-strong);
  background: #fff; color: var(--primary);
  border-radius: 9px;
  transition: background .18s ease, border-color .18s ease;
}
.month-arrow:hover { background: var(--primary-soft); border-color: var(--primary); }
.month-arrow.flip .icon { transform: rotate(180deg); }
.month-current { display: flex; align-items: baseline; gap: 8px; min-width: 218px; justify-content: center; }
.mc-label { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.month-current strong { font-size: 18px; font-weight: 700; letter-spacing: .2px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mc-tag { font-size: 10.5px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--success-soft); color: var(--success); white-space: nowrap; }
.mc-tag.past { background: #f2eff8; color: var(--text-2); }
.mc-tag.future { background: var(--primary-soft); color: var(--primary); }
.month-meta { flex: 1; min-width: 170px; font-size: 12px; color: var(--text-2); line-height: 1.7; }
.month-meta b { color: var(--primary); font-variant-numeric: tabular-nums; }
.month-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-actions .select-wrap select { min-width: 132px; }
.month-inline { color: var(--primary); font-weight: 600; margin-left: 4px; }

/* ---------- Monthly awards ---------- */
.award-badge {
  display: inline-block; margin-left: 7px; padding: 2px 7px;
  border-radius: 6px; font-size: 10.5px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid #f3d3e6; white-space: nowrap;
  vertical-align: middle;
}
.award-banner {
  display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
  padding: 14px 16px; margin-bottom: 16px;
  border: 1px solid #f0d9e8; border-radius: 12px;
  background: linear-gradient(100deg, #fdf5fa, #fff);
}
.award-banner .ab-head { min-width: 178px; }
.award-banner .ab-title { font-size: 13px; font-weight: 700; color: var(--accent); }
.award-banner .ab-note { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.award-chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.award-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 9px; border-radius: 8px;
  background: #fff; border: 1px solid #f0d9e8;
  font-size: 11.5px; font-weight: 600; color: var(--text-2);
}
.award-chip i { font-style: normal; color: var(--accent); font-variant-numeric: tabular-nums; }
.month-table { min-width: 860px; }
.month-state { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 600; }
.month-state.current { background: var(--success-soft); color: var(--success); }
.month-state.past { background: #f2eff8; color: var(--text-2); }
.month-state.future { background: var(--primary-soft); color: var(--primary); }
.month-name { font-weight: 700; white-space: nowrap; }
.month-top3 { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.month-top3 b { color: var(--primary); font-weight: 600; }

@media (max-width: 720px) {
  .month-bar { gap: 10px; padding: 12px; }
  .month-current { min-width: 0; }
  .month-meta { flex-basis: 100%; }
  .month-actions { width: 100%; }
  .month-actions .select-wrap { flex: 1; }
  .month-actions .select-wrap select { width: 100%; }
}

/* ---------- Tabs ---------- */
.tabbar {
  display: flex; align-items: center; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 5px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
}
.tab {
  display: flex; align-items: center; gap: 8px;
  border: none; background: transparent;
  color: var(--text-2);
  padding: 9px 17px;
  border-radius: 9px;
  font-size: 13.5px; font-weight: 600;
  transition: background .18s ease, color .18s ease;
  white-space: nowrap;
}
.tab .icon { width: 16px; height: 16px; }
.tab:hover { background: var(--surface-soft); color: var(--primary); }
.tab.active { background: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(124, 77, 203, .24); }
.tab.active:hover { background: var(--primary-dark); color: #fff; }
.tabbar-spacer { flex: 1; }
.text-button {
  display: flex; align-items: center; gap: 7px;
  border: none; background: transparent;
  color: var(--text-2); font-size: 13px; font-weight: 600;
  padding: 9px 14px; border-radius: 9px;
  transition: background .18s ease, color .18s ease;
}
.text-button:hover { background: var(--primary-soft); color: var(--primary); }
.text-button .icon { width: 16px; height: 16px; }

/* ---------- Panel ---------- */
.view { display: none; }
.view.active { display: block; animation: fadeIn .24s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px 18px;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.panel-head.compact { padding-bottom: 14px; margin-bottom: 14px; }
.panel-head h2 { font-size: 16.5px; font-weight: 700; letter-spacing: .2px; }
.panel-head p { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
.panel-head p strong { color: var(--primary); }
.filters { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.select-wrap, .search-wrap { position: relative; display: flex; align-items: center; }
.select-wrap select, .search-wrap input, .field input[type="text"], .field input[type="date"], .field input[type="number"] {
  height: 36px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  padding: 0 12px;
  font-size: 13px;
  color: var(--text);
  transition: border-color .18s ease, box-shadow .18s ease;
}
.select-wrap select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%239187a6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2 4 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
.search-wrap .icon { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--text-3); pointer-events: none; }
.search-wrap input { padding-left: 32px; width: 190px; }
.search-wrap input[type="search"]::-webkit-search-cancel-button { cursor: pointer; }
select:focus, input:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 77, 203, .12); }
input::placeholder { color: #aaa2ba; }

/* ---------- Grade overview ---------- */
.grade-overview { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.grade-box {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px 11px;
  transition: border-color .18s ease, background .18s ease;
}
.grade-box:hover { border-color: var(--border-strong); background: #fff; }
.grade-box .gb-top { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; }
.grade-box .gb-name { font-size: 12px; color: var(--text-2); font-weight: 600; }
.grade-box .gb-score { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }
.grade-box .gb-track { height: 5px; border-radius: 99px; background: #eae3f5; margin-top: 9px; overflow: hidden; }
.grade-box .gb-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #9a6ce0, #7c4dcb); transition: width .4s ease; }
.grade-box .gb-note { font-size: 10.5px; color: var(--text-3); margin-top: 6px; }

/* ---------- Podium ---------- */
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; margin-bottom: 20px; }
.podium-card {
  position: relative;
  border-radius: 14px;
  padding: 16px 16px 15px;
  border: 1px solid var(--border);
  background: linear-gradient(160deg, #fbfaff, #fff);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.podium-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.podium-card.first { background: linear-gradient(155deg, #fff9ec 0%, #fffdf8 60%, #fff 100%); border-color: #f0dcae; padding-top: 20px; }
.podium-card.second { background: linear-gradient(155deg, #f8f7fc 0%, #fff 100%); }
.podium-card.third { background: linear-gradient(155deg, #fdf6f1 0%, #fff 100%); }
.podium-card .medal {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center; margin-bottom: 10px;
  background: #f2eef9; color: #8b7bab;
}
.podium-card.first .medal { background: #fbecd0; color: #c9922c; }
.podium-card.second .medal { background: #eceaf4; color: #8b87a3; }
.podium-card.third .medal { background: #f8e8dc; color: #c08a63; }
.podium-card .medal .icon { width: 18px; height: 18px; }
.pc-rank { font-size: 11px; font-weight: 700; letter-spacing: 1.4px; color: var(--text-3); text-transform: uppercase; }
.pc-class { font-size: 17px; font-weight: 700; margin-top: 2px; }
.pc-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.pc-bottom { display: flex; align-items: flex-end; justify-content: space-between; margin-top: 14px; }
.pc-score { font-size: 26px; font-weight: 700; line-height: 1; color: var(--primary); font-variant-numeric: tabular-nums; }
.pc-score small { font-size: 12px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.pc-deduct { font-size: 11.5px; color: var(--text-3); text-align: right; }
.podium-card.first .pc-score { color: #c28a24; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 680px; }
.data-table thead th {
  background: var(--surface-soft);
  color: var(--text-2);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .3px;
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td { padding: 11px 14px; border-bottom: 1px solid #f2eff8; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .16s ease; }
.data-table tbody tr:hover { background: #faf7ff; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-rank { width: 72px; }
.col-action { width: 88px; text-align: right; }
.rank-badge {
  display: inline-grid; place-items: center;
  min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 8px;
  background: #f3f0f8; color: var(--text-2);
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.rank-badge.r1 { background: #fbecd0; color: #a9781c; }
.rank-badge.r2 { background: #eae8f1; color: #6f6b85; }
.rank-badge.r3 { background: #f8e8dc; color: #a7714d; }
.class-cell { display: flex; align-items: center; gap: 9px; }
.class-avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700;
  background: var(--primary-soft); color: var(--primary);
}
.class-name { font-weight: 600; white-space: nowrap; }
.class-teacher { font-size: 11px; color: var(--text-3); white-space: nowrap; }
.grade-tag { display: inline-block; padding: 3px 9px; border-radius: 6px; background: #f4f1f9; color: var(--text-2); font-size: 11.5px; white-space: nowrap; }
.score-cell { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.score-num { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 34px; }
.score-num.low { color: var(--danger); }
.score-track { flex: 1; height: 6px; border-radius: 99px; background: #efeaf7; overflow: hidden; }
.score-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #9d72e2, #7c4dcb); transition: width .4s ease; }
.score-fill.low { background: linear-gradient(90deg, #eb8b8b, #d4505f); }
.action-button {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text-2);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
  white-space: nowrap;
}
.action-button .icon { width: 14px; height: 14px; }
.action-button:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.action-button.danger:hover { border-color: #eab9bf; color: var(--danger); background: var(--danger-soft); }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; font-size: 12px; color: var(--text-3); }
.empty-state { text-align: center; padding: 44px 16px; color: var(--text-3); font-size: 13px; background: var(--surface-soft); border: 1px dashed var(--border-strong); border-radius: 12px; margin-top: 12px; }
.deduct-value { color: var(--danger); font-weight: 600; }
.muted { color: var(--text-3); }
.reason-text { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Entry form ---------- */
.entry-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.field { margin-bottom: 20px; min-width: 0; }
.field > label, .field-label-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 9px; color: var(--text); }
.field label em { color: var(--accent); font-style: normal; margin-left: 2px; }
.field label .optional { font-size: 11px; font-weight: 400; color: var(--text-3); margin-left: 5px; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; }
.mini-actions { display: flex; align-items: center; gap: 6px; margin-bottom: 9px; }
.dot-sep { color: var(--border-strong); }
.link-button { border: none; background: transparent; color: var(--primary); font-size: 12px; font-weight: 600; padding: 0; }
.link-button:hover { text-decoration: underline; }
.field input[type="text"], .field input[type="date"], .field input[type="number"] { width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-row .field { margin-bottom: 20px; }

.class-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; }
.class-group { min-width: 0; }
.class-group-head { display: flex; align-items: center; justify-content: space-between; font-size: 11.5px; color: var(--text-3); margin-bottom: 7px; padding-left: 2px; }
.class-group-head button { border: none; background: transparent; color: var(--primary); font-size: 11px; padding: 0 2px; }
.class-group-head button:hover { text-decoration: underline; }
.class-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.class-chip {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text-2);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px; font-weight: 600;
  min-width: 48px; text-align: center;
  transition: all .16s ease;
}
.class-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.class-chip.selected { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 7px rgba(124, 77, 203, .22); }
.class-chip.selected:hover { background: var(--primary-dark); color: #fff; }

.category-picker { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.category-chip {
  border: 1px solid var(--border-strong);
  background: #fff;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
  font-size: 12.5px; font-weight: 600;
  color: var(--text-2);
  transition: all .16s ease;
}
.category-chip .cat-points { display: block; font-size: 10.5px; font-weight: 500; color: var(--text-3); margin-top: 2px; }
.category-chip:hover { border-color: var(--primary); color: var(--primary); }
.category-chip.selected { background: var(--primary-soft); border-color: var(--primary); color: var(--primary-dark); }
.category-chip.selected .cat-points { color: var(--primary); }

.point-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.point-presets { display: flex; gap: 6px; }
.point-preset {
  border: 1px solid var(--border-strong); background: #fff;
  border-radius: 8px; padding: 7px 11px; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  transition: all .16s ease;
}
.point-preset:hover { border-color: var(--danger); color: var(--danger); }
.point-preset.active { background: var(--danger-soft); border-color: #eeb9c0; color: var(--danger); }
.number-wrap { position: relative; display: flex; align-items: center; }
.number-wrap input { width: 92px; padding-right: 28px; font-variant-numeric: tabular-nums; font-weight: 600; }
.number-wrap span { position: absolute; right: 12px; font-size: 12px; color: var(--text-3); pointer-events: none; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 9px; padding: 9px 18px;
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-strong);
  background: #fff; color: var(--text-2);
  transition: all .18s ease;
  white-space: nowrap;
}
.button .icon { width: 16px; height: 16px; }
.button:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 3px 10px rgba(124, 77, 203, .22); }
.button.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.button.primary:active { transform: translateY(1px); }
.button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.button.danger:hover { background: #b93f4d; border-color: #b93f4d; color: #fff; }
.button.small { padding: 7px 12px; font-size: 12px; height: 36px; }
.button:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.side-panel { padding: 20px 18px; position: sticky; top: 20px; }
.preview-empty { text-align: center; padding: 36px 12px; color: var(--text-3); font-size: 12.5px; line-height: 1.8; }
.preview-empty .icon { width: 30px; height: 30px; color: #cbbde5; margin-bottom: 8px; }
.preview-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.preview-row:last-child { border-bottom: none; }
.preview-row .pr-label { color: var(--text-3); flex: none; }
.preview-row .pr-value { color: var(--text); font-weight: 600; text-align: right; word-break: break-all; }
.preview-classes { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.preview-classes span { background: var(--primary-soft); color: var(--primary-dark); border-radius: 6px; padding: 2px 7px; font-size: 11.5px; font-weight: 600; }
.preview-total { margin-top: 14px; padding: 13px; border-radius: 11px; background: var(--danger-soft); border: 1px solid #f6dadd; display: flex; align-items: center; justify-content: space-between; }
.preview-total span { font-size: 12px; color: #9d4b56; }
.preview-total strong { font-size: 20px; color: var(--danger); font-variant-numeric: tabular-nums; }
.preview-hint { margin-top: 12px; font-size: 11.5px; color: var(--text-3); line-height: 1.7; }

/* ---------- Detail view ---------- */
.detail-summary { display: flex; align-items: center; gap: 18px; padding: 12px 15px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: 11px; margin-bottom: 14px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.detail-summary strong { color: var(--text); font-size: 15px; font-variant-numeric: tabular-nums; }
.detail-summary .sep { width: 1px; height: 18px; background: var(--border-strong); }
.detail-summary .neg { color: var(--danger); }
.class-info { display: flex; align-items: center; gap: 14px; padding: 13px 16px; border: 1px solid var(--border); border-radius: 11px; margin-bottom: 14px; background: linear-gradient(100deg, #faf6ff, #fff); flex-wrap: wrap; }
.class-info .ci-title { font-size: 15px; font-weight: 700; }
.class-info .ci-sub { font-size: 11.5px; color: var(--text-3); }
.class-info .ci-spacer { flex: 1; }
.class-info .ci-teacher { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); }
.class-info .ci-teacher input { height: 32px; width: 130px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 10px; font-size: 12.5px; background: #fff; }
.class-info .ci-stat { text-align: center; padding: 0 12px; border-left: 1px solid var(--border); }
.class-info .ci-stat b { display: block; font-size: 17px; font-variant-numeric: tabular-nums; line-height: 1.3; }
.class-info .ci-stat span { font-size: 11px; color: var(--text-3); }
.chip-cat { display: inline-block; padding: 3px 9px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-dark); font-size: 11.5px; white-space: nowrap; }
.date-cell { font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(35, 22, 58, .42); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 20px; animation: fadeIn .18s ease; }
.modal { width: min(520px, 100%); max-height: min(86vh, 760px); overflow: auto; background: #fff; border-radius: 18px; box-shadow: 0 24px 70px rgba(35, 20, 65, .28); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16.5px; font-weight: 700; }
.modal-head .icon-button { border-color: var(--border-strong); background: #fff; color: var(--text-2); width: 32px; height: 32px; }
.modal-head .icon-button:hover { background: var(--surface-soft); color: var(--text); }
.modal-body { padding: 20px 22px 24px; }
.modal-section { margin-bottom: 22px; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section h3 { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.modal-section p { font-size: 12px; color: var(--text-3); line-height: 1.7; margin-bottom: 11px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 11px; }
.setting-row label { font-size: 13px; font-weight: 600; }
.setting-row small { display: block; font-size: 11.5px; color: var(--text-3); font-weight: 400; }
.setting-row input[type="number"] { width: 90px; height: 34px; border: 1px solid var(--border-strong); border-radius: 8px; padding: 0 10px; font-variant-numeric: tabular-nums; text-align: center; }
.danger-zone { border: 1px solid #f1d4d8; background: #fef9f9; border-radius: 11px; padding: 14px; }
.danger-zone h3 { color: var(--danger); }
.confirm-box { text-align: center; padding: 6px 0 2px; }
.confirm-box .confirm-icon { width: 46px; height: 46px; border-radius: 14px; background: var(--danger-soft); color: var(--danger); display: grid; place-items: center; margin: 0 auto 12px; }
.confirm-box .confirm-icon .icon { width: 23px; height: 23px; }
.confirm-box h3 { font-size: 16px; margin-bottom: 6px; }
.confirm-box p { font-size: 13px; color: var(--text-2); margin-bottom: 20px; }
.confirm-box .modal-actions { justify-content: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translate(-50%, 16px);
  background: #2c2140; color: #fff;
  padding: 11px 20px; border-radius: 11px;
  font-size: 13px; font-weight: 500;
  box-shadow: 0 12px 34px rgba(30, 18, 55, .28);
  opacity: 0; pointer-events: none; z-index: 80;
  transition: opacity .22s ease, transform .22s ease;
  display: flex; align-items: center; gap: 9px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .icon { width: 16px; height: 16px; color: #9ae0bf; }
.toast.error .icon { color: #ff9aa5; }

.footer { text-align: center; padding: 18px 20px 26px; color: var(--text-3); font-size: 11.5px; }
.footer-dot { margin: 0 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .entry-layout { grid-template-columns: 1fr; }
  .side-panel { position: static; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grade-overview { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .category-picker { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .topbar-inner { padding: 16px; }
  .brand-mark { width: 44px; height: 44px; border-radius: 12px; }
  .brand-mark svg { width: 29px; height: 29px; }
  .brand-copy h1 { font-size: 16px; }
  .brand-copy p { font-size: 11px; letter-spacing: .5px; }
  .today-chip { display: none; }
  .container { padding: 16px 14px 30px; }
  .stats-grid { gap: 10px; }
  .stat-card { padding: 13px; }
  .stat-value { font-size: 23px; }
  .stat-icon { width: 32px; height: 32px; }
  .tabbar { gap: 2px; padding: 4px; }
  .tab { padding: 8px 10px; font-size: 12.5px; gap: 5px; }
  .tab .icon { width: 14px; height: 14px; }
  .text-button span { display: none; }
  .text-button { padding: 8px 10px; }
  .panel { padding: 16px 14px; }
  .panel-head { gap: 12px; }
  .filters { width: 100%; }
  .filters .select-wrap { flex: 1; min-width: 110px; }
  .filters .select-wrap select { width: 100%; }
  .filters .search-wrap { flex: 1 1 100%; }
  .filters .search-wrap input { width: 100%; }
  .grade-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .podium { gap: 8px; }
  .podium-card { padding: 12px 10px; }
  .podium-card.first { padding-top: 16px; }
  .pc-class { font-size: 14px; }
  .pc-score { font-size: 21px; }
  .pc-deduct { display: none; }
  .class-picker { grid-template-columns: 1fr; }
  .category-picker { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .detail-summary { gap: 10px; }
  .class-info .ci-stat { border-left: none; padding: 0 8px; }
  .demo-banner { flex-wrap: wrap; }
  .demo-banner span { flex-basis: calc(100% - 30px); }
}
@media (max-width: 400px) {
  .tab span { display: none; }
  .tab { padding: 8px 12px; }
  .tab .icon { width: 18px; height: 18px; }
  .podium { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  body { background: #fff; }
  .topbar { background: #7c4dcb !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .tabbar, .topbar-actions, .footer, .demo-banner, .form-actions, .filters, .col-action, .button, .text-button, .side-panel { display: none !important; }
  .view:not(.active) { display: none !important; }
  .view.active { display: block !important; }
  .panel { box-shadow: none; border: none; padding: 0; }
  .table-wrap { overflow: visible; }
  .data-table { min-width: 0; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}


/* ---------- 云端同步状态 ---------- */
.sync-chip { display:inline-flex; align-items:center; gap:7px; height:32px; padding:0 12px;
  border:1px solid var(--border-strong); border-radius:999px; background:#fff;
  font-size:12px; font-weight:600; color:#6b6478; white-space:nowrap; }
.sync-dot { width:8px; height:8px; border-radius:50%; background:#c9c2d8; flex:none; }
.sync-chip.ok .sync-dot { background:#22a06b; box-shadow:0 0 0 3px rgba(34,160,107,.14); }
.sync-chip.ok { color:#1c7a54; border-color:#bfe8d3; background:#f4fcf8; }
.sync-chip.syncing .sync-dot { background:#d99a17; animation:syncPulse 1.1s infinite; }
.sync-chip.syncing { color:#96660b; border-color:#f0dfb4; background:#fffaf0; }
.sync-chip.offline .sync-dot { background:#d94a4a; box-shadow:0 0 0 3px rgba(217,74,74,.14); }
.sync-chip.offline { color:#a62f2f; border-color:#f2c8c8; background:#fff6f6; }
@keyframes syncPulse { 0%,100% { opacity:1 } 50% { opacity:.35 } }
.sync-alert { display:flex; align-items:center; gap:10px; margin:0 0 16px; padding:12px 16px;
  border:1px solid #f2c8c8; background:#fff6f6; color:#a62f2f; border-radius:12px; font-size:13px; }
.sync-alert[hidden] { display:none; }
.sync-alert .icon { width:18px; height:18px; flex:none; }
.sync-alert span { flex:1; line-height:1.5; }
.sync-alert button { border:1px solid #e3a7a7; background:#fff; color:#a62f2f;
  border-radius:8px; padding:5px 12px; font-size:12px; cursor:pointer; white-space:nowrap; }
@media (max-width:720px) { .sync-chip { display:none; } }

/* ---------- 进入口令层（仅积分系统） ---------- */
body.gate-locked { overflow: hidden; }
.entry-gate {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; overflow: auto;
  background: radial-gradient(1200px 600px at 50% -10%, #a884e6 0%, #7c4dcb 45%, #5c34a3 100%);
}
.entry-gate[hidden] { display: none !important; }
.gate-card {
  width: 100%; max-width: 420px; padding: 34px 34px 28px;
  border-radius: 22px; background: var(--surface);
  box-shadow: 0 24px 70px rgba(38, 16, 78, .3);
  text-align: center;
}
.gate-mark {
  width: 62px; height: 62px; margin: 0 auto 16px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, #8e5ed8, #6a3bb6);
  box-shadow: 0 8px 20px rgba(124, 77, 203, .28);
}
.gate-mark svg { width: 42px; height: 42px; }
.gate-kicker { display: block; font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--primary); }
.gate-card h2 { margin: 8px 0 4px; font-size: 22px; line-height: 1.35; }
.gate-sub { margin: 0 0 20px; font-size: 13px; color: var(--text-3); }
.gate-notice {
  text-align: left; padding: 12px 14px; margin-bottom: 20px;
  border: 1px solid #f0dfb4; border-radius: 12px;
  background: var(--gold-soft); color: #87621a; font-size: 12.5px; line-height: 1.65;
}
.gate-notice strong { display: block; font-size: 13px; color: #6e4d0c; margin-bottom: 2px; }
#gateForm { text-align: left; }
#gateForm > label:first-child { display: block; font-size: 13px; font-weight: 600; margin-bottom: 7px; }
#gatePass {
  width: 100%; height: 46px; padding: 0 14px; font-size: 16px;
  border: 1px solid var(--border-strong); border-radius: 11px;
  background: var(--surface-soft); color: var(--text); outline: none;
}
#gatePass:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124, 77, 203, .14); background: #fff; }
.gate-remember {
  display: flex; align-items: flex-start; gap: 8px; margin: 13px 0 0;
  font-size: 12.5px; color: var(--text-2); cursor: pointer; line-height: 1.5;
}
.gate-remember input { margin: 2px 0 0; flex: none; accent-color: var(--primary); }
.gate-error { margin: 12px 0 0; font-size: 12.5px; color: var(--danger); font-weight: 600; }
.gate-error[hidden] { display: none; }
.gate-submit {
  width: 100%; height: 46px; margin-top: 18px; border: 0; border-radius: 11px;
  background: var(--primary); color: #fff; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: background .15s, transform .15s;
}
.gate-submit:hover { background: var(--primary-dark); }
.gate-submit:active { transform: translateY(1px); }
.gate-footer {
  margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--text-3); line-height: 1.8;
}
.gate-footer a { color: var(--primary); font-weight: 700; text-decoration: none; }
.gate-footer a:hover { text-decoration: underline; }
@media (max-width: 480px) {
  .entry-gate { padding: 16px; }
  .gate-card { padding: 26px 22px 22px; border-radius: 18px; }
}
@media print { .entry-gate { display: none !important; } }
