/* =========================================
   InsureAcademy - Modern Dashboard UI
   ========================================= */

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

:root {
  --sidebar-width: 220px;
  --topbar-height: 60px;
  --bg: #f4f6f9;
  --sidebar-bg: #1e2235;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active-bg: rgba(67,97,238,0.18);
  --sidebar-active-text: #6a8fff;
  --white: #ffffff;
  --primary: #4361ee;
  --primary-dark: #3451d1;
  --primary-light: #eef1fd;
  --success: #10b981;
  --success-light: #ecfdf5;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --purple: #8b5cf6;
  --purple-light: #f5f3ff;
  --text-primary: #1e2235;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition: 150ms ease;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
}

/* =========================================
   App Layout
   ========================================= */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* =========================================
   Sidebar
   ========================================= */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  margin-bottom: 6px;
  flex-shrink: 0;
}

.sidebar-logo-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: white;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.logo-text {
  color: white;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.28);
  padding: 14px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: rgba(255,255,255,0.85);
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

/* =========================================
   Main Wrapper
   ========================================= */
.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* =========================================
   Topbar
   ========================================= */
.topbar {
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.score-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
}

/* =========================================
   Page Content
   ========================================= */
.page-content {
  padding: 24px;
  flex: 1;
}

/* =========================================
   Buttons
   ========================================= */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  font-family: var(--font);
  white-space: nowrap;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(67,97,238,0.3);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.btn-secondary:hover {
  background: var(--bg);
  color: var(--text-primary);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg);
  color: var(--text-primary);
}

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

.btn-lg {
  padding: 11px 24px;
  font-size: 15px;
}

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

.hidden {
  display: none !important;
}

/* =========================================
   Stats Row (Dashboard)
   ========================================= */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-card-icon svg {
  width: 20px;
  height: 20px;
}

.stat-card-icon.blue { background: var(--primary-light); color: var(--primary); }
.stat-card-icon.green { background: var(--success-light); color: var(--success); }
.stat-card-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-card-icon.purple { background: var(--purple-light); color: var(--purple); }

.stat-card-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
  margin-top: 14px;
}

.stat-card-label {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* =========================================
   Module Tabs
   ========================================= */
.module-tabs-row {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.module-tabs-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-right: 4px;
}

.module-tab {
  padding: 8px 18px;
  margin-right: 8px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.module-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.module-tab:last-child {
  margin-right: 0;
}

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

/* =========================================
   Section Cards (Practice Modes)
   ========================================= */
.dashboard-summary {
  margin-bottom: 22px;
}

.dashboard-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
}

@media (max-width: 900px) {
  .dashboard-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.active-modules-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.active-module-toggle {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.active-module-toggle:hover {
  border-color: var(--text-muted);
}

.active-module-toggle.active {
  border-color: var(--primary);
  background: var(--primary-light, #eef2ff);
  color: var(--primary);
}

.dashboard-summary-item {
  padding: 4px 0;
}

.dashboard-summary-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 4px;
}

.dashboard-summary-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.section-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 18px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.section-label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  margin-bottom: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

/* quiz-btn = the option buttons on selection page */
.quiz-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
}

.quiz-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

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

.quiz-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* =========================================
   Confirmation Banner
   ========================================= */
.confirm-banner {
  background: var(--primary-light);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius);
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
}

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

.confirm-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--primary);
}

.confirm-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.confirm-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* selected-detail classes used by selection.js */
.selected-detail {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 6px;
}

.selected-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.selected-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.selected-note {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(67,97,238,0.15);
}

/* =========================================
   Quiz Page
   ========================================= */
.quiz-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

.question-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}

.question-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.question-number-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.progress-track {
  height: 4px;
  background: var(--border);
  border-radius: var(--radius-full);
  margin-bottom: 22px;
  overflow: hidden;
}

/* progressFill ID used by JS */
#progressFill, .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7b9fff);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
  width: 0%;
}

