/* ============ 基础 ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff6ff;
  --text: #1f2937;
  --text-muted: #6b7280;
  --text-faint: #9ca3af;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #f0fdf4;
  --warning: #d97706;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.12);
}
/* 原生 hidden 属性必须真正隐藏：.auth-view / .app-shell 的 display:flex 属于作者样式，
   优先级高于浏览器默认的 [hidden]{display:none}，不写这条会让登录页和后台外壳同时渲染 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea {
  font-family: inherit; font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: #fff;
  color: var(--text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
textarea { resize: vertical; min-height: 80px; }
label { display: block; }
label > span { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 5px; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  transition: background .15s, border-color .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-primary:disabled { background: #93c5fd; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border-strong); }
.btn-ghost:hover { background: #f3f4f6; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-icon { padding: 6px; color: var(--text-muted); border-radius: var(--radius-sm); }
.btn-icon:hover { background: #f3f4f6; color: var(--text); }
.btn-icon.danger:hover { background: var(--danger-soft); color: var(--danger); }

/* ============ 登录页 ============ */
.auth-view {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
  padding: 20px;
}
.auth-card {
  width: 100%; max-width: 380px; background: #fff; border-radius: 16px;
  padding: 36px 32px; box-shadow: var(--shadow-lg);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-logo {
  width: 56px; height: 56px; border-radius: 14px; background: var(--brand); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 26px;
  font-weight: 700; margin-bottom: 14px;
}
.auth-brand h1 { font-size: 20px; }
.auth-brand p { color: var(--text-muted); font-size: 13px; margin-top: 4px; }
.auth-form label { margin-bottom: 14px; }
.auth-form .btn { margin-top: 6px; }
.auth-hint { text-align: center; color: var(--text-faint); font-size: 12px; margin-top: 20px; }
.form-error {
  background: var(--danger-soft); color: var(--danger); padding: 8px 12px;
  border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 12px;
}

/* ============ 后台外壳 ============ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
  flex-shrink: 0;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid #1e293b; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 9px; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px;
}
.brand-text strong { color: #fff; display: block; font-size: 15px; }
.brand-text small { color: #64748b; font-size: 11px; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  color: #cbd5e1; font-size: 14px; margin-bottom: 2px;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.sidebar-footer { padding: 14px; border-top: 1px solid #1e293b; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: #334155; color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600;
}
.user-info { overflow: hidden; }
.user-info strong { color: #fff; font-size: 13px; display: block; }
.user-info small { color: #64748b; font-size: 11px; }
.sidebar-footer .btn-ghost { border-color: #334155; color: #cbd5e1; }
.sidebar-footer .btn-ghost:hover { background: #1e293b; color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border); padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar h2 { font-size: 18px; }
.page-actions { display: flex; gap: 8px; }
.view { padding: 24px 28px; flex: 1; }

/* ============ 卡片 / 统计 ============ */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h3 { font-size: 15px; }
.card-body { padding: 20px; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: #fff; border-radius: var(--radius); padding: 20px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.stat-card .label { color: var(--text-muted); font-size: 13px; }
.stat-card .value { font-size: 30px; font-weight: 700; margin-top: 6px; }
.stat-card .hint { color: var(--text-faint); font-size: 12px; margin-top: 4px; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
table.data th {
  text-align: left; padding: 11px 16px; background: #f9fafb;
  color: var(--text-muted); font-weight: 600; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data td {
  padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover { background: #f9fafb; }
.row-actions { display: flex; gap: 4px; }
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px;
  font-weight: 500;
}
.tag-pin { background: #fef3c7; color: #92400e; }
.tag-all { background: #e0e7ff; color: #3730a3; }
.tag-class { background: #d1fae5; color: #065f46; }
.tag-college { background: #fce7f3; color: #9d174d; }
.tag-muted { background: #f3f4f6; color: #4b5563; }
.tag-success { background: var(--success-soft); color: var(--success); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }

/* ============ 空状态 / 加载 ============ */
.empty {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty .icon { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.spinner {
  width: 22px; height: 22px; border: 3px solid var(--border);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { text-align: center; padding: 40px; }

/* ============ 模态框 ============ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 20px; animation: fadeIn .15s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column;
  animation: pop .18s;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  padding: 18px 22px; 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 22px; overflow-y: auto; }
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-row { margin-bottom: 14px; }
.check-row { display: flex; align-items: center; gap: 8px; }
.check-row input { width: auto; }

/* ============ Toast ============ */
.toast-root {
  position: fixed; top: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: #1f2937; color: #fff; padding: 11px 16px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-lg); animation: slideIn .2s;
  min-width: 200px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ============ 工具行 / 过滤器 ============ */
.toolbar {
  display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap;
}
.toolbar input, .toolbar select { width: auto; min-width: 180px; }
.toolbar .spacer { flex: 1; }

.hint-text { color: var(--text-muted); font-size: 13px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 6px; }
.muted { color: var(--text-muted); }

/* ============ 组织架构树 ============ */
.org-node { border-left: 2px solid var(--border); margin-top: 6px; }
.org-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff;
}
.org-row + .org-node { margin-top: 6px; }
.org-title { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.org-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.org-dot.college { background: #2563eb; }
.org-dot.grade { background: #7c3aed; }
.org-dot.class { background: #475569; }

/* 响应式 */
@media (max-width: 768px) {
  .sidebar { position: fixed; left: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: translateX(0); }
  .form-grid { grid-template-columns: 1fr; }
}
