:root {
  --primary: #4f46e5;
  --primary-hover: #3730a3;
  --primary-light: #e0e7ff;
  --accent: #06b6d4;
  --accent-hover: #0891b2;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-bg: #fef2f2;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --dark: #1e293b;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --white: #ffffff;
  --card-bg: #ffffff;
  --body-bg: #f8fafc;
  --text-color: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --input-bg: #ffffff;
  --table-header-bg: #f1f5f9;
  --table-hover-bg: #f8fafc;
  --popup-bg: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.06), 0 4px 10px rgba(0, 0, 0, 0.04);
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --transition: 200ms ease;
}

[data-theme="dark"] {
  --primary: #818cf8;
  --primary-hover: #6366f1;
  --primary-light: #1e1b4b;
  --accent: #22d3ee;
  --accent-hover: #06b6d4;
  --danger: #f87171;
  --danger-hover: #ef4444;
  --danger-bg: #3b1111;
  --success: #34d399;
  --success-bg: #0a2e1d;
  --warning: #fbbf24;
  --dark: #e2e8f0;
  --gray-50: #0f172a;
  --gray-100: #1e293b;
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-400: #64748b;
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --gray-800: #f1f5f9;
  --white: #1e293b;
  --card-bg: #1e293b;
  --body-bg: #0f172a;
  --text-color: #e2e8f0;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --input-bg: #0f172a;
  --table-header-bg: #1e293b;
  --table-hover-bg: #1e293b;
  --popup-bg: #1e293b;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5), 0 4px 10px rgba(0, 0, 0, 0.3);
}

.theme-toggle-wrapper {
  padding: 0.75rem 0.8rem;
  display: flex;
  justify-content: flex-start;
}

