/* ============================================================
   COMPUTER REPAIR SCORE SYSTEM — DESIGN SYSTEM
   Noto Sans Thai + Inter | Dark Mode | Glassmorphism
   ============================================================ */

/* ── 1. GOOGLE FONTS ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+Thai:wght@300;400;500;600;700;800&display=swap');

/* ── 2. CSS RESET ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: 'Noto Sans Thai', 'Inter', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; line-height: 1.6; -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul, ol { list-style: none; }
table { border-collapse: collapse; }

/* ── 3. CSS VARIABLES ────────────────────────────────────── */
:root {
  /* Colors */
  --bg:              #0a0d16;
  --bg-card:         #111827;
  --bg-elevated:     #1a2236;
  --bg-input:        #1e2a42;
  --border:          #1e2a42;
  --border-light:    #2a3a5c;
  --primary:         #6c8ef5;
  --primary-dark:    #4f6ee0;
  --primary-glow:    rgba(108,142,245,0.2);
  --primary-glow-lg: rgba(108,142,245,0.12);
  --secondary:       #a78bfa;
  --secondary-glow:  rgba(167,139,250,0.2);
  --success:         #34d399;
  --success-bg:      rgba(52,211,153,0.12);
  --warning:         #fbbf24;
  --warning-bg:      rgba(251,191,36,0.12);
  --danger:          #f87171;
  --danger-bg:       rgba(248,113,113,0.12);
  --text:            #e2e8f0;
  --text-muted:      #64748b;
  --text-dim:        #94a3b8;

  /* Gradients */
  --grad-primary:  linear-gradient(135deg, #6c8ef5 0%, #a78bfa 100%);
  --grad-success:  linear-gradient(135deg, #34d399 0%, #059669 100%);
  --grad-danger:   linear-gradient(135deg, #f87171 0%, #dc2626 100%);
  --grad-warning:  linear-gradient(135deg, #fbbf24 0%, #d97706 100%);
  --grad-bg:       linear-gradient(135deg, #0a0d16 0%, #0f172a 50%, #0a0d16 100%);

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow:      0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.6);
  --shadow-xl:   0 16px 64px rgba(0,0,0,0.7);
  --shadow-glow: 0 0 24px var(--primary-glow);

  /* Radii */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full: 9999px;

  /* Spacing */
  --space-1: 4px; --space-2: 8px; --space-3: 12px;
  --space-4: 16px; --space-5: 20px; --space-6: 24px;
  --space-8: 32px; --space-10: 40px; --space-12: 48px;

  /* Transitions */
  --trans-fast:   all 0.15s ease;
  --trans-normal: all 0.25s ease;
  --trans-slow:   all 0.4s ease;

  /* Sidebar */
  --sidebar-w: 240px;

  /* Z-indexes */
  --z-dropdown: 100;
  --z-modal:    200;
  --z-toast:    300;
  --z-savebar:  150;
}

/* ── 4. KEYFRAME ANIMATIONS ──────────────────────────────── */
@keyframes fadeIn     { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp    { from { opacity: 0; transform: translateY(24px) } to { opacity: 1; transform: translateY(0) } }
@keyframes slideIn    { from { opacity: 0; transform: translateX(40px) } to { opacity: 1; transform: translateX(0) } }
@keyframes slideDown  { from { opacity: 0; transform: translateY(-16px) } to { opacity: 1; transform: translateY(0) } }
@keyframes flashGreen { 0%,100% { border-color: var(--border-light); box-shadow: none; } 30% { border-color: var(--success); box-shadow: 0 0 12px rgba(52,211,153,0.4); } }
@keyframes pulse      { 0%,100% { opacity: 1 } 50% { opacity: 0.5 } }
@keyframes shimmer    { from { background-position: -200% 0 } to { background-position: 200% 0 } }
@keyframes spin       { to { transform: rotate(360deg) } }
@keyframes scaleIn    { from { transform: scale(0.9); opacity: 0 } to { transform: scale(1); opacity: 1 } }
@keyframes glow       { 0%,100% { box-shadow: 0 0 8px var(--primary-glow) } 50% { box-shadow: 0 0 24px var(--primary-glow), 0 0 48px var(--primary-glow-lg) } }

/* ── 5. SCROLLBAR ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-card); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ── 6. LAYOUT ───────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  overflow-y: auto;
  transition: transform 0.3s ease;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: 64px;
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.content {
  flex: 1;
  padding: var(--space-6);
  animation: fadeIn 0.3s ease;
}

/* ── 7. SIDEBAR ──────────────────────────────────────────── */
.logo {
  padding: var(--space-5) var(--space-5) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.logo-icon {
  width: 40px;
  height: 40px;
  background: var(--grad-primary);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: var(--space-3);
  box-shadow: 0 0 20px var(--primary-glow);
}

.logo-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.logo-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.nav-section {
  padding: var(--space-4) var(--space-3);
  flex: 1;
}

.nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--trans-fast);
  margin-bottom: 2px;
  position: relative;
  overflow: hidden;
}

.nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.nav-item .nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
}

/* ── 8. CARDS ────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  animation: slideUp 0.3s ease;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.glass-card {
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255,255,255,0.05);
}

/* Stat Cards */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  transition: var(--trans-normal);
  animation: slideUp 0.3s ease;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(108,142,245,0.04) 100%);
  pointer-events: none;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--primary-glow);    }