.question-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: 22px;
  white-space: pre-line;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* option class used by quiz.js to create answer options */
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  background: var(--white);
  margin-bottom: 9px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.option.correct {
  border-color: var(--success);
  background: var(--success-light);
}

.option.incorrect {
  border-color: var(--danger);
  background: var(--danger-light);
}

.option-label {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--bg);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.option.selected .option-label {
  background: var(--primary);
  color: white;
}

.option.correct .option-label {
  background: var(--success);
  color: white;
}

.option.incorrect .option-label {
  background: var(--danger);
  color: white;
}

.option-text {
  font-size: 13.5px;
  color: var(--text-primary);
  line-height: 1.55;
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.question-actions {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-top: 6px;
}

/* =========================================
   Feedback Panel
   ========================================= */
.feedback-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
}

.feedback-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.feedback-content {
  min-height: 120px;
}

.placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-size: 13px;
  text-align: center;
  padding: 30px 0;
}

/* feedback-result and feedback-explanation are created by quiz.js innerHTML */
.feedback-result {
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 14px;
}

.feedback-result.correct {
  background: var(--success-light);
  border-left: 4px solid var(--success);
}

.feedback-result.incorrect {
  background: var(--danger-light);
  border-left: 4px solid var(--danger);
}

.feedback-result h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.feedback-result.correct h3 { color: var(--success); }
.feedback-result.incorrect h3 { color: var(--danger); }

.feedback-result p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 4px;
  line-height: 1.55;
}

.feedback-explanation {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 13px;
  border-left: 3px solid var(--primary);
}