[data-theme="dark"] .theme-toggle-wrapper {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.theme-toggle-wrapper:not([data-theme="dark"]) {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.theme-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #ffffff;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

@media (min-width: 641px) {
  .theme-toggle-wrapper {
    position: absolute;
    bottom: 0.1rem;
    left: 0;
    right: 0;
    padding: 0.75rem 0.8rem;
    border-top: none;
  }
}

@media (max-width: 640px) {
  .theme-toggle-wrapper {
    padding: 0.5rem 0.8rem 1rem;
    justify-content: center;
  }

  .theme-toggle {
    width: 100%;
    justify-content: center;
    padding: 0.6rem 0.9rem;
    font-size: 1rem;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: var(--body-bg);
  color: var(--text-color);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  background: var(--body-bg);
}

.content {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.sidebar {
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
}

[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, #0f0f2e 0%, #1a1040 50%, #1e1b4b 100%);
}

.top-row {
  background: rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.2rem;
}

.navbar-brand {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff !important;
  text-decoration: none;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.navbar-brand::before {
  content: "🎯";
  font-size: 1.2rem;
}

.navbar-toggler {
  display: none;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #ffffff;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.nav-item {
  padding: 0.15rem 0.8rem;
}

.nav-item:first-of-type {
  padding-top: 1rem;
}

.nav-link {
  color: rgba(255, 255, 255, 0.85) !important;
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  text-decoration: none !important;
  font-weight: 500;
  font-size: 0.93rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: all var(--transition);
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff !important;
  transform: translateX(3px);
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.22);
  color: #ffffff !important;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  border-left: 3px solid var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

[data-theme="dark"] .btn-primary {
  box-shadow: 0 2px 8px rgba(129, 140, 248, 0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, #4f46e5 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
}

[data-theme="dark"] .btn-primary:hover {
  box-shadow: 0 4px 14px rgba(129, 140, 248, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #f87171 100%);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .btn-danger {
  box-shadow: 0 2px 8px rgba(248, 113, 113, 0.25);
}

.btn-danger:hover {
  background: linear-gradient(135deg, var(--danger-hover) 0%, #ef4444 100%);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

[data-theme="dark"] .btn-danger:hover {
  box-shadow: 0 4px 14px rgba(248, 113, 113, 0.35);
}

.btn-outline {
  background: var(--card-bg);
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  min-width: 2rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.form-input {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text-color);
  background: var(--input-bg);
  transition: all var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-input::placeholder {
  color: var(--gray-400);
}

.form-select {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  color: var(--text-color);
  background: var(--input-bg);
  transition: all var(--transition);
  outline: none;
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
}

.card-header {
  background: linear-gradient(135deg, var(--primary-light) 0%, #c7d2fe 100%);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

[data-theme="dark"] .card-header {
  background: linear-gradient(135deg, var(--primary-light) 0%, #2d2a6e 100%);
}

.card-header h2,
.card-header h3 {
  margin: 0;
  color: var(--primary-hover);
  font-weight: 700;
}

.card-body {
  padding: 1.5rem;
}

.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card-bg);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table th {
  background: var(--primary-light);
  color: var(--primary-hover);
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.9rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--primary);
}

table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-color);
}

table tbody tr:hover {
  background: var(--table-hover-bg);
}

table tbody tr:last-child td {
  border-bottom: none;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  margin-bottom: 1rem;
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid #fecaca;
}

[data-theme="dark"] .alert-danger {
  border-color: #991b1b;
}

.alert-success {
  background: var(--success-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

[data-theme="dark"] .alert-success {
  color: #34d399;
  border-color: #065f46;
}

.popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

[data-theme="dark"] .popup-backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.popup-box {
  background: var(--popup-bg);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
}

[data-theme="dark"] .popup-box {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.popup-box h3 {
  margin: 0 0 1rem;
  color: var(--text-color);
  font-size: 1.5rem;
}

.popup-box h4 {
  margin: 0 0 0.5rem;
  color: var(--text-color);
}

.popup-box p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.winner-box {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  border: 2px solid var(--warning);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

[data-theme="dark"] .winner-box {
  background: linear-gradient(135deg, #78350f 0%, #92400e 100%);
  border-color: var(--warning);
}

.winner-box h4 {
  color: #92400e;
  margin: 0 0 0.5rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

[data-theme="dark"] .winner-box h4 {
  color: #fcd34d;
}

.winner-name {
  font-size: 2rem;
  font-weight: 800;
  color: #92400e;
  margin: 0;
}

[data-theme="dark"] .winner-name {
  color: #fde68a;
}

.home-hero {
  text-align: center;
  padding: 3rem 2rem;
}

.home-hero h1 {
  font-size: 2.8rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin: 0 0 1rem;
}

.home-hero p {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 500px;
  margin: 0 auto 2rem;
}

.home-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
}

.feature-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  transition:
    transform var(--transition),
    box-shadow var(--transition);
}

.feature-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.feature-card .icon {
  font-size: 2.5rem;
  margin-bottom: 0.8rem;
}

.feature-card h3 {
  color: var(--text-color);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.feature-card p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading-progress {
  position: absolute;
  display: block;
  width: 8rem;
  height: 8rem;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.loading-progress circle {
  fill: none;
  stroke: var(--gray-200);
  stroke-width: 0.4rem;
  transform-origin: 50% 50%;
  stroke-dasharray: 251.2;
  stroke-dashoffset: 251.2;
}

.loading-progress circle:first-child {
  animation: loadingSpin 1.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.loading-progress circle:last-child {
  stroke: var(--primary);
  animation: loadingProgress 3.2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

[data-theme="dark"] .loading-progress circle {
  stroke: var(--gray-300);
}

[data-theme="dark"] .loading-progress circle:last-child {
  stroke: var(--primary);
}

@keyframes loadingSpin {
  100% {
    transform: rotate(360deg);
  }
}

@keyframes loadingProgress {
  0% {
    stroke-dashoffset: 251.2;
  }
  50% {
    stroke-dashoffset: 50.24;
  }
  100% {
    stroke-dashoffset: 251.2;
  }
}

.global-spinner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: globalFadeIn 0.15s ease;
}

.global-spinner {
  width: 52px;
  height: 52px;
  border: 5px solid rgba(255, 255, 255, 0.25);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: globalSpin 0.7s linear infinite;
}

.global-spinner-text {
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 1rem;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

@keyframes globalSpin {
  to { transform: rotate(360deg); }
}

@keyframes globalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

#blazor-error-ui {
  display: none;
  background: #fef2f2;
  bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  position: fixed;
  width: 100%;
  padding: 0.8rem 1.25rem;
  z-index: 1001;
  color: var(--danger);
  font-weight: 500;
  border-top: 2px solid var(--danger);
}

[data-theme="dark"] #blazor-error-ui {
  background: #3b1111;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.6);
}

#blazor-error-ui .dismiss {
  cursor: pointer;
  position: absolute;
  right: 0.75rem;
  top: 0.5rem;
  font-size: 1.2rem;
  color: var(--gray-400);
}

#blazor-error-ui .reload {
  color: var(--primary);
  font-weight: 600;
  margin-left: 0.5rem;
}

@media (max-width: 640px) {
  .content {
    padding: 1rem;
  }

  .home-hero h1 {
    font-size: 2rem;
  }

  .popup-box {
    padding: 1.5rem;
    margin: 1rem;
  }

  .top-row {
    justify-content: space-between;
  }

  .navbar-toggler {
    display: block;
  }
}

@media (min-width: 641px) {
  .page {
    flex-direction: row;
  }

  .sidebar {
    width: 260px;
    height: 100vh;
    position: sticky;
    top: 0;
  }

  .top-row {
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .navbar-toggler {
    display: none;
  }

  .nav-scrollable {
    height: calc(100vh - 4rem);
    overflow-y: auto;
  }
}