.stat-icon.green  { background: var(--success-bg);      }
.stat-icon.red    { background: var(--danger-bg);       }
.stat-icon.purple { background: var(--secondary-glow);  }
.stat-icon.yellow { background: var(--warning-bg);      }

.stat-body { flex: 1; }

.stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-delta {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 4px;
}

/* ── 9. BUTTONS ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  transition: var(--trans-fast);
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
  line-height: 1.4;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 2px 12px var(--primary-glow);
}
.btn-primary:hover { box-shadow: 0 4px 20px var(--primary-glow), 0 0 0 1px rgba(108,142,245,0.3); transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-dim);
  border-color: var(--border-light);
}
.btn-secondary:hover { background: var(--border-light); color: var(--text); }

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(248,113,113,0.3);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-success {
  background: var(--success-bg);
  color: var(--success);
  border-color: rgba(52,211,153,0.3);
}
.btn-success:hover { background: var(--success); color: #fff; }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border-light);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text); }

.btn-sm {
  padding: 0.3rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
  border-radius: var(--radius-lg);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

/* ── 10. FORMS ───────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  padding: 0.6rem 0.9rem;
  width: 100%;
  transition: var(--trans-fast);
  outline: none;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

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

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%2364748b' d='M8 10.5L3 5.5h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  padding-right: 2.5rem;
  cursor: pointer;
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: -var(--space-1);
}

/* Search + filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.search-wrap .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.9rem;
}

.search-wrap .form-input {
  padding-left: 2.4rem;
}

/* ── 11. TABLES ──────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  font-size: 0.875rem;
}

thead {
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 2;
}

thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: var(--trans-fast);
}

thead th:hover { color: var(--text); }
thead th.sort-asc::after  { content: ' ↑'; color: var(--primary); }
thead th.sort-desc::after { content: ' ↓'; color: var(--primary); }

tbody tr {
  border-bottom: 1px solid rgba(30,42,66,0.6);
  transition: background 0.15s ease;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-elevated); }
tbody tr:nth-child(even) { background: rgba(26,34,54,0.3); }
tbody tr:nth-child(even):hover { background: var(--bg-elevated); }

td {
  padding: var(--space-3) var(--space-4);
  color: var(--text-dim);
  vertical-align: middle;
}

td.td-center { text-align: center; }
td.td-right  { text-align: right; }
td.td-bold   { font-weight: 700; color: var(--text); }
td.td-mono   { font-family: 'Inter', monospace; }

.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ── 12. BADGES ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-pass {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(52,211,153,0.3);
}

.badge-fail {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(248,113,113,0.3);
}

.badge-primary {
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(108,142,245,0.3);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(251,191,36,0.3);
}

.badge-unit-1 { background: rgba(108,142,245,0.15); color: #6c8ef5; border: 1px solid rgba(108,142,245,0.3); }
.badge-unit-2 { background: rgba(167,139,250,0.15); color: #a78bfa; border: 1px solid rgba(167,139,250,0.3); }
.badge-unit-3 { background: rgba(52,211,153,0.15);  color: #34d399; border: 1px solid rgba(52,211,153,0.3);  }
.badge-unit-4 { background: rgba(251,191,36,0.15);  color: #fbbf24; border: 1px solid rgba(251,191,36,0.3);  }
.badge-unit-5 { background: rgba(248,113,113,0.15); color: #f87171; border: 1px solid rgba(248,113,113,0.3); }

/* ── 13. PROGRESS BARS ───────────────────────────────────── */
.progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  flex: 1;
}

.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.progress-fill.success { background: var(--grad-success); }
.progress-fill.warning { background: var(--grad-warning); }
.progress-fill.danger  { background: var(--grad-danger);  }
.progress-fill.primary { background: var(--grad-primary); }

.progress-labeled {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.progress-label-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  min-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  min-width: 42px;
  text-align: right;
}

