/* ============ 设计变量 ============ */
:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warn: #ea580c;
  --warn-light: #ffedd5;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --purple: #7c3aed;
  --purple-light: #f3e8ff;
  --gray: #64748b;
  --gray-light: #f1f5f9;

  --bg: #f5f7fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-sub: #64748b;

  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #2563eb;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 16px rgba(15, 23, 42, .08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .16);
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ 布局 ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform .25s ease;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-logo .logo-mark {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 9px;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.sidebar-logo .logo-text { color: #fff; font-size: 15px; font-weight: 600; line-height: 1.2; }
.sidebar-logo .logo-sub { font-size: 11px; color: #64748b; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-group-title {
  font-size: 11px;
  color: #475569;
  padding: 12px 12px 6px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
  font-size: 13.5px;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 500; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item .badge-count {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  padding: 0 6px;
  border-radius: 9px;
  min-width: 18px;
  text-align: center;
  line-height: 17px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, .07);
}

.main {
  flex: 1;
  margin-left: 220px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 58px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 40;
}
.topbar h1 { font-size: 17px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.menu-toggle { display: none; background: none; border: 0; cursor: pointer; color: var(--text-sub); }

.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 20px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #fff;
  transition: background .15s;
}
.user-chip:hover { background: var(--gray-light); }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
  flex-shrink: 0;
}
.user-chip .uname { font-size: 13px; font-weight: 500; }
.dropdown {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  padding: 6px;
  display: none;
}
.dropdown.show { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  width: 100%;
  background: none; border: 0; text-align: left;
}
.dropdown-item:hover { background: var(--gray-light); }

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

/* ============ 卡片与通用块 ============ */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-header .spacer { flex: 1; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }

.page-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.page-head h1 { font-size: 20px; font-weight: 600; }
.page-head .spacer { flex: 1; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--gray-light); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.94); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn-warn:hover { filter: brightness(.94); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-link {
  border: 0; background: none; color: var(--primary);
  padding: 0; cursor: pointer; font-size: 13px;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--danger); }

/* ============ 表单 ============ */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12.5px; font-weight: 500; color: var(--text-sub); }
.form-group label .req { color: var(--danger); }
input, select, textarea {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { resize: vertical; min-height: 76px; }
input[type="checkbox"] { width: auto; }
.hint { font-size: 12px; color: var(--text-sub); }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.filter-bar .form-group { min-width: 150px; }
.filter-bar .form-group.wide { min-width: 220px; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 11px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-sub);
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
td .cell-title { font-weight: 500; color: var(--text); }
td .cell-sub { font-size: 12px; color: var(--text-sub); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ============ 徽章 ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  line-height: 19px;
  white-space: nowrap;
}
.badge-default { background: var(--gray-light); color: var(--gray); }
.badge-blue { background: var(--primary-light); color: var(--primary); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-orange { background: var(--warn-light); color: var(--warn); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 5px;
  background: var(--gray-light);
  color: var(--text-sub);
  font-size: 11.5px;
  margin-right: 4px;
}

/* ============ 进度条 ============ */
.progress {
  height: 6px;
  background: var(--gray-light);
  border-radius: 4px;
  overflow: hidden;
  min-width: 70px;
}
.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width .3s;
}
.progress-bar.green { background: var(--success); }
.progress-bar.orange { background: var(--warn); }
.progress-bar.red { background: var(--danger); }
.progress-cell { display: flex; align-items: center; gap: 8px; }
.progress-cell span { font-size: 12px; color: var(--text-sub); min-width: 32px; }

/* ============ 统计卡 ============ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 12.5px; color: var(--text-sub); display: flex; align-items: center; gap: 6px; }
.stat-card .stat-value { font-size: 27px; font-weight: 650; margin-top: 6px; line-height: 1.2; }
.stat-card .stat-value small { font-size: 14px; font-weight: 500; color: var(--text-sub); }
.stat-card .stat-foot { font-size: 12px; color: var(--text-sub); margin-top: 4px; }
.stat-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: grid; place-items: center; margin-bottom: 10px;
}
.stat-icon svg { width: 18px; height: 18px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > * { margin-bottom: 0; }

/* ============ 时间线 ============ */
.timeline { position: relative; padding-left: 22px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
  content: ""; position: absolute; left: -22px; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--primary);
}
.timeline-item.head::before { background: var(--primary); }
.timeline-title { font-size: 13.5px; font-weight: 500; }
.timeline-meta { font-size: 12px; color: var(--text-sub); }
.timeline-body { font-size: 13px; color: var(--text-sub); margin-top: 2px; }

/* ============ 空状态 / 加载 ============ */
.empty {
  padding: 48px 20px;
  text-align: center;
  color: var(--text-sub);
}
.empty svg { width: 44px; height: 44px; opacity: .35; margin-bottom: 10px; }
.loading {
  padding: 40px;
  text-align: center;
  color: var(--text-sub);
  font-size: 13px;
}
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 分页 ============ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.pagination button {
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.pagination button:hover:not(:disabled) { background: var(--gray-light); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: .45; cursor: not-allowed; }
.pagination .total { margin-right: auto; font-size: 13px; color: var(--text-sub); }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, .5);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  overflow-y: auto;
  z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease;
}
.modal.wide { max-width: 860px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-12px); } }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
}
.modal-header h3 { font-size: 15.5px; font-weight: 600; }
.modal-header .spacer { flex: 1; }
.modal-close {
  background: none; border: 0; cursor: pointer;
  color: var(--text-sub); font-size: 20px; line-height: 1; padding: 2px 6px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--gray-light); }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============ Toast ============ */
.toast-wrap {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: #fff;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  padding: 11px 16px;
  font-size: 13.5px;
  min-width: 240px;
  max-width: 380px;
  animation: toastIn .2s ease;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } }

/* ============ 登录页 ============ */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
  padding: 20px;
}
.login-box {
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
  padding: 36px 32px;
}
.login-box .brand { text-align: center; margin-bottom: 26px; }
.login-box .brand .logo-mark {
  width: 46px; height: 46px;
  background: var(--primary);
  border-radius: 12px;
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 19px;
  margin: 0 auto 12px;
}
.login-box .brand h1 { font-size: 19px; font-weight: 650; }
.login-box .brand p { font-size: 13px; color: var(--text-sub); margin-top: 2px; }
.login-box .demo-tip {
  margin-top: 18px;
  padding: 10px 12px;
  background: var(--gray-light);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-sub);
  line-height: 1.7;
}
.alert {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  background: var(--danger-light);
  color: var(--danger);
  display: none;
}
.alert.show { display: block; }

/* ============ 详情页布局 ============ */
.detail-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.info-list { display: grid; grid-template-columns: 92px 1fr; gap: 10px 14px; font-size: 13.5px; }
.info-list dt { color: var(--text-sub); }
.info-list dd { color: var(--text); word-break: break-all; }

.subtask-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.file-item .file-icon {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary);
  display: grid; place-items: center;
  flex-shrink: 0;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase;
}
.file-item .file-main { flex: 1; min-width: 0; }
.file-item .file-name {
  font-size: 13.5px; font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.file-item .file-meta { font-size: 12px; color: var(--text-sub); }

.score-bar-row {
  display: grid;
  grid-template-columns: 88px 1fr 52px;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12.5px;
}
.score-bar-row .lbl { color: var(--text-sub); }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .menu-toggle { display: block; }
  .content { padding: 16px; }
  .topbar { padding: 0 14px; }
}
