/* ============================================
   学生成绩管理系统 - 教务风格UI
   ============================================ */

:root {
  --primary: #1a56db;
  --primary-hover: #1e40af;
  --primary-light: #dbeafe;
  --secondary: #059669;
  --secondary-light: #d1fae5;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

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

body {
  font-family: 'PingFang SC', -apple-system, 'Segoe UI', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ========== 登录页 ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #06b6d4 100%);
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.login-subtitle {
  color: var(--text-light);
  margin-bottom: 24px;
}

.login-card input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

.login-card input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
}

.login-msg {
  margin-top: 12px;
  color: var(--danger);
  font-size: 14px;
}

/* ========== 主应用 ========== */
.main-app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ========== 顶部导航 ========== */
.top-nav {
  background: white;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.nav-tab:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-tab.active {
  background: var(--primary);
  color: white;
}

/* ========== 页面 ========== */
.page {
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* ========== 视图切换内容 ========== */
.vtab-content, .etab-content {
  display: none;
}

.vtab-content.active, .etab-content.active {
  display: block;
}

/* ========== 视图切换 ========== */
.view-tabs, .entry-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  background: white;
  padding: 8px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.view-tab, .entry-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}

.view-tab:hover, .entry-tab:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.view-tab.active, .entry-tab.active {
  background: var(--primary);
  color: white;
}

/* ========== 卡片 ========== */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.card-header:hover {
  background: var(--bg);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== 折叠功能 ========== */
#gradeCardContent.collapsed,
#clsCardContent.collapsed {
  display: none;
}

/* ========== 筛选栏 ========== */
.filter-row {
  padding: 16px 20px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
}

.filter-item label {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 500;
}

.filter-item select,
.filter-item input[type="text"],
.filter-item input[type="number"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: white;
  color: var(--text);
  min-width: 140px;
}

.filter-item select:focus,
.filter-item input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ========== 统计栏 ========== */
.stats-bar {
  padding: 12px 20px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  background: var(--primary-light);
  border-top: 1px solid var(--border);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-light);
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
}

/* ========== 表格 ========== */
.table-wrap {
  overflow-x: auto;
  padding: 0 20px 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

th, td {
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg);
  font-weight: 600;
  color: var(--text);
  position: sticky;
  top: 0;
}

tr:hover {
  background: var(--bg);
}

.cell-class {
  font-weight: 600;
  color: var(--secondary);
  background: var(--secondary-light);
  border-radius: 6px;
}

.cell-name {
  font-weight: 500;
  text-align: center;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cell-total {
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  border-radius: 6px;
}

.score-high {
  color: #dc2626;
  font-weight: 600;
}

.score-mid {
  color: #d97706;
}

.score-low {
  color: var(--text-light);
}

.score-null {
  color: var(--border);
}

/* 排名样式 */
.rank-1 { background: linear-gradient(135deg, #fbbf24, #f59e0b) !important; color: white !important; }
.rank-2 { background: linear-gradient(135deg, #9ca3af, #6b7280) !important; color: white !important; }
.rank-3 { background: linear-gradient(135deg, #d97706, #b45309) !important; color: white !important; }

/* ========== 按钮 ========== */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-outline {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-chart {
  background: var(--primary-light);
  color: var(--primary);
  padding: 6px 10px;
  font-size: 14px;
}

.btn-chart:hover {
  background: var(--primary);
  color: white;
}

/* ========== 搜索 ========== */
.search-box {
  padding: 16px 20px;
}

.search-box input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary);
}

.search-list {
  padding: 0 20px 20px;
}

.search-item {
  padding: 12px 16px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  background: var(--bg);
  transition: all 0.2s;
}

.search-item:hover {
  background: var(--primary-light);
}

.search-name {
  font-weight: 600;
}

.search-info {
  color: var(--text-light);
  font-size: 13px;
}

/* ========== 学生历史/修改 ========== */
.student-edit-list {
  padding: 0 20px 20px;
}

.student-edit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 8px;
}

.student-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.student-info strong {
  font-size: 15px;
}

.student-info span {
  color: var(--text-light);
  font-size: 13px;
}

.student-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.student-actions select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}

/* ========== 表单 ========== */
.form-group {
  padding: 16px 20px;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-hint {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 8px;
  line-height: 1.5;
}

.input-row {
  display: flex;
  gap: 12px;
}

.input-row input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}

.input-row input:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group input[type="file"] {
  padding: 10px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  width: 100%;
  background: var(--bg);
}

/* ========== 年级列表 ========== */
.grade-list {
  padding: 0 20px 20px;
}

.grade-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 8px;
}

.grade-item span {
  font-weight: 600;
  font-size: 15px;
}

/* ========== 成绩编辑输入 ========== */
.score-input {
  width: 72px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
}

.score-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

/* ========== 结果提示 ========== */
.result-box {
  padding: 0 20px 20px;
}

.success {
  padding: 12px 16px;
  background: var(--secondary-light);
  color: var(--secondary);
  border-radius: 8px;
  font-weight: 500;
}

.error {
  padding: 12px 16px;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: 8px;
  font-weight: 500;
}

/* ========== 空状态 ========== */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
}

/* ========== 弹窗 ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  padding: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: manipulation;
}

.modal {
  z-index: 1001;
  background: white;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 1100px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  isolation: isolate;
}

.modal-header {
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: white;
  z-index: 20;
}

.modal-header h3 {
  font-size: 18px;
  color: var(--text);
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg);
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--danger-light);
  color: var(--danger);
}

#historyBody {
  padding: 20px;
}

/* ========== 图表 ========== */
.chart-section {
  margin-bottom: 24px;
}

.chart-section h4 {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 12px;
  font-weight: 600;
}

.chart-container {
  height: 250px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
  .top-nav {
    padding: 0 12px;
  }
  
  .nav-tabs {
    display: none;
  }
  
  .page {
    padding: 12px;
  }
  
  .view-tabs, .entry-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  
  .view-tab, .entry-tab {
    white-space: nowrap;
    flex-shrink: 0;
  }
  
  .filter-row {
    padding: 12px;
    gap: 12px;
  }
  
  .filter-item {
    min-width: 100%;
  }
  
  .filter-item select,
  .filter-item input {
    width: 100%;
    min-width: unset;
  }
  
  .table-wrap {
    padding: 0 12px 12px;
  }
  
  th, td {
    padding: 8px 6px;
    font-size: 12px;
  }
  
  .cell-name {
    max-width: 60px;
  }
  
  .score-input {
    width: 50px;
    padding: 4px 2px;
    font-size: 12px;
  }
  
  .modal {
  z-index: 1001;
  display: flex;
  flex-direction: column;
    max-height: 95vh;
    width: 1100px !important;
    min-width: 1100px;
    overflow-x: auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: manipulation;
  }
  
  .chart-container {
    height: 200px;
  }
  
  .stats-bar {
    padding: 12px;
    gap: 16px;
  }
  
  .stat-value {
    font-size: 16px;
  }
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-light);
}

/* ========== 拖拽排序 ========== */
.sortable-list {
  padding: 0 20px;
}

.sortable-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 8px;
  cursor: grab;
  transition: all 0.2s;
}

.sortable-item:hover {
  background: var(--primary-light);
}

.sortable-item.dragging {
  opacity: 0.5;
  background: var(--primary-light);
}

.sort-handle {
  color: var(--text-light);
  font-size: 18px;
}

.sort-num {
  width: 28px;
  height: 28px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

.sort-name {
  font-weight: 500;
}
/* 历史表格考试名称列 - 15字符宽度 */
#historyModal .table-wrap table th:first-child,
#historyModal .table-wrap table td:first-child {
  min-width: 180px;
  max-width: 180px;
  word-break: break-all;
}.chart-controls { margin: 15px 0; } .chart-controls select { padding: 8px 12px; font-size: 14px; border: 1px solid #ddd; border-radius: 4px; }

.btn-refresh {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  margin-left: 4px;
}
.btn-refresh:hover {
  background: var(--hover);
}