/* ── 14. MODAL ───────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-lg { max-width: 720px; }

.modal-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: var(--trans-fast);
  background: none;
  border: none;
  cursor: pointer;
}

.modal-close:hover { background: var(--bg-elevated); color: var(--text); }

.modal-body    { padding: var(--space-6); }
.modal-footer  {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ── 15. TOAST NOTIFICATIONS ─────────────────────────────── */
.toast-container {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  pointer-events: all;
  min-width: 280px;
  max-width: 380px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger);  }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info    { border-left: 4px solid var(--primary); }

.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger);  }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info    .toast-icon { color: var(--primary); }
.toast-msg { flex: 1; }

.toast-exit { animation: slideIn 0.3s ease reverse; }

/* ── 16. SCORE INPUT ─────────────────────────────────────── */
.score-input {
  width: 70px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.875rem;
  font-family: 'Inter', monospace;
  font-weight: 600;
  padding: 0.3rem 0.5rem;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

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

.score-input.changed {
  border-color: var(--warning);
  box-shadow: 0 0 0 2px rgba(251,191,36,0.2);
  background: rgba(251,191,36,0.06);
}

.score-input.saved {
  animation: flashGreen 1s ease;
  border-color: var(--success);
}

.score-cell {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.score-max {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ── 17. SAVE BAR ────────────────────────────────────────── */
.save-bar {
  position: fixed;
  bottom: 0; left: var(--sidebar-w); right: 0;
  background: rgba(17, 24, 39, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-light);
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: var(--z-savebar);
  animation: slideDown 0.3s ease;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.4);
}

.save-bar-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 0.875rem;
  color: var(--text-dim);
}

.save-bar-count {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(251,191,36,0.3);
  border-radius: var(--radius-full);
  padding: 2px 10px;
  font-weight: 700;
  font-size: 0.8rem;
}

.save-bar-actions { display: flex; gap: var(--space-3); }
.save-bar.hidden  { display: none; }

/* ── 18. UNIT TABS ───────────────────────────────────────── */
.unit-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  overflow-x: auto;
  padding-bottom: 2px;
}

.unit-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--trans-fast);
  white-space: nowrap;
  min-width: 120px;
  text-align: center;
  gap: 2px;
}

.unit-tab:hover { background: var(--bg-elevated); color: var(--text); border-color: var(--primary); }

.unit-tab.active {
  background: var(--primary-glow);
  color: var(--primary);
  border-color: rgba(108,142,245,0.5);
  font-weight: 600;
}

.unit-tab-name { font-weight: 600; font-size: 0.78rem; }
.unit-tab-meta { font-size: 0.7rem; color: inherit; opacity: 0.8; display: flex; align-items: center; gap: 4px; }

.sub-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.sub-tab {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--trans-fast);
}

.sub-tab:hover { background: var(--bg-elevated); color: var(--text); }
.sub-tab.active { background: var(--secondary-glow); color: var(--secondary); border-color: rgba(167,139,250,0.4); }

/* ── 19. LANDING PAGE ────────────────────────────────────── */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(108,142,245,0.12) 0%, transparent 60%),
                    radial-gradient(ellipse 40% 30% at 80% 80%, rgba(167,139,250,0.08) 0%, transparent 50%);
  padding: var(--space-8);
  position: relative;
  overflow: hidden;
}

.landing::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(108,142,245,0.06) 0%, transparent 70%);
  top: -200px; left: 50%; transform: translateX(-50%);
  pointer-events: none;
}

.landing-header {
  text-align: center;
  margin-bottom: var(--space-10);
  animation: slideUp 0.5s ease;
}

.landing-icon {
  width: 72px; height: 72px;
  background: var(--grad-primary);
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
  margin: 0 auto var(--space-5);
  box-shadow: 0 0 40px var(--primary-glow), 0 0 80px var(--primary-glow-lg);
  animation: glow 3s ease infinite;
}

.landing-title {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.landing-course {
  font-size: 1.8rem;
  font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  margin-bottom: var(--space-2);
}

.landing-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.landing-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  width: 100%;
  max-width: 680px;
  animation: slideUp 0.6s ease 0.1s both;
}

.landing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s, box-shadow 0.3s;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.landing-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--grad-primary);
  opacity: 0;
  transition: opacity 0.3s;
}

.landing-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: var(--primary);
  box-shadow: 0 20px 60px rgba(108,142,245,0.2);
}

.landing-card:hover::before { opacity: 0.04; }

.landing-card .card-emoji {
  font-size: 3.5rem;
  position: relative;
  z-index: 1;
  transition: transform 0.3s;
}

