/* =============================================================
   在线选课系统 样式表
   设计原则：简洁、清晰、反馈及时；桌面与移动端响应式；
   遵循 WCAG 2.1 AA：可键盘操作、焦点态清晰、状态不以颜色为唯一表达。
   ============================================================= */

:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #101828;
  --text-2: #475467;
  --muted: #98a2b3;

  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;

  --green: #079455;
  --green-soft: #ecfdf3;
  --amber: #b54708;
  --amber-soft: #fffaeb;
  --red: #b42318;
  --red-soft: #fef3f2;
  --purple: #6941c6;
  --purple-soft: #f4f3ff;
  --gray-soft: #f2f4f7;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.16);
  --topbar-h: 58px;
  --sidebar-w: 218px;
}

* { box-sizing: border-box; }

/* hidden 属性必须优先于类选择器：
   [hidden] 的 UA 样式是优先级极低的 display:none，会被 .field / .layout / .login-page
   这类设置了 display 的类规则覆盖，导致"隐藏"失效（登录页与应用框架同时显示、
   验证码区一直可见却从未加载题目）。此处统一兜底。 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.35; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: var(--primary); text-decoration: none; }

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------------- 通用组件 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--gray-soft); border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #912018; border-color: #912018; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--gray-soft); border-color: transparent; }

.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; height: 40px; font-size: 14px; }

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-size: 16px;
  cursor: pointer;
}
.icon-btn:hover { background: var(--gray-soft); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before { content: "●"; font-size: 8px; line-height: 1; }
.badge.no-dot::before { content: none; }

.badge-green { background: var(--green-soft); color: var(--green); border-color: #abefc6; }
.badge-blue { background: var(--primary-soft); color: var(--primary-dark); border-color: #c7d7fe; }
.badge-amber { background: var(--amber-soft); color: var(--amber); border-color: #fedf89; }
.badge-red { background: var(--red-soft); color: var(--red); border-color: #fecdca; }
.badge-purple { background: var(--purple-soft); color: var(--purple); border-color: #d9d6fe; }
.badge-gray { background: var(--gray-soft); color: var(--text-2); border-color: var(--border); }

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 4px;
  background: var(--gray-soft);
  color: var(--text-2);
  font-size: 12px;
  border: 1px solid var(--border);
}

/* ---------------- 登录页 ---------------- */

.login-page {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  min-height: 100vh;
}

.login-brand {
  background: linear-gradient(150deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 56px;
  position: relative;
  overflow: hidden;
}
.login-brand::after {
  content: "";
  position: absolute;
  right: -120px; bottom: -160px;
  width: 460px; height: 460px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.login-brand-inner { position: relative; max-width: 460px; }
.brand-mark {
  width: 52px; height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .35);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
  margin-bottom: 22px;
}
.login-brand h1 { font-size: 30px; letter-spacing: .5px; }
.brand-sub { margin-top: 10px; color: rgba(255, 255, 255, .82); font-size: 15px; }
.brand-points { margin-top: 34px; display: grid; gap: 14px; }
.brand-points li { color: rgba(255, 255, 255, .8); font-size: 13px; padding-left: 16px; position: relative; }
.brand-points li::before {
  content: ""; position: absolute; left: 0; top: 8px;
  width: 6px; height: 6px; border-radius: 50%; background: #93c5fd;
}
.brand-points li span {
  display: inline-block; min-width: 70px; margin-right: 8px;
  color: #fff; font-weight: 600;
}

.login-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.login-form { width: 100%; max-width: 372px; }
.login-form h2 { font-size: 22px; }
.login-tip { margin-top: 6px; color: var(--text-2); font-size: 13px; }

.field { display: block; margin-top: 18px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-2); }
.field input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; color: var(--text);
  background: #fff;
}
.field input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }

.captcha-row { display: flex; gap: 10px; }
.captcha-question {
  flex: none; min-width: 120px; height: 40px; padding: 0 12px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--panel-2); color: var(--text-2); font-size: 14px; cursor: pointer;
  font-family: inherit;
}

.login-error {
  margin-top: 14px; padding: 9px 12px;
  background: var(--red-soft); border: 1px solid #fecdca; border-radius: var(--radius-sm);
  color: var(--red); font-size: 13px;
}

.login-form .btn-block { margin-top: 22px; }