.feedback-explanation h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.feedback-explanation p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* loading and noQuestions */
.loading, .no-questions {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================
   Results Page
   ========================================= */
.results-layout {
  max-width: 860px;
  margin: 0 auto;
}

.score-hero {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  text-align: center;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

/* score-circle is referenced by results.js querySelector */
.score-circle {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 8px solid var(--primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 22px;
  background: var(--primary-light);
  transition: border-color 0.3s;
}

.score-number {
  font-size: 40px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.score-total {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

.score-percentage {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.results-stats {
  display: flex;
  justify-content: center;
  gap: 36px;
  margin-bottom: 26px;
}

.stat-item {
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-value.correct { color: var(--success); }
.stat-value.incorrect { color: var(--danger); }

.results-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* Review Section */
.review-section {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-top: 18px;
}

.review-section h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* review-item and related classes are created by results.js innerHTML */
.review-item {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  border-left: 4px solid var(--border);
  background: var(--bg);
}

.review-item.correct { border-left-color: var(--success); }
.review-item.incorrect { border-left-color: var(--danger); }

.review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.review-number {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.review-status {
  font-size: 12px;
  font-weight: 600;
}

.review-item.correct .review-status { color: var(--success); }
.review-item.incorrect .review-status { color: var(--danger); }

.review-question {
  font-size: 13.5px;
  color: var(--text-primary);
  line-height: 1.55;
  margin-bottom: 10px;
}

.review-answers {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.review-answer {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 6px 10px;
  background: var(--white);
  border-radius: var(--radius-sm);
}

.review-answer.correct {
  background: var(--success-light);
  color: var(--success);
}

/* =========================================
   History Page
   ========================================= */
.history-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

.analytics-panel {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
}

.analytics-panel h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* stats-grid and stat-card are created by history.js innerHTML */
.analytics-panel .stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
  width: 100%;
  max-width: 100%;
  margin-left: 0;
  margin-right: 0;
}

.analytics-panel .stat-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  border: none;
}

.analytics-panel .stat-card .stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}

.analytics-panel .stat-card .stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

/* lo-item and related created by history.js */
.lo-performance {
  margin-bottom: 20px;
}

.lo-item {
  margin-bottom: 14px;
}

.lo-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}

.lo-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.lo-score {
  font-size: 13px;
  font-weight: 700;
}

.lo-score.excellent { color: var(--success); }
.lo-score.good { color: var(--warning); }
.lo-score.needs-work { color: var(--danger); }

.lo-bar {
  height: 5px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 3px;
}

.lo-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.lo-bar-fill.excellent { background: var(--success); }
.lo-bar-fill.good { background: var(--warning); }
.lo-bar-fill.needs-work { background: var(--danger); }

.lo-details {
  font-size: 11.5px;
  color: var(--text-muted);
}

.weak-areas {
  margin-top: 8px;
}

/* weak-areas-list li created by history.js innerHTML */
.weak-areas-list {
  list-style: none;
  padding: 0;
}

.weak-areas-list li {
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--danger-light);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--danger);
  font-weight: 500;
}

.history-panel {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

.history-panel h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.history-list {
  max-height: 70vh;
  overflow-y: auto;
}

/* history-item and related created by history.js innerHTML */
.history-item {
  padding: 14px 16px;
  margin-bottom: 9px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--primary);
  transition: all var(--transition);
}

.history-item:hover {
  background: var(--primary-light);
  border-left-color: var(--primary);
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 10px;
  flex-wrap: wrap;
}

.history-date {
  color: var(--text-muted);
  font-size: 12px;
}

.history-mode {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 13px;
  flex: 1;
}

.history-score {
  font-weight: 700;
  font-size: 15px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
}

.history-score.excellent {
  background: var(--success-light);
  color: var(--success);
}

.history-score.good {
  background: var(--warning-light);
  color: var(--warning);
}

.history-score.needs-work {
  background: var(--danger-light);
  color: var(--danger);
}

.history-details {
  color: var(--text-secondary);
  font-size: 12.5px;
  display: flex;
  gap: 8px;
}

/* Current units on dashboard */
.current-units-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.current-unit-row {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.current-unit-main {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 2px;
}

.current-unit-code {
  font-weight: 600;
  font-size: 13px;
  color: var(--text-primary);
}

.current-unit-title {
  font-size: 13px;
  color: var(--text-secondary);
}

.current-unit-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

.current-units-footer {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}

/* =========================================
   Exam Planner
   ========================================= */

.planner-view-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
}

.planner-view-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.planner-view-btn:hover {
  background: var(--bg);
  color: var(--text-primary);
}

.planner-view-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.planner-summary {
  margin-bottom: 22px;
}

.planner-add-module {
  margin-bottom: 22px;
}

.planner-add-module-select {
  display: block;
  width: 100%;
  max-width: 420px;
  margin-top: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-primary);
}

.planner-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.planner-summary-text {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.planner-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.planner-summary-card {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.planner-summary-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.planner-summary-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.planner-summary-caption {
  font-size: 11.5px;
  color: var(--text-muted);
}

.planner-modules-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.planner-section.planner-section-vertical {
  width: 100%;
}

.planner-section.planner-section-vertical .section-card {
  width: 100%;
}

.planner-help-text {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.planner-table-wrapper {
  overflow-x: auto;
  margin-bottom: 10px;
}

.planner-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.planner-table th,
.planner-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.planner-table th {
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.planner-input {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 4px 6px;
  font-size: 12.5px;
  font-family: inherit;
  background: var(--white);
}

.planner-input-small {
  max-width: 72px;
}

.planner-cell-center {
  text-align: center;
}

.planner-row-done {
  background: var(--success-light) !important;
  border-left: 4px solid var(--success);
}

.planner-row-done td {
  border-color: rgba(16, 185, 129, 0.2);
}

.planner-tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.planner-tick:hover {
  border-color: var(--text-muted);
}

.planner-tick-svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.planner-tick-done {
  border-color: var(--success);
  background: var(--success-light);
}

.planner-tick-done .planner-tick-svg {
  color: var(--success);
}

.planner-tick-disabled,
.planner-tick:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.planner-row-studying {
  background: var(--primary-light) !important;
  border-left: 4px solid var(--primary);
}

.planner-row-studying td {
  border-color: rgba(67, 97, 238, 0.15);
}

.planner-th-studying {
  min-width: 100px;
  white-space: nowrap;
}

.planner-studying-checkbox {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.planner-cell-credits,
.planner-cell-hours {
  font-size: 12.5px;
  color: var(--text-primary);
  white-space: nowrap;
}

.planner-unit-select {
  min-width: 240px;
}

.planner-exemption-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.planner-exemption-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.planner-exemption-input {
  width: 64px;
  padding: 4px 8px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.planner-criteria-status {
  margin-top: 6px;
  font-size: 12px;
}

.planner-met-yes {
  color: var(--success);
  font-weight: 500;
}

.planner-met-no {
  color: var(--text-muted);
}

.planner-remove-row {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.planner-remove-row:hover {
  color: var(--danger);
}

.planner-actions {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.planner-save-status {
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* Calendar view */
.planner-calendar-view {
  margin-top: 0;
}

.planner-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.planner-calendar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.planner-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.planner-calendar-day {
  min-height: 90px;
  padding: 6px;
  background: var(--white);
  font-size: 12px;
}

.planner-calendar-day.planner-calendar-weekday {
  min-height: auto;
  padding: 8px 6px;
  font-weight: 600;
  color: var(--text-secondary);
}

.planner-calendar-day-header {
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-size: 11px;
}

.planner-calendar-day.other-month .planner-calendar-day-header {
  color: var(--text-muted);
}

.planner-calendar-day.other-month {
  background: var(--bg);
}

.planner-calendar-event {
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.planner-calendar-event.certificate {
  background: var(--primary-light);
  color: var(--primary);
}

.planner-calendar-event.diploma {
  background: var(--purple-light);
  color: var(--purple);
}

.planner-calendar-event.advanced {
  background: var(--success-light);
  color: var(--success);
}

.planner-calendar-legend {
  display: flex;
  gap: 16px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.planner-calendar-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.certificate { background: var(--primary); }
.legend-dot.diploma { background: var(--purple); }
.legend-dot.advanced { background: var(--success); }

/* =========================================
   Login Page
   ========================================= */
.login-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 13.5px;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 26px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
}

.form-input::placeholder { color: var(--text-muted); }

.error-alert {
  background: var(--danger-light);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13px;
  color: var(--danger);
  margin-bottom: 16px;
}

.login-submit {
  width: 100%;
  margin-top: 8px;
  padding: 11px;
  font-size: 14px;
  justify-content: center;
  text-align: center;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition);
}
.btn-google:hover {
  background: var(--bg);
}

.login-divider {
  text-align: center;
  margin: 16px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}
.login-footer a {
  color: var(--primary);
  text-decoration: none;
}
.login-footer a:hover {
  text-decoration: underline;
}

.success-alert {
  background: var(--success-light);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13px;
  color: var(--success);
  margin-bottom: 16px;
}

.pricing-cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 20px 0;
}
.pricing-card {
  flex: 1;
  min-width: 180px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--white);
  text-align: center;
  position: relative;
}
.pricing-card-featured {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(67,97,238,0.15);
}
.pricing-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 0 8px;
  border-radius: var(--radius-full);
}
.pricing-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 8px;
}
.pricing-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.pricing-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.subscribe-btn {
  width: 100%;
  margin-top: 8px;
}

/* =========================================
   Responsive
   ========================================= */
@media (max-width: 1100px) {
  .quiz-layout {
    grid-template-columns: 1fr;
  }

  .feedback-card {
    position: static;
  }

  .history-layout {
    grid-template-columns: 1fr;
  }

  .analytics-panel {
    position: static;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

  .sidebar {
    display: none;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .page-content {
    padding: 16px;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .results-stats {
    flex-wrap: wrap;
    gap: 20px;
  }

  .confirm-banner {
    flex-direction: column;
    align-items: flex-start;
  }
}
