:root {
  --bg: #f3f6fa;
  --card: #ffffff;
  --border: #e3e9f0;
  --text: #26313d;
  --muted: #6b7a8c;
  --primary: #2f7dd1;
  --primary-dark: #2567b1;
  --primary-soft: #e8f1fb;
  --accent: #e88b1e;
  --accent-soft: #fdf0dd;
  --green: #23a26d;
  --green-soft: #e4f6ee;
  --red: #d64545;
  --red-soft: #fbeaea;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(20, 40, 70, 0.06);
  --shadow-lg: 0 8px 28px rgba(20, 40, 70, 0.12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

.hidden { display: none !important; }

/* ---------- 顶部深色标题栏 ---------- */
.topbar {
  background: linear-gradient(120deg, #1b2a3a 0%, #24364a 55%, #2d4158 100%);
  color: #fff;
  padding: 16px 24px;
}
.topbar-inner { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 8px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
}
.brand-text h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: .5px; }
.brand-text p { margin: 4px 0 0; font-size: 12.5px; opacity: .8; }
.header-meta { font-size: 13px; background: rgba(255,255,255,.12); padding: 6px 12px; border-radius: 8px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right .btn-outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.6); }
.topbar-right .btn-outline:hover { color: #fff; border-color: #fff; }

/* ---------- 主体 ---------- */
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 24px 20px 40px; }

.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px;
  padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all .15s ease; line-height: 1.4; user-select: none;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { background: #fff; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-soft); }
.btn-ghost { background: #fff; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { color: var(--primary); border-color: var(--primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.94); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- 登录 ---------- */
.login-wrap { display: flex; justify-content: center; margin-top: 12px; }
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px 26px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 13px; text-align: left;
  width: 100%; max-width: 380px;
}
.login-icon {
  width: 52px; height: 52px; margin: 0 auto 4px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700;
}
.login-icon.icon-admin { background: var(--accent-soft); color: var(--accent); }
.login-card h2 { margin: 0; font-size: 18px; text-align: center; }
.login-desc { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.6; text-align: center; }
.login-foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 22px; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 600; }
.field input, .field select, .week-select {
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  font-size: 14.5px; outline: none; transition: border-color .15s ease, box-shadow .15s ease; background: #fff; color: var(--text);
}
.field input:focus, .field select:focus, .week-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,125,209,.14); }
.week-select { padding: 8px 10px; font-size: 14px; }
.week-picker { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.week-label { font-size: 13px; color: var(--muted); font-weight: 600; }

/* ---------- 页头 ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .page-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title h2 { margin: 0; font-size: 21px; }
.month-nav { display: flex; align-items: center; gap: 8px; }
/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 20px;
  background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 600;
}
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-red { background: var(--red-soft); color: var(--red); }

/* ---------- 提示条 ---------- */
.notice {
  background: var(--accent-soft); border: 1px solid #f3d9a8; color: #8a5a0b;
  border-radius: var(--radius); padding: 13px 16px; font-size: 14px; margin-bottom: 18px;
  line-height: 1.6;
}
.notice-danger { background: var(--red-soft); border-color: #f0c2c2; color: #962525; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px;
}
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 13px; }
.card-title h3 { margin: 0; font-size: 16px; }
.card-title .hint { font-size: 12.5px; color: var(--muted); }