.demo-accounts { margin-top: 26px; padding-top: 18px; border-top: 1px dashed var(--border); }
.demo-title { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.demo-list { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-list button {
  height: 28px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px;
  background: #fff; color: var(--text-2); font-size: 12px; cursor: pointer; font-family: inherit;
}
.demo-list button:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ---------------- 主布局 ---------------- */

.layout { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  flex: none;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  z-index: 30;
}
.menu-toggle { display: none; }
.logo { display: flex; align-items: center; gap: 9px; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
}
.logo-text { font-weight: 600; font-size: 15px; }

.term-chip {
  margin-left: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 12px;
  border: 1px solid #c7d7fe;
}

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.badge-dot {
  position: absolute; top: 2px; right: 0;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--red); color: #fff;
  font-size: 10px; line-height: 16px; text-align: center; font-weight: 600;
}

.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; }
.user-meta strong { font-size: 13px; font-weight: 600; }
.user-meta em { font-style: normal; font-size: 11px; color: var(--muted); }

.body { flex: 1; display: flex; min-height: 0; }

.sidebar {
  flex: none; width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 12px 10px;
  overflow-y: auto;
}
.side-group-title {
  padding: 12px 10px 6px;
  font-size: 11px; color: var(--muted); letter-spacing: .5px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  width: 100%; height: 38px; padding: 0 11px;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2);
  font-size: 13.5px; font-family: inherit; text-align: left; cursor: pointer;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--gray-soft); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.nav-item .ni { width: 18px; text-align: center; font-size: 15px; }
.nav-item .ni-count {
  margin-left: auto; font-size: 11px; color: var(--muted);
  background: var(--gray-soft); border-radius: 999px; padding: 1px 7px;
}
.nav-item.active .ni-count { background: #fff; color: var(--primary-dark); }

.side-foot { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--border); }
.side-foot .sf-title { font-size: 11px; color: var(--muted); }
.side-foot .sf-value { font-size: 12px; color: var(--text-2); margin-top: 4px; }

.content { flex: 1; min-width: 0; padding: 20px; overflow-y: auto; }

/* ---------------- 页面头部 ---------------- */

.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { font-size: 19px; }
.page-head .sub { margin-top: 5px; color: var(--text-2); font-size: 13px; }
.page-head .head-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; }
.card-head .head-actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--text-2); }
.stat .value { margin-top: 6px; font-size: 24px; font-weight: 600; letter-spacing: -.4px; }
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat .hint { margin-top: 4px; font-size: 12px; color: var(--muted); }

