/* ==========================================================================
   教务巡课管理系统 —— 管理后台样式
   纯手写 CSS，无任何框架/构建步骤
   ========================================================================== */

:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --success: #16a34a;
  --warning: #ea580c;
  --danger: #dc2626;
  --info: #0891b2;

  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #4f46e5;

  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

button, input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- 登录页 */
.login-view {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #2563eb 100%);
  padding: 20px;
  z-index: 100;
}
.login-card {
  width: 100%; max-width: 420px;
  background: #fff; border-radius: 16px;
  padding: 40px 36px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.login-logo {
  width: 56px; height: 56px; border-radius: 14px;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; margin: 0 auto 18px;
}
.login-card h1 { font-size: 21px; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 26px; }
.login-accounts {
  margin-top: 22px; padding: 14px 16px;
  background: #f8fafc; border: 1px dashed var(--border); border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-muted); line-height: 1.9;
}
.login-accounts b { color: var(--text); }
.login-accounts code {
  background: #e2e8f0; padding: 1px 6px; border-radius: 4px;
  font-family: Consolas, Monaco, monospace; color: #334155;
}

/* ---------------------------------------------------------------- 布局 */
.app-view { display: none; min-height: 100vh; }
.app-view.active { display: block; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 216px;
  background: var(--sidebar-bg); color: #cbd5e1;
  display: flex; flex-direction: column; z-index: 20;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 20px 20px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.sidebar-brand .txt { font-size: 15px; font-weight: 600; color: #f1f5f9; line-height: 1.25; }
.sidebar-brand .txt small { display: block; font-size: 11px; color: #94a3b8; font-weight: 400; }

.nav { padding: 12px 10px; flex: 1; }
.nav-group-title {
  font-size: 11px; color: #64748b; padding: 14px 12px 6px;
  letter-spacing: .5px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13.5px; color: #cbd5e1;
  transition: background .15s, color .15s;
  user-select: none;
}
.nav-item:hover { background: var(--sidebar-hover); color: #f1f5f9; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 500; }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; }
.nav-item .badge-dot {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 9px; font-weight: 600;
}

.sidebar-foot {
  padding: 12px 16px 16px; border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 12px; color: #94a3b8;
}
.sidebar-foot .who { color: #e2e8f0; font-weight: 500; margin-bottom: 2px; }

.main { margin-left: 216px; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  position: sticky; top: 0; z-index: 15;
}
.topbar h2 { font-size: 17px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar .meta { font-size: 12.5px; color: var(--text-muted); }

.content { padding: 22px 24px 60px; flex: 1; }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-head {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-head .hint { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar { width: 60px; }
  .sidebar .txt, .nav-item span:not(.ico), .nav-group-title, .sidebar-foot { display: none; }
  .main { margin-left: 60px; }
  .content { padding: 16px; }
}

/* ---------------------------------------------------------------- 统计卡 */
.stat {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.stat .label { font-size: 12.5px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 28px; font-weight: 700; margin: 6px 0 2px; letter-spacing: -.5px; }
.stat .value small { font-size: 14px; font-weight: 500; color: var(--text-muted); margin-left: 3px; }
.stat .foot { font-size: 12px; color: var(--text-light); }
.stat.accent { border-left: 4px solid var(--primary); }
.stat.ok { border-left: 4px solid var(--success); }
.stat.warn { border-left: 4px solid var(--warning); }
.stat.bad { border-left: 4px solid var(--danger); }

/* ---------------------------------------------------------------- 按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: #fff; color: var(--text); cursor: pointer; font-size: 13.5px;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- 表单 */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 13px; font-weight: 500;
  margin-bottom: 5px; color: #334155;
}
.field label .req { color: var(--danger); }
.field .tip { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.input, .select, .textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.textarea { min-height: 78px; resize: vertical; line-height: 1.6; }
.select { cursor: pointer; }

.filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}
.filters .field { margin-bottom: 0; min-width: 132px; }
.filters .field.grow { flex: 1; min-width: 180px; }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; padding: 11px 14px; background: #f8fafc;
  border-bottom: 1px solid var(--border); font-weight: 600;
  color: #475569; font-size: 12.5px; white-space: nowrap;
}
table.data td {
  padding: 11px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle;
}
table.data tbody tr:hover { background: #f8fafc; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .num { font-variant-numeric: tabular-nums; }
table.data .nowrap { white-space: nowrap; }
table.data .actions { display: flex; gap: 6px; }

/* ---------------------------------------------------------------- 徽标 */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 500; line-height: 1.7; white-space: nowrap;
}
.badge-green { background: #dcfce7; color: #15803d; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-sm { font-size: 11px; padding: 1px 7px; }

.tag {
  display: inline-block; padding: 3px 10px; border-radius: 6px;
  background: var(--primary-light); color: var(--primary-dark);
  font-size: 12px; margin: 0 5px 5px 0;
}

/* ---------------------------------------------------------------- 分页 */
.pager {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 14px 20px; border-top: 1px solid var(--border); font-size: 13px;
}
.pager .info { color: var(--text-muted); margin-right: auto; }

/* ---------------------------------------------------------------- 空状态 */
.empty {
  text-align: center; padding: 56px 20px; color: var(--text-light);
}
.empty .ico { font-size: 40px; margin-bottom: 10px; opacity: .5; }
.empty .txt { font-size: 13.5px; }

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

/* ---------------------------------------------------------------- 提示条 */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: 13.5px; display: flex; gap: 10px;
  align-items: flex-start; line-height: 1.7;
}
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-warn { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }

/* ---------------------------------------------------------------- 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 20px; animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 560px;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: pop .18s;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.modal.wide { max-width: 900px; }
.modal-head {
  padding: 17px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; font-weight: 600; font-size: 15.5px;
}
.modal-head .close {
  margin-left: auto; cursor: pointer; color: var(--text-light);
  font-size: 22px; line-height: 1; background: none; border: none; padding: 0 4px;
}
.modal-head .close:hover { color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ---------------------------------------------------------------- 提示 */
#toast-box {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none;
}
.toast {
  padding: 10px 20px; border-radius: 8px; font-size: 13.5px;
  box-shadow: var(--shadow-lg); animation: slidedown .2s;
  max-width: 620px; line-height: 1.6;
}
@keyframes slidedown { from { transform: translateY(-14px); opacity: 0; } }
.toast-success { background: #166534; color: #fff; }
.toast-error { background: #b91c1c; color: #fff; }
.toast-info { background: #1e293b; color: #fff; }
.toast-warn { background: #b45309; color: #fff; }

/* ---------------------------------------------------------------- 选项卡 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 9px 16px; cursor: pointer; font-size: 13.5px;
  border-bottom: 2px solid transparent; color: var(--text-muted);
  margin-bottom: -1px; user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* ---------------------------------------------------------------- 图表 */
.chart { width: 100%; }
.chart-empty { text-align: center; color: var(--text-light); padding: 40px; font-size: 13px; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; font-size: 13px; }
.bar-row .name { width: 96px; text-align: right; color: var(--text-muted); flex-shrink: 0; }
.bar-row .track { flex: 1; background: #f1f5f9; border-radius: 5px; height: 20px; overflow: hidden; }
.bar-row .fill {
  height: 100%; background: linear-gradient(90deg, #6366f1, #4f46e5);
  border-radius: 5px; transition: width .4s;
}
.bar-row .val { width: 62px; font-variant-numeric: tabular-nums; color: #475569; flex-shrink: 0; }

/* ---------------------------------------------------------------- 课表网格 */
.tt-grid { overflow-x: auto; }
table.tt { border-collapse: collapse; width: 100%; min-width: 760px; font-size: 12.5px; }
table.tt th, table.tt td { border: 1px solid var(--border); padding: 6px; text-align: center; vertical-align: top; }
table.tt th { background: #f8fafc; font-weight: 600; color: #475569; }
table.tt td.period-cell { background: #f8fafc; font-weight: 500; width: 92px; line-height: 1.5; }
table.tt td.period-cell small { display: block; color: var(--text-light); font-weight: 400; font-size: 11px; }
table.tt .cell-course {
  background: var(--primary-light); border-radius: 5px; padding: 5px 4px;
  margin: 2px 0; text-align: left; line-height: 1.45;
}
table.tt .cell-course b { color: var(--primary-dark); font-weight: 600; }
table.tt .cell-course span { display: block; color: #475569; font-size: 11.5px; }
table.tt .cell-course em { display: block; color: var(--text-light); font-size: 11px; font-style: normal; }

/* ---------------------------------------------------------------- 详情 */
.detail-list { display: grid; grid-template-columns: 92px 1fr; gap: 9px 14px; font-size: 13.5px; }
.detail-list dt { color: var(--text-muted); }
.detail-list dd { color: var(--text); word-break: break-all; }
.photo-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.photo-row img {
  width: 108px; height: 108px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); cursor: pointer;
}
.note-item {
  padding: 11px 14px; background: #f8fafc; border-radius: var(--radius-sm);
  margin-bottom: 8px; font-size: 13px; border-left: 3px solid var(--primary);
}
.note-item .meta { font-size: 11.5px; color: var(--text-light); margin-top: 4px; }

/* ---------------------------------------------------------------- 上传区 */
.drop {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px 20px; text-align: center; cursor: pointer;
  transition: all .15s; background: #fcfdff;
}
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-light); }
.drop .ico { font-size: 34px; margin-bottom: 8px; }
.drop .t1 { font-weight: 500; margin-bottom: 4px; }
.drop .t2 { font-size: 12.5px; color: var(--text-muted); }

/* ---------------------------------------------------------------- 其它 */
.kv-inline { display: flex; flex-wrap: wrap; gap: 8px 18px; font-size: 13px; color: var(--text-muted); }
.kv-inline b { color: var(--text); font-weight: 600; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.right { text-align: right; }
.mono { font-family: Consolas, Monaco, monospace; font-size: 12.5px; }
.stars { color: #f59e0b; letter-spacing: 1px; }
.rating-big { font-size: 17px; font-weight: 700; }
.rule-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}
.rule-row:last-child { border-bottom: none; }
.rule-row .rname { flex: 1; font-size: 13.5px; }
.rule-row .rname small { display: block; color: var(--text-muted); font-size: 12px; }
.rule-row .rval { width: 140px; }
.switch { position: relative; width: 46px; height: 25px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 25px;
  cursor: pointer; transition: .2s;
}
.switch .slider::before {
  content: ''; position: absolute; width: 19px; height: 19px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(21px); }
.progress-line { height: 7px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.progress-line > i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