/* ---------- 状态与名额 ---------- */
.ver-status { font-size: 15px; font-weight: 600; margin-bottom: 12px; }
.quota-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.quota-chip {
  padding: 5px 12px; border-radius: 8px; background: #f7fafc;
  border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text);
}
.quota-chip.full { background: var(--red-soft); color: var(--red); border-color: #f0c2c2; }
.dist-line { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.dist-status { font-size: 13.5px; margin-bottom: 14px; font-weight: 600; }
.status-ok { color: var(--green); }
.status-warn { color: var(--accent); }
.status-err { color: var(--red); }
.quota-list { display: flex; flex-direction: column; gap: 10px; }
.quota-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.quota-bar { flex: 1; height: 10px; background: #eef2f7; border-radius: 6px; overflow: hidden; }
.quota-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width .2s; }

/* ---------- 版本卡片 ---------- */
.version-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.version-card {
  background: var(--card); border: 2px solid var(--border); border-radius: var(--radius);
  padding: 16px 16px 14px; box-shadow: var(--shadow); position: relative; transition: border-color .15s ease;
}
.version-card.scheme-a { border-top: 4px solid var(--primary); }
.version-card.scheme-b { border-top: 4px solid var(--accent); }
.version-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.version-card h4 { margin: 0 0 10px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.version-tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.version-tag.tag-a { background: var(--primary); color: #fff; }
.version-tag.tag-b { background: var(--accent); color: #fff; }
.version-slots { font-size: 13px; color: var(--muted); line-height: 1.8; margin: 0 0 12px; }
.version-slots li { margin-left: 18px; }
.version-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.capacity { font-size: 13px; color: var(--muted); font-weight: 600; }
.capacity b { color: var(--text); font-size: 15px; }
.capacity.full { color: var(--red); }

/* ---------- 资源选择 ---------- */
.sel-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 18px; }
.sel-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: #fbfcfe; }
.sel-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.sel-head .time { font-weight: 700; font-size: 15px; }
.sel-head .type { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 12px; }
.type-outdoor { background: var(--green-soft); color: var(--green); }
.type-room { background: var(--primary-soft); color: var(--primary); }
.type-sport { background: var(--accent-soft); color: var(--accent); }
.sel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.res-chip {
  border: 1.5px solid var(--border); background: #fff; border-radius: 8px;
  padding: 10px 6px; text-align: center; cursor: pointer; position: relative;
  transition: all .13s ease; user-select: none;
}
.res-chip .name { font-size: 14px; font-weight: 600; display: block; }
.res-chip .count { font-size: 12px; color: var(--muted); display: block; margin-top: 3px; }
.res-chip:hover:not(.occupied):not(.selected) { border-color: var(--primary); background: var(--primary-soft); }
.res-chip.occupied { background: #f2f4f7; border-color: var(--border); opacity: .55; cursor: not-allowed; }
.res-chip.occupied .name { color: var(--muted); }
.res-chip.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(47,125,209,.14); }
.res-chip.selected .name { color: var(--primary); }
.res-chip.sport-full .count { color: var(--red); font-weight: 700; }

/* ---------- 班级页脚 ---------- */
.class-foot { text-align: right; font-size: 12.5px; color: var(--muted); padding: 4px 2px 20px; }

/* ---------- 提交栏 ---------- */
.submit-bar {
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 16px;
  background: var(--primary-soft); border: 1px solid var(--primary); border-radius: var(--radius);
}
.submit-msg { font-weight: 600; color: var(--primary); }

/* ---------- 已提交只读 ---------- */
.notice-lock { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.locked-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.locked-list li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: #fafbfc; }
.locked-list .time { font-weight: 700; font-size: 13.5px; min-width: 96px; }
.locked-list .locked-res { margin-left: auto; font-weight: 600; color: var(--text); }
.locked-list .locked-res:empty::after { content: '未选择'; color: var(--muted); font-weight: 400; }

/* ---------- 管理员修改版本选择 ---------- */
.ver-pick-row { display: flex; gap: 10px; flex-wrap: wrap; }
.ver-pick {
  border: 1.5px solid var(--border); background: #fff; border-radius: 8px;
  padding: 10px 16px; font-size: 14px; font-weight: 700; cursor: pointer; transition: all .13s ease;
}
.ver-pick:hover { border-color: var(--primary); color: var(--primary); }
.ver-pick.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ---------- 个人中心 ---------- */
.uc-info { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 16px; }
.uc-info > div { display: flex; flex-direction: column; gap: 3px; }
.uc-label { font-size: 12px; color: var(--muted); }
.uc-pwd { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 14px; }
.uc-pwd h4 { margin: 0 0 2px; font-size: 15px; }
.modal-actions .spacer { flex: 1; }
.modal-box h4 { margin: 0 0 10px; font-size: 17px; }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.tab {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  border-radius: 8px; padding: 8px 18px; font-size: 14px; font-weight: 600; cursor: pointer; transition: all .13s ease;
}
.tab:hover { color: var(--primary); border-color: var(--primary); }
.tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 两栏布局 ---------- */
.two-col { display: grid; grid-template-columns: 1.2fr 1fr; gap: 18px; align-items: start; }

/* ---------- 方案设置 ---------- */
.scheme-presets { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.preset-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 8px; padding: 8px 14px;
  font-size: 13.5px; cursor: pointer; transition: all .13s ease; font-weight: 600;
}
.preset-btn:hover { border-color: var(--primary); color: var(--primary); }
.preset-btn.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.grade-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  border: 1px solid var(--border); border-radius: 8px; padding: 13px 16px; margin-bottom: 10px; background: #fff; flex-wrap: wrap;
}
.grade-row .gname { font-weight: 700; font-size: 15px; min-width: 64px; }
.grade-row .gstatus { font-size: 13px; color: var(--muted); }
.radio-group { display: flex; gap: 8px; }
.radio-btn {
  padding: 7px 18px; border-radius: 8px; border: 1.5px solid var(--border); background: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all .13s ease;
}
.radio-btn:hover { border-color: var(--primary); }
.radio-btn.sel-a { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.radio-btn.sel-b { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.radio-btn.sel-n { color: var(--muted); }

/* ---------- 汇总表 ---------- */
.table-scroll { overflow-x: auto; }
table.summary { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 660px; }
table.summary th, table.summary td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; vertical-align: top; }
table.summary th { background: #f7fafc; font-weight: 600; color: var(--muted); white-space: nowrap; }
table.summary tr:hover td { background: #fafcfe; }
table.summary .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
.sel-text { color: var(--muted); font-size: 12.5px; line-height: 1.7; }
.ver-badge { display: inline-block; padding: 2px 9px; border-radius: 6px; font-weight: 700; font-size: 12px; }
.ver-a { background: var(--primary-soft); color: var(--primary); }
.ver-b { background: var(--accent-soft); color: var(--accent); }
.ver-none { color: var(--muted); }
.tag-incomplete {
  background: var(--red-soft); color: var(--red); font-size: 12px; padding: 2px 8px;
  border-radius: 6px; margin-left: 6px; font-weight: 600; white-space: nowrap;
}

/* ---------- 入口码 ---------- */
.code-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.code-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; background: #fff;
}
.code-item .cname { font-weight: 600; font-size: 14px; }
.code-item .ccode { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; color: var(--primary); letter-spacing: 1px; }

/* ---------- 修改记录 ---------- */
.rec-grid {
  display: grid; grid-template-columns: 150px 86px 76px 1fr; gap: 6px 12px;
  padding: 9px 2px; border-bottom: 1px solid var(--border); font-size: 13.5px; align-items: baseline;
}
.rec-grid:last-child { border-bottom: none; }
.rec-head { font-weight: 600; color: var(--muted); font-size: 12.5px; }
.rec-time { color: var(--muted); font-size: 12.5px; font-family: ui-monospace, Menlo, monospace; white-space: nowrap; }
.rec-detail { color: var(--text); }

/* ---------- 清空 ---------- */
.clear-box { text-align: center; padding: 30px 20px; }
.clear-box .big {
  width: 52px; height: 52px; margin: 0 auto 10px; border-radius: 50%;
  background: var(--red-soft); color: var(--red);
  display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700;
}
.clear-box h3 { margin: 0 0 8px; }
.clear-box p { color: var(--muted); font-size: 14px; margin: 0 0 20px; line-height: 1.7; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  color: #fff; padding: 12px 22px; border-radius: 8px;
  font-size: 14px; box-shadow: var(--shadow-lg); z-index: 300; max-width: 88vw; text-align: center;
  animation: toastIn .2s ease;
}
.toast.ok { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%); } }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 30, 45, .45); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s ease;
}
.modal-box { background: #fff; border-radius: var(--radius); padding: 22px; width: 100%; max-width: 420px; box-shadow: var(--shadow-lg); }
.modal-box h3 { margin: 0 0 10px; font-size: 17px; }
.modal-box p { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- 页脚 ---------- */
.footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 14px; border-top: 1px solid var(--border); background: #fff; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar-inner { flex-direction: column; align-items: flex-start; }
  .brand-text h1 { font-size: 16px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .page-title h2 { font-size: 18px; }
  .sel-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .grade-row { flex-direction: column; align-items: stretch; }
  .rec-grid { grid-template-columns: 1fr; gap: 2px 0; padding: 10px 2px; }
  .rec-head { display: none; }
}

/* ---------- 分部切换栏 ---------- */
.admin-org-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--primary-soft); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px; margin: 14px 0 18px;
}
.org-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.org-select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: #fff; color: var(--text); outline: none;
}
.org-select:focus { border-color: var(--primary); }
.org-name { font-size: 13px; font-weight: 600; color: var(--primary); }

/* ---------- 方案版本编辑（时段行） ---------- */
.slot-row {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap;
}
.slot-row input.slot-time { width: 110px; }
.slot-row input.slot-title { flex: 1; min-width: 140px; }
.slot-row select.slot-type { width: 110px; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: #fff; }
.slot-row input {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none;
}
.slot-row input:focus { border-color: var(--primary); }
#sf-slots { margin-bottom: 8px; }
#sf-add-slot { margin-top: 2px; }