/* ---------------- 表单 ---------------- */

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.toolbar .grow { flex: 1; min-width: 180px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

input[type="text"], input[type="password"], input[type="number"], input[type="datetime-local"],
input[type="date"], select, textarea {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; color: var(--text); background: #fff;
}
textarea { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; line-height: 1.6; }
select { cursor: pointer; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft);
}
.field-inline { display: flex; flex-direction: column; gap: 5px; }
.field-inline > span { font-size: 12.5px; color: var(--text-2); }
.checkbox { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.checkbox input { width: auto; height: auto; }

/* ---------------- 表格 ---------------- */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; vertical-align: middle; }
table.data thead th {
  background: var(--panel-2); color: var(--text-2); font-weight: 500; font-size: 12.5px;
  border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0;
}
table.data tbody tr { border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: #fafbfc; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .course-name { font-weight: 600; }
table.data .course-code { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 6px; }
table.data .cell-sub { color: var(--text-2); font-size: 12px; }
table.data .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.empty { padding: 46px 20px; text-align: center; color: var(--muted); }
.empty .empty-icon { font-size: 28px; }
.empty p { margin-top: 8px; font-size: 13px; }

.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.pager .page-info { font-size: 12.5px; color: var(--text-2); }
.pager .spacer { margin-left: auto; }

/* ---------------- 课程卡片（学生选课中心） ---------------- */

.course-list { display: grid; gap: 12px; padding: 16px; }
.course-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; background: #fff;
  display: grid; grid-template-columns: 1fr auto; gap: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.course-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.course-card.is-selected { border-left: 3px solid var(--primary); }
.course-card.is-full { background: #fcfcfd; }

.cc-title { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.cc-title .name { font-size: 15px; font-weight: 600; }
.cc-title .code { font-size: 12px; color: var(--muted); }
.cc-meta { margin-top: 7px; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.cc-meta .m { display: inline-flex; align-items: center; gap: 5px; }
.cc-sched { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.cc-sched .s {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 2px 8px; font-size: 12px; color: var(--text-2);
}
.cc-bar { margin-top: 10px; display: flex; align-items: center; gap: 10px; }
.progress { flex: 1; max-width: 240px; height: 6px; border-radius: 999px; background: var(--gray-soft); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.progress.high i { background: #f04438; }
.progress.mid i { background: #f79009; }
.progress.low i { background: #12b76a; }
.cc-count { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.cc-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 10px; min-width: 132px; }
.cc-side .badges { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.cc-reasons { margin-top: 9px; display: grid; gap: 4px; }
.cc-reason { font-size: 12px; color: var(--amber); display: flex; gap: 6px; align-items: flex-start; }
.cc-reason .ic { flex: none; }

/* ---------------- 课表 ---------------- */

.timetable { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }
.timetable th, .timetable td { border: 1px solid var(--border); padding: 0; }
.timetable thead th { background: var(--panel-2); padding: 9px 6px; font-weight: 500; color: var(--text-2); }
.timetable tbody th {
  width: 78px; background: var(--panel-2); padding: 6px; color: var(--text-2);
  font-weight: 400; text-align: center; font-size: 12px; line-height: 1.35;
}
.timetable tbody th .p-time { color: var(--muted); font-size: 11px; }
.timetable tbody th.p-cell .p-no { display: block; }
.timetable tbody th.band {
  width: 40px; background: #eef2f7; color: var(--text); font-weight: 600;
  vertical-align: middle; letter-spacing: 1px;
}
.timetable tbody th.band .band-t { writing-mode: vertical-rl; text-orientation: upright; letter-spacing: 3px; }

/* 课时表（选课规则页） */
.pt-wrap { max-width: 520px; }
.period-table td { text-align: center; }
.period-table td.pt-band { background: var(--panel-2); font-weight: 600; vertical-align: middle; letter-spacing: 2px; }
.period-table td.pt-group { background: var(--panel-2); font-weight: 600; vertical-align: middle; }
.period-table td.pt-no { color: var(--text-2); }
.period-table td.pt-time { font-variant-numeric: tabular-nums; }
.timetable td { height: 62px; vertical-align: top; position: relative; }
.timetable td.empty-cell { background: repeating-linear-gradient(45deg, #fbfcfd, #fbfcfd 6px, #f7f9fb 6px, #f7f9fb 12px); }
.timetable td.conflict-cell { background: var(--red-soft); }
.timetable .slot {
  height: 100%; padding: 7px 8px; border-left: 3px solid var(--primary);
  background: linear-gradient(180deg, #f5f8ff, #eef4ff);
  display: flex; flex-direction: column; gap: 3px;
}
.timetable .slot .n { font-weight: 600; font-size: 12.5px; color: #1e3a8a; }
.timetable .slot .t, .timetable .slot .p { color: var(--text-2); font-size: 11.5px; }
.timetable .slot.c1 { border-left-color: #2563eb; background: linear-gradient(180deg,#f5f8ff,#eaf1ff); }
.timetable .slot.c2 { border-left-color: #079455; background: linear-gradient(180deg,#f2fdf7,#e7f9f0); }
.timetable .slot.c3 { border-left-color: #b54708; background: linear-gradient(180deg,#fffaf0,#fef3e2); }
.timetable .slot.c4 { border-left-color: #6941c6; background: linear-gradient(180deg,#f9f8ff,#f1efff); }
.timetable .slot.c5 { border-left-color: #0ea5e9; background: linear-gradient(180deg,#f2fafd,#e6f5fb); }
.timetable .slot.c6 { border-left-color: #db2777; background: linear-gradient(180deg,#fdf4f9,#fbe9f3); }

/* ---------------- 进度条 / 类别学分 ---------------- */

.cat-credit { display: grid; gap: 10px; }
.cat-credit-item .top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.cat-credit-item .bar { height: 7px; border-radius: 999px; background: var(--gray-soft); overflow: hidden; }
.cat-credit-item .bar i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.cat-credit-item .bar i.ok { background: var(--green); }

/* ---------------- 描述列表 ---------------- */

.desc { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; font-size: 13px; }
.desc dt { color: var(--text-2); }
.desc dd { margin: 0; }

.kv-list { display: grid; gap: 10px; }
.kv-list .kv { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
.kv-list .kv:last-child { border-bottom: none; padding-bottom: 0; }
.kv-list .kv .k { color: var(--text-2); }
.kv-list .kv .v { font-weight: 600; text-align: right; }

/* ---------------- 时间线 ---------------- */

.timeline { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 22px 1fr; gap: 10px; }
.tl-item .dot-wrap { display: flex; flex-direction: column; align-items: center; }
.tl-item .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); margin-top: 5px; flex: none; }
.tl-item .line { flex: 1; width: 1px; background: var(--border); }
.tl-item:last-child .line { display: none; }
.tl-item .tl-body { padding-bottom: 16px; }
.tl-item .tl-title { font-size: 13.5px; font-weight: 600; }
.tl-item .tl-time { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tl-item .tl-text { font-size: 12.5px; color: var(--text-2); margin-top: 4px; }

/* ---------------- 通知 ---------------- */

.notice-item { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.notice-item:last-child { border-bottom: none; }
.notice-item.unread { background: #f8fbff; }
.notice-item .n-body { flex: 1; min-width: 0; }
.notice-item .n-title { font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.notice-item .n-text { margin-top: 4px; font-size: 12.5px; color: var(--text-2); }
.notice-item .n-time { margin-top: 6px; font-size: 12px; color: var(--muted); }
.notice-item .n-side { display: flex; align-items: center; gap: 8px; }

/* ---------------- 模态框 / 抽屉 ---------------- */

.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .48);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100;
  animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 620px; max-height: 88vh; display: flex; flex-direction: column;
  background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15.5px; }
.modal-head .close { margin-left: auto; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 13px 18px; border-top: 1px solid var(--border); background: var(--panel-2); }

/* ---------------- Toast ---------------- */

.toast-root {
  position: fixed; top: 68px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center;
  pointer-events: none;
}
.toast {
  min-width: 220px; max-width: 520px;
  padding: 10px 16px; border-radius: var(--radius-sm);
  background: #101828; color: #fff; font-size: 13px;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: flex-start; gap: 9px;
  animation: toastIn .18s ease-out;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.toast.success { background: #054f31; }
.toast.error { background: #7a271a; }
.toast.warn { background: #7a2e0e; }
.toast .t-text { flex: 1; }
.toast .t-detail { margin-top: 4px; font-size: 12px; opacity: .85; }

/* ---------------- 提示条 ---------------- */

.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert .a-ic { flex: none; font-size: 14px; }
.alert-info { background: var(--primary-soft); border-color: #c7d7fe; color: #1e3a8a; }
.alert-warn { background: var(--amber-soft); border-color: #fedf89; color: #93370d; }
.alert-error { background: var(--red-soft); border-color: #fecdca; color: var(--red); }
.alert-success { background: var(--green-soft); border-color: #abefc6; color: #05603a; }

.loading { padding: 44px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner {
  width: 18px; height: 18px; margin: 0 auto 10px;
  border: 2px solid var(--border-strong); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.section-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.sep { height: 1px; background: var(--border); margin: 14px 0; }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1024px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}

@media (max-width: 860px) {
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--topbar-h); bottom: 0; left: 0; z-index: 40;
    transform: translateX(-100%); transition: transform .2s ease-out;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .content { padding: 14px; }
  .course-card { grid-template-columns: 1fr; }
  .cc-side { align-items: stretch; }
  .cc-side .badges { flex-direction: row; align-items: center; }
  .cc-side .btn { width: 100%; }
  .logo-text, .term-chip { display: none; }
  .user-meta { display: none; }
  .modal { max-height: 92vh; }
}

@media (max-width: 600px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .page-head .head-actions { width: 100%; }
  table.data th, table.data td { padding: 8px 9px; }
}

/* 打印视图（课表导出） */
@media print {
  .topbar, .sidebar, .page-head .head-actions, .no-print { display: none !important; }
  .content { padding: 0; overflow: visible; }
  .layout, .body { height: auto; display: block; }
  .card { box-shadow: none; border: none; }
}
