/* 作业快打 · 管理后台 */
:root {
  --brand: #0fbf6e;
  --brand-dark: #0a9c5a;
  --bg: #f5f6f8;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
  --warn: #d97706;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #e8f9f0 0%, #f5f6f8 60%);
}
.login-card {
  background: var(--card); border-radius: 16px; padding: 40px 36px; width: 360px;
  box-shadow: 0 10px 40px rgba(0,0,0,.08); text-align: center;
}
.login-logo { color: var(--brand); display: flex; justify-content: center; margin-bottom: 8px; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.login-card .err { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; background: #fff; border-right: 1px solid var(--border);
  padding: 16px 10px; flex-shrink: 0; display: flex; flex-direction: column;
}
.sidebar .logo { font-weight: 700; font-size: 16px; padding: 8px 12px 18px; display: flex; align-items: center; gap: 7px; color: var(--brand); }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav button {
  border: none; background: none; text-align: left; padding: 10px 12px;
  border-radius: 8px; font-size: 14px; color: var(--text); display: flex; gap: 8px; align-items: center;
}
.sidebar nav button:hover { background: #f0fdf4; }
.sidebar nav button.active { background: var(--brand); color: #fff; font-weight: 600; }
.sidebar .who { padding: 10px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.sidebar .who button { margin-top: 6px; }

.main { flex: 1; padding: 24px 28px; min-width: 0; width: 100%; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 18px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.card h3 { font-size: 15px; margin-bottom: 14px; }
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 8px; font-size: 13px;
}
.btn:hover { border-color: #cfd3d9; background: #f9fafb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: #fef2f2; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text);
}
.field textarea { resize: vertical; min-height: 60px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.row { display: flex; gap: 12px; }
.row .field { flex: 1; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #f1f3f5; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.badge.green { background: #ecfdf3; color: #067647; }
.badge.gray { background: #f3f4f6; color: var(--muted); }
.badge.orange { background: #fff7ed; color: var(--warn); }
.badge.red { background: #fef2f2; color: var(--danger); }
.badge.blue { background: #eff6ff; color: #2563eb; }

.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13px; z-index: 99; box-shadow: 0 6px 24px rgba(0,0,0,.2);
}
.toast.err { background: var(--danger); }

/* ---------- 仪表盘 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-card .num { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat-card .num small { font-size: 13px; color: var(--muted); font-weight: 400; }
.stat-card .label { font-size: 12px; color: var(--muted); }
.chart-box { width: 100%; overflow: hidden; }
.chart-box svg { display: block; width: 100%; height: auto; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

.ver-bars { display: flex; flex-direction: column; gap: 8px; }
.ver-bar { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.ver-bar .name { width: 70px; color: var(--muted); flex-shrink: 0; }
.ver-bar .bar-bg { flex: 1; height: 18px; background: #f3f4f6; border-radius: 6px; overflow: hidden; }
.ver-bar .bar { height: 100%; background: var(--brand); border-radius: 6px; min-width: 2px; }
.ver-bar .cnt { width: 60px; text-align: right; flex-shrink: 0; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 16px; padding: 0; width: 520px; max-width: 100%;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 70px rgba(0,0,0,.25);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.modal-head h3 { font-size: 16px; }
.modal-close {
  border: none; background: none; color: var(--muted); width: 30px; height: 30px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #f3f4f6; color: var(--text); }
.modal-body { padding: 20px 24px; overflow: auto; }
.modal-body .field { margin-bottom: 16px; }
.modal-body .field:last-child { margin-bottom: 0; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 12px;
  padding: 14px 24px 18px; border-top: 1px solid var(--border);
  margin-top: 0; flex-shrink: 0; background: #fafbfc; border-radius: 0 0 16px 16px;
}
.modal-foot .btn { padding: 8px 20px; }
.perm-checks { display: flex; flex-direction: column; gap: 8px; }
.perm-checks label { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text); }
.tag-select { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip {
  padding: 4px 12px; border-radius: 20px; border: 1px solid var(--border);
  font-size: 12px; background: #fff; user-select: none;
}
.tag-chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.muted { color: var(--muted); }
.mt { margin-top: 12px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 10px; font-size: 13px; color: var(--muted); }

.filter-bar { display: flex; gap: 10px; align-items: center; margin: 14px 0; }
.filter-bar .fl-select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); font-size: 13px; min-width: 140px;
}

@media (max-width: 720px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 8px; gap: 4px; overflow-x: auto; }
  .sidebar .logo { padding: 4px 8px; white-space: nowrap; }
  .sidebar nav { flex-direction: row; }
  .sidebar nav button { white-space: nowrap; padding: 8px 10px; }
  .sidebar .who { border: none; margin-left: auto; padding: 4px 8px; white-space: nowrap; }
  .main { padding: 14px; }
  .row { flex-direction: column; gap: 0; }
}
