:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --primary-dark: #3730a3;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning: #f59e0b;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --border-focus: #818cf8;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: rgba(99, 102, 241, 0.15);
  --primary-dark: #818cf8;
  --success: #34d399;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(52, 211, 153, 0.3);
  --danger: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(248, 113, 113, 0.3);
  --warning: #fbbf24;
  --bg-main: #0b0f19;
  --bg-card: #151c2c;
  --bg-subtle: #1e293b;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-light: #64748b;
  --border-color: #334155;
  --border-focus: #6366f1;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  transition: background-color 0.3s ease, color 0.3s ease;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-sm);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}

.logo-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.logo-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-icon {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.88rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  font-weight: 500;
}

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

/* Package Tabs */
.package-nav-wrapper {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}

.package-nav {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  white-space: nowrap;
}

.package-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 8px 16px;
  border-radius: 9999px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.package-btn:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

.package-btn.active {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}

.package-btn .badge-count {
  background: rgba(0, 0, 0, 0.1);
  padding: 2px 7px;
  border-radius: 9999px;
  font-size: 0.75rem;
}

.package-btn.active .badge-count {
  background: rgba(255, 255, 255, 0.25);
}

/* Main Container */
.main-content {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 20px;
  flex: 1;
  width: 100%;
}

.quiz-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .quiz-layout {
    grid-template-columns: 1fr;
  }
}

/* Quiz Card */
.quiz-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

/* Card Top bar */
.card-header-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 10px;
}

.question-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
}

.question-points {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  background: var(--bg-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}

/* Progress bar */
.progress-container {
  width: 100%;
  height: 8px;
  background-color: var(--bg-subtle);
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 24px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #8b5cf6);
  border-radius: 9999px;
  width: 4%;
  transition: width 0.3s ease;
}

/* Question Statement */
.question-body {
  margin-bottom: 24px;
}

.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text-main);
}

/* Options Container */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.option-item {
  background-color: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
  position: relative;
  text-align: left;
  width: 100%;
}

.option-item:hover:not(.disabled) {
  border-color: var(--border-focus);
  background-color: var(--bg-subtle);
  transform: translateY(-1px);
}

.option-letter {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 50%;
  background-color: var(--bg-subtle);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

.option-text {
  flex: 1;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-main);
  font-weight: 500;
}

.option-status-icon {
  font-size: 1.25rem;
  margin-left: auto;
  opacity: 0;
  transform: scale(0.6);
  transition: var(--transition);
}

/* State: Selected Correct */
.option-item.correct {
  background-color: var(--success-bg) !important;
  border-color: var(--success) !important;
  box-shadow: 0 0 0 2px var(--success-border);
}

.option-item.correct .option-letter {
  background-color: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.option-item.correct .option-text {
  color: #065f46;
  font-weight: 600;
}

[data-theme="dark"] .option-item.correct .option-text {
  color: #a7f3d0;
}

.option-item.correct .option-status-icon {
  color: var(--success);
  opacity: 1;
  transform: scale(1);
}

/* State: Selected Incorrect */
.option-item.wrong {
  background-color: var(--danger-bg) !important;
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 2px var(--danger-border);
}

.option-item.wrong .option-letter {
  background-color: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

.option-item.wrong .option-text {
  color: #991b1b;
  font-weight: 600;
}

[data-theme="dark"] .option-item.wrong .option-text {
  color: #fecaca;
}

.option-item.wrong .option-status-icon {
  color: var(--danger);
  opacity: 1;
  transform: scale(1);
}

/* State: Highlight correct answer when user answered wrong */
.option-item.reveal-correct {
  border-color: var(--success) !important;
  border-style: dashed;
  background-color: var(--success-bg) !important;
}

.option-item.reveal-correct .option-letter {
  background-color: var(--success);
  color: #ffffff;
}

.option-item.reveal-correct::after {
  content: 'Kunci Jawaban';
  position: absolute;
  top: -9px;
  right: 14px;
  background-color: var(--success);
  color: #ffffff;
  font-size: 0.72rem;
  padding: 1px 8px;
  border-radius: 9999px;
  font-weight: 700;
  text-transform: uppercase;
}

.option-item.disabled {
  cursor: default;
}

/* Explanation Accordion Box */
.explanation-box {
  background-color: var(--bg-subtle);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 18px 20px;
  margin-top: 20px;
  display: none;
  animation: fadeIn 0.3s ease;
}

.explanation-box.show {
  display: block;
}

.explanation-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
  margin-bottom: 8px;
}

.explanation-content {
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.6;
}

.explanation-key-tag {
  display: inline-block;
  background-color: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-border);
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  margin-right: 6px;
}

/* Footer Navigation Controls */
.quiz-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-secondary {
  background-color: var(--bg-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--border-color);
}

.btn-success {
  background-color: var(--success);
  color: #ffffff;
}

.btn-success:hover:not(:disabled) {
  filter: brightness(0.92);
}

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

/* Sidebar / Question Grid */
.quiz-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.grid-navigation {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.grid-num-btn {
  height: 40px;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

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

.grid-num-btn.active {
  box-shadow: 0 0 0 2px var(--primary);
  border-color: var(--primary);
  font-weight: 800;
}

.grid-num-btn.correct {
  background-color: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.grid-num-btn.wrong {
  background-color: var(--danger);
  color: #ffffff;
  border-color: var(--danger);
}

/* Stats Widget in Sidebar */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 16px;
  text-align: center;
}

.stat-item {
  background-color: var(--bg-subtle);
  padding: 10px 8px;
  border-radius: var(--radius-sm);
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  display: block;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.stat-item.stat-correct .stat-value { color: var(--success); }
.stat-item.stat-wrong .stat-value { color: var(--danger); }
.stat-item.stat-answered .stat-value { color: var(--primary); }

/* Score Modal / Result Screen */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

.modal-overlay.show {
  display: flex;
}

.modal-dialog {
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 650px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  text-align: center;
  position: relative;
}

.score-badge-circle {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.35);
}

.score-number {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
}

.score-max {
  font-size: 0.8rem;
  opacity: 0.85;
}

.modal-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
}

.modal-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 24px;
}

