:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --accent: #e74c3c;
  --bg: #f0f4f8;
  --card-bg: #ffffff;
  --text: #2c3e50;
  --text-light: #7f8c8d;
  --border: #d5dbdb;
  --success: #27ae60;
  --warning: #f39c12;
  --danger: #e74c3c;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

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

#app { min-height: 100vh; }

/* ===== Header ===== */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 20px 30px;
  box-shadow: var(--shadow);
}
.header h1 { font-size: 22px; font-weight: 600; }
.header p { font-size: 14px; opacity: 0.85; margin-top: 4px; }
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}
.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.header-user .badge {
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 20px;
}
.header-user .btn-logout {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.header-user .btn-logout:hover { background: rgba(255,255,255,0.25); }

/* ===== Container ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 20px;
}

/* ===== Cards ===== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
}
.card h2 { font-size: 18px; color: var(--primary); margin-bottom: 16px; }
.card h3 { font-size: 16px; color: var(--text); margin-bottom: 12px; }

/* ===== Home Page ===== */
.hero {
  text-align: center;
  padding: 60px 20px;
}
.hero h1 {
  font-size: 32px;
  color: var(--primary);
  margin-bottom: 10px;
}
.hero p {
  font-size: 16px;
  color: var(--text-light);
  margin-bottom: 40px;
}
.role-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 900px;
  margin: 0 auto;
}
.role-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 36px 28px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  border: 2px solid transparent;
}
.role-card:hover {
  border-color: var(--primary-light);
  transform: translateY(-4px);
}
.role-card .icon { font-size: 40px; margin-bottom: 16px; }
.role-card h3 { font-size: 20px; color: var(--primary); margin-bottom: 8px; }
.role-card p { font-size: 14px; color: var(--text-light); }

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary-light);
}
.form-group textarea { min-height: 180px; resize: vertical; }

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

/* ===== Buttons ===== */
.btn {
  display: inline-block;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-light); }
.btn-primary:disabled { background: #95a5a6; cursor: not-allowed; }
.btn-secondary {
  background: white;
  color: var(--primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #ecf0f1; }
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover { background: #c0392b; }
.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover { background: #229954; }
.btn-lg { padding: 14px 32px; font-size: 16px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* ===== Alert/Messages ===== */
.alert {
  padding: 12px 18px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}
.alert-error { background: #fadbd8; color: #c0392b; border: 1px solid #e74c3c; }
.alert-success { background: #d4efdf; color: #1e8449; border: 1px solid #27ae60; }
.alert-info { background: #d6eaf8; color: #2471a3; border: 1px solid #3498db; }
.alert-warning { background: #fef9e7; color: #b7950b; border: 1px solid #f39c12; }

/* ===== Timer ===== */
.timer-bar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: white;
  padding: 12px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.timer-display {
  font-size: 28px;
  font-weight: 700;
  font-family: "Courier New", monospace;
}
.timer-display.warning { color: #f39c12; }
.timer-display.danger { color: #e74c3c; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.6; } }
.timer-info { font-size: 13px; opacity: 0.85; }

/* ===== Question Selection ===== */
.question-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}
.question-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  cursor: pointer;
  transition: all 0.2s;
}
.question-card:hover { border-color: var(--primary-light); }
.question-card.selected { border-color: var(--success); background: #f0faf4; }
.question-card.claimed { border-color: var(--text-light); opacity: 0.6; }
.question-card .q-num {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 10px;
}
.question-card .q-type {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 8px;
}
.question-card h3 { font-size: 17px; margin-bottom: 8px; }
.question-card .claim-badge {
  display: inline-block;
  background: var(--text-light);
  color: white;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  margin-top: 8px;
}

/* ===== Exam Interface ===== */
.exam-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  margin-top: 0;
}
.exam-main { max-width: 100%; }
.exam-sidebar {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  height: fit-content;
  position: sticky;
  top: 80px;
}
.exam-sidebar h3 { font-size: 14px; margin-bottom: 12px; color: var(--primary); }
.download-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 8px;
  text-decoration: none;
  color: var(--primary);
  font-size: 13px;
  transition: background 0.2s;
}
.download-item:hover { background: #eaf2f8; }
.download-item .dl-icon { font-size: 18px; }

/* ===== Question Content ===== */
.question-content {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
}
.question-content h2 { color: var(--primary); font-size: 20px; margin-bottom: 16px; }
.question-content h3 { color: var(--text); font-size: 16px; margin: 18px 0 10px; }
.question-content p { margin-bottom: 12px; line-height: 1.8; }
.question-content ul, .question-content ol { margin: 8px 0 12px 20px; }
.question-content li { margin-bottom: 6px; line-height: 1.7; }
.question-content table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.question-content th, .question-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  font-size: 14px;
}
.question-content th { background: #eaf2f8; font-weight: 600; }

/* ===== Submission ===== */
.submit-section {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-top: 24px;
}
.char-count { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.char-count.ok { color: var(--success); }
.char-count.warn { color: var(--danger); }
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.file-upload-area:hover { border-color: var(--primary-light); background: #f8fbfc; }
.file-upload-area.has-file { border-color: var(--success); background: #f0faf4; }
.file-info { font-size: 13px; margin-top: 8px; }

/* ===== Judge Interface ===== */
.judge-list {
  width: 100%;
  border-collapse: collapse;
}
.judge-list th, .judge-list td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}
.judge-list th { background: #eaf2f8; font-weight: 600; }
.judge-list tr { cursor: pointer; transition: background 0.15s; }
.judge-list tr:hover { background: #f8fbfc; }
.judge-list .status-badge {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.status-badge.submitted { background: #d4efdf; color: #1e8449; }
.status-badge.pending { background: #fadbd8; color: #c0392b; }
.status-badge.scored { background: #d6eaf8; color: #2471a3; }

/* Score form */
.score-form { max-width: 700px; }
.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.score-item label {
  display: block;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--text);
}
.score-item .max-label { font-size: 12px; color: var(--text-light); }
.score-item input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
}
.score-total {
  background: #eaf2f8;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 16px;
}

/* ===== Admin Dashboard ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  text-align: center;
}
.stat-card .stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }

.rank-table {
  width: 100%;
  border-collapse: collapse;
}
.rank-table th, .rank-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}
.rank-table th { background: #eaf2f8; font-weight: 600; }
.rank-table .rank-1 { color: #f39c12; font-weight: 700; }
.rank-table .rank-2 { color: #95a5a6; font-weight: 600; }
.rank-table .rank-3 { color: #cd7f32; font-weight: 600; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}
.tab {
  padding: 10px 24px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .exam-layout { grid-template-columns: 1fr; }
  .exam-sidebar { position: static; }
  .header-bar { flex-direction: column; gap: 10px; }
  .score-grid { grid-template-columns: 1fr; }
}