.landing-card:hover .card-emoji { transform: scale(1.1) rotate(-5deg); }

.landing-card-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  position: relative;
  z-index: 1;
}

.landing-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  position: relative;
  z-index: 1;
}

.landing-card-btn {
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(108,142,245,0.3);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-5);
  font-size: 0.85rem;
  font-weight: 700;
  position: relative;
  z-index: 1;
  transition: var(--trans-fast);
}

.landing-card:hover .landing-card-btn {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

/* ── 20. STUDENT VIEW ────────────────────────────────────── */
.student-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  background-image: radial-gradient(ellipse 60% 50% at 50% 0%, rgba(108,142,245,0.1) 0%, transparent 60%);
  padding: var(--space-6);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-xl);
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.login-icon {
  width: 64px; height: 64px;
  background: var(--grad-primary);
  border-radius: var(--radius-xl);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto var(--space-5);
  box-shadow: 0 0 32px var(--primary-glow);
}

.login-title {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.login-subtitle {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: var(--space-8);
}

.error-msg {
  background: var(--danger-bg);
  border: 1px solid rgba(248,113,113,0.3);
  border-radius: var(--radius);
  padding: var(--space-3) var(--space-4);
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: var(--space-4);
  display: none;
}
.error-msg.show { display: flex; align-items: center; gap: var(--space-2); }

/* Unit cards grid */
.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-5);
  margin-top: var(--space-5);
}

.unit-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: var(--trans-normal);
  animation: slideUp 0.3s ease;
}

.unit-card:hover { border-color: var(--border-light); transform: translateY(-2px); box-shadow: var(--shadow); }

.unit-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.unit-card-name { font-weight: 700; font-size: 0.9rem; color: var(--text); }
.unit-card-weight { font-size: 0.75rem; color: var(--text-muted); }

.unit-score-circle {
  position: relative;
  width: 80px; height: 80px;
  margin: 0 auto var(--space-3);
}

.unit-score-circle svg {
  transform: rotate(-90deg);
  width: 80px; height: 80px;
}

.unit-score-circle circle {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
}

.circle-bg   { stroke: var(--bg-elevated); }
.circle-fill { stroke: var(--primary); transition: stroke-dashoffset 1s cubic-bezier(0.34, 1.56, 0.64, 1); }

.unit-score-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
}

/* ── 21. LOADING STATES ──────────────────────────────────── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,13,22,0.8);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border-light) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

.empty-state {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: var(--space-3); }
.empty-state .empty-title { font-size: 1rem; font-weight: 600; color: var(--text-dim); margin-bottom: var(--space-2); }
.empty-state .empty-desc  { font-size: 0.85rem; }

/* ── 22. MISC UTILITIES ──────────────────────────────────── */
.gap-2  { gap: var(--space-2);  }
.gap-3  { gap: var(--space-3);  }
.gap-4  { gap: var(--space-4);  }
.flex   { display: flex;        }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right  { text-align: right;  }
.font-bold   { font-weight: 700;    }
.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim);   }
.text-sm     { font-size: 0.85rem;  }
.text-xs     { font-size: 0.75rem;  }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.divider { border: none; border-top: 1px solid var(--border); margin: var(--space-5) 0; }

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-full);
  padding: 2px 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.rank-1 { color: #fbbf24; font-weight: 800; }
.rank-2 { color: #94a3b8; font-weight: 800; }
.rank-3 { color: #f97316; font-weight: 800; }

/* ── 23. RESPONSIVE ──────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .save-bar { left: 0; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .landing-cards { grid-template-columns: 1fr; max-width: 340px; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .content { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); }
  .stat-cards { grid-template-columns: 1fr; }
  .unit-tabs { flex-wrap: nowrap; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-wrap { max-width: 100%; }
  .landing-course { font-size: 1.3rem; }
  .unit-grid { grid-template-columns: 1fr; }
}

/* ── 24. REPORT PAGE ─────────────────────────────────────── */
.export-section {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.export-card {
  flex: 1;
  min-width: 200px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  transition: var(--trans-normal);
}

.export-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.export-card .export-icon { font-size: 2.5rem; }
.export-card .export-label { font-weight: 700; font-size: 0.95rem; color: var(--text); }
.export-card .export-sub { font-size: 0.75rem; color: var(--text-muted); }

/* Sticky table header fix */
.table-sticky-head { max-height: calc(100vh - 300px); overflow-y: auto; }
.table-sticky-head thead th { position: sticky; top: 0; z-index: 3; }

.score-pct-cell {
  font-weight: 700;
  font-size: 0.85rem;
}