.results-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.result-card {
  background-color: var(--bg-subtle);
  padding: 14px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.result-card .rc-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.result-card .rc-lbl {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Study Mode / All Questions Table */
.study-mode-container {
  display: none;
}

.study-mode-container.show {
  display: block;
}

.search-filter-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 260px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.study-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.study-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-focus);
}

.study-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.study-num-badge {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.study-options-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 16px 0;
}

.study-opt-line {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  font-size: 0.95rem;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.study-opt-line.correct-key {
  background-color: var(--success-bg);
  border: 1px solid var(--success-border);
  color: #065f46;
  font-weight: 600;
}

[data-theme="dark"] .study-opt-line.correct-key {
  color: #a7f3d0;
}

.study-opt-key {
  font-weight: 700;
  min-width: 24px;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Toast alert */
.toast-notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: #1e293b;
  color: #f8fafc;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 999;
  display: none;
  animation: fadeIn 0.2s ease;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 24px 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-card);
  margin-top: auto;
}


/* ========================================================
   AUTHENTICATION GATE & LOGIN SCREEN
   ======================================================== */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(139, 92, 246, 0.08)), var(--bg-main);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(8px);
}

.login-screen.hidden {
  display: none;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 36px 32px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  text-align: center;
  animation: fadeIn 0.3s ease;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 18px;
  box-shadow: 0 10px 20px rgba(79, 70, 229, 0.3);
}

.login-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 6px;
}

.login-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: var(--transition);
  font-family: inherit;
}

.form-input:focus {
  border-color: var(--primary);
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-input.uppercase {
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 1px;
}

.login-alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  display: none;
  line-height: 1.4;
  margin-top: 4px;
}

.login-alert.show {
  display: block;
}

.login-alert.danger {
  background: var(--danger-bg);
  color: #b91c1c;
  border: 1px solid var(--danger-border);
}

[data-theme="dark"] .login-alert.danger {
  color: #fca5a5;
}

.login-alert.success {
  background: var(--success-bg);
  color: #047857;
  border: 1px solid var(--success-border);
}

.btn-login-submit {
  width: 100%;
  padding: 13px;
  font-size: 1rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  transition: var(--transition);
  margin-top: 6px;
}

.btn-login-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

.login-footer-links {
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  border-top: 1px solid var(--border-color);
  padding-top: 16px;
}

.login-footer-links a, .login-footer-links button {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
}

.login-footer-links a:hover, .login-footer-links button:hover {
  text-decoration: underline;
}

/* User Profile Badge in Header */
.user-profile-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.82rem;
  font-weight: 600;
}

.user-profile-badge .user-name {
  color: var(--text-main);
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-profile-badge .user-token {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 800;
}

/* Live Online Status Indicator */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-pill.online {
  background: var(--success-bg);
  color: #047857;
  border: 1px solid var(--success-border);
}

[data-theme="dark"] .status-pill.online {
  color: #34d399;
}

.status-pill.offline {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.online {
  background-color: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse-dot 1.8s infinite;
}

.status-dot.offline {
  background-color: #94a3b8;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ========================================================
   ADMIN DASHBOARD & CONTROLS
   ======================================================== */
.admin-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.admin-modal.show {
  display: flex;
}

.admin-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 1050px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.25s ease;
}

.admin-header {
  padding: 20px 24px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-header-title h2 {
  font-size: 1.3rem;
  font-weight: 800;
}

.admin-tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-top: 4px;
}

.admin-tab-btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-tab-btn:hover {
  color: var(--text-main);
}

.admin-tab-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.admin-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.admin-tab-content {
  display: none;
}

.admin-tab-content.show {
  display: block;
}

/* Admin Stats Cards */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.admin-stat-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.admin-stat-info .stat-num {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.admin-stat-info .stat-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

/* Generator Box */
.generator-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 24px;
}

.generator-form {
  display: grid;
  grid-template-columns: 1fr 140px 180px;
  gap: 12px;
  align-items: end;
}

@media (max-width: 768px) {
  .generator-form {
    grid-template-columns: 1fr;
  }
}

.new-tokens-alert {
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-top: 14px;
  display: none;
  animation: fadeIn 0.2s ease;
}

.new-tokens-alert.show {
  display: block;
}

.new-tokens-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.token-pill-badge {
  background: var(--bg-card);
  color: #047857;
  padding: 4px 10px;
  border-radius: 4px;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.95rem;
  border: 1px solid var(--success-border);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

[data-theme="dark"] .token-pill-badge {
  color: #34d399;
}

/* Admin Tables */
.admin-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.admin-table th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 700;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover {
  background: var(--bg-subtle);
}

.badge-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-tag.active {
  background: var(--primary-light);
  color: var(--primary);
}

.badge-tag.used {
  background: var(--danger-bg);
  color: #b91c1c;
}

[data-theme="dark"] .badge-tag.used {
  color: #fca5a5;
}

/* Action button inside table */
.btn-table-action {
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: var(--transition);
}

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

.btn-table-action.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Auth Modal for Admin PIN */
.pin-dialog {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 400px;
  width: 100%;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
