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

:root {
  --primary: #0066ff;
  --primary-dark: #0052cc;
  --primary-light: #e6f0ff;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --text-main: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 16px 18px;
  border-left: 4px solid var(--primary);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  opacity: 0.08;
}

.kpi-green { border-left-color: #10b981; }
.kpi-green::after { background: #10b981; }
.kpi-blue { border-left-color: #0066ff; }
.kpi-blue::after { background: #0066ff; }
.kpi-purple { border-left-color: #8b5cf6; }
.kpi-purple::after { background: #8b5cf6; }
.kpi-orange { border-left-color: #f59e0b; }
.kpi-orange::after { background: #f59e0b; }
.kpi-cyan { border-left-color: #06b6d4; }
.kpi-cyan::after { background: #06b6d4; }
.kpi-indigo { border-left-color: #6366f1; }
.kpi-indigo::after { background: #6366f1; }

.kpi-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.kpi-icon {
  font-size: 18px;
}

.kpi-label {
  font-size: 13px;
  color: var(--text-light);
  font-weight: 500;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}

.rank-1 { background: #f59e0b; }
.rank-2 { background: #94a3b8; }
.rank-3 { background: #b45309; }
.rank-normal { background: #cbd5e1; color: var(--text-main); }

:root {
  --primary-glow: rgba(0, 102, 255, 0.3);
  --bg: #f0f5ff;
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-solid: #ffffff;
  --text: #0f1b2d;
  --text-light: #5a6c85;
  --border: rgba(0, 102, 255, 0.12);
  --success: #00b364;
  --success-light: #d4f5e3;
  --danger: #ff3b5c;
  --danger-light: #ffe0e6;
  --warning: #ff8800;
  --warning-light: #fff3d6;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0, 30, 100, 0.06);
  --shadow-lg: 0 12px 40px rgba(0, 30, 100, 0.12);
  --glass-blur: blur(12px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

#particleCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

.header {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 20px rgba(0, 102, 255, 0.08);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.5px;
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary) 0%, #00aaff 100%);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  box-shadow: 0 4px 12px var(--primary-glow);
  position: relative;
  overflow: hidden;
}

.logo-icon::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(45deg, transparent, rgba(255,255,255,0.3), transparent);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { transform: rotate(0deg) translate(-100%, -100%); }
  100% { transform: rotate(360deg) translate(-100%, -100%); }
}

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

.user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.user-avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary) 0%, #00aaff 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--card-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 14px;
  position: sticky;
  top: 88px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-light);
  padding: 8px 12px 12px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.25s;
  margin-bottom: 4px;
  position: relative;
  overflow: hidden;
}

.sidebar-item:hover {
  background: var(--primary-light);
  color: var(--primary);
  transform: translateX(3px);
}

.sidebar-item.active {
  background: linear-gradient(135deg, var(--primary) 0%, #00aaff 100%);
  color: white;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.sidebar-item.active .sidebar-item-icon {
  filter: drop-shadow(0 0 4px rgba(255,255,255,0.5));
}

.sidebar-item-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  transition: all 0.25s;
}

.main-content {
  flex: 1;
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card {
  background: var(--card-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
  transition: box-shadow 0.3s;
}

.card:hover {
  box-shadow: 0 4px 20px rgba(0, 102, 255, 0.1);
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  width: 4px;
  height: 18px;
  background: linear-gradient(180deg, var(--primary) 0%, #00aaff 100%);
  border-radius: 2px;
}

.card-body {
  padding: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  background: rgba(230, 240, 255, 0.6);
  padding: 13px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-light);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

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

tr:hover td {
  background: rgba(230, 240, 255, 0.4);
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 600; }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-primary {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(0, 102, 255, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #00aaff 100%);
  color: white;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-success {
  background: linear-gradient(135deg, var(--success) 0%, #00d180 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 179, 100, 0.3);
}

.btn-success:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 179, 100, 0.3);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #ff6b8a 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(255, 59, 92, 0.3);
}

.btn-danger:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(255, 59, 92, 0.3);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.input, .select {
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: all 0.25s;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
}

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

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 20, 50, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--card-solid);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 440px;
  overflow: hidden;
  border: 1px solid var(--border);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

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

.modal-title {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

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

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

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: all 0.25s;
  background: rgba(255, 255, 255, 0.9);
}

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

.error-msg {
  color: var(--danger);
  font-size: 14px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--danger-light);
  border-radius: 8px;
  border: 1px solid rgba(255, 59, 92, 0.2);
}

.success-msg {
  color: var(--success);
  font-size: 14px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--success-light);
  border-radius: 8px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--border);
}

.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.25s;
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-light);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-info {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid rgba(0, 102, 255, 0.15);
}

.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #cbd5e1;
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--primary) 0%, #00aaff 100%);
}

.toggle input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

.input-edit {
  width: 90px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  text-align: center;
  transition: all 0.25s;
  background: rgba(255, 255, 255, 0.9);
}

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

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #001a3d 0%, #003366 50%, #0066cc 100%);
  position: relative;
}

.login-page::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 20% 50%, rgba(0, 102, 255, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(0, 170, 255, 0.1) 0%, transparent 50%);
}

.login-box {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 40px rgba(0, 102, 255, 0.15);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  position: relative;
  z-index: 1;
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text);
  background: linear-gradient(135deg, var(--primary) 0%, #00aaff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 32px;
  font-size: 14px;
}

.login-btn {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  margin-top: 8px;
}

.group-section {
  margin-bottom: 24px;
}

.group-section-title {
  font-size: 15px;
  font-weight: 600;
  color: white;
  padding: 12px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, #00aaff 100%);
  border-radius: 10px;
  margin-bottom: 8px;
  box-shadow: 0 2px 8px var(--primary-glow);
}

@media (max-width: 768px) {
  .container { padding: 16px; }
  .header { padding: 0 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  table { font-size: 13px; }
  th, td { padding: 8px 10px; }
  .modal { max-width: 100%; }
  .layout { flex-direction: column; }
  .sidebar { width: 100%; position: static; }
  .sidebar-item { display: inline-flex; margin-right: 4px; }
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--card-solid, #fff);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  min-width: 140px;
  z-index: 999;
  margin-top: 4px;
}

.user-dropdown-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s;
}

.user-dropdown-item:first-child {
  border-radius: 8px 8px 0 0;
}

.user-dropdown-item:last-child {
  border-radius: 0 0 8px 8px;
}

.user-dropdown-item:hover {
  background: var(--primary-light, #e6f0ff);
}

.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-light);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 22px;
  border-radius: 10px;
  color: white;
  font-size: 14px;
  z-index: 2000;
  animation: toastIn 0.3s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.toast-success {
  background: linear-gradient(135deg, var(--success) 0%, #00d180 100%);
}

.toast-error {
  background: linear-gradient(135deg, var(--danger) 0%, #ff6b8a 100%);
}

@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
