/* ============ 基础变量 ============ */
:root {
  --primary: #1e6fd9;
  --primary-dark: #1557b0;
  --primary-soft: #e8f1fd;
  --accent: #0d9488;
  --accent-soft: #e3f6f4;
  --bg: #f3f5fa;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e4e7ee;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --warn: #f59e0b;
  --warn-soft: #fef4e4;
  --danger: #dc2626;
  --danger-soft: #fdeaea;
  --sidebar-bg: #101a2e;
  --sidebar-hover: #1b2942;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(16, 24, 46, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 46, .16);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.6;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
a { color: var(--primary); text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd3e0; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 布局 ============ */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar-bg);
  color: #cdd6e6; display: flex; flex-direction: column;
  transition: width .2s ease;
}
.app.collapsed .sidebar { width: 64px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, #2f8bf5, #14b8a6);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { color: #fff; font-size: 15px; }
.brand-text span { font-size: 11px; color: #7f8ca6; letter-spacing: .3px; }
.app.collapsed .brand-text, .app.collapsed .menu span,
.app.collapsed .menu-group, .app.collapsed .sidebar-foot { display: none; }
.app.collapsed .menu-item { justify-content: center; }
.app.collapsed .menu-item .badge-dot { display: none; }

.menu { flex: 1; overflow-y: auto; padding: 6px 10px; }
.menu-group { font-size: 11px; color: #65748f; padding: 14px 10px 6px; letter-spacing: 1px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px;
  border-radius: 9px; cursor: pointer; color: #cdd6e6; font-size: 13.5px;
  white-space: nowrap; transition: background .15s;
}
.menu-item:hover { background: var(--sidebar-hover); }
.menu-item.active { background: var(--primary); color: #fff; }
.menu-item .ico { width: 20px; text-align: center; font-size: 15px; flex-shrink: 0; }
.menu-item .badge-dot {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  min-width: 18px; height: 18px; border-radius: 9px; display: flex;
  align-items: center; justify-content: center; padding: 0 5px;
}
.sidebar-foot { padding: 12px 10px; border-top: 1px solid #1d2942; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; flex-shrink: 0; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 20px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 18px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.role-switch {
  display: flex; background: #eef1f6; border-radius: 8px; padding: 3px;
}
.role-btn {
  border: 0; background: transparent; padding: 6px 14px; border-radius: 6px;
  cursor: pointer; font-size: 13px; color: var(--muted); font-family: inherit;
}
.role-btn.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }
.user-chip { display: flex; align-items: center; gap: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 13px; }
.user-meta span { font-size: 11px; color: var(--muted); }
.icon-btn {
  border: 1px solid var(--border); background: #fff; border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer; font-size: 14px; color: var(--text);
}
.icon-btn:hover { background: #f3f5fa; }

.content { flex: 1; overflow-y: auto; padding: 20px; }

/* ============ 通用组件 ============ */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; }
.card-head .sub { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 8px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat {
  background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; display: flex; align-items: center; gap: 14px;
}
.stat-ico {
  width: 44px; height: 44px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.stat-num { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--muted); }
.stat-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  font-family: inherit; transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { opacity: .9; color: #fff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; color: #fff; }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-warn:hover { opacity: .9; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: #cdd6e6; }
.btn-ghost:hover { background: var(--sidebar-hover); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 20px; font-size: 12px; background: #eef1f6; color: var(--muted);
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warn { background: var(--warn-soft); color: #b45309; }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--primary-soft); color: var(--primary); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px;
  background: #f0f3f8; color: var(--muted); margin-right: 6px;
}

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 500; background: #fafbfd; }
.table tbody tr:hover { background: #fafbfe; }
.table .actions { display: flex; gap: 6px; }
.table-wrap { overflow-x: auto; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font-size: 13.5px; font-family: inherit; color: var(--text); background: #fff;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); }
.textarea { min-height: 90px; resize: vertical; line-height: 1.6; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1; min-width: 160px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 8px 16px; cursor: pointer; font-size: 13.5px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .input, .filters .select { width: auto; min-width: 150px; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .ico { font-size: 40px; opacity: .35; }

.section-title { font-size: 14px; margin: 18px 0 10px; font-weight: 600; }
.hint { font-size: 12.5px; color: var(--muted); }
.text-muted { color: var(--muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warn { color: #b45309; }
.mono { font-family: Consolas, "Courier New", monospace; }
.right { text-align: right; }
.flex { display: flex; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.gap8 { gap: 8px; }
.wrap { flex-wrap: wrap; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; }

/* 列表卡片 */
.list-item {
  border: 1px solid var(--border); border-radius: 10px; padding: 14px;
  display: flex; gap: 12px; align-items: flex-start; transition: box-shadow .15s;
}
.list-item:hover { box-shadow: var(--shadow); }
.list-item .li-ico {
  width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft);
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.list-item .li-body { flex: 1; min-width: 0; }
.list-item h4 { font-size: 14px; margin-bottom: 4px; }
.list-item p { margin: 0; font-size: 12.5px; color: var(--muted); }
.card-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 46, .45); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 560px; max-width: 100%; max-height: 90vh; display: flex; flex-direction: column;
}
.modal-lg { width: 820px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-close { border: 0; background: transparent; font-size: 20px; cursor: pointer; color: var(--muted); }

/* ============ 提示 ============ */
.toast-root { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: #fff; border-left: 4px solid var(--primary); border-radius: 8px;
  box-shadow: var(--shadow-lg); padding: 10px 16px; font-size: 13.5px; min-width: 200px;
  animation: slideIn .2s ease;
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warn { border-left-color: var(--warn); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ 仿真实验 ============ */
.sim-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
@media (max-width: 980px) { .sim-layout { grid-template-columns: 1fr; } }
.sim-stage {
  background: linear-gradient(180deg, #f8fbff, #eef4fb); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-end; min-height: 380px; position: relative;
}
.burette { position: relative; width: 26px; height: 190px; }
.burette-tube {
  position: absolute; inset: 0 0 26px 0; border: 2px solid #94a3b8; border-radius: 4px 4px 2px 2px;
  background: #fff; overflow: hidden;
}
.burette-liquid { position: absolute; left: 0; right: 0; bottom: 0; background: #dbeafe; transition: height .25s; }
.burette-stopcock {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  width: 16px; height: 10px; background: #64748b; border-radius: 3px;
}
.burette-tip { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); width: 6px; height: 14px; background: #94a3b8; }
.drop { position: absolute; bottom: -6px; left: 50%; width: 6px; height: 6px; border-radius: 50%; background: #60a5fa; }
.flask { margin-top: 6px; position: relative; width: 110px; height: 120px; }
.flask-shape {
  position: absolute; bottom: 0; width: 110px; height: 110px;
  clip-path: polygon(50% 0, 56% 26%, 100% 100%, 0 100%);
  border: 2px solid #94a3b8; background: #fff; overflow: hidden;
}
.flask-neck {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 22px; height: 30px; border: 2px solid #94a3b8; border-bottom: 0; background: #fff;
}
.flask-liquid {
  position: absolute; bottom: 0; left: 0; right: 0; background: #f1f5f9;
  transition: height .25s, background .35s;
}
.stir-bar { position: absolute; bottom: 6px; left: 50%; width: 22px; height: 6px; border-radius: 3px; background: #94a3b8; }

.sim-panel { display: grid; grid-template-columns: 1fr; gap: 16px; }
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.readout-box {
  background: #f8fafc; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
.readout-box .k { font-size: 12px; color: var(--muted); }
.readout-box .v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.log-box {
  max-height: 170px; overflow-y: auto; font-size: 12.5px; background: #0f172a; color: #cbd5e1;
  border-radius: 8px; padding: 10px 12px; line-height: 1.7;
}
.log-box .l-warn { color: #fbbf24; } .log-box .l-ok { color: #4ade80; } .log-box .l-err { color: #f87171; }

/* 装置组装 */
.assembly-area {
  display: flex; align-items: flex-end; justify-content: center; gap: 6px;
  min-height: 150px; padding: 16px; background: #f8fbff;
  border: 2px dashed #c7d7ef; border-radius: 12px; flex-wrap: wrap;
}
.slot {
  width: 92px; height: 92px; border: 2px dashed #cbd5e1; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted); background: #fff; text-align: center; padding: 4px;
}
.slot.filled { border-style: solid; border-color: var(--primary); background: var(--primary-soft); color: var(--text); }
.slot.correct { border-color: var(--success); background: var(--success-soft); }
.slot.wrong { border-color: var(--danger); background: var(--danger-soft); }
.slot .slot-ico { font-size: 22px; }
.parts-pool { display: flex; gap: 8px; flex-wrap: wrap; }
.part {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; background: #fff;
  cursor: grab; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 78px;
}
.part:hover { border-color: var(--primary); background: var(--primary-soft); }
.part.used { opacity: .4; cursor: default; }
.part .p-ico { font-size: 20px; }

/* 步骤排序 */
.step-item {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; background: #fff; margin-bottom: 8px;
}
.step-item .idx {
  width: 24px; height: 24px; border-radius: 50%; background: #eef1f6; color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-size: 12px; flex-shrink: 0;
}
.step-item.ok { border-color: var(--success); background: var(--success-soft); }
.step-item.ok .idx { background: var(--success); color: #fff; }
.step-item.bad { border-color: var(--danger); background: var(--danger-soft); }
.step-item.bad .idx { background: var(--danger); color: #fff; }
.step-item .txt { flex: 1; font-size: 13.5px; }

/* ============ 课表 ============ */
.timetable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.timetable th, .timetable td { border: 1px solid var(--border); padding: 6px; text-align: center; }
.timetable th { background: #fafbfd; color: var(--muted); font-weight: 500; }
.timetable td.lab-cell { cursor: pointer; height: 62px; vertical-align: middle; }
.timetable td.lab-cell:hover { background: var(--primary-soft); }
.timetable td.booked { background: var(--warn-soft); }
.timetable td.mine { background: var(--primary-soft); }
.cell-bk { font-size: 11px; line-height: 1.35; padding: 3px; border-radius: 6px; }
.cell-bk.approved { background: var(--success-soft); color: #15803d; }
.cell-bk.pending { background: var(--warn-soft); color: #b45309; }
.cell-bk.rejected { background: var(--danger-soft); color: var(--danger); }

/* ============ 题目 ============ */
.q-card { border: 1px solid var(--border); border-radius: 12px; padding: 16px; margin-bottom: 14px; background: #fff; }
.q-title { font-size: 14.5px; margin-bottom: 10px; line-height: 1.7; }
.q-option {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 8px;
  cursor: pointer; font-size: 13.5px; transition: all .15s;
}
.q-option:hover { border-color: var(--primary); }
.q-option.selected { border-color: var(--primary); background: var(--primary-soft); }
.q-option.correct { border-color: var(--success); background: var(--success-soft); }
.q-option.wrong { border-color: var(--danger); background: var(--danger-soft); }
.q-analysis {
  margin-top: 10px; padding: 10px 12px; background: #f8fafc; border-left: 3px solid var(--accent);
  border-radius: 6px; font-size: 13px;
}

/* 柱状成绩图 */
.bar-chart { display: flex; align-items: flex-end; justify-content: space-around; gap: 10px; min-height: 150px; padding-top: 8px; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: 1; min-width: 40px; }
.bar-val { font-size: 12px; font-weight: 600; color: var(--muted); }
.bar-lab { font-size: 11px; color: var(--muted); max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-col .progress { display: flex; flex-direction: column-reverse; width: 26px; height: 90px; margin: 0 auto; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.bar-col .progress > i { width: 100%; }

/* 进度条 */
.progress { height: 8px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; transition: width .3s; }
.progress.warn > i { background: var(--warn); }
.progress.danger > i { background: var(--danger); }
.progress.success > i { background: var(--success); }

/* 详情描述 */
.dl { display: grid; grid-template-columns: 92px 1fr; gap: 6px 12px; font-size: 13.5px; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }
.step-ol { padding-left: 20px; margin: 0; }
.step-ol li { margin-bottom: 6px; font-size: 13.5px; }
.notice-box {
  background: var(--warn-soft); border-left: 3px solid var(--warn); border-radius: 6px;
  padding: 10px 14px; font-size: 13px; margin-top: 10px;
}
.danger-box {
  background: var(--danger-soft); border-left: 3px solid var(--danger); border-radius: 6px;
  padding: 10px 14px; font-size: 13px; margin-top: 10px;
}
.safe-box {
  background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 6px;
  padding: 10px 14px; font-size: 13px; margin-top: 10px;
}
