:root {
  --sidebar-width: 240px;
  --sidebar-bg: #1e293b;
  --body-bg: #f1f5f9;
}

body {
  background: var(--body-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
}

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

#sidebar .nav-link {
  font-size: 0.9rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  transition: background 0.15s;
}

#sidebar .nav-link:hover {
  background: rgba(255,255,255,0.08);
}

#sidebar .nav-link.text-white {
  background: rgba(255,255,255,0.1);
}

.sidebar-header {
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* Main content */
#main {
  margin-left: var(--sidebar-width);
  padding: 24px 32px;
  min-height: 100vh;
}

/* Dashboard cards */
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  border: 1px solid #e2e8f0;
  transition: box-shadow 0.15s;
}

.stat-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.stat-card .stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: #1e293b;
}

.stat-card .stat-label {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 4px;
}

.stat-card .stat-icon {
  font-size: 1.5rem;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

/* Table */
.table-wrapper {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

.table-wrapper .table {
  margin-bottom: 0;
}

.table-wrapper .table th {
  background: #f8fafc;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.table-wrapper .table td {
  font-size: 0.9rem;
  vertical-align: middle;
}

/* Badges */
.badge-teacher {
  background: #f59e0b;
  color: #000;
}

.badge-student {
  background: #3b82f6;
  color: #fff;
}

/* Page header */
.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  font-weight: 700;
  font-size: 1.5rem;
  color: #1e293b;
  margin-bottom: 4px;
}

.page-header p {
  color: #64748b;
  font-size: 0.9rem;
  margin: 0;
}

/* Password reveal */
.pwd-cell {
  cursor: pointer;
  user-select: none;
}

.pwd-cell .pwd-mask {
  color: #94a3b8;
}

/* Form card */
.form-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 28px;
}

/* Result table after bulk create */
.result-table {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 20px;
  margin-top: 20px;
}

/* Login page */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card h2 {
  font-weight: 700;
  margin-bottom: 8px;
}

.login-card .subtitle {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* Loading */
.loading-spinner {
  display: flex;
  justify-content: center;
  padding: 40px;
}

/* Alert */
.alert-float {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  min-width: 300px;
}

/* Topup record sub-row */
.topup-row {
  background: #f8fafc !important;
}

.topup-inner {
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e2e8f0;
  padding: 12px;
}

.topup-inner .table th {
  background: #f1f5f9;
  font-size: 0.78rem;
  color: #475569;
}

.topup-inner .table td {
  font-size: 0.83rem;
}

/* Responsive */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s;
  }
  #sidebar.show {
    transform: translateX(0);
  }
  #main {
    margin-left: 0;
    padding: 16px;
  }
}